Example #1
0
def get_typedefs_to_template(shared_vars,ast):
    """ Build a list with all type declarations for the shared var array """
    decls_dict = {}
    param_var_list = []
    for elem in shared_vars:
        try:
            identifier_type = IdentifierTypeFilter().apply(elem.type)
            if not identifier_type.names[0] in decls_dict:
                typedef_node = TypedefFilter(name = identifier_type.names[0]).apply(ast)
                # TODO: Avoid construction/destruction
                typedefIO = cStringIO.StringIO()
                cw = CWriter(stream = typedefIO)
                cw.visit(typedef_node)
                decls_dict[identifier_type.names[0]] = str(typedefIO.getvalue())
        except NodeNotFound as nnf:
            # It is not a complex type
#                print " Not a userdefined-type " + elem[1]
#                structIO = cStringIO.StringIO()
#                cw = CWriter(stream = structIO)
#                cw.visit(elem[3])
#                param_var_list.append(str(structIO.getvalue()).replace(';','') )
            pass

    return [elem for elem in decls_dict.values()]
Example #2
0
 def fast_write(self, elem):
     writeIO = cStringIO.StringIO()
     cw = CWriter(stream = writeIO)
     cw.visit(elem)
     return writeIO.getvalue()