def setTreeNodeInfo(self, decl): decom = decls.decompose_type(decl) decom.reverse() # decom for int** is now [int, int*, int**] self._pgxDecl = base = decls.type_traits.remove_declarated(decom[0]) # type base is either fundamental type or class/enum/else. TODO: void if decls.type_traits.is_fundamental(base): self._baseName = base.decl_string self._baseTypeName = funIdlMapping(base) self._deriveTypeName = funIdlMappingShort(base) # TODO: let classes/enums/... objects control it's name or control it from here? # TODO2: specify the _whole_ mechanism behind this class else: self._baseName = base.decl_string self._baseTypeName = self._deriveTypeName = base.decl_string.lstrip( '::') ## TODO: maybe need to stripall a::b::[actual name] # array / ptr -> corba sequence for ptype in decom[1:]: if decls.type_traits.is_pointer( ptype) or decls.type_traits.is_array(ptype): self._incDimension() self._levelOfVar = self._level self._typeName = self.getTypeName if not isinstance(decl, decls.cpptypes.void_t): assert (self._level) # must not be null
def _exportable_impl( self ): 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()
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()
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.decl_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 = [unit for unit in units if isinstance( unit, declarations.calldef_type_t )] 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()
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 setTreeNodeInfo(self, decl): decom = decls.decompose_type(decl) decom.reverse() # decom for int** is now [int, int*, int**] self._pgxDecl = base = decls.type_traits.remove_declarated(decom[0]) # type base is either fundamental type or class/enum/else. TODO: void if decls.type_traits.is_fundamental(base): self._baseName = base.decl_string self._baseTypeName = funIdlMapping(base) self._deriveTypeName = funIdlMappingShort(base) # TODO: let classes/enums/... objects control it's name or control it from here? # TODO2: specify the _whole_ mechanism behind this class else: self._baseName = base.decl_string self._baseTypeName = self._deriveTypeName = base.decl_string.lstrip( "::" ) ## TODO: maybe need to stripall a::b::[actual name] # array / ptr -> corba sequence for ptype in decom[1:]: if decls.type_traits.is_pointer(ptype) or decls.type_traits.is_array(ptype): self._incDimension() self._levelOfVar = self._level self._typeName = self.getTypeName if not isinstance(decl, decls.cpptypes.void_t): assert self._level # must not be null
def merge(self, decl): currLvl = 0 decom = decls.decompose_type(decl) decom.reverse() if not self._isCompatBaseDirect(decom[0]): raise Exception("TypedefSeq::merge types not compatible") for ptype in typeDecom[1:]: if decls.type_traits.is_pointer(ptype) or decls.type_traits.is_array(ptype): currLvl += 1 if currLvl > self._level: self._incDimension() if currLvl == 0: return self._baseTypeName else: return self._typeArrList[currLvl - 1][0] # return type name
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 merge(self, decl): currLvl = 0 decom = decls.decompose_type(decl) decom.reverse() if not self._isCompatBaseDirect(decom[0]): raise Exception('TypedefSeq::merge types not compatible') for ptype in typeDecom[1:]: if decls.type_traits.is_pointer( ptype) or decls.type_traits.is_array(ptype): currLvl += 1 if currLvl > self._level: self._incDimension() if currLvl == 0: return self._baseTypeName else: return self._typeArrList[currLvl - 1][0] # return type name
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 _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()
def isCompat(self, decl): decom = decls.decompose_type(decl) decom.reverse() return decom[0].decl_string == self._baseName
def argCompress(arg): """INPUT: pygccxml Argument RETURN: Tuple ([codeLst], procArg). codeList = generated code in list. call '\n',join() procArg = pointer to packed Argument struct (variable). Is meant to be used after codeList (in 1 function) to further processing""" global argDecs, argTypes, nameArr global argClsList argDecs = declarations.decompose_type( arg.type) # [char const *, char const, char] argTypes = map(lambda w: getDeclType(w), argDecs) # [Pointer, Fundamental..] # code generation codeList = [] nameArr = [] argN = arg.name # from [decomposedTypes] -> [list structures], length is the same for argPtr in argDecs: if getDeclType(argPtr) == "Pointer": nameArr.append('P_' + argN) argN = nameArr[-1] codeList.append('PACK_NODE ' + nameArr[-1] + ' = ' + 'PACK_PTR();') elif getDeclType(argPtr) == "Fundamental": nameArr.append('F_' + argN) argN = nameArr[-1] codeList.append('PACK_NODE %s = PACK_FUN(%d);' % (nameArr[-1], argPtr.byte_size)) elif getDeclType(argPtr) == "Class": nameArr.append('C_' + argN) argN = nameArr[-1] codeList.append('PACK_NODE %s = PACK_CLS(&pack_CLS_%s);' % (nameArr[-1], (argPtr.decl_string).lstrip('::'))) # TODO identities argClsList[argPtr.declaration.name] = argPtr.declaration elif getDeclType(argPtr) == "Unknown": nameArr.append('U_' + argN) argN = nameArr[-1] codeList.append('PACK_NODE %s = PACK_UNK(%d);' % (nameArr[-1], argPtr.byte_size)) if argTypes[0] == "Unknown": print "ERROR: pyargs(argcompress): Unknown Type" i = 0 while i < len(argTypes) - 1: #print("TYPE[%d]=%s" % (i, argTypes[i])) if argTypes[i] == "Pointer": codeList.append('CONNECT(%s, %s);' % (nameArr[i], nameArr[i + 1])) elif argTypes[i] == "Fundamental": codeList.append('CONNECT_ALIAS(%s, %s);' % (nameArr[i], nameArr[i + 1])) elif argTypes[i] == "Class": codeList.append('CONNECT_CLASS(%s, %s);' % (nameArr[i], nameArr[i + 1])) elif argTypes[i] == "Unknown": print "ERROR: pyargs(argcompress): Unknown Type" codeList.append('UNKNOWN;') i += 1 codeList.append("PROCESS(%s,%s);" % (arg.name, nameArr[0])) #return ";\n".join(codeList) return (codeList, nameArr[0])
def argCompress(arg): """INPUT: pygccxml Argument RETURN: Tuple ([codeLst], procArg). codeList = generated code in list. call '\n',join() procArg = pointer to packed Argument struct (variable). Is meant to be used after codeList (in 1 function) to further processing""" global argDecs, argTypes, nameArr global argClsList argDecs = declarations.decompose_type(arg.type) # [char const *, char const, char] argTypes = map(lambda w:getDeclType(w), argDecs) # [Pointer, Fundamental..] # code generation codeList = [] nameArr = [] argN = arg.name # from [decomposedTypes] -> [list structures], length is the same for argPtr in argDecs: if getDeclType(argPtr) == "Pointer": nameArr.append('P_' + argN) argN = nameArr[-1] codeList.append('PACK_NODE ' + nameArr[-1] + ' = ' + 'PACK_PTR();') elif getDeclType(argPtr) == "Fundamental": nameArr.append('F_' + argN); argN = nameArr[-1] codeList.append('PACK_NODE %s = PACK_FUN(%d);' % (nameArr[-1], argPtr.byte_size)) elif getDeclType(argPtr) == "Class": nameArr.append('C_' + argN); argN = nameArr[-1] codeList.append('PACK_NODE %s = PACK_CLS(&pack_CLS_%s);' % (nameArr[-1], (argPtr.decl_string).lstrip('::'))) # TODO identities argClsList[argPtr.declaration.name] = argPtr.declaration elif getDeclType(argPtr) == "Unknown": nameArr.append('U_' + argN); argN = nameArr[-1] codeList.append('PACK_NODE %s = PACK_UNK(%d);' % (nameArr[-1], argPtr.byte_size)) if argTypes[0] == "Unknown": print "ERROR: pyargs(argcompress): Unknown Type" i = 0 while i < len(argTypes) - 1: #print("TYPE[%d]=%s" % (i, argTypes[i])) if argTypes[i] == "Pointer": codeList.append('CONNECT(%s, %s);' % (nameArr[i], nameArr[i+1])) elif argTypes[i] == "Fundamental": codeList.append('CONNECT_ALIAS(%s, %s);' % (nameArr[i], nameArr[i+1])) elif argTypes[i] == "Class": codeList.append('CONNECT_CLASS(%s, %s);' % (nameArr[i], nameArr[i+1])) elif argTypes[i] == "Unknown": print "ERROR: pyargs(argcompress): Unknown Type" codeList.append('UNKNOWN;') i+=1 codeList.append("PROCESS(%s,%s);" % (arg.name, nameArr[0])) #return ";\n".join(codeList) return (codeList, nameArr[0])