本文整理汇总了Python中pygccxml.declarations.remove_alias函数的典型用法代码示例。如果您正苦于以下问题:Python remove_alias函数的具体用法?Python remove_alias怎么用?Python remove_alias使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_alias函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: _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
示例3: 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
示例4: 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
示例5: _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
示例6: bind_aliases
def bind_aliases(decls):
"""
This function binds between class and it's typedefs.
:param decls: list of all declarations
:type all_classes: list of :class:`declarations.declaration_t` items
:rtype: None
"""
visited = set()
typedefs = [
decl for decl in decls if isinstance(decl, declarations.typedef_t)]
for decl in typedefs:
type_ = declarations.remove_alias(decl.type)
if not isinstance(type_, declarations.declarated_t):
continue
cls_inst = type_.declaration
if not isinstance(cls_inst, declarations.class_types):
continue
if id(cls_inst) not in visited:
visited.add(id(cls_inst))
del cls_inst.aliases[:]
cls_inst.aliases.append(decl)
开发者ID:iMichka,项目名称:pygccxml,代码行数:25,代码来源:source_reader.py
示例7: _resolve_by_type
def _resolve_by_type( self, some_type ):
temp_type = declarations.remove_alias( some_type )
temp_type = declarations.remove_cv( temp_type )
if isinstance( temp_type, declarations.fundamental_t ) \
or isinstance( temp_type, declarations.declarated_t ):
return decl_wrappers.default_call_policies()
if declarations.is_same( some_type, self.__const_char_pointer ):
return decl_wrappers.default_call_policies()
return None
开发者ID:alekob,项目名称:tce,代码行数:9,代码来源:call_policies_resolver.py
示例8: find_out_depend_on_declaration
def find_out_depend_on_declaration( self ):
"""if declaration depends on other declaration and not on some type
this function will return reference to it. Otherwise None will be returned
"""
#prevent recursive import
from pygccxml import declarations
if isinstance( self.depend_on_it, declarations.declaration_t ):
return self.depend_on_it
base_type = declarations.base_type( declarations.remove_alias( self.depend_on_it ) )
if isinstance( base_type, cpptypes.declarated_t ):
return base_type.declaration
return None
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:13,代码来源:dependencies.py
示例9: __call__
def __call__( self, calldef, hint=None ):
if not isinstance( calldef, declarations.calldef_t ):
return None
if isinstance( calldef, declarations.constructor_t ):
return None
return_type = declarations.remove_alias( calldef.return_type )
void_ptr = declarations.pointer_t( declarations.void_t() )
const_void_ptr = declarations.pointer_t( declarations.const_t( declarations.void_t() ) )
if declarations.is_same( return_type, void_ptr ) \
or declarations.is_same( return_type, const_void_ptr ):
return decl_wrappers.return_value_policy( decl_wrappers.return_opaque_pointer )
return None
开发者ID:alekob,项目名称:tce,代码行数:13,代码来源:call_policies_resolver.py
示例10: __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
示例11: _get_alias
def _get_alias(self):
if not self._alias or self.name == super(casting_operator_t, self)._get_alias():
return_type = declarations.remove_alias(self.return_type)
decl_string = return_type.decl_string
for type_, alias in self.SPECIAL_CASES.items():
if isinstance(type_, declarations.type_t):
if declarations.is_same(return_type, type_):
self._alias = alias
break
else:
if decl_string == type_:
self._alias = alias
break
else:
self._alias = "as_" + self._generate_valid_name(self.return_type.decl_string)
return self._alias
开发者ID:ISoirar,项目名称:pypp11,代码行数:16,代码来源:calldef_wrapper.py
示例12: __format_type_as_undecorated
def __format_type_as_undecorated( self, type_, is_argument, hint ):
result = []
type_ = declarations.remove_alias( type_ )
if declarations.is_array( type_ ):
result.append( declarations.array_item_type( type_ ).decl_string )
result.append( '*' )
if is_argument:
result.append( 'const' )
else:
result.append( self.__remove_leading_scope( type_.decl_string ) )
result = ' '.join( result )
if hint == 'nm':
for x in ( '*', '&' ):
result = result.replace( ' ' + x, x )
return result
开发者ID:Noitidart,项目名称:osxtypes,代码行数:16,代码来源:undname.py
示例13: 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
示例14: dig_declarations
def dig_declarations( depend_on_it ):
#prevent recursive import
from pygccxml import declarations
if isinstance( depend_on_it, declarations.declaration_t ):
return [depend_on_it]
base_type = declarations.base_type( declarations.remove_alias( depend_on_it ) )
if isinstance( base_type, cpptypes.declarated_t ):
return [base_type.declaration]
elif isinstance( base_type, cpptypes.calldef_type_t ):
result = []
result.extend( impl_details.dig_declarations( base_type.return_type ) )
for argtype in base_type.arguments_types:
result.extend( impl_details.dig_declarations( argtype ) )
if isinstance( base_type, cpptypes.member_function_type_t ):
result.extend( impl_details.dig_declarations( base_type.class_inst ) )
return result
return []
开发者ID:Noitidart,项目名称:osxtypes,代码行数:18,代码来源:dependencies.py
示例15: _exportable_impl
def _exportable_impl( self ):
if not self.parent.name and self.is_wrapper_needed():
#return messages.W1057 % str( self )
return messages.W1058 % str( self )
if not self.name:
return messages.W1033
if self.bits == 0 and self.name == "":
return messages.W1034
if not self.expose_address:
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 not self.expose_address and self.type_qualifiers.has_static:
return messages.W1035
if not self.expose_address and 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 cls.class_type == declarations.CLASS_TYPES.UNION:
# return messages.W1061 % ( str( self ), str( cls ) )
if isinstance( self.parent, declarations.class_t ):
if self.access_type != declarations.ACCESS_TYPES.PUBLIC:
return messages.W1039
if declarations.is_array( type_ ):
item_type = declarations.array_item_type( type_ )
if declarations.is_pointer( item_type ):
item_type_no_ptr = declarations.remove_pointer( item_type )
if python_traits.is_immutable( item_type_no_ptr ):
return messages.W1056
return ''
开发者ID:CTrauma,项目名称:pypp11,代码行数:41,代码来源:variable_wrapper.py
示例16: _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
示例17: __find_out_is_read_only
def __find_out_is_read_only(self):
type_ = declarations.remove_alias( self.type )
if isinstance( type_, declarations.const_t ):
return True
if declarations.is_pointer( type_ ):
type_ = declarations.remove_pointer( type_ )
if declarations.is_reference( type_ ):
type_ = declarations.remove_reference( type_ )
if isinstance( type_, declarations.const_t ):
return True
if self.apply_smart_ptr_wa:
return False #all smart pointers has assign operator
if isinstance( type_, declarations.declarated_t ) \
and isinstance( type_.declaration, declarations.class_t ) \
and not declarations.has_public_assign( type_.declaration ):
return True
return False
开发者ID:alekob,项目名称:tce,代码行数:23,代码来源:variable_wrapper.py
示例18: set_array_item_type_as_size_t
def set_array_item_type_as_size_t(klass, member_name):
_D.remove_cv(_D.remove_alias(klass.var(member_name).type)).base = size_t_t()
开发者ID:BackupGGCode,项目名称:pyopencv,代码行数:2,代码来源:memvar_transformers.py
示例19: Auto_Functional_Transformation
def Auto_Functional_Transformation ( mb, ignore_funs=[], special_vars=[]):
toprocess = []
aliases={}
for fun in mb.member_functions(allow_empty=True):
toprocess.append( fun )
for fun in mb.free_functions(allow_empty=True):
toprocess.append( fun )
for fun in toprocess:
fun_demangled = fun.demangled # need to check as extern functions don't have demangled name...
if fun_demangled:
# try: # ugly wrapping in a try :(
fullname = fun.demangled.split('(')[0]
if fullname not in ignore_funs and not fun.ignore:
outputonly = False
arg_position = 0
trans=[]
desc=""
ft_type = None
ctypes_conversion = False
for arg in fun.arguments:
rawarg = declarations.remove_declarated(
declarations.remove_const(
declarations.remove_reference(
declarations.remove_pointer ( arg.type ))))
## now check if the arg is a fundemental type (int float etc), a void
## or a special ..
if declarations.is_arithmetic (rawarg)\
or declarations.is_void(rawarg)\
or arg.type.decl_string in special_vars:
if declarations.is_pointer(arg.type): #we convert any pointers to unsigned int's
# now look to see if it's a char * and if so we treat it as a string..
# # print "**" , declarations.remove_alias( rawarg ), declarations.type_traits.create_cv_types( declarations.cpptypes.char_t())
if declarations.remove_alias( rawarg ) in declarations.type_traits.create_cv_types( declarations.cpptypes.char_t() ):
print ("MATCHED CString", fun)
trans.append( ft.input_c_string(arg_position, 4096 ) )
desc = desc +"Argument: "+arg.name+ "( pos:" + str(arg_position) + " - " +\
arg.type.decl_string + " ) takes a python string. \\n"
ctypes_conversion = True
ctypes_arg = arg.type.decl_string.split()[0]
ft_type = 'CTYPES'
else:
trans.append( ft.modify_type(arg_position,_ReturnUnsignedInt ) )
desc = desc +"Argument: "+arg.name+ "( pos:" + str(arg_position) + " - " +\
arg.type.decl_string + " ) takes a CTypes.addressof(xx). \\n"
ctypes_conversion = True
ctypes_arg = arg.type.decl_string.split()[0]
ft_type = 'CTYPES'
elif declarations.is_reference(arg.type)and not declarations.is_const(declarations.remove_reference( arg.type)): # seen functions passing const ref's
trans.append( ft.inout(arg_position ) )
desc = desc + "Argument: "+arg.name+ "( pos:" + str(arg_position) + " - " +\
arg.type.decl_string + " ) converted to an input/output (change to return types).\\n"
ft_type = 'INOUT'
elif declarations.is_reference(arg.type):
print ("Warning: - possible code change.", fun,arg," not wrapped as const reference to base type invalid")
else:
pass # it isn't a pointer or reference so doesn't need wrapping
else:
pass # it's not a var we need to handle
arg_position += 1
if trans:
const_return = False # declarations.is_const(fun)
if fun.decl_string.endswith('const'):
const_return=True
simple_return = declarations.is_arithmetic(fun.return_type) or declarations.is_void(fun.return_type)
nonpublic_destructor = declarations.is_class(fun.parent) and declarations.has_destructor(fun.parent) and\
not declarations.has_public_destructor(fun.parent)
if fun.documentation or fun.transformations: # it's already be tweaked:
print ("AUTOFT ERROR: Duplicate Tranforms.", fun, fun.documentation)
# if the class has a protected destruction AND the return value is const or a non arithmatic value then exclude it.
elif nonpublic_destructor and const_return:
print ("AUTOFT ERROR Const: Parent has non public destructor and const return.", fun.parent.name, fun.return_type.decl_string, fun)
fun.documentation="Python-Ogre Warning: function required transformation - not possible due to non public destructor and const return value.."
elif nonpublic_destructor and not simple_return:
print ("AUTOFT ERROR Const: Parent has non public destructor and complex return value.", fun.parent.name, fun.return_type.decl_string, fun)
fun.documentation="Python-Ogre Warning: function required transformation - not possible due to non public destructor and complex return value.."
else:
new_alias = fun.name
if ctypes_conversion: # only manage name changes if ctypes changing
# now lets look for a duplicate function name with the same number arguments
f= [None]*len(fun.arguments)
s = mb.member_functions("::" + fullname, arg_types=f, allow_empty=True)
if len (s) > 1:
# there are duplicate names so need to create something unique
ctypes_arg = ctypes_arg.replace("::", "_") # to clean up function names...
new_alias = fun.name + ctypes_arg[0].upper() + ctypes_arg[1:]
# now for REAL ugly code -- we have faked a new alias and it may not be unique
# so we track previous alias + class name to ensure unique names are generated
keyname = fullname + new_alias # we use the full class + function name + alias as the key
if keyname in aliases: # already exists, need to fake another version..
new_alias = new_alias + "_" + str( aliases[keyname] )
aliases[keyname] = aliases[keyname] + 1
else:
aliases[keyname] = 1
desc = desc + "\\\nWARNING FUNCTION NAME CHANGE - from "+fun.name + " -- " + fun.decl_string +" to " + new_alias + " \\n"
print ("INFO: Adjusting Alias as multiple overlapping functions:", new_alias)
#.........这里部分代码省略.........
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:101,代码来源:__init__.py
示例20: get_pointee
def get_pointee( self, sp_instantiation ):
#sp_instantiation - reference to SharedPtr<XXX>
#returns reference to XXX type/declaration
no_ptr = declarations.remove_pointer( sp_instantiation.variable ('pRep').type )
no_alias = declarations.remove_alias( no_ptr )
return declarations.remove_declarated( no_alias )
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:6,代码来源:shared_ptr.py
注:本文中的pygccxml.declarations.remove_alias函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论