本文整理汇总了Python中pygccxml.declarations.remove_const函数的典型用法代码示例。如果您正苦于以下问题:Python remove_const函数的具体用法?Python remove_const怎么用?Python remove_const使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_const函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: _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
示例17: _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
示例18: __call__
def __call__( self, variable, hint=None ):
if not isinstance( variable, declarations.variable_t ):
return None
assert hint in ( 'get', 'set' )
if not declarations.is_reference( variable.type ):
return None
no_ref = declarations.remove_reference( variable.type )
base_type = declarations.remove_const( no_ref )
if python_traits.is_immutable( base_type ):
#the relevant code creator will generate code, that will return this member variable
#by value
return decl_wrappers.default_call_policies()
if not isinstance( base_type, declarations.declarated_t ):
return None
base_type = declarations.remove_alias( base_type )
decl = base_type.declaration
if declarations.is_class_declaration( decl ):
return None
if decl.is_abstract:
return None
if declarations.has_destructor( decl ) and not declarations.has_public_destructor( decl ):
return None
if not declarations.has_copy_constructor(decl):
return None
if hint == 'get':
#if we rich this line, it means that we are able to create an obect using
#copy constructor.
if declarations.is_const( no_ref ):
return decl_wrappers.return_value_policy( decl_wrappers.copy_const_reference )
else:
return decl_wrappers.return_value_policy( decl_wrappers.copy_non_const_reference )
else:
return decl_wrappers.default_call_policies()
开发者ID:alekob,项目名称:tce,代码行数:40,代码来源:call_policies_resolver.py
示例19: _exportable_impl
def _exportable_impl( self ):
all_types = [ arg.type for arg in self.arguments ]
all_types.append( self.return_type )
for some_type in all_types:
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:atemysemicolon,项目名称:pyplusplusclone,代码行数:22,代码来源:calldef_wrapper.py
示例20: check_args_exportable
def check_args_exportable ( function, ns ):
""" Look at each argument in the function and determine that we have exported it
or it's a special.
"""
ret = True
Specials = ['::Ogre::String']
for a in function.arguments:
rawarg = declarations.remove_declarated(
declarations.remove_const(
declarations.remove_reference(
declarations.remove_pointer ( a.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 declarations.is_enum(rawarg):
pass
elif 'Ogre::' in a.type.decl_string: # assume it's a class and needs checking
name = a.type.decl_string.split()[0] # let's grab the actual class name
if name in Specials: # we know that the classes in specials DO exist
pass
else:
try:
tcls = ns.class_(name)
if not tcls.exportable or tcls.ignore or type ( tcls.parent ) != decl_wrappers.namespace_wrapper.namespace_t:
## print "check_args_exportable: NOT EXPORTABLE:", tcls, tcls.exportable, tcls.ignore , type ( tcls.parent )
ret = False
break
else:
pass # print name, "IS exportable"
except:
print "check_args_exportable: unable to find:", name
ret = False
else:
print "check_args_exportable: NOT SURE...", a, a.type, type(a.type)
return ret
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:38,代码来源:swig_wrapper.py
注:本文中的pygccxml.declarations.remove_const函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论