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


Python declarations.is_pointer函数代码示例

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


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

示例1: Fix_Pointer_Returns

def Fix_Pointer_Returns ( mb ):
    """ Change out functions that return a variety of pointers to base types and instead
    have them return the address the pointer is pointing to (the pointer value)
    This allow us to use CTypes to handle in memory buffers from Python
    
    Also - if documentation has been set then ignore the class/function as it means it's been tweaked else where
    """
    pointee_types=['unsigned int','int', 'float', 'unsigned char', '::udword', '::sbyte' ]
    known_names=[]  # these are function names we know it's cool to exclude
    for fun in mb.member_functions():
        if declarations.is_pointer (fun.return_type) and not fun.documentation:
            for i in pointee_types:
                if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
                    if not fun.name in known_names:
                        print "Excluding (function):", fun, "as it returns (pointer)", i
                    fun.exclude()
    try:                
        for fun in mb.member_operators():
            if declarations.is_pointer (fun.return_type) and not fun.documentation:
                for i in pointee_types:
                    if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
                        print "Excluding (operator):", fun
                        fun.exclude()
    except:
        pass
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:25,代码来源:generate_code.py

示例2: call_traits

def call_traits( type_ ):
    """http://boost.org/libs/utility/call_traits.htm"""
    type_ = declarations.remove_alias( type_ )
    if is_immutable( type_ ):
        return "%(arg)s" #pass by value
    elif declarations.is_reference( type_ ):
        no_ref = declarations.remove_reference( type_ )
        if is_immutable( no_ref ):
            return "%(arg)s" #pass by value
        else:
            return "boost::ref(%(arg)s)" #pass by ref
    elif declarations.is_pointer( type_ ) \
         and not is_immutable( type_.base ) \
         and not declarations.is_pointer( type_.base ):
        base = type_.base
        while hasattr(base, 'base'):
            base = base.base
        if hasattr(base.declaration, 'custom_call_trait'):
            custom_call_trait = base.declaration.custom_call_trait
            call_trait = custom_call_trait(type_) if custom_call_trait else None
            if call_trait:
                return call_trait
        return "boost::python::ptr(%(arg)s)" #pass by ptr
    else:
        return "%(arg)s" #pass by value
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:25,代码来源:python_traits.py

示例3: filter_decls

def filter_decls(mb):
    mb.global_ns.exclude()
    fx_ns = mb.namespace( 'FX' )
    fx_ns.include()
    fx_ns.decls( declarations_to_exclude.is_excluded ).exclude()
    fx_ns.decls( lambda decl: decl.name.startswith('FXIPCMsgHolder') ).exclude()
    fx_ns.namespace( 'Pol' ).exclude()
    fx_ns.decls( files_to_exclude.is_excluded ).exclude()
    fx_ns.class_( 'QValueList<FX::Pol::knowReferrers::ReferrerEntry>').exclude()
    try:
        fx_ns.variables( 'metaClass').exclude()
    except: pass
    try:
        fx_ns.class_( 'QPtrVector<FX::Generic::BoundFunctorV>').exclude()
    except: pass
    #Niall? wrapper for this function could not be compiled
    #TnFXSQLDBStatement = fx_ns.class_( 'TnFXSQLDBStatement' )
    #TnFXSQLDBStatement.member_function( name='bind', arg_types=[None,None,None] ).exclude()

    for func in fx_ns.calldefs():
        #I want to exclude all functions that returns pointer to pointer
        #and returns pointer to fundamental type
        if declarations.is_pointer( func.return_type ):
            temp = declarations.remove_pointer( func.return_type )
            if declarations.is_fundamental( temp ) and not declarations.is_const(temp):
                func.exclude()
            temp = declarations.remove_cv( func.return_type )
            temp = declarations.remove_pointer( temp )
            if declarations.is_pointer( temp ):
                func.exclude()
开发者ID:ned14,项目名称:tnfox,代码行数:30,代码来源:create_tnfox.py

示例4: fix_pointer_returns

def fix_pointer_returns (classes, pointee_types = None, ignore_names = None):
    """
    Change out functions that return a variety of pointer to base types and
    instead have them return the address the pointer is pointing to (the
    pointer value)
    
    This allow us to use CTypes to handle in memory buffers from Python
    
    Also - if documentation has been set then ignore the class/function as it
    means it's been tweaked else where
    """

    if pointee_types is None:
        pointee_types = ['unsigned int', 'int', 'float', 'double', 'char',
                         'unsigned char']
    if ignore_names is None:
        ignore_names = []

    for cls in classes:
        for fun in cls.member_functions( allow_empty = True ):
            if declarations.is_pointer (fun.return_type) and not fun.documentation:
                for i in pointee_types:
                    if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
                        if not fun.name in ignore_names:
                            decl_logger.info("Excluding (function): %s as it returns (pointer) %s" % (fun, i))
                        fun.exclude()
        for fun in cls.member_operators( allow_empty = True ):
            if declarations.is_pointer (fun.return_type) and not fun.documentation:
                for i in pointee_types:
                    if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
                        decl_logger.info("Excluding (operator): %s" % fun)
                        fun.exclude()
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:32,代码来源:wrap.py

示例5: Fix_Void_Ptr_Args

def Fix_Void_Ptr_Args ( mb ):
    """ we modify functions that take void *'s in their argument list to instead take
    unsigned ints, which allows us to use CTypes buffers
    """
    for fun in mb.member_functions():
        arg_position = 0
        for arg in fun.arguments:
            if declarations.type_traits.is_void_pointer(arg.type) or arg.type.decl_string == "void const *":
                fun.add_transformation( ft.modify_type(arg_position,_ReturnUnsignedInt ), alias=fun.name )
                fun.documentation = docit ("Modified Input Argument to work with CTypes",
                                            "Argument "+arg.name+ "(pos:" + str(arg_position)\
                                            +") takes a CTypes.adddressof(xx)", "...")
                print "Fixed Void Ptr", fun, arg_position
                break
            arg_position +=1
            
   ## lets go and look for stuff that might be a problem        
    pointee_types=['unsigned int',' int ', ' float ', ' Real ', 'uchar', 'uint8',
             'unsigned char']
                          
    function_names=[]
    for fun in mb.member_functions():
        if fun.documentation or fun.ignore: continue ## means it's been tweaked somewhere else
        for n in function_names:
            if n in fun.name:
                print "CHECK :", fun
                break
        arg_position = 0
        for arg in fun.arguments:
            if declarations.is_pointer(arg.type): ## and "const" not in arg.type.decl_string:
                for i in pointee_types:
                    if i in arg.type.decl_string:
                        print '"',arg.type.decl_string, '"'
                        print "CHECK ", fun, str(arg_position)
                        fun.documentation=docit("SUSPECT - MAYBE BROKEN", "....", "...")
                        break
            arg_position +=1

## NEED To do the same for constructors
    for fun in mb.constructors():
        arg_position = 0
        for arg in fun.arguments:
            if declarations.is_pointer(arg.type): ## and "const" not in arg.type.decl_string:
                for i in pointee_types:
                    if i in arg.type.decl_string:
                        print '"',arg.type.decl_string, '"'
                        print "Excluding: ", fun
                        fun.exclude()
                        break
            arg_position +=1         
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:50,代码来源:generate_code.py

示例6: Fix_Pointer_Returns

def Fix_Pointer_Returns ( mb, pointee_types=['unsigned int','int', 'float','char','unsigned char',
                            'bool', '::Ogre::uint8', '::Ogre::uint16', '::Ogre::uint32' ], known_names=[]):
    """ Change out functions that return a variety of pointer to base types and instead
    have them return the address the pointer is pointing to (the pointer value)
    This allow us to use CTypes to handle in memory buffers from Python
    
    Also - if documentation has been set then ignore the class/function as it means it's been tweaked else where
    """
    for fun in mb.member_functions( allow_empty = True ):
        if declarations.is_pointer (fun.return_type) and not fun.documentation:
#            print "Checking", fun, fun.return_type.decl_string
            for i in pointee_types:
                if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
                    if not fun.name in known_names:
                        print ("WARNING: Func (", fun.name, ") returns ", i, ".Using ctype return_addressof functionality")
                        fun.call_policies = call_policies.return_value_policy( call_policies.return_addressof )
                        fun.documentation=docit("CTYPE Integration - returns address of return value", "...", "Address of Return Value")
#                         print "WARNING: Excluding (function):", fun, "as it returns (pointer)", i
#                         fun.exclude()
    for fun in mb.member_operators( allow_empty = True ):
        if declarations.is_pointer (fun.return_type) and not fun.documentation:
            for i in pointee_types:
                if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
                    print ("WARNING: Excluding (operator):", fun)
                    fun.exclude()
                    
    # Change 15 Feb 2008 -- adding free function management                
    for fun in mb.free_functions( allow_empty = True ):
        if declarations.is_pointer (fun.return_type) and not fun.documentation:
            for i in pointee_types:
                if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
                    if not fun.name in known_names:
                        print ("WARNING: Excluding (free function):", fun, "as it returns (pointer)", i)
                        fun.exclude()
                        
    # Update 30 July 2008 -- support for void * variables to be exposed with ctypes handling                        
    for v in mb.variables( allow_empty=True ):
        supported = ['void const *','void *',
                     'char const *','char *',
                     'unsigned char const *','unsigned char *'
                     ]
        if v.type.decl_string in supported:
            try:  # this only works on memeber vars not global ones so need to check
                if v.access_type == 'public' and not v.documentation:
    #                 if not v.parent.noncopyable:    ## this test as we don't support classes with protected destructors
                    print ("CTYPE Implementation on ", v, v.access_type)
                    v.expose_address = True
            except : #RunTimeError:
                pass
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:49,代码来源:__init__.py

示例7: set_call_policies_pointee

def set_call_policies_pointee( mb ):
    # Set the default policy to deal with pointer/reference return types to reference_existing object
    # as this is the ogrenewt Default.
    ## NOTE AJM 1/1/07 -- this function not used as change to ref_existing_object..
    from pyplusplus import module_creator
    mem_funs = mb.calldefs ()
    mem_funs.create_with_signature = True 
    #MSVC 7.1 if function has throw modifier.
    resolver = module_creator.built_in_resolver_t()
    for mem_fun in mem_funs:
        if mem_fun.call_policies:
            continue
        decl_call_policies = resolver( mem_fun )
        if decl_call_policies:
            mem_fun.call_policies = decl_call_policies
            continue
        rtype = declarations.remove_alias( mem_fun.return_type )
        if declarations.is_pointer(rtype) or declarations.is_reference(rtype):
#             mem_fun.call_policies \
#                 = call_policies.return_value_policy( call_policies.reference_existing_object )
            mem_fun.call_policies \
               = call_policies.return_value_policy( '::boost::python::return_pointee_value' )
               
    ## now we fix a problem where the getSingleton policy isn't right               
    mb.mem_funs( 'getSingleton' ).call_policies = call_policies.return_value_policy(
                call_policies.reference_existing_object )
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:26,代码来源:generate_code.py

示例8: _exportable_impl

    def _exportable_impl( self ):
        if not self.name:
            return messages.W1033
        if self.bits == 0 and self.name == "":
            return messages.W1034
        if declarations.is_array( self.type ) and declarations.array_size( self.type ) < 1:
            return messages.W1045
        type_ = declarations.remove_alias( self.type )
        type_ = declarations.remove_const( type_ )
        if declarations.is_pointer( type_ ):
            if self.type_qualifiers.has_static:
                return messages.W1035
            if python_traits.is_immutable( type_.base ):
                return messages.W1036

            units = declarations.decompose_type( type_ )
            ptr2functions = filter( lambda unit: isinstance( unit, declarations.calldef_type_t )
                                    , units )
            if ptr2functions:
                return messages.W1037
        type_ = declarations.remove_pointer( type_ )
        if declarations.class_traits.is_my_case( type_ ):
            cls = declarations.class_traits.get_declaration( type_ )
            if not cls.name:
                return messages.W1038
        if isinstance( self.parent, declarations.class_t ):
            if self.access_type != declarations.ACCESS_TYPES.PUBLIC:
                return messages.W1039
        return ''
开发者ID:alekob,项目名称:tce,代码行数:29,代码来源:variable_wrapper.py

示例9: fix_ptr_fun

def fix_ptr_fun(fun, pointee_types = None, ignore_names = None, Exclude = False):
    """
    Allows to exclude or mark with a warning functions which take pointers as arguments
    It ignores already documented functions, because those have been fixed elsewhere
    """
    if pointee_types is None:
        pointee_types = []
    if ignore_names is None:
        ignore_names = []
        
    if fun.documentation or fun.ignore:
        # means it's been tweaked somewhere else
        return
    
    for n in ignore_names:
        if n in fun.name:
            return
    for arg in fun.arguments:
        # and "const" not in arg.type.decl_string:
        if declarations.is_pointer(arg.type): 
            for i in pointee_types:
                if arg.type.decl_string.startswith(i):
                    if Exclude: 
                        decl_logger.info("Excluding: %s due to pointer argument %s" %
                                         (fun, arg.type.decl_string))
                        fun.exclude()
                        return
                    else:
                        decl_logger.info("Function has pointer argument: %s %s" %
                                         (fun, arg.type.decl_string))
                        fun.documentation=docit("SUSPECT - MAYBE BROKEN due to pointer argument", "....", "...")
                        return
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:32,代码来源:wrap.py

示例10: wrap_ImageWindow

 def wrap_ImageWindow(self):
     self.mb.class_('ImageWindowReceiver').exclude()
     self.mb.class_('ImageWindowDispatcher').exclude()
     cls = self.mb.class_('ImageWindow')
     cls.include()
     cls.variables('handle').exclude()
     # get/set image
     fn1 = cls.member_function("getImage")
     fn1.call_policies = call_policies.return_internal_reference()
     fn2 = cls.member_function("setImage")
     fn2.call_policies = call_policies.with_custodian_and_ward(1,2)
     cls.add_property( 'image'
                  , cls.member_function( 'getImage' )
                  , cls.member_function( 'setImage' ) )
     # get/set name
     cls.add_property( 'name'
                  , cls.member_function( 'getName' )
                  , cls.member_function( 'setName' ) )
     # 3D window controls
     fn = cls.member_function("getView3DControl")
     fn.call_policies = call_policies.return_internal_reference()
     cls.add_property('view3DControl', fn)
     fn = cls.member_function("getLocalView3DControl")
     fn.call_policies = call_policies.return_internal_reference()
     cls.add_property('localView3DControl', fn)
     fn = cls.member_function("getTriviewControl")
     fn.call_policies = call_policies.return_internal_reference()
     cls.add_property('triViewControl', fn)
     # exclude constructor that takes void* argument
     for ctor in cls.constructors(arg_types = [None]):
         arg_t = ctor.argument_types[0]
         if (declarations.is_pointer(arg_t)):
             ctor.exclude()
开发者ID:Vaa3D,项目名称:vaa3d_tools,代码行数:33,代码来源:wrap_v3d_boost.py

示例11: _create_impl

 def _create_impl( self ):
     if declarations.is_pointer( self.declaration.type ):
         return self._generate_for_pointer()
     elif self.declaration.apply_smart_ptr_wa or self.declaration.use_make_functions:
         return self._generate_using_functions()
     else:
         return self._generate_for_none_pointer()
开发者ID:CTrauma,项目名称:pypp11,代码行数:7,代码来源:member_variable.py

示例12: remove_ref_or_ptr

def remove_ref_or_ptr( type_ ):
    if declarations.is_pointer( type_ ):
        return declarations.remove_pointer( type_ )
    elif declarations.is_reference( type_ ):
        return declarations.remove_reference( type_ )
    else:
        raise TypeError( 'Type should be reference or pointer, got %s.' % type_ )
开发者ID:asford,项目名称:pyplusplus,代码行数:7,代码来源:transformers.py

示例13: __find_out_class_dependencies

    def __find_out_class_dependencies( self, class_ ):
        full_name = declarations.full_name
        #class depends on it's base classes
        i_depend_on_them = set( [ full_name( base.related_class ) for base in class_.bases ] )
        #class depends on all classes that used in function as argument
        # types and those arguments have default value
        calldefs = filter( lambda decl: isinstance( decl, declarations.calldef_t )
                           , declarations.make_flatten( class_ ))
        for calldef in calldefs:
            for arg in calldef.arguments:
                if declarations.is_enum( arg.type ):
                    top_class_inst = self.__get_top_class_inst( declarations.enum_declaration( arg.type ) )
                    if top_class_inst:
                        i_depend_on_them.add( full_name( top_class_inst ) )
                    continue
                if not arg.default_value:
                    continue
                if declarations.is_pointer( arg.type ) and arg.default_value == 0:
                    continue
                base_type = declarations.base_type( arg.type )
                if not isinstance( base_type, declarations.declarated_t ):
                    continue
                top_class_inst = self.__get_top_class_inst( base_type.declaration )
                if top_class_inst:
                    i_depend_on_them.add( full_name( top_class_inst ) )

        for internal_cls in class_.classes(allow_empty=True):
            internal_cls_dependencies = self.__find_out_class_dependencies( internal_cls )
            i_depend_on_them.update( internal_cls_dependencies )

        i_depend_on_them = list( i_depend_on_them )
        i_depend_on_them.sort()
        return i_depend_on_them
开发者ID:BackupTheBerlios,项目名称:slon,代码行数:33,代码来源:sort_algorithms.py

示例14: keywords_args

 def keywords_args(self):
     if not self.__args:
         return ""
     boost_arg = self.__id_creator("::boost::python::arg")
     boost_obj = self.__id_creator("::boost::python::object")
     result = ["( "]
     for arg in self.__args:
         if 1 < len(result):
             result.append(self.PARAM_SEPARATOR)
         result.append(boost_arg)
         result.append('("%s")' % arg.name)
         if self.__decl.use_default_arguments and arg.default_value:
             if not declarations.is_pointer(arg.type) or arg.default_value != "0":
                 arg_type_no_alias = declarations.remove_alias(arg.type)
                 if (
                     declarations.is_fundamental(arg_type_no_alias)
                     and declarations.is_integral(arg_type_no_alias)
                     and not arg.default_value.startswith(arg_type_no_alias.decl_string)
                 ):
                     result.append("=(%s)(%s)" % (arg_type_no_alias.partial_decl_string, arg.default_value))
                 elif self.__should_use_enum_wa(arg):
                     # Work around for bug/missing functionality in boost.python.
                     # registration order
                     result.append("=(long)(%s)" % arg.default_value)
                 else:
                     result.append("=%s" % arg.default_value)
             else:
                 result.append("=%s()" % boost_obj)
     result.append(" )")
     return "".join(result)
开发者ID:rhinton,项目名称:tce,代码行数:30,代码来源:calldef_utils.py

示例15: wrap_one_QList

 def wrap_one_QList(self, cls):
     cls.include()
     cls.variables().exclude()
     # Avoid constructor that takes Node* argument
     for ctor in cls.constructors(arg_types=[None]):
         arg_t = ctor.argument_types[0]
         if (declarations.is_pointer(arg_t)):
             ctor.exclude()
     for fn_name in ['detach_helper_grow', 
                     'node_construct', 
                     'node_destruct',
                     'node_copy',
                     'fromVector',
                     'toVector',
                     'toSet',
                     'fromSet']:
         cls.member_functions(fn_name).exclude()
     for fn_name in ['back', 'first', 'front', 'last']:
         cls.member_functions(fn_name).call_policies = \
             call_policies.return_internal_reference()
     # TODO - add python sequence operators
     cls.include_files.append("qlist_py_indexing.h")
     cls.add_registration_code("""
         def(bp::indexing::container_suite<
                 %s, 
                 bp::indexing::all_methods, 
                 list_algorithms<qlist_container_traits<%s > > >())
         """ % (cls.demangled, cls.demangled) )
开发者ID:Vaa3D,项目名称:vaa3d_tools,代码行数:28,代码来源:wrap_v3d_boost.py


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