1996-07-25 22:56:11 +00:00
|
|
|
|
/* classes: h_files */
|
|
|
|
|
|
|
2001-05-27 22:00:03 +00:00
|
|
|
|
#ifndef SCM_STRUCT_H
|
|
|
|
|
|
#define SCM_STRUCT_H
|
2001-08-31 11:17:06 +00:00
|
|
|
|
|
2001-05-27 22:00:03 +00:00
|
|
|
|
/* Copyright (C) 1995,1997,1999,2000,2001 Free Software Foundation, Inc.
|
2001-08-31 11:17:06 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2001-08-31 11:17:06 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
1996-07-25 22:56:11 +00:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
2001-08-31 11:17:06 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
*/
|
1999-12-16 03:46:42 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* alist.h, append.h, arbiters.h, async.h, boolean.h, chars.h,
continuations.h, debug.h, dynwind.h, error.h, eval.h, fdsocket.h,
feature.h, filesys.h, fports.h, gc.h, gdbint.h, genio.h, gsubr.h,
hash.h, init.h, ioext.h, kw.h, list.h, markers.h, marksweep.h,
mbstrings.h, numbers.h, objprop.h, options.h, pairs.h, ports.h,
posix.h, print.h, procprop.h, procs.h, ramap.h, read.h, root.h,
sequences.h, smob.h, socket.h, srcprop.h, stackchk.h, stime.h,
strings.h, strop.h, strorder.h, strports.h, struct.h, symbols.h,
tag.h, throw.h, unif.h, variable.h, vectors.h, version.h,
vports.h, weaks.h: #include "libguile/__scm.h", not
<libguile/__scm.h>. This allows 'gcc -MM' to determine which
dependencies are within libguile properly.
1996-09-05 21:19:08 +00:00
|
|
|
|
#include "libguile/__scm.h"
|
1997-06-03 21:49:52 +00:00
|
|
|
|
#include "libguile/print.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-09-22 22:38:56 +00:00
|
|
|
|
/* Number of words with negative index */
|
1999-06-23 11:17:36 +00:00
|
|
|
|
#define scm_struct_n_extra_words 4
|
1999-08-29 03:27:55 +00:00
|
|
|
|
#define scm_struct_entity_n_extra_words 6
|
1996-09-22 22:38:56 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
/* These are how the initial words of a vtable are allocated. */
|
1999-08-29 03:27:55 +00:00
|
|
|
|
#define scm_struct_i_setter -6 /* Setter */
|
|
|
|
|
|
#define scm_struct_i_procedure -5 /* Optional procedure slot */
|
1999-06-23 11:17:36 +00:00
|
|
|
|
#define scm_struct_i_free -4 /* Destructor */
|
|
|
|
|
|
#define scm_struct_i_ptr -3 /* Start of block (see alloc_struct) */
|
1997-10-03 00:44:28 +00:00
|
|
|
|
#define scm_struct_i_n_words -2 /* How many words allocated to this struct? */
|
1999-06-23 11:17:36 +00:00
|
|
|
|
#define scm_struct_i_size -1 /* Instance size */
|
|
|
|
|
|
#define scm_struct_i_flags -1 /* Upper 12 bits used as flags */
|
2001-07-29 20:39:38 +00:00
|
|
|
|
|
|
|
|
|
|
/* These indices must correspond to required_vtable_fields in
|
|
|
|
|
|
struct.c. */
|
1997-10-03 00:44:28 +00:00
|
|
|
|
#define scm_vtable_index_layout 0 /* A symbol describing the physical arrangement of this type. */
|
2001-07-29 20:39:38 +00:00
|
|
|
|
#define scm_vtable_index_vtable 1 /* A pointer to the handle for this vtable. */
|
|
|
|
|
|
#define scm_vtable_index_printer 2 /* A printer for this struct type. */
|
|
|
|
|
|
#define scm_vtable_offset_user 3 /* Where do user fields start? */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
typedef void (*scm_t_struct_free) (scm_t_bits * vtable, scm_t_bits * data);
|
1999-06-23 11:17:36 +00:00
|
|
|
|
|
|
|
|
|
|
#define SCM_STRUCTF_MASK (0xFFF << 20)
|
1998-12-16 08:08:07 +00:00
|
|
|
|
#define SCM_STRUCTF_ENTITY (1L << 30) /* Indicates presence of proc slots */
|
1999-03-11 11:47:58 +00:00
|
|
|
|
#define SCM_STRUCTF_LIGHT (1L << 31) /* Light representation
|
|
|
|
|
|
(no hidden words) */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-08-31 11:17:06 +00:00
|
|
|
|
#define SCM_STRUCTP(X) (!SCM_IMP(X) && (SCM_TYP3(X) == scm_tc3_struct))
|
2001-06-14 19:50:43 +00:00
|
|
|
|
#define SCM_STRUCT_DATA(X) ((scm_t_bits *) SCM_CELL_WORD_1 (X))
|
* tags.h: Update tag system docs.
(scm_tc3_cons_gloc): Renamed to scm_tc3_struct. Changed all uses.
(scm_tcs_cons_gloc): Renamed to scm_tcs_struct. Changed all uses.
(SCM_ECONSP, SCM_NECONSP): Removed. Changed all uses to SCM_CONSP
or SCM_NCONSP, respectively.
* struct.c, struct.h, srcprop.c, procs.c, procprop.c, print.c,
objects.c. modules.c, goops.c, eval.c, debug.c: Changed all uses
of scm_tc3_cond_gloc and scm_tcs_cons_gloc. See above.
* print.c (scm_iprin1): Remove printing of glocs. Do not try to
tell glocs from structs.
* gc.c (scm_gc_mark, scm_gc_sweep): Remove handling of glocs.
* eval.c (scm_m_atbind): Make a list of variables, not glocs.
(scm_ceval, scm_deval): For SCM_IM_BIND, fiddle with variables
instead of with glocs.
(EVALCAR): Do not test for glocs.
(scm_lookupcar, scm_lookupcar1): Do not handle glocs in race
condition.
(scm_unmemocar): Do not handle glocs.
(scm_m_atfop): Memoize as a variable, not as a gloc.
(scm_eval_args, scm_deval_args): Do not handle glocs.
(scm_ceval, scm_deval): Likewise.
* eval.h (SCM_XEVALCAR): Do not test for glocs.
(SCM_GLOC_VAR, SCM_GLOC_VAL, SCM_GLOC_SET_VAL, SCM_GLOC_VAL_LOC):
Removed.
* debug.h, debug.c (scm_make_gloc, scm_gloc_p): Removed.
* dynwind.c (scm_swap_bindings): Likewise.
(scm_dowinds): Updated to recognize lists of variables instead of
lists of glocs.
* __scm.h (SCM_CAUTIOS, SCM_RECKLESS): Update comments.
2001-07-26 21:40:18 +00:00
|
|
|
|
#define SCM_STRUCT_VTABLE_DATA(X) ((scm_t_bits *) (SCM_CELL_WORD_0 (X) - scm_tc3_struct))
|
2000-04-11 22:36:55 +00:00
|
|
|
|
|
|
|
|
|
|
#define SCM_STRUCT_LAYOUT(X) (SCM_PACK (SCM_STRUCT_VTABLE_DATA (X) [scm_vtable_index_layout]))
|
|
|
|
|
|
#define SCM_SET_STRUCT_LAYOUT(X, v) (SCM_STRUCT_VTABLE_DATA (X) [scm_vtable_index_layout] = SCM_UNPACK (v))
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_STRUCT_VTABLE(X) (SCM_PACK (SCM_STRUCT_VTABLE_DATA (X) [scm_vtable_index_vtable]))
|
2001-06-11 08:51:28 +00:00
|
|
|
|
#define SCM_STRUCT_VTABLE_FLAGS(X) \
|
|
|
|
|
|
(SCM_STRUCT_VTABLE_DATA (X) [scm_struct_i_flags])
|
2000-04-11 22:36:55 +00:00
|
|
|
|
#define SCM_STRUCT_PRINTER(X) (SCM_PACK (SCM_STRUCT_VTABLE_DATA (X) [scm_vtable_index_printer]))
|
2000-11-26 18:27:49 +00:00
|
|
|
|
#define SCM_SET_STRUCT_PRINTER(x, v)\
|
2001-05-27 22:00:03 +00:00
|
|
|
|
(SCM_STRUCT_VTABLE_DATA (x) [scm_vtable_index_printer] = SCM_UNPACK (v))
|
2001-06-14 19:50:43 +00:00
|
|
|
|
#define SCM_SET_VTABLE_DESTRUCTOR(X, D) (SCM_STRUCT_DATA (X) [scm_struct_i_free] = (scm_t_bits) (D))
|
1996-09-22 22:38:56 +00:00
|
|
|
|
/* Efficiency is important in the following macro, since it's used in GC */
|
|
|
|
|
|
#define SCM_LAYOUT_TAILP(X) (((X) & 32) == 0) /* R, W or O */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1999-03-14 16:52:56 +00:00
|
|
|
|
#define SCM_STRUCT_TABLE_NAME(X) SCM_CAR (X)
|
|
|
|
|
|
#define SCM_SET_STRUCT_TABLE_NAME(X, NAME) SCM_SETCAR (X, NAME)
|
|
|
|
|
|
#define SCM_STRUCT_TABLE_CLASS(X) SCM_CDR (X)
|
|
|
|
|
|
#define SCM_SET_STRUCT_TABLE_CLASS(X, CLASS) SCM_SETCDR (X, CLASS)
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_struct_table;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-08-09 18:29:39 +00:00
|
|
|
|
#define SCM_STRUCT_GC_CHAIN(X) SCM_CELL_OBJECT_3 (X)
|
|
|
|
|
|
#define SCM_SET_STRUCT_GC_CHAIN(X, Y) SCM_SET_CELL_OBJECT_3 (X, Y)
|
2002-09-05 21:12:21 +00:00
|
|
|
|
SCM_API SCM scm_i_structs_to_free;
|
2000-08-09 18:29:39 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
SCM_API scm_t_bits * scm_alloc_struct (int n_words, int n_extra,
|
|
|
|
|
|
const char *what);
|
|
|
|
|
|
SCM_API void scm_struct_free_0 (scm_t_bits * vtable, scm_t_bits * data);
|
|
|
|
|
|
SCM_API void scm_struct_free_light (scm_t_bits * vtable, scm_t_bits * data);
|
|
|
|
|
|
SCM_API void scm_struct_free_standard (scm_t_bits * vtable, scm_t_bits * data);
|
|
|
|
|
|
SCM_API void scm_struct_free_entity (scm_t_bits * vtable, scm_t_bits * data);
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_make_struct_layout (SCM fields);
|
|
|
|
|
|
SCM_API SCM scm_struct_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_struct_vtable_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_make_struct (SCM vtable, SCM tail_array_size, SCM init);
|
|
|
|
|
|
SCM_API SCM scm_make_vtable_vtable (SCM extra_fields, SCM tail_array_size, SCM init);
|
|
|
|
|
|
SCM_API SCM scm_struct_ref (SCM handle, SCM pos);
|
|
|
|
|
|
SCM_API SCM scm_struct_set_x (SCM handle, SCM pos, SCM val);
|
|
|
|
|
|
SCM_API SCM scm_struct_vtable (SCM handle);
|
|
|
|
|
|
SCM_API SCM scm_struct_vtable_tag (SCM handle);
|
|
|
|
|
|
SCM_API unsigned long scm_struct_ihashq (SCM obj, unsigned long n);
|
|
|
|
|
|
SCM_API SCM scm_struct_create_handle (SCM obj);
|
|
|
|
|
|
SCM_API SCM scm_struct_vtable_name (SCM vtable);
|
|
|
|
|
|
SCM_API SCM scm_set_struct_vtable_name_x (SCM vtable, SCM name);
|
|
|
|
|
|
SCM_API void scm_print_struct (SCM exp, SCM port, scm_print_state *);
|
|
|
|
|
|
SCM_API void scm_struct_prehistory (void);
|
|
|
|
|
|
SCM_API void scm_init_struct (void);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-05-27 22:00:03 +00:00
|
|
|
|
#endif /* SCM_STRUCT_H */
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|