guile/libguile/goops.c

1676 lines
50 KiB
C
Raw Normal View History

/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011,2012,2013,2014,2015
* Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
/* This software is a derivative work of other copyrighted softwares; the
* copyright notices of these softwares are placed in the file COPYRIGHTS
*
* This file is based upon stklos.c from the STk distribution by
* Erick Gallesio <eg@unice.fr>.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "libguile/_scm.h"
#include "libguile/async.h"
#include "libguile/chars.h"
#include "libguile/dynwind.h"
#include "libguile/eval.h"
#include "libguile/gsubr.h"
#include "libguile/hashtab.h"
#include "libguile/keywords.h"
#include "libguile/macros.h"
#include "libguile/modules.h"
#include "libguile/ports.h"
#include "libguile/procprop.h"
#include "libguile/programs.h"
#include "libguile/smob.h"
#include "libguile/strings.h"
#include "libguile/strports.h"
#include "libguile/vectors.h"
#include "libguile/validate.h"
#include "libguile/goops.h"
/* Port classes */
#define SCM_IN_PCLASS_INDEX 0
#define SCM_OUT_PCLASS_INDEX SCM_I_MAX_PORT_TYPE_COUNT
#define SCM_INOUT_PCLASS_INDEX (2 * SCM_I_MAX_PORT_TYPE_COUNT)
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-04 13:41:09 -05:00
/* Objects have identity, so references to classes and instances are by
value, not by reference. Redefinition of a class or modification of
an instance causes in-place update; you can think of GOOPS as
building in its own indirection, and for that reason referring to
GOOPS values by variable reference is unnecessary.
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-04 13:41:09 -05:00
References to ordinary procedures is by reference (by variable),
though, as in the rest of Guile. */
static SCM var_make_standard_class = SCM_BOOL_F;
static SCM var_slot_unbound = SCM_BOOL_F;
static SCM var_slot_missing = SCM_BOOL_F;
static SCM var_change_class = SCM_BOOL_F;
static SCM var_make = SCM_BOOL_F;
static SCM var_class_name = SCM_BOOL_F;
static SCM var_class_direct_supers = SCM_BOOL_F;
static SCM var_class_direct_slots = SCM_BOOL_F;
static SCM var_class_direct_subclasses = SCM_BOOL_F;
static SCM var_class_direct_methods = SCM_BOOL_F;
static SCM var_class_precedence_list = SCM_BOOL_F;
static SCM var_class_slots = SCM_BOOL_F;
static SCM var_generic_function_methods = SCM_BOOL_F;
static SCM var_method_generic_function = SCM_BOOL_F;
static SCM var_method_specializers = SCM_BOOL_F;
static SCM var_method_procedure = SCM_BOOL_F;
SCM_SYMBOL (sym_slot_unbound, "slot-unbound");
SCM_SYMBOL (sym_slot_missing, "slot-missing");
SCM_SYMBOL (sym_change_class, "change-class");
SCM_VARIABLE (scm_var_make_extended_generic, "make-extended-generic");
/* Class redefinition protocol:
A class is represented by a heap header h1 which points to a
malloc:ed memory block m1.
When a new version of a class is created, a new header h2 and
memory block m2 are allocated. The headers h1 and h2 then switch
pointers so that h1 refers to m2 and h2 to m1. In this way, names
bound to h1 will point to the new class at the same time as h2 will
2005-04-24 12:23:57 +00:00
be a handle which the GC will use to free m1.
The `redefined' slot of m1 will be set to point to h1. An old
2005-04-24 12:23:57 +00:00
instance will have its class pointer (the CAR of the heap header)
pointing to m1. The non-immediate `redefined'-slot in m1 indicates
the class modification and the new class pointer can be found via
h1.
*/
#define TEST_CHANGE_CLASS(obj, class) \
{ \
class = SCM_CLASS_OF (obj); \
if (scm_is_true (SCM_OBJ_CLASS_REDEF (obj))) \
{ \
scm_change_object_class (obj, class, SCM_OBJ_CLASS_REDEF (obj));\
class = SCM_CLASS_OF (obj); \
} \
}
#define SCM_GOOPS_UNBOUND SCM_UNBOUND
#define SCM_GOOPS_UNBOUNDP(x) (scm_is_eq (x, SCM_GOOPS_UNBOUND))
static int goops_loaded_p = 0;
/* These variables are filled in by the object system when loaded. */
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-06 14:16:03 -05:00
static SCM class_boolean, class_char, class_pair;
static SCM class_procedure, class_string, class_symbol;
static SCM class_primitive_generic;
static SCM class_vector, class_null;
static SCM class_integer, class_real, class_complex, class_fraction;
static SCM class_unknown;
static SCM class_top, class_object, class_class;
static SCM class_applicable;
static SCM class_applicable_struct, class_applicable_struct_with_setter;
static SCM class_generic, class_generic_with_setter;
static SCM class_accessor;
static SCM class_extended_generic, class_extended_generic_with_setter;
static SCM class_extended_accessor;
static SCM class_method;
static SCM class_accessor_method;
static SCM class_procedure_class;
static SCM class_applicable_struct_class;
static SCM class_applicable_struct_with_setter_class;
static SCM class_number, class_list;
static SCM class_keyword;
static SCM class_port, class_input_output_port;
static SCM class_input_port, class_output_port;
static SCM class_foreign_slot;
static SCM class_self, class_protected;
static SCM class_hidden, class_opaque, class_read_only;
static SCM class_protected_hidden, class_protected_opaque, class_protected_read_only;
static SCM class_scm;
static SCM class_int, class_float, class_double;
static SCM class_foreign;
static SCM class_hashtable;
static SCM class_fluid;
static SCM class_dynamic_state;
static SCM class_frame;
static SCM class_vm_cont;
static SCM class_bytevector;
static SCM class_uvec;
static SCM class_array;
static SCM class_bitvector;
static SCM vtable_class_map = SCM_BOOL_F;
/* Port classes. Allocate 3 times the maximum number of port types so that
input ports, output ports, and in/out ports can be stored at different
offsets. See `SCM_IN_PCLASS_INDEX' et al. */
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-06 14:16:03 -05:00
SCM scm_i_port_class[3 * SCM_I_MAX_PORT_TYPE_COUNT];
/* SMOB classes. */
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-06 14:16:03 -05:00
SCM scm_i_smob_class[SCM_I_MAX_SMOB_TYPE_COUNT];
static SCM scm_make_unbound (void);
static SCM scm_unbound_p (SCM obj);
static SCM scm_class_p (SCM obj);
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-06 13:41:56 -05:00
static SCM scm_sys_bless_applicable_struct_vtables_x (SCM applicable,
SCM setter);
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-04 13:41:09 -05:00
static SCM scm_sys_bless_pure_generic_vtable_x (SCM vtable);
static SCM scm_sys_make_root_class (SCM name, SCM dslots,
SCM getters_n_setters);
static SCM scm_sys_init_layout_x (SCM class, SCM layout);
static SCM scm_sys_goops_early_init (void);
2000-12-16 20:25:08 +00:00
static SCM scm_sys_goops_loaded (void);
/* This function is used for efficient type dispatch. */
SCM_DEFINE (scm_class_of, "class-of", 1, 0, 0,
(SCM x),
"Return the class of @var{x}.")
#define FUNC_NAME s_scm_class_of
{
switch (SCM_ITAG3 (x))
{
case scm_tc3_int_1:
case scm_tc3_int_2:
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-06 14:16:03 -05:00
return class_integer;
case scm_tc3_imm24:
if (SCM_CHARP (x))
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-06 14:16:03 -05:00
return class_char;
else if (scm_is_bool (x))
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-06 14:16:03 -05:00
return class_boolean;
else if (scm_is_null (x))
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-06 14:16:03 -05:00
return class_null;
else
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-06 14:16:03 -05:00
return class_unknown;
case scm_tc3_cons:
switch (SCM_TYP7 (x))
{
case scm_tcs_cons_nimcar:
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-06 14:16:03 -05:00
return class_pair;
case scm_tc7_symbol:
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-06 14:16:03 -05:00
return class_symbol;
case scm_tc7_vector:
case scm_tc7_wvect:
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-06 14:16:03 -05:00
return class_vector;
case scm_tc7_pointer:
return class_foreign;
case scm_tc7_hashtable:
return class_hashtable;
case scm_tc7_fluid:
return class_fluid;
case scm_tc7_dynamic_state:
return class_dynamic_state;
case scm_tc7_frame:
return class_frame;
case scm_tc7_keyword:
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-06 14:16:03 -05:00
return class_keyword;
case scm_tc7_vm_cont:
return class_vm_cont;
case scm_tc7_bytevector:
if (SCM_BYTEVECTOR_ELEMENT_TYPE (x) == SCM_ARRAY_ELEMENT_TYPE_VU8)
return class_bytevector;
else
return class_uvec;
case scm_tc7_array:
return class_array;
case scm_tc7_bitvector:
return class_bitvector;
case scm_tc7_string:
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-06 14:16:03 -05:00
return class_string;
case scm_tc7_number:
switch SCM_TYP16 (x) {
case scm_tc16_big:
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-06 14:16:03 -05:00
return class_integer;
case scm_tc16_real:
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-06 14:16:03 -05:00
return class_real;
case scm_tc16_complex:
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-06 14:16:03 -05:00
return class_complex;
case scm_tc16_fraction:
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-06 14:16:03 -05:00
return class_fraction;
}
case scm_tc7_program:
if (SCM_PROGRAM_IS_PRIMITIVE_GENERIC (x)
&& SCM_UNPACK (*SCM_SUBR_GENERIC (x)))
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-06 14:16:03 -05:00
return class_primitive_generic;
else
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-06 14:16:03 -05:00
return class_procedure;
case scm_tc7_smob:
{
scm_t_bits type = SCM_TYP16 (x);
if (type != scm_tc16_port_with_ps)
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-06 14:16:03 -05:00
return scm_i_smob_class[SCM_TC2SMOBNUM (type)];
x = SCM_PORT_WITH_PS_PORT (x);
/* fall through to ports */
}
case scm_tc7_port:
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-06 14:16:03 -05:00
return scm_i_port_class[(SCM_WRTNG & SCM_CELL_WORD_0 (x)
? (SCM_RDNG & SCM_CELL_WORD_0 (x)
? SCM_INOUT_PCLASS_INDEX | SCM_PTOBNUM (x)
: SCM_OUT_PCLASS_INDEX | SCM_PTOBNUM (x))
: SCM_IN_PCLASS_INDEX | SCM_PTOBNUM (x))];
case scm_tcs_struct:
if (SCM_OBJ_CLASS_FLAGS (x) & SCM_CLASSF_GOOPS_VALID)
return SCM_CLASS_OF (x);
else if (SCM_OBJ_CLASS_FLAGS (x) & SCM_CLASSF_GOOPS)
{
/* Goops object */
if (! scm_is_false (SCM_OBJ_CLASS_REDEF (x)))
scm_change_object_class (x,
SCM_CLASS_OF (x), /* old */
SCM_OBJ_CLASS_REDEF (x)); /* new */
return SCM_CLASS_OF (x);
}
else
return scm_i_define_class_for_vtable (SCM_CLASS_OF (x));
default:
if (scm_is_pair (x))
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-06 14:16:03 -05:00
return class_pair;
else
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-06 14:16:03 -05:00
return class_unknown;
}
case scm_tc3_struct:
case scm_tc3_tc7_1:
case scm_tc3_tc7_2:
eval.c closures are now applicable smobs, not tc3s * libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and some dead code. (scm_procedure_module): Remove. This was introduced a few months ago for the hygienic expander, but now it is no longer needed, as the expander keeps track of this information itself. * libguile/debug.h: Remove scm_procedure_module. * libguile/eval.c: Instead of using tc3 closures, define a "boot closure" applicable smob type, and represent closures with that. The advantage is that after eval.scm is compiled, boot closures take up no address space (besides a smob number) in the runtime, and require no special cases in procedure dispatch. * libguile/eval.h: Remove the internal functions scm_i_call_closure_0 and scm_closure_apply, and the public function scm_closure. * libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement registration. (scm_i_tag_name): Remove closure case, and a dead cclo case. * libguile/vm.c (apply_foreign): * libguile/print.c (iprin1): * libguile/procs.c (scm_procedure_p, scm_procedure_documentation); * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases. * libguile/hash.c (scm_hasher): * libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity. * libguile/macros.c (macro_print): Print all macros using the same code. (scm_macro_transformer): Return any procedure, not just programs. * libguile/procprop.h: * libguile/procprop.c (scm_i_procedure_arity): Instead of returning a list that the caller has to parse, have the same prototype as scm_i_program_arity. An incompatible change, but it's an internal function anyway. (scm_procedure_properties, scm_set_procedure_properties) (scm_procedure_property, scm_set_procedure_property): Remove closure cases, and use scm_i_program_arity for arity. * libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE) (SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS) (SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV) (SCM_TOP_LEVEL): Remove these macros that pertain to boot closures only. Only eval.c should know abut boot closures. * libguile/procs.c (scm_closure_p): Remove this function. There is a simple stub in deprecated.scm now. (scm_thunk_p): Use scm_i_program_arity. * libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play with! (scm_tcs_closures): Remove. * libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove. * module/ice-9/deprecated.scm (closure?): Add stub. * module/ice-9/documentation.scm (object-documentation) * module/ice-9/session.scm (help-doc, arity) * module/oop/goops.scm (compute-getters-n-setters) * module/oop/goops/describe.scm (describe) * module/system/repl/describe.scm (display-object, display-type): Remove calls to closure?.
2009-12-04 19:20:11 +01:00
/* case scm_tc3_unused: */
/* Never reached */
break;
}
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-06 14:16:03 -05:00
return class_unknown;
}
#undef FUNC_NAME
/******************************************************************************
*
* initialize-object
*
******************************************************************************/
/*fixme* Manufacture keywords in advance */
SCM
scm_i_get_keyword (SCM key, SCM l, long len, SCM default_value, const char *subr)
{
long i;
2000-12-01 16:05:33 +00:00
for (i = 0; i != len; i += 2)
{
2000-12-01 16:05:33 +00:00
SCM obj = SCM_CAR (l);
if (!scm_is_keyword (obj))
scm_misc_error (subr, "bad keyword: ~S", scm_list_1 (obj));
else if (scm_is_eq (obj, key))
return SCM_CADR (l);
2000-12-01 16:05:33 +00:00
else
l = SCM_CDDR (l);
}
2000-12-01 16:05:33 +00:00
return default_value;
}
2000-12-01 16:05:33 +00:00
SCM_DEFINE (scm_get_keyword, "get-keyword", 3, 0, 0,
(SCM key, SCM l, SCM default_value),
"Determine an associated value for the keyword @var{key} from\n"
"the list @var{l}. The list @var{l} has to consist of an even\n"
"number of elements, where, starting with the first, every\n"
"second element is a keyword, followed by its associated value.\n"
"If @var{l} does not hold a value for @var{key}, the value\n"
"@var{default_value} is returned.")
2000-12-01 16:05:33 +00:00
#define FUNC_NAME s_scm_get_keyword
{
long len;
2000-12-01 16:05:33 +00:00
SCM_ASSERT (scm_is_keyword (key), key, SCM_ARG1, FUNC_NAME);
len = scm_ilength (l);
2001-01-27 00:13:55 +00:00
if (len < 0 || len % 2 == 1)
scm_misc_error (FUNC_NAME, "Bad keyword-value list: ~S", scm_list_1 (l));
2000-12-01 16:05:33 +00:00
return scm_i_get_keyword (key, l, len, default_value, FUNC_NAME);
}
2000-12-01 16:05:33 +00:00
#undef FUNC_NAME
SCM_KEYWORD (k_init_keyword, "init-keyword");
static SCM get_slot_value (SCM class, SCM obj, SCM slotdef);
static SCM set_slot_value (SCM class, SCM obj, SCM slotdef, SCM value);
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_initialize_object, "%initialize-object", 2, 0, 0,
(SCM obj, SCM initargs),
"Initialize the object @var{obj} with the given arguments\n"
"@var{initargs}.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_sys_initialize_object
{
SCM tmp, get_n_set, slots;
SCM class = SCM_CLASS_OF (obj);
long n_initargs;
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, obj);
n_initargs = scm_ilength (initargs);
2000-12-16 20:25:08 +00:00
SCM_ASSERT ((n_initargs & 1) == 0, initargs, SCM_ARG2, FUNC_NAME);
get_n_set = SCM_SLOT (class, scm_si_getters_n_setters);
slots = SCM_SLOT (class, scm_si_slots);
/* See for each slot how it must be initialized */
for (;
2004-09-22 17:41:37 +00:00
!scm_is_null (slots);
get_n_set = SCM_CDR (get_n_set), slots = SCM_CDR (slots))
{
SCM slot_name = SCM_CAR (slots);
SCM slot_value = SCM_GOOPS_UNBOUND;
2004-09-22 17:41:37 +00:00
if (!scm_is_null (SCM_CDR (slot_name)))
{
/* This slot admits (perhaps) to be initialized at creation time */
long n = scm_ilength (SCM_CDR (slot_name));
if (n & 1) /* odd or -1 */
2000-12-16 20:25:08 +00:00
SCM_MISC_ERROR ("class contains bogus slot definition: ~S",
scm_list_1 (slot_name));
tmp = scm_i_get_keyword (k_init_keyword,
SCM_CDR (slot_name),
n,
SCM_PACK (0),
2000-12-16 20:25:08 +00:00
FUNC_NAME);
slot_name = SCM_CAR (slot_name);
if (SCM_UNPACK (tmp))
{
/* an initarg was provided for this slot */
if (!scm_is_keyword (tmp))
2000-12-16 20:25:08 +00:00
SCM_MISC_ERROR ("initarg must be a keyword. It was ~S",
scm_list_1 (tmp));
slot_value = scm_i_get_keyword (tmp,
initargs,
n_initargs,
SCM_GOOPS_UNBOUND,
2000-12-16 20:25:08 +00:00
FUNC_NAME);
}
}
if (!SCM_GOOPS_UNBOUNDP (slot_value))
/* set slot to provided value */
set_slot_value (class, obj, SCM_CAR (get_n_set), slot_value);
else
{
/* set slot to its :init-form if it exists */
tmp = SCM_CADAR (get_n_set);
if (scm_is_true (tmp))
set_slot_value (class,
obj,
SCM_CAR (get_n_set),
scm_call_0 (tmp));
}
}
return obj;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
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-04 13:41:09 -05:00
SCM_DEFINE (scm_sys_init_layout_x, "%init-layout!", 2, 0, 0,
(SCM class, SCM layout),
2000-12-16 20:25:08 +00:00
"")
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-04 13:41:09 -05:00
#define FUNC_NAME s_scm_sys_init_layout_x
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, class);
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-04 13:41:09 -05:00
SCM_ASSERT (!scm_is_symbol (SCM_VTABLE_LAYOUT (class)), class, 1, FUNC_NAME);
SCM_VALIDATE_STRING (2, layout);
SCM_SET_VTABLE_LAYOUT (class, scm_make_struct_layout (layout));
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_inherit_magic_x, "%inherit-magic!", 2, 0, 0,
(SCM class, SCM dsupers),
"")
#define FUNC_NAME s_scm_sys_inherit_magic_x
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, class);
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-08 11:24:23 +01:00
scm_i_struct_inherit_vtable_magic (SCM_CLASS_OF (class), class);
SCM_SET_CLASS_FLAGS (class, SCM_CLASSF_GOOPS_OR_VALID);
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/******************************************************************************/
SCM
scm_make_standard_class (SCM meta, SCM name, SCM dsupers, SCM dslots)
{
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-04 13:41:09 -05:00
return scm_call_4 (scm_variable_ref (var_make_standard_class),
meta, name, dsupers, dslots);
}
/******************************************************************************/
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-04 13:41:09 -05:00
SCM_DEFINE (scm_sys_make_root_class, "%make-root-class", 3, 0, 0,
(SCM name, SCM dslots, SCM getters_n_setters),
"")
#define FUNC_NAME s_scm_sys_make_root_class
{
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-04 13:41:09 -05:00
SCM cs, z;
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-04 13:41:09 -05:00
cs = scm_from_locale_string (SCM_CLASS_CLASS_LAYOUT);
z = scm_i_make_vtable_vtable (cs);
SCM_SET_CLASS_FLAGS (z, (SCM_CLASSF_GOOPS_OR_VALID
| SCM_CLASSF_METACLASS));
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-04 13:41:09 -05:00
SCM_SET_SLOT (z, scm_vtable_index_name, name);
SCM_SET_SLOT (z, scm_si_direct_supers, SCM_EOL); /* will be changed */
SCM_SET_SLOT (z, scm_si_direct_slots, dslots); /* will be changed */
SCM_SET_SLOT (z, scm_si_direct_subclasses, SCM_EOL);
SCM_SET_SLOT (z, scm_si_direct_methods, SCM_EOL);
SCM_SET_SLOT (z, scm_si_cpl, SCM_EOL); /* will be changed */
SCM_SET_SLOT (z, scm_si_slots, dslots); /* will be changed */
SCM_SET_SLOT (z, scm_si_nfields, scm_from_int (SCM_N_CLASS_SLOTS));
SCM_SET_SLOT (z, scm_si_getters_n_setters, getters_n_setters); /* will be changed */
SCM_SET_SLOT (z, scm_si_redefined, SCM_BOOL_F);
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-04 13:41:09 -05:00
return z;
}
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-04 13:41:09 -05:00
#undef FUNC_NAME
/******************************************************************************/
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_instance_p, "instance?", 1, 0, 0,
(SCM obj),
"Return @code{#t} if @var{obj} is an instance.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_instance_p
{
return scm_from_bool (SCM_INSTANCEP (obj));
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
SCM_DEFINE (scm_class_p, "class?", 1, 0, 0,
(SCM obj),
"Return @code{#t} if @var{obj} is a class.")
#define FUNC_NAME s_scm_class_p
{
return scm_from_bool (SCM_CLASSP (obj));
}
#undef FUNC_NAME
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-06 14:16:03 -05:00
int
scm_is_generic (SCM x)
{
return SCM_INSTANCEP (x) && SCM_SUBCLASSP (SCM_CLASS_OF (x), class_generic);
}
int
scm_is_method (SCM x)
{
return SCM_INSTANCEP (x) && SCM_SUBCLASSP (SCM_CLASS_OF (x), class_method);
}
/******************************************************************************
*
* Meta object accessors
*
******************************************************************************/
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-04 13:41:09 -05:00
SCM_SYMBOL (sym_procedure, "procedure");
SCM
scm_class_name (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_class_name), obj);
}
SCM
scm_class_direct_supers (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_class_direct_supers), obj);
}
SCM
scm_class_direct_slots (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_class_direct_slots), obj);
}
SCM
scm_class_direct_subclasses (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_class_direct_subclasses), obj);
}
SCM
scm_class_direct_methods (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_class_direct_methods), obj);
}
SCM
scm_class_precedence_list (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_class_precedence_list), obj);
}
SCM
scm_class_slots (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_class_slots), obj);
}
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_generic_function_name, "generic-function-name", 1, 0, 0,
(SCM obj),
"Return the name of the generic function @var{obj}.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_generic_function_name
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_GENERIC (1, obj);
return scm_procedure_property (obj, scm_sym_name);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
SCM
scm_generic_function_methods (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_generic_function_methods), obj);
}
SCM
scm_method_generic_function (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_method_generic_function), obj);
}
SCM
scm_method_specializers (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_method_specializers), obj);
}
SCM
scm_method_procedure (SCM obj)
{
return scm_call_1 (scm_variable_ref (var_method_procedure), obj);
}
/******************************************************************************
*
* S l o t a c c e s s
*
******************************************************************************/
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_make_unbound, "make-unbound", 0, 0, 0,
(),
"Return the unbound value.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_make_unbound
{
return SCM_GOOPS_UNBOUND;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_unbound_p, "unbound?", 1, 0, 0,
(SCM obj),
"Return @code{#t} if @var{obj} is unbound.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_unbound_p
{
return SCM_GOOPS_UNBOUNDP (obj) ? SCM_BOOL_T : SCM_BOOL_F;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/** Utilities **/
/* In the future, this function will return the effective slot
* definition associated with SLOT_NAME. Now it just returns some of
* the information which will be stored in the effective slot
* definition.
*/
static SCM
slot_definition_using_name (SCM class, SCM slot_name)
{
register SCM slots = SCM_SLOT (class, scm_si_getters_n_setters);
2004-09-22 17:41:37 +00:00
for (; !scm_is_null (slots); slots = SCM_CDR (slots))
if (scm_is_eq (SCM_CAAR (slots), slot_name))
return SCM_CAR (slots);
return SCM_BOOL_F;
}
static SCM
get_slot_value (SCM class SCM_UNUSED, SCM obj, SCM slotdef)
#define FUNC_NAME "%get-slot-value"
{
SCM access = SCM_CDDR (slotdef);
/* Two cases here:
* - access is an integer (the offset of this slot in the slots vector)
* - otherwise (car access) is the getter function to apply
*
* Instances have never more than SCM_MOST_POSITIVE_FIXNUM slots, so
* we can just assume fixnums here.
2000-12-01 16:05:33 +00:00
*/
if (SCM_I_INUMP (access))
/* Don't poke at the slots directly, because scm_struct_ref handles the
access bits for us. */
return scm_struct_ref (obj, access);
else
return scm_call_1 (SCM_CAR (access), obj);
}
#undef FUNC_NAME
static SCM
get_slot_value_using_name (SCM class, SCM obj, SCM slot_name)
{
SCM slotdef = slot_definition_using_name (class, slot_name);
if (scm_is_true (slotdef))
return get_slot_value (class, obj, slotdef);
else
return scm_call_3 (SCM_VARIABLE_REF (var_slot_missing), class, obj, slot_name);
}
static SCM
set_slot_value (SCM class SCM_UNUSED, SCM obj, SCM slotdef, SCM value)
#define FUNC_NAME "%set-slot-value"
{
SCM access = SCM_CDDR (slotdef);
/* Two cases here:
* - access is an integer (the offset of this slot in the slots vector)
* - otherwise (cadr access) is the setter function to apply
*
* Instances have never more than SCM_MOST_POSITIVE_FIXNUM slots, so
* we can just assume fixnums here.
*/
if (SCM_I_INUMP (access))
/* obey permissions bits via going through struct-set! */
scm_struct_set_x (obj, access, value);
else
/* ((cadr l) obj value) */
scm_call_2 (SCM_CADR (access), obj, value);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
static SCM
set_slot_value_using_name (SCM class, SCM obj, SCM slot_name, SCM value)
{
SCM slotdef = slot_definition_using_name (class, slot_name);
if (scm_is_true (slotdef))
return set_slot_value (class, obj, slotdef, value);
else
return scm_call_4 (SCM_VARIABLE_REF (var_slot_missing), class, obj, slot_name, value);
}
static SCM
test_slot_existence (SCM class SCM_UNUSED, SCM obj, SCM slot_name)
{
register SCM l;
2004-09-22 17:41:37 +00:00
for (l = SCM_ACCESSORS_OF (obj); !scm_is_null (l); l = SCM_CDR (l))
if (scm_is_eq (SCM_CAAR (l), slot_name))
return SCM_BOOL_T;
return SCM_BOOL_F;
}
/* ======================================== */
2000-12-01 16:05:33 +00:00
SCM_DEFINE (scm_slot_ref_using_class, "slot-ref-using-class", 3, 0, 0,
(SCM class, SCM obj, SCM slot_name),
"")
#define FUNC_NAME s_scm_slot_ref_using_class
{
SCM res;
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_CLASS (1, class);
SCM_VALIDATE_INSTANCE (2, obj);
SCM_VALIDATE_SYMBOL (3, slot_name);
res = get_slot_value_using_name (class, obj, slot_name);
if (SCM_GOOPS_UNBOUNDP (res))
return scm_call_3 (SCM_VARIABLE_REF (var_slot_unbound), class, obj, slot_name);
return res;
}
2000-12-01 16:05:33 +00:00
#undef FUNC_NAME
2000-12-01 16:05:33 +00:00
SCM_DEFINE (scm_slot_set_using_class_x, "slot-set-using-class!", 4, 0, 0,
(SCM class, SCM obj, SCM slot_name, SCM value),
"")
#define FUNC_NAME s_scm_slot_set_using_class_x
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_CLASS (1, class);
SCM_VALIDATE_INSTANCE (2, obj);
SCM_VALIDATE_SYMBOL (3, slot_name);
2000-12-01 16:05:33 +00:00
return set_slot_value_using_name (class, obj, slot_name, value);
}
2000-12-01 16:05:33 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_slot_bound_using_class_p, "slot-bound-using-class?", 3, 0, 0,
(SCM class, SCM obj, SCM slot_name),
"")
#define FUNC_NAME s_scm_slot_bound_using_class_p
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_CLASS (1, class);
SCM_VALIDATE_INSTANCE (2, obj);
SCM_VALIDATE_SYMBOL (3, slot_name);
return (SCM_GOOPS_UNBOUNDP (get_slot_value_using_name (class, obj, slot_name))
? SCM_BOOL_F
: SCM_BOOL_T);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_slot_exists_using_class_p, "slot-exists-using-class?", 3, 0, 0,
(SCM class, SCM obj, SCM slot_name),
"")
#define FUNC_NAME s_scm_slot_exists_using_class_p
{
SCM_VALIDATE_CLASS (1, class);
SCM_VALIDATE_INSTANCE (2, obj);
SCM_VALIDATE_SYMBOL (3, slot_name);
return test_slot_existence (class, obj, slot_name);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/* ======================================== */
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_slot_ref, "slot-ref", 2, 0, 0,
(SCM obj, SCM slot_name),
"Return the value from @var{obj}'s slot with the name\n"
"@var{slot_name}.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_slot_ref
{
SCM res, class;
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, obj);
TEST_CHANGE_CLASS (obj, class);
res = get_slot_value_using_name (class, obj, slot_name);
if (SCM_GOOPS_UNBOUNDP (res))
return scm_call_3 (SCM_VARIABLE_REF (var_slot_unbound), class, obj, slot_name);
return res;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_slot_set_x, "slot-set!", 3, 0, 0,
(SCM obj, SCM slot_name, SCM value),
"Set the slot named @var{slot_name} of @var{obj} to @var{value}.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_slot_set_x
{
SCM class;
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, obj);
TEST_CHANGE_CLASS(obj, class);
return set_slot_value_using_name (class, obj, slot_name, value);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_slot_bound_p, "slot-bound?", 2, 0, 0,
(SCM obj, SCM slot_name),
"Return @code{#t} if the slot named @var{slot_name} of @var{obj}\n"
"is bound.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_slot_bound_p
{
SCM class;
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, obj);
TEST_CHANGE_CLASS(obj, class);
return (SCM_GOOPS_UNBOUNDP (get_slot_value_using_name (class,
obj,
slot_name))
? SCM_BOOL_F
: SCM_BOOL_T);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
SCM_DEFINE (scm_slot_exists_p, "slot-exists?", 2, 0, 0,
2000-12-16 20:25:08 +00:00
(SCM obj, SCM slot_name),
"Return @code{#t} if @var{obj} has a slot named @var{slot_name}.")
#define FUNC_NAME s_scm_slot_exists_p
{
SCM class;
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, obj);
SCM_VALIDATE_SYMBOL (2, slot_name);
TEST_CHANGE_CLASS (obj, class);
return test_slot_existence (class, obj, slot_name);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/******************************************************************************
*
* %allocate-instance (the low level instance allocation primitive)
*
******************************************************************************/
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_allocate_instance, "%allocate-instance", 2, 0, 0,
(SCM class, SCM initargs),
"Create a new instance of class @var{class} and initialize it\n"
"from the arguments @var{initargs}.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_sys_allocate_instance
{
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
SCM obj;
scm_t_signed_bits n, i;
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
SCM layout;
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_CLASS (1, class);
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
/* FIXME: duplicates some of scm_make_struct. */
n = SCM_I_INUM (SCM_SLOT (class, scm_si_nfields));
obj = scm_i_alloc_struct (SCM_STRUCT_DATA (class), n);
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
layout = SCM_VTABLE_LAYOUT (class);
/* Set all SCM-holding slots to unbound */
for (i = 0; i < n; i++)
{
scm_t_wchar c = scm_i_symbol_ref (layout, i*2);
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
if (c == 'p')
SCM_STRUCT_DATA (obj)[i] = SCM_UNPACK (SCM_GOOPS_UNBOUND);
else if (c == 's')
SCM_STRUCT_DATA (obj)[i] = SCM_UNPACK (obj);
else
SCM_STRUCT_DATA (obj)[i] = 0;
}
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
return obj;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/******************************************************************************
*
* %modify-instance (used by change-class to modify in place)
*
******************************************************************************/
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_modify_instance, "%modify-instance", 2, 0, 0,
(SCM old, SCM new),
"")
#define FUNC_NAME s_scm_sys_modify_instance
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_INSTANCE (1, old);
SCM_VALIDATE_INSTANCE (2, new);
/* Exchange the data contained in old and new. We exchange rather than
* scratch the old value with new to be correct with GC.
* See "Class redefinition protocol above".
*/
2005-03-02 20:42:01 +00:00
SCM_CRITICAL_SECTION_START;
{
scm_t_bits word0, word1;
word0 = SCM_CELL_WORD_0 (old);
word1 = SCM_CELL_WORD_1 (old);
SCM_SET_CELL_WORD_0 (old, SCM_CELL_WORD_0 (new));
SCM_SET_CELL_WORD_1 (old, SCM_CELL_WORD_1 (new));
SCM_SET_CELL_WORD_0 (new, word0);
SCM_SET_CELL_WORD_1 (new, word1);
}
2005-03-02 20:42:01 +00:00
SCM_CRITICAL_SECTION_END;
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_modify_class, "%modify-class", 2, 0, 0,
(SCM old, SCM new),
"")
#define FUNC_NAME s_scm_sys_modify_class
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_CLASS (1, old);
SCM_VALIDATE_CLASS (2, new);
2005-03-02 20:42:01 +00:00
SCM_CRITICAL_SECTION_START;
{
scm_t_bits word0, word1;
word0 = SCM_CELL_WORD_0 (old);
word1 = SCM_CELL_WORD_1 (old);
SCM_SET_CELL_WORD_0 (old, SCM_CELL_WORD_0 (new));
SCM_SET_CELL_WORD_1 (old, SCM_CELL_WORD_1 (new));
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
SCM_STRUCT_DATA (old)[scm_vtable_index_self] = SCM_UNPACK (old);
SCM_SET_CELL_WORD_0 (new, word0);
SCM_SET_CELL_WORD_1 (new, word1);
a very big commit cleaning up structs & goops. also applicable structs. I tried to split this one, and I know it's a bit disruptive, but this stuff really is one big cobweb. So instead we'll pretend like these are separate commits, by separating the changelog. Applicable struct runtime support. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): * libguile/eval.i.c (CEVAL): * libguile/goops.c (scm_class_of): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow for applicable structs. Whee! * libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym for scm_vtable_index_self. (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer. (scm_struct_i_free): Alias scm_vtable_index_instance_finalize. (scm_struct_i_flags): Alias scm_vtable_index_flags. (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now. (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand. Hidden slots. * libguile/struct.c (scm_make_struct_layout): Add support for "hidden" fields, writable fields that are not visible to make-struct. This allows us to add fields to vtables and not break existing make-struct invocations. (scm_struct_ref, scm_struct_set_x): Always get struct length from the vtable. Support hidden fields. * libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New slot classes, to correspond to the new vtable slots. (scm_sys_prep_layout_x): Turn hidden slots into 'h'. (build_class_class_slots): Reorder the class slots to account for vtable fields coming out of negative-land, for name as a vtable slot, and for hidden fields. (create_standard_classes): Define <hidden-slot> and <protected-hidden-slot>. Clean up struct.h. * libguile/struct.h: Lay things out cleaner. There are no more hidden (negative) words. Names are nicer. The exposition is nicer. But the basics are the same. The incompatibilities are that <vtable> has more slots now, and that scm_alloc_struct's signature has changed. The former is ameliorated by the "hidden" slots mentioned before, and the latter, well, it was always a very internal thing... (scm_t_struct_finalize): New type, a finalizer function to be run when instances of a vtable are collected. (scm_t_struct_free): Removed, structs' data is managed by the GC now, and not freed by vtable functions. * libguile/struct.c: (scm_vtable_p): Now we keep flags on vtable-vtables, so this check is cheaper. (scm_alloc_struct): No hidden words. Yippee. (struct_finalizer_trampoline): Entersify. (scm_make_struct): No need to babysit extra words, though now we have to babysit flags. Propagate the vtable, applicable, and setter flags appropriately. (scm_make_vtable_vtable): Update for new simplicity. (scm_print_struct): A better printer. (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable like CL's funcallable-standard-class. Also define <applicable-struct-with-setter-vtable>. Remove foreign object implementation. * libguile/goops.h: * libguile/goops.c (scm_make_foreign_object, scm_make_class) (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these were undocumented and unworking. Clean up goops.h, a little. * libguile/goops.h: * libguile/goops.c: Also clean up. * module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset index.
2009-11-03 23:59:51 +01:00
SCM_STRUCT_DATA (new)[scm_vtable_index_self] = SCM_UNPACK (new);
}
2005-03-02 20:42:01 +00:00
SCM_CRITICAL_SECTION_END;
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_invalidate_class, "%invalidate-class", 1, 0, 0,
(SCM class),
"")
#define FUNC_NAME s_scm_sys_invalidate_class
{
2000-12-16 20:25:08 +00:00
SCM_VALIDATE_CLASS (1, class);
SCM_CLEAR_CLASS_FLAGS (class, SCM_CLASSF_GOOPS_VALID);
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/* When instances change class, they finally get a new body, but
* before that, they go through purgatory in hell. Odd as it may
* seem, this data structure saves us from eternal suffering in
* infinite recursions.
*/
2001-06-14 19:50:43 +00:00
static scm_t_bits **hell;
static long n_hell = 1; /* one place for the evil one himself */
static long hell_size = 4;
static SCM hell_mutex;
static long
burnin (SCM o)
{
long i;
for (i = 1; i < n_hell; ++i)
2001-07-18 10:14:29 +00:00
if (SCM_STRUCT_DATA (o) == hell[i])
return i;
return 0;
}
static void
go_to_hell (void *o)
{
SCM obj = *(SCM*)o;
scm_lock_mutex (hell_mutex);
if (n_hell >= hell_size)
{
hell_size *= 2;
hell = scm_realloc (hell, hell_size * sizeof(*hell));
}
2001-07-18 10:14:29 +00:00
hell[n_hell++] = SCM_STRUCT_DATA (obj);
scm_unlock_mutex (hell_mutex);
}
static void
go_to_heaven (void *o)
{
SCM obj = *(SCM*)o;
scm_lock_mutex (hell_mutex);
hell[burnin (obj)] = hell[--n_hell];
scm_unlock_mutex (hell_mutex);
}
2001-07-18 10:14:29 +00:00
SCM_SYMBOL (scm_sym_change_class, "change-class");
static SCM
purgatory (SCM obj, SCM new_class)
{
return scm_call_2 (SCM_VARIABLE_REF (var_change_class), obj, new_class);
}
/* This function calls the generic function change-class for all
* instances which aren't currently undergoing class change.
*/
void
scm_change_object_class (SCM obj, SCM old_class SCM_UNUSED, SCM new_class)
{
if (!burnin (obj))
{
scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE);
scm_dynwind_rewind_handler (go_to_hell, &obj, SCM_F_WIND_EXPLICITLY);
scm_dynwind_unwind_handler (go_to_heaven, &obj, SCM_F_WIND_EXPLICITLY);
purgatory (obj, new_class);
scm_dynwind_end ();
}
}
/******************************************************************************
*
* GGGG FFFFF
* G F
* G GG FFF
* G G F
* GGG E N E R I C F U N C T I O N S
*
* This implementation provides
* - generic functions (with class specializers)
* - multi-methods
* - next-method
* - a hard-coded MOP for standard gf, which can be overloaded for non-std gf
*
******************************************************************************/
SCM_KEYWORD (k_name, "name");
SCM_GLOBAL_SYMBOL (scm_sym_args, "args");
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_generic_capability_p, "generic-capability?", 1, 0, 0,
(SCM proc),
"")
#define FUNC_NAME s_scm_generic_capability_p
{
SCM_ASSERT (scm_is_true (scm_procedure_p (proc)),
2000-12-16 20:25:08 +00:00
proc, SCM_ARG1, FUNC_NAME);
return (SCM_PRIMITIVE_GENERIC_P (proc) ? SCM_BOOL_T : SCM_BOOL_F);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_enable_primitive_generic_x, "enable-primitive-generic!", 0, 0, 1,
(SCM subrs),
"")
#define FUNC_NAME s_scm_enable_primitive_generic_x
{
2001-07-18 10:14:29 +00:00
SCM_VALIDATE_REST_ARGUMENT (subrs);
2004-09-22 17:41:37 +00:00
while (!scm_is_null (subrs))
{
SCM subr = SCM_CAR (subrs);
SCM_ASSERT (SCM_PRIMITIVE_GENERIC_P (subr), subr, SCM_ARGn, FUNC_NAME);
foreign.h presents a more pointer-centric interface * libguile/foreign.c: * libguile/foreign.h: Rework interface to be more pointer-centric. Details are: (SCM_FOREIGN_TYPE_STRUCT, SCM_FOREIGN_TYPE_POINTER): Removed; now the pointer in a foreign is first-class. If it points to a native type like uint32, then it still has a tag; but if it points to something else, like a struct or a pointer or something, then its type is VOID (i.e., void*). (SCM_FOREIGN_POINTER): Rename from SCM_FOREIGN_OBJECT. (SCM_FOREIGN_VALUE_REF, SCM_FOREIGN_VALUE_SET): Rename from SCM_FOREIGN_OBJECT_REF and SCM_FOREIGN_OBJECT_SET, to indicate that they only work with value types. (SCM_FOREIGN_HAS_FINALIZER): Reserve a bit to indicate if the foreign pointer in question has a finalizer registered. (SCM_FOREIGN_LEN): For void* pointers, optionally store the length in bytes of the associated memory region. (SCM_FOREIGN_VALUE_P): Rename from SCM_FOREIGN_SIMPLE_P. (SCM_VALIDATE_FOREIGN_VALUE): Rename from SCM_VALIDATE_FOREIGN_SIMPLE. (scm_take_foreign_pointer): Rename from scm_c_take_foreign. Remove scm_c_from_foreign. (scm_foreign_type): New accessor. (scm_foreign_ref, scm_foreign_set_x): Take some optional args, used when dereferencing void pointers. * libguile/dynl.h: * libguile/dynl.c (scm_dynamic_pointer): New function, used by scm_dynamic_func. Adapt code to foreign.h changes. * libguile/goops.c (scm_enable_primitive_generic_x) (scm_set_primitive_generic_x): Use the SCM_SET_SUBR_GENERIC macro. * libguile/gsubr.c (create_gsubr): Adapt to API change. * libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_GENERIC): Store the pointer directly, not indirected. * libguile/snarf.h (SCM_DEFINE, SCM_IMMUTABLE_FOREIGN): Store subr pointers directly. Adapt to SCM_FOREIGN_TYPE_VOID change. * libguile/vm-i-system.c (subr-call): Access the void* directly.
2010-01-18 11:42:35 +01:00
SCM_SET_SUBR_GENERIC (subr,
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-06 14:16:03 -05:00
scm_make (scm_list_3 (class_generic,
foreign.h presents a more pointer-centric interface * libguile/foreign.c: * libguile/foreign.h: Rework interface to be more pointer-centric. Details are: (SCM_FOREIGN_TYPE_STRUCT, SCM_FOREIGN_TYPE_POINTER): Removed; now the pointer in a foreign is first-class. If it points to a native type like uint32, then it still has a tag; but if it points to something else, like a struct or a pointer or something, then its type is VOID (i.e., void*). (SCM_FOREIGN_POINTER): Rename from SCM_FOREIGN_OBJECT. (SCM_FOREIGN_VALUE_REF, SCM_FOREIGN_VALUE_SET): Rename from SCM_FOREIGN_OBJECT_REF and SCM_FOREIGN_OBJECT_SET, to indicate that they only work with value types. (SCM_FOREIGN_HAS_FINALIZER): Reserve a bit to indicate if the foreign pointer in question has a finalizer registered. (SCM_FOREIGN_LEN): For void* pointers, optionally store the length in bytes of the associated memory region. (SCM_FOREIGN_VALUE_P): Rename from SCM_FOREIGN_SIMPLE_P. (SCM_VALIDATE_FOREIGN_VALUE): Rename from SCM_VALIDATE_FOREIGN_SIMPLE. (scm_take_foreign_pointer): Rename from scm_c_take_foreign. Remove scm_c_from_foreign. (scm_foreign_type): New accessor. (scm_foreign_ref, scm_foreign_set_x): Take some optional args, used when dereferencing void pointers. * libguile/dynl.h: * libguile/dynl.c (scm_dynamic_pointer): New function, used by scm_dynamic_func. Adapt code to foreign.h changes. * libguile/goops.c (scm_enable_primitive_generic_x) (scm_set_primitive_generic_x): Use the SCM_SET_SUBR_GENERIC macro. * libguile/gsubr.c (create_gsubr): Adapt to API change. * libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_GENERIC): Store the pointer directly, not indirected. * libguile/snarf.h (SCM_DEFINE, SCM_IMMUTABLE_FOREIGN): Store subr pointers directly. Adapt to SCM_FOREIGN_TYPE_VOID change. * libguile/vm-i-system.c (subr-call): Access the void* directly.
2010-01-18 11:42:35 +01:00
k_name,
SCM_SUBR_NAME (subr))));
subrs = SCM_CDR (subrs);
}
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
SCM_DEFINE (scm_set_primitive_generic_x, "set-primitive-generic!", 2, 0, 0,
(SCM subr, SCM generic),
"")
#define FUNC_NAME s_scm_set_primitive_generic_x
{
SCM_ASSERT (SCM_PRIMITIVE_GENERIC_P (subr), subr, SCM_ARG1, FUNC_NAME);
SCM_ASSERT (SCM_PUREGENERICP (generic), generic, SCM_ARG2, FUNC_NAME);
foreign.h presents a more pointer-centric interface * libguile/foreign.c: * libguile/foreign.h: Rework interface to be more pointer-centric. Details are: (SCM_FOREIGN_TYPE_STRUCT, SCM_FOREIGN_TYPE_POINTER): Removed; now the pointer in a foreign is first-class. If it points to a native type like uint32, then it still has a tag; but if it points to something else, like a struct or a pointer or something, then its type is VOID (i.e., void*). (SCM_FOREIGN_POINTER): Rename from SCM_FOREIGN_OBJECT. (SCM_FOREIGN_VALUE_REF, SCM_FOREIGN_VALUE_SET): Rename from SCM_FOREIGN_OBJECT_REF and SCM_FOREIGN_OBJECT_SET, to indicate that they only work with value types. (SCM_FOREIGN_HAS_FINALIZER): Reserve a bit to indicate if the foreign pointer in question has a finalizer registered. (SCM_FOREIGN_LEN): For void* pointers, optionally store the length in bytes of the associated memory region. (SCM_FOREIGN_VALUE_P): Rename from SCM_FOREIGN_SIMPLE_P. (SCM_VALIDATE_FOREIGN_VALUE): Rename from SCM_VALIDATE_FOREIGN_SIMPLE. (scm_take_foreign_pointer): Rename from scm_c_take_foreign. Remove scm_c_from_foreign. (scm_foreign_type): New accessor. (scm_foreign_ref, scm_foreign_set_x): Take some optional args, used when dereferencing void pointers. * libguile/dynl.h: * libguile/dynl.c (scm_dynamic_pointer): New function, used by scm_dynamic_func. Adapt code to foreign.h changes. * libguile/goops.c (scm_enable_primitive_generic_x) (scm_set_primitive_generic_x): Use the SCM_SET_SUBR_GENERIC macro. * libguile/gsubr.c (create_gsubr): Adapt to API change. * libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_GENERIC): Store the pointer directly, not indirected. * libguile/snarf.h (SCM_DEFINE, SCM_IMMUTABLE_FOREIGN): Store subr pointers directly. Adapt to SCM_FOREIGN_TYPE_VOID change. * libguile/vm-i-system.c (subr-call): Access the void* directly.
2010-01-18 11:42:35 +01:00
SCM_SET_SUBR_GENERIC (subr, generic);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_primitive_generic_generic, "primitive-generic-generic", 1, 0, 0,
(SCM subr),
"")
#define FUNC_NAME s_scm_primitive_generic_generic
{
if (SCM_PRIMITIVE_GENERIC_P (subr))
{
if (!SCM_UNPACK (*SCM_SUBR_GENERIC (subr)))
scm_enable_primitive_generic_x (scm_list_1 (subr));
return *SCM_SUBR_GENERIC (subr);
}
2001-03-04 17:09:34 +00:00
SCM_WRONG_TYPE_ARG (SCM_ARG1, subr);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
typedef struct t_extension {
struct t_extension *next;
SCM extended;
SCM extension;
} t_extension;
/* Hint for `scm_gc_malloc ()' et al. when allocating `t_extension'
objects. */
static const char extension_gc_hint[] = "GOOPS extension";
static t_extension *extensions = 0;
void
scm_c_extend_primitive_generic (SCM extended, SCM extension)
{
if (goops_loaded_p)
{
SCM gf, gext;
if (!SCM_UNPACK (*SCM_SUBR_GENERIC (extended)))
scm_enable_primitive_generic_x (scm_list_1 (extended));
gf = *SCM_SUBR_GENERIC (extended);
gext = scm_call_2 (SCM_VARIABLE_REF (scm_var_make_extended_generic),
gf,
SCM_SUBR_NAME (extension));
SCM_SET_SUBR_GENERIC (extension, gext);
}
else
{
t_extension *e = scm_gc_malloc (sizeof (t_extension),
extension_gc_hint);
t_extension **loc = &extensions;
/* Make sure that extensions are placed before their own
* extensions in the extensions list. O(N^2) algorithm, but
* extensions of primitive generics are rare.
*/
while (*loc && !scm_is_eq (extension, (*loc)->extended))
loc = &(*loc)->next;
e->next = *loc;
e->extended = extended;
e->extension = extension;
*loc = e;
}
}
static void
setup_extended_primitive_generics ()
{
while (extensions)
{
t_extension *e = extensions;
scm_c_extend_primitive_generic (e->extended, e->extension);
extensions = e->next;
}
}
/* Dirk:FIXME:: In all of these scm_wta_dispatch_* routines it is
* assumed that 'gf' is zero if uninitialized. It would be cleaner if
* some valid SCM value like SCM_BOOL_F or SCM_UNDEFINED were chosen.
*/
SCM
scm_wta_dispatch_0 (SCM gf, const char *subr)
{
if (!SCM_UNPACK (gf))
scm_error_num_args_subr (subr);
return scm_call_0 (gf);
}
SCM
scm_wta_dispatch_1 (SCM gf, SCM a1, int pos, const char *subr)
{
if (!SCM_UNPACK (gf))
scm_wrong_type_arg (subr, pos, a1);
return scm_call_1 (gf, a1);
}
SCM
scm_wta_dispatch_2 (SCM gf, SCM a1, SCM a2, int pos, const char *subr)
{
if (!SCM_UNPACK (gf))
scm_wrong_type_arg (subr, pos, (pos == SCM_ARG1) ? a1 : a2);
return scm_call_2 (gf, a1, a2);
}
SCM
scm_wta_dispatch_n (SCM gf, SCM args, int pos, const char *subr)
{
if (!SCM_UNPACK (gf))
scm_wrong_type_arg (subr, pos, scm_list_ref (args, scm_from_int (pos)));
return scm_apply_0 (gf, args);
}
/******************************************************************************
*
* Protocol for calling a generic fumction
* This protocol is roughly equivalent to (parameter are a little bit different
* for efficiency reasons):
*
* + apply-generic (gf args)
* + compute-applicable-methods (gf args ...)
* + sort-applicable-methods (methods args)
* + apply-methods (gf methods args)
*
* apply-methods calls make-next-method to build the "continuation" of a a
* method. Applying a next-method will call apply-next-method which in
* turn will call apply again to call effectively the following method.
*
******************************************************************************/
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_make, "make", 0, 0, 1,
(SCM args),
"Make a new object. @var{args} must contain the class and\n"
"all necessary initialization information.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_make
{
return scm_apply_0 (scm_variable_ref (var_make), args);
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/**********************************************************************
*
* Smob classes
*
**********************************************************************/
static SCM
make_class_name (const char *prefix, const char *type_name, const char *suffix)
{
if (!type_name)
type_name = "";
return scm_string_to_symbol (scm_string_append
(scm_list_3 (scm_from_utf8_string (prefix),
scm_from_utf8_string (type_name),
scm_from_utf8_string (suffix))));
}
SCM
scm_make_extended_class (char const *type_name, int applicablep)
{
SCM name, meta, supers;
name = make_class_name ("<", type_name, ">");
meta = class_class;
if (applicablep)
supers = scm_list_1 (class_applicable);
else
supers = scm_list_1 (class_top);
return scm_make_standard_class (meta, name, supers, SCM_EOL);
}
void
scm_i_inherit_applicable (SCM c)
{
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-06 14:16:03 -05:00
if (!SCM_SUBCLASSP (c, class_applicable))
{
SCM dsupers = SCM_SLOT (c, scm_si_direct_supers);
SCM cpl = SCM_SLOT (c, scm_si_cpl);
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-06 14:16:03 -05:00
/* patch class_applicable into direct-supers */
SCM top = scm_c_memq (class_top, dsupers);
if (scm_is_false (top))
dsupers = scm_append (scm_list_2 (dsupers,
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-06 14:16:03 -05:00
scm_list_1 (class_applicable)));
else
{
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-06 14:16:03 -05:00
SCM_SETCAR (top, class_applicable);
SCM_SETCDR (top, scm_cons (class_top, SCM_CDR (top)));
}
SCM_SET_SLOT (c, scm_si_direct_supers, dsupers);
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-06 14:16:03 -05:00
/* patch class_applicable into cpl */
top = scm_c_memq (class_top, cpl);
if (scm_is_false (top))
abort ();
else
{
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-06 14:16:03 -05:00
SCM_SETCAR (top, class_applicable);
SCM_SETCDR (top, scm_cons (class_top, SCM_CDR (top)));
}
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-06 14:16:03 -05:00
/* add class to direct-subclasses of class_applicable */
SCM_SET_SLOT (class_applicable,
scm_si_direct_subclasses,
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-06 14:16:03 -05:00
scm_cons (c, SCM_SLOT (class_applicable,
scm_si_direct_subclasses)));
}
}
static void
create_smob_classes (void)
{
long i;
for (i = 0; i < SCM_I_MAX_SMOB_TYPE_COUNT; ++i)
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-06 14:16:03 -05:00
scm_i_smob_class[i] = SCM_BOOL_F;
for (i = 0; i < scm_numsmob; ++i)
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-06 14:16:03 -05:00
if (scm_is_false (scm_i_smob_class[i]))
scm_i_smob_class[i] = scm_make_extended_class (SCM_SMOBNAME (i),
scm_smobs[i].apply != 0);
}
void
scm_make_port_classes (long ptobnum, char *type_name)
{
SCM name, meta, super, supers;
meta = class_class;
name = make_class_name ("<", type_name, "-port>");
supers = scm_list_1 (class_port);
super = scm_make_standard_class (meta, name, supers, SCM_EOL);
name = make_class_name ("<", type_name, "-input-port>");
supers = scm_list_2 (super, class_input_port);
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-06 14:16:03 -05:00
scm_i_port_class[SCM_IN_PCLASS_INDEX + ptobnum]
= scm_make_standard_class (meta, name, supers, SCM_EOL);
name = make_class_name ("<", type_name, "-output-port>");
supers = scm_list_2 (super, class_output_port);
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-06 14:16:03 -05:00
scm_i_port_class[SCM_OUT_PCLASS_INDEX + ptobnum]
= scm_make_standard_class (meta, name, supers, SCM_EOL);
name = make_class_name ("<", type_name, "-input-output-port>");
supers = scm_list_2 (super, class_input_output_port);
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-06 14:16:03 -05:00
scm_i_port_class[SCM_INOUT_PCLASS_INDEX + ptobnum]
= scm_make_standard_class (meta, name, supers, SCM_EOL);
}
static void
create_port_classes (void)
{
long i;
for (i = scm_c_num_port_types () - 1; i >= 0; i--)
scm_make_port_classes (i, SCM_PTOBNAME (i));
}
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-06 13:41:56 -05:00
SCM
scm_i_define_class_for_vtable (SCM vtable)
{
SCM class;
scm_i_pthread_mutex_lock (&scm_i_misc_mutex);
if (scm_is_false (vtable_class_map))
vtable_class_map = scm_c_make_weak_table (0, SCM_WEAK_TABLE_KIND_KEY);
scm_i_pthread_mutex_unlock (&scm_i_misc_mutex);
if (scm_is_false (scm_struct_vtable_p (vtable)))
abort ();
class = scm_weak_table_refq (vtable_class_map, vtable, SCM_BOOL_F);
if (scm_is_false (class))
{
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-06 14:16:03 -05:00
if (SCM_UNPACK (class_class))
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-06 13:41:56 -05:00
{
SCM name, meta, supers;
name = SCM_VTABLE_NAME (vtable);
if (scm_is_symbol (name))
name = scm_string_to_symbol
(scm_string_append
(scm_list_3 (scm_from_latin1_string ("<"),
scm_symbol_to_string (name),
scm_from_latin1_string (">"))));
else
name = scm_from_latin1_symbol ("<>");
if (SCM_STRUCT_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SETTER))
{
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-06 14:16:03 -05:00
meta = class_applicable_struct_with_setter_class;
supers = scm_list_1 (class_applicable_struct_with_setter);
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-06 13:41:56 -05:00
}
else if (SCM_STRUCT_VTABLE_FLAG_IS_SET (vtable,
SCM_VTABLE_FLAG_APPLICABLE))
{
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-06 14:16:03 -05:00
meta = class_applicable_struct_class;
supers = scm_list_1 (class_applicable_struct);
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-06 13:41:56 -05:00
}
else
{
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-06 14:16:03 -05:00
meta = class_class;
supers = scm_list_1 (class_top);
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-06 13:41:56 -05:00
}
return scm_make_standard_class (meta, name, supers, SCM_EOL);
}
else
/* `create_struct_classes' will fill this in later. */
class = SCM_BOOL_F;
/* Don't worry about races. This only happens when creating a
vtable, which happens by definition in one thread. */
scm_weak_table_putq_x (vtable_class_map, vtable, class);
}
return class;
}
static SCM
make_struct_class (void *closure SCM_UNUSED,
SCM vtable, SCM data, SCM prev SCM_UNUSED)
{
if (scm_is_false (data))
scm_i_define_class_for_vtable (vtable);
return SCM_UNSPECIFIED;
}
static void
create_struct_classes (void)
{
/* FIXME: take the vtable_class_map while initializing goops? */
scm_internal_hash_fold (make_struct_class, 0, SCM_BOOL_F,
vtable_class_map);
}
/**********************************************************************
*
* C interface
*
**********************************************************************/
void
scm_load_goops ()
{
if (!goops_loaded_p)
scm_c_resolve_module ("oop goops");
}
SCM_KEYWORD (k_setter, "setter");
SCM
scm_ensure_accessor (SCM name)
{
SCM var, gf;
var = scm_module_variable (scm_current_module (), name);
if (SCM_VARIABLEP (var) && !SCM_UNBNDP (SCM_VARIABLE_REF (var)))
gf = SCM_VARIABLE_REF (var);
else
gf = SCM_BOOL_F;
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-06 14:16:03 -05:00
if (!SCM_IS_A_P (gf, class_accessor))
{
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-06 14:16:03 -05:00
gf = scm_make (scm_list_3 (class_generic, k_name, name));
gf = scm_make (scm_list_5 (class_accessor,
k_name, name, k_setter, gf));
}
return gf;
}
#ifdef GUILE_DEBUG
/*
* Debugging utilities
*/
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_pure_generic_p, "pure-generic?", 1, 0, 0,
(SCM obj),
"Return @code{#t} if @var{obj} is a pure generic.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_pure_generic_p
{
return scm_from_bool (SCM_PUREGENERICP (obj));
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
#endif /* GUILE_DEBUG */
/*
* Initialization
*/
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-06 13:41:56 -05:00
SCM_DEFINE (scm_sys_bless_applicable_struct_vtables_x, "%bless-applicable-struct-vtables!", 2, 0, 0,
(SCM applicable, SCM setter),
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-04 13:41:09 -05:00
"")
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-06 13:41:56 -05:00
#define FUNC_NAME s_scm_sys_bless_applicable_struct_vtables_x
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-04 13:41:09 -05:00
{
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-06 13:41:56 -05:00
SCM_VALIDATE_CLASS (1, applicable);
SCM_VALIDATE_CLASS (2, setter);
SCM_SET_VTABLE_FLAGS (applicable, SCM_VTABLE_FLAG_APPLICABLE_VTABLE);
SCM_SET_VTABLE_FLAGS (setter, SCM_VTABLE_FLAG_SETTER_VTABLE);
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-04 13:41:09 -05:00
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
SCM_DEFINE (scm_sys_bless_pure_generic_vtable_x, "%bless-pure-generic-vtable!", 1, 0, 0,
(SCM vtable),
"")
#define FUNC_NAME s_scm_sys_bless_pure_generic_vtable_x
{
SCM_VALIDATE_CLASS (1, vtable);
SCM_SET_CLASS_FLAGS (vtable, SCM_CLASSF_PURE_GENERIC);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
SCM_DEFINE (scm_sys_goops_early_init, "%goops-early-init", 0, 0, 0,
(),
"")
#define FUNC_NAME s_scm_sys_goops_early_init
{
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-04 13:41:09 -05:00
var_make_standard_class = scm_c_lookup ("make-standard-class");
var_make = scm_c_lookup ("make");
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-04 13:41:09 -05:00
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-06 14:16:03 -05:00
class_class = scm_variable_ref (scm_c_lookup ("<class>"));
class_top = scm_variable_ref (scm_c_lookup ("<top>"));
class_object = scm_variable_ref (scm_c_lookup ("<object>"));
class_foreign_slot = scm_variable_ref (scm_c_lookup ("<foreign-slot>"));
class_protected = scm_variable_ref (scm_c_lookup ("<protected-slot>"));
class_hidden = scm_variable_ref (scm_c_lookup ("<hidden-slot>"));
class_opaque = scm_variable_ref (scm_c_lookup ("<opaque-slot>"));
class_read_only = scm_variable_ref (scm_c_lookup ("<read-only-slot>"));
class_self = scm_variable_ref (scm_c_lookup ("<self-slot>"));
class_protected_opaque = scm_variable_ref (scm_c_lookup ("<protected-opaque-slot>"));
class_protected_hidden = scm_variable_ref (scm_c_lookup ("<protected-hidden-slot>"));
class_protected_read_only = scm_variable_ref (scm_c_lookup ("<protected-read-only-slot>"));
class_scm = scm_variable_ref (scm_c_lookup ("<scm-slot>"));
class_int = scm_variable_ref (scm_c_lookup ("<int-slot>"));
class_float = scm_variable_ref (scm_c_lookup ("<float-slot>"));
class_double = scm_variable_ref (scm_c_lookup ("<double-slot>"));
/* Applicables */
class_procedure_class = scm_variable_ref (scm_c_lookup ("<procedure-class>"));
class_applicable_struct_class = scm_variable_ref (scm_c_lookup ("<applicable-struct-class>"));
class_applicable_struct_with_setter_class =
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-06 13:41:56 -05:00
scm_variable_ref (scm_c_lookup ("<applicable-struct-with-setter-class>"));
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-04 13:41:09 -05:00
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-06 14:16:03 -05:00
class_method = scm_variable_ref (scm_c_lookup ("<method>"));
class_accessor_method = scm_variable_ref (scm_c_lookup ("<accessor-method>"));
class_applicable = scm_variable_ref (scm_c_lookup ("<applicable>"));
class_applicable_struct = scm_variable_ref (scm_c_lookup ("<applicable-struct>"));
class_applicable_struct_with_setter = scm_variable_ref (scm_c_lookup ("<applicable-struct-with-setter>"));
class_generic = scm_variable_ref (scm_c_lookup ("<generic>"));
class_extended_generic = scm_variable_ref (scm_c_lookup ("<extended-generic>"));
class_generic_with_setter = scm_variable_ref (scm_c_lookup ("<generic-with-setter>"));
class_accessor = scm_variable_ref (scm_c_lookup ("<accessor>"));
class_extended_generic_with_setter = scm_variable_ref (scm_c_lookup ("<extended-generic-with-setter>"));
class_extended_accessor = scm_variable_ref (scm_c_lookup ("<extended-accessor>"));
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-04 13:41:09 -05:00
/* Primitive types classes */
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-06 14:16:03 -05:00
class_boolean = scm_variable_ref (scm_c_lookup ("<boolean>"));
class_char = scm_variable_ref (scm_c_lookup ("<char>"));
class_list = scm_variable_ref (scm_c_lookup ("<list>"));
class_pair = scm_variable_ref (scm_c_lookup ("<pair>"));
class_null = scm_variable_ref (scm_c_lookup ("<null>"));
class_string = scm_variable_ref (scm_c_lookup ("<string>"));
class_symbol = scm_variable_ref (scm_c_lookup ("<symbol>"));
class_vector = scm_variable_ref (scm_c_lookup ("<vector>"));
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-04 13:41:09 -05:00
class_foreign = scm_variable_ref (scm_c_lookup ("<foreign>"));
class_hashtable = scm_variable_ref (scm_c_lookup ("<hashtable>"));
class_fluid = scm_variable_ref (scm_c_lookup ("<fluid>"));
class_dynamic_state = scm_variable_ref (scm_c_lookup ("<dynamic-state>"));
class_frame = scm_variable_ref (scm_c_lookup ("<frame>"));
class_vm_cont = scm_variable_ref (scm_c_lookup ("<vm-continuation>"));
class_bytevector = scm_variable_ref (scm_c_lookup ("<bytevector>"));
class_uvec = scm_variable_ref (scm_c_lookup ("<uvec>"));
class_array = scm_variable_ref (scm_c_lookup ("<array>"));
class_bitvector = scm_variable_ref (scm_c_lookup ("<bitvector>"));
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-06 14:16:03 -05:00
class_number = scm_variable_ref (scm_c_lookup ("<number>"));
class_complex = scm_variable_ref (scm_c_lookup ("<complex>"));
class_real = scm_variable_ref (scm_c_lookup ("<real>"));
class_integer = scm_variable_ref (scm_c_lookup ("<integer>"));
class_fraction = scm_variable_ref (scm_c_lookup ("<fraction>"));
class_keyword = scm_variable_ref (scm_c_lookup ("<keyword>"));
class_unknown = scm_variable_ref (scm_c_lookup ("<unknown>"));
class_procedure = scm_variable_ref (scm_c_lookup ("<procedure>"));
class_primitive_generic = scm_variable_ref (scm_c_lookup ("<primitive-generic>"));
class_port = scm_variable_ref (scm_c_lookup ("<port>"));
class_input_port = scm_variable_ref (scm_c_lookup ("<input-port>"));
class_output_port = scm_variable_ref (scm_c_lookup ("<output-port>"));
class_input_output_port = scm_variable_ref (scm_c_lookup ("<input-output-port>"));
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-04 13:41:09 -05:00
create_smob_classes ();
create_struct_classes ();
create_port_classes ();
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_goops_loaded, "%goops-loaded", 0, 0, 0,
(),
"Announce that GOOPS is loaded and perform initialization\n"
"on the C level which depends on the loaded GOOPS modules.")
2000-12-16 20:25:08 +00:00
#define FUNC_NAME s_scm_sys_goops_loaded
{
goops_loaded_p = 1;
var_class_name = scm_c_lookup ("class-name");
var_class_direct_supers = scm_c_lookup ("class-direct-supers");
var_class_direct_slots = scm_c_lookup ("class-direct-slots");
var_class_direct_subclasses = scm_c_lookup ("class-direct-subclasses");
var_class_direct_methods = scm_c_lookup ("class-direct-methods");
var_class_precedence_list = scm_c_lookup ("class-precedence-list");
var_class_slots = scm_c_lookup ("class-slots");
var_generic_function_methods = scm_c_lookup ("generic-function-methods");
var_method_generic_function = scm_c_lookup ("method-generic-function");
var_method_specializers = scm_c_lookup ("method-specializers");
var_method_procedure = scm_c_lookup ("method-procedure");
var_slot_unbound =
scm_module_variable (scm_module_goops, sym_slot_unbound);
var_slot_missing =
scm_module_variable (scm_module_goops, sym_slot_missing);
var_change_class =
scm_module_variable (scm_module_goops, sym_change_class);
setup_extended_primitive_generics ();
#if (SCM_ENABLE_DEPRECATED == 1)
scm_init_deprecated_goops ();
#endif
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
SCM scm_module_goops;
static void
scm_init_goops_builtins (void *unused)
{
scm_module_goops = scm_current_module ();
hell = scm_calloc (hell_size * sizeof (*hell));
hell_mutex = scm_make_mutex ();
#include "libguile/goops.x"
}
void
scm_init_goops ()
{
scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION,
"scm_init_goops_builtins", scm_init_goops_builtins,
NULL);
}
2000-12-01 16:05:33 +00:00
/*
Local Variables:
c-file-style: "gnu"
End:
*/