• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python declarations.access_type_matcher_t函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AutoExclude

def AutoExclude( mb ):
    """ Automaticaly exclude a range of things that don't convert well from C++ to Python
    """
    global_ns = mb.global_ns
    for ns in NAMESPACES:
        main_ns = global_ns.namespace( ns )
    
        # vars that are static consts but have their values set in the header file are bad
        Remove_Static_Consts ( main_ns )
        
        ## Exclude protected and private that are not pure virtual
        query = declarations.access_type_matcher_t( 'private' ) \
                & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
        try:
            non_public_non_pure_virtual = main_ns.calldefs( query )
            non_public_non_pure_virtual.exclude()
        except:
            pass
    
        #Virtual functions that return reference could not be overriden from Python
        query = declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.VIRTUAL ) \
                & declarations.custom_matcher_t( lambda decl: declarations.is_reference( decl.return_type ) )
        try:
            main_ns.calldefs( query ).virtuality = declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
        except:
            pass
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:26,代码来源:generate_code.py


示例2: test_and_matcher

 def test_and_matcher( self ):
     criteria1 = declarations.regex_matcher_t( 'oper.*'
                                                , lambda decl: decl.name )
     criteria2 = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
     found = declarations.matcher.find( criteria1 & criteria2, self.global_ns )
     found = filter( lambda d: not d.is_artificial, found )
     self.failUnless( len( found ) <= 6 )
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:7,代码来源:filters_tester.py


示例3: emitClassMethods

def emitClassMethods(c):
    global hSrc, cppSrc, chsSrc
    #chsSrc += '-- *** Constructors\n'
    query = declarations.access_type_matcher_t( 'public' )
    #query = declarations.custom_matcher_t( lambda f: len(f.overloads) == 0) & declarations.access_type_matcher_t( 'public' )
    if not c.is_abstract:
        tc = []
        if c.find_trivial_constructor() != None:
            tc.append(c.find_trivial_constructor())
        ok = False
        cons = [a for a in c.constructors(allow_empty=True, function=query, recursive = False) if not a.is_copy_constructor]
        if len(cons) == 1:
            emitConstructorBinding(c,cons[0])
        else:
            cnt = 0
            for mf in cons: # + tc:
                emitConstructorBinding(c,mf,str(cnt))
                cnt += 1
        emitDestructorBinding(c)
    #chsSrc += '-- *** Methods\n'
    methods = {}
    for mf in c.mem_funs(allow_empty=True, function=query, recursive = False):
        if methods.has_key(mf.name):
            methods[mf.name].append(mf)
        else:
            methods[mf.name] = [mf]
    for mname,mlist in methods.iteritems():
        if len(mlist) == 1:
            emitMethodBinding(c,mlist[0]) # default method is the first one
        else:
            emitMethodBinding(c,mlist[0],'','0')
            cnt = 0
            for mf in mlist:
                emitMethodBinding(c,mf,str(cnt),str(cnt))
                cnt += 1
开发者ID:csabahruska,项目名称:bullet,代码行数:35,代码来源:bullet.py


示例4: test_access_type

 def test_access_type( self ):       
     criteria = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
     public_members = declarations.matcher.find( criteria, self.declarations )
     if '0.9' in public_members[0].compiler:
         #2 empty classes, this compiler doesn't generate constructor and copy constructor
         self.failUnless( 15 == len( public_members ) ) 
     else:
         self.failUnless( 19 == len( public_members ) )
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:8,代码来源:filters_tester.py


示例5: test_access_type

 def test_access_type( self ):       
     criteria = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
     public_members = declarations.matcher.find( criteria, self.global_ns )
     if '0.9' in public_members[0].compiler:
         public_members = filter( lambda d: not d.is_artificial, public_members )
         self.failUnless( 16 == len( public_members ) ) 
     else:
         self.failUnless( 20 == len( public_members ) )
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:8,代码来源:filters_tester.py


示例6: test_access_type

 def test_access_type(self):
     criteria = declarations.access_type_matcher_t(
         declarations.ACCESS_TYPES.PUBLIC)
     public_members = declarations.matcher.find(criteria, self.global_ns)
     if '0.9' in public_members[0].compiler:
         public_members = [d for d in public_members if not d.is_artificial]
         self.failUnless(17 == len(public_members))
     else:
         self.failUnless(21 == len(public_members))
开发者ID:programmdesign,项目名称:pygccxml,代码行数:9,代码来源:filters_tester.py


示例7: test_and_matcher

 def test_and_matcher(self):
     criteria1 = declarations.regex_matcher_t(
         'oper.*',
         lambda decl: decl.name)
     criteria2 = declarations.access_type_matcher_t(
         declarations.ACCESS_TYPES.PUBLIC)
     found = declarations.matcher.find(
         criteria1 & criteria2,
         self.global_ns)
     found = [d for d in found if not d.is_artificial]
     self.assertTrue(len(found) <= 6)
开发者ID:gccxml,项目名称:pygccxml,代码行数:11,代码来源:filters_tester.py


示例8: test_or_matcher

    def test_or_matcher( self ):
        criteria1 = declarations.regex_matcher_t( 'oper.*'
                                                   , lambda decl: decl.name )
        criteria2 = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
        found = declarations.matcher.find( criteria1 | criteria2, self.declarations )

        if '0.9' in found[0].compiler:
            #2 empty classes, this compiler doesn't generate constructor and copy constructor
            self.failUnless( 15 <= len( found ) <= 21) 
        else:
            self.failUnless( 19 <= len( found ) <= 25)
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:11,代码来源:filters_tester.py


示例9: test_or_matcher

    def test_or_matcher( self ):
        criteria1 = declarations.regex_matcher_t( 'oper.*'
                                                   , lambda decl: decl.name )
        criteria2 = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
        found = declarations.matcher.find( criteria1 | criteria2, self.global_ns )

        if '0.9' in found[0].compiler:
            found = filter( lambda d: not d.is_artificial, found )
            self.failUnless( 15 <= len( found ) <= 21) 
        else:
            self.failUnless( 19 <= len( found ) <= 25)
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:11,代码来源:filters_tester.py


示例10: test_access_type

 def test_access_type(self):
     criteria = declarations.access_type_matcher_t(
         declarations.ACCESS_TYPES.PUBLIC)
     public_members = declarations.matcher.find(criteria, self.global_ns)
     if "CastXML" in utils.xml_generator:
         public_members = [d for d in public_members if not d.is_artificial]
         self.failUnless(21 == len(public_members))
     if "0.9" in utils.xml_generator:
         public_members = [d for d in public_members if not d.is_artificial]
         self.failUnless(17 == len(public_members))
     else:
         self.failUnless(21 == len(public_members))
开发者ID:iMichka,项目名称:pygccxml,代码行数:12,代码来源:filters_tester.py


示例11: filter_declarations

def filter_declarations( mb ):
    global_ns = mb.global_ns
    global_ns.exclude()
    ogrerefapp_ns = global_ns.namespace( 'OgreRefApp' )
    ogrerefapp_ns.include()
    
 
    ## Exclude protected and private that are not pure virtual
    query = ~declarations.access_type_matcher_t( 'public' ) \
            & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
    non_public_non_pure_virtual = ogrerefapp_ns.calldefs( query )
    non_public_non_pure_virtual.exclude()
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:12,代码来源:generate_code.py


示例12: Auto_Document

def Auto_Document ( mb, namespace=None ):
    """Indicate that the functions being exposed are declated protected or private in the C++ code
    this should warn people to be careful using them :) """
    global_ns = mb.global_ns
    if namespace:
        main_ns = global_ns.namespace( namespace )
    else:
        main_ns = global_ns
    query = declarations.access_type_matcher_t( 'private' ) 
    for c in main_ns.calldefs( query, allow_empty=True ):
#         print "PRIVATE:", c
        s = c.documentation
        if not s:
            s = ""
        c.documentation="Private declaration.\\n"+s
    query = declarations.access_type_matcher_t( 'protected' ) 
    for c in main_ns.calldefs( query, allow_empty=True ):
#         print "PROTECTED:", c
        s = c.documentation
        if not s:
            s = ""
        c.documentation="Protected declaration.\\n"+s
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:22,代码来源:__init__.py


示例13: test_access_type

 def test_access_type(self):
     criteria = declarations.access_type_matcher_t(
         declarations.ACCESS_TYPES.PUBLIC)
     public_members = declarations.matcher.find(criteria, self.global_ns)
     public_members = [d for d in public_members if not d.is_artificial]
     if self.xml_generator_from_xml_file.is_castxml:
         nbr = len(public_members)
         self.assertTrue(nbr in [17, 21])
         if nbr == 21:
             # We are using llvm 3.9, see bug #32. Make sure the 4 names
             # are still there
             ll = ["isa", "flags", "str", "length"]
             for l in ll:
                 self.assertTrue(l in [mbr.name for mbr in public_members])
     else:
         self.assertTrue(17 == len(public_members))
开发者ID:gccxml,项目名称:pygccxml,代码行数:16,代码来源:filters_tester.py


示例14: test_or_matcher

    def test_or_matcher(self):
        criteria1 = declarations.regex_matcher_t(
            "oper.*",
            lambda decl: decl.name)
        criteria2 = declarations.access_type_matcher_t(
            declarations.ACCESS_TYPES.PUBLIC)
        found = declarations.matcher.find(
            criteria1 | criteria2,
            self.global_ns)

        if "CastXML" in utils.xml_generator:
            found = [d for d in found if not d.is_artificial]
            self.assertTrue(len(found) != 35)
        elif "0.9" in utils.xml_generator:
            found = [d for d in found if not d.is_artificial]
            self.assertTrue(15 <= len(found) <= 21)
        else:
            self.assertTrue(19 <= len(found) <= 25)
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:18,代码来源:filters_tester.py


示例15: test_or_matcher

    def test_or_matcher(self):
        criteria1 = declarations.regex_matcher_t(
            "oper.*",
            lambda decl: decl.name)
        criteria2 = declarations.access_type_matcher_t(
            declarations.ACCESS_TYPES.PUBLIC)
        found = declarations.matcher.find(
            criteria1 | criteria2,
            self.global_ns)

        if self.xml_generator_from_xml_file.is_castxml:
            found = [d for d in found if not d.is_artificial]
            self.assertTrue(len(found) != 35)
        elif self.xml_generator_from_xml_file.is_gccxml_09 or \
                self.xml_generator_from_xml_file.is_gccxml_09_buggy:
            found = [d for d in found if not d.is_artificial]
            self.assertTrue(15 <= len(found) <= 21)
        else:
            self.assertTrue(19 <= len(found) <= 25)
开发者ID:gccxml,项目名称:pygccxml,代码行数:19,代码来源:filters_tester.py


示例16: _test_class_membership

    def _test_class_membership(self, class_inst, enum_name, access):
        # getting enum through get_members function
        nested_enum1 = class_inst.enum(
            name=enum_name,
            function=declarations.access_type_matcher_t(access))

        # getting enum through declarations property
        nested_enum2 = class_inst.enum(enum_name)

        # it shoud be same object
        self.failUnless(
            nested_enum1 is nested_enum2,
            ("enum accessed through access definition('%s') and " +
                "through declarations('%s') are different enums " +
                "or instances.") %
            (nested_enum1.name, nested_enum2.name))

        # check whether we meaning same class instance
        self.failUnless(
            class_inst is nested_enum1.parent is nested_enum2.parent,
            'There are 2 or more instances of ns namespace.')
开发者ID:programmdesign,项目名称:pygccxml,代码行数:21,代码来源:core_tester.py


示例17: _process_methods

 def _process_methods(self):
     if not self.methods_:
         query = declarations.access_type_matcher_t("public")
         hierarchy = self.gcc.recursive_bases
         cls_decls = self.gcc.decls(function=query)
         base_decls = [
             c.related_class.decls(function=query, allow_empty=True) for c in hierarchy if c.access_type == "public"
         ]
         for m in iter_seq([cls_decls] + base_decls):
             if isinstance(m, declarations.enumeration.enumeration_t):
                 try:
                     e = create_decl(m, self.doxyindex, self.opts)
                 except RuntimeError:
                     pass  # ok - not found by doxygen mechanism
                 else:
                     if e.is_exported():
                         raise RuntimeError("Enum '%s' within class '%s' - not allowed." % (m.name, self.gcc.name))
             elif isinstance(m, declarations.calldef.member_function_t):
                 if m.virtuality != "pure virtual":
                     raise RuntimeError("'%s' is not virtual" % m)
                 dm = create_decl(m, self.doxyindex, self.opts)
                 if dm.is_exported():
                     self.methods_.add(dm)
                 else:
                     self.internal_methods_.add(dm)
                 # this is needed as methods in base classes need to know
                 # the class they belong to in the generated (flat) hierarchy
                 dm.gcc_leaf_class = self.gcc
             else:
                 if not isinstance(
                     m,
                     (
                         declarations.calldef.constructor_t,
                         declarations.calldef.destructor_t,
                         declarations.calldef.member_operator_t,
                     ),
                 ):
                     raise RuntimeError(
                         "Unknown declaration '%s' of type '%s' within class '%s'." % (m.name, m, self.gcc.name)
                     )
开发者ID:mkawserm,项目名称:jagpdf,代码行数:40,代码来源:introspect.py


示例18: redefined_funcs

    def redefined_funcs( self ):
        """
        returns list of member functions that should be defined in the class wrapper

        It comes useful in 3 tier hierarchy:

        .. code-block:: c++

           struct base{
               virtual void do_nothing() = 0;
           };

           struct derived{
               virtual void do_something() = 0;
           };

           struct concrete{
               virtual void do_nothing(){}
               virtual void do_something(){}
           };

        The wrapper for class `derived`, should define `do_nothing` function,
        otherwise the generated code will not compile
        """

        if isinstance( self._redefined_funcs, list ):
            return self._redefined_funcs

        all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False and decl.exportable )
        all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
        all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
        all_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.VIRTUAL ) \
                      & ( declarations.access_type_matcher_t( 'public' ) \
                          | declarations.access_type_matcher_t( 'protected' ))
        all_not_pure_virtual = ~all_pure_virtual

        query = all_protected | all_pure_virtual
        mf_query = query | all_virtual
        relevant_opers = declarations.custom_matcher_t( lambda decl: decl.symbol in ('()', '[]') )
        funcs = []
        defined_funcs = []

        for base in self.recursive_bases:
            if base.access == ACCESS_TYPES.PRIVATE:
                continue
            base_cls = base.related_class

            funcs.extend( base_cls.member_functions( mf_query, recursive=False, allow_empty=True ) )
            funcs.extend( base_cls.member_operators( relevant_opers & query, recursive=False, allow_empty=True ) )

            defined_funcs.extend( base_cls.member_functions( all_not_pure_virtual, recursive=False, allow_empty=True ) )
            defined_funcs.extend( base_cls.member_operators( all_not_pure_virtual & relevant_opers, recursive=False, allow_empty=True ) )

        not_reimplemented_funcs = set()
        is_same_function = declarations.is_same_function
        for f in funcs:
            cls_fs = self.calldefs( name=f.name, recursive=False, allow_empty=True )
            for cls_f in cls_fs:
                if is_same_function( f, cls_f ):
                    break
            else:
                #should test whether this function has been added or not
                for f_impl in not_reimplemented_funcs:
                    if is_same_function( f, f_impl ):
                        if declarations.is_base_and_derived( f_impl.parent, f.parent ):
                            #add function from the most derived class
                            not_reimplemented_funcs.remove( f_impl )
                            not_reimplemented_funcs.add( f )
                        break
                else:
                    #should test whether this function is implemented in base class
                    if f.virtuality != VIRTUALITY_TYPES.PURE_VIRTUAL:
                        not_reimplemented_funcs.add( f )
                    else:
                        for f_defined in defined_funcs:
                            if is_same_function( f, f_defined ):
                                break
                        else:
                            not_reimplemented_funcs.add( f )
        functions = [f for f in list( not_reimplemented_funcs ) if ( False == f.ignore and True == f.exportable )
                                      or all_pure_virtual( f )]


        #Boost.Python is not able to call for non-virtual function, from the base
        #class if there is a virtual function with the same within base class
        #See override_bug tester for more information

        def buggy_bpl_filter( f ):
            if f.parent is self:
                return False
            if f.access_type != ACCESS_TYPES.PUBLIC:
                return False
            if f.virtuality != VIRTUALITY_TYPES.NOT_VIRTUAL:
                return False
            #we need to check that we don't have "same" function in this class
            this_funs = self.decls( name=f.name
                                    , decl_type=declarations.calldef_t
                                    , recursive=False
                                    , allow_empty=True )
            for this_f in this_funs:
#.........这里部分代码省略.........
开发者ID:detoxhby,项目名称:lambdawars,代码行数:101,代码来源:class_wrapper.py


示例19: filter_declarations

    def filter_declarations(self):
        code_generator_t.filter_declarations(self)
        # don't export variables that need a wrapper
        self.ompl_ns.variables(lambda decl: decl.is_wrapper_needed()).exclude()
        # make objects printable that have a print function
        self.replace_member_functions(self.ompl_ns.member_functions('print'))
        # print paths as matrices
        self.replace_member_functions(self.ompl_ns.member_functions('printAsMatrix'))
        # print debug info
        self.replace_member_functions(self.ompl_ns.member_functions('printDebug'))
        self.ompl_ns.member_functions('freeGridMotions').exclude()
        self.ompl_ns.class_('PRM').member_functions('maybeConstructSolution').exclude()
        self.ompl_ns.class_('PRM').member_functions('growRoadmap',
                function=declarations.access_type_matcher_t('protected')).exclude()
        self.ompl_ns.class_('PRM').member_functions('expandRoadmap',
                function=declarations.access_type_matcher_t('protected')).exclude()
        # don't export some internal data structure
        self.ompl_ns.classes('OrderCellsByImportance').exclude()
        # LLVM's clang++ compiler doesn't like exporting this method because
        # the argument type (Grid::Cell) is protected
        self.ompl_ns.member_functions('computeImportance').exclude()
        # add wrappers for boost::function types
        self.add_boost_function('unsigned int()',
            'NumNeighborsFn', 'Number of neighbors function')
        # self.add_boost_function('std::vector<ompl::geometric::PRM::Vertex>&(const ompl::geometric::PRM::Vertex)',
        #     'ConnectionStrategy', 'Connection strategy')
        self.add_boost_function('bool(const ompl::geometric::PRM::Vertex&, const ompl::geometric::PRM::Vertex&)',
            'ConnectionFilter', 'Connection filter')
        # code generation fails because of same bug in gxxcml that requires us
        # to patch the generated code with workaround_for_gccxml_bug.cmake
        self.ompl_ns.member_functions('getPlannerAllocator').exclude()
        self.ompl_ns.member_functions('setPlannerAllocator').exclude()
        self.ompl_ns.namespace('geometric').class_('SimpleSetup').add_registration_code(
            'def("setPlannerAllocator", &ompl::geometric::SimpleSetup::setPlannerAllocator)')
        self.ompl_ns.namespace('geometric').class_('SimpleSetup').add_registration_code(
            'def("getPlannerAllocator", &ompl::geometric::SimpleSetup::getPlannerAllocator, bp::return_value_policy< bp::copy_const_reference >())')

        # Py++ seems to get confused by some methods declared in one module
        # that are *not* overridden in a derived class in another module. The
        # Planner class is defined in ompl::base and two of its virtual methods,
        # setProblemDefinition and checkValidity, and not overridden by most
        # planners. The code below forces Py++ to do the right thing (or at
        # least make it work). It seems rather hacky and there may be a better
        # solution.

        # do this for all planners
        for planner in ['EST', 'KPIECE1', 'BKPIECE1', 'LBKPIECE1', 'PRM', 'LazyPRM', 'LazyPRMstar', 'PDST', 'LazyRRT', 'RRT', 'RRTConnect', 'TRRT', 'RRTstar', 'LBTRRT', 'SBL', 'SPARS', 'SPARStwo', 'STRIDE', 'FMT', 'BITstar']:
            try:
                cls = self.ompl_ns.class_(planner)
            except:
                continue
            self.ompl_ns.class_(planner).add_registration_code("""
            def("solve", (::ompl::base::PlannerStatus(::ompl::base::Planner::*)( double ))(&::ompl::base::Planner::solve), (bp::arg("solveTime")) )""")
            if planner!='PRM':
                # PRM overrides setProblemDefinition, so we don't need to add this code
                self.ompl_ns.class_(planner).add_registration_code("""
                def("setProblemDefinition",&::ompl::base::Planner::setProblemDefinition,
                    &%s_wrapper::default_setProblemDefinition, (bp::arg("pdef")) )""" % planner)
            self.ompl_ns.class_(planner).add_registration_code("""
            def("checkValidity",&::ompl::base::Planner::checkValidity,
                &%s_wrapper::default_checkValidity )""" % planner)

        # The OMPL implementation of PRM uses two threads: one for constructing
        # the roadmap and another for checking for a solution. This causes
        # problems when both threads try to access the python interpreter
        # simultaneously. This is a known limitation of Boost.Python. We
        # therefore use a single-threaded version of PRM in python.
        PRM_cls = self.ompl_ns.class_('PRM')
        PRM_cls.member_function('solve').exclude()
        PRM_cls.add_wrapper_code("""
            virtual ::ompl::base::PlannerStatus solve( ::ompl::base::PlannerTerminationCondition const & ptc ) {
                if( bp::override func_solve = this->get_override( "solve" ) )
                    return func_solve( boost::ref(ptc) );
                else{
                    return default_solve( boost::ref(ptc) );
                }
            }

            ::ompl::base::PlannerStatus default_solve( ::ompl::base::PlannerTerminationCondition const & ptc );
            """)
        PRM_cls.add_declaration_code(open('PRM.SingleThreadSolve.cpp','r').read())
        # This needs to be the last registration code added to the PRM_cls to the ugly hack below.
        PRM_cls.add_registration_code("""def("solve",
            (::ompl::base::PlannerStatus(::ompl::geometric::PRM::*)( ::ompl::base::PlannerTerminationCondition const &))(&PRM_wrapper::solve),
            (::ompl::base::PlannerStatus(PRM_wrapper::*)( ::ompl::base::PlannerTerminationCondition const & ))(&PRM_wrapper::default_solve), bp::arg("ptc") );

            // HACK ALERT: closing brace destroys bp::scope, so that PRMstar is not a nested class of PRM
            }
            {
                // wrapper for PRMstar, derived from single-threaded PRM_wrapper
                bp::class_<PRMstar_wrapper, bp::bases< PRM_wrapper >, boost::noncopyable >("PRMstar", bp::init< ompl::base::SpaceInformationPtr const & >( bp::arg("si") ) )
            """)
        # Add wrapper code for PRM*
        PRM_cls.add_declaration_code("""
        class PRMstar_wrapper : public PRM_wrapper
        {
        public:
            PRMstar_wrapper(const ompl::base::SpaceInformationPtr &si) : PRM_wrapper(si, true)
            {
                setName("PRMstar");
#.........这里部分代码省略.........
开发者ID:jf---,项目名称:ompl,代码行数:101,代码来源:generate_bindings.py


示例20: redefined_funcs

    def redefined_funcs( self ):
        """returns list of member functions that should be defined in class wrapper

        It comes useful in 3 tier hierarchy:
        struct base{
            virtual void do_nothing() = 0;
        };

        struct derived{
            virtual void do_something() = 0;
        };

        struct concrete{
            virtual void do_nothing(){}
            virtual void do_something(){}
        };

        derived_wrapper should define do_nothing function, otherwise the generated
        code will not compile
        """

        if isinstance( self._redefined_funcs, list ):
            return self._redefined_funcs

        all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False and decl.exportable )
        all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
        all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
        all_not_pure_virtual = ~all_pure_virtual

        query = all_protected | all_pure_virtual
        relevant_opers = declarations.custom_matcher_t( lambda decl: decl.symbol in ('()', '[]') )
        funcs = set()
        defined_funcs = set()

        for base in self.recursive_bases:
            if base.access == ACCESS_TYPES.PRIVATE:
                continue
            base_cls = base.related_class
            funcs.update( base_cls.member_functions( query, recursive=False, allow_empty=True ) )
            funcs.update( base_cls.member_operators( relevant_opers & query, recursive=False, allow_empty=True ) )

            defined_funcs.update( base_cls.member_functions( all_not_pure_virtual, recursive=False, allow_empty=True ) )
            defined_funcs.update( base_cls.member_operators( all_not_pure_virtual & relevant_opers, recursive=False, allow_empty=True ) )

        not_reimplemented_funcs = set()
        is_same_function = declarations.is_same_function
        for f in funcs:
            cls_fs = self.calldefs( name=f.name, recursive=False, allow_empty=True )
            for cls_f in cls_fs:
                if is_same_function( f, cls_f ):
                    break
            else:
                #should test whether this function has been added or not
                for f_impl in not_reimplemented_funcs:
                    if is_same_function( f, f_impl ):
                        if declarations.is_base_and_derived( f_impl.parent, f.parent ):
                            #add function from the most derived class
                            not_reimplemented_funcs.remove( f_impl )
                            not_reimplemented_funcs.add( f )                       
                        break
                else:
                    #should test whether this function is implemented in base class
                    if f.virtuality != VIRTUALITY_TYPES.PURE_VIRTUAL:
                        not_reimplemented_funcs.add( f )
                    else:
                        for f_defined in defined_funcs:
                            if is_same_function( f, f_defined ):
                                break
                        else:
                            not_reimplemented_funcs.add( f )
        functions = list( not_reimplemented_funcs )
        functions.sort( cmp=lambda f1, f2: cmp( ( f1.name, f1.location.as_tuple() )
                                                , ( f2.name, f2.location.as_tuple() ) ) )
        self._redefined_funcs = functions
        return self._redefined_funcs
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:75,代码来源:class_wrapper.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python declarations.apply_visitor函数代码示例发布时间:2022-05-25
下一篇:
Python screen.Screen类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap