Beispiel #1
0
    def to_binary(self):
        b = []
        encoding = self.VariantType.value & 0b111111
        if type(self.Value) in (list, tuple):
            if self.Dimensions is not None:
                encoding = uabin.set_bit(encoding, 6)
            encoding = uabin.set_bit(encoding, 7)
            b.append(uabin.Primitives.UInt8.pack(encoding))
            b.append(uabin.pack_uatype_array(self.VariantType, flatten(self.Value)))
            if self.Dimensions is not None:
                b.append(uabin.pack_uatype_array(VariantType.Int32, self.Dimensions))
        else:
            b.append(uabin.Primitives.UInt8.pack(encoding))
            b.append(uabin.pack_uatype(self.VariantType, self.Value))

        return b"".join(b)
Beispiel #2
0
    def to_binary(self):
        b = []
        encoding = self.VariantType.value & 0b111111
        if type(self.Value) in (list, tuple):
            if self.Dimensions is not None:
                encoding = uabin.set_bit(encoding, 6)
            encoding = uabin.set_bit(encoding, 7)
            b.append(uabin.Primitives.UInt8.pack(encoding))
            b.append(uabin.pack_uatype_array(self.VariantType, flatten(self.Value)))
            if self.Dimensions is not None:
                b.append(uabin.pack_uatype_array(VariantType.Int32, self.Dimensions))
        else:
            b.append(uabin.Primitives.UInt8.pack(encoding))
            b.append(uabin.pack_uatype(self.VariantType, self.Value))

        return b"".join(b)