本文整理汇总了Python中pygccxml.declarations.remove_reference函数的典型用法代码示例。如果您正苦于以下问题:Python remove_reference函数的具体用法?Python remove_reference怎么用?Python remove_reference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_reference函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_)
示例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
示例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()
示例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)
)
示例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
示例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_ )
示例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
示例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)
示例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()
示例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 )
示例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
示例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
示例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)
示例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)
示例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