def GenerateMain(self, interfaces):
     # generate the main cpp
     filename = os.path.join(self.outdir, '_main.cpp')
     fout = SmartFile(filename, 'w')
     fout.write(utils.left_equals('Include'))
     fout.write('#include <boost/python/module.hpp>\n\n')
     fout.write(utils.left_equals('Exports'))
     functions = [self._FunctionName(x) for x in interfaces]
     for function in functions:
         fout.write('void %s();\n' % function)
     fout.write('\n')
     fout.write(utils.left_equals('Module'))
     fout.write('BOOST_PYTHON_MODULE(%s)\n' % self.modulename)
     fout.write('{\n')
     indent = ' ' * 4
     for function in functions:
         fout.write(indent)
         fout.write('%s();\n' % function)
     fout.write('}\n')
 def GenerateMain(self, interfaces):                    
     # generate the main cpp
     filename = os.path.join(self.outdir, '_main.cpp')
     fout = SmartFile(filename, 'w')
     fout.write(utils.left_equals('Include'))
     fout.write('#include <boost/python/module.hpp>\n\n')
     fout.write(utils.left_equals('Exports'))
     functions = [self._FunctionName(x) for x in interfaces]
     for function in functions:
         fout.write('void %s();\n' % function)
     fout.write('\n')
     fout.write(utils.left_equals('Module'))
     fout.write('BOOST_PYTHON_MODULE(%s)\n' % self.modulename)
     fout.write('{\n')
     indent = ' ' * 4
     for function in functions:
         fout.write(indent)
         fout.write('%s();\n' % function)
     fout.write('}\n')
Example #3
0
 def Save(self, append=False):
     'Writes this code unit to the filename'
     space = '\n\n'
     if not append:
         flag = 'w'
     else:
         flag = 'a'
     fout = SmartFile(self.filename, flag)
     fout.write('\n')
     # includes
     # boost.python header
     if self.code['pchinclude']:
         fout.write(left_equals('PCH'))        
         fout.write(self.code['pchinclude']+'\n')
         fout.write('#ifdef _MSC_VER\n')
         fout.write('#pragma hdrstop\n')
         fout.write('#endif\n') 
     else:
         fout.write(left_equals('Boost Includes'))        
         fout.write('#include <boost/python.hpp>\n')
         # include numerical boost for int64 definitions
         fout.write('#include <boost/cstdint.hpp>\n') 
     fout.write('\n')
     # other includes        
     if self.code['include']:
         fout.write(left_equals('Includes'))        
         includes = remove_duplicated_lines(self.code['include'])
         fout.write(includes)
         fout.write(space)
     # using
     if settings.USING_BOOST_NS and not append:
         fout.write(left_equals('Using'))
         fout.write('using namespace boost::python;\n\n')
     # declarations
     declaration = self.code['declaration']
     declaration_outside = self.code['declaration-outside']
     if declaration_outside or declaration:
         fout.write(left_equals('Declarations'))
         if declaration_outside:
             fout.write(declaration_outside + '\n\n')
         if declaration:
             pyste_namespace = namespaces.pyste[:-2]            
             fout.write('namespace %s {\n\n' % pyste_namespace)
             fout.write(declaration) 
             fout.write('\n}// namespace %s\n' % pyste_namespace)
             fout.write(space)
     # module
     fout.write(left_equals('Module'))
     fout.write(self.module_definition + '\n')
     fout.write('{\n')
     fout.write(self.code['module']) 
     fout.write('}\n\n')
     fout.close()
Example #4
0
 def Save(self, append=False):
     'Writes this code unit to the filename'
     space = '\n\n'
     if not append:
         flag = 'w'
     else:
         flag = 'a'
     fout = SmartFile(self.filename, flag)
     fout.write('\n')
     # includes
     # boost.python header
     if self.code['pchinclude']:
         fout.write(left_equals('PCH'))
         fout.write(self.code['pchinclude'] + '\n')
         fout.write('#ifdef _MSC_VER\n')
         fout.write('#pragma hdrstop\n')
         fout.write('#endif\n')
     else:
         fout.write(left_equals('Boost Includes'))
         fout.write('#include <boost/python.hpp>\n')
         # include numerical boost for int64 definitions
         fout.write('#include <boost/cstdint.hpp>\n')
     fout.write('\n')
     # other includes
     if self.code['include']:
         fout.write(left_equals('Includes'))
         includes = remove_duplicated_lines(self.code['include'])
         fout.write(includes)
         fout.write(space)
     # using
     if settings.USING_BOOST_NS and not append:
         fout.write(left_equals('Using'))
         fout.write('using namespace boost::python;\n\n')
     # declarations
     declaration = self.code['declaration']
     declaration_outside = self.code['declaration-outside']
     if declaration_outside or declaration:
         fout.write(left_equals('Declarations'))
         if declaration_outside:
             fout.write(declaration_outside + '\n\n')
         if declaration:
             pyste_namespace = namespaces.pyste[:-2]
             fout.write('namespace %s {\n\n' % pyste_namespace)
             fout.write(declaration)
             fout.write('\n}// namespace %s\n' % pyste_namespace)
             fout.write(space)
     # module
     fout.write(left_equals('Module'))
     fout.write(self.module_definition + '\n')
     fout.write('{\n')
     fout.write(self.code['module'])
     fout.write('}\n\n')
     fout.close()
 def Save(self, append=False):
     "Writes this code unit to the filename"
     space = "\n\n"
     if not append:
         flag = "w"
     else:
         flag = "a"
     fout = SmartFile(self.filename, flag)
     fout.write("\n")
     # includes
     # boost.python header
     if self.code["pchinclude"]:
         fout.write(left_equals("PCH"))
         fout.write(self.code["pchinclude"] + "\n")
         fout.write("#ifdef _MSC_VER\n")
         fout.write("#pragma hdrstop\n")
         fout.write("#endif\n")
     else:
         fout.write(left_equals("Boost Includes"))
         fout.write("#include <boost/python.hpp>\n")
         # include numerical boost for int64 definitions
         fout.write("#include <boost/cstdint.hpp>\n")
     fout.write("\n")
     # other includes
     if self.code["include"]:
         fout.write(left_equals("Includes"))
         includes = remove_duplicated_lines(self.code["include"])
         fout.write(includes)
         fout.write(space)
     # using
     if settings.USING_BOOST_NS and not append:
         fout.write(left_equals("Using"))
         fout.write("using namespace boost::python;\n\n")
     # declarations
     declaration = self.code["declaration"]
     declaration_outside = self.code["declaration-outside"]
     if declaration_outside or declaration:
         fout.write(left_equals("Declarations"))
         if declaration_outside:
             fout.write(declaration_outside + "\n\n")
         if declaration:
             pyste_namespace = namespaces.pyste[:-2]
             fout.write("namespace %s {\n\n" % pyste_namespace)
             fout.write(declaration)
             fout.write("\n}// namespace %s\n" % pyste_namespace)
             fout.write(space)
     # module
     fout.write(left_equals("Module"))
     fout.write(self.module_definition + "\n")
     fout.write("{\n")
     fout.write(self.code["module"])
     fout.write("}\n\n")
     fout.close()