1.1 --- a/templates/progops.c Sun Mar 19 00:56:43 2017 +0100
1.2 +++ b/templates/progops.c Fri Mar 24 22:39:37 2017 +0100
1.3 @@ -28,18 +28,18 @@
1.4
1.5 /* Generic instantiation operations, defining common members. */
1.6
1.7 -__attr __new(const __table * table, __ref cls, size_t size)
1.8 +__attr __new(const __table * table, __ref cls, size_t size, int immutable)
1.9 {
1.10 - __ref obj = (__ref) __ALLOCATE(1, size);
1.11 + __ref obj = (__ref) (immutable ? __ALLOCATEIM : __ALLOCATE)(1, size);
1.12 obj->table = table;
1.13 obj->pos = __INSTANCEPOS;
1.14 __store_via_object(obj, __class__, __ATTRVALUE(cls));
1.15 - return (__attr) {.value=obj};
1.16 + return __ATTRVALUE(obj);
1.17 }
1.18
1.19 -__attr __new_wrapper(__ref context, __attr attr)
1.20 +__attr __new_wrapper(__attr context, __attr attr)
1.21 {
1.22 - return __new___builtins___core_wrapper(__NULL, __ATTRVALUE(context), attr);
1.23 + return __new___builtins___core_wrapper(__NULL, context, attr);
1.24 }
1.25
1.26 /* Generic internal data allocation. */
1.27 @@ -74,7 +74,7 @@
1.28
1.29 /* Store a reference to the data in the object's __data__ attribute. */
1.30
1.31 - __store_via_object(self.value, __data__, attr);
1.32 + __store_via_object(__VALUE(self), __data__, attr);
1.33 return self;
1.34 }
1.35
1.36 @@ -145,7 +145,7 @@
1.37
1.38 /* Return instances as provided. */
1.39
1.40 - if (__is_instance(arg.value))
1.41 + if (__is_instance(__VALUE(arg)))
1.42 return arg;
1.43
1.44 /* Invoke non-instances to produce instances. */
1.45 @@ -174,7 +174,7 @@
1.46 /* Obtain the __args__ special member, referencing the parameter table. */
1.47 /* Refer to the table and minimum/maximum. */
1.48
1.49 - const __ptable *ptable = __check_and_load_via_object(target.value, __args__).ptable;
1.50 + const __ptable *ptable = __check_and_load_via_object(__VALUE(target), __args__).ptable;
1.51 const unsigned int min = ptable->min, max = ptable->max;
1.52
1.53 /* Reserve enough space for the arguments. */
1.54 @@ -203,7 +203,7 @@
1.55 /* Erase the remaining arguments. */
1.56
1.57 for (pos = nargs; pos < max; pos++)
1.58 - allargs[pos].value = 0;
1.59 + __SETNULL(allargs[pos]);
1.60
1.61 /* Fill keyword arguments. */
1.62
1.63 @@ -228,8 +228,8 @@
1.64
1.65 for (pos = nargs; pos < max; pos++)
1.66 {
1.67 - if (allargs[pos].value == 0)
1.68 - allargs[pos] = __GETDEFAULT(target.value, pos - min);
1.69 + if (__ISNULL(allargs[pos]))
1.70 + allargs[pos] = __GETDEFAULT(__VALUE(target), pos - min);
1.71 }
1.72 }
1.73
1.74 @@ -238,8 +238,8 @@
1.75
1.76 return __call_with_args(
1.77 always_callable ?
1.78 - __get_function(allargs[0].value, target) :
1.79 - __check_and_get_function(allargs[0].value, target),
1.80 + __get_function(allargs[0], target) :
1.81 + __check_and_get_function(allargs[0], target),
1.82 allargs, max);
1.83 }
1.84
1.85 @@ -265,8 +265,10 @@
1.86
1.87 int __BOOL(__attr attr)
1.88 {
1.89 + __ref truevalue = __VALUE(__builtins___boolean_True);
1.90 +
1.91 /* Invoke the bool function with the object and test against True. */
1.92
1.93 - return (attr.value == __builtins___boolean_True.value) ||
1.94 - (__fn___builtins___boolean_bool(__NULL, attr).value == __builtins___boolean_True.value);
1.95 + return (__VALUE(attr) == truevalue) ||
1.96 + (__VALUE(__fn___builtins___boolean_bool(__NULL, attr)) == truevalue);
1.97 }