return None def add_array(self, a, comment, add_fn, sz_width = 8): return None def add_symbol(self, symbol): name = symbol.get_name() value = symbol.get_value() if not self.__allow_multi: old = self.__symbols.get(name) if old == None: self.__symbols[name] = value elif old != value: raise Exception("different values ('%s' vs. '%s') for symbol '%s'" % (old, value, name)) else: return None return C._Symbol(symbol) def create_block(self, parent, comment): if self.__allow_block or parent == None: return C._Block(parent, comment) else: return None if __name__ == '__main__': cfac = CodeFactory() generator._test(cfac)
class _Comment(generator.CodeObject): def __init__(self): generator.CodeObject.__init__(self, None) def emit(self, lvl = 0, print_comment = True): return b'' def __init__(self, endian): assert(isinstance(endian, Endianess)) self.__endian = endian def _add_int(self, v, comment, width, is_signed, fmt = None): return CodeFactory._Int(v, width, is_signed, self.__endian) def add_string(self, s, comment): return CodeFactory._String(s, self.__endian) def add_comment(self, comment): return CodeFactory._Comment() def add_symbol(self, symbol): return None def create_block(self, parent, comment): return None if __name__ == '__main__': generator._test(CodeFactory(LITTLE_ENDIAN)) generator._test(CodeFactory(BIG_ENDIAN))