当前位置: 首页>>代码示例>>Python>>正文


Python declarations.declarated_t函数代码示例

本文整理汇总了Python中pygccxml.declarations.declarated_t函数的典型用法代码示例。如果您正苦于以下问题:Python declarated_t函数的具体用法?Python declarated_t怎么用?Python declarated_t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了declarated_t函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ApplyCommonRules

 def ApplyCommonRules(self, mb):
     # Common function added for getting the "PyObject" of an entity
     mb.member_functions('GetPySelf').exclude()
     
     ihandleentity = mb.class_('IHandleEntity')
     
     # All return values derived from IHandleEntity entity will be returned by value.
     # This ensures the converter is called
     testinherit = MatcherTestInheritClass(ihandleentity)
     decls = mb.calldefs(matchers.custom_matcher_t(testinherit))
     decls.call_policies = call_policies.return_value_policy(call_policies.return_by_value)
     
     # All CBaseEntity related classes should have a custom call trait
     self.baseentcls = mb.class_('CBaseEntity' if self.isserver else 'C_BaseEntity')
     def ent_call_trait(type_):
         return '%(arg)s ? %(arg)s->GetPyHandle() : boost::python::object()'
     entclasses = mb.classes(self.TestCBaseEntity)
     for entcls in entclasses:
         entcls.custom_call_trait = ent_call_trait
         
     # All functions receiving an IHandleEntity argument should be converted
     def ihandleentity_call_trait(type_):
         return 'PyEntityFromEntityHandle( %(arg)s )'
     ihandleentity.custom_call_trait = ihandleentity_call_trait
     
     # Anything returning KeyValues should be returned by value so it calls the converter
     keyvalues = mb.class_('KeyValues')
     mb.calldefs(calldef_matcher_t(return_type=pointer_t(declarated_t(keyvalues))), allow_empty=True).call_policies = call_policies.return_value_policy(call_policies.return_by_value) 
     mb.calldefs(calldef_matcher_t(return_type=pointer_t(const_t(declarated_t(keyvalues)))), allow_empty=True).call_policies = call_policies.return_value_policy(call_policies.return_by_value) 
     
     # Anything returning a void pointer is excluded by default
     mb.calldefs(calldef_matcher_t(return_type=pointer_t(declarated_t(void_t()))), allow_empty=True).exclude()
     mb.calldefs(calldef_matcher_t(return_type=pointer_t(const_t(declarated_t(void_t())))), allow_empty=True).exclude()
开发者ID:Sandern,项目名称:py-source-sdk-2013,代码行数:33,代码来源:basesource.py

示例2: __init__

 def __init__( self, function ):
     sealed_fun_controller_t.__init__( self, function )
     
     inst_arg_type = declarations.declarated_t( self.function.parent )
     if self.function.has_const:
         inst_arg_type = declarations.const_t( inst_arg_type )
     inst_arg_type = declarations.reference_t( inst_arg_type )
     
     self.__inst_arg = declarations.argument_t( name=self.register_variable_name( 'inst' )
                                                , decl_type=inst_arg_type )
开发者ID:Sandern,项目名称:py-source-sdk-2013,代码行数:10,代码来源:controllers.py

示例3: wrap_all_osg_referenced_noderive

 def wrap_all_osg_referenced_noderive(self, namespace):
     # Identify all classes derived from osg::Referenced, 
     # and set their boost::python held_type to "osg::ref_ptr<class>"
     osg = self.mb.namespace("osg")
     referenced = osg.class_("Referenced")
     referenced_derived = DerivedClasses(referenced)
     referenced_derived.include_module(namespace)
     copyop = osg.class_("CopyOp")
     # We are interested in constructors that take an argument of type "const osg::CopyOp&""
     copyop_arg_t = declarations.reference_t(declarations.const_t(declarations.declarated_t(copyop)))
     for cls in referenced_derived:
         expose_nonoverridable_ref_ptr_class(cls)
         # These copy constructors consistently cause trouble
         for ctor in cls.constructors(arg_types=[None, copyop_arg_t], allow_empty=True):
             ctor.exclude()
开发者ID:cmbruns,项目名称:osgpyplusplus,代码行数:15,代码来源:wrap_helpers.py

示例4: __link_type

 def __link_type(self, type_id):
     if type_id is None:
         # in some situations type_id is None, return_type of constructor or
         # destructor
         return None
     elif type_id in self.__types:
         return self.__types[type_id]
     elif type_id in self.__decls:
         base = declarations.declarated_t(declaration=self.__decls[type_id])
         self.__types[type_id] = base
         return base
     elif '...' == type_id:
         return declarations.ellipsis_t()
     else:
         return declarations.unknown_t()
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:15,代码来源:linker.py

示例5: customize

    def customize( self, mb ):
        mb.global_ns.exclude()

        mb.free_function( 'create_randome_rationals' ).include()

        xxx = mb.class_( 'XXX' )
        xxx.include()
        xxx_ref = declarations.reference_t( declarations.const_t( declarations.declarated_t( xxx ) ) )
        oper = mb.global_ns.free_operator( '<<', arg_types=[None, xxx_ref] )
        oper.include()

        mb.class_( 'YYY' ).include()

        rational = mb.class_('rational<long>')
        rational.include()
        rational.alias = "pyrational"

        #Test query api.
        #artificial declarations come back
        #rational.operator( '=' )
        #rational.operator( name='operator=' )
        #rational.operator( symbol='=' )
        rational.operators( '=' )
        rational.operators( name='operator=' )
        rational.operators( symbol='=' )
        #artificial declarations come back
        #rational.member_operator( '=' )
        #rational.member_operator( name='operator=' )
        #rational.member_operator( symbol='=' )
        rational.member_operators( '=' )
        rational.member_operators( name='operator=' )
        rational.member_operators( symbol='=' )
        mb.global_ns.free_operators( '<<' )
        mb.global_ns.free_operators( name='operator<<' )
        mb.global_ns.free_operators( symbol='<<' )

        r_assign = rational.calldef( 'assign', recursive=False )
        r_assign.call_policies = call_policies.return_self()

        foperators = mb.free_operators( lambda decl: 'rational<long>' in decl.decl_string )
        foperators.include()

        bad_rational = mb.class_('bad_rational' )
        bad_rational.include()
        mb.namespace( 'Geometry' ).include()
        mb.namespace( 'Geometry' ).class_( 'VecOfInts' ).exclude()

        mb.namespace( 'Geometry2' ).include()
开发者ID:asford,项目名称:pyplusplus,代码行数:48,代码来源:operators_tester.py

示例6: ParseEditablePanel

 def ParseEditablePanel(self, mb):
     focusnavgroup = mb.class_('FocusNavGroup')
     buildgroup = mb.class_('BuildGroup')
     excludetypes = [
         pointer_t(const_t(declarated_t(focusnavgroup))),
         pointer_t(declarated_t(focusnavgroup)),
         reference_t(declarated_t(focusnavgroup)),
         pointer_t(const_t(declarated_t(buildgroup))),
         pointer_t(declarated_t(buildgroup)),
         reference_t(declarated_t(buildgroup)),
     ]
     mb.calldefs(calldef_withtypes(excludetypes), allow_empty=True).exclude()
     
     mb.mem_funs( 'GetDialogVariables' ).call_policies = call_policies.return_value_policy(call_policies.return_by_value)
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:14,代码来源:_vguicontrols.py

示例7: customize

    def customize(self, mb):
        mb.global_ns.exclude()

        xxx = mb.class_("XXX")
        xxx.include()
        xxx_ref = declarations.reference_t(declarations.const_t(declarations.declarated_t(xxx)))
        oper = mb.global_ns.free_operator("<<", arg_types=[None, xxx_ref])
        oper.include()

        mb.class_("YYY").include()

        rational = mb.class_("rational<long>")
        rational.include()
        rational.alias = "pyrational"

        # Test query api.
        # artificial declarations come back
        # rational.operator( '=' )
        # rational.operator( name='operator=' )
        # rational.operator( symbol='=' )
        rational.operators("=")
        rational.operators(name="operator=")
        rational.operators(symbol="=")
        # artificial declarations come back
        # rational.member_operator( '=' )
        # rational.member_operator( name='operator=' )
        # rational.member_operator( symbol='=' )
        rational.member_operators("=")
        rational.member_operators(name="operator=")
        rational.member_operators(symbol="=")
        mb.global_ns.free_operators("<<")
        mb.global_ns.free_operators(name="operator<<")
        mb.global_ns.free_operators(symbol="<<")

        r_assign = rational.calldef("assign", recursive=False)
        r_assign.call_policies = call_policies.return_self()

        foperators = mb.free_operators(lambda decl: "rational<long>" in decl.decl_string)
        foperators.include()

        bad_rational = mb.class_("bad_rational")
        bad_rational.include()
开发者ID:venkatarajasekhar,项目名称:tortuga,代码行数:42,代码来源:operators_tester.py

示例8: test_constructors_destructors

    def test_constructors_destructors(self):
        struct_calldefs = self.global_ns.class_('calldefs_t')

        destructor = struct_calldefs.calldef('~calldefs_t')
        self._test_calldef_args(destructor, [])
        self._test_calldef_return_type(destructor, None.__class__)

        # well, now we have a few functions ( constructors ) with the same
        # name, there is no easy way to find the desired one. Well in my case
        # I have only 4 constructors
        # 1. from char
        # 2. from (int,double)
        # 3. default
        # 4. copy constructor
        constructor_found = struct_calldefs.constructors('calldefs_t')
        self.failUnless(
            len(constructor_found) == 5,
            ("struct 'calldefs_t' has 5 constructors, pygccxml parser " +
                "reports only about %d.") %
            len(constructor_found))
        error_text = "copy constructor has not been found"
        self.failUnless(1 == len(
            [constructor for constructor in constructor_found if
                constructor.is_copy_constructor]), error_text)
        # there is nothing to check about constructors - I know the
        # implementation of parser.
        # In this case it doesn't different from any other function

        c = struct_calldefs.constructor('calldefs_t', arg_types=['char'])
        self.failUnless(
            c.explicit,
            ("calldef_t constructor defined with 'explicit' keyword, " +
                "for some reason the value is False "))

        arg_type = declarations.declarated_t(
            self.global_ns.class_('some_exception_t'))
        c = struct_calldefs.constructor('calldefs_t', arg_types=[arg_type])
        self.failUnless(
            c.explicit is False,
            ("calldef_t constructor defined without 'explicit' keyword, " +
                "for some reason the value is True "))
开发者ID:iMichka,项目名称:pygccxml,代码行数:41,代码来源:declarations_tester.py

示例9: wrap_one_call_policy

def wrap_one_call_policy(fn):
    rt = fn.return_type
    if fn.return_type.decl_string == "char const *":
        return # use default for strings
    if fn.return_type.decl_string == "char *":
        return # use default for strings
    elif fn.return_type.decl_string == "void *":
        return # use default for void pointers
    elif fn.return_type.decl_string == "::GLvoid const *":
        return # use default for void pointers
    parent_ref = declarations.reference_t(declarations.declarated_t(fn.parent))
    if declarations.is_reference(rt):
        # Need type without reference for next type checks
        nonref_rt = rt.base
        if declarations.is_arithmetic(nonref_rt) or declarations.is_enum(nonref_rt):
            # returning const& double can cause compile trouble if return_internal_reference is used
            if declarations.is_const(nonref_rt):
                fn.call_policies = return_value_policy(copy_const_reference)
                return
            # int& might need to be copy_non_const_reference...
            else:
                fn.call_policies = return_value_policy(copy_non_const_reference)
                return
        # Const string references should be copied to python strings
        if declarations.is_std_string(nonref_rt) and declarations.is_const(nonref_rt):
            fn.call_policies = return_value_policy(copy_const_reference)
            return
        # Returning reference to this same class looks like return_self() [does this always work?]
        if declarations.is_same(parent_ref, rt):
            fn.call_policies = return_self()
            return
    elif declarations.is_pointer(rt):
        # Clone methods
        if re.search(r'^clone', fn.name):
            fn.call_policies = return_value_policy(reference_existing_object)
            return
    else:
        return
    # Everything else probably returns an internal reference
    fn.call_policies = return_internal_reference()
    return
开发者ID:cmbruns,项目名称:osgpyplusplus,代码行数:41,代码来源:wrap_helpers.py

示例10: _get_class_inst_type

 def _get_class_inst_type( self ):
     return declarations.declarated_t( self.declaration.parent )
开发者ID:CTrauma,项目名称:pypp11,代码行数:2,代码来源:member_variable.py

示例11: wrapped_class_type

 def wrapped_class_type( self ):
     wrapped_cls_type = declarations.declarated_t( self.declaration.parent )
     if declarations.is_const( self.declaration.type ):
         wrapped_cls_type = declarations.const_t( wrapped_cls_type )
     return declarations.reference_t( wrapped_cls_type )
开发者ID:CTrauma,项目名称:pypp11,代码行数:5,代码来源:member_variable.py

示例12: inst_arg_type

 def inst_arg_type( self, has_const ):
     inst_arg_type = declarations.declarated_t( self.declaration.parent )
     if has_const:
         inst_arg_type = declarations.const_t(inst_arg_type)
     inst_arg_type = declarations.reference_t(inst_arg_type)
     return inst_arg_type
开发者ID:CTrauma,项目名称:pypp11,代码行数:6,代码来源:member_variable.py

示例13: ParsePanels

    def ParsePanels(self, mb):
        # Panels
        cls = mb.class_('DeadPanel')
        cls.include()
        cls.mem_funs('NonZero', allow_empty=True).rename('__nonzero__')
        cls.mem_funs('Bool', allow_empty=True).rename('__bool__')
        
        # For each panel sub class we take some default actions
        for cls_name in self.panel_cls_list:
            cls = mb.class_(cls_name)

            # Include everything by default
            cls.include()
            cls.no_init = False
            
            # Be selective about we need to override
            cls.mem_funs().virtuality = 'not virtual' 
            
            #if cls_name not in ['AnimationController', 'Frame', 'ScrollBar', 'CBaseMinimap']:
            #    cls.mem_funs( matchers.access_type_matcher_t( 'protected' ) ).exclude()
            
            # By default exclude any subclass. These classes are likely controlled intern by the panel
            if cls.classes(allow_empty=True):
                cls.classes().exclude()
                
            self.AddVGUIConverter(mb, cls_name, self.novguilib, containsabstract=False)
            
            # # Add custom wrappers for functions who take keyvalues as input
            if self.novguilib:
                # No access to source code, so need to add message stuff for python here.
                cls.add_wrapper_code('virtual void OnMessage(const KeyValues *params, VPANEL fromPanel) {\r\n' +
                                     '    if( Panel_DispatchMessage( m_PyMessageMap, params, fromPanel ) )\r\n' +
                                     '        return;\r\n' +
                                     '    Panel::OnMessage(params, fromPanel);\r\n' +
                                     '}\r\n' + \
                                     '\r\n' + \
                                     'void RegMessageMethod( const char *message, boost::python::object method, int numParams=0, \r\n' + \
                                     '       const char *nameFirstParam="", int typeFirstParam=DATATYPE_VOID, \r\n' + \
                                     '       const char *nameSecondParam="", int typeSecondParam=DATATYPE_VOID ) { \r\n' + \
                                     '       py_message_entry_t entry;\r\n' + \
                                     '       entry.method = method;\r\n' + \
                                     '       entry.numParams = numParams;\r\n' + \
                                     '       entry.firstParamName = nameFirstParam;\r\n' + \
                                     '       entry.firstParamSymbol = KeyValuesSystem()->GetSymbolForString(nameFirstParam);\r\n' + \
                                     '       entry.firstParamType = typeFirstParam;\r\n' + \
                                     '       entry.secondParamName = nameSecondParam;\r\n' + \
                                     '       entry.secondParamSymbol = KeyValuesSystem()->GetSymbolForString(nameSecondParam);\r\n' + \
                                     '       entry.secondParamType = typeSecondParam;\r\n' + \
                                     '\r\n' + \
                                     '       GetPyMessageMap().Insert(message, entry);\r\n' + \
                                     '}\r\n' + \
                                     'virtual Panel *GetPanel() { return this; }\r\n'
                                     )
                cls.add_registration_code('def( "RegMessageMethod", &'+cls_name+'_wrapper::RegMessageMethod\r\n' + \
                                               ', ( bp::arg("message"), bp::arg("method"), bp::arg("numParams")=(int)(0), bp::arg("nameFirstParam")="", bp::arg("typeFirstParam")=int(::vgui::DATATYPE_VOID), bp::arg("nameSecondParam")="", bp::arg("typeSecondParam")=int(::vgui::DATATYPE_VOID) ))' )
                                               
                # Add stubs
                cls.add_wrapper_code('virtual void EnableSBuffer( bool bUseBuffer ) { PyPanel::EnableSBuffer( bUseBuffer ); }')
                cls.add_registration_code('def( "EnableSBuffer", &%(cls_name)s_wrapper::EnableSBuffer, bp::arg("bUseBuffer") )' % {'cls_name' : cls_name})
                cls.add_wrapper_code('virtual bool IsSBufferEnabled() { return PyPanel::IsSBufferEnabled(); }')
                cls.add_registration_code('def( "IsSBufferEnabled", &%(cls_name)s_wrapper::IsSBufferEnabled )' % {'cls_name' : cls_name})
                cls.add_wrapper_code('virtual void FlushSBuffer() { PyPanel::FlushSBuffer(); }')
                cls.add_registration_code('def( "FlushSBuffer", &%(cls_name)s_wrapper::FlushSBuffer )' % {'cls_name' : cls_name})
                cls.add_wrapper_code('virtual void SetFlushedByParent( bool bEnabled ) { PyPanel::SetFlushedByParent( bEnabled ); }')
                cls.add_registration_code('def( "SetFlushedByParent", &%(cls_name)s_wrapper::SetFlushedByParent, bp::arg("bEnabled") )' % {'cls_name' : cls_name})
    
        # Tweak Panels
        # Used by converters + special method added in the wrapper
        # Don't include here
        if not self.novguilib:
            mb.mem_funs('GetPySelf').exclude()
            mb.mem_funs('PyDestroyPanel').exclude()
            
        # Exclude message stuff. Maybe look into wrapping this in a nice way
        mb.mem_funs( 'AddToMap' ).exclude()
        mb.mem_funs( 'ChainToMap' ).exclude()
        mb.mem_funs( 'GetMessageMap' ).exclude()
        mb.mem_funs( 'AddToAnimationMap' ).exclude()
        mb.mem_funs( 'ChainToAnimationMap' ).exclude()
        mb.mem_funs( 'GetAnimMap' ).exclude()
        mb.mem_funs( 'KB_AddToMap' ).exclude()
        mb.mem_funs( 'KB_ChainToMap' ).exclude()
        mb.mem_funs( 'KB_AddBoundKey' ).exclude()
        mb.mem_funs( 'GetKBMap' ).exclude()
        mb.mem_funs( lambda decl: 'GetVar_' in decl.name ).exclude()
        
        mb.classes( lambda decl: 'PanelMessageFunc_' in decl.name ).exclude()
        mb.classes( lambda decl: '_Register' in decl.name ).exclude()
        mb.classes( lambda decl: 'PanelAnimationVar_' in decl.name ).exclude()
        mb.vars( lambda decl: '_register' in decl.name ).exclude()
        mb.vars( lambda decl: 'm_Register' in decl.name ).exclude()
        
        # Don't need the following:
        menu = mb.class_('Menu')
        keybindindcontexthandle = mb.enum('KeyBindingContextHandle_t')
        excludetypes = [
            pointer_t(const_t(declarated_t(menu))),
            pointer_t(declarated_t(menu)),
            reference_t(declarated_t(menu)),
            pointer_t(declarated_t(mb.class_('IPanelAnimationPropertyConverter'))),
#.........这里部分代码省略.........
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:101,代码来源:_vguicontrols.py

示例14: Parse

    def Parse(self, mb):
        if self.settings.branch == 'source2013':
            self.steamsdkversion = (1, 30)
    
        # Exclude everything by default
        mb.decls().exclude()  

        # Generic steam api call return result
        mb.typedef('SteamAPICall_t').include()

        # CSteamID
        cls = mb.class_('CSteamID')
        cls.include()
        constpchararg = pointer_t(const_t(declarated_t(char_t())))
        cls.constructors(matchers.calldef_matcher_t(arg_types=[constpchararg, None])).exclude()
        cls.mem_funs('Render').exclude()
        cls.mem_funs('SetFromStringStrict').exclude()
        cls.mem_funs('SetFromString').exclude() # No definition...
        cls.mem_funs('SetFromSteam2String').exclude() # No definition...
        cls.mem_funs('BValidExternalSteamID').exclude() # No definition...
        
        mb.enum('EResult').include()
        mb.enum('EDenyReason').include()
        mb.enum('EUniverse').include()
        mb.enum('EAccountType').include()
        mb.enum('ESteamUserStatType').include()
        mb.enum('EChatEntryType').include()
        mb.enum('EChatRoomEnterResponse').include()
        mb.enum('EChatMemberStateChange').include()
        
        # Generic API functions
        mb.free_function('SteamAPI_RunCallbacks').include()
        
        # Accessor class client
        mb.add_registration_code( "bp::scope().attr( \"steamapicontext\" ) = boost::ref(steamapicontext);" )
        cls = mb.class_('CSteamAPIContext')
        cls.include()
        cls.no_init = True
        cls.noncopyable = True
        cls.mem_fun('Init').exclude()
        cls.mem_fun('Clear').exclude()
        
        if self.steamsdkversion > (1, 11):
            cls.mem_fun('SteamHTTP').exclude()
        if self.steamsdkversion > (1, 15):
            cls.mem_fun('SteamScreenshots').exclude()
        if self.steamsdkversion > (1, 20):
            cls.mem_fun('SteamUnifiedMessages').exclude()
            
        cls.mem_fun('SteamMatchmakingServers').exclude() # Full python class wrapper

        cls.mem_fun('SteamNetworking').exclude()
        cls.mem_fun('SteamRemoteStorage').exclude()
        if self.steamsdkversion > (1, 16):
            cls.mem_fun('SteamAppList').exclude()
            cls.mem_fun('SteamController').exclude()
            cls.mem_fun('SteamMusic').exclude()
            cls.mem_fun('SteamMusicRemote').exclude()
            cls.mem_fun('SteamUGC').exclude() 
            cls.mem_fun('SteamHTMLSurface').exclude()
            
        cls.mem_funs('SteamApps').call_policies = call_policies.return_internal_reference()
        cls.mem_funs('SteamFriends').call_policies = call_policies.return_internal_reference()
        cls.mem_funs('SteamUtils').call_policies = call_policies.return_internal_reference()
        cls.mem_funs('SteamMatchmaking').call_policies = call_policies.return_internal_reference()
        cls.mem_funs('SteamMatchmakingServers').call_policies = call_policies.return_internal_reference()
        cls.mem_funs('SteamUser').call_policies = call_policies.return_internal_reference()
        cls.mem_funs('SteamUserStats').call_policies = call_policies.return_internal_reference()
        
        mb.add_registration_code( "bp::scope().attr( \"QUERY_PORT_NOT_INITIALIZED\" ) = (int)QUERY_PORT_NOT_INITIALIZED;" )
        mb.add_registration_code( "bp::scope().attr( \"QUERY_PORT_ERROR\" ) = (int)QUERY_PORT_ERROR;" )
        
        self.ParseSteamApps(mb)
        self.ParseSteamFriends(mb)
        
        # User
        cls = mb.class_('ISteamUser')
        cls.include()
        cls.no_init = True
        cls.noncopyable = True
        cls.mem_funs().virtuality = 'not virtual'
        
        # Utils
        cls = mb.class_('ISteamUtils')
        cls.include()
        cls.no_init = True
        cls.noncopyable = True
        cls.mem_funs().virtuality = 'not virtual'
        cls.mem_fun('GetImageRGBA').exclude()
        cls.mem_fun('GetImageSize').exclude()
        
        self.ParseMatchmaking(mb)
        self.ParseUserStats(mb)
        
        #mb.class_('ISteamUtils').mem_funs('GetImageSize').add_transformation( FT.output('pnWidth'), FT.output('pnHeight'))
        #mb.class_('ISteamUtils').mem_funs('GetCSERIPPort').add_transformation( FT.output('unIP'), FT.output('usPort'))
        
        if self.isserver:
            self.ParseServerOnly(mb)
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:99,代码来源:_steam.py

示例15: ParsePanels


#.........这里部分代码省略.........
            , PaintBackground_function_type(&::vgui::Panel::PaintBackground)
            , default_PaintBackground_function_type(&%(cls_name)s_wrapper::default_PaintBackground) );
    
    }
    { //::vgui::%(cls_name)s::InvalidateLayout
    
        typedef void ( ::vgui::Panel::*InvalidateLayout_function_type )( bool,bool ) ;
        typedef void ( %(cls_name)s_wrapper::*default_InvalidateLayout_function_type )( bool,bool ) ;
        
        %(cls_name)s_exposer.def( 
            "InvalidateLayout"
            , InvalidateLayout_function_type(&::vgui::Panel::InvalidateLayout)
            , default_InvalidateLayout_function_type(&%(cls_name)s_wrapper::default_InvalidateLayout)
            , ( bp::arg("layoutNow")=(bool)(false), bp::arg("reloadScheme")=(bool)(false) ) );
    
    }
    ''' % {'cls_name' : cls_name}, False)
            
            # By default exclude any subclass. These classes are likely controlled intern by the panel
            if cls.classes(allow_empty=True):
                cls.classes().exclude()
                
            self.AddVGUIConverter(mb, cls_name, self.novguilib, containsabstract=False)
            
            # # Add custom wrappers for functions who take keyvalues as input
            if self.novguilib:
                # No access to source code, so need to add message stuff for python here.
                cls.add_wrapper_code('virtual void OnMessage(const KeyValues *params, VPANEL fromPanel) {\r\n' +
                                     '    if( Panel_DispatchMessage( m_PyMessageMap, params, fromPanel ) )\r\n' +
                                     '        return;\r\n' +
                                     '    Panel::OnMessage(params, fromPanel);\r\n' +
                                     '}\r\n' + \
                                     '\r\n' + \
                                     'void RegMessageMethod( const char *message, boost::python::object method, int numParams=0, \r\n' + \
                                     '       const char *nameFirstParam="", int typeFirstParam=DATATYPE_VOID, \r\n' + \
                                     '       const char *nameSecondParam="", int typeSecondParam=DATATYPE_VOID ) { \r\n' + \
                                     '       py_message_entry_t entry;\r\n' + \
                                     '       entry.method = method;\r\n' + \
                                     '       entry.numParams = numParams;\r\n' + \
                                     '       entry.firstParamName = nameFirstParam;\r\n' + \
                                     '       entry.firstParamSymbol = KeyValuesSystem()->GetSymbolForString(nameFirstParam);\r\n' + \
                                     '       entry.firstParamType = typeFirstParam;\r\n' + \
                                     '       entry.secondParamName = nameSecondParam;\r\n' + \
                                     '       entry.secondParamSymbol = KeyValuesSystem()->GetSymbolForString(nameSecondParam);\r\n' + \
                                     '       entry.secondParamType = typeSecondParam;\r\n' + \
                                     '\r\n' + \
                                     '       GetPyMessageMap().Insert(message, entry);\r\n' + \
                                     '}\r\n' + \
                                     'virtual Panel *GetPanel() { return this; }\r\n'
                                     )
                cls.add_registration_code('def( "RegMessageMethod", &'+cls_name+'_wrapper::RegMessageMethod\r\n' + \
                                               ', ( bp::arg("message"), bp::arg("method"), bp::arg("numParams")=(int)(0), bp::arg("nameFirstParam")="", bp::arg("typeFirstParam")=int(::vgui::DATATYPE_VOID), bp::arg("nameSecondParam")="", bp::arg("typeSecondParam")=int(::vgui::DATATYPE_VOID) ))' )
                                               
                # Add stubs
                cls.add_wrapper_code('virtual void EnableSBuffer( bool bUseBuffer ) { PyPanel::EnableSBuffer( bUseBuffer ); }')
                cls.add_registration_code('def( "EnableSBuffer", &%(cls_name)s_wrapper::EnableSBuffer, bp::arg("bUseBuffer") )' % {'cls_name' : cls_name})
                cls.add_wrapper_code('virtual bool IsSBufferEnabled() { return PyPanel::IsSBufferEnabled(); }')
                cls.add_registration_code('def( "IsSBufferEnabled", &%(cls_name)s_wrapper::IsSBufferEnabled )' % {'cls_name' : cls_name})
                cls.add_wrapper_code('virtual void FlushSBuffer() { PyPanel::FlushSBuffer(); }')
                cls.add_registration_code('def( "FlushSBuffer", &%(cls_name)s_wrapper::FlushSBuffer )' % {'cls_name' : cls_name})
                cls.add_wrapper_code('virtual void SetFlushedByParent( bool bEnabled ) { PyPanel::SetFlushedByParent( bEnabled ); }')
                cls.add_registration_code('def( "SetFlushedByParent", &%(cls_name)s_wrapper::SetFlushedByParent, bp::arg("bEnabled") )' % {'cls_name' : cls_name})
    
        # Tweak Panels
        # Used by converters + special method added in the wrapper
        # Don't include here
        if not self.novguilib:
            mb.mem_funs('GetPySelf').exclude()
            mb.mem_funs('PyDestroyPanel').exclude()
            
        # Exclude message stuff. Maybe look into wrapping this in a nice way
        mb.mem_funs( 'AddToMap' ).exclude()
        mb.mem_funs( 'ChainToMap' ).exclude()
        mb.mem_funs( 'GetMessageMap' ).exclude()
        mb.mem_funs( 'AddToAnimationMap' ).exclude()
        mb.mem_funs( 'ChainToAnimationMap' ).exclude()
        mb.mem_funs( 'GetAnimMap' ).exclude()
        mb.mem_funs( 'KB_AddToMap' ).exclude()
        mb.mem_funs( 'KB_ChainToMap' ).exclude()
        mb.mem_funs( 'KB_AddBoundKey' ).exclude()
        mb.mem_funs( 'GetKBMap' ).exclude()
        mb.mem_funs( lambda decl: 'GetVar_' in decl.name ).exclude()
        
        mb.classes( lambda decl: 'PanelMessageFunc_' in decl.name ).exclude()
        mb.classes( lambda decl: '_Register' in decl.name ).exclude()
        mb.classes( lambda decl: 'PanelAnimationVar_' in decl.name ).exclude()
        mb.vars( lambda decl: '_register' in decl.name ).exclude()
        mb.vars( lambda decl: 'm_Register' in decl.name ).exclude()
        
        # Don't need the following:
        menu = mb.class_('Menu')
        keybindindcontexthandle = mb.enum('KeyBindingContextHandle_t')
        excludetypes = [
            pointer_t(const_t(declarated_t(menu))),
            pointer_t(declarated_t(menu)),
            reference_t(declarated_t(menu)),
            pointer_t(declarated_t(mb.class_('IPanelAnimationPropertyConverter'))),
            declarated_t(keybindindcontexthandle),
        ]
        mb.calldefs(calldef_withtypes(excludetypes), allow_empty=True).exclude()
开发者ID:detoxhby,项目名称:lambdawars,代码行数:101,代码来源:_vguicontrols.py


注:本文中的pygccxml.declarations.declarated_t函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。