1.1 --- a/templates/progops.c Mon Dec 05 13:01:21 2016 +0100
1.2 +++ b/templates/progops.c Mon Dec 05 16:03:06 2016 +0100
1.3 @@ -109,6 +109,25 @@
1.4 __Raise(exc);
1.5 }
1.6
1.7 +/* Helper for raising exception instances. */
1.8 +
1.9 +__attr __ensure_instance(__attr arg)
1.10 +{
1.11 + /* Reserve space for the instance. */
1.12 +
1.13 + __attr args[1];
1.14 +
1.15 + /* Return instances as provided. */
1.16 +
1.17 + if (__is_instance(arg.value))
1.18 + return arg;
1.19 +
1.20 + /* Invoke non-instances to produce instances. */
1.21 +
1.22 + else
1.23 + return __invoke(arg, 0, 0, 0, 0, 1, args);
1.24 +}
1.25 +
1.26 /* Generic invocation operations. */
1.27
1.28 /* Invoke the given callable, supplying keyword argument details in the given