1.1 --- a/generator.py Tue Nov 29 17:29:42 2016 +0100
1.2 +++ b/generator.py Tue Nov 29 22:09:52 2016 +0100
1.3 @@ -919,7 +919,7 @@
1.4 __args[0] = __new(&%s, &%s, sizeof(%s));
1.5
1.6 /* Allocate a structure for the data. */
1.7 - data = __newdata(__args, number);
1.8 + data = __newfragment(__args, number);
1.9
1.10 /* Store a reference to the data in the object's __data__ attribute. */
1.11 __store_via_object(__args[0].value, %s, data);
2.1 --- a/lib/native.py Tue Nov 29 17:29:42 2016 +0100
2.2 +++ b/lib/native.py Tue Nov 29 22:09:52 2016 +0100
2.3 @@ -1,7 +1,8 @@
2.4 #!/usr/bin/env python
2.5
2.6 """
2.7 -Native library functions.
2.8 +Native library functions. None of these are actually defined here. Instead,
2.9 +native implementations are substituted when each program is built.
2.10
2.11 Copyright (C) 2011, 2015, 2016 Paul Boddie <paul@boddie.org.uk>
2.12
2.13 @@ -19,13 +20,19 @@
2.14 this program. If not, see <http://www.gnu.org/licenses/>.
2.15 """
2.16
2.17 +# Environment support.
2.18 +
2.19 def _exit(status): pass
2.20 def _get_argv(): pass
2.21 def _get_path(): pass
2.22
2.23 +# Identity testing.
2.24 +
2.25 def _is(x, y): pass
2.26 def _is_not(x, y): pass
2.27
2.28 +# Integer operations.
2.29 +
2.30 def _int_add(self, other): pass
2.31 def _int_div(self, other): pass
2.32 def _int_mod(self, other): pass
2.33 @@ -45,6 +52,8 @@
2.34
2.35 def _int_str(self): pass
2.36
2.37 +# String operations.
2.38 +
2.39 def _str_add(self, other): pass
2.40 def _str_lt(self, other): pass
2.41 def _str_gt(self, other): pass
2.42 @@ -52,6 +61,8 @@
2.43 def _str_len(self): pass
2.44 def _str_nonempty(self): pass
2.45
2.46 +# List operations.
2.47 +
2.48 def _list_init(size): pass
2.49 def _list_setsize(self, size): pass
2.50 def _list_append(self, value): pass
2.51 @@ -61,15 +72,22 @@
2.52 def _list_element(self, index): pass
2.53 def _list_setelement(self, index, value): pass
2.54
2.55 +# Buffer operations.
2.56 +
2.57 def _buffer_str(self): pass
2.58
2.59 +# Method binding.
2.60 +
2.61 def _get_using(callable, instance): pass
2.62
2.63 +# Introspection.
2.64 +
2.65 def _object_getattr(obj, name, default): pass
2.66 -
2.67 def _isinstance(obj, cls): pass
2.68 def _issubclass(obj, cls): pass
2.69
2.70 +# Input/output.
2.71 +
2.72 def _read(fd, n): pass
2.73 def _write(fd, str): pass
2.74
3.1 --- a/templates/native.c Tue Nov 29 17:29:42 2016 +0100
3.2 +++ b/templates/native.c Tue Nov 29 22:09:52 2016 +0100
3.3 @@ -341,7 +341,7 @@
3.4
3.5 /* Allocate space for the list. */
3.6 __fragment *data = (__fragment *) __ALLOCATE(1, __FRAGMENT_SIZE(n));
3.7 - __attr attr = {0, .data=data};
3.8 + __attr attr = {0, .seqvalue=data};
3.9
3.10 /* The initial capacity is the same as the given size. */
3.11 data->size = 0;
3.12 @@ -354,7 +354,7 @@
3.13 __attr * const self = &__args[1];
3.14 __attr * const size = &__args[2];
3.15 /* self.__data__ interpreted as list */
3.16 - __fragment *data = __load_via_object(self->value, __pos___data__).data;
3.17 + __fragment *data = __load_via_object(self->value, __pos___data__).seqvalue;
3.18 /* size.__data__ interpreted as int */
3.19 unsigned int n = __load_via_object(size->value, __pos___data__).intvalue;
3.20
3.21 @@ -367,7 +367,7 @@
3.22 __attr * const self = &__args[1];
3.23 __attr * const value = &__args[2];
3.24 /* self.__data__ interpreted as list */
3.25 - __fragment *data = __load_via_object(self->value, __pos___data__).data;
3.26 + __fragment *data = __load_via_object(self->value, __pos___data__).seqvalue;
3.27 __fragment *newdata = data;
3.28 unsigned int size = data->size, capacity = data->capacity;
3.29 unsigned int n;
3.30 @@ -387,7 +387,7 @@
3.31
3.32 /* Replace the __data__ attribute if appropriate. */
3.33 if (newdata != data)
3.34 - __store_via_object(self->value, __pos___data__, ((__attr) {0, .data=newdata}));
3.35 + __store_via_object(self->value, __pos___data__, ((__attr) {0, .seqvalue=newdata}));
3.36 return __builtins___none_None;
3.37 }
3.38
3.39 @@ -396,8 +396,8 @@
3.40 __attr * const self = &__args[1];
3.41 __attr * const other = &__args[2];
3.42 /* self.__data__, other.__data__ interpreted as list */
3.43 - __fragment *data = __load_via_object(self->value, __pos___data__).data;
3.44 - __fragment *other_data = __load_via_object(other->value, __pos___data__).data;
3.45 + __fragment *data = __load_via_object(self->value, __pos___data__).seqvalue;
3.46 + __fragment *other_data = __load_via_object(other->value, __pos___data__).seqvalue;
3.47 __fragment *newdata = data;
3.48 unsigned int size = data->size, capacity = data->capacity;
3.49 unsigned int other_size = other_data->size;
3.50 @@ -418,7 +418,7 @@
3.51
3.52 /* Replace the __data__ attribute if appropriate. */
3.53 if (newdata != data)
3.54 - __store_via_object(self->value, __pos___data__, ((__attr) {0, .data=newdata}));
3.55 + __store_via_object(self->value, __pos___data__, ((__attr) {0, .seqvalue=newdata}));
3.56 return __builtins___none_None;
3.57 }
3.58
3.59 @@ -426,7 +426,7 @@
3.60 {
3.61 __attr * const self = &__args[1];
3.62 /* self.__data__ interpreted as fragment */
3.63 - unsigned int size = __load_via_object(self->value, __pos___data__).data->size;
3.64 + unsigned int size = __load_via_object(self->value, __pos___data__).seqvalue->size;
3.65
3.66 /* Return the new integer. */
3.67 return __new_int(size);
3.68 @@ -436,7 +436,7 @@
3.69 {
3.70 __attr * const self = &__args[1];
3.71
3.72 - return __load_via_object(self->value, __pos___data__).data->size ? __builtins___boolean_True : __builtins___boolean_False;
3.73 + return __load_via_object(self->value, __pos___data__).seqvalue->size ? __builtins___boolean_True : __builtins___boolean_False;
3.74 }
3.75
3.76 __attr __fn_native__list_element(__attr __args[])
3.77 @@ -444,7 +444,7 @@
3.78 __attr * const self = &__args[1];
3.79 __attr * const index = &__args[2];
3.80 /* self.__data__ interpreted as fragment */
3.81 - __attr *elements = __load_via_object(self->value, __pos___data__).data->attrs;
3.82 + __attr *elements = __load_via_object(self->value, __pos___data__).seqvalue->attrs;
3.83 /* index.__data__ interpreted as int */
3.84 int i = __load_via_object(index->value, __pos___data__).intvalue;
3.85
3.86 @@ -457,7 +457,7 @@
3.87 __attr * const index = &__args[2];
3.88 __attr * const value = &__args[3];
3.89 /* self.__data__ interpreted as fragment */
3.90 - __attr *elements = __load_via_object(self->value, __pos___data__).data->attrs;
3.91 + __attr *elements = __load_via_object(self->value, __pos___data__).seqvalue->attrs;
3.92 /* index.__data__ interpreted as int */
3.93 int i = __load_via_object(index->value, __pos___data__).intvalue;
3.94
3.95 @@ -470,7 +470,7 @@
3.96 {
3.97 __attr * const self = &__args[1];
3.98 /* self.__data__ interpreted as buffer */
3.99 - __fragment *data = __load_via_object(self->value, __pos___data__).data;
3.100 + __fragment *data = __load_via_object(self->value, __pos___data__).seqvalue;
3.101 unsigned int size = 0, i, j, n;
3.102 char *s, *o;
3.103
4.1 --- a/templates/progops.c Tue Nov 29 17:29:42 2016 +0100
4.2 +++ b/templates/progops.c Tue Nov 29 22:09:52 2016 +0100
4.3 @@ -24,12 +24,12 @@
4.4
4.5 /* Generic internal data allocation. */
4.6
4.7 -__attr __newdata(__attr args[], unsigned int number)
4.8 +__attr __newfragment(__attr args[], unsigned int number)
4.9 {
4.10 /* Calculate the size of the fragment. */
4.11
4.12 __fragment *data = (__fragment *) __ALLOCATE(1, __FRAGMENT_SIZE(number));
4.13 - __attr attr = {0, .data=data};
4.14 + __attr attr = {0, .seqvalue=data};
4.15 unsigned int i, j;
4.16
4.17 /* Copy the given number of values, starting from the second element. */
5.1 --- a/templates/progops.h Tue Nov 29 17:29:42 2016 +0100
5.2 +++ b/templates/progops.h Tue Nov 29 22:09:52 2016 +0100
5.3 @@ -7,7 +7,7 @@
5.4
5.5 __attr __new(const __table *table, __ref cls, size_t size);
5.6
5.7 -__attr __newdata(__attr args[], unsigned int number);
5.8 +__attr __newfragment(__attr args[], unsigned int number);
5.9
5.10 __attr __invoke(__attr callable, int always_callable,
5.11 unsigned int nkwargs, __param kwcodes[], __attr kwargs[],
6.1 --- a/templates/types.h Tue Nov 29 17:29:42 2016 +0100
6.2 +++ b/templates/types.h Tue Nov 29 22:09:52 2016 +0100
6.3 @@ -53,7 +53,7 @@
6.4 int intvalue; /* integer value */
6.5 double floatvalue; /* floating point value */
6.6 char * strvalue; /* string value */
6.7 - __fragment * data; /* sequence data */
6.8 + __fragment * seqvalue; /* sequence data */
6.9 };
6.10 } __attr;
6.11
6.12 @@ -66,7 +66,8 @@
6.13
6.14 typedef __obj * __ref;
6.15
6.16 -/* Fragments are simple collections of attributes employed by sequence types. */
6.17 +/* Fragments are simple collections of attributes employed by sequence types.
6.18 + They provide the basis of lists and tuples. */
6.19
6.20 typedef struct __fragment
6.21 {