def pre_load(self): ormClass.pre_load(self) # Do not call this! ''' for node in self.yinNode.subNodes: # Record key if node.token == "key": self.listKeys = node.value.split(iutil.ws) for item in self.yinNode.subNodes: if item.token == 'leaf' and item.identifier == self.listKeys[0]: self.keyItem = item ''' #print self.listKeys #type defines key_cpp_type = self.keyNode.cpp_type if self.keyNode else yin_common.tString self.externs.append('typedef std::pair<%s, %s> %s;' % (key_cpp_type, self.itemName, self.itemPair)) self.externs.append('typedef std::map<%s, %s> %s;' % (key_cpp_type, self.itemName, self.itemMap)) self.externs.append('typedef std::map<%s, %s>::iterator %s;' % (key_cpp_type, self.itemName, self.itemIter)) #The only one member variable fo std::map list, remove it first self.subLeafVars = [] mv = simple_syntax.variable(self.itemMap, 'list_m') self.subLeafVars.append(mv) self.enums = []
def __init__(self, mod_prefix, yinNode): yinNode.cpp_type = 'ch_' + iutil.namingConvert_Luc(yinNode.identifier) ormClass.__init__(self, mod_prefix, yinNode, yinNode.cpp_type) self.cases = {} self.mf_getElementType.impBody = [] self.mf_getElementType.impBody.append('return E_Element_Choice;') self.mv_curCase = simple_syntax.variable(yin_common.tString, 'm_curCase') self.pri_memb.append(self.mv_curCase) self.mf_getCurCase = simple_syntax.function(yin_common.tString, 'getCurCase', []) self.mf_getCurCase.impBody = [] self.mf_getCurCase.impBody.append('return %s;' % self.mv_curCase.identifier) self.pub_func.append(self.mf_getCurCase) params = [simple_syntax.var_param(yin_common.tString, 'strCase', False, True, False, False, False)] self.mf_setCurCase = simple_syntax.function('bool', 'setCurCase', params) self.pub_func.append(self.mf_setCurCase)
def __init__(self, mod_prefix, yinNode): #yinNode.cpp_type = iutil.namingConvert_Luc(yinNode.getKeyPath()) #new_cpp_type = iutil.namingConvert_Luc(yinNode.getKeyPath()) + '_lm' new_cpp_type = 'lm_' + iutil.namingConvert_Luc(yinNode.identifier) yinNode.cpp_type = new_cpp_type map_item_type = 'l_' + iutil.namingConvert_Luc(yinNode.identifier) ormClass.__init__(self, mod_prefix, yinNode, new_cpp_type) self.mf_getElementType.impBody = [] self.mf_getElementType.impBody.append('return E_Element_List;') # Map part self.itemName = map_item_type self.itemPair = ('%s_map_pair' % self.itemName) self.itemMap = ('%s_map' % self.itemName) self.itemIter = ('%s_map_iter' % self.itemName) mv = simple_syntax.variable(self.itemIter, 'iter') mv.complex = True self.pri_memb.append(mv) # Special functions for list self.mf_beginInst = simple_syntax.function('bool', 'beginInst', []) self.mf_beginInst.inline = True self.mf_beginInst.impBody.append("iter = list_m.begin();") self.mf_beginInst.impBody.append("return iter != list_m.end();") self.mf_isNextInstAvail = simple_syntax.function('bool', 'isNextInstAvail', []) self.mf_isNextInstAvail.inline = True #self.mf_isNextInstAvail.impBody.append("iter = %s.begin();\n" % self.itemName) self.mf_isNextInstAvail.impBody.append("return iter != list_m.end();") self.mf_getNextInst = simple_syntax.function('bool', 'getNextInst', []) self.mf_getNextInst.inline = True self.mf_getNextInst.impBody.append("iter ++;") self.mf_getNextInst.impBody.append("return true;") self.mf_flushInstances = simple_syntax.function('bool', 'flushInstances', []) self.mf_flushInstances.inline = True self.mf_flushInstances.impBody.append("list_m.clear();") self.mf_flushInstances.impBody.append("return true;")
def pre_load(self): ormClass.pre_load(self) # Do not call this! for node in self.yinNode.subNodes: # Record key if node.token == "type": self.leafType = node.cpp_type if yin_common.isOrmStringType(self.leafType): self.itemName = 'L_chars' else: self.itemName = 'L_' + iutil.taggingConvert(self.leafType) #type defines self.typedefs.append('typedef Data<%s> %s;' % (self.leafType, self.itemName)) self.typedefs.append('typedef std::vector<%s> %s;' % (self.itemName, self.itemName + 's')) #self.externs.append('typedef std::vector<%s>::iterator %s;' % (self.leafType, self.itemName, self.itemIter)) #The only one member variable fo std::map list, remove it first self.subLeafVars = [] mv = simple_syntax.variable(self.itemName, 'leaflist_m') mv.complex = False self.subLeafVars.append(mv) self.enums = []