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

Python declarations.remove_reference函数代码示例

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

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



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

示例1: is_supported

    def is_supported(oper):
        """returns True if Boost.Python support the operator"""
        if oper.symbol == "*" and len(oper.arguments) == 0:
            # dereference does not make sense
            return False
        if oper.symbol != "<<":
            return oper.symbol in operators_helper.all

        args_len = len(oper.arguments)
        if isinstance(oper, declarations.member_operator_t):  # and args_len != 1:
            return False  # Boost.Python does not support member operator<< :-(
        if isinstance(oper, declarations.free_operator_t) and args_len != 2:
            return False
        if not declarations.is_same(oper.return_type, oper.arguments[0].type):
            return False
        type_ = oper.return_type
        if not declarations.is_reference(type_):
            return False
        type_ = declarations.remove_reference(type_)
        if declarations.is_const(type_):
            return False
        if args_len == 2:
            # second argument should has "T const &" type, otherwise the code will not compile
            tmp = oper.arguments[1].type
            if not declarations.is_reference(tmp):
                return False
            tmp = declarations.remove_reference(tmp)
            if not declarations.is_const(tmp):
                return False
        return declarations.is_std_ostream(type_) or declarations.is_std_wostream(type_)
开发者ID:ISoirar,项目名称:pypp11,代码行数:30,代码来源:calldef_wrapper.py


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


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


示例4: suspicious_type

 def suspicious_type(type_):
     if not declarations.is_reference(type_):
         return False
     type_no_ref = declarations.remove_reference(type_)
     return not declarations.is_const(type_no_ref) and (
         declarations.is_fundamental(type_no_ref) or declarations.is_enum(type_no_ref)
     )
开发者ID:ISoirar,项目名称:pypp11,代码行数:7,代码来源:calldef_wrapper.py


示例5: 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


示例6: 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


示例7: _update_containers_db

    def _update_containers_db( self, type_ ):
        #will return True is type was treated
        type_ = declarations.remove_alias( type_ )
        type_ = declarations.remove_pointer( type_ )
        type_ = declarations.remove_reference( type_ )
        type_ = declarations.remove_cv( type_ )
        type_ = declarations.remove_declarated( type_ )

        class_traits = declarations.class_traits
        class_declaration_traits = declarations.class_declaration_traits
        if not class_traits.is_my_case( type_ ) and not class_declaration_traits.is_my_case( type_ ):
            return False

        if class_traits.is_my_case( type_ ):
            container_cls = class_traits.get_declaration( type_ )
        else:
            container_cls = class_declaration_traits.get_declaration( type_ )

        if None is container_cls.indexing_suite:
            return False

        try:
            #check extraction of element type from container
            container_cls.indexing_suite.element_type
        except RuntimeError:
            decls_logger = _logging_.loggers.declarations
            if not messages.filter_disabled_msgs([messages.W1042], container_cls.disabled_messages ):
                return #user disabled property warning
            decls_logger.warn( "%s;%s" % ( container_cls, messages.W1042 ) )
        self.__containers.add( container_cls )
        return True
开发者ID:CTrauma,项目名称:pypp11,代码行数:31,代码来源:types_database.py


示例8: 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


示例9: 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


示例10: test

 def test( self ):                
     buggy = self.global_ns.mem_fun( 'buggy' )
     ExpressionError = self.global_ns.class_( 'ExpressionError' )
     self.failUnless( len( buggy.exceptions ) == 1 )
     err = buggy.exceptions[0]
     self.failUnless( declarations.is_reference( err ) )
     err = declarations.remove_declarated( declarations.remove_reference( err ) )
     self.failUnless( err is ExpressionError )
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:8,代码来源:type_as_exception_bug_tester.py


示例11: find_class

 def find_class(type_):
     type_ = declarations.remove_reference(type_)
     if declarations.is_class(type_):
         return declarations.class_traits.get_declaration(type_)
     elif declarations.is_class_declaration(type_):
         return declarations.class_declaration_traits.get_declaration(type_)
     else:
         return None
开发者ID:ISoirar,项目名称:pypp11,代码行数:8,代码来源:calldef_wrapper.py


示例12: check_type_compatibility

    def check_type_compatibility( self, fget, fset ):
        #algorithms allows "const" differences between types
        t1 = fget.return_type
        t2 = fset.arguments[0].type

        if declarations.is_same( t1, t2 ):
            return True
        elif declarations.is_pointer( t1 ) and declarations.is_pointer( t2 ):
            t1 = declarations.remove_cv( declarations.remove_pointer( t1 ) )
            t2 = declarations.remove_cv( declarations.remove_pointer( t2 ) )
            return declarations.is_same( t1, t2 )
        elif declarations.is_reference( t1 ) and declarations.is_reference( t2 ):
            t1 = declarations.remove_cv( declarations.remove_reference( t1 ) )
            t2 = declarations.remove_cv( declarations.remove_reference( t2 ) )
            return declarations.is_same( t1, t2 )
        else:
            return False
开发者ID:alekob,项目名称:tce,代码行数:17,代码来源:properties.py


示例13: test

 def test(self):
     buggy = self.global_ns.member_function('buggy')
     expression_error = self.global_ns.class_('ExpressionError')
     self.assertTrue(len(buggy.exceptions) == 1)
     err = buggy.exceptions[0]
     self.assertTrue(declarations.is_reference(err))
     err = declarations.remove_declarated(
         declarations.remove_reference(err))
     self.assertTrue(err is expression_error)
开发者ID:gccxml,项目名称:pygccxml,代码行数:9,代码来源:type_as_exception_bug_tester.py


示例14: 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


示例15: __is_invalid_integral

 def __is_invalid_integral(self, func, arg):
     type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
     if not declarations.is_integral(type_):
         return False
     try:
         int(arg.default_value)
         return False
     except:
         return True
开发者ID:praetorian20,项目名称:pygccxml,代码行数:9,代码来源:patcher.py


示例16: __fix_unqualified_enum

 def __fix_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
     enum_type = declarations.enum_declaration(type_)
     if self.__cxx_std.is_cxx11_or_greater:
         qualifier_decl_string = enum_type.decl_string
     else:
         qualifier_decl_string = enum_type.parent.decl_string
     return self.__join_names(
         qualifier_decl_string,
         arg.default_value.split('::')[-1])
开发者ID:praetorian20,项目名称:pygccxml,代码行数:10,代码来源:patcher.py


示例17: __is_unqualified_enum

 def __is_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
     if not declarations.is_enum(type_):
         return False
     enum_type = declarations.enum_declaration(type_)
     # GCCXML does not qualify an enum value in the default argument
     # but CastXML does. Split the default value and use only the
     # enum value for fixing it.
     return enum_type.has_value_name(
         arg.default_value.split('::')[-1])
开发者ID:praetorian20,项目名称:pygccxml,代码行数:10,代码来源:patcher.py


示例18: 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


示例19: _get_has_setter

    def _get_has_setter( self ):
        if declarations.is_const( declarations.remove_reference( self.declaration.type ) ):
            return False
        elif python_traits.is_immutable( self._get_exported_var_type() ):
            return True
        else:
            pass

        no_ref = declarations.remove_reference( self.declaration.type )
        no_const = declarations.remove_const( no_ref )
        base_type = declarations.remove_alias( no_const )
        if not isinstance( base_type, declarations.declarated_t ):
            return True #TODO ????
        decl = base_type.declaration
        if decl.is_abstract:
            return False
        if declarations.has_destructor( decl ) and not declarations.has_public_destructor( decl ):
            return False
        if not declarations.has_copy_constructor(decl):
            return False
        return True
开发者ID:CTrauma,项目名称:pypp11,代码行数:21,代码来源:member_variable.py


示例20: create_default

    def create_default(self):
        cntrl = self.controller.default_controller

        make_object = algorithm.create_identifier( self, 'pyplusplus::call_policies::make_object' )
        make_tuple = algorithm.create_identifier( self, 'boost::python::make_tuple' )
        
        tmpl_values = dict()

        tmpl_values['unique_function_name'] = self.default_name()
        tmpl_values['return_type'] = cntrl.wrapper_return_type.decl_string
        tmpl_values['arg_declarations'] = self.args_default_declaration()        
        tmpl_values['wrapper_class'] = self.parent.wrapper_alias
        tmpl_values['wrapped_class'] = declarations.full_name( self.declaration.parent )
        tmpl_values['wrapped_inst'] = cntrl.inst_arg.name
        tmpl_values['wrapped_inst_constness'] = ''
        if declarations.is_const( declarations.remove_reference( cntrl.inst_arg.type ) ):
            tmpl_values['wrapped_inst_constness'] = 'const'
            
        decl_vars = cntrl.variables[:]
        if not declarations.is_void( self.declaration.return_type ):
            decl_vars.append( cntrl.result_variable )
        tmpl_values['declare_variables'] \
            = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() )
                                                 , decl_vars ) )
                
        tmpl_values['pre_call'] = os.linesep + self.indent( os.linesep.join( cntrl.pre_call ) )

        tmpl_values['save_result'] = ''
        if not declarations.is_void( self.declaration.return_type ):
            tmpl_tmp = '%(result_var_name)s = '
            if declarations.is_reference( self.declaration.return_type ):
                tmpl_tmp = tmpl_tmp + '&'
            tmpl_values['save_result'] = tmpl_tmp % dict( result_var_name=cntrl.result_variable.name )

        tmpl_values['function_name'] = self.declaration.name
        tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions )
        return_stmt_creator = calldef_utils.return_stmt_creator_t( self
                                    , cntrl
                                    , cntrl.result_variable
                                    , cntrl.return_variables )

        tmpl_values['post_call'] = os.linesep + self.indent( os.linesep.join( cntrl.post_call ) )
        if return_stmt_creator.pre_return_code:
            tmpl_values['post_call'] \
                = os.linesep.join([ tmpl_values['post_call']
                                    , self.indent( return_stmt_creator.pre_return_code )])
        tmpl_values['return'] = os.linesep + self.indent( return_stmt_creator.statement )
            
        f_def = cntrl.template.substitute(tmpl_values)
        return remove_duplicate_linesep( f_def )
开发者ID:CTrauma,项目名称:pypp11,代码行数:50,代码来源:calldef_transformed.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python parser.parse函数代码示例发布时间:2022-05-25
下一篇:
Python declarations.remove_pointer函数代码示例发布时间: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