1996-07-25 22:56:11 +00:00
|
|
|
|
/* classes: h_files */
|
|
|
|
|
|
|
2001-04-21 21:50:08 +00:00
|
|
|
|
#ifndef SCM_SMOB_H
|
|
|
|
|
|
#define SCM_SMOB_H
|
2001-08-31 12:13:50 +00:00
|
|
|
|
|
2011-02-13 14:50:05 +01:00
|
|
|
|
/* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2004, 2006, 2009,
|
2015-02-10 14:35:35 +01:00
|
|
|
|
* 2010, 2011, 2012, 2015 Free Software Foundation, Inc.
|
2001-08-31 12:13:50 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
2001-08-31 12:13:50 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, 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 12:13:50 +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
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
2001-08-31 12:13:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-08-31 12:13:50 +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-07-18 14:39:52 +00:00
|
|
|
|
#include "libguile/print.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2006-05-26 13:50:21 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1999-05-23 09:57:31 +00:00
|
|
|
|
/* This is the internal representation of a smob type */
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct scm_smob_descriptor
|
|
|
|
|
|
{
|
2003-10-07 15:58:19 +00:00
|
|
|
|
char const *name;
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
size_t size;
|
2000-03-02 20:54:43 +00:00
|
|
|
|
SCM (*mark) (SCM);
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
size_t (*free) (SCM);
|
2000-03-02 20:54:43 +00:00
|
|
|
|
int (*print) (SCM exp, SCM port, scm_print_state *pstate);
|
|
|
|
|
|
SCM (*equalp) (SCM, SCM);
|
2011-02-13 14:50:05 +01:00
|
|
|
|
scm_t_subr apply;
|
2012-03-18 20:04:28 +01:00
|
|
|
|
SCM apply_trampoline;
|
1999-05-23 09:57:31 +00:00
|
|
|
|
} scm_smob_descriptor;
|
|
|
|
|
|
|
2006-05-22 19:12:12 +00:00
|
|
|
|
|
scm_new_smob, scm_new_double_smob inline functions
* libguile/smob.h (scm_new_smob, scm_new_double_smob): New constructors,
which do what SCM_NEWSMOB / SCM_NEWSMOB3 had done, but with inline
functions instead of macros. They also bail to scm_i_new_smob /
scm_i_new_double_smob in either the mark or the free case, so that the
inline definition doesn't reference other internal details like libgc
stuff.
(SCM_SMOB_TYPE_MASK et al): Move definitions up so the new_smob see
them as already being declared.
(SCM_NEWSMOB, SCM_RETURN_NEWSMOB, SCM_NEWSMOB2, SCM_RETURN_NEWSMOB2):
(SCM_NEWSMOB3, SCM_RETURN_NEWSMOB3): Reimplement in terms of the new
inline functions.
(scm_i_finalize_smob): Remove declaration, as it's no longer needed or
used.
Remove now-unneeded bdw-gc include.
* libguile/smob.c (finalize_smob): Rename from scm_i_finalize_smob, and
make static.
(scm_i_new_smob, scm_i_new_double_smob): Slow-path allocators.
* libguile/inline.c: Include smob.h, so as to reify scm_new_smob and
scm_new_double_smob.
2011-05-26 16:49:47 +02:00
|
|
|
|
#define SCM_SMOB_TYPE_MASK 0xffff
|
|
|
|
|
|
#define SCM_SMOB_TYPE_BITS(tc) (tc)
|
|
|
|
|
|
#define SCM_TC2SMOBNUM(x) (0x0ff & ((x) >> 8))
|
|
|
|
|
|
#define SCM_SMOBNUM(x) (SCM_TC2SMOBNUM (SCM_CELL_TYPE (x)))
|
|
|
|
|
|
/* SCM_SMOBNAME can be 0 if name is missing */
|
|
|
|
|
|
#define SCM_SMOBNAME(smobnum) (scm_smobs[smobnum].name)
|
refactor tc7 and tc16 checks
* libguile/tags.h (SCM_HAS_TYP7, SCM_HAS_TYP7S, SCM_HAS_TYP16): New
macros.
* libguile/bytevectors.h (SCM_BYTEVECTOR_P):
* libguile/control.h (SCM_PROMPT_P):
* libguile/filesys.h (SCM_DIRP):
* libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_FLUID_P)
(SCM_I_DYNAMIC_STATE_P):
* libguile/foreign.h (SCM_POINTER_P):
* libguile/fports.h (SCM_FPORTP):
* libguile/frames.h (SCM_VM_FRAME_P):
* libguile/hashtab.h (SCM_HASHTABLE_P):
* libguile/inline.h (scm_get_byte_or_eof):
* libguile/numbers.h (SCM_REALP, SCM_BIGP, SCM_COMPLEXP, SCM_FRACTIONP):
* libguile/objcodes.h (SCM_OBJCODE_P):
* libguile/ports.h (SCM_OUTPUT_PORT_P):
* libguile/programs.h (SCM_PROGRAM_P):
* libguile/smob.h (SCM_SMOB_PREDICATE):
* libguile/srfi-14.h (SCM_CHARSETP):
* libguile/strings.c (IS_STRING):
* libguile/strports.h (SCM_STRPORTP):
* libguile/symbols.h (scm_is_symbol):
* libguile/variable.h (SCM_VARIABLEP):
* libguile/vectors.h (SCM_I_IS_VECTOR, SCM_I_IS_NONWEAK_VECTOR):
* libguile/vm-i-system.c (call, tail-call, mv-call)
* libguile/vm.h (SCM_VM_P, SCM_VM_CONT_P):
* libguile/weak-set.c (SCM_WEAK_SET_P):
* libguile/weak-table.c (SCM_WEAK_TABLE_P):
* libguile/weak-vector.h (SCM_I_WVECTP): Use them.
2011-10-24 17:34:47 +02:00
|
|
|
|
#define SCM_SMOB_PREDICATE(tag, obj) SCM_HAS_TYP16 (obj, tag)
|
scm_new_smob, scm_new_double_smob inline functions
* libguile/smob.h (scm_new_smob, scm_new_double_smob): New constructors,
which do what SCM_NEWSMOB / SCM_NEWSMOB3 had done, but with inline
functions instead of macros. They also bail to scm_i_new_smob /
scm_i_new_double_smob in either the mark or the free case, so that the
inline definition doesn't reference other internal details like libgc
stuff.
(SCM_SMOB_TYPE_MASK et al): Move definitions up so the new_smob see
them as already being declared.
(SCM_NEWSMOB, SCM_RETURN_NEWSMOB, SCM_NEWSMOB2, SCM_RETURN_NEWSMOB2):
(SCM_NEWSMOB3, SCM_RETURN_NEWSMOB3): Reimplement in terms of the new
inline functions.
(scm_i_finalize_smob): Remove declaration, as it's no longer needed or
used.
Remove now-unneeded bdw-gc include.
* libguile/smob.c (finalize_smob): Rename from scm_i_finalize_smob, and
make static.
(scm_i_new_smob, scm_i_new_double_smob): Slow-path allocators.
* libguile/inline.c: Include smob.h, so as to reify scm_new_smob and
scm_new_double_smob.
2011-05-26 16:49:47 +02:00
|
|
|
|
#define SCM_SMOB_DESCRIPTOR(x) (scm_smobs[SCM_SMOBNUM (x)])
|
|
|
|
|
|
#define SCM_SMOB_APPLICABLE_P(x) (SCM_SMOB_DESCRIPTOR (x).apply)
|
|
|
|
|
|
|
|
|
|
|
|
/* Maximum number of SMOB types. */
|
|
|
|
|
|
#define SCM_I_MAX_SMOB_TYPE_COUNT 256
|
|
|
|
|
|
|
|
|
|
|
|
SCM_API long scm_numsmob;
|
|
|
|
|
|
SCM_API scm_smob_descriptor scm_smobs[];
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-03-14 06:42:40 +00:00
|
|
|
|
|
scm_new_smob, scm_new_double_smob inline functions
* libguile/smob.h (scm_new_smob, scm_new_double_smob): New constructors,
which do what SCM_NEWSMOB / SCM_NEWSMOB3 had done, but with inline
functions instead of macros. They also bail to scm_i_new_smob /
scm_i_new_double_smob in either the mark or the free case, so that the
inline definition doesn't reference other internal details like libgc
stuff.
(SCM_SMOB_TYPE_MASK et al): Move definitions up so the new_smob see
them as already being declared.
(SCM_NEWSMOB, SCM_RETURN_NEWSMOB, SCM_NEWSMOB2, SCM_RETURN_NEWSMOB2):
(SCM_NEWSMOB3, SCM_RETURN_NEWSMOB3): Reimplement in terms of the new
inline functions.
(scm_i_finalize_smob): Remove declaration, as it's no longer needed or
used.
Remove now-unneeded bdw-gc include.
* libguile/smob.c (finalize_smob): Rename from scm_i_finalize_smob, and
make static.
(scm_i_new_smob, scm_i_new_double_smob): Slow-path allocators.
* libguile/inline.c: Include smob.h, so as to reify scm_new_smob and
scm_new_double_smob.
2011-05-26 16:49:47 +02:00
|
|
|
|
SCM_API SCM scm_i_new_smob (scm_t_bits tc, scm_t_bits);
|
|
|
|
|
|
SCM_API SCM scm_i_new_double_smob (scm_t_bits tc, scm_t_bits,
|
|
|
|
|
|
scm_t_bits, scm_t_bits);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_INLINE SCM scm_new_smob (scm_t_bits tc, scm_t_bits);
|
|
|
|
|
|
SCM_INLINE SCM scm_new_double_smob (scm_t_bits tc, scm_t_bits,
|
|
|
|
|
|
scm_t_bits, scm_t_bits);
|
|
|
|
|
|
|
|
|
|
|
|
#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
|
|
|
|
|
|
SCM_INLINE_IMPLEMENTATION SCM
|
|
|
|
|
|
scm_new_smob (scm_t_bits tc, scm_t_bits data)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_t_bits smobnum = SCM_TC2SMOBNUM (tc);
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_UNLIKELY (scm_smobs[smobnum].mark || scm_smobs[smobnum].free))
|
|
|
|
|
|
return scm_i_new_smob (tc, data);
|
|
|
|
|
|
else
|
|
|
|
|
|
return scm_cell (tc, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_INLINE_IMPLEMENTATION SCM
|
|
|
|
|
|
scm_new_double_smob (scm_t_bits tc, scm_t_bits data1,
|
|
|
|
|
|
scm_t_bits data2, scm_t_bits data3)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_t_bits smobnum = SCM_TC2SMOBNUM (tc);
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_UNLIKELY (scm_smobs[smobnum].mark || scm_smobs[smobnum].free))
|
|
|
|
|
|
return scm_i_new_double_smob (tc, data1, data2, data3);
|
|
|
|
|
|
else
|
|
|
|
|
|
return scm_double_cell (tc, data1, data2, data3);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_NEWSMOB(z, tc, data) \
|
|
|
|
|
|
z = scm_new_smob ((tc), (scm_t_bits)(data))
|
|
|
|
|
|
#define SCM_RETURN_NEWSMOB(tc, data) \
|
|
|
|
|
|
return scm_new_smob ((tc), (scm_t_bits)(data))
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_NEWSMOB2(z, tc, data1, data2) \
|
|
|
|
|
|
z = scm_new_double_smob ((tc), (scm_t_bits)(data1), \
|
|
|
|
|
|
(scm_t_bits)(data2), 0)
|
|
|
|
|
|
#define SCM_RETURN_NEWSMOB2(tc, data1, data2) \
|
|
|
|
|
|
return scm_new_double_smob ((tc), (scm_t_bits)(data1), \
|
|
|
|
|
|
(scm_t_bits)(data2), 0)
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_NEWSMOB3(z, tc, data1, data2, data3) \
|
|
|
|
|
|
z = scm_new_double_smob ((tc), (scm_t_bits)(data1), \
|
|
|
|
|
|
(scm_t_bits)(data2), (scm_t_bits)(data3))
|
|
|
|
|
|
#define SCM_RETURN_NEWSMOB3(tc, data1, data2, data3) \
|
|
|
|
|
|
return scm_new_double_smob ((tc), (scm_t_bits)(data1), \
|
|
|
|
|
|
(scm_t_bits)(data2), (scm_t_bits)(data3))
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-05-23 09:57:31 +00:00
|
|
|
|
|
2009-12-08 22:14:26 +01:00
|
|
|
|
#define SCM_SMOB_DATA_N(x, n) (SCM_CELL_WORD ((x), (n)))
|
|
|
|
|
|
#define SCM_SET_SMOB_DATA_N(x, n, data) (SCM_SET_CELL_WORD ((x), (n), (data)))
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_SMOB_DATA_0(x) (SCM_SMOB_DATA_N ((x), 0))
|
|
|
|
|
|
#define SCM_SMOB_DATA_1(x) (SCM_SMOB_DATA_N ((x), 1))
|
|
|
|
|
|
#define SCM_SMOB_DATA_2(x) (SCM_SMOB_DATA_N ((x), 2))
|
|
|
|
|
|
#define SCM_SMOB_DATA_3(x) (SCM_SMOB_DATA_N ((x), 3))
|
|
|
|
|
|
#define SCM_SET_SMOB_DATA_0(x, data) (SCM_SET_SMOB_DATA_N ((x), 0, (data)))
|
|
|
|
|
|
#define SCM_SET_SMOB_DATA_1(x, data) (SCM_SET_SMOB_DATA_N ((x), 1, (data)))
|
|
|
|
|
|
#define SCM_SET_SMOB_DATA_2(x, data) (SCM_SET_SMOB_DATA_N ((x), 2, (data)))
|
|
|
|
|
|
#define SCM_SET_SMOB_DATA_3(x, data) (SCM_SET_SMOB_DATA_N ((x), 3, (data)))
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_SMOB_FLAGS(x) (SCM_SMOB_DATA_0 (x) >> 16)
|
|
|
|
|
|
#define SCM_SMOB_DATA(x) (SCM_SMOB_DATA_1 (x))
|
|
|
|
|
|
#define SCM_SET_SMOB_FLAGS(x, data) (SCM_SET_SMOB_DATA_0 ((x), (SCM_CELL_TYPE (x)&0xffff)|((data)<<16)))
|
|
|
|
|
|
#define SCM_SET_SMOB_DATA(x, data) (SCM_SET_SMOB_DATA_1 ((x), (data)))
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_N(x,n) (SCM_CELL_OBJECT ((x), (n)))
|
|
|
|
|
|
#define SCM_SET_SMOB_OBJECT_N(x,n,obj) (SCM_SET_CELL_OBJECT ((x), (n), (obj)))
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_N_LOC(x,n) (SCM_CELL_OBJECT_LOC ((x), (n)))
|
|
|
|
|
|
|
|
|
|
|
|
/*#define SCM_SMOB_OBJECT_0(x) (SCM_SMOB_OBJECT_N ((x), 0))*/
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_1(x) (SCM_SMOB_OBJECT_N ((x), 1))
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_2(x) (SCM_SMOB_OBJECT_N ((x), 2))
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_3(x) (SCM_SMOB_OBJECT_N ((x), 3))
|
|
|
|
|
|
/*#define SCM_SET_SMOB_OBJECT_0(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 0, (obj)))*/
|
|
|
|
|
|
#define SCM_SET_SMOB_OBJECT_1(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 1, (obj)))
|
|
|
|
|
|
#define SCM_SET_SMOB_OBJECT_2(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 2, (obj)))
|
|
|
|
|
|
#define SCM_SET_SMOB_OBJECT_3(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 3, (obj)))
|
2014-09-20 05:17:54 -04:00
|
|
|
|
#define SCM_SMOB_OBJECT_0_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 0))
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_1_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 1))
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_2_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 2))
|
|
|
|
|
|
#define SCM_SMOB_OBJECT_3_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 3))
|
2009-12-08 22:14:26 +01:00
|
|
|
|
|
|
|
|
|
|
#define SCM_SMOB_OBJECT(x) (SCM_SMOB_OBJECT_1 (x))
|
|
|
|
|
|
#define SCM_SET_SMOB_OBJECT(x,obj) (SCM_SET_SMOB_OBJECT_1 ((x), (obj)))
|
2014-09-20 05:17:54 -04:00
|
|
|
|
#define SCM_SMOB_OBJECT_LOC(x) (SCM_SMOB_OBJECT_1_LOC (x))
|
2009-12-08 22:14:26 +01:00
|
|
|
|
|
* smob.h (SCM_SMOB_DATA_2, SCM_SMOB_DATA_3, SCM_SMOB_FLAGS,
SCM_SET_SMOB_DATA_2, SCM_SET_SMOB_DATA_3, SCM_SET_SMOB_FLAGS,
SCM_SMOB_OBJECT, SCM_SMOB_OBJECT_2, SCM_SMOB_OBJECT_3,
SCM_SET_SMOB_OBJECT, SCM_SET_SMOB_OBJECT_2, SCM_SET_SMOB_OBJECT_3,
SCM_SMOB_OBJECT_LOC, SCM_SMOB_OBJECT_2_LOC,
SCM_SMOB_OBJECT_3_LOC): New.
* smob.c (scm_i_set_smob_flags): New function.
2004-05-06 16:41:27 +00:00
|
|
|
|
|
smobs are applied with vm trampoline procedures
* libguile/smob.c: Instead of having special evaluator support for
applying smobs, we use the same strategy that gsubr uses, that smob
application should happen via a trampoline VM procedure, which uses a
special opcode (smob-apply). So statically allocate all of the desired
trampoline procedures here.
(scm_i_smob_apply_trampoline): Unfortunately there's no real place to
put the trampoline, so instead use a weak-key hash. It's nasty, but I
think the benefits of speeding up procedure calls in the general case
are worth it.
* libguile/smob.h (scm_smob_descriptor): Remove fields apply_0, apply_1,
apply_2, and apply_3; these were never public. Also remove the
gsubr_type field. Instead cache the trampoline objcode here.
(SCM_SMOB_APPLY_0, SCM_SMOB_APPLY_1, SCM_SMOB_APPLY_2,
SCM_SMOB_APPLY_3): Just go through scm_call_0, etc here.
* libguile/vm-i-system.c (call, tail-call, mv-call): Simplify. All
procedure calls are VM calls now.
(smob-call): New instruction, used in smob trampoline procedures.
* libguile/vm.c (apply_foreign): Remove. Yay!
* libguile/procprop.c (scm_i_procedure_arity): Refactor a bit for the
smob changes.
2010-01-09 14:12:47 +01:00
|
|
|
|
#define SCM_SMOB_APPLY_0(x) (scm_call_0 (x))
|
|
|
|
|
|
#define SCM_SMOB_APPLY_1(x, a1) (scm_call_1 (x, a1))
|
|
|
|
|
|
#define SCM_SMOB_APPLY_2(x, a1, a2) (scm_call_2 (x, a1, a2))
|
|
|
|
|
|
#define SCM_SMOB_APPLY_3(x, a1, a2, rst) (scm_call_3 (x, a1, a2, a3))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_mark0 (SCM ptr);
|
|
|
|
|
|
SCM_API SCM scm_markcdr (SCM ptr);
|
|
|
|
|
|
SCM_API size_t scm_free0 (SCM ptr);
|
|
|
|
|
|
SCM_API int scm_smob_print (SCM exp, SCM port, scm_print_state *pstate);
|
1999-07-07 09:44:01 +00:00
|
|
|
|
|
2000-06-20 02:37:53 +00:00
|
|
|
|
/* The following set of functions is the standard way to create new
|
|
|
|
|
|
* SMOB types.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Create a type tag using `scm_make_smob_type', accept default values
|
|
|
|
|
|
* for mark, free, print and/or equalp functions, or set your own
|
|
|
|
|
|
* values using `scm_set_smob_xxx'.
|
|
|
|
|
|
*/
|
1999-07-07 09:44:01 +00:00
|
|
|
|
|
2003-10-07 22:03:26 +00:00
|
|
|
|
SCM_API scm_t_bits scm_make_smob_type (char const *name, size_t size);
|
1999-07-07 09:44:01 +00:00
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API void scm_set_smob_mark (scm_t_bits tc, SCM (*mark) (SCM));
|
|
|
|
|
|
SCM_API void scm_set_smob_free (scm_t_bits tc, size_t (*free) (SCM));
|
|
|
|
|
|
SCM_API void scm_set_smob_print (scm_t_bits tc,
|
|
|
|
|
|
int (*print) (SCM, SCM, scm_print_state*));
|
|
|
|
|
|
SCM_API void scm_set_smob_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM));
|
|
|
|
|
|
SCM_API void scm_set_smob_apply (scm_t_bits tc,
|
2011-02-13 14:50:05 +01:00
|
|
|
|
scm_t_subr apply,
|
2001-11-02 00:19:12 +00:00
|
|
|
|
unsigned int req,
|
|
|
|
|
|
unsigned int opt,
|
|
|
|
|
|
unsigned int rst);
|
2000-06-20 02:37:53 +00:00
|
|
|
|
|
2015-02-10 14:35:35 +01:00
|
|
|
|
SCM_API SCM scm_smob_type_class (scm_t_bits tc);
|
|
|
|
|
|
|
2004-09-24 01:46:09 +00:00
|
|
|
|
SCM_API void scm_assert_smob_type (scm_t_bits tag, SCM val);
|
|
|
|
|
|
|
2000-12-07 12:04:48 +00:00
|
|
|
|
/* Function for creating smobs */
|
2000-06-20 02:37:53 +00:00
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_make_smob (scm_t_bits tc);
|
2004-09-24 01:46:09 +00:00
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API void scm_smob_prehistory (void);
|
2000-12-07 12:04:48 +00:00
|
|
|
|
|
2001-04-21 21:50:08 +00:00
|
|
|
|
#endif /* SCM_SMOB_H */
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|