Lichen

Changeset

764:c731ec23e6b1
2017-03-24 Paul Boddie raw files shortlog changelog graph Merged changes from the integers-as-tagged-attrs branch. normal-function-parameters
templates/ops.c (file) templates/ops.h (file) templates/progops.c (file)
     1.1 --- a/templates/ops.c	Fri Mar 24 22:39:37 2017 +0100
     1.2 +++ b/templates/ops.c	Fri Mar 24 22:46:46 2017 +0100
     1.3 @@ -326,8 +326,11 @@
     1.4  
     1.5  __attr (*__get_function(__attr context, __attr target))()
     1.6  {
     1.7 -    target = __unwrap_callable(target);
     1.8 +    return __get_function_unwrapped(context, __unwrap_callable(target));
     1.9 +}
    1.10  
    1.11 +__attr (*__get_function_unwrapped(__attr context, __attr target))(__attr[])
    1.12 +{
    1.13      /* Require null or instance contexts for functions and methods respectively,
    1.14         or type instance contexts for type methods. */
    1.15  
    1.16 @@ -339,8 +342,11 @@
    1.17  
    1.18  __attr (*__check_and_get_function(__attr context, __attr target))()
    1.19  {
    1.20 -    target = __unwrap_callable(target);
    1.21 +    return __check_and_get_function_unwrapped(context, __unwrap_callable(target));
    1.22 +}
    1.23  
    1.24 +__attr (*__check_and_get_function_unwrapped(__attr context, __attr target))(__attr[])
    1.25 +{
    1.26      /* Require null or instance contexts for functions and methods respectively,
    1.27         or type instance contexts for type methods. */
    1.28  
     2.1 --- a/templates/ops.h	Fri Mar 24 22:39:37 2017 +0100
     2.2 +++ b/templates/ops.h	Fri Mar 24 22:46:46 2017 +0100
     2.3 @@ -114,7 +114,9 @@
     2.4  __attr __unwrap_callable(__attr callable);
     2.5  __attr (*__get_function_unchecked(__attr target))();
     2.6  __attr (*__get_function(__attr context, __attr target))();
     2.7 +__attr (*__get_function_unwrapped(__attr context, __attr target))();
     2.8  __attr (*__check_and_get_function(__attr context, __attr target))();
     2.9 +__attr (*__check_and_get_function_unwrapped(__attr context, __attr target))();
    2.10  
    2.11  /* Parameter position operations. */
    2.12  
     3.1 --- a/templates/progops.c	Fri Mar 24 22:39:37 2017 +0100
     3.2 +++ b/templates/progops.c	Fri Mar 24 22:46:46 2017 +0100
     3.3 @@ -186,14 +186,22 @@
     3.4      unsigned int pos, kwpos;
     3.5  
     3.6      /* Check the number of arguments. */
     3.7 +
     3.8 +    if ((nargs == max) && (nkwargs == 0))
     3.9 +    {
    3.10 +        /* pass */
    3.11 +    }
    3.12 +
    3.13      /* NOTE: Should use a more specific exception. */
    3.14  
    3.15 -    if ((min > (nargs + nkwargs)) || ((nargs + nkwargs) > max))
    3.16 +    else if ((min > (nargs + nkwargs)) || ((nargs + nkwargs) > max))
    3.17 +    {
    3.18          __raise_type_error();
    3.19 +    }
    3.20  
    3.21      /* Copy the arguments. */
    3.22  
    3.23 -    if (nargs < max)
    3.24 +    else if (nargs < max)
    3.25      {
    3.26          allargs = moreargs;
    3.27  
    3.28 @@ -238,8 +246,8 @@
    3.29  
    3.30      return __call_with_args(
    3.31          always_callable ?
    3.32 -        __get_function(allargs[0], target) :
    3.33 -        __check_and_get_function(allargs[0], target),
    3.34 +        __get_function_unwrapped(allargs[0], target) :
    3.35 +        __check_and_get_function_unwrapped(allargs[0], target),
    3.36          allargs, max);
    3.37  }
    3.38