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.
This commit is contained in:
Andy Wingo 2009-11-08 11:24:23 +01:00
commit 51f66c9120
6 changed files with 147 additions and 248 deletions

View file

@ -42,11 +42,7 @@
*/
#define SCM_VTABLE_FLAG_GOOPS_CLASS SCM_VTABLE_FLAG_GOOPS_0
#define SCM_VTABLE_FLAG_GOOPS_VALID SCM_VTABLE_FLAG_GOOPS_1
#define SCM_VTABLE_FLAG_GOOPS_METACLASS SCM_VTABLE_FLAG_GOOPS_2
#define SCM_VTABLE_FLAG_GOOPS_FOREIGN SCM_VTABLE_FLAG_GOOPS_3
#define SCM_VTABLE_FLAG_GOOPS_PURE_GENERIC SCM_VTABLE_FLAG_GOOPS_4
#define SCM_VTABLE_FLAG_GOOPS_SIMPLE_METHOD SCM_VTABLE_FLAG_GOOPS_5
#define SCM_VTABLE_FLAG_GOOPS_ACCESSOR_METHOD SCM_VTABLE_FLAG_GOOPS_6
#define SCM_VTABLE_FLAG_GOOPS_PURE_GENERIC SCM_VTABLE_FLAG_GOOPS_2
#define SCM_CLASS_OF(x) SCM_STRUCT_VTABLE (x)
#define SCM_CLASS_FLAGS(class) (SCM_VTABLE_FLAGS (class))
@ -54,13 +50,10 @@
#define SCM_SET_CLASS_FLAGS(c, f) (SCM_SET_VTABLE_FLAGS (c, f))
#define SCM_CLEAR_CLASS_FLAGS(c, f) (SCM_CLEAR_VTABLE_FLAGS (c, f))
#define SCM_CLASSF_FOREIGN SCM_VTABLE_FLAG_GOOPS_FOREIGN
#define SCM_CLASSF_METACLASS SCM_VTABLE_FLAG_GOOPS_METACLASS
#define SCM_CLASSF_METACLASS (SCM_VTABLE_FLAG_GOOPS_CLASS|SCM_VTABLE_FLAG_VTABLE)
#define SCM_CLASSF_PURE_GENERIC SCM_VTABLE_FLAG_GOOPS_PURE_GENERIC
#define SCM_CLASSF_GOOPS_VALID SCM_VTABLE_FLAG_GOOPS_VALID
#define SCM_CLASSF_GOOPS SCM_VTABLE_FLAG_GOOPS_CLASS
#define SCM_CLASSF_SIMPLE_METHOD SCM_VTABLE_FLAG_GOOPS_SIMPLE_METHOD
#define SCM_CLASSF_ACCESSOR_METHOD SCM_VTABLE_FLAG_GOOPS_ACCESSOR_METHOD
#define SCM_CLASSF_GOOPS_OR_VALID (SCM_CLASSF_GOOPS | SCM_CLASSF_GOOPS_VALID)
/*
@ -140,10 +133,6 @@ typedef struct scm_t_method {
(SCM_STRUCTP (x) && (SCM_STRUCT_VTABLE_FLAGS (x) & SCM_CLASSF_PURE_GENERIC))
#define SCM_VALIDATE_PUREGENERIC(pos, x) SCM_MAKE_VALIDATE_MSG (pos, x, PUREGENERICP, "pure generic function")
#define SCM_ACCESSORP(x) \
(SCM_STRUCTP (x) && (SCM_STRUCT_VTABLE_FLAGS (x) & SCM_CLASSF_ACCESSOR_METHOD))
#define SCM_VALIDATE_ACCESSOR(pos, x) SCM_MAKE_VALIDATE_MSG (pos, x, ACCESSORP, "accessor")
#define SCM_SLOT(x, i) (SCM_STRUCT_SLOT_REF (x, i))
#define SCM_SET_SLOT(x, i, v) (SCM_STRUCT_SLOT_SET (x, i, v))
#define SCM_INSTANCE_HASH(c, i) (SCM_INST (c) [scm_si_hashsets + (i)])
@ -176,14 +165,14 @@ typedef struct scm_t_method {
#define SCM_INITIAL_MCACHE_SIZE 1
#define scm_si_methods 0 /* offset of methods slot in a <generic> */
#define scm_si_n_specialized 1
#define scm_si_cache_mutex 2
#define scm_si_extended_by 3
#define scm_si_generic_cache 4
#define scm_si_dispatch_procedure 5
#define scm_si_effective_methods 6
#define scm_si_generic_setter 7
#define scm_si_dispatch_procedure scm_applicable_struct_index_procedure /* 0 */
#define scm_si_methods 1
#define scm_si_n_specialized 2
#define scm_si_cache_mutex 3
#define scm_si_extended_by 4
#define scm_si_generic_cache 5
#define scm_si_effective_methods 6
#define scm_si_generic_setter 7
#define scm_si_generic_function 0 /* offset of gf slot in a <method> */
#define scm_si_specializers 1 /* offset of spec. slot in a <method> */
@ -213,8 +202,8 @@ SCM_API SCM scm_class_top;
SCM_API SCM scm_class_object;
SCM_API SCM scm_class_class;
SCM_API SCM scm_class_applicable;
SCM_API SCM scm_class_entity;
SCM_API SCM scm_class_entity_with_setter;
SCM_API SCM scm_class_applicable_struct;
SCM_API SCM scm_class_applicable_struct_with_setter;
SCM_API SCM scm_class_generic;
SCM_API SCM scm_class_generic_with_setter;
SCM_API SCM scm_class_accessor;
@ -222,10 +211,9 @@ SCM_API SCM scm_class_extended_generic;
SCM_API SCM scm_class_extended_generic_with_setter;
SCM_API SCM scm_class_extended_accessor;
SCM_API SCM scm_class_method;
SCM_API SCM scm_class_simple_method;
SCM_API SCM scm_class_accessor_method;
SCM_API SCM scm_class_procedure_class;
SCM_API SCM scm_class_entity_class;
SCM_API SCM scm_class_applicable_struct_class;
SCM_API SCM scm_class_number;
SCM_API SCM scm_class_list;
SCM_API SCM scm_class_keyword;
@ -233,8 +221,6 @@ SCM_API SCM scm_class_port;
SCM_API SCM scm_class_input_output_port;
SCM_API SCM scm_class_input_port;
SCM_API SCM scm_class_output_port;
SCM_API SCM scm_class_foreign_class;
SCM_API SCM scm_class_foreign_object;
SCM_API SCM scm_class_foreign_slot;
SCM_API SCM scm_class_self;
SCM_API SCM scm_class_protected;
@ -304,7 +290,6 @@ SCM_API SCM scm_generic_function_methods (SCM obj);
SCM_API SCM scm_method_generic_function (SCM obj);
SCM_API SCM scm_method_specializers (SCM obj);
SCM_API SCM scm_method_procedure (SCM obj);
SCM_API SCM scm_accessor_method_slot_definition (SCM obj);
SCM_API SCM scm_sys_tag_body (SCM body);
SCM_API SCM scm_sys_fast_slot_ref (SCM obj, SCM index);
SCM_API SCM scm_sys_fast_slot_set_x (SCM obj, SCM index, SCM value);