Exemple #1
0
 def get_includes(self):
     for l in self.libInclude:
         self.printer.append("#include <%s>" % iutil.taggingConvert(l))
     self.printer.append(iutil.newline)
     for p in self.pathInclude:
         self.printer.append("#include \"%s\"" % iutil.taggingConvert(p))
     self.printer.append(iutil.newline)
Exemple #2
0
    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 = []
Exemple #3
0
    def __init__(self, mod_prefix, yinNode, cpp_ident):
        #print(yinNode.getKeyPath())
        code_templates.class_template.__init__(self, cpp_ident, 'ConfDDataObject')
        #TODO: The rule to identify namespace and tag is based on ConfD, which is not guarunteed
        self.mod_prefix = mod_prefix
        self.yinNode = yinNode
        self.KeyList = []
        self.keyName = None
        self.keyNode = None
        self.subLeafVars = []
        self.enums = []
        self.typedefs = []
        
        # Common public member functions
        self.mf_getNumAttrs = simple_syntax.function(yin_common.uint32_t, 'getNumAttrs', [])
        self.mf_getNumAttrs.inline = True
        self.mf_getNumAttrs.impBody.append('return numAttrs_c;')

        self.mf_getNumTags = simple_syntax.function(yin_common.uint8_t, 'getNumTags', [])
        self.mf_getNumTags.inline = True
        self.mf_getNumTags.impBody.append('return numTags_c;')

        self.mf_getNumAttrsDmsDataType = simple_syntax.function(yin_common.uint32_t, 'getNumAttrsDmsDataType', [])
        self.mf_getNumAttrsDmsDataType.inline = True
        self.mf_getNumAttrsDmsDataType.impBody.append('return numAttrsDmsDataType_c;')

        self.mf_getNumAttrsForDmsTagDataType = simple_syntax.function(yin_common.uint32_t, 'getNumAttrsForDmsTagDataType', [])
        self.mf_getNumAttrsForDmsTagDataType.inline = True
        self.mf_getNumAttrsForDmsTagDataType.impBody.append('return numAttrsDmsTagDataType_c;')
        
        self.mf_setDefVal = simple_syntax.function('void', 'setDefaultValues', [])
        
        self.mf_copy = simple_syntax.function('DataObject*', 'copy', [])
        self.mf_copy.virtual = True
        self.mf_copy.impBody.append('%s *dataObjCopy = new %s();' % (cpp_ident, cpp_ident))
        self.mf_copy.impBody.append('*dataObjCopy = *this;')
        self.mf_copy.impBody.append('return dataObjCopy;')
        
        self.mf_resetSpecifiedAllAttrs = simple_syntax.function('void', 'resetSpecifiedAllAttrs', [])
        
        params = [simple_syntax.var_param('bool', 'rhs')]
        self.mf_updateAllAttr = simple_syntax.function('void', 'updateAllAttr', params)
        
        # Common public operators
        params = [simple_syntax.var_param('DmsDataType', 'attr', False, False, True, False, False)]
        self.op_leftShift = simple_syntax.function(yin_common.uint32_t, 'operator<<', params)
        
        params = [simple_syntax.var_param('DmsDataType', 'attr', False, True, False, True, False)]
        self.op_rightShift = simple_syntax.function(yin_common.uint32_t, 'operator>>', params)
        
        params = [simple_syntax.var_param('DmsTagDataType', 'attr', False, False, True, False, False)]
        self.op_leftShiftWithTag = simple_syntax.function(yin_common.uint32_t, 'operator<<', params)
        
        params = [simple_syntax.var_param('DmsTagDataType', 'attr', False, True, False, True, False)]
        self.op_rightShiftWithTag = simple_syntax.function(yin_common.uint32_t, 'operator>>', params)
        
        # Common protected functions
        self.mf_getDataType = simple_syntax.function(yin_common.uint8_t, 'getDataType', [])
        self.mf_getDataType.inline = True
        
        self.mf_getElementType = simple_syntax.function(yin_common.uint8_t, 'getElementType', [])
        self.mf_getElementType.inline = True
        #self.mf_getElementType.impBody.append('return %s;' % self.elemType)
    
        self.mf_getKeyReg = simple_syntax.function('bool', 'getKeyReq', [])
        self.mf_getKeyReg.inline = True
        self.mf_getKeyReg.virtual = True
        self.mf_getKeyReg.impBody.append('return true;')
    
        self.mf_getNameSpace = simple_syntax.function(yin_common.uint32_t, 'getNameSpace', [])
        self.mf_getNameSpace.inline = True
        self.mf_getNameSpace.impBody.append('return %s__ns;' % iutil.taggingConvert(self.mod_prefix))
        #self.mf_getNameSpace.impBody.append('return 0;')
        
        self.mf_getTag = simple_syntax.function(yin_common.uint32_t, 'getTag', [])
        self.mf_getTag.inline = True
        self.mf_getTag.impBody.append('return %s_%s;' % (iutil.taggingConvert(self.mod_prefix), iutil.taggingConvert(self.yinNode.identifier)))