1.1 --- a/templates/native.c Wed Dec 07 17:37:00 2016 +0100
1.2 +++ b/templates/native.c Thu Dec 08 18:51:05 2016 +0100
1.3 @@ -1,3 +1,21 @@
1.4 +/* Native functions.
1.5 +
1.6 +Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
1.7 +
1.8 +This program is free software; you can redistribute it and/or modify it under
1.9 +the terms of the GNU General Public License as published by the Free Software
1.10 +Foundation; either version 3 of the License, or (at your option) any later
1.11 +version.
1.12 +
1.13 +This program is distributed in the hope that it will be useful, but WITHOUT
1.14 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.15 +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.16 +details.
1.17 +
1.18 +You should have received a copy of the GNU General Public License along with
1.19 +this program. If not, see <http://www.gnu.org/licenses/>.
1.20 +*/
1.21 +
1.22 #include <stdlib.h> /* abs, exit */
1.23 #include <unistd.h> /* read, write */
1.24 #include <limits.h> /* INT_MAX, INT_MIN */
1.25 @@ -61,7 +79,7 @@
1.26 return newdata;
1.27 }
1.28
1.29 -/* Native functions. */
1.30 +/* Environment support. */
1.31
1.32 __attr __fn_native__exit(__attr __args[])
1.33 {
1.34 @@ -87,6 +105,8 @@
1.35 return __builtins___none_None;
1.36 }
1.37
1.38 +/* Identity testing. */
1.39 +
1.40 __attr __fn_native__is(__attr __args[])
1.41 {
1.42 __attr * const x = &__args[1];
1.43 @@ -103,6 +123,8 @@
1.44 return x->value != y->value ? __builtins___boolean_True : __builtins___boolean_False;
1.45 }
1.46
1.47 +/* Limit definition. */
1.48 +
1.49 __attr __fn_native__get_maxint(__attr __args[])
1.50 {
1.51 __attr * const status = &__args[1];
1.52 @@ -117,6 +139,8 @@
1.53 return __new_int(INT_MIN);
1.54 }
1.55
1.56 +/* Integer operations. */
1.57 +
1.58 __attr __fn_native__int_add(__attr __args[])
1.59 {
1.60 __attr * const _data = &__args[1];
1.61 @@ -357,6 +381,8 @@
1.62 return __new_str(s);
1.63 }
1.64
1.65 +/* String operations. */
1.66 +
1.67 __attr __fn_native__str_add(__attr __args[])
1.68 {
1.69 __attr * const _data = &__args[1];
1.70 @@ -456,6 +482,8 @@
1.71 return __new_str(sub);
1.72 }
1.73
1.74 +/* List operations. */
1.75 +
1.76 __attr __fn_native__list_init(__attr __args[])
1.77 {
1.78 __attr * const size = &__args[1];
1.79 @@ -569,6 +597,8 @@
1.80 return __builtins___none_None;
1.81 }
1.82
1.83 +/* Buffer operations. */
1.84 +
1.85 __attr __fn_native__buffer_str(__attr __args[])
1.86 {
1.87 __attr * const _data = &__args[1];
1.88 @@ -597,6 +627,8 @@
1.89 return __new_str(s);
1.90 }
1.91
1.92 +/* Method binding. */
1.93 +
1.94 __attr __fn_native__get_using(__attr __args[])
1.95 {
1.96 __attr * const callable = &__args[1];
1.97 @@ -605,6 +637,8 @@
1.98 return __replace_context(instance->value, *callable);
1.99 }
1.100
1.101 +/* Introspection. */
1.102 +
1.103 __attr __fn_native__object_getattr(__attr __args[])
1.104 {
1.105 __attr * const obj = &__args[1];