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


Python declarations.remove_const函数代码示例

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


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

示例1: _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

示例2: __configure_sealed

    def __configure_sealed(self, controller):
        global _seq2arr
        w_buffer_arg = controller.find_wrapper_arg( self.buffer_arg.name )
        w_buffer_arg.type = declarations.dummy_type_t( "boost::python::object" )

        controller.remove_wrapper_arg( self.size_arg.name )

        size_var = controller.declare_variable(
                          declarations.remove_const( self.size_arg.type )
                        , self.size_arg.name
                        , ' = boost::python::len(%s)' % w_buffer_arg.name )

        # Declare a variable that will hold the C array...
        buffer_var = controller.declare_variable(
                          declarations.dummy_type_t( "std::vector< %s >" % self.buffer_item_type.decl_string )
                        , "native_" + self.buffer_arg.name )

        controller.add_pre_call_code( '%s.reserve( %s );' % ( buffer_var, size_var ) )

        copy_pylist2arr = _seq2vector.substitute( type=self.buffer_item_type
                                                  , pylist=w_buffer_arg.name
                                                  , native_array=buffer_var )

        controller.add_pre_call_code( copy_pylist2arr )

        controller.modify_arg_expression( self.buffer_arg_index, '&%s[0]' % buffer_var )
        controller.modify_arg_expression( self.size_arg_index, '%s' % size_var )
开发者ID:asford,项目名称:pyplusplus,代码行数:27,代码来源:transformers.py

示例3: _get_exported_var_type

 def _get_exported_var_type( self ):
     type_ = declarations.remove_reference( self.declaration.type )
     type_ = declarations.remove_const( type_ )
     if python_traits.is_immutable( type_ ):
         return type_
     else:
         return self.declaration.type
开发者ID:CTrauma,项目名称:pypp11,代码行数:7,代码来源:member_variable.py

示例4: _exportable_impl

 def _exportable_impl(self):
     if self.transformations:
         # It is possible that the function asked for the user attention.
         # The user paid attention and created a transformation.
         # Py++ should be silent in this case.
         return ""
     if not self.parent.name:
         return messages.W1057 % str(self)
     all_types = [arg.type for arg in self.arguments]
     all_types.append(self.return_type)
     for some_type in all_types:
         if isinstance(some_type, declarations.ellipsis_t):
             return messages.W1053 % str(self)
         units = declarations.decompose_type(some_type)
         ptr2functions = filter(lambda unit: isinstance(unit, declarations.calldef_type_t), units)
         if ptr2functions:
             return messages.W1004
         # Function that take as agrument some instance of non public class
         # will not be exported. Same to the return variable
         if isinstance(units[-1], declarations.declarated_t):
             dtype = units[-1]
             if isinstance(dtype.declaration.parent, declarations.class_t):
                 if dtype.declaration not in dtype.declaration.parent.public_members:
                     return messages.W1005
         no_ref = declarations.remove_reference(some_type)
         no_ptr = declarations.remove_pointer(no_ref)
         no_const = declarations.remove_const(no_ptr)
         if declarations.is_array(no_const):
             return messages.W1006
     return self._exportable_impl_derived()
开发者ID:ISoirar,项目名称:pypp11,代码行数:30,代码来源:calldef_wrapper.py

示例5: __init__

    def __init__(self, function, buffer_arg_ref, size_arg_ref):
        """Constructor.

        :param buffer_arg_ref: "reference" to the buffer argument
        :param buffer_arg_ref: "reference" to argument, which holds buffer size
        """
        transformer.transformer_t.__init__(self, function)

        self.buffer_arg = self.get_argument(buffer_arg_ref)
        self.buffer_arg_index = self.function.arguments.index(self.buffer_arg)

        self.size_arg = self.get_argument(size_arg_ref)
        self.size_arg_index = self.function.arguments.index(self.size_arg)

        if not is_ptr_or_array(self.buffer_arg.type):
            raise ValueError(
                '%s\nin order to use "input_c_buffer" transformation, "buffer" argument %s type must be a array or a pointer (got %s).'
            ) % (function, self.buffer_arg.name, self.buffer_arg.type)

        if not declarations.is_integral(self.size_arg.type):
            raise ValueError(
                '%s\nin order to use "input_c_buffer" transformation, "size" argument %s type must be an integral type (got %s).'
            ) % (function, self.size_arg.name, self.size_arg.type)

        self.buffer_item_type = declarations.remove_const(declarations.array_item_type(self.buffer_arg.type))
开发者ID:ISoirar,项目名称:pypp11,代码行数:25,代码来源:transformers.py

示例6: add_decl_desc

def add_decl_desc(decl):
    try:
        # assume there are some docs for the declaration
        desc_list = dict_decl_name_to_desc[(decl.parent.name, decl.name)]
        desc_count = len(desc_list)-1
        reference = desc_list[desc_count]
    except KeyError:
        desc_list = None
        desc_count = 0
        reference = None
        
    try:
        # assume decl is a function
        for a in decl.arguments:
            if not a.name in decl._args_docs:
                continue
            arg = a.name
            add_decl_boost_doc(decl, "Argument '%s':" % arg)
            for z in decl._args_docs[arg]:
                add_decl_boost_doc(decl, "    "+z)
                
        if decl._output_args:
            # get the return value and output arguments
            return_list = []
            if decl.return_type.partial_decl_string!='void':
                return_type = _D.remove_const(_D.remove_reference(decl.return_type))
                pds = unique_pds(return_type.partial_decl_string)
                pds = current_sb.get_registered_decl_name(pds)
                return_list.append("(%s)" % pds)
            return_list.extend([x.name for x in decl._output_args])
                
            # document it
            add_decl_boost_doc(decl, "Returns:")
            s = ""
            for r in return_list:
                s += r+", "
            s = s[:-2]
            if len(return_list) > 1:
                s = "    ("+s+")"
            else:
                s = "    "+s
            add_decl_boost_doc(decl, s)
    except AttributeError:
        pass
        
    if reference is not None:
        add_decl_boost_doc(decl, "    "+reference, False, word_wrap=False)
        add_decl_boost_doc(decl, "Reference:", False)    
    try:
        # assume decl is a function
        alias = decl.transformations[0].alias if len(decl.transformations) > 0 else decl.alias
        if alias != decl.name:
            add_decl_boost_doc(decl, "    "+decl.name, False)
            add_decl_boost_doc(decl, "Wrapped function:", False)
    except AttributeError:
        pass
        
    for i in xrange(desc_count-1, -1, -1):
        add_decl_boost_doc(decl, desc_list[i], False)
开发者ID:BackupGGCode,项目名称:pyopencv,代码行数:59,代码来源:common.py

示例7: remove_const_from_reference

def remove_const_from_reference(type):
    "Helper to avoid compile errors with const-reference-protected-destructor argument types"
    if not type_traits.is_reference(type):
        return type
    nonref = declarations.remove_reference(type)
    if not type_traits.is_const(nonref):
        return type
    nonconst = declarations.remove_const(nonref)
    return cpptypes.reference_t(nonconst)
开发者ID:cmbruns,项目名称:osgpyplusplus,代码行数:9,代码来源:wrap_helpers.py

示例8: visit_reference

 def visit_reference( self ):
     no_ref = declarations.remove_const( declarations.remove_reference( self.user_type ) )
     if declarations.is_same( declarations.char_t(), no_ref ):
         return "ctypes.c_char_p"
     elif declarations.is_same( declarations.wchar_t(), no_ref ):
         return "ctypes.c_wchar_p"
     elif declarations.is_same( declarations.void_t(), no_ref ):
         return "ctypes.c_void_p"
     else:
         base_visitor = self.create_converter( self.user_type.base )
         internal_type_str = declarations.apply_visitor( base_visitor, base_visitor.user_type )
         return "ctypes.POINTER( %s )" % internal_type_str
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:12,代码来源:ctypes_formatter.py

示例9: __should_be_exposed_by_address_only

 def __should_be_exposed_by_address_only(self):
     type_ = declarations.remove_alias( self.type )
     type_ = declarations.remove_const( type_ )
     type_ = declarations.remove_pointer( type_ )
     if not declarations.class_traits.is_my_case( type_ ):
         return False
     cls = declarations.class_traits.get_declaration( type_ )
     if cls.class_type == declarations.CLASS_TYPES.UNION:
         return True
     elif not cls.name:
         return True
     else:
         return False
开发者ID:CTrauma,项目名称:pypp11,代码行数:13,代码来源:variable_wrapper.py

示例10: visit_pointer

 def visit_pointer( self ):
     no_ptr = declarations.remove_const( declarations.remove_pointer( self.user_type ) )
     if declarations.is_same( declarations.char_t(), no_ptr ) and self.treat_char_ptr_as_binary_data == False:
         return "ctypes.c_char_p"
     elif declarations.is_same( declarations.wchar_t(), no_ptr ) and self.treat_char_ptr_as_binary_data == False:
         return "ctypes.c_wchar_p"
     elif declarations.is_same( declarations.void_t(), no_ptr ):
         return "ctypes.c_void_p"
     else:
         base_visitor = self.create_converter( self.user_type.base )
         internal_type_str = declarations.apply_visitor( base_visitor, base_visitor.user_type )
         if declarations.is_calldef_pointer( self.user_type ):
             return internal_type_str
         else:
             return "ctypes.POINTER( %s )" % internal_type_str
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:15,代码来源:ctypes_formatter.py

示例11: _get_call_policies

 def _get_call_policies(self):
     if self.__call_policies:
         return self.__call_policies
     if self.container_traits not in declarations.sequential_container_traits:
         # TODO: find out why map's don't like the policy
         return self.__call_policies
     element_type = None
     try:
         element_type = self.element_type
     except:
         return
     if declarations.is_const(element_type):
         element_type = declarations.remove_const(element_type)
     if declarations.is_pointer(element_type):
         self.__call_policies = call_policies.return_internal_reference()
     return self.__call_policies
开发者ID:rhinton,项目名称:tce,代码行数:16,代码来源:indexing_suite2.py

示例12: __init__

    def __init__(self, function, arg_ref, size):
        """Constructor.

        @param size: The fixed size of the input array
        @type size: int
        """
        transformer.transformer_t.__init__( self, function )
        
        self.arg = self.get_argument( arg_ref )
        self.arg_index = self.function.arguments.index( self.arg )
        
        if not is_ptr_or_array( self.arg.type ):
            raise ValueError( '%s\nin order to use "input_array" transformation, argument %s type must be a array or a pointer (got %s).' ) \
                  % ( function, self.arg.name, self.arg.type)

        self.array_size = size
        self.array_item_type = declarations.remove_const( declarations.array_item_type( self.arg.type ) )
开发者ID:alekob,项目名称:tce,代码行数:17,代码来源:transformers.py

示例13: str_from_ostream

def str_from_ostream(ns):
    """
    Finds all free operators, then exposes only the ones with classes
    currently exposed then Py++ can do the rest.
    """
    for oper in ns.free_operators( '<<' ):
        rtype = declarations.remove_declarated(
            declarations.remove_reference( oper.return_type ) )
        type_or_decl = declarations.remove_declarated(
            declarations.remove_const(
            declarations.remove_reference( oper.arguments[1].type)))
        
        if not isinstance( type_or_decl, declarations.declaration_t ):
            continue
        if type_or_decl.ignore == False:
            decl_logger.info("Exposing operator<<: " + str(oper))
            oper.include()
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:17,代码来源:wrap.py

示例14: __init__

    def __init__(self, function, arg_ref, rows, columns):
        """Constructor.

        :param rows, columns: The fixed size of the input matrix
        :type rows, columns: int
        """
        transformer.transformer_t.__init__( self, function )

        self.arg = self.get_argument( arg_ref )
        self.arg_index = self.function.arguments.index( self.arg )

        if not is_ptr_or_array( self.arg.type ):
            raise ValueError( '%s\nin order to use "input_matrix" transformation, argument %s type must be a array or a pointer (got %s).' ) \
                  % ( function, self.arg.name, self.arg.type)

        self.rows = rows
        self.columns = columns
        self.matrix_item_type = declarations.remove_const( declarations.array_item_type( declarations.array_item_type( self.arg.type ) ) )
开发者ID:asford,项目名称:pyplusplus,代码行数:18,代码来源:transformers.py

示例15: __init__

    def __init__(self, function, arg_ref, size):
        """Constructor.

        :param maxsize: The maximum string size we will allow...
        :type maxsize: int
        """
        transformer.transformer_t.__init__( self, function )

        self.arg = self.get_argument( arg_ref )
        self.arg_index = self.function.arguments.index( self.arg )

        if not is_ptr_or_array( self.arg.type ):
            raise ValueError( '%s\nin order to use "input_array" transformation, argument %s type must be a array or a pointer (got %s).' ) \
                  % ( function, self.arg.name, self.arg.type)

        self.max_size = size
        self.array_item_type = declarations.remove_const( declarations.array_item_type( self.arg.type ) )
        self.array_item_rawtype = declarations.remove_cv( self.arg.type )
        self.array_item_rawtype = declarations.pointer_t( self.array_item_type )
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:19,代码来源:PO_FuncTransform.py


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