Example #1
0
 def __init__(self, value):
     if not isinstance(value, six.integer_types):
         raise TypeError(
             "WXFExprInteger must be initialize with an integer value.")
     wxf_type, self.int_size = integer_size(value)
     super(WXFExprInteger, self).__init__(wxf_type)
     self.value = value
Example #2
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