As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.' It does take up
space though! For that reason, we remove it here from our C files.
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT, scm_vtable_index_self):
Remove "self" field. Renumber the other fields.
* module/oop/goops.scm (<self-slot>): Remove.
(fold-class-slots): Adapt for "self" slot removal. Adapt all users.
(class-redefinition): Now that there is no "self" slot to update, use
%modify-instance instead of %modify-class.
* libguile/goops.c (class_self): Remove.
(scm_sys_modify_class): Remove.
* libguile/goops.h (scm_sys_modify_class): Remove.
* module/rnrs/records/procedural.scm: Import vtable-offset-user.
Renumber rtd indexes using vtable-offset-user.
* module/srfi/srfi-35.scm (%condition-type-vtable): Remove mention of
vtable fields.
* module/system/base/types.scm (address->inferior-struct): Adapt for
different vtable field layout.
* 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.
* libguile/goops.c (scm_class_of): Call out directly to the GOOPS-local
`migrate-instance' if an instance needs to migrate.
(scm_sys_struct_data): New internal temporary function used by the
Scheme `migrate-instance'. Exorcise the evil one from the old C
implementation.
* libguile/goops.h (scm_change_object_class): Remove function used only
internally in GOOPS.
* module/oop/goops.scm (migrate-instance): Implement the
hell/purgatory/etc logic in Scheme instead of C.
This removes a limitation on the number of port types, simplifies the
API, and removes a central point of coordination.
* libguile/ports-internal.h (struct scm_t_port_type): Rename from
scm_t_ptob_descriptor, now that it's private. Add GOOPS class
fields.
(struct scm_t_port): Rename from struct scm_port, especially
considering that deprecated.h redefines scm_port using the
preprocessor :(.
* libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE,
though the scm_t_port and scm_t_port_type types are incomplete.
(SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no
more typecodes for port types.
(scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x):
Remove.
(scm_make_port_type): Return a scm_t_port_type*. All methods adapted
to take a scm_t_port_type* instead of a ptobnum.
(scm_c_make_port_with_encoding, scm_c_make_port): Take a port type
pointer instead of a tag.
(scm_new_port_table_entry): Remove; not useful.
* libguile/ports.c: Remove things related to the port kind table. Adapt
uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use
SCM_PORT_TYPE and scm_t_port_type.
* libguile/deprecated.c:
* libguile/deprecated.h:
* libguile/filesys.c:
* libguile/fports.c:
* libguile/fports.h:
* libguile/print.c:
* libguile/r6rs-ports.c:
* libguile/strports.c:
* libguile/strports.h:
* libguile/tags.h:
* libguile/vports.c:
* test-suite/standalone/test-scm-c-read.c: Adapt to change.
* libguile/goops.c (scm_class_of, make_port_classes)
(scm_make_port_classes, create_port_classes): Adapt to store the
classes in the ptob.
* libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_STATIC): Reserve the fourth
GOOPS flag to indicate that a class has static slot allocation.
* libguile/goops.c (scm_init_goops_builtins): Define
vtable-flag-goops-static for goops.scm.
* module/oop/goops.scm (class-has-statically-allocated-slots?): New
helper.
(build-slots-list): Instead of the ad-hoc checks for <class> or
<slot>, use the new helper.
(initialize): Accept #:static-slot-allocation? keyword.
* module/system/foreign-object.scm (make-foreign-object-type): Declare
foreign object classes as having static slot allocation.
* test-suite/tests/goops.test ("static slot allocation"): Add tests.
* libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_SLOT): Allocate another vtable
flag to indicate that instances of this vtable are slots.
* libguile/goops.c (scm_init_goops_builtins): Export
vtable-flag-goops-slot to Scheme.
* module/oop/goops.scm (<slot>, slot?, make-standard-class, initialize):
Arrange for <slot> classes to have the vtable-flag-goops.slot.
(build-slots-list): Ensure that <slot> slots are statically laid out.
* libguile/deprecated.h:
* libguile/goops.c:
* libguile/goops.h:
* libguile/deprecated.c (scm_slot_ref_using_class):
(scm_slot_set_using_class_x):
(scm_slot_bound_using_class_p):
(scm_slot_exists_using_class_p): Deprecate.
* module/oop/goops.scm (slot-ref-using-class, slot-set-using-class!)
(slot-bound-using-class?, slot-exists-using-class?): Deprecate.
Change to check that `class' is indeed the class of `obj', as
required, and then dispatch to slot-ref et al.
* libguile/goops.h: Remove unimplemented declarations of
scm_make_next_method, scm_sys_invalidate_method_cache_x, and
stklos_version.
(scm_sys_invalidate_class_x): Remove helper definition. This was
exported in the past but shouldn't have been.
* libguile/goops.c (scm_sys_make_vtable_vtable): Rename from
scm_sys_make_root_class, and don't do anything about flags.
(scm_sys_bless_applicable_struct_vtables_x, scm_class_p)
(scm_sys_invalidate_class_x): Remove; we do these in Scheme now.
(scm_init_goops_builtins): Define Scheme values for vtable flags.
* module/oop/goops.scm (vtable-flag-goops-metaclass)
(class-add-flags!, class-clear-flags!, class-has-flags?)
(class?, instance?): New definitions.
(<class>): Add GOOPS metaclass flags from Scheme.
(<applicable-struct-class>, <applicable-struct-with-setter-class>):
Add flags from Scheme.
(make, initialize): Add class flags as appropriate.
(class-redefinition): Clear the "valid" flag on the old class.
(check-slot-args): Use instance? instead of a CPL check.
* libguile/goops.c (scm_class_of): Access "redefined" slot by name in
the case where we need to change the class of an instance.
(scm_sys_goops_early_init): Move up capture of class-precedence-list
so SCM_SUBCLASSP can use it.
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, scm_si_redefined)
(scm_si_direct_supers, scm_si_direct_slots, scm_si_direct_subclasses)
(scm_si_direct_methods, scm_si_cpl scm_si_slots)
(scm_si_getters_n_setters, SCM_N_CLASS_SLOTS, SCM_OBJ_CLASS_REDEF):
Remove. Now C code has no special knowledge about the layout of
GOOPS classes.
(SCM_SUBCLASSP): Use scm_class_precedence_list to get CPL.
(SCM_INST, SCM_ACCESSORS_OF): Remove unused macros that were
undocumented and nonsensical.
* libguile/goops.c (scm_sys_clear_fields_x): New function.
(scm_sys_allocate_instance): Remove. It was available to C but not to
Scheme and it's really internal.
* libguile/goops.h: Remove scm_sys_allocate_instance.
* module/oop/goops.scm (%allocate-instance): Implement in Scheme, using
allocate-struct and %clear-fields!.
(make, shallow-clone, deep-clone, allocate-instance): Adapt to
%allocate-instance not taking an initargs argument.
* module/oop/goops.scm (fold-<class>-slots): The first "reserved" slot
is actually for instance sizes, used by the "simple struct"
mechanism. Reuse this field for GOOPS's "nfields".
(make-standard-class, <class>, initialize): Adapt order of field
initializations.
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, SCM_N_CLASS_SLOTS)
* libguile/goops.c (scm_sys_allocate_instance): Adapt.
* libguile/goops.h:
* libguile/goops.c (scm_sys_initialize_object): Remove C interface.
This function was only really useful as part of a GOOPS initialize
method but was not exported from the goops module.
* module/oop/goops.scm (get-keyword, %initialize-object): Implement in
Scheme.
* libguile/goops.h (scm_c_extend_primitive_generic): Remove public
interface. This was introduced in 2003 with the "extended" generics
but never documented, unused as far as I can tell, and is better
accessed from Scheme.
* libguile/goops.c: Remove support for scm_c_extend_primitive_generic.
Simplify capture of change-class.
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, SCM_INSTANCE_HASH)
(SCM_SET_HASHSET):
* libguile/goops.c (prep_hashsets, scm_sys_make_root_class,
scm_sys_init_layout_x):
* module/oop/goops.scm (build-<class>-slots): Remove hashsets from
classes. We haven't implemented hashed dispatch since Guile 1.8, and
it's not clear that the particular formulation of dispatch is a good
idea.
* libguile/goops.c (scm_sys_set_object_setter_x): Remove. Instead, we
use slot-set! of 'setter.
(scm_i_define_class_for_vtable): Move lower in the file, and fold in
scm_make_extended_class_from_symbol and make_class_from_symbol.
Properly handle applicable structs with setters.
(scm_class_applicable_struct_with_setter_class): New private capture.
(scm_sys_bless_applicable_struct_vtables_x): Rename to take two
arguments, and bless the second argument as an applicable struct with
setter vtable.
(scm_sys_goops_early_init): Capture setter classes.
* libguile/deprecated.c (SPEC_OF, CPL_OF): Access slots by name, not by
index.
(applicablep, more_specificp): Adapt to use CPL_OF.
(scm_find_method): Access "methods" slot by name.
* libguile/procs.c (scm_setter): Remove special case for generics; if
it's a setter, it will be a normal applicable struct.
* module/oop/goops.scm (<applicable-struct-with-setter-class>)
(<applicable-struct-with-setter>): New classes.
(<generic-with-setter>): Now an instance of the setter metaclass and a
child of the setter class, so that the "setter" slot ends up in the
right place.
(<accessor>, <extended-generic-with-setter>, <extended-accessor>): Be
instances of the setter metaclass.
(<method>, <accessor-method>): Move definitions farther down.
(make): Use slot-set! when initializing setters here.
(initialize): Likewise for <applicable-struct-with-setter>. Remove
specialization for <generic-with-setter>.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_basic_make_class): Deprecate.
* libguile/goops.c:
* libguile/goops.h (scm_make_standard_class): New internal helper. It's
a better spelling, as it matches make-standard-class, and is internal
so as not to cause confusion between boot GOOPS helpers and "real"
GOOPS interfaces.
* module/oop/goops.scm (build-<class>-slots): New helper, replacing
build_class_class_slots.
(build-slots-list, %compute-getters-n-setters, %compute-layout): New
private helpers, moved here from C.
(%prep-layout!): Reimplement in Scheme.
(make-standard-class): New private helper, replacing
scm_basic_make_class.
(<class>, <top>, <object>): Define in Scheme.
(<foreign-slot>, <protected-slot>, <hidden-slot>, <opaque-slot>,
<read-only-slot>, <self-slot>, <protected-opaque-slot>,
<protected-hidden-slot>, <protected-read-only-slot>, <scm-slot>,
<int-slot>, <float-slot>, <double-slot>, <procedure-class>,
<applicable-struct-class>, <method>, <accessor-method>, <applicable>,
<applicable-struct>, <generic>, <extended-generic>,
<generic-with-setter>, <accessor>, <extended-generic-with-setter>,
<extended-accessor>): Define in Scheme.
(<boolean>, <char>, <list>, <pair>, <null>, <string>, <symbol>,
<vector>, <foreign>, <hashtable>, <fluid>, <dynamic-state>, <frame>,
<vm-continuation>, <bytevector>, <uvec>, <array>, <bitvector>,
<number>, <complex>, <real>, <integer>, <fraction>, <keyword>,
<unknown>, <procedure>, <primitive-generic>, <port>, <input-port>,
<output-port>, <input-output-port>): Define in Scheme.
(compute-slots): Use build-slots-list helper.
* libguile/goops.h:
* libguile/goops.c (scm_basic_basic_make_class, scm_sys_compute_slots)
(scm_sys_prep_layout_x): Remove. These were available to C, but were
undocumented internals that were dangerous, confusing, and
unnecessary.
* libguile/goops.c: Add note about variable versus value references.
Remove internal C routines that were just used during boot, as they
have been moved to Scheme.
(scm_basic_make_class): Change to call out to make-standard-class in
Scheme.
(scm_sys_make_root_class, scm_sys_bless_applicable_struct_vtable_x)
(scm_sys_bless_pure_generic_vtable_x, scm_sys_init_layout_x): New
private helpers.
(scm_sys_goops_early_init): Change to capture values defined in
Scheme.
* libguile/goops.h:
* libguile/goops.c (scm_sys_fast_slot_ref, scm_sys_fast_slot_set_x):
Remove these unused, unsafe functions. They were publically available
only to C.
* module/oop/goops/active-slot.scm (compute-get-n-set): Update to use
struct-ref / struct-set! instead of %fast-slot-ref / %fast-slot-set!
from (oop goops internal).
* libguile/goops.h:
* libguile/goops.c (scm_init_goops, scm_init_goops_builtins): Move
%init-goops-builtins to be an extension instead of a globally
accessible function.
* module/oop/goops.scm: Adapt.
* libguile/goops.h:
* libguile/goops.c (more_specificp, scm_sys_method_more_specific_p):
* module/oop/goops.scm (%method-more-specific?): Rewrite in Scheme. We
remove the scm_sys_method_more_specific_p interface as it is a private
interface and it's not extensible.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_compute_applicable_methods): Deprecate.
This was the boot version of compute-applicable-methods, not the full
version; the right thing to do is to call scheme.
(scm_find_method): Deprecate. Again, the right thing is to do this on
the Scheme level.
* libguile/goops.c:
* libguile/goops.h: Deprecated code moved to deprecated.[ch].
* libguile/goops.c: Move %compute-applicable-methods to Scheme.
(scm_sys_goops_loaded): No need to initialize
var_compute_applicable_methods.
* libguile/goops.h (scm_sys_compute_applicable_methods): Remove. This
was internal so it shouldn't cause a problem.
* module/oop/goops.scm (%sort-applicable-methods):
(%compute-applicable-methods): New definitions.
* libguile/__scm.h: Move all the SCM_WTA and SCM_GASSERT macros out of
here. Also remove the scm_call_generic declarations.
* libguile/deprecated.h (SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1):
(SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_N): Deprecate. See below for
their replacements.
(SCM_GASSERT0, SCM_GASSERT1, SCM_GASSERT2, SCM_GASSERTn): Deprecate
these too.
(SCM_WTA_DISPATCH_1_SUBR): Deprecate this strange thing.
(scm_call_generic_0, scm_call_generic_1, scm_call_generic_2):
(scm_call_generic_3, scm_apply_generic): Remove, indicating their
replacements.
* libguile/print.c (iprin1):
* libguile/eq.c (scm_equal_p): Use scm_call_2 instead of
scm_call_generic_2.
* libguile/goops.h:
* libguile/goops.c: Remove scm_{call,apply}_generic definitions.
(scm_wta_dispatch_0, scm_wta_dispatch_1, scm_wta_dispatch_2):
(scm_wta_dispatch_n): New procedures, replacing the SCM_WTA macros.
* libguile/numbers.c (scm_lcm):
* libguile/procs.c (scm_setter): Remove uses of SCM_GASSERT.
* libguile/numbers.c (scm_lcm):
* libguile/procs.c (scm_setter):
* libguile/vectors.c: Use the procedural scm_wta routines instead of the
SCM_WTA macros.
* libguile/goops.h:
* libguile/goops.c (scm_i_define_class_for_vtable): New internal helper,
defines a class for a vtable, relying on the name slot being set
correctly.
(scm_class_of, create_struct_classes): Use the local vtable-to-class
map instead of scm_struct_table.
* libguile/struct.h (SCM_STRUCT_TABLE_NAME, SCM_SET_STRUCT_TABLE_NAME)
(SCM_STRUCT_TABLE_CLASS, SCM_SET_STRUCT_TABLE_CLASS, scm_struct_table)
(scm_struct_create_handle): Deprecate these internals of the map
between structs and classes.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_struct_create_handle): Deprecated code over
here now.
* libguile/goops.h:
* libguile/goops.c (scm_add_method): Remove this function. It didn't
work, and even if we fixed it to work it wouldn't be as good as using
Scheme's `add-method!'.
If you're wondering what I'm doing, I'm trying to eventually reimplement
smobs in terms of structs, so that applicable smobs can just follow the
applicable struct dispatch path. But to do that I have to get structs
initialized before things that use smobs, which means transforming a
bunch of smobby things to tc7 things. But this transformation is good
for performance anyway, and we currently have a glut of unused tc7s,
so here we go...
* libguile/tags.h (scm_tc7_fluid, scm_tc7_dynamic_state): Fluids (and
dynamic states) now have tc7s.
* libguile/fluids.h: Remove scm_fluids_prehistory, and add internal
scm_i_fluid_print. Update a comment.
* libguile/fluids.c: Update for tc7 representation. Also remove the next
pointers while we're at it, as they aren't used in the new BDW GC.
* libguile/eq.c (scm_equal_p): Remove the hashtable case. Hashtables
could never be equal? before, I don't see why to add stubs doing the
same thing now.
* libguile/print.c (iprin1):
* libguile/gc.c (scm_i_tag_name):
* libguile/evalext.c (scm_self_evaluating_p): Add fluid and
dynamic_state cases.
* libguile/goops.h: Remove scm_class_hashtable; it will be static.
* libguile/goops.c: Make <hashtable> static, and add <fluid> and
<dynamic-state> classes.
* libguile/hashtab.h:
* libguile/hashtab.c: Remove scm_i_hashtable_equal_p.
* libguile/init.c (scm_i_init_guile): Remove call to fluids_prehistory.