Example #1
0
 def __str__(self):
     out = utils.comment(self._desc)
     out += 'struct ' + self._name + '\n'
     out += '{\n'
     out += ';\n'.join([str(f) for f in self._fields]) + ';\n'
     out += '};\n'
     return out
Example #2
0
File: code.py Project: LSTS/dune
 def __str__(self):
     out = utils.comment(self._desc)
     out += 'struct ' + self._name + '\n'
     out += '{\n'
     out += ';\n'.join([str(f) for f in self._fields]) + ';\n'
     out += '};\n'
     return out
Example #3
0
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s' % self._data
Example #4
0
 def as_decl(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s;' % self._data
Example #5
0
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '#define %(name)s %(value)s' % self._data
Example #6
0
 def __str__(self):
     if self._data['value'] == '':
         return utils.comment(self._data['desc']) + \
                '%(name)s' % self._data
     return utils.comment(self._data['desc']) + \
            '%(name)s = %(value)s' % self._data
Example #7
0
File: file.py Project: Aero348/dune
    def write(self):
        print('* ' + self.path)
        text = utils.get_cxx_copyright() + '\n'
        if self.path_ext == '.hpp':
            if type(self._ns) is list:
                prefix = ('_'.join(self._ns)).upper()
            else:
                prefix = 'DUNE_IMC'
            guard = prefix + '_' + self.name.upper() + '_HPP_INCLUDED_'
            text += '#ifndef ' + guard + '\n'
            text += '#define ' + guard + '\n\n'

        if len(self.isoc_hdrs) > 0:
            text += utils.comment('ISO C++ 98 headers', dox = False)
            for hdr in self.isoc_hdrs:
                text += '#include <' + hdr + '>\n'
            text += '\n'

        if len(self.dune_hdrs) > 0:
            text += utils.comment('DUNE headers', dox = False)
            for hdr in self.dune_hdrs:
                text += '#include <' + hdr + '>\n'
            text += '\n'

        if self._ns:
            if type(self._ns) is list:
                for ns in self._ns:
                    text += 'namespace %s\n{\n' % ns
            else:
                text += 'namespace DUNE\n{\n'
                text += 'namespace IMC\n{\n'

        text += self.text

        if self._ns:
            if type(self._ns) is list:
                for ns in self._ns:
                    text += '}\n'
            else:
                text += '}\n'
                text += '}\n'

        if self.path_ext == '.hpp':
            text += '\n#endif'

        text += '\n'
        new_text = utils.beautify(text)
        try:
            old_text = open(self.path).read()
        except:
            old_text = ''

        if self._stdout:
            import sys
            sys.stdout.write(new_text)
            return

        if new_text != old_text:
            fd = open(self.path, 'w')
            fd.write(new_text)
            fd.close()
Example #8
0
File: code.py Project: LSTS/dune
 def __str__(self):
     if self._data['value'] == '':
         return utils.comment(self._data['desc']) + \
                '%(name)s' % self._data
     return utils.comment(self._data['desc']) + \
            '%(name)s = %(value)s' % self._data
Example #9
0
File: code.py Project: LSTS/dune
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s' % self._data
Example #10
0
File: code.py Project: LSTS/dune
 def as_decl(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s;' % self._data
Example #11
0
File: code.py Project: LSTS/dune
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '#define %(name)s %(value)s' % self._data
Example #12
0
    def write(self):
        print('* ' + self.path)
        text = utils.get_cxx_copyright(self.md5, self._skip_md5) + '\n'
        if self.path_ext == '.hpp':
            if type(self._ns) is list:
                prefix = ('_'.join(self._ns)).upper()
            else:
                prefix = 'DUNE_IMC'
            guard = prefix + '_' + self.name.upper() + '_HPP_INCLUDED_'
            text += '#ifndef ' + guard + '\n'
            text += '#define ' + guard + '\n\n'

        if len(self.isoc_hdrs) > 0:
            text += utils.comment('ISO C++ 98 headers', dox=False)
            for hdr in self.isoc_hdrs:
                text += '#include <' + hdr + '>\n'
            text += '\n'

        if len(self.dune_hdrs) > 0:
            text += utils.comment('DUNE headers', dox=False)
            for hdr in self.dune_hdrs:
                text += '#include <' + hdr + '>\n'
            text += '\n'

        if self._ns:
            if type(self._ns) is list:
                for ns in self._ns:
                    text += 'namespace %s\n{\n' % ns
            else:
                text += 'namespace DUNE\n{\n'
                text += 'namespace IMC\n{\n'

        text += self.text

        if self._ns:
            if type(self._ns) is list:
                for ns in self._ns:
                    text += '}\n'
            else:
                text += '}\n'
                text += '}\n'

        if self.path_ext == '.hpp':
            text += '\n#endif'

        text += '\n'
        new_text = utils.beautify(text)
        try:
            old_text = open(self.path).read()
        except:
            old_text = ''

        if self._stdout:
            import sys
            sys.stdout.write(new_text)
            return

        if new_text != old_text:
            fd = open(self.path, 'w')
            fd.write(new_text)
            fd.close()