1.1 --- a/lib/__builtins__/dict.py Fri Dec 09 16:26:50 2016 +0100
1.2 +++ b/lib/__builtins__/dict.py Fri Dec 09 17:27:30 2016 +0100
1.3 @@ -21,7 +21,7 @@
1.4
1.5 from __builtins__.iterator import itemiterator
1.6 from __builtins__.sequence import _max
1.7 -import native
1.8 +from native import isinstance as _isinstance
1.9
1.10 class dict:
1.11
1.12 @@ -86,7 +86,7 @@
1.13
1.14 index = key.__hash__()
1.15
1.16 - if not native.isinstance(index, int):
1.17 + if not _isinstance(index, int):
1.18 raise TypeError
1.19
1.20 return index % len(self.buckets)
2.1 --- a/lib/__builtins__/file.py Fri Dec 09 16:26:50 2016 +0100
2.2 +++ b/lib/__builtins__/file.py Fri Dec 09 17:27:30 2016 +0100
2.3 @@ -20,7 +20,7 @@
2.4 """
2.5
2.6 from __builtins__.types import check_int, check_string
2.7 -import native
2.8 +from native import fclose, fopen, fread, fwrite
2.9
2.10 class filestream:
2.11
2.12 @@ -42,7 +42,7 @@
2.13 # Read any indicated number of bytes.
2.14
2.15 if n > 0:
2.16 - return native.fread(self.__data__, n)
2.17 + return fread(self.__data__, n)
2.18
2.19 # Read all remaining bytes.
2.20
2.21 @@ -53,7 +53,7 @@
2.22
2.23 try:
2.24 while True:
2.25 - l.append(native.fread(self.__data__, self.bufsize))
2.26 + l.append(fread(self.__data__, self.bufsize))
2.27
2.28 # Handle end-of-file reads.
2.29
2.30 @@ -67,13 +67,13 @@
2.31 "Write string 's' to the stream."
2.32
2.33 check_string(s)
2.34 - native.fwrite(self.__data__, s)
2.35 + fwrite(self.__data__, s)
2.36
2.37 def close(self):
2.38
2.39 "Close the stream."
2.40
2.41 - native.fclose(self.__data__)
2.42 + fclose(self.__data__)
2.43
2.44 class file(filestream):
2.45
2.46 @@ -84,7 +84,7 @@
2.47 "Open the file with the given 'filename' using the given access 'mode'."
2.48
2.49 get_using(filestream.__init__, self)(bufsize)
2.50 - self.__data__ = native.fopen(filename, mode)
2.51 + self.__data__ = fopen(filename, mode)
2.52
2.53 def readline(self, size=None): pass
2.54 def readlines(self, size=None): pass
3.1 --- a/lib/__builtins__/identity.py Fri Dec 09 16:26:50 2016 +0100
3.2 +++ b/lib/__builtins__/identity.py Fri Dec 09 17:27:30 2016 +0100
3.3 @@ -19,7 +19,7 @@
3.4 this program. If not, see <http://www.gnu.org/licenses/>.
3.5 """
3.6
3.7 -import native
3.8 +from native import isinstance as _isinstance, issubclass as _issubclass
3.9
3.10 def callable(obj):
3.11
3.12 @@ -50,13 +50,13 @@
3.13 either a class or a sequence of classes.
3.14 """
3.15
3.16 - if native.isinstance(cls_or_tuple, tuple):
3.17 + if _isinstance(cls_or_tuple, tuple):
3.18 for cls in cls_or_tuple:
3.19 - if obj.__class__ is cls or isclass(cls) and native.isinstance(obj, cls):
3.20 + if obj.__class__ is cls or isclass(cls) and _isinstance(obj, cls):
3.21 return True
3.22 return False
3.23 else:
3.24 - return obj.__class__ is cls_or_tuple or isclass(cls_or_tuple) and native.isinstance(obj, cls_or_tuple)
3.25 + return obj.__class__ is cls_or_tuple or isclass(cls_or_tuple) and _isinstance(obj, cls_or_tuple)
3.26
3.27 def issubclass(obj, cls_or_tuple):
3.28
3.29 @@ -68,13 +68,13 @@
3.30
3.31 if not isclass(obj):
3.32 return False
3.33 - elif native.isinstance(cls_or_tuple, tuple):
3.34 + elif _isinstance(cls_or_tuple, tuple):
3.35 for cls in cls_or_tuple:
3.36 - if obj is cls or isclass(cls) and native.issubclass(obj, cls):
3.37 + if obj is cls or isclass(cls) and _issubclass(obj, cls):
3.38 return True
3.39 return False
3.40 else:
3.41 - return obj is cls_or_tuple or isclass(cls_or_tuple) and native.issubclass(obj, cls_or_tuple)
3.42 + return obj is cls_or_tuple or isclass(cls_or_tuple) and _issubclass(obj, cls_or_tuple)
3.43
3.44 def repr(obj):
3.45
4.1 --- a/lib/__builtins__/int.py Fri Dec 09 16:26:50 2016 +0100
4.2 +++ b/lib/__builtins__/int.py Fri Dec 09 17:27:30 2016 +0100
4.3 @@ -20,7 +20,10 @@
4.4 """
4.5
4.6 from __builtins__.operator import _negate
4.7 -import native
4.8 +from native import isinstance as _isinstance, get_maxint, get_minint, \
4.9 + int_add, int_and, int_div, int_eq, int_gt, int_lt, int_mod, \
4.10 + int_mul, int_ne, int_neg, int_not, int_or, int_pow, \
4.11 + int_str, int_sub, int_xor
4.12
4.13 class int:
4.14
4.15 @@ -30,7 +33,7 @@
4.16
4.17 "Initialise the integer with the given 'number_or_string'."
4.18
4.19 - if native.isinstance(number_or_string, int):
4.20 + if _isinstance(number_or_string, int):
4.21 self.__data__ = number_or_string.__data__
4.22 else:
4.23 # NOTE: To be implemented.
4.24 @@ -46,7 +49,7 @@
4.25
4.26 "Perform 'op' on this int and 'other' if appropriate."
4.27
4.28 - if native.isinstance(other, int):
4.29 + if _isinstance(other, int):
4.30 return op(self.__data__, other.__data__)
4.31 else:
4.32 return NotImplemented
4.33 @@ -55,7 +58,7 @@
4.34
4.35 "Perform 'op' on 'other' and this int if appropriate."
4.36
4.37 - if native.isinstance(other, int):
4.38 + if _isinstance(other, int):
4.39 return op(other.__data__, self.__data__)
4.40 else:
4.41 return NotImplemented
4.42 @@ -64,61 +67,61 @@
4.43
4.44 "Return a new int for the addition of this int and 'other'."
4.45
4.46 - return self._binary_op(native.int_add, other)
4.47 + return self._binary_op(int_add, other)
4.48
4.49 def __isub__(self, other):
4.50
4.51 "Return a new int for the subtraction of this int and 'other'."
4.52
4.53 - return self._binary_op(native.int_sub, other)
4.54 + return self._binary_op(int_sub, other)
4.55
4.56 def __imul__(self, other):
4.57
4.58 "Return a new int for the multiplication of this int and 'other'."
4.59
4.60 - return self._binary_op(native.int_mul, other)
4.61 + return self._binary_op(int_mul, other)
4.62
4.63 def __idiv__(self, other):
4.64
4.65 "Return a new int for the division of this int and 'other'."
4.66
4.67 - return self._binary_op(native.int_div, other)
4.68 + return self._binary_op(int_div, other)
4.69
4.70 def __imod__(self, other):
4.71
4.72 "Return a new int for the modulo of this int by 'other'."
4.73
4.74 - return self._binary_op(native.int_mod, other)
4.75 + return self._binary_op(int_mod, other)
4.76
4.77 def __ipow__(self, other):
4.78
4.79 "Return a new int for the exponentiation of this int by 'other'."
4.80
4.81 - return self._binary_op(native.int_pow, other)
4.82 + return self._binary_op(int_pow, other)
4.83
4.84 def __iand__(self, other):
4.85
4.86 "Return a new int for the binary-and of this int and 'other'."
4.87
4.88 - return self._binary_op(native.int_and, other)
4.89 + return self._binary_op(int_and, other)
4.90
4.91 def __ior__(self, other):
4.92
4.93 "Return a new int for the binary-or of this int and 'other'."
4.94
4.95 - return self._binary_op(native.int_or, other)
4.96 + return self._binary_op(int_or, other)
4.97
4.98 def __ixor__(self, other):
4.99
4.100 "Return a new int for the exclusive-or of this int and 'other'."
4.101
4.102 - return self._binary_op(native.int_xor, other)
4.103 + return self._binary_op(int_xor, other)
4.104
4.105 def __invert__(self):
4.106
4.107 "Return the inversion of this int."
4.108
4.109 - return native.int_not(self.__data__)
4.110 + return int_not(self.__data__)
4.111
4.112 __add__ = __radd__ = __iadd__
4.113 __sub__ = __isub__
4.114 @@ -127,7 +130,7 @@
4.115
4.116 "Return a new int for the subtraction of this int from 'other'."
4.117
4.118 - return self._binary_op_rev(native.int_sub, other)
4.119 + return self._binary_op_rev(int_sub, other)
4.120
4.121 __mul__ = __rmul__ = __imul__
4.122 __div__ = __idiv__
4.123 @@ -136,7 +139,7 @@
4.124
4.125 "Return a new int for the division of this int into 'other'."
4.126
4.127 - return self._binary_op_rev(native.int_div, other)
4.128 + return self._binary_op_rev(int_div, other)
4.129
4.130 def __floordiv__(self, other): pass
4.131 def __rfloordiv__(self, other): pass
4.132 @@ -148,7 +151,7 @@
4.133
4.134 "Return a new int for the modulo of 'other' by this int."
4.135
4.136 - return self._binary_op_rev(native.int_mod, other)
4.137 + return self._binary_op_rev(int_mod, other)
4.138
4.139 __pow__ = __ipow__
4.140
4.141 @@ -156,7 +159,7 @@
4.142
4.143 "Return a new int for the exponentiation of 'other' by this int."
4.144
4.145 - return self._binary_op_rev(native.int_pow, other)
4.146 + return self._binary_op_rev(int_pow, other)
4.147
4.148 __and__ = __rand__ = __iand__
4.149 __or__ = __ror__ = __ior__
4.150 @@ -166,13 +169,13 @@
4.151
4.152 "Return whether this int is less than 'other'."
4.153
4.154 - return self._binary_op(native.int_lt, other)
4.155 + return self._binary_op(int_lt, other)
4.156
4.157 def __gt__(self, other):
4.158
4.159 "Return whether this int is greater than 'other'."
4.160
4.161 - return self._binary_op(native.int_gt, other)
4.162 + return self._binary_op(int_gt, other)
4.163
4.164 def __le__(self, other):
4.165
4.166 @@ -190,7 +193,7 @@
4.167
4.168 "Return whether this int is equal to 'other'."
4.169
4.170 - return self._binary_op(native.int_eq, other)
4.171 + return self._binary_op(int_eq, other)
4.172
4.173 def __ne__(self, other):
4.174
4.175 @@ -202,7 +205,7 @@
4.176
4.177 "Apply the unary negation operator."
4.178
4.179 - return native.int_neg(self.__data__)
4.180 + return int_neg(self.__data__)
4.181
4.182 def __pos__(self):
4.183
4.184 @@ -214,7 +217,7 @@
4.185
4.186 "Return a string representation."
4.187
4.188 - return native.int_str(self.__data__)
4.189 + return int_str(self.__data__)
4.190
4.191 __repr__ = __str__
4.192
4.193 @@ -230,11 +233,11 @@
4.194 "Return whether this int is non-zero."
4.195
4.196 zero = 0
4.197 - return native.int_ne(self.__data__, zero.__data__)
4.198 + return int_ne(self.__data__, zero.__data__)
4.199
4.200 # Limits.
4.201
4.202 -maxint = native.get_maxint()
4.203 -minint = native.get_minint()
4.204 +maxint = get_maxint()
4.205 +minint = get_minint()
4.206
4.207 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/lib/__builtins__/list.py Fri Dec 09 16:26:50 2016 +0100
5.2 +++ b/lib/__builtins__/list.py Fri Dec 09 17:27:30 2016 +0100
5.3 @@ -21,7 +21,8 @@
5.4
5.5 from __builtins__.iterator import itemiterator
5.6 from __builtins__.sequence import sequence
5.7 -import native
5.8 +from native import list_append, list_concat, list_element, list_init, \
5.9 + list_len, list_nonempty, list_setelement
5.10
5.11 class list(sequence):
5.12
5.13 @@ -34,7 +35,7 @@
5.14 # Reserve an attribute for a fragment reference along with some space
5.15 # for elements.
5.16
5.17 - self.__data__ = native.list_init(args is not None and len(args) or 0)
5.18 + self.__data__ = list_init(args is not None and len(args) or 0)
5.19
5.20 if args is not None:
5.21 self.extend(args)
5.22 @@ -47,7 +48,7 @@
5.23
5.24 "Append 'value' to the list."
5.25
5.26 - native.list_append(self, value)
5.27 + list_append(self, value)
5.28
5.29 def insert(self, i, value): pass
5.30
5.31 @@ -66,7 +67,7 @@
5.32
5.33 "Return the length of the list."
5.34
5.35 - return native.list_len(self.__data__)
5.36 + return list_len(self.__data__)
5.37
5.38 def __add__(self, other): pass
5.39
5.40 @@ -75,7 +76,7 @@
5.41 "Concatenate 'other' to the list."
5.42
5.43 if isinstance(other, list):
5.44 - native.list_concat(self, other.__data__)
5.45 + list_concat(self, other.__data__)
5.46 else:
5.47 self.extend(other)
5.48 return self
5.49 @@ -92,7 +93,7 @@
5.50
5.51 "Lists are true if non-empty."
5.52
5.53 - return native.list_nonempty(self.__data__)
5.54 + return list_nonempty(self.__data__)
5.55
5.56 def __iter__(self):
5.57
5.58 @@ -107,13 +108,13 @@
5.59 "Return the item at the normalised (positive) 'index'."
5.60
5.61 self._check_index(index)
5.62 - return native.list_element(self.__data__, index)
5.63 + return list_element(self.__data__, index)
5.64
5.65 def __set_single_item__(self, index, value):
5.66
5.67 "Set at the normalised (positive) 'index' the given 'value'."
5.68
5.69 self._check_index(index)
5.70 - return native.list_setelement(self.__data__, index, value)
5.71 + return list_setelement(self.__data__, index, value)
5.72
5.73 # vim: tabstop=4 expandtab shiftwidth=4
6.1 --- a/lib/__builtins__/sequence.py Fri Dec 09 16:26:50 2016 +0100
6.2 +++ b/lib/__builtins__/sequence.py Fri Dec 09 17:27:30 2016 +0100
6.3 @@ -19,7 +19,7 @@
6.4 this program. If not, see <http://www.gnu.org/licenses/>.
6.5 """
6.6
6.7 -import native
6.8 +from native import isinstance as _isinstance
6.9
6.10 class itemaccess:
6.11
6.12 @@ -42,13 +42,13 @@
6.13 # Normalise any integer indexes, converting negative indexes to positive
6.14 # ones.
6.15
6.16 - if native.isinstance(index, int):
6.17 + if _isinstance(index, int):
6.18 index = _get_absolute_index(index, self.__len__())
6.19 return self.__get_single_item__(index)
6.20
6.21 # Handle slices separately.
6.22
6.23 - elif native.isinstance(index, slice):
6.24 + elif _isinstance(index, slice):
6.25 return self.__getslice__(index.start, index.end, index.step)
6.26
6.27 # No other kinds of objects are supported as indexes.
6.28 @@ -63,13 +63,13 @@
6.29 # Normalise any integer indexes, converting negative indexes to positive
6.30 # ones.
6.31
6.32 - if native.isinstance(index, int):
6.33 + if _isinstance(index, int):
6.34 index = _get_absolute_index(index, self.__len__())
6.35 return self.__set_single_item__(index, value)
6.36
6.37 # Handle slices separately.
6.38
6.39 - elif native.isinstance(index, slice):
6.40 + elif _isinstance(index, slice):
6.41 return self.__setslice__(index.start, index.end, value)
6.42
6.43 # No other kinds of objects are supported as indexes.
7.1 --- a/lib/__builtins__/str.py Fri Dec 09 16:26:50 2016 +0100
7.2 +++ b/lib/__builtins__/str.py Fri Dec 09 17:27:30 2016 +0100
7.3 @@ -22,7 +22,8 @@
7.4 from __builtins__.int import maxint, minint
7.5 from __builtins__.operator import _negate
7.6 from __builtins__.sequence import itemaccess
7.7 -import native
7.8 +from native import str_add, str_lt, str_gt, str_eq, str_len, str_nonempty, \
7.9 + str_substr
7.10
7.11 class basestring(itemaccess):
7.12
7.13 @@ -68,7 +69,7 @@
7.14
7.15 "Return a string combining this string with 'other'."
7.16
7.17 - return self._binary_op(native.str_add, other)
7.18 + return self._binary_op(str_add, other)
7.19
7.20 __add__ = __radd__ = __iadd__
7.21
7.22 @@ -81,13 +82,13 @@
7.23
7.24 "Return whether this string is less than 'other'."
7.25
7.26 - return self._binary_op(native.str_lt, other)
7.27 + return self._binary_op(str_lt, other)
7.28
7.29 def __gt__(self, other):
7.30
7.31 "Return whether this string is greater than 'other'."
7.32
7.33 - return self._binary_op(native.str_gt, other)
7.34 + return self._binary_op(str_gt, other)
7.35
7.36 def __le__(self, other):
7.37
7.38 @@ -105,7 +106,7 @@
7.39
7.40 "Return whether this string is equal to 'other'."
7.41
7.42 - return self._binary_op(native.str_eq, other)
7.43 + return self._binary_op(str_eq, other)
7.44
7.45 def __ne__(self, other):
7.46
7.47 @@ -117,7 +118,7 @@
7.48
7.49 "Return the length of this string."
7.50
7.51 - return native.str_len(self.__data__)
7.52 + return str_len(self.__data__)
7.53
7.54 def __str__(self):
7.55
7.56 @@ -134,7 +135,7 @@
7.57 return str(b)
7.58
7.59 def __bool__(self):
7.60 - return native.str_nonempty(self.__data__)
7.61 + return str_nonempty(self.__data__)
7.62
7.63 def endswith(self, s): pass
7.64 def find(self, sub, start=None, end=None): pass
7.65 @@ -182,7 +183,7 @@
7.66 "Return the item at the normalised (positive) 'index'."
7.67
7.68 self._check_index(index)
7.69 - return native.str_substr(self.__data__, index, 1)
7.70 + return str_substr(self.__data__, index, 1)
7.71
7.72 class string(basestring):
7.73 pass
8.1 --- a/lib/__builtins__/tuple.py Fri Dec 09 16:26:50 2016 +0100
8.2 +++ b/lib/__builtins__/tuple.py Fri Dec 09 17:27:30 2016 +0100
8.3 @@ -21,7 +21,8 @@
8.4
8.5 from __builtins__.iterator import itemiterator
8.6 from __builtins__.sequence import sequence
8.7 -import native
8.8 +from native import list_element, list_init, list_len, list_setsize, \
8.9 + list_setelement
8.10
8.11 class tuple(sequence):
8.12
8.13 @@ -35,15 +36,15 @@
8.14 # for elements.
8.15
8.16 size = args is not None and len(args) or 0
8.17 - self.__data__ = native.list_init(size)
8.18 - native.list_setsize(self.__data__, size)
8.19 + self.__data__ = list_init(size)
8.20 + list_setsize(self.__data__, size)
8.21
8.22 # Populate the tuple.
8.23
8.24 if args is not None:
8.25 i = 0
8.26 for arg in args:
8.27 - native.list_setelement(self.__data__, i, arg)
8.28 + list_setelement(self.__data__, i, arg)
8.29 i += 1
8.30
8.31 def __getslice__(self, start, end=None):
8.32 @@ -56,7 +57,7 @@
8.33
8.34 "Return the length of the tuple."
8.35
8.36 - return native.list_len(self.__data__)
8.37 + return list_len(self.__data__)
8.38
8.39 def __add__(self, other): pass
8.40
8.41 @@ -87,7 +88,7 @@
8.42 "Return the item at the normalised (positive) 'index'."
8.43
8.44 self._check_index(index)
8.45 - return native.list_element(self.__data__, index)
8.46 + return list_element(self.__data__, index)
8.47
8.48 def __set_single_item__(self, index, value):
8.49
9.1 --- a/lib/__builtins__/types.py Fri Dec 09 16:26:50 2016 +0100
9.2 +++ b/lib/__builtins__/types.py Fri Dec 09 17:27:30 2016 +0100
9.3 @@ -19,20 +19,20 @@
9.4 this program. If not, see <http://www.gnu.org/licenses/>.
9.5 """
9.6
9.7 -import native
9.8 +from native import isinstance as _isinstance
9.9
9.10 def check_int(i):
9.11
9.12 "Check the given int 'i'."
9.13
9.14 - if not native.isinstance(i, int):
9.15 + if not _isinstance(i, int):
9.16 raise ValueError(i)
9.17
9.18 def check_string(s):
9.19
9.20 "Check the given string 's'."
9.21
9.22 - if not native.isinstance(s, string):
9.23 + if not _isinstance(s, string):
9.24 raise ValueError(s)
9.25
9.26 # vim: tabstop=4 expandtab shiftwidth=4
10.1 --- a/lib/posix/io.py Fri Dec 09 16:26:50 2016 +0100
10.2 +++ b/lib/posix/io.py Fri Dec 09 17:27:30 2016 +0100
10.3 @@ -21,7 +21,12 @@
10.4
10.5 from __builtins__.file import filestream
10.6 from __builtins__.types import check_int, check_string
10.7 -import native
10.8 +from native import (
10.9 + close as _close,
10.10 + fdopen as _fdopen,
10.11 + read as _read,
10.12 + write as _write
10.13 + )
10.14
10.15 # Abstractions for system-level files and streams.
10.16
10.17 @@ -78,7 +83,7 @@
10.18
10.19 "Close the file descriptor 'fd'."
10.20
10.21 - native.close(fd)
10.22 + _close(fd)
10.23
10.24 def closerange(fd_low, fd_high): pass
10.25 def dup(fd): pass
10.26 @@ -97,7 +102,7 @@
10.27
10.28 check_int(fd)
10.29 check_string(mode)
10.30 - return native.fdopen(fd, mode)
10.31 + return _fdopen(fd, mode)
10.32
10.33 def fpathconf(fd, name): pass
10.34 def fstat(fd): pass
10.35 @@ -124,7 +129,7 @@
10.36
10.37 check_int(fd)
10.38 check_int(n)
10.39 - return native.read(fd, n)
10.40 + return _read(fd, n)
10.41
10.42 def times(): pass
10.43 def ttyname(fd): pass
10.44 @@ -138,7 +143,7 @@
10.45
10.46 check_int(fd)
10.47 check_string(s)
10.48 - return native.write(fd, s)
10.49 + return _write(fd, s)
10.50
10.51 # Constants.
10.52
11.1 --- a/lib/sys.py Fri Dec 09 16:26:50 2016 +0100
11.2 +++ b/lib/sys.py Fri Dec 09 17:27:30 2016 +0100
11.3 @@ -21,16 +21,20 @@
11.4
11.5 from __builtins__.int import maxint, minint
11.6 from posix.io import stdin, stdout, stderr
11.7 -import native
11.8 +from native import (
11.9 + exit as _exit,
11.10 + get_argv as _get_argv,
11.11 + get_path as _get_path
11.12 + )
11.13
11.14 # NOTE: Environment details to be implemented.
11.15
11.16 -argv = native.get_argv()
11.17 -path = native.get_path()
11.18 +argv = _get_argv()
11.19 +path = _get_path()
11.20
11.21 # Functions to be implemented natively.
11.22
11.23 def exit(status=0):
11.24 - native.exit(int(status))
11.25 + _exit(int(status))
11.26
11.27 # vim: tabstop=4 expandtab shiftwidth=4