本文整理汇总了Python中pygccxml.declarations.is_reference函数的典型用法代码示例。如果您正苦于以下问题:Python is_reference函数的具体用法?Python is_reference怎么用?Python is_reference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_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: 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
示例3: 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
示例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: 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
示例8: 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
示例9: 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
示例10: visit_variable
def visit_variable(self):
self.__types_db.update( self.curr_decl )
self.__dependencies_manager.add_exported( self.curr_decl )
if self.curr_decl.expose_address:
creator_type = None
if isinstance( self.curr_decl.parent, declarations.namespace_t ):
creator_type = code_creators.global_variable_addressof_t
else:
creator_type = code_creators.member_variable_addressof_t
self.curr_code_creator.adopt_creator( creator_type(self.curr_decl) )
return
if not self.curr_decl.expose_value:
return
if declarations.is_array( self.curr_decl.type ):
if self._register_array_1( self.curr_decl.type ):
array_1_registrator = code_creators.array_1_registrator_t( array_type=self.curr_decl.type )
self.curr_code_creator.adopt_creator( array_1_registrator )
if isinstance( self.curr_decl.parent, declarations.namespace_t ):
maker = None
wrapper = None
if declarations.is_array( self.curr_decl.type ):
wrapper = code_creators.array_gv_wrapper_t( variable=self.curr_decl )
maker = code_creators.array_gv_t( variable=self.curr_decl, wrapper=wrapper )
else:
maker = code_creators.global_variable_t( variable=self.curr_decl )
if wrapper:
self.__extmodule.adopt_declaration_creator( wrapper )
else:
maker = None
wrapper = None
if self.curr_decl.bits != None:
wrapper = code_creators.bit_field_wrapper_t( variable=self.curr_decl )
maker = code_creators.bit_field_t( variable=self.curr_decl, wrapper=wrapper )
elif declarations.is_array( self.curr_decl.type ):
wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )
maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )
elif declarations.is_pointer( self.curr_decl.type ):
wrapper = code_creators.member_variable_wrapper_t( variable=self.curr_decl )
maker = code_creators.member_variable_t( variable=self.curr_decl, wrapper=wrapper )
elif declarations.is_reference( self.curr_decl.type ):
if None is self.curr_decl.getter_call_policies:
self.curr_decl.getter_call_policies = self.__call_policies_resolver( self.curr_decl, 'get' )
if None is self.curr_decl.setter_call_policies:
self.curr_decl.setter_call_policies = self.__call_policies_resolver( self.curr_decl, 'set' )
wrapper = code_creators.mem_var_ref_wrapper_t( variable=self.curr_decl )
maker = code_creators.mem_var_ref_t( variable=self.curr_decl, wrapper=wrapper )
self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
else:
maker = code_creators.member_variable_t( variable=self.curr_decl )
if wrapper:
self.curr_code_creator.wrapper.adopt_creator( wrapper )
self.curr_code_creator.adopt_creator( maker )
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:56,代码来源:bpcreator.py
示例11: setDefaultCallPolicies
def setDefaultCallPolicies(ns):
# Set the default policy to deal with pointer/reference return types to reference_existing object
# as this is the CEGUI Default.
mem_funs = ns.calldefs()
mem_funs.create_with_signature = True #Generated code will not compile on
#MSVC 7.1 if function has throw modifier.
for mem_fun in mem_funs:
if mem_fun.call_policies:
continue
if declarations.is_pointer (mem_fun.return_type) or declarations.is_reference (mem_fun.return_type):
mem_fun.call_policies = call_policies.return_value_policy(call_policies.reference_existing_object)
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:11,代码来源:common_utils.py
示例12: get_overridable
def get_overridable( self ):
"""Check if the method can be overridden."""
if None is self._overridable:
if isinstance( self, declarations.member_calldef_t ) \
and self.virtuality != declarations.VIRTUALITY_TYPES.NOT_VIRTUAL \
and declarations.is_reference( self.return_type ):
self._overridable = False
self._non_overridable_reason = messages.W1049
else:
self._overridable = True
self._non_overridable_reason = ""
return self._overridable
开发者ID:BackupTheBerlios,项目名称:slon,代码行数:12,代码来源:calldef_wrapper.py
示例13: Set_Call_Policies
def Set_Call_Policies( mb ):
""" set the return call policies on classes that this hasn't already been done for.
Set the default policy to deal with pointer/reference return types to reference_existing object
"""
mem_funs = mb.calldefs ()
mem_funs.create_with_signature = True #Generated code will not compile on
#MSVC 7.1 if function has throw modifier.
for mem_fun in mem_funs:
if mem_fun.call_policies:
continue
if not mem_fun.call_policies and \
(declarations.is_reference (mem_fun.return_type) or declarations.is_pointer (mem_fun.return_type) ):
mem_fun.call_policies = call_policies.return_value_policy(
call_policies.reference_existing_object )
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:14,代码来源:generate_code.py
示例14: create_holder
def create_holder( self, class_decl ):
#holder should be created when we pass object created in python
#as parameter to function in C++ that takes the smart pointer by reference
found = self._find_smart_ptrs( self.__arguments_types, class_decl )
if not found:
return None#not found or ambiguty
held_type = None
for smart_ptr, type_ in found:
if declarations.is_reference( type_ ) and not declarations.is_const( type_.base ):
temp = code_creators.held_type_t( smart_ptr=smart_ptr )
if not held_type or 'shared_ptr' in smart_ptr:
held_type = temp
return held_type
开发者ID:CTrauma,项目名称:pypp11,代码行数:14,代码来源:types_database.py
示例15: 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
示例16: is_wrapper_needed
def is_wrapper_needed(self):
"""returns an explanation( list of str ) why wrapper is needed.
If wrapper is not needed than [] will be returned.
"""
explanation = []
if self.bits:
explanation.append( messages.W1024 % self.name )
if declarations.is_pointer( self.type ):
explanation.append( messages.W1025 % self.name )
if declarations.is_reference( self.type ):
explanation.append( messages.W1026 % self.name )
if declarations.is_array( self.type ):
explanation.append( messages.W1027 % self.name)
return explanation
开发者ID:CTrauma,项目名称:pypp11,代码行数:15,代码来源:variable_wrapper.py
示例17: visit_casting_operator
def visit_casting_operator( self ):
self.__dependencies_manager.add_exported( self.curr_decl )
if None is self.curr_decl.call_policies:
self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
self.__types_db.update( self.curr_decl )
if not self.curr_decl.parent.is_abstract and not declarations.is_reference( self.curr_decl.return_type ):
maker = code_creators.casting_operator_t( operator=self.curr_decl )
self.__module_body.adopt_creator( maker )
self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
#what to do if class is abstract
maker = code_creators.casting_member_operator_t( operator=self.curr_decl )
self.curr_code_creator.adopt_creator( maker )
self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
开发者ID:Axitonium,项目名称:py-source-sdk-2013,代码行数:15,代码来源:bpcreator.py
示例18: call_traits
def call_traits( type_ ):
"""http://boost.org/libs/utility/call_traits.htm"""
type_ = declarations.remove_alias( type_ )
if is_immutable( type_ ):
return "%s" #pass by value
elif declarations.is_reference( type_ ):
no_ref = declarations.remove_reference( type_ )
if is_immutable( no_ref ):
return "%s" #pass by value
else:
return "boost::ref(%s)" #pass by ref
elif declarations.is_pointer( type_ ) \
and not is_immutable( type_.base ) \
and not declarations.is_pointer( type_.base ):
return "boost::python::ptr(%s)" #pass by ptr
else:
return "%s" #pass by value
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:17,代码来源:python_traits.py
示例19: __init__
def __init__( self, function ):
controller_base_t.__init__( self, function )
self.__vars_manager = create_variables_manager( function )
self.__wrapper_args = [ arg.clone() for arg in function.arguments ]
initialize_expr = ''
result_type = self.function.return_type
if declarations.is_reference( self.function.return_type ):
initialize_expr = ' = 0'
result_type = declarations.pointer_t( declarations.remove_reference( self.function.return_type ) )
self.__result_var = variable_t( result_type
, self.register_variable_name( 'result' )
, initialize_expr=initialize_expr )
self.__return_variables = []
self.__pre_call = []
self.__post_call = []
self.__arg_expressions = [ arg.name for arg in function.arguments ]
开发者ID:Sandern,项目名称:py-source-sdk-2013,代码行数:17,代码来源:controllers.py
示例20: create_fun_definition
def create_fun_definition(self):
cntrl = self.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.wrapper_name()
tmpl_values['return_type'] = self.controller.wrapper_return_type.decl_string
tmpl_values['arg_declarations'] = self.args_declaration()
tmpl_values['declare_variables'] \
= os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() )
, cntrl.variables ) )
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 = '%(type)s %(name)s = '
if declarations.is_reference( self.declaration.return_type ):
tmpl_tmp = tmpl_tmp + '&'
tmpl_values['save_result'] = tmpl_tmp \
% { 'type': cntrl.result_variable.type.decl_string
, 'name' : cntrl.result_variable.name }
tmpl_values['function_name'] = self.resolve_function_ref()
tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions )
return_stmt_creator = calldef_utils.return_stmt_creator_t( self
, self.controller
, self.controller.result_variable
, self.controller.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 = self.controller.template.substitute(tmpl_values)
return remove_duplicate_linesep( f_def )
开发者ID:CTrauma,项目名称:pypp11,代码行数:44,代码来源:calldef_transformed.py
注:本文中的pygccxml.declarations.is_reference函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论