1.1 --- a/templates/progops.c Sun Feb 12 23:24:42 2017 +0100
1.2 +++ b/templates/progops.c Mon Feb 13 15:35:36 2017 +0100
1.3 @@ -30,11 +30,14 @@
1.4 __attr __new(const __table * table, __ref cls, size_t size)
1.5 {
1.6 __ref obj = (__ref) __ALLOCATE(1, size);
1.7 - __attr self = {.context=obj, .value=obj};
1.8 - __attr tmp = {.context=0, .value=cls};
1.9 obj->table = table;
1.10 - __store_via_object(obj, __ATTRPOS(__class__), tmp);
1.11 - return self;
1.12 + __store_via_object(obj, __ATTRPOS(__class__), (__attr) {.value=cls});
1.13 + return (__attr) {.value=obj};
1.14 +}
1.15 +
1.16 +__attr __new_wrapper(__ref context, __attr attr)
1.17 +{
1.18 + return __new___builtins___core_wrapper((__attr[]) {__NULL, {.value=context}, attr});
1.19 }
1.20
1.21 /* Generic internal data allocation. */
1.22 @@ -181,9 +184,13 @@
1.23 unsigned int nkwargs, __param kwcodes[], __attr kwargs[],
1.24 unsigned int nargs, __attr args[])
1.25 {
1.26 + /* Unwrap any wrapped function. */
1.27 +
1.28 + __attr target = __unwrap_callable(callable);
1.29 +
1.30 /* Obtain the __args__ special member, referencing the parameter table. */
1.31
1.32 - __attr minparams = __check_and_load_via_object(callable.value, __ATTRPOS(__args__), __ATTRCODE(__args__));
1.33 + __attr minparams = __check_and_load_via_object(target.value, __ATTRPOS(__args__), __ATTRCODE(__args__));
1.34
1.35 /* Refer to the table and minimum/maximum. */
1.36
1.37 @@ -240,12 +247,12 @@
1.38 for (pos = nargs; pos < max; pos++)
1.39 {
1.40 if (allargs[pos].value == 0)
1.41 - allargs[pos] = __GETDEFAULT(callable.value, pos - min);
1.42 + allargs[pos] = __GETDEFAULT(target.value, pos - min);
1.43 }
1.44
1.45 /* Call with the prepared arguments. */
1.46
1.47 - return (always_callable ? __get_function(callable) : __check_and_get_function(callable))(allargs);
1.48 + return (always_callable ? __get_function(allargs[0].value, target) : __check_and_get_function(allargs[0].value, target))(allargs);
1.49 }
1.50
1.51 /* Error routines. */