diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-08-30 08:47:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-02 22:22:48 -0700 |
commit | 4463445b017cd0099cbb0fa050d199a814505f72 (patch) | |
tree | d098442a4183c67bdcbeb90db97172d12685c166 /struct.h | |
parent | 834f4f7d1e56cee66b8cda42ca8bf36da26fe659 (diff) | |
download | txr-4463445b017cd0099cbb0fa050d199a814505f72.tar.gz txr-4463445b017cd0099cbb0fa050d199a814505f72.tar.bz2 txr-4463445b017cd0099cbb0fa050d199a814505f72.zip |
Introducing structs.
* args.c (args_cat_zap): New function.
* args.h: (args_cat_zap): Declared.
* eval.c (struct_lit_s): New symbol variable.
(eval_init): Initialize struct_lit_s.
* eval.h (struct_lit_s): Declared.
* gc.c (finalize): If a symbol has a struct slot
hash attached to it, we must free it when
the symbol is reclaimed.
* lib.c (make_sym): Initialize symbol's slot_cache pointer
to null.
(copy): Copy structure objects.
(init): Call struct_init to initialize struct module.
* lib.h (SLOT_CACHE_SIZE): New preprocessor symbol
(slot_cache_line_t, slot_cache_t): New typedefs.
(struct sym): New member, slot_cache.
* lisplib.c (struct_set_entries, struct_instantiate): New
static functions.
(liplib_init): Register new functions in dl_table.
parser.y (HASH_S): New terminal symbol.
(struct): New grammar rule.
(n_expr): Derive struct.
(yybadtoken): Map HASH_S to #S string.
parser.l (grammar): Recognize #S and return HASH_S token.
share/txr/stdlib/place.tl (slot): New defplace.
share/txr/stdlib/struct.tl: New file.
struct.c: New file.
struct.h: New file.
* Makefile (OBJS): Adding struct.o.
Diffstat (limited to 'struct.h')
-rw-r--r-- | struct.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/struct.h b/struct.h new file mode 100644 index 00000000..193c605d --- /dev/null +++ b/struct.h @@ -0,0 +1,39 @@ +/* Copyright 2015 + * Kaz Kylheku <kaz@kylheku.com> + * Vancouver, Canada + * All rights reserved. + * + * Redistribution of this software in source and binary forms, with or without + * modification, is permitted provided that the following two conditions are met. + * + * Use of this software in any manner constitutes agreement with the disclaimer + * which follows the two conditions. + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DAMAGES, HOWEVER CAUSED, + * AND UNDER ANY THEORY OF LIABILITY, ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +extern val struct_type_s; +val make_struct_type(val name, val super, val slots, val initfun, val boactor); +val struct_type_p(val obj); +val super(val type); +val make_struct(val type, val plist, struct args *); +val copy_struct(val strct); +val find_struct_type(val sym); +val slot(val strct, val sym); +val slotset(val strct, val sym, val newval); +val structp(val obj); +val struct_type(val strct); +val method(val strct, val obj); +void struct_init(void); |