def visit_array( self ): item_visitor = self.create_converter( declarations.array_item_type(self.user_type) ) item_type = declarations.apply_visitor( item_visitor, item_visitor.user_type ) size = declarations.array_size( self.user_type ) if size == declarations.array_t.SIZE_UNKNOWN: size = 0 return "( %s * %d )" % ( item_type, size )
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 ''
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 ''
def _register_array_1( self, array_type ): data = ( array_type.decl_string, declarations.array_size( array_type ) ) if data in self.__array_1_registered: return False else: self.__array_1_registered.add( data ) return True
def visit_array(self): item_visitor = self.create_converter( declarations.array_item_type(self.user_type)) item_type = declarations.apply_visitor(item_visitor, item_visitor.user_type) size = declarations.array_size(self.user_type) if size == declarations.array_t.SIZE_UNKNOWN: size = 0 return "( %s * %d )" % (item_type, size)
def wrapper_type( self ): tmpl = "%(namespace)s::%(constness)sarray_1_t< %(item_type)s, %(array_size)d>" constness = '' if declarations.is_const( self.declaration.type ): constness = 'const_' result = tmpl % { 'namespace' : code_repository.array_1.namespace , 'constness' : constness , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string , 'array_size': declarations.array_size( self.declaration.type ) } return declarations.dummy_type_t( result )
def _get_wrapper_type( self ): ns_name = code_repository.array_1.namespace if declarations.is_const( self.declaration.type ): class_name = 'const_array_1_t' else: class_name = 'array_1_t' decl_string = declarations.templates.join( '::'.join( [ns_name, class_name] ) , [ declarations.array_item_type( self.declaration.type ).decl_string , str( declarations.array_size( self.declaration.type ) ) ]) return declarations.dummy_type_t( decl_string )
def _create_impl(self): templates = declarations.templates call_invocation = declarations.call_invocation ns_name = code_repository.array_1.namespace if declarations.is_const( self.array_type ): fn_name = 'register_const_array_1' else: fn_name = 'register_array_1' fn_def_tmpl_args = [ declarations.array_item_type(self.array_type).decl_string , str( declarations.array_size(self.array_type) ) ] if not self.call_policies.is_default(): fn_def_tmpl_args.append( self.call_policies.create(self, call_policies.CREATION_POLICY.AS_TEMPLATE_ARGUMENT ) ) fn_def = templates.join( '::'.join( [ns_name, fn_name] ), fn_def_tmpl_args ) return call_invocation.join( fn_def, [ '"%s"' % self._create_name() ] ) + ';'
def wrapper_type( self ): tmpl = "%(namespace)s::%(constness)sarray_1_t< %(item_type)s, %(array_size)d>" item_type = declarations.array_item_type(self.declaration.decl_type) is_noncopyable = not declarations.is_fundamental(item_type) and \ declarations.is_noncopyable(item_type) constness = '' if declarations.is_const(self.declaration.decl_type) or is_noncopyable: constness = 'const_' result = tmpl % { 'namespace' : code_repository.array_1.namespace , 'constness' : constness , 'item_type' : declarations.array_item_type( self.declaration.decl_type ).decl_string , 'array_size': declarations.array_size( self.declaration.decl_type ) } return declarations.dummy_type_t( result )
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 = [ unit for unit in units if isinstance(unit, declarations.calldef_type_t) ] 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 ''
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 ''
def _create_name( self ): item_type = declarations.array_item_type(self.array_type) return "__array_1_%(type)s_%(size)d" \ % dict( type=algorithm.create_valid_name( item_type.decl_string ) , size=declarations.array_size(self.array_type) )