diff options
author | Andy Wingo <wingo@pobox.com> | 2009-11-03 23:59:51 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-11-26 00:24:58 +0100 |
commit | b6cf4d026506b8e5042671f7503d4d9e9a810d49 (patch) | |
tree | 23fc026ced45b0ae756c4d0de111e9521711c7a8 /libguile/procs.c | |
parent | 9bd48cb17b4ce685f94f974442d452485a1017d6 (diff) | |
download | guile-b6cf4d026506b8e5042671f7503d4d9e9a810d49.tar.gz |
a very big commit cleaning up structs & goops. also applicable structs.
I tried to split this one, and I know it's a bit disruptive, but this
stuff really is one big cobweb. So instead we'll pretend like these are
separate commits, by separating the changelog.
Applicable struct runtime support.
* libguile/debug.c (scm_procedure_source):
* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
(scm_trampoline_2):
* libguile/eval.i.c (CEVAL):
* libguile/goops.c (scm_class_of):
* libguile/procprop.c (scm_i_procedure_arity):
* libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow
for applicable structs. Whee!
* libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym
for scm_vtable_index_self.
(scm_vtable_index_printer): Alias scm_vtable_index_instance_printer.
(scm_struct_i_free): Alias scm_vtable_index_instance_finalize.
(scm_struct_i_flags): Alias scm_vtable_index_flags.
(SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now.
(SCM_SET_VTABLE_DESTRUCTOR): Implement by hand.
Hidden slots.
* libguile/struct.c (scm_make_struct_layout): Add support for "hidden"
fields, writable fields that are not visible to make-struct. This
allows us to add fields to vtables and not break existing make-struct
invocations.
(scm_struct_ref, scm_struct_set_x): Always get struct length from the
vtable. Support hidden fields.
* libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New
slot classes, to correspond to the new vtable slots.
(scm_sys_prep_layout_x): Turn hidden slots into 'h'.
(build_class_class_slots): Reorder the class slots to account for
vtable fields coming out of negative-land, for name as a vtable slot,
and for hidden fields.
(create_standard_classes): Define <hidden-slot> and
<protected-hidden-slot>.
Clean up struct.h.
* libguile/struct.h: Lay things out cleaner. There are no more hidden
(negative) words. Names are nicer. The exposition is nicer. But the
basics are the same. The incompatibilities are that <vtable> has more
slots now, and that scm_alloc_struct's signature has changed. The
former is ameliorated by the "hidden" slots mentioned before, and the
latter, well, it was always a very internal thing...
(scm_t_struct_finalize): New type, a finalizer function to be run when
instances of a vtable are collected.
(scm_t_struct_free): Removed, structs' data is managed by the GC now,
and not freed by vtable functions.
* libguile/struct.c: (scm_vtable_p): Now we keep flags on
vtable-vtables, so this check is cheaper.
(scm_alloc_struct): No hidden words. Yippee.
(struct_finalizer_trampoline): Entersify.
(scm_make_struct): No need to babysit extra words, though now we have
to babysit flags. Propagate the vtable, applicable, and setter flags
appropriately.
(scm_make_vtable_vtable): Update for new simplicity.
(scm_print_struct): A better printer.
(scm_init_struct): Define <applicable-struct-vtable>, a magical vtable
like CL's funcallable-standard-class. Also define
<applicable-struct-with-setter-vtable>.
Remove foreign object implementation.
* libguile/goops.h:
* libguile/goops.c (scm_make_foreign_object, scm_make_class)
(scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these
were undocumented and unworking.
Clean up goops.h, a little.
* libguile/goops.h:
* libguile/goops.c: Also clean up.
* module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset
index.
Diffstat (limited to 'libguile/procs.c')
-rw-r--r-- | libguile/procs.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libguile/procs.c b/libguile/procs.c index df6251404..dc4375554 100644 --- a/libguile/procs.c +++ b/libguile/procs.c @@ -97,7 +97,8 @@ SCM_DEFINE (scm_procedure_p, "procedure?", 1, 0, 0, switch (SCM_TYP7 (obj)) { case scm_tcs_struct: - if (!(SCM_OBJ_CLASS_FLAGS (obj) & SCM_CLASSF_PURE_GENERIC)) + if (!((SCM_OBJ_CLASS_FLAGS (obj) & SCM_CLASSF_PURE_GENERIC) + || SCM_STRUCT_APPLICABLE_P (obj))) break; case scm_tcs_closures: case scm_tcs_subrs: @@ -253,7 +254,7 @@ SCM_DEFINE (scm_make_procedure_with_setter, "make-procedure-with-setter", 2, 0, SCM_DEFINE (scm_procedure, "procedure", 1, 0, 0, (SCM proc), "Return the procedure of @var{proc}, which must be either a\n" - "procedure with setter, or an operator struct.") + "procedure with setter, or an applicable struct.") #define FUNC_NAME s_scm_procedure { SCM_VALIDATE_NIM (1, proc); @@ -261,7 +262,7 @@ SCM_DEFINE (scm_procedure, "procedure", 1, 0, 0, return SCM_PROCEDURE (proc); else if (SCM_STRUCTP (proc)) { - SCM_ASSERT (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC, + SCM_ASSERT (SCM_PUREGENERICP (proc) || SCM_STRUCT_APPLICABLE_P (proc), proc, SCM_ARG1, FUNC_NAME); return proc; } @@ -280,10 +281,11 @@ scm_setter (SCM proc) return SCM_SETTER (proc); else if (SCM_STRUCTP (proc)) { - SCM setter; - SCM_GASSERT1 (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC, - g_setter, proc, SCM_ARG1, s_setter); - setter = SCM_GENERIC_SETTER (proc); + SCM setter = SCM_BOOL_F; + if (SCM_PUREGENERICP (proc)) + setter = SCM_GENERIC_SETTER (proc); + else if (SCM_STRUCT_SETTER_P (proc)) + setter = SCM_STRUCT_SETTER (proc); if (SCM_NIMP (setter)) return setter; /* fall through */ |