Esempio n. 1
0
    def write_object(self, object_, flags):

        out = Writer.write_object(self, object_, flags)

        if flags == FLAG_HPP:
            out[flags] += self.build_type_str(object_) + ';\n'

        if flags == FLAG_CPP:
            if object_.is_static:
                if object_.initial_value is None and self._current_class.type != 'enum':
                    Error.exit(Error.STATIS_MEMBER_SHOULD_HAVE_INITIALISATION,
                               self._current_class.name, object_.name)
                if self._current_class.type == 'enum':
                    pattern = '{4}{0} {2}::{1}'
                else:
                    pattern = '{4}{0} {2}::{1} = {3}'
                pattern += ';\n'
                modifier = ''
                if object_.is_const:
                    modifier = 'const '
                out[flags] += pattern.format(convert_type(object_.type),
                                             object_.name,
                                             self._current_class.name,
                                             object_.initial_value, modifier)
                pass
        return out