1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

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.
This commit is contained in:
Andy Wingo 2009-11-05 17:35:44 +01:00
parent 2aecf4cfe2
commit a9a90a8820
2 changed files with 14 additions and 12 deletions

View file

@ -1904,6 +1904,8 @@ clear_method_cache (SCM gf)
{
SCM cache = scm_make_method_cache (gf);
SCM_SET_GENERIC_METHOD_CACHE (gf, cache);
SCM_SET_GENERIC_DISPATCH_PROCEDURE (gf, SCM_BOOL_F);
SCM_CLEAR_GENERIC_EFFECTIVE_METHODS (gf);
}
SCM_DEFINE (scm_sys_invalidate_method_cache_x, "%invalidate-method-cache!", 1, 0, 0,
@ -2575,12 +2577,10 @@ create_standard_classes (void)
k_init_value,
SCM_EOL),
scm_from_locale_symbol ("%cache"),
scm_from_locale_symbol ("applicable-methods"),
scm_from_locale_symbol ("effective-method"),
scm_from_locale_symbol ("dispatch-procedure"),
scm_from_locale_symbol ("effective-methods"),
SCM_UNDEFINED);
SCM setter_slots = scm_list_3 (scm_from_locale_symbol ("%setter-cache"),
scm_from_locale_symbol ("applicable-setter-methods"),
scm_from_locale_symbol ("effective-setter-method"));
SCM setter_slots = scm_list_1 (sym_setter);
SCM egf_slots = scm_list_1 (scm_list_3 (scm_from_locale_symbol ("extends"),
k_init_value,
SCM_EOL));

View file

@ -165,11 +165,15 @@ typedef struct scm_t_method {
#define SCM_GENERIC_METHOD_CACHE(G) (SCM_PACK (SCM_STRUCT_DATA (G) [scm_si_generic_cache]))
#define SCM_SET_GENERIC_METHOD_CACHE(G,C) (SCM_STRUCT_DATA (G) [scm_si_generic_cache] = SCM_UNPACK (C))
#define SCM_GENERIC_SETTER(G) (SCM_PACK (SCM_STRUCT_DATA (G) [scm_si_generic_setter_cache]))
#define SCM_SET_GENERIC_SETTER(G,C) (SCM_STRUCT_DATA (G) [scm_si_generic_setter_cache] = SCM_UNPACK (C))
#define SCM_MCACHE_N_SPECIALIZED(C) SCM_CADDR (C)
#define SCM_SET_MCACHE_N_SPECIALIZED(C, X) SCM_SETCAR (SCM_CDDR (C), X)
#define SCM_SET_GENERIC_DISPATCH_PROCEDURE(G,C) (SCM_STRUCT_SLOT_SET (G, scm_si_dispatch_procedure, (C)))
#define SCM_CLEAR_GENERIC_EFFECTIVE_METHODS(G) (SCM_STRUCT_SLOT_SET (G, scm_si_effective_methods, SCM_EOL));
#define SCM_GENERIC_SETTER(G) (SCM_PACK (SCM_STRUCT_DATA (G) [scm_si_generic_setter]))
#define SCM_SET_GENERIC_SETTER(G,C) (SCM_STRUCT_DATA (G) [scm_si_generic_setter] = SCM_UNPACK (C))
#define SCM_INITIAL_MCACHE_SIZE 1
#define scm_si_methods 0 /* offset of methods slot in a <generic> */
@ -177,11 +181,9 @@ typedef struct scm_t_method {
#define scm_si_cache_mutex 2
#define scm_si_extended_by 3
#define scm_si_generic_cache 4
#define scm_si_applicable_methods 5
#define scm_si_effective_method 6
#define scm_si_generic_setter_cache 7
#define scm_si_applicable_setter_methods 8
#define scm_si_effective_setter_method 9
#define scm_si_dispatch_procedure 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> */