1.1 --- a/templates/progops.c Sun Nov 14 00:50:17 2021 +0100
1.2 +++ b/templates/progops.c Sun Nov 28 02:03:21 2021 +0100
1.3 @@ -42,6 +42,13 @@
1.4 return __ATTRVALUE(obj);
1.5 }
1.6
1.7 +__attr __new_stack(const __table * table, __ref cls, size_t size)
1.8 +{
1.9 + __attr attr = __stack_allocate(__stack, size);
1.10 + __init(__VALUE(attr), table, cls);
1.11 + return attr;
1.12 +}
1.13 +
1.14 __attr __new_wrapper(__attr context, __attr attr)
1.15 {
1.16 return __new___builtins___core_wrapper(__NULL, context, attr);
1.17 @@ -69,7 +76,10 @@
1.18 /* Copy the given number of values. */
1.19
1.20 for (i = 0; i < number; i++)
1.21 - data->attrs[i] = args[i];
1.22 + {
1.23 + data->attrs[i] = __RAWVALUE(0);
1.24 + __store_target(&data->attrs[i], args[i]);
1.25 + }
1.26
1.27 data->size = number;
1.28 }
1.29 @@ -81,7 +91,7 @@
1.30
1.31 /* Store a reference to the data in the object's __data__ attribute. */
1.32
1.33 - __store_via_object(__VALUE(self), __data__, (__attr) {.seqvalue=data});
1.34 + __store_via_object_internal(__VALUE(self), __data__, (__attr) {.seqvalue=data});
1.35 __newdata_sequence(number, data, args);
1.36 return self;
1.37 }
1.38 @@ -97,7 +107,7 @@
1.39
1.40 /* Store a reference to the data in the object's __data__ attribute. */
1.41
1.42 - __store_via_object(__VALUE(self), __data__, (__attr) {.seqvalue=data});
1.43 + __store_via_object_internal(__VALUE(self), __data__, (__attr) {.seqvalue=data});
1.44 __newdata_sequence(number, data, args);
1.45 return self;
1.46 }
1.47 @@ -207,8 +217,10 @@
1.48 /* Invoke the given callable, supplying keyword argument details in the given
1.49 codes and arguments arrays, indicating the number of arguments described.
1.50 The number of positional arguments is specified, and such arguments then
1.51 - follow as conventional function arguments. Typically, at least one argument
1.52 - is specified, starting with any context argument.
1.53 + follow as conventional function arguments.
1.54 +
1.55 + Typically, at least one argument is specified, starting with any context
1.56 + argument.
1.57 */
1.58
1.59 __attr __invoke(__attr callable, int always_callable,
1.60 @@ -220,9 +232,11 @@
1.61 __attr target = __unwrap_callable(callable);
1.62
1.63 /* Obtain the __args__ special member, referencing the parameter table. */
1.64 +
1.65 + const __ptable *ptable = __check_and_load_via_object(__VALUE(target), __args__).ptable;
1.66 +
1.67 /* Refer to the table and minimum/maximum. */
1.68
1.69 - const __ptable *ptable = __check_and_load_via_object(__VALUE(target), __args__).ptable;
1.70 const unsigned int min = ptable->min, max = ptable->max;
1.71
1.72 /* Reserve enough space for the arguments. */
1.73 @@ -270,10 +284,13 @@
1.74 /* Check the table entry against the supplied argument details.
1.75 Set the argument but only if it does not overwrite positional
1.76 arguments. */
1.77 - /* NOTE: Should use a more specific exception. */
1.78
1.79 if ((pos == -1) || (pos < nargs))
1.80 + {
1.81 + /* NOTE: Should use a more specific exception. */
1.82 +
1.83 __raise_type_error();
1.84 + }
1.85
1.86 /* Set the argument using the appropriate position. */
1.87
1.88 @@ -290,7 +307,8 @@
1.89 }
1.90
1.91 /* Call with the prepared arguments via a special adaptor function that
1.92 - converts the array to an argument list. */
1.93 + converts the array to an argument list. The context argument occupies
1.94 + position #0. */
1.95
1.96 return __call_with_args(
1.97 always_callable ?
1.98 @@ -336,7 +354,8 @@
1.99
1.100 return value == (__ref) &__predefined___builtins___boolean_True ? 1 :
1.101 value == (__ref) &__predefined___builtins___boolean_False ? 0 :
1.102 - __VALUE(__fn___builtins___boolean_bool(__NULL, attr)) == (__ref) &__predefined___builtins___boolean_True;
1.103 + __VALUE(__fn___builtins___boolean_bool(__NULL, attr)) ==
1.104 + (__ref) &__predefined___builtins___boolean_True;
1.105 }
1.106
1.107 /* Conversion of trailing data to an integer. */