コード例 #1
0
ファイル: cppgen.py プロジェクト: 8l/connectal
def generate_marshall(pfmt, w):
    global fdName
    off = 0
    word = []
    fmt = pfmt
    outstr = ''
    for e in w:
        field = e.name
        if typeCName(e.datatype) == 'float':
            return pfmt % ('*(int*)&' + e.name)
        mask = signCName(e.datatype)
        if mask:
            field = '(%s & %s)' % (field, mask)
        if e.shifted:
            field = '(%s>>%s)' % (field, e.shifted)
        if off:
            field = '(((unsigned long)%s)<<%s)' % (field, off)
        if typeBitWidth(e.datatype) > 64:
            field = '(const %s & std::bitset<%d>(0xFFFFFFFF)).to_ulong()' % (field, typeBitWidth(e.datatype))
        word.append(field)
        off = off+e.width-e.shifted
        if typeCName(e.datatype) == 'SpecialTypeForSendingFd':
            fdName = field
            fmt = 'p->item->writefd(p, &temp_working_addr, %s);'
    return fmt % (''.join(util.intersperse('|', word)))
コード例 #2
0
def generate_marshall(pfmt, argWords):
    global fdName
    retList = []
    for w in argWords:
        off = 0
        fields = []
        fmt = pfmt
        outstr = ''
        for e in w:
            field = e.name
            if typeCName(e.datatype) == 'float':
                return pfmt % ('*(int*)&' + e.name)
            mask = signCName(e.datatype)
            if mask:
                field = '(%s & %s)' % (field, mask)
            if e.shifted:
                field = '(%s>>%s)' % (field, e.shifted)
            if off:
                field = '(((unsigned long)%s)<<%s)' % (field, off)
            if typeBitWidth(e.datatype) > 64:
                field = '(const %s & std::bitset<%d>(0xFFFFFFFF)).to_ulong()' % (
                    field, typeBitWidth(e.datatype))
            fields.append(field)
            off = off + e.width - e.shifted
            if typeCName(e.datatype) == 'SpecialTypeForSendingFd':
                fdName = field
                fmt = 'p->transport->writefd(p, &temp_working_addr, %s);'
                if generatePacketOnly:
                    print 'generate_marshall: when using "generatePacketOnly", fd items cannot be sent'
                    sys.exit(-1)
        retList.append(fmt % (''.join(util.intersperse('|', fields))))
    return retList
コード例 #3
0
ファイル: cppgen.py プロジェクト: acw1251/connectal
def generate_marshall(pfmt, argWords):
    global fdName
    retList = []
    for w in argWords:
        off = 0
        fields = []
        fmt = pfmt
        outstr = ''
        for e in w:
            field = e.name
            if typeCName(e.datatype) == 'float':
                return pfmt % ('*(int*)&' + e.name)
            mask = signCName(e.datatype)
            if mask:
                field = '(%s & %s)' % (field, mask)
            if e.shifted:
                field = '(%s>>%s)' % (field, e.shifted)
            if off:
                field = '(((unsigned long)%s)<<%s)' % (field, off)
            if typeBitWidth(e.datatype) > 64:
                field = '(const %s & std::bitset<%d>(0xFFFFFFFF)).to_ulong()' % (field, typeBitWidth(e.datatype))
            fields.append(field)
            off = off+e.width-e.shifted
            if typeCName(e.datatype) == 'SpecialTypeForSendingFd':
                fdName = field
                fmt = 'p->transport->writefd(p, &temp_working_addr, %s);'
                if generatePacketOnly:
                    print 'generate_marshall: when using "generatePacketOnly", fd items cannot be sent'
                    sys.exit(-1)
        retList.append(fmt % (''.join(util.intersperse('|', fields))))
    return retList
コード例 #4
0
ファイル: cppgen.py プロジェクト: chamdoo/xbsv
        def generate_marshall(w):
            off = 0
            word = []
            for e in w:
                field = e.name;
		if e.datatype.cName() == 'float':
		    return '        WRITEL(p, temp_working_addr, *(int*)&%s);\n' % e.name;
                if e.shifted:
                    field = '(%s>>%s)' % (field, e.shifted)
                if off:
                    field = '(%s<<%s)' % (field, off)
                if e.datatype.bitWidth() > 64:
                    field = '(const %s & std::bitset<%d>(0xFFFFFFFF)).to_ulong()' % (field, e.datatype.bitWidth())
                word.append(field)
                off = off+e.width-e.shifted
            return '        WRITEL(p, temp_working_addr, %s);\n' % (''.join(util.intersperse('|', word)))
コード例 #5
0
 def generate_marshall(w):
     off = 0
     word = []
     for e in w:
         field = e.name
         if e.datatype.cName() == 'float':
             return '        WRITEL(p, temp_working_addr, *(int*)&%s);\n' % e.name
         if e.shifted:
             field = '(%s>>%s)' % (field, e.shifted)
         if off:
             field = '(%s<<%s)' % (field, off)
         if e.datatype.bitWidth() > 64:
             field = '(const %s & std::bitset<%d>(0xFFFFFFFF)).to_ulong()' % (
                 field, e.datatype.bitWidth())
         word.append(field)
         off = off + e.width - e.shifted
     return '        WRITEL(p, temp_working_addr, %s);\n' % (''.join(
         util.intersperse('|', word)))
コード例 #6
0
ファイル: cppgen.py プロジェクト: m-liu/bluedbm_test
def generate_marshall(pfmt, w):
    global fdName
    off = 0
    word = []
    fmt = pfmt
    for e in w:
        field = e.name
        if e.datatype['cName'] == 'float':
            return pfmt % ('*(int*)&' + e.name)
        if e.shifted:
            field = '(%s>>%s)' % (field, e.shifted)
        if off:
            field = '(%s<<%s)' % (field, off)
        if e.datatype['bitWidth'] > 64:
            field = '(const %s & std::bitset<%d>(0xFFFFFFFF)).to_ulong()' % (field, e.datatype['bitWidth'])
        word.append(field)
        off = off+e.width-e.shifted
        if e.datatype['cName'] == 'SpecialTypeForSendingFd':
            fdName = field
            fmt = 'p->item->writefd(p, &temp_working_addr, %s);'
    return fmt % (''.join(util.intersperse('|', word)))