From: <sv...@ww...> - 2004-11-14 17:21:54
|
Author: mkrose Date: 2004-11-14 09:21:46 -0800 (Sun, 14 Nov 2004) New Revision: 1307 Modified: trunk/CSP/SimData/CHANGES.current trunk/CSP/SimData/Include/SimData/Timing.h trunk/CSP/SimData/SConscript trunk/CSP/SimData/Tools/TaggedRecordCompiler/BaseTypes.py trunk/CSP/SimData/Tools/TaggedRecordCompiler/trc.py Log: Added a method to Timer to both return and reset the elapsed time. Set the SWIG_STD_BACKWARD_COMP flag to the Scons script to fix the build under Swig 1.3.22. Added message id generation to the tagged record compiler. Also inlined several of the generated methods. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1307 Modified: trunk/CSP/SimData/CHANGES.current =================================================================== --- trunk/CSP/SimData/CHANGES.current 2004-11-14 10:20:16 UTC (rev 1306) +++ trunk/CSP/SimData/CHANGES.current 2004-11-14 17:21:46 UTC (rev 1307) @@ -1,12 +1,21 @@ Version 0.4.0 (in progress) =========================== +2004-11-14: onsight +* Added a method to Timer to both return and reset the elapsed time. + +* Set the SWIG_STD_BACKWARD_COMP flag to the Scons script to fix the + build under Swig 1.3.22. + +* Added message id generation to the tagged record compiler. Also + inlined several of the generated methods. + 2004-11-11: delta * Added SWIG_STD_BACKWARD_COMP to the swig command line in SimData.vcproj for swig 1.3.22. - + * Added a few pragmas for insignificant warnings. - + 2004-11-10: onsight * Another bug fix in Parse.py, this time for TableN types. Prevents spurious complaints about missing required fields. Modified: trunk/CSP/SimData/Include/SimData/Timing.h =================================================================== --- trunk/CSP/SimData/Include/SimData/Timing.h 2004-11-14 10:20:16 UTC (rev 1306) +++ trunk/CSP/SimData/Include/SimData/Timing.h 2004-11-14 17:21:46 UTC (rev 1307) @@ -107,13 +107,29 @@ return (_running ? get_realtime() - _start + _elapsed : _elapsed); } - /// Reset the elapsed time to zero (does not stop the timer). + /** Reset the elapsed time to zero (does not stop the timer). + */ inline void reset() { if (_running) { _start = get_realtime(); } _elapsed = 0; } + + /** Return the elapsed time and reset the timer to zero (does not + * stop the timer). + */ + inline timing_t incremental() { + timing_t elapsed = _elapsed; + _elapsed = 0; + if (_running) { + timing_t start = _start; + _start = get_realtime(); + elapsed += (_start - start); + } + return elapsed; + } + }; Modified: trunk/CSP/SimData/SConscript =================================================================== --- trunk/CSP/SimData/SConscript 2004-11-14 10:20:16 UTC (rev 1306) +++ trunk/CSP/SimData/SConscript 2004-11-14 17:21:46 UTC (rev 1307) @@ -18,7 +18,7 @@ Import('env build') -SWIGFLAGS = '-runtime -noexcept -python -c++' +SWIGFLAGS = '-runtime -noexcept -python -c++ -DSWIG_STD_BACKWARD_COMP' SHLIBS = ['dl', 'pthread'] MODULES = ['Source', 'SimData/Tests'] Modified: trunk/CSP/SimData/Tools/TaggedRecordCompiler/BaseTypes.py =================================================================== --- trunk/CSP/SimData/Tools/TaggedRecordCompiler/BaseTypes.py 2004-11-14 10:20:16 UTC (rev 1306) +++ trunk/CSP/SimData/Tools/TaggedRecordCompiler/BaseTypes.py 2004-11-14 17:21:46 UTC (rev 1307) @@ -71,7 +71,7 @@ format.write(text) def dump_clear(self, format): - format.write('void clear_%s() { m_has_%s = 0; }' % (self.id, self.id)) + format.write('inline void clear_%s() { m_has_%s = 0; }' % (self.id, self.id)) def init(self): pass def dump_private(self, format): assert 0 @@ -170,7 +170,7 @@ format.write('}') format.write() for element in self.elements: - format.write('bool has_%s() const { return m_has_%s; }' % (element.id, element.id)) + format.write('inline bool has_%s() const { return m_has_%s; }' % (element.id, element.id)) element.dump_clear(format) format.write() for element in self.elements: @@ -304,7 +304,7 @@ def dump_get(self, format): type = self.typename() id = self.id - format.write('%s const & %s() const { return m_%s; }' % (type, id, id)) + format.write('inline %s const & %s() const { return m_%s; }' % (type, id, id)) def dump_set(self, format): if self.isDeprecated(): return @@ -366,7 +366,7 @@ type = self.child.fulltype() id = self.id name = self.varname() - format.write('std::vector< %s > const & %s() const { return %s; }' % (type, id, name)) + format.write('inline std::vector< %s > const & %s() const { return %s; }' % (type, id, name)) def dump_set(self, format): if self.isDeprecated(): return @@ -631,6 +631,10 @@ class t_int32(TrfType): TYPENAME = 'int32' class t_int16(TrfType): TYPENAME = 'int16' class t_int8(TrfType): TYPENAME = 'int8' +class t_uint64(TrfType): TYPENAME = 'uint64' +class t_uint32(TrfType): TYPENAME = 'uint32' +class t_uint16(TrfType): TYPENAME = 'uint16' +class t_uint8(TrfType): TYPENAME = 'uint8' class t_string(SimpleType): TYPENAME = 'std::string' @@ -658,6 +662,10 @@ t_int32, t_int16, t_int8, + t_uint64, + t_uint32, + t_uint16, + t_uint8, t_bool, t_string, ]) Modified: trunk/CSP/SimData/Tools/TaggedRecordCompiler/trc.py =================================================================== --- trunk/CSP/SimData/Tools/TaggedRecordCompiler/trc.py 2004-11-14 10:20:16 UTC (rev 1306) +++ trunk/CSP/SimData/Tools/TaggedRecordCompiler/trc.py 2004-11-14 17:21:46 UTC (rev 1307) @@ -92,25 +92,34 @@ includes = [] namespace = '' include_as = '"%s"' % os.path.basename(self._header) + id_base = None + default_base = None header = 1 for line in file: line_number = line_number + 1 trim = line.strip() if not trim: continue - if header and trim.startswith('#include'): - includes.append(trim) - continue - if header and trim.startswith('#header'): - include_as = trim[7:].strip() - continue - if header and trim.startswith('namespace'): - m = DataPackCompiler.re_ns.match(trim) - if m: - if namespace: self.error('multiple namespace declarations') - namespace = m.groups(1) + if header: + if trim.startswith('#include'): + includes.append(trim) continue - else: - self.error('syntax error') + if trim.startswith('#header'): + include_as = trim[7:].strip() + continue + if trim.startswith('#message '): + default_base = trim[8:].strip() + continue + if trim.startswith('#idbase '): + id_base = int(trim[7:]) + continue + if trim.startswith('namespace'): + m = DataPackCompiler.re_ns.match(trim) + if m: + if namespace: self.error('multiple namespace declarations') + namespace = m.groups(1) + continue + else: + self.error('syntax error') if trim.startswith('//'): continue idx = trim.rfind('//') @@ -161,6 +170,15 @@ for option_pair in option_list: option, value = option_pair.split('=') options[option] = value + else: + options = {} + if type_class.TOPLEVEL: + if default_base: + options.setdefault('BASE', default_base) + if id_base is not None and type_class.TOPLEVEL: + if not options.has_key('ID'): + options['ID'] = str(id_base) + id_base += 1 if array: object = BaseTypes.ArrayType(id, type_class, opts=options) else: |