def run(tree): if config.state['Fragment']: # build the defs file defs_filename = config.state['Basename'] +\ config.state['_DEFS Fragment'] +\ config.state['HH Suffix'] defs_stream = output.Stream(output.createFile(defs_filename), 2) defs_fragment(defs_stream, tree) # build the opers file opers_filename = config.state['Basename'] +\ config.state['_OPERS Fragment'] +\ config.state['HH Suffix'] opers_stream = output.Stream(output.createFile(opers_filename), 2) opers_fragment(opers_stream, tree) # build the poa file poa_filename = config.state['Basename'] +\ config.state['_POA Fragment'] +\ config.state['HH Suffix'] poa_stream = output.Stream(output.createFile(poa_filename), 2) poa_fragment(poa_stream, tree) defs_stream.close() opers_stream.close() poa_stream.close() else: # build the full header file header_filename = config.state['Basename'] +\ config.state['HH Suffix'] stream = output.Stream(output.createFile(header_filename), 2) # generate one big chunk of header monolithic(stream, tree) stream.close()
def run(tree): # create somewhere to put the output header_filename = config.state["Basename"] + config.state["DYNSK Suffix"] stream = output.Stream(output.createFile(header_filename), 2) generate(stream, tree) stream.close()
def run(tree): # create somewhere to put the output header_filename = config.state['Basename'] +\ config.state['DYNSK Suffix'] stream = output.Stream(output.createFile(header_filename), 2) generate(stream, tree) stream.close()
def run(tree): hh_filename = config.state['Basename'] + config.state['HH Suffix'] idl_filename = tree.file() impl_filename = config.state['Basename'] + config.state['IMPL Suffix'] stream = output.Stream(output.createFile(impl_filename), 2) main.init(stream, idl_filename, hh_filename) main.run(tree) stream.close()
def run(tree): hh_filename = config.state['Basename'] + config.state['HH Suffix'] idl_filename = tree.file() impl_filename = config.state['Basename'] + config.state['IMPL Suffix'] stream = output.Stream(output.createFile(impl_filename), 2) main.__init__(stream, idl_filename, hh_filename) main.run(tree) stream.close()
def run(tree): # create somewhere to put the output skel_filename = config.state['Basename'] +\ config.state['SK Suffix'] stream = output.Stream(output.createFile(skel_filename), 2) if config.state['Fragment']: fragment(stream, tree) else: # generate one big chunk of code monolithic(stream, tree) stream.close()
def __init__(idl_filename, impl_basename, skel_filename, \ suffix = "_impl", ignore_op = [], fd_h = None, fd_cpp = None): self.idl_filename = idl_filename self.suffix = suffix self.impl_h_filename = impl_basename + self.suffix + ".h" self.impl_cpp_filename = impl_basename + self.suffix + ".cpp" self.skel_filename = skel_filename self.ignore_op = ignore_op self.include_guard = self.impl_h_filename.upper().replace(".","_") if fd_h == None: self.stream_h = \ output.Stream(output.createFile(self.impl_h_filename), 2) else: self.stream_h = output.Stream(fd_h, 2) if fd_cpp == None: self.stream_cpp = \ output.Stream(output.createFile(self.impl_cpp_filename), 2) else: self.stream_cpp = output.Stream(fd_cpp, 2)
def run(tree, backend_args): # Process arguments dirname, filename = os.path.split(tree.file()) basename,ext = os.path.splitext(filename) config.state['Basename'] = basename config.state['Directory'] = dirname process_args(backend_args) try: # Check the input tree only contains stuff we understand support.checkIDL(tree) # initialise the handy ast module ast.__init__(tree) # Initialise the descriptor generating code descriptor.__init__(tree) # Build the map of AST nodes to Environments tree.accept(id.WalkTree()) hh_filename = config.state['Basename'] + config.state['HH Suffix'] hpp_filename = config.state['Basename'] + config.state['HPP Suffix'] hxx_filename = config.state['Basename'] + config.state['HXX Suffix'] cc_filename = config.state['Basename'] + config.state['CC Suffix'] if config.state["Include Prefix"]: prefix = config.state['Include Prefix'] + '/' else: prefix = "" idl_filename = tree.file() hpp_stream = output.Stream(output.createFile(hpp_filename), 2) hxx_stream = output.Stream(output.createFile(hxx_filename), 2) cc_stream = output.Stream(output.createFile( cc_filename), 2) main.self = main main.__init__(hpp_stream, hxx_stream, cc_stream, idl_filename, prefix, hh_filename, hpp_filename, hxx_filename) main.run(tree) hpp_stream .close() hxx_stream.close() cc_stream .close() except AttributeError as e: name = e.args[0] unsupported_visitors = map(lambda x:"visit" + x, AST_unsupported_nodes[:]) if name in unsupported_visitors: # delete all possibly partial output files for file in output.listAllCreatedFiles(): os.unlink(file) util.unsupportedIDL() raise except SystemExit as e: # fatalError function throws SystemExit exception # delete all possibly partial output files for file in output.listAllCreatedFiles(): os.unlink(file) raise
def visitModule(self, node): if not node.mainFile(): return # Output the interface header st = output.Stream(output.createFile(node.identifier() + ".h"), 2) self.outputGenCode(st) st.out("#ifndef __@nsu@_H__", nsu = node.identifier().upper()) st.out("#define __@nsu@_H__\n", nsu = node.identifier().upper()) st.out("#include \"message-buffer.h\"\n"); st.out("#include <linux/types.h>\n"); for f in self.includefiles: st.out("#include \"@fn@\"", fn = string.replace(f, ".idl", ".h")) st.out("") st.inc_indent() visitor = CxxTypeDeclVisitor(st) for n in node.definitions(): n.accept(visitor) visitor = CxxInterfaceHeaderVisitor(st) for n in node.definitions(): n.accept(visitor) st.dec_indent() st.out("#endif // __@nsu@_H__\n", nsu = node.identifier().upper()) st.close() # Output the unmarshal header st = output.Stream(output.createFile(node.identifier() + "_unmarshal.h"), 2) self.outputGenCode(st) st.out("#ifndef __@nsu@_UNMARSHAL_H__", nsu = node.identifier().upper()) st.out("#define __@nsu@_UNMARSHAL_H__\n", nsu = node.identifier().upper()) st.out("#include \"message-buffer.h\"\n") st.out("#include \"AvbDefs.h\"\n") st.out("#include <linux/types.h>\n"); st.inc_indent() st.out("extern AvbDefs__ErrorCode @n@__unmarshal(RequestMessageBuffer_t request, ResponseMessageBuffer_t response);\n", n=node.identifier()) st.dec_indent() st.out("#endif // __@nsu@_UNMARSHAL_H__\n", nsu = node.identifier().upper()) st.close() # Output the unmarshal implementation st = output.Stream(output.createFile(node.identifier() + "_unmarshal.c"), 2) self.outputGenCode(st) st.out("#include \"@ns@_unmarshal.h\"", ns = node.identifier()) st.out("#include \"@[email protected]\"\n", ns = node.identifier()) st.out("#include \"@ns@_type.h\"\n", ns = node.identifier()) st.inc_indent() st.out("") # Forward declarations st.out("static AvbDefs__ErrorCode get_unmarshal(RequestMessageBuffer_t request, ResponseMessageBuffer_t response);"); st.out("static AvbDefs__ErrorCode set_unmarshal(RequestMessageBuffer_t request, ResponseMessageBuffer_t response);"); visitor = CxxInterfaceUnmarshalStaticForwardVisitor(st) for n in node.definitions(): n.accept(visitor) st.out("") # Common unmarshal functions self.outputUnmarshal(st, node) self.outputGetUnmarshal(st, node) self.outputSetUnmarshal(st, node) # Individual unmarshal functions visitor = CxxInterfaceUnmarshalStaticBodyVisitor(st, self.outputUnmarshalBody) for n in node.definitions(): n.accept(visitor) st.dec_indent() st.close() # Output the stub header st = output.Stream(output.createFile(node.identifier() + "_stub.h"), 2) self.outputGenCode(st) visitor = CxxStubHeaderVisitor(st) st.out("#ifndef __@nsu@_STUB_H__", nsu = node.identifier().upper()) st.out("#define __@nsu@_STUB_H__\n", nsu = node.identifier().upper()) st.out("#include \"message-buffer.h\"\n"); st.out("#include <linux/types.h>\n"); st.out("#include \"@[email protected]\"\n", ns = node.identifier()) st.inc_indent() for n in node.definitions(): n.accept(visitor) st.dec_indent() st.out("#endif // __@nsu@_STUB_H__\n", nsu = node.identifier().upper()) st.close() # Output the stub implementation st = output.Stream(output.createFile(node.identifier() + "_stub.c"), 2) self.outputGenCode(st) visitor = CxxStubImplVisitor(st, self.outputStubBody) st.out("#include \"@ns@_stub.h\"\n", ns = node.identifier()) st.out("#include \"@[email protected]\"\n", ns = node.identifier()) st.out("#include \"@ns@_type.h\"\n", ns = node.identifier()) st.inc_indent() st.out("ClassCode k_CC = k_CC_@cc@;\n", cc = node.identifier()) for n in node.definitions(): n.accept(visitor) st.dec_indent() st.close() # Output the type header st = output.Stream(output.createFile(node.identifier() + "_type.h"), 2) self.outputGenCode(st) visitor = CxxTypeHeaderVisitor(st) st.out("#ifndef __@nsu@_TYPE_H__", nsu = node.identifier().upper()) st.out("#define __@nsu@_TYPE_H__\n", nsu = node.identifier().upper()) st.out("#include \"message-buffer.h\"\n"); st.out("#include <linux/types.h>\n"); st.out("#include \"@[email protected]\"\n", ns = node.identifier()) st.inc_indent() for n in node.definitions(): n.accept(visitor) st.out("") st.dec_indent() st.out("#endif // __@nsu@_TYPE_H__\n", nsu = node.identifier().upper()) st.close() # Output the type implementation st = output.Stream(output.createFile(node.identifier() + "_type.c"), 2) self.outputGenCode(st) visitor = CxxTypeImplVisitor(st) st.out("#include \"@ns@_type.h\"\n", ns = node.identifier()) st.out("#include \"@[email protected]\"\n", ns = node.identifier()) st.inc_indent() for n in node.definitions(): n.accept(visitor) st.dec_indent() st.close()
def run(tree, backend_args): # Process arguments dirname, filename = os.path.split(tree.file()) basename, ext = os.path.splitext(filename) config.state["Basename"] = basename config.state["Directory"] = dirname process_args(backend_args) try: # Check the input tree only contains stuff we understand support.checkIDL(tree) # initialise the handy ast module ast.__init__(tree) # Initialise the descriptor generating code descriptor.__init__(tree) # Build the map of AST nodes to Environments tree.accept(id.WalkTree()) hh_filename = config.state["Basename"] + config.state["HH Suffix"] hpp_filename = config.state["Basename"] + config.state["HPP Suffix"] hxx_filename = config.state["Basename"] + config.state["HXX Suffix"] cc_filename = config.state["Basename"] + config.state["CC Suffix"] if config.state["Include Prefix"]: prefix = config.state["Include Prefix"] + "/" else: prefix = "" idl_filename = tree.file() hpp_stream = output.Stream(output.createFile(hpp_filename), 2) hxx_stream = output.Stream(output.createFile(hxx_filename), 2) cc_stream = output.Stream(output.createFile(cc_filename), 2) main.self = main main.__init__( hpp_stream, hxx_stream, cc_stream, idl_filename, prefix, hh_filename, hpp_filename, hxx_filename, ) main.run(tree) hpp_stream.close() hxx_stream.close() cc_stream.close() except AttributeError as e: name = e.args[0] unsupported_visitors = map(lambda x: "visit" + x, AST_unsupported_nodes[:]) if name in unsupported_visitors: # delete all possibly partial output files for file in output.listAllCreatedFiles(): os.unlink(file) util.unsupportedIDL() raise except SystemExit: # fatalError function throws SystemExit exception # delete all possibly partial output files for file in output.listAllCreatedFiles(): os.unlink(file) raise