1.1 --- a/lib/__builtins__/int.py Fri Dec 09 16:26:50 2016 +0100
1.2 +++ b/lib/__builtins__/int.py Fri Dec 09 17:27:30 2016 +0100
1.3 @@ -20,7 +20,10 @@
1.4 """
1.5
1.6 from __builtins__.operator import _negate
1.7 -import native
1.8 +from native import isinstance as _isinstance, get_maxint, get_minint, \
1.9 + int_add, int_and, int_div, int_eq, int_gt, int_lt, int_mod, \
1.10 + int_mul, int_ne, int_neg, int_not, int_or, int_pow, \
1.11 + int_str, int_sub, int_xor
1.12
1.13 class int:
1.14
1.15 @@ -30,7 +33,7 @@
1.16
1.17 "Initialise the integer with the given 'number_or_string'."
1.18
1.19 - if native.isinstance(number_or_string, int):
1.20 + if _isinstance(number_or_string, int):
1.21 self.__data__ = number_or_string.__data__
1.22 else:
1.23 # NOTE: To be implemented.
1.24 @@ -46,7 +49,7 @@
1.25
1.26 "Perform 'op' on this int and 'other' if appropriate."
1.27
1.28 - if native.isinstance(other, int):
1.29 + if _isinstance(other, int):
1.30 return op(self.__data__, other.__data__)
1.31 else:
1.32 return NotImplemented
1.33 @@ -55,7 +58,7 @@
1.34
1.35 "Perform 'op' on 'other' and this int if appropriate."
1.36
1.37 - if native.isinstance(other, int):
1.38 + if _isinstance(other, int):
1.39 return op(other.__data__, self.__data__)
1.40 else:
1.41 return NotImplemented
1.42 @@ -64,61 +67,61 @@
1.43
1.44 "Return a new int for the addition of this int and 'other'."
1.45
1.46 - return self._binary_op(native.int_add, other)
1.47 + return self._binary_op(int_add, other)
1.48
1.49 def __isub__(self, other):
1.50
1.51 "Return a new int for the subtraction of this int and 'other'."
1.52
1.53 - return self._binary_op(native.int_sub, other)
1.54 + return self._binary_op(int_sub, other)
1.55
1.56 def __imul__(self, other):
1.57
1.58 "Return a new int for the multiplication of this int and 'other'."
1.59
1.60 - return self._binary_op(native.int_mul, other)
1.61 + return self._binary_op(int_mul, other)
1.62
1.63 def __idiv__(self, other):
1.64
1.65 "Return a new int for the division of this int and 'other'."
1.66
1.67 - return self._binary_op(native.int_div, other)
1.68 + return self._binary_op(int_div, other)
1.69
1.70 def __imod__(self, other):
1.71
1.72 "Return a new int for the modulo of this int by 'other'."
1.73
1.74 - return self._binary_op(native.int_mod, other)
1.75 + return self._binary_op(int_mod, other)
1.76
1.77 def __ipow__(self, other):
1.78
1.79 "Return a new int for the exponentiation of this int by 'other'."
1.80
1.81 - return self._binary_op(native.int_pow, other)
1.82 + return self._binary_op(int_pow, other)
1.83
1.84 def __iand__(self, other):
1.85
1.86 "Return a new int for the binary-and of this int and 'other'."
1.87
1.88 - return self._binary_op(native.int_and, other)
1.89 + return self._binary_op(int_and, other)
1.90
1.91 def __ior__(self, other):
1.92
1.93 "Return a new int for the binary-or of this int and 'other'."
1.94
1.95 - return self._binary_op(native.int_or, other)
1.96 + return self._binary_op(int_or, other)
1.97
1.98 def __ixor__(self, other):
1.99
1.100 "Return a new int for the exclusive-or of this int and 'other'."
1.101
1.102 - return self._binary_op(native.int_xor, other)
1.103 + return self._binary_op(int_xor, other)
1.104
1.105 def __invert__(self):
1.106
1.107 "Return the inversion of this int."
1.108
1.109 - return native.int_not(self.__data__)
1.110 + return int_not(self.__data__)
1.111
1.112 __add__ = __radd__ = __iadd__
1.113 __sub__ = __isub__
1.114 @@ -127,7 +130,7 @@
1.115
1.116 "Return a new int for the subtraction of this int from 'other'."
1.117
1.118 - return self._binary_op_rev(native.int_sub, other)
1.119 + return self._binary_op_rev(int_sub, other)
1.120
1.121 __mul__ = __rmul__ = __imul__
1.122 __div__ = __idiv__
1.123 @@ -136,7 +139,7 @@
1.124
1.125 "Return a new int for the division of this int into 'other'."
1.126
1.127 - return self._binary_op_rev(native.int_div, other)
1.128 + return self._binary_op_rev(int_div, other)
1.129
1.130 def __floordiv__(self, other): pass
1.131 def __rfloordiv__(self, other): pass
1.132 @@ -148,7 +151,7 @@
1.133
1.134 "Return a new int for the modulo of 'other' by this int."
1.135
1.136 - return self._binary_op_rev(native.int_mod, other)
1.137 + return self._binary_op_rev(int_mod, other)
1.138
1.139 __pow__ = __ipow__
1.140
1.141 @@ -156,7 +159,7 @@
1.142
1.143 "Return a new int for the exponentiation of 'other' by this int."
1.144
1.145 - return self._binary_op_rev(native.int_pow, other)
1.146 + return self._binary_op_rev(int_pow, other)
1.147
1.148 __and__ = __rand__ = __iand__
1.149 __or__ = __ror__ = __ior__
1.150 @@ -166,13 +169,13 @@
1.151
1.152 "Return whether this int is less than 'other'."
1.153
1.154 - return self._binary_op(native.int_lt, other)
1.155 + return self._binary_op(int_lt, other)
1.156
1.157 def __gt__(self, other):
1.158
1.159 "Return whether this int is greater than 'other'."
1.160
1.161 - return self._binary_op(native.int_gt, other)
1.162 + return self._binary_op(int_gt, other)
1.163
1.164 def __le__(self, other):
1.165
1.166 @@ -190,7 +193,7 @@
1.167
1.168 "Return whether this int is equal to 'other'."
1.169
1.170 - return self._binary_op(native.int_eq, other)
1.171 + return self._binary_op(int_eq, other)
1.172
1.173 def __ne__(self, other):
1.174
1.175 @@ -202,7 +205,7 @@
1.176
1.177 "Apply the unary negation operator."
1.178
1.179 - return native.int_neg(self.__data__)
1.180 + return int_neg(self.__data__)
1.181
1.182 def __pos__(self):
1.183
1.184 @@ -214,7 +217,7 @@
1.185
1.186 "Return a string representation."
1.187
1.188 - return native.int_str(self.__data__)
1.189 + return int_str(self.__data__)
1.190
1.191 __repr__ = __str__
1.192
1.193 @@ -230,11 +233,11 @@
1.194 "Return whether this int is non-zero."
1.195
1.196 zero = 0
1.197 - return native.int_ne(self.__data__, zero.__data__)
1.198 + return int_ne(self.__data__, zero.__data__)
1.199
1.200 # Limits.
1.201
1.202 -maxint = native.get_maxint()
1.203 -minint = native.get_minint()
1.204 +maxint = get_maxint()
1.205 +minint = get_minint()
1.206
1.207 # vim: tabstop=4 expandtab shiftwidth=4