1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

103 commits

Author SHA1 Message Date
Andy Wingo
cd51ce81d0 Use heap-allocated port types instead of ptobnums
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.
2016-05-13 18:31:29 +02:00
Andy Wingo
26350edcac Add #:static-slot-allocation?
* 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.
2015-02-06 13:25:17 +01:00
Andy Wingo
e437c50b88 Use a vtable bit to mark <slot> instances
* 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.
2015-01-23 16:16:03 +01:00
Andy Wingo
2bcb278a30 GOOPS: Deprecate "using-class" procs like slot-ref-using-class
* 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.
2015-01-23 16:16:03 +01:00
Andy Wingo
761338f60c Manipulate GOOPS vtable flags from Scheme, for speed
* 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.
2015-01-23 16:16:03 +01:00
Andy Wingo
60061fe0fe Incorporate %inherit-magic! into %init-layout!
* libguile/goops.c (scm_make_standard_class, scm_sys_init_layout_x):
  Move definitions up.  Incorporate scm_sys_inherit_magic_x into
  scm_sys_init_layout_x.

* libguile/goops.h: Remove scm_sys_init_layout_x declaration.
2015-01-23 16:16:02 +01:00
Andy Wingo
2025a02793 goops.c no longer knows about <class> slot allocation
* 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.
2015-01-23 16:16:02 +01:00
Andy Wingo
07452c83ae Reimplement %allocate-instance in Scheme
* 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.
2015-01-23 16:16:02 +01:00
Andy Wingo
92928b8619 Re-use the vtable "size" field for GOOPS nfields
* 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.
2015-01-23 16:16:02 +01:00
Andy Wingo
2b5812c64d Deprecate scm_get_keyword
* libguile/deprecated.c (scm_get_keyword): Deprecate.
* libguile/deprecated.h:
* libguile/goops.c:
* libguile/goops.h:
2015-01-23 16:16:01 +01:00
Andy Wingo
4a28ef1086 Rewrite %initialize-object in Scheme
* 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.
2015-01-23 16:16:01 +01:00
Andy Wingo
5a6165db6e Remove scm_c_extend_primitive_generic
* 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.
2015-01-23 16:16:01 +01:00
Andy Wingo
2b7692bcc4 No more concept of "pure generics"
* libguile/goops.h (SCM_PUREGENERICP, SCM_VALIDATE_PUREGENERIC)
  (SCM_VTABLE_FLAG_GOOPS_PURE_GENERIC, SCM_CLASSF_PURE_GENERIC):
  Remove.
* libguile/goops.c (scm_set_primitive_generic_x): Use SCM_GENERICP, not
  SCM_PUREGENERICP.
  (scm_sys_bless_pure_generic_vtable_x): Remove; this flag isn't
  checked.

* module/oop/goops.scm: Don't call %bless-pure-generic-vtable!; there's
  no need.
2015-01-23 16:16:01 +01:00
Andy Wingo
3292354a4d Remove pure-generic?
* libguile/goops.h:
* libguile/goops.c (scm_pure_generic_p): Remove function only compiled
  in debug mode.
2015-01-23 16:16:01 +01:00
Andy Wingo
e03e310126 Remove hashset slots from GOOPS classes
* 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.
2015-01-23 16:16:00 +01:00
Andy Wingo
57898597ad Deprecate C exports of GOOPS classes.
* libguile/deprecated.h:
  (scm_class_boolean, scm_class_char, scm_class_pair)
  (scm_class_procedure, scm_class_string, scm_class_symbol)
  (scm_class_primitive_generic, scm_class_vector, scm_class_null)
  (scm_class_real, scm_class_complex, scm_class_integer)
  (scm_class_fraction, scm_class_unknown, scm_class_top)
  (scm_class_object, scm_class_class, scm_class_applicable)
  (scm_class_applicable_struct, scm_class_applicable_struct_with_setter)
  (scm_class_generic, scm_class_generic_with_setter, scm_class_accessor)
  (scm_class_extended_generic, scm_class_extended_generic_with_setter)
  (scm_class_extended_accessor, scm_class_method)
  (scm_class_accessor_method, scm_class_procedure_class)
  (scm_class_applicable_struct_class, scm_class_number, scm_class_list)
  (scm_class_keyword, scm_class_port, scm_class_input_output_port)
  (scm_class_input_port, scm_class_output_port, scm_class_foreign_slot)
  (scm_class_self, scm_class_protected, scm_class_hidden)
  (scm_class_opaque, scm_class_read_only, scm_class_protected_hidden)
  (scm_class_protected_opaque, scm_class_protected_read_only)
  (scm_class_scm, scm_class_int, scm_class_float)
  (scm_class_double, scm_port_class, scm_smob_class): Deprecate.

* libguile/deprecated.c:
* libguile/goops.c:
* libguile/goops.h: Adapt to deprecation.

* libguile/goops.h
* libguile/goops.c (scm_is_generic, scm_is_method): New interfaces.
  (SCM_GENERICP, SCM_METHODP): Change to use new interfaces.

* libguile/ports.c (scm_make_port_type):
* libguile/smob.c (scm_make_smob_type, scm_set_smob_apply): Use internal
  names for the port and smob class arrays.
2015-01-23 16:16:00 +01:00
Andy Wingo
6c7dd9ebd3 Generics with setters have <applicable-struct-with-setter> layout
* 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>.
2015-01-23 16:16:00 +01:00
Andy Wingo
9e2cd55ec8 Remove unused CPP defines naming <method> slots
* libguile/goops.h (scm_si_generic_function, scm_si_specializers)
  (scm_si_procedure, scm_si_formals, scm_si_body)
  (scm_si_make_procedure): Remove unused CPP defines.
2015-01-23 16:16:00 +01:00
Andy Wingo
79f2aaab30 Remove unused `default-slot-definition-class' <class> slot
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, scm_si_slotdef_class)
* module/oop/goops.scm (build-<class>-slots): Remove unused
  `default-slot-definition-class' <class> slot.
2015-01-23 16:16:00 +01:00
Andy Wingo
005c078f27 Remove useless scm_s_slot_set_x export
* libguile/goops.c:
* libguile/goops.h (scm_s_slot_set_x): Remove unused and useless
  export.
2015-01-23 16:16:00 +01:00
Andy Wingo
623559f311 Deprecate scm_no_applicable_method C export
* libguile/deprecated.c (scm_init_deprecated_goops)
  (scm_no_applicable_method):
* libguile/goops.h:
* libguile/goops.c (scm_no_applicable_method)
  (scm_sys_goops_early_init): Deprecate scm_no_applicable_method C
  export.
2015-01-23 16:16:00 +01:00
Andy Wingo
07f6200116 Remove unused scm_t_method and SCM_METHOD
* libguile/goops.h (scm_t_method, SCM_METHOD): Remove unused struct
  type, typedef, and macro.
2015-01-23 16:16:00 +01:00
Andy Wingo
28b818d303 Deprecate scm_basic_make_class
* 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.
2015-01-23 16:16:00 +01:00
Andy Wingo
51fd1cd650 Move GOOPS boot to Scheme
* 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.
2015-01-23 16:16:00 +01:00
Andy Wingo
a91ea6a8a3 Remove declarations without definitions
* libguile/goops.h: Remove declarations for scm_oldfmt, scm_c_oldfmt0,
  and scm_c_oldfmt.  These symbols were not defined.
2015-01-23 16:16:00 +01:00
Andy Wingo
8906f23ded Remove unused %fast-slot-ref / %fast-slot-set! from GOOPS
* 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).
2015-01-23 16:16:00 +01:00
Andy Wingo
6ab1939653 %init-goops-builtins is an extension, not a global
* 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.
2015-01-23 16:15:59 +01:00
Andy Wingo
3a0d141233 Rewrite %method-more-specific? to be in Scheme
* 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.
2015-01-23 16:15:59 +01:00
Andy Wingo
e4aa440a2f Deprecate C interfaces scm_compute_applicable_methods, scm_find_method
* 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].
2015-01-23 16:15:59 +01:00
Andy Wingo
c0a56ec78d %compute-applicable-methods in Scheme
* 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.
2015-01-23 16:15:59 +01:00
Andy Wingo
686022e84e remove scm_si_name_access
* libguile/goops.h (scm_si_name_access): Remove alias for
  scm_si_getters_n_setters.
2011-11-24 11:47:36 +01:00
Andy Wingo
2575157e54 remove unused <class> slot: keyword-access
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, scm_si_keyword_access):
* libguile/goops.c (build_class_class_slots): Remove unused
  keyword-access slot from classes.
2011-11-24 11:47:36 +01:00
Andy Wingo
fa075d40dc scm_wta_* procedures replace SCM_WTA_* macros
* 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.
2011-05-15 15:34:16 +02:00
Andy Wingo
f3c6a02c88 deprecate scm_struct_table
* 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.
2011-05-01 23:01:14 +02:00
Andy Wingo
d5f9864ffc remove scm_add_method
* 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!'.
2009-12-20 15:34:19 +01:00
Andy Wingo
ea68d342f1 procedures-with-setters implemented in terms of structs
* libguile/tags.h (scm_tc7_pws): No more.

* libguile/procs.c (scm_procedure_with_setter_p)
  (scm_make_procedure_with_setter, scm_procedure, scm_setter): Implement
  procedures-with-setters in terms of applicable structs with setters.

* libguile/procs.h: Remove a big, outdated comment, and the deprecated
  macros.

* libguile/deprecated.h (SCM_PROCEDURE_WITH_SETTER_P, SCM_PROCEDURE)
  (SCM_SETTER): Deprecate these. SCM_PROCEDURE and SCM_SETTER are bad
  names.

* libguile/evalext.c (scm_self_evaluating_p):
* libguile/gc.c (scm_i_tag_name):
* libguile/goops.c: (scm_class_of):
* libguile/print.c (iprin1):
* libguile/procprop.c (scm_i_procedure_arity):
* libguile/procs.c (scm_procedure_p):
* libguile/debug.c (scm_procedure_source): Remove a tc7_pws case.

* libguile/goops.h:
* libguile/goops.c (scm_class_procedure_with_setter): Remove this class;
  it is subsumed by applicable_struct_with_setter.

* libguile/struct.h: Update a comment.

* libguile/vm-i-system.c (call, goto/args, mv-call): Remove PWS cases.
2009-12-07 09:56:58 +01:00
Andy Wingo
9ea31741da fluids are tc7 objects
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.
2009-12-05 10:52:18 +01:00
Andy Wingo
c99de5aa27 hash tables have a tc7
* libguile/tags.h (scm_tc7_hashtable): Allocate a tc7 for hashtables.

* libguile/hashtab.h: Adjust macros accordingly.
  (scm_i_hashtable_print, scm_i_hashtable_equal_p): New internal
  functions.
  (scm_hashtab_prehistory): Remove, no more need for this.

* libguile/hashtab.c (scm_hash_fn_remove_x): Fix a longstanding bug.
  (make_hash_table): Adapt to the new hash table representation.

* libguile/eq.c (scm_equal_p)
* libguile/evalext.c (scm_self_evaluating_p)
* libguile/print.c (iprin1)
* libguile/gc.c (scm_i_tag_name): Add some tc7_hashtab cases.

* libguile/init.c: Remove unused environments init functions. Remove
  call to hashtab_prehistory.

* libguile/goops.h (scm_class_hashtable)
* libguile/goops.c (scm_class_of, create_standard_classes): Have to
  make a class for hash tables manually, because they aren't smobs any
  more.
2009-12-05 10:07:07 +01:00
Andy Wingo
9d019f9be0 remove class-environment slot, goops grubs less in the evaluator
* libguile/goops.h (scm_sys_tag_body): Remove declaration of undefined
  function.
  (SCM_CLASS_CLASS_LAYOUT, scm_si_environment, SCM_N_CLASS_SLOTS)
  (scm_class_environment) Remove class environment slot and getter.

* libguile/goops.c (compute_getters_n_setters): Use scm_primitive_eval
  to produce the init thunk, instead of scm_i_eval_x; though really we
  should be doing this in Scheme.
  (scm_basic_basic_make_class, build_class_class_slots)
  (create_basic_classes, scm_class_environment): Remove class
  environment slot.
  (get_slot_value, set_slot_value): Use scm_call_1 instead of evaluator
  tricks.

* module/oop/goops.scm: Remove class-environment export, and
  environments throughout the file.
2009-12-01 21:00:25 +01:00
Andy Wingo
2858deaf47 header tidyings
* libguile/goops.h:
* libguile/struct.h: c-backslash-region some vars.
2009-11-26 00:25:07 +01:00
Andy Wingo
c06e3eb0c2 generic method cache begone
* libguile/goops.h (SCM_GENERIC_METHOD_CACHE)
  (SCM_SET_GENERIC_METHOD_CACHE, scm_si_generic_cache)
* libguile/goops.c (create_standard_classes): Remove slot for generic
  method cache. Yay!
2009-11-26 00:25:07 +01:00
Andy Wingo
9022ff183c remove code that manages the method cache
* libguile/goops.h (SCM_MCACHE_N_SPECIALIZED)
  (SCM_SET_MCACHE_N_SPECIALIZED, SCM_INITIAL_MCACHE_SIZE)
  (scm_make_method_cache, scm_memoize_method, scm_mcache_lookup_cmethod)
  (scm_mcache_compute_cmethod):
* libguile/goops.c: Remove these procedures which managed the method
  cache. There's still a slot there but it's not initialized. The method
  cache is no longer necessary.

* module/oop/goops/dispatch.scm (memoize-method!): Change to not take a
  "cache" argument.

* libguile/eval.i.c:
* libguile/vm-i-system.c: Remove dispatch via the method cache.
2009-11-26 00:25:07 +01:00
Andy Wingo
2f652c6884 generics now dispatch as applicable structs
* libguile/eval.i.c (CEVAL, SCM_APPLY): Dispatch applicable structs
  before pure generics. In practice what this means is that we never hit
  the mcache case, because all pure generics are applicable structs.
  We're moving over to having generics dispatch themselves. Also, they
  don't prepend the struct as an arg; in order to have that effect, the
  user has closures.

* libguile/goops.c (scm_apply_generic, scm_call_generic_0):
  (scm_call_generic_1, scm_call_generic_2, scm_call_generic_3): Dispatch
  directly to the struct procedures.
  (scm_var_make_extended_generic): Remove a duplicate definition for
  scm_var_make_extended_generic.
  (create_standard_classes): Mark all instances of
  <applicable-struct-class> (themselves classes) as applicable classes.
  Meaning: generics are now applicable structs.

* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT): The hashsets are actually
  uw slots -- or at least, making subclasses maps the int slots to be uw
  slots

* libguile/vm-i-system.c (call, goto/args, mv-call): Dispatch applicable
  structs in the VM.

* module/oop/goops/dispatch.scm (emit-linear-dispatch): Fix bug in the
  non-rest cache miss case.
  (delayed-compile): Rework to avoid fluids.
  (cache-dispatch): Don't call `equal?', it causes bootstrapping
  problems with the primitive-generic equal?. Using our own version is
  faster anyway.
2009-11-26 00:25:07 +01:00
Andy Wingo
9f63ce021c make sure that when equal? is extended, that the generic has a method
* libguile/goops.h:
* libguile/goops.c (scm_set_primitive_generic_x): New function, for now
  local to the goops module.

* module/oop/goops.scm (equal?): Make sure that when equal? is extended,
  that the generic already has a default method.
2009-11-26 00:25:07 +01:00
Andy Wingo
72d2e7e65f remove cache-mutex slot from generics
* libguile/goops.c:
* libguile/goops.h: Remove cache-mutex slot from generics, and renumber
  other slots.
2009-11-26 00:25:07 +01:00
Andy Wingo
51f66c9120 limn goops flags, remove foreign objs, rename entity to applicable-struct
* libguile/goops.c (scm_class_applicable_struct)
  (scm_class_applicable_struct_with_setter)
  (scm_class_applicable_struct_class): Rename from
  scm_class_entity, scm_class_entity_with_setter, and
  scm_class_entity_class.
  (scm_class_simple_method): Removed; this abstraction is not used.
  (scm_class_foreign_class, scm_class_foreign_object): Remove these,
  they are undocumented and unused. They might come back later.
  (scm_sys_inherit_magic_x): Simply inherit the vtable flags from the
  class's class. Flags are about layout, and it is the class that
  determines the layout of the instance.
  (scm_basic_basic_make_class): Don't bother setting GOOPS_OR_VALID,
  inherit-magic will do that.
  (scm_basic_make_class): Inherit magic after setting the layout. Allows
  the struct magic checker to do its job.
  (scm_accessor_method_slot_definition): Move implementation to Scheme.
  Removes the need for the accessor flag.
  (scm_sys_allocate_instance): Adapt to scm_i_alloc_struct name change,
  and that alloc-struct will handle finalization.
  (scm_compute_applicable_methods): Remove accessor check, as it's
  unnecessary.
  (scm_make): Adapt to new generic slot order, and no more
  simple-method.
  (create_standard_classes): What was the GF slot "dispatch-procedure"
  is now the applicable-struct slot "procedure". No more foreign class,
  foreign object, or simple method. Rename <entity> and friends to
  <applicable-struct> and friends. No more entity-with-setter -- though
  perhaps it will come back too. Instead generic-with-setter is its own
  thing.

* libguile/goops.h (SCM_CLASSF_METACLASS): "A goops class that is a
  vtable" -- no need for a separate flag.
  (SCM_CLASSF_FOREIGN, SCM_CLASSF_SIMPLE_METHOD)
  (SCM_CLASSF_ACCESSOR_METHOD): Removed these unused flags.
  (SCM_ACCESSORP): Removed.
  Renumber generic slots, rename entity classes, and remove the foreign
  class, foreign object, and simple method classes.

* libguile/struct.c (scm_i_struct_inherit_vtable_magic): New function,
  called when making new vtables.applicable structs
  (scm_i_alloc_struct): Remove 8-bit alignment check, as libGC
  guarantees this for us. Handle finalizer registration here.
  (scm_make_struct): Factor some things to scm_i_alloc_struct and
  scm_i_struct_inherit_vtable_magic.
  (scm_make_vtable_vtable): Adapt to scm_i_alloc_struct name change.

* libguile/struct.h (scm_i_alloc_struct): Change name from
  scm_alloc_struct, and make internal.

* module/oop/goops.scm (oop): Don't declare #:replace <class> et al,
  because <class> isn't defined in the core any more.
  (accessor-method-slot-definition): Defined in Scheme now.
  Remove <foreign-object> methods.
  (initialize on <class>): Prep layout before inheriting magic, as in
  scm_basic_make_class.

* module/oop/goops/dispatch.scm (delayed-compile)
  (memoize-effective-method!): Adapt to 'procedure slot name change.
2009-11-26 00:25:07 +01:00
Andy Wingo
a9a90a8820 generic tweaks; realizing what the setter slot actually is
* libguile/goops.h (scm_si_dispatch_procedure)
  (scm_si_effective_methods): Rename the new generics slots to
  "effective-methods" and "dispatch-procedure".
  (scm_si_generic_setter): Rename this one from "%setter" to "setter",
  and it's not a cache -- it's a pointer to the setter, which is also a
  generic. I didn't realize that before. It's better this way (like it
  always was.)
  (SCM_SET_GENERIC_DISPATCH_PROCEDURE)
  (SCM_CLEAR_GENERIC_EFFECTIVE_METHODS): New helper macros.

* libguile/goops.c (clear_method_cache): Clear the new dispatch
  procedure and the effective methods as well.
  (create_standard_classes): Rename slots, and fix the setter slots.
2009-11-26 00:25:06 +01:00
Andy Wingo
c40944c9ff remove code-table slot from methods
* libguile/goops.c (scm_sys_invalidate_method_cache_x, scm_make)
  (create_standard_classes): Remove code-table slot from methods. The
  generic cache completely does its job, afaict.

* libguile/goops.h (scm_si_formals, scm_si_body, scm_si_make_procedure):
  Renumber slots.

* module/oop/goops.scm (initialize on <method>): No more code-table
  slot.

* module/oop/goops/compile.scm: Always "compile" a method, instead of
  looking for a hit in an always-empty cache.
2009-11-26 00:25:06 +01:00
Andy Wingo
6d33e90f0c remove used-by slot from generics
* libguile/goops.c (clear_method_cache)
  (scm_sys_invalidate_method_cache_x, scm_make)
  (create_standard_classes): Remove the used-by method from generics, as
  it is not used at all.

* libguile/goops.h: Renumber generic slots.

* module/oop/goops/dispatch.scm (memoize-method!): No more used-by slot.
2009-11-26 00:25:06 +01:00
Andy Wingo
0f84ac3fe6 first step towards effective methods
* libguile/goops.c (create_standard_classes):
* libguile/goops.h *scm_si_applicable_methods, scm_si_effective_method)
  (scm_si_applicable_setter_methods, scm_si_effective_setter_method):
  Add space for the new form of the generic cache and effective method.
2009-11-26 00:25:06 +01:00