guile/libguile/goops.c

1044 lines
31 KiB
C
Raw Normal View History

/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011,2012,2013,2014,2015,2017
* 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/ports-internal.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"
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. */
SCM_KEYWORD (k_name, "name");
SCM_KEYWORD (k_setter, "setter");
SCM_SYMBOL (sym_redefined, "redefined");
SCM_GLOBAL_SYMBOL (scm_sym_args, "args");
static int goops_loaded_p = 0;
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 var_make_standard_class = SCM_BOOL_F;
static SCM var_migrate_instance = SCM_BOOL_F;
static SCM var_make = SCM_BOOL_F;
static SCM var_inherit_applicable = 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;
static SCM var_slot_ref = SCM_BOOL_F;
static SCM var_slot_set_x = SCM_BOOL_F;
static SCM var_slot_bound_p = SCM_BOOL_F;
static SCM var_slot_exists_p = SCM_BOOL_F;
/* 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_syntax;
static SCM class_atomic_box;
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_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;
/* 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];
SCM scm_module_goops;
static SCM scm_sys_make_vtable_vtable (SCM layout);
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_init_layout_x (SCM class, SCM layout);
static SCM scm_sys_clear_fields_x (SCM obj, SCM unbound);
static SCM scm_sys_goops_early_init (void);
2000-12-16 20:25:08 +00:00
static SCM scm_sys_goops_loaded (void);
SCM_DEFINE (scm_sys_make_vtable_vtable, "%make-vtable-vtable", 1, 0, 0,
(SCM layout),
"")
#define FUNC_NAME s_scm_sys_make_vtable_vtable
{
return scm_i_make_vtable_vtable (layout);
}
#undef FUNC_NAME
SCM
scm_make_standard_class (SCM meta, SCM name, SCM dsupers, SCM dslots)
{
return scm_call_4 (scm_variable_ref (var_make_standard_class),
meta, name, dsupers, dslots);
}
SCM_DEFINE (scm_sys_init_layout_x, "%init-layout!", 2, 0, 0,
(SCM class, SCM layout),
"")
#define FUNC_NAME s_scm_sys_init_layout_x
{
SCM_VALIDATE_INSTANCE (1, class);
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));
scm_i_struct_inherit_vtable_magic (SCM_CLASS_OF (class), class);
SCM_SET_CLASS_FLAGS (class, SCM_CLASSF_GOOPS_OR_VALID);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
/* 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_syntax:
return class_syntax;
case scm_tc7_atomic_box:
return class_atomic_box;
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:
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
{
scm_t_port_type *ptob = SCM_PORT_TYPE (x);
if (SCM_INPUT_PORT_P (x))
{
if (SCM_OUTPUT_PORT_P (x))
return ptob->input_output_class;
return ptob->input_class;
}
return ptob->output_class;
}
case scm_tcs_struct:
if (SCM_OBJ_CLASS_FLAGS (x) & SCM_CLASSF_GOOPS_VALID)
/* A GOOPS object with a valid class. */
return SCM_CLASS_OF (x);
else if (SCM_OBJ_CLASS_FLAGS (x) & SCM_CLASSF_GOOPS)
/* A GOOPS object whose class might have been redefined;
try to migrate it over to the new class. */
{
scm_call_1 (scm_variable_ref (var_migrate_instance), x);
/* At this point, either the migration succeeded, in which
case SCM_CLASS_OF is the new class, or the migration
failed because it's already in progress on the current
thread, in which case we want to return the old class
for the time being. SCM_CLASS_OF (x) is the right
answer for both cases. */
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
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
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);
}
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
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);
}
SCM
scm_slot_ref (SCM obj, SCM slot_name)
{
return scm_call_2 (scm_variable_ref (var_slot_ref), obj, slot_name);
}
SCM
scm_slot_set_x (SCM obj, SCM slot_name, SCM value)
{
return scm_call_3 (scm_variable_ref (var_slot_set_x), obj, slot_name, value);
}
SCM
scm_slot_bound_p (SCM obj, SCM slot_name)
{
return scm_call_2 (scm_variable_ref (var_slot_bound_p), obj, slot_name);
}
SCM
scm_slot_exists_p (SCM obj, SCM slot_name)
{
return scm_call_2 (scm_variable_ref (var_slot_exists_p), obj, slot_name);
}
SCM_DEFINE (scm_sys_clear_fields_x, "%clear-fields!", 2, 0, 0,
(SCM obj, SCM unbound),
"")
#define FUNC_NAME s_scm_sys_clear_fields_x
{
scm_t_signed_bits n, i;
SCM vtable, layout;
SCM_VALIDATE_STRUCT (1, obj);
vtable = SCM_STRUCT_VTABLE (obj);
n = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
layout = SCM_VTABLE_LAYOUT (vtable);
/* Set all SCM-holding slots to the GOOPS unbound value. */
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
for (i = 0; i < n; i++)
if (scm_i_symbol_ref (layout, i*2) == 'p')
SCM_STRUCT_SLOT_SET (obj, i, unbound);
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
static scm_i_pthread_mutex_t goops_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_INTERNAL SCM scm_sys_struct_data (SCM);
SCM_DEFINE (scm_sys_struct_data, "%struct-data", 1, 0, 0,
(SCM s),
"Internal function used when migrating classes")
#define FUNC_NAME s_scm_sys_struct_data
{
SCM_VALIDATE_INSTANCE (1, s);
return scm_from_uintptr_t (SCM_CELL_WORD_1 (s));
}
#undef FUNC_NAME
2000-12-16 20:25:08 +00:00
SCM_DEFINE (scm_sys_modify_instance, "%modify-instance", 2, 0, 0,
(SCM old, SCM new),
"Used by change-class to modify objects in place.")
2000-12-16 20:25:08 +00:00
#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".
*/
scm_i_pthread_mutex_lock (&goops_lock);
{
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);
}
scm_i_pthread_mutex_unlock (&goops_lock);
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);
scm_i_pthread_mutex_lock (&goops_lock);
{
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);
}
scm_i_pthread_mutex_unlock (&goops_lock);
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
/* Primitive generics: primitives that can dispatch to generics if their
arguments fail to apply. */
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_GENERICP (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
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);
}
SCM
scm_make (SCM args)
{
return scm_apply_0 (scm_variable_ref (var_make), args);
}
/* SMOB, struct, and port 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)
{
scm_call_1 (scm_variable_ref (var_inherit_applicable), c);
}
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);
}
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
struct pre_goops_port_type
{
scm_t_port_type *ptob;
struct pre_goops_port_type *prev;
};
struct pre_goops_port_type *pre_goops_port_types;
static void
make_port_classes (scm_t_port_type *ptob)
{
SCM name, meta, super, supers;
meta = class_class;
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
name = make_class_name ("<", ptob->name, "-port>");
supers = scm_list_1 (class_port);
super = scm_make_standard_class (meta, name, supers, SCM_EOL);
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
name = make_class_name ("<", ptob->name, "-input-port>");
supers = scm_list_2 (super, class_input_port);
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
ptob->input_class = scm_make_standard_class (meta, name, supers, SCM_EOL);
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
name = make_class_name ("<", ptob->name, "-output-port>");
supers = scm_list_2 (super, class_output_port);
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
ptob->output_class = scm_make_standard_class (meta, name, supers, SCM_EOL);
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
name = make_class_name ("<", ptob->name, "-input-output-port>");
supers = scm_list_2 (super, class_input_output_port);
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
ptob->input_output_class =
scm_make_standard_class (meta, name, supers, SCM_EOL);
}
void
scm_make_port_classes (scm_t_port_type *ptob)
{
ptob->input_class = SCM_BOOL_F;
ptob->output_class = SCM_BOOL_F;
ptob->input_output_class = SCM_BOOL_F;
if (!goops_loaded_p)
{
/* Not really a pair. */
struct pre_goops_port_type *link;
link = scm_gc_typed_calloc (struct pre_goops_port_type);
link->ptob = ptob;
link->prev = pre_goops_port_types;
pre_goops_port_types = link;
return;
}
make_port_classes (ptob);
}
static void
create_port_classes (void)
{
Use heap-allocated port types instead of ptobnums This removes a limitation on the number of port types, simplifies the API, and removes a central point of coordination. * libguile/ports-internal.h (struct scm_t_port_type): Rename from scm_t_ptob_descriptor, now that it's private. Add GOOPS class fields. (struct scm_t_port): Rename from struct scm_port, especially considering that deprecated.h redefines scm_port using the preprocessor :(. * libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE, though the scm_t_port and scm_t_port_type types are incomplete. (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no more typecodes for port types. (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x): Remove. (scm_make_port_type): Return a scm_t_port_type*. All methods adapted to take a scm_t_port_type* instead of a ptobnum. (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type pointer instead of a tag. (scm_new_port_table_entry): Remove; not useful. * libguile/ports.c: Remove things related to the port kind table. Adapt uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use SCM_PORT_TYPE and scm_t_port_type. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/filesys.c: * libguile/fports.c: * libguile/fports.h: * libguile/print.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/strports.h: * libguile/tags.h: * libguile/vports.c: * test-suite/standalone/test-scm-c-read.c: Adapt to change. * libguile/goops.c (scm_class_of, make_port_classes) (scm_make_port_classes, create_port_classes): Adapt to store the classes in the ptob.
2016-05-13 18:23:47 +02:00
while (pre_goops_port_types)
{
make_port_classes (pre_goops_port_types->ptob);
pre_goops_port_types = pre_goops_port_types->prev;
}
}
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
}
class = scm_make_standard_class (meta, name, supers, SCM_EOL);
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
/* `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);
}
void
scm_load_goops ()
{
if (!goops_loaded_p)
scm_c_resolve_module ("oop goops");
}
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;
}
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_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");
var_inherit_applicable = scm_c_lookup ("inherit-applicable!");
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
/* For SCM_SUBCLASSP. */
var_class_precedence_list = scm_c_lookup ("class-precedence-list");
var_slot_ref = scm_c_lookup ("slot-ref");
var_slot_set_x = scm_c_lookup ("slot-set!");
var_slot_bound_p = scm_c_lookup ("slot-bound?");
var_slot_exists_p = scm_c_lookup ("slot-exists?");
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>"));
Introduce <slot> objects in GOOPS * module/oop/goops.scm (fold-class-slots): Change format to use proper slot specifications. (fold-slot-slots): Flesh out with all needed slots. (<class>): Update cons-layout to deal with new fold-class-slots form. Don't create slots; we do that later. (is-a?, get-keyword, *unbound, unbound?, %allocate-instance): Move definitions up. (<slot>, slot?): New definitions. (slot-definition-name, slot-definition-allocation) (slot-definition-init-keyword, slot-definition-init-form) (slot-definition-init-value, slot-definition-init-thunk) (slot-definition-options, slot-definition-getter) (slot-definition-setter, slot-definition-accessor) (slot-definition-slot-ref, slot-definition-slot-set!) (slot-definition-index, slot-definition-size): New definitions as accessors on <slot> objects. (class-slot-definition): Adapt to class-slots change. (direct-slot-definition-class, make-slot): New definitions. (make): Define a boot version that can allocate <slot> instances. (compute-direct-slot-definition) (compute-direct-slot-definition-initargs) (effective-slot-definition-class, compute-effective-slot-definition): New definitions. (build-slots-list): Adapt to slots being <slot> objects. (compute-get-n-set): New boot definition. (allocate-slots): New definition. Replaces compute-getters-n-setters. (%compute-layout, %prep-layout): Adapt to changes. (make-standard-class): Make <slot> objects for direct-slots, and handle the allocate-slots protocol. (<foreign-slot>): Inherit from <slot>. (get-slot-value-using-name, set-slot-value-using-name!) (test-slot-existence): Adapt to using slot definition objects. (make-class): Allow slot specs or <slot> objects as the `slots' argument. (write): New method on <slot>. (class-slot-ref, class-slot-set!): Reimplement. (compute-slot-accessors, compute-getter-method) (compute-setter-method): Adapt to changes. (compute-getters-n-setters): Remove. Yay! (compute-get-n-set): Adapt to use effective slot definitions instead of the getters-n-setters for #:class / #:each-subclass allocation. (%initialize-object): Adapt. (initialize): New method for <slot>. Adapt method for <class>. * module/oop/goops/active-slot.scm (compute-get-n-set): * module/oop/goops/composite-slot.scm (compute-propagated-get-n-set): Use slot-definition-options to access options of slot. * test-suite/tests/goops.test ("bad init-thunk"): Fix to be a "pass-if" instead of an "expect-fail".
2015-01-18 20:53:19 +01:00
class_keyword = scm_variable_ref (scm_c_lookup ("<keyword>"));
class_syntax = scm_variable_ref (scm_c_lookup ("<syntax>"));
class_atomic_box = scm_variable_ref (scm_c_lookup ("<atomic-box>"));
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_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_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_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_migrate_instance = scm_c_lookup ("migrate-instance");
return SCM_UNSPECIFIED;
}
2000-12-16 20:25:08 +00:00
#undef FUNC_NAME
static void
scm_init_goops_builtins (void *unused)
{
scm_module_goops = scm_current_module ();
#include "libguile/goops.x"
scm_c_define ("vtable-flag-vtable",
scm_from_int (SCM_VTABLE_FLAG_VTABLE));
scm_c_define ("vtable-flag-applicable-vtable",
scm_from_int (SCM_VTABLE_FLAG_APPLICABLE_VTABLE));
scm_c_define ("vtable-flag-setter-vtable",
scm_from_int (SCM_VTABLE_FLAG_SETTER_VTABLE));
scm_c_define ("vtable-flag-validated",
scm_from_int (SCM_VTABLE_FLAG_VALIDATED));
scm_c_define ("vtable-flag-goops-class",
scm_from_int (SCM_VTABLE_FLAG_GOOPS_CLASS));
scm_c_define ("vtable-flag-goops-valid",
scm_from_int (SCM_VTABLE_FLAG_GOOPS_VALID));
scm_c_define ("vtable-flag-goops-slot",
scm_from_int (SCM_VTABLE_FLAG_GOOPS_SLOT));
scm_c_define ("vtable-flag-goops-static",
scm_from_int (SCM_VTABLE_FLAG_GOOPS_STATIC));
}
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:
*/