Ejemplo n.º 1
0
    def serialize_int(self, number):
        try:
            wxf_type, int_size = integer_size(number)
            yield wxf_type
            yield integer_to_bytes(number, int_size)

        except ValueError:
            # WXFExprInteger is raising a ValueError if the integer is not in the appropriate bounds.
            # that check needs to be done in case, it's better to do it only once.

            number = b"%i" % number

            yield WXF_CONSTANTS.BigInteger
            yield varint_bytes(len(number))
            yield number
Ejemplo n.º 2
0
 def to_bytes(self):
     return integer_to_bytes(self.value, self.int_size)