コード例 #1
0
    def AddAdditionalCode(self, mb):
        # Add includes
        header = code_creators.include_t("srcpy_converters.h")
        mb.code_creator.adopt_include(header)
        header = code_creators.include_t("coordsize.h")
        mb.code_creator.adopt_include(header)

        super(SrcBase, self).AddAdditionalCode(mb)
コード例 #2
0
ファイル: _cef.py プロジェクト: detoxhby/lambdawars
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t('include/cef_v8.h')
     mb.code_creator.adopt_include(header)
     header = code_creators.include_t('include/cef_process_message.h')
     mb.code_creator.adopt_include(header)
     header = code_creators.include_t('src_cef_js.h')
     mb.code_creator.adopt_include(header)
     super(CEF, self).AddAdditionalCode(mb)
コード例 #3
0
 def AddAdditionalCode(self, mb):
     mb.code_creator.user_defined_directories.append( os.path.abspath('.') )
     header = code_creators.include_t( 'cbase.h' )
     mb.code_creator.adopt_creator( header, 0 )
     header = code_creators.include_t( 'srcpy.h' )
     mb.code_creator.adopt_include( header )
     header = code_creators.include_t( 'tier0/memdbgon.h' )
     mb.code_creator.adopt_include(header)
コード例 #4
0
 def AddAdditionalCode(self, mb):
     # Add includes
     header = code_creators.include_t( 'srcpy_converters.h' )
     mb.code_creator.adopt_include(header)
     header = code_creators.include_t( 'coordsize.h' )
     mb.code_creator.adopt_include(header)
     
     super(SrcBase, self).AddAdditionalCode(mb)
コード例 #5
0
 def AddAdditionalCode(self, mb):
     mb.code_creator.user_defined_directories.append( os.path.abspath('.') )
     header = code_creators.include_t( 'cbase.h' )
     mb.code_creator.adopt_creator( header, 0 )
     header = code_creators.include_t( 'srcpy.h' )
     mb.code_creator.adopt_include( header )
     header = code_creators.include_t( 'tier0/memdbgon.h' )
     mb.code_creator.adopt_include(header)
コード例 #6
0
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t("include/cef_v8.h")
     mb.code_creator.adopt_include(header)
     header = code_creators.include_t("include/cef_process_message.h")
     mb.code_creator.adopt_include(header)
     header = code_creators.include_t("src_cef_js.h")
     mb.code_creator.adopt_include(header)
     super(CEF, self).AddAdditionalCode(mb)
コード例 #7
0
ファイル: create_tnfox.py プロジェクト: ned14/tnfox
def customize_module( mb ):   
    extmodule = mb.code_creator
    extmodule.license = customization_data.license

    # Insert a custom init call
    extmodule.adopt_creator( code_creators.custom_text_t('extern void InitialiseTnFOXPython();\n\n'), len(extmodule.creators)-1)
    extmodule.body.adopt_creator( code_creators.custom_text_t('    InitialiseTnFOXPython();\n\n'), 0)

    # Remove all standard headers in favour of precompiled header
    includes = filter( lambda creator: isinstance( creator, code_creators.include_t )
                        , extmodule.creators )
    map( lambda creator: extmodule.remove_creator( creator ), includes )
    position = extmodule.last_include_index() + 1
    extmodule.adopt_creator( code_creators.namespace_using_t('::FX'), position )
    extmodule.user_defined_directories.append( settings.generated_files_dir )
    extmodule.adopt_include( code_creators.include_t( header='../common.h' ) )    
    extmodule.precompiled_header = '../common.h'
    extmodule.adopt_include( code_creators.include_t( header='../patches.cpp.h' ) )    

    # Fix bug in gccxml where default args with function as value gain an extra ()
    try:
        constr = mb.constructor( 'FXPrimaryButton', arg_types=[None]*15 )
        constr.arguments[10].default_value = '(FX::FXWindow::defaultPadding() * 4)'
        constr.arguments[11].default_value = '(FX::FXWindow::defaultPadding() * 4)'
    except: pass

    # Patch default args with enums to be number (to avoid undeclared enum problem)
    def args_declaration_wa( self ):
        args = []
        for index, arg in enumerate( self.declaration.arguments ):
            result = arg.type.decl_string + ' ' + self.argument_name(index)
            if arg.default_value:
                result += '=%s' % arg.wrapper_default_value
            args.append( result )
        if len( args ) == 1:
            return args[ 0 ]
        return ', '.join( args )

    code_creators.calldef.calldef_wrapper_t.args_declaration = args_declaration_wa 

    allfuncs = mb.calldefs()
    for func in allfuncs:
        #print type(func), type(func.parent), func
        for arg in func.arguments:
            if not arg.default_value:
                continue
            arg.wrapper_default_value = arg.default_value
            if not declarations.is_enum( arg.type ):
                continue
            enum_ = declarations.enum_declaration( arg.type )
            if isinstance( enum_.parent, declarations.namespace_t ):
                continue #global enum
            # Be lazy, and just lookup the last part
            value = arg.default_value[ arg.default_value.rfind('::')+2: ]
            arg.default_value = arg.type.declaration.values[ value ] + '/*' + arg.default_value + '*/'
コード例 #8
0
 def AddAdditionalCode(self, mb):
     mb.code_creator.user_defined_directories.append( os.path.abspath('.') )
     if self.settings.branch == 'source2013':
         header = code_creators.include_t( 'tier0/valve_minmax_off.h' )
         mb.code_creator.adopt_include( header )
     header = code_creators.include_t( 'srcpy.h' )
     if self.settings.branch == 'source2013':
         mb.code_creator.adopt_include( header )
         header = code_creators.include_t( 'tier0/valve_minmax_on.h' )
     mb.code_creator.adopt_include( header )
     header = code_creators.include_t( 'tier0/memdbgon.h' )
     mb.code_creator.adopt_include(header)
コード例 #9
0
ファイル: multiple_files.py プロジェクト: tfepam/tce
    def split_creators( self, creators, pattern, function_name, registrator_pos ):
        """Write non-class creators into a particular .h/.cpp file.

        @param creators: The code creators that should be written
        @type creators: list of code_creator_t
        @param pattern: Name pattern that is used for constructing the final output file name
        @type pattern: str
        @param function_name: The name of the register_xyz() function
        @type function_name: str
        @param registrator_pos: The position of the code creator that creates the code to invoke the register_xyz() function.
        @type registrator_pos: int
        """
        if not creators:
            return
        file_pattern = self.extmodule.body.name + pattern
        file_path = os.path.join( self.directory_path, file_pattern )
        header_name = file_path + self.HEADER_EXT
        self.write_file( header_name
                         , self.create_header( file_pattern, self.create_function_code( function_name ) ) )
        self.write_file( file_path + self.SOURCE_EXT
                         , self.create_source( file_pattern, function_name, creators ))

        for creator in creators:
            creator.create = lambda: ''
        self.extmodule.body.adopt_creator(
            code_creators.custom_text_t( function_name + '();' )
            , registrator_pos)
        self.include_creators.append( code_creators.include_t( header_name ) )
        self.split_header_names.append(header_name)
        self.split_method_names.append(function_name)
コード例 #10
0
ファイル: multiple_files.py プロジェクト: asford/pyplusplus
    def split_creators( self, creators, pattern, function_name, registrator_pos ):
        """Write non-class creators into a particular .h/.cpp file.

        :param creators: The code creators that should be written
        :type creators: list of :class:`code_creators.code_creator_t`

        :param pattern: Name pattern that is used for constructing the final output file name
        :type pattern: str

        :param function_name: "register" function name
        :type function_name: str

        :param registrator_pos: The position of the code creator that creates the code to invoke the "register" function.
        :type registrator_pos: int
        """
        if not creators:
            return
        file_pattern = self.extmodule.body.name + pattern
        file_path = os.path.join( self.directory_path, file_pattern )
        header_name = file_path + self.HEADER_EXT
        self.write_file( header_name
                         , self.create_header( file_pattern, self.create_function_code( function_name ) ) )
        self.write_file( file_path + self.SOURCE_EXT
                         , self.create_source( file_pattern, function_name, creators ))

        for creator in creators:
            creator.create = lambda: ''
        self.extmodule.body.adopt_creator(
            code_creators.custom_text_t( function_name + '();' )
            , registrator_pos)
        self.include_creators.append( code_creators.include_t( header_name ) )
        self.split_header_names.append(header_name)
        self.split_method_names.append(function_name)
コード例 #11
0
ファイル: class_multiple_files.py プロジェクト: tfepam/tce
    def split_class_impl( self, class_creator):
        if not class_creator.declaration in self.huge_classes:
            return super( class_multiple_files_t, self ).split_class_impl( class_creator )

        class_creator.declaration.always_expose_using_scope = True

        function_name = 'register_%s_class' % class_creator.alias
        file_path = os.path.join( self.directory_path, class_creator.alias )
        # Write the .h file...
        header_name = file_path + self.HEADER_EXT
        self.write_file( header_name
                         , self.create_header( class_creator.alias
                                               , self.create_function_code( function_name ) ) )

        self.write_wrapper( class_creator )

        tail_headers = []
        for splitter in self.internal_splitters:
            pattern = splitter( class_creator )
            if not pattern:
                continue
            if isinstance( pattern, str ):
                tail_headers.append( self.create_base_fname( class_creator, pattern + self.HEADER_EXT ) )
            else:
                assert( isinstance( pattern, list ) )
                for p in pattern:
                    tail_headers.append( self.create_base_fname( class_creator, p + self.HEADER_EXT ) )
        #writting source file
        source_code = []
        if self.extmodule.license:
            source_code.append( self.extmodule.license.create() )

        source_code.append( self.create_include_code( [class_creator], tail_headers=tail_headers ) )

        source_code.append( '' )
        source_code.append( self.create_namespaces_code( [class_creator] ) )

        for creator in class_creator.associated_decl_creators:
            source_code.append( '' )
            source_code.append( creator.create() )
            if not isinstance( creator, self.ref_count_creators ):
                creator.create = lambda: ''

        # Write the register() function...
        source_code.append( '' )
        source_code.append( 'void %s(){' % function_name )
        source_code.append( '' )
        source_code.append( class_creator.create() )
        source_code.append( '' )
        source_code.append( '}' )
        self.write_file( file_path + self.SOURCE_EXT, os.linesep.join( source_code ) )

        # Replace the create() method so that only the register() method is called
        # (this is called later for the main source file).
        class_creator.create = lambda: function_name +'();'
        self.include_creators.append( code_creators.include_t( header_name ) )
        self.split_header_names.append(header_name)
        self.split_method_names.append(function_name)
コード例 #12
0
 def customize(self, mb ):
     #add precompiled header
     mb.build_code_creator( self.EXTENSION_NAME )
     stdafx = code_creators.include_t( 'stdafx.h' )            
     mb.code_creator.adopt_creator( stdafx, 0 )
             
     f = file( os.path.join( autoconfig.build_dir, 'stdafx.h' ), 'w+' )
     f.writelines( ['//this should be the first header file' + os.linesep] )
     f.close()
コード例 #13
0
    def customize(self, mb):
        #add precompiled header
        mb.build_code_creator(self.EXTENSION_NAME)
        stdafx = code_creators.include_t('stdafx.h')
        mb.code_creator.adopt_creator(stdafx, 0)

        f = open(os.path.join(autoconfig.build_dir, 'stdafx.h'), 'w+')
        f.write('//this should be the first header file\n')
        f.close()
コード例 #14
0
ファイル: argpolicy.py プロジェクト: ISoirar/pypp11
    def updateCreators(self, root):
        """Modifies the code creator tree.

        This method has to be called after the code creator tree was built
        and before the files were written.

        @param root: The root of the code creator tree
        @type root: module_t
        """
        self.creator_root = root
        for inc in self.includes:
            root.adopt_include(code_creators.include_t(inc))
コード例 #15
0
ファイル: argpolicy.py プロジェクト: laxris/pyplusplus
    def updateCreators(self, root):
        """Modifies the code creator tree.

        This method has to be called after the code creator tree was built
        and before the files were written.

        @param root: The root of the code creator tree
        @type root: module_t
        """
        self.creator_root = root
        for inc in self.includes:
            root.adopt_include(code_creators.include_t(inc))
コード例 #16
0
ファイル: multiple_files.py プロジェクト: asford/pyplusplus
    def split_class_impl( self, class_creator):
        function_name = 'register_%s_class' % class_creator.alias
        file_path = os.path.join( self.directory_path, class_creator.alias )
        # Write the .h file...
        header_name = file_path + self.HEADER_EXT
        self.write_file( header_name
                         , self.create_header( class_creator.alias
                                               , self.create_function_code( function_name ) ) )

        # Write the .cpp file...
        cpp_code = self.create_source( class_creator.alias, function_name, [class_creator] )

        self.write_file( file_path + self.SOURCE_EXT, cpp_code )

        # Replace the create() method so that only the register() method is called
        # (this is called later for the main source file).
        class_creator.create = lambda: function_name +'();'
        self.include_creators.append( code_creators.include_t( header_name ) )
        self.split_header_names.append(header_name)
        self.split_method_names.append(function_name)
コード例 #17
0
ファイル: multiple_files.py プロジェクト: tfepam/tce
    def split_class_impl( self, class_creator):
        function_name = 'register_%s_class' % class_creator.alias
        file_path = os.path.join( self.directory_path, class_creator.alias )
        # Write the .h file...
        header_name = file_path + self.HEADER_EXT
        self.write_file( header_name
                         , self.create_header( class_creator.alias
                                               , self.create_function_code( function_name ) ) )

        # Write the .cpp file...
        cpp_code = self.create_source( class_creator.alias, function_name, [class_creator] )

        self.write_file( file_path + self.SOURCE_EXT, cpp_code )

        # Replace the create() method so that only the register() method is called
        # (this is called later for the main source file).
        class_creator.create = lambda: function_name +'();'
        self.include_creators.append( code_creators.include_t( header_name ) )
        self.split_header_names.append(header_name)
        self.split_method_names.append(function_name)
コード例 #18
0
ファイル: modulebuilder.py プロジェクト: laxris/pyplusplus
    def buildCreators(self, moduleName=None, filename=None, useScope=None):
        """ Build creator tree and module from the current declarations.
          See writeModule for parameter documentation.
          In normal usage the user will not call this directly.
          Return the base of the creator tree.

          @rtype: module_t
      """
        if None == self.mDeclRoot:
            self.parse()

        if self.mVerbose:
            print "Decoration time:", self._time2str(time.time() -
                                                     self.mParseEndTime)
        startTime = time.time()

        if moduleName == None:
            moduleName = self.mModuleName
        if moduleName == None:
            raise ValueError, "No output module name given"
        if useScope == None:
            useScope = self.mUseScope

        # Lock the decoration interface (an attempt to decorate after this
        # call will lead to an error)
        declwrapper.decl_lock = True

        if self.mVerbose:
            print "Creating module code creator tree...."

        # Filter the exposed decl list to create a final decl list.


#      def filter(decl):
#         expose = getattr(decl, "_expose_flag", False)
#         return expose

#      if self.mVerbose:
#         print "Filtering module..."

#      self.mFinalDecls = declarations.filtering.user_defined( self.mDeclRoot, filter)

# The above filtering is already done in pyplusplus as it stores
# the "ignore" flag itself. [mbaas]

# Create creator.module_t for the module
# - override the header files in create since we already know what files we used.
        maker = module_creator.creator_t(self.mDeclRoot,
                                         module_name=moduleName)
        #      maker = module_creator.creator_t(self.mFinalDecls, module_name=moduleName)
        extmodule = maker.create(decl_headers=self.mHeaderFiles)

        # Preprocess the tree
        self._preprocessCreatorTree(extmodule)

        # Let the arg policy manager update the tree...
        self.mArgPolicyManager.updateCreators(extmodule)

        # Handle the extra creators that need added
        mod_body = extmodule.body
        for c in self.mBodyTailCreators:
            mod_body.adopt_creator(c)

        for c in self.mEndCreators:
            extmodule.adopt_creator(c)

        self.mStartCreators.reverse()
        for c in self.mStartCreators:
            extmodule.adopt_creator(c, extmodule.last_include_index() + 1)

        for h in self.mExtraIncludes:
            extmodule.adopt_include(code_creators.include_t(h))

        if useScope:
            class_creators = filter(
                lambda c: isinstance(c, code_creators.class_t),
                code_creators.make_flatten(extmodule.body.creators))
            for c in class_creators:
                c.always_expose_using_scope = True  #better error reporting from compiler

        if self.mLicense:
            extmodule._set_license(self.mLicense)

        if self.mVerbose:
            print "Code creator tree built in %s" % self._time2str(
                time.time() - startTime)

        self.mExtModule = extmodule
        return self.mExtModule
コード例 #19
0
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t( 'srcpy_gameinterface_converters.h' )
     mb.code_creator.adopt_include(header)
     super(GameInterface, self).AddAdditionalCode(mb)
     
コード例 #20
0
ファイル: _physics.py プロジェクト: detoxhby/lambdawars
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t( 'srcpy_physics_converters.h' )
     mb.code_creator.adopt_include(header)
     super(Physics, self).AddAdditionalCode(mb)
     
         
コード例 #21
0
ファイル: _physics.py プロジェクト: su6ur6an/lambdawars
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t( 'srcpy_physics_converters.h' )
     mb.code_creator.adopt_include(header)
     super(Physics, self).AddAdditionalCode(mb)
     
         
コード例 #22
0
ファイル: generate_code.py プロジェクト: direclown/osiris-sps
mfuns.add_override_precall_code("::osiris::PythonState __pystate(getPythonThreadState());")
mfuns.add_override_native_precall_code("__pystate.leave();")

initAlreadyExposedClasses(module_builder)
includeClasses(namespace_osiris)
includeEnumerations(namespace_osiris)
applyDefaultReturnPolicies(mfuns)

module_builder.build_code_creator(module_name = settings.module_name)
module_builder.code_creator.user_defined_directories.append(settings.root_dir)

module_builder.add_declaration_code('#include "pythonmanualwrappers.h"')
module_builder.add_registration_code("OS_NAMESPACE_NAME::initPythonManualWrappers();", False)

module_builder.code_creator.replace_included_headers([])		# Rimuove tutti gli headers inclusi automaticamente (wrappers.h in particolare che non deve essere incluso in ogni classe)
module_builder.code_creator.adopt_creator(code_creators.include_t("stdafx.h"), 0)
module_builder.code_creator.adopt_creator(code_creators.include_t("pypluspluscommon.h"), 1)

####################################################################################################

# I nomi dei files rispecchiano quelli delle classi, ma nell'include dei wrapper vengono generati in minuscolo da Py++ (il che crea problemi sotto linux...)
# Questa funzione fa da wrapper a quella originale passando il nome del file sempre in minuscolo
original_write_file = pyplusplus.file_writers.multiple_files.multiple_files_t.write_file
def make_lower_write_file(self, fpath, content):
	splittedPath = os.path.split(fpath)
	fpath = os.path.join(splittedPath[0], splittedPath[1].lower())	
	original_write_file(self, fpath, content)
pyplusplus.file_writers.multiple_files.multiple_files_t.write_file = make_lower_write_file

def make_lower_create_value_traits_header_name( self, value_class ):
	return ("_" + value_class.alias + "__value_traits" + self.HEADER_EXT).lower()
コード例 #23
0
ファイル: srcbuiltins.py プロジェクト: detoxhby/lambdawars
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t('srcpy_srcbuiltins_converters.h')
     mb.code_creator.adopt_include(header)
     super(SrcBuiltins, self).AddAdditionalCode(mb)
コード例 #24
0
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t( 'coordsize.h' )
     mb.code_creator.adopt_include(header)
     
     super(SrcBase, self).AddAdditionalCode(mb)
コード例 #25
0
ファイル: srcbuiltins.py プロジェクト: detoxhby/lambdawars
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t( 'srcpy_srcbuiltins_converters.h' )
     mb.code_creator.adopt_include(header)
     super(SrcBuiltins, self).AddAdditionalCode(mb)
コード例 #26
0
l = ( 'int', 'float' )
for s in l:
    f = mb.class_( "ShaderParams" ).member_function( name = "GetValue", arg_types = [ None, ''.join( ( s, ' &' ) ) ] )
    f.add_transformation( ft.output( "value" ), alias = ''.join( ( f.alias, '_', camel_convert( s ) ) ) )

f = mb.class_( "ShaderParams" ).member_function( name = "GetValue", arg_types = [ None, '::boost::shared_ptr<xfx::ITexture const> &' ] )
f.add_transformation( ft.output( "value" ), alias = ''.join( ( f.alias, '_texture' ) ) )

#mb.print_declarations( mb.namespace( lambda x: x.name.startswith( 'xfx' ) ) )

mb.namespace( "Primitives" ).class_( "Triangle" ).disable_warnings( messages.W1027 ) #Py++ will generate class wrapper - array member variable
mb.class_( "Shader" ).disable_warnings( messages.W1023 ) #Py++ will generate class wrapper - few functions that should be redefined in class wrapper
mb.class_( "ScriptResource" ).disable_warnings( messages.W1023 ) #Py++ will generate class wrapper - few functions that should be redefined in class wrapper
mb.class_( "Font" ).disable_warnings( messages.W1023 ) #Py++ will generate class wrapper - few functions that should be redefined in class wrapper
mb.class_( "ParticleSystem" ).disable_warnings( messages.W1023 ) #Py++ will generate class wrapper - few functions that should be redefined in class wrapper
mb.class_( "MessagesBook" ).disable_warnings( messages.W1023 ) #Py++ will generate class wrapper - few functions that should be redefined in class wrapper
mb.class_( "Mesh" ).disable_warnings( messages.W1023 ) #Py++ will generate class wrapper - few functions that should be redefined in class wrapper
mb.class_( "DrawTools" ).class_( "DrawChunkInfo" ).disable_warnings( messages.W1024 ) #Py++ will generate class wrapper - bit field member variable
mb.class_( "ITexture" ).member_functions( lambda x: x.name in ( "GetTextureMatrix", "GetTransformation", ) ).disable_warnings( messages.W1049 ) #This method could not be overriden in Python
mb.namespace( "boost" ).decls( lambda x: x.name.startswith( "shared_ptr" ) ).disable_warnings( messages.W1040 ) #The declaration is unexposed
mb.namespace( "boost" ).decls( lambda x: x.name.startswith( "function" ) ).disable_warnings( messages.W1040 ) #The declaration is unexposed
mb.namespace( "tuples" ).decls( lambda x: x.name.startswith( "tuple" ) ).disable_warnings( messages.W1040 ) #The declaration is unexposed
mb.namespace( "stdext" ).decls( lambda x: x.name.startswith( "hash_map" ) ).disable_warnings( messages.W1040 ) #The declaration is unexposed

#Creating code creator. After this step you should not modify/customize declarations.
mb.build_code_creator( module_name='xfx' )
mb.code_creator.adopt_creator( code_creators.include_t( 'xfx.h' ), 0 )

#Writing code to file.
mb.split_module( 'generated' )
コード例 #27
0
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t( 'srcpy_converters_ents.h' )
     mb.code_creator.adopt_include(header)
     super(EntitiesMisc, self).AddAdditionalCode(mb)
コード例 #28
0
    def AddAdditionalCode(self, mb):
        header = code_creators.include_t('coordsize.h')
        mb.code_creator.adopt_include(header)

        super(SrcBase, self).AddAdditionalCode(mb)
コード例 #29
0
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t('srcpy_converters_ents.h')
     mb.code_creator.adopt_include(header)
     super(EntitiesMisc, self).AddAdditionalCode(mb)
コード例 #30
0
mb.class_("Mesh").disable_warnings(
    messages.W1023
)  #Py++ will generate class wrapper - few functions that should be redefined in class wrapper
mb.class_("DrawTools").class_("DrawChunkInfo").disable_warnings(
    messages.W1024
)  #Py++ will generate class wrapper - bit field member variable
mb.class_("ITexture").member_functions(lambda x: x.name in (
    "GetTextureMatrix",
    "GetTransformation",
)).disable_warnings(
    messages.W1049)  #This method could not be overriden in Python
mb.namespace("boost").decls(
    lambda x: x.name.startswith("shared_ptr")).disable_warnings(
        messages.W1040)  #The declaration is unexposed
mb.namespace(
    "boost").decls(lambda x: x.name.startswith("function")).disable_warnings(
        messages.W1040)  #The declaration is unexposed
mb.namespace(
    "tuples").decls(lambda x: x.name.startswith("tuple")).disable_warnings(
        messages.W1040)  #The declaration is unexposed
mb.namespace(
    "stdext").decls(lambda x: x.name.startswith("hash_map")).disable_warnings(
        messages.W1040)  #The declaration is unexposed

#Creating code creator. After this step you should not modify/customize declarations.
mb.build_code_creator(module_name='xfx')
mb.code_creator.adopt_creator(code_creators.include_t('xfx.h'), 0)

#Writing code to file.
mb.split_module('generated')
コード例 #31
0
ファイル: modulebuilder.py プロジェクト: ChrisCarlsen/tortuga
   def buildCreators(self, moduleName=None, filename=None, useScope=None):
      """ Build creator tree and module from the current declarations.
          See writeModule for parameter documentation.
          In normal usage the user will not call this directly.
          Return the base of the creator tree.

          @rtype: module_t
      """
      if None == self.mDeclRoot:
         self.parse()

      if self.mVerbose:
         print "Decoration time:",self._time2str(time.time()-self.mParseEndTime)
      startTime = time.time()

      if moduleName==None:
         moduleName = self.mModuleName
      if moduleName==None:
         raise ValueError, "No output module name given"
      if useScope==None:
         useScope = self.mUseScope

      # Lock the decoration interface (an attempt to decorate after this
      # call will lead to an error)
      declwrapper.decl_lock = True
      
      if self.mVerbose:
         print "Creating module code creator tree...."
         
      # Filter the exposed decl list to create a final decl list.      
#      def filter(decl):
#         expose = getattr(decl, "_expose_flag", False)
#         return expose
      
#      if self.mVerbose:
#         print "Filtering module..."
         
#      self.mFinalDecls = declarations.filtering.user_defined( self.mDeclRoot, filter)

      # The above filtering is already done in pyplusplus as it stores
      # the "ignore" flag itself. [mbaas]
         
      # Create creator.module_t for the module
      # - override the header files in create since we already know what files we used.
      maker = module_creator.creator_t(self.mDeclRoot, module_name=moduleName)      
#      maker = module_creator.creator_t(self.mFinalDecls, module_name=moduleName)      
      extmodule = maker.create(decl_headers=self.mHeaderFiles)

      # Preprocess the tree
      self._preprocessCreatorTree(extmodule)

      # Let the arg policy manager update the tree...
      self.mArgPolicyManager.updateCreators(extmodule)

      # Handle the extra creators that need added
      mod_body = extmodule.body
      for c in self.mBodyTailCreators:
         mod_body.adopt_creator(c)
      
      for c in self.mEndCreators:
         extmodule.adopt_creator(c)
         
      self.mStartCreators.reverse()
      for c in self.mStartCreators:
         extmodule.adopt_creator(c, extmodule.last_include_index()+1)
         
      for h in self.mExtraIncludes:
         extmodule.adopt_include(code_creators.include_t(h))
         
      if useScope:
         class_creators = filter( lambda c: isinstance( c, code_creators.class_t )
                                 , code_creators.make_flatten( extmodule.body.creators ) )
         for c in class_creators:
            c.always_expose_using_scope = True #better error reporting from compiler   
      
      if self.mLicense:
         extmodule._set_license(self.mLicense)

      if self.mVerbose:
         print "Code creator tree built in %s"%self._time2str(time.time()-startTime)
         
      self.mExtModule = extmodule
      return self.mExtModule
コード例 #32
0
 def AddAdditionalCode(self, mb):
     header = code_creators.include_t('srcpy_gameinterface_converters.h')
     mb.code_creator.adopt_include(header)
     super(GameInterface, self).AddAdditionalCode(mb)