示例#1
0
文件: code.py 项目: tsmarques/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
示例#2
0
文件: code.py 项目: 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
示例#3
0
文件: code.py 项目: tsmarques/dune
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s' % self._data
示例#4
0
文件: code.py 项目: tsmarques/dune
 def as_decl(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s;' % self._data
示例#5
0
文件: code.py 项目: tsmarques/dune
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '#define %(name)s %(value)s' % self._data
示例#6
0
文件: code.py 项目: tsmarques/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
示例#7
0
文件: file.py 项目: 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()
示例#8
0
文件: code.py 项目: 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
示例#9
0
文件: code.py 项目: LSTS/dune
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s' % self._data
示例#10
0
文件: code.py 项目: LSTS/dune
 def as_decl(self):
     return utils.comment(self._data['desc']) + \
            '%(type)s %(name)s;' % self._data
示例#11
0
文件: code.py 项目: LSTS/dune
 def __str__(self):
     return utils.comment(self._data['desc']) + \
            '#define %(name)s %(value)s' % self._data
示例#12
0
文件: file.py 项目: tucuongbrt/dune
    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()