diff options
author | Andy Wingo <wingo@pobox.com> | 2017-09-08 10:44:54 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2017-09-14 09:44:30 +0200 |
commit | 48989599016c218da68899aee2af8264df98e34c (patch) | |
tree | d5b934930b72eb54e1395414837d2ac8a2f1460e /libguile/struct.h | |
parent | 5c8bb1363032eb5797fbd232dec162350304a768 (diff) | |
download | guile-48989599016c218da68899aee2af8264df98e34c.tar.gz |
Implement class redefinition on top of fixed structs
* libguile/struct.h: Steal another flag for GOOPS.
* libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_INDIRECT)
(SCM_VTABLE_FLAG_GOOPS_NEEDS_MIGRATION): New flags.
(SCM_CLASSF_GOOPS_VALID, SCM_CLASSF_GOOPS_OR_VALID): Remove obsolete
definitions.
(SCM_IS_A_P): Use the scm_class_of function.
* libguile/goops.c (var_class_of_obsolete_indirect_instance): Rename
from var_migrate_instance.
(scm_is_generic, scm_is_method, scm_sys_init_layout_x): Use
scm_class_of instead of the SCM_CLASS_OF macro.
(get_indirect_slots): New helper.
(scm_class_of): This patch moves us in a direction where we won't be
able to separately address a struct's data and its identity.
Therefore to check whether a class needs migration, we check an
embedded pointer from a slot instead of the vtable data.
(scm_sys_struct_data): Remove this temporary function.
(scm_sys_modify_instance): Update to swap slot values instead of the
data pointers themselves.
(scm_sys_modify_class): Use scm_sys_modify_instance.
(scm_sys_goops_loaded): Capture class-of-obsolete-indirect-instance
instead of migrate-instance.
(scm_init_goops_builtins): Don't export the "valid" flag any more;
export instead the "indirect" and "needs-migration" flags.
* libguile/foreign-object.c (scm_assert_foreign_object_type): Add a
FIXME.
* libguile/vm-engine.c (class-of): Take away fast path for the time
being.
* module/oop/goops.scm (class-has-indirect-instances?)
(indirect-slots-need-migration?): New helpers.
(<class>, <slot>, %class-slot-definition, initialize): Remove use of
vtable-flag-goops-valid.
(define-class): Always push redefined values through
`class-redefinition'.
(<redefinable-class>): New public definition. Use it as a metaclass
for redefinable classes. Provide a compute-slots function that
declares the indirect slots mechanism. Add the "indirect" flag to
instances of <redefinable-class>. Create indirect-slots objects for
instances of those classes as part of their allocate-instance.
(change-object-class, class-of-obsolete-indirect-instance): Update for
new representation change.
* test-suite/tests/goops.test ("object update"): Add #:metaclass
<redefinable-class> to all redefinable classes. For the "hell" test,
make the new classes with class-direct-slots, not class-slots; this
was an error in the test.
Diffstat (limited to 'libguile/struct.h')
-rw-r--r-- | libguile/struct.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libguile/struct.h b/libguile/struct.h index e8db316c8..e7007b7e0 100644 --- a/libguile/struct.h +++ b/libguile/struct.h @@ -112,12 +112,12 @@ #define SCM_VTABLE_FLAG_SIMPLE_RW (1L << 7) /* instances of this vtable have only "pw" fields and no tail array */ #define SCM_VTABLE_FLAG_RESERVED_0 (1L << 8) #define SCM_VTABLE_FLAG_RESERVED_1 (1L << 9) -#define SCM_VTABLE_FLAG_RESERVED_2 (1L << 10) -#define SCM_VTABLE_FLAG_SMOB_0 (1L << 11) -#define SCM_VTABLE_FLAG_GOOPS_0 (1L << 12) -#define SCM_VTABLE_FLAG_GOOPS_1 (1L << 13) -#define SCM_VTABLE_FLAG_GOOPS_2 (1L << 14) -#define SCM_VTABLE_FLAG_GOOPS_3 (1L << 15) +#define SCM_VTABLE_FLAG_SMOB_0 (1L << 10) +#define SCM_VTABLE_FLAG_GOOPS_0 (1L << 11) +#define SCM_VTABLE_FLAG_GOOPS_1 (1L << 12) +#define SCM_VTABLE_FLAG_GOOPS_2 (1L << 13) +#define SCM_VTABLE_FLAG_GOOPS_3 (1L << 14) +#define SCM_VTABLE_FLAG_GOOPS_4 (1L << 15) #define SCM_VTABLE_USER_FLAG_SHIFT 16 typedef void (*scm_t_struct_finalize) (SCM obj); |