summaryrefslogtreecommitdiff
path: root/module/oop
Commit message (Collapse)AuthorAgeFilesLines
* goops: Preserve all slot options in redefinable classes.David Thompson2021-03-191-7/+9
| | | | | | | * module/goops.scm (compute-slots): Fix <redefinable-class> slot transformation. * test-suite/tests/goops.test ("slot options on redefinable classes"): Add a test.
* Replace libltdl with raw dlopen, dlsymAndy Wingo2021-02-031-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * NEWS: Update. * am/bootstrap.am (SOURCES): * module/Makefile.am (SOURCES): Add system/foreign-library.scm. * configure.ac: Replace ltdl check with -ldl check. * libguile/dynl.c: Rewrite to just expose core dlopen / dlsym / etc to a helper Scheme module. (scm_dynamic_link, scm_dynamic_pointer, scm_dynamic_function) (scm_dynamic_object_p, scm_dynamic_call): Rewrite in terms of (system foreign-library). * libguile/extensions.c (load_extension): Avoid scm_dynamic_call. * module/system/foreign-library.scm: New file. * module/oop/goops.scm (<dynamic-object>): Hackily export <foreign-library> instead of a class here. * doc/ref/api-foreign.texi (Foreign Function Interface): Rewrite to only document the new interfaces. Eventually we will deprecate dynamic-link and friends. * doc/ref/guile.texi (API Reference): Move Foreign Objects after Foreign Function Interface. Seems there should be some closer relationship but this will do for now. * doc/ref/tour.texi (Putting Extensions into Modules): * doc/ref/libguile-parallel.texi (Parallel Installations): Update for rename of Modules and Extensions to Foreign Extensions. * libguile/deprecated.h: * libguile/deprecated.c (scm_dynamic_unlink): Deprecate. * libguile/guile.c: Remove ltdl include. * test-suite/tests/foreign.test: Update tests to use new API, and update error expectations.
* Move copy-tree to (ice-9 copy-tree); deprecate main bindingAndy Wingo2020-09-101-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/ref/api-data.texi (List Constructors): * doc/ref/api-utility.texi (Copying): Update docs to mention module. * libguile.h: Remove trees.h inclusion. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Remove trees.c, trees.h, and related files. * libguile/init.c (scm_i_init_guile): Remove trees.h and the scm_init_trees call. * libguile/trees.c: * libguile/trees.h: Remove. * module/Makefile.am (SOURCES): Add ice-9/copy-tree.scm. * module/ice-9/copy-tree.scm: New file. * module/ice-9/deprecated.scm (copy-tree*): Export as copy-tree, proxying to (ice-9 copy-tree). * module/system/repl/common.scm: * module/web/client.scm: * test-suite/tests/elisp.test: * test-suite/tests/srfi-1.test: * module/oop/goops/save.scm: Use (ice-9 copy-tree). * test-suite/Makefile.am (SCM_TESTS): Add copy-tree.test. * test-suite/tests/copy-tree.test: New file; test pulled from eval.test. * libguile/deprecated.h: * libguile/deprecated.c (scm_copy_tree): Deprecate.
* goops: Fix 'instance?' to work on objects that aren't structs.Mark H Weaver2018-08-071-2/+4
| | | | | | | | Fixes <https://bugs.gnu.org/31606> Reported by Tommi Höynälänmaa <tommi.hoynalanmaa@gmail.com> * module/oop/goops.scm (instance?): Check that OBJ is a struct before applying 'struct-vtable' to it.
* Add new vtable reserved unboxed fieldAndy Wingo2017-09-261-2/+3
| | | | | | | * libguile/struct.h (SCM_VTABLE_BASE_LAYOUT) (scm_vtable_index_reserved_6): Add a reserved field. * module/oop/goops.scm (fold-class-slots, unboxed-slot?): Reserve a new unboxed field.
* Fix GOOPS class redefinition type error.Andy Wingo2017-09-251-1/+1
| | | | | * module/oop/goops.scm (allocate-instance): Fix error introduced in recent merge.
* Merge 'stable-2.2'Andy Wingo2017-09-251-32/+61
|\ | | | | | | | | Resolve conflicts by removing capability of struct-ref / struct-set! to access unboxed slots.
| * Add struct-ref/unboxed, struct-set!/unboxedAndy Wingo2017-09-251-29/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * NEWS: Add news entry. * doc/ref/api-data.texi (Vtables, Structure Basics): Update documentation. * libguile/struct.c (scm_i_struct_equalp): Avoid using struct-ref on unboxed fields. (scm_struct_ref, scm_struct_set_x_unboxed): Issue deprecation warning when accessing unboxed fields. (scm_struct_ref_unboxed, scm_struct_set_x_unboxed): New functions. * libguile/struct.h (scm_struct_ref_unboxed, scm_struct_set_x_unboxed): New functions. * module/oop/goops.scm (class-add-flags!, class-clear-flags!): (class-has-flags?, <class>, %allocate-instance, <slot>): (compute-get-n-set, unboxed-get, unboxed-set, unboxed-slot?): (allocate-slots, %prep-layout!, make-standard-class, initialize): Adapt to access unboxed nfields and flags fields via the new accessors.
* | Replace "pr" struct fields with "pw" fieldsAndy Wingo2017-09-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Layout is a "pr" field. * module/ice-9/boot-9.scm (record-type-vtable): Record vtable fields are writable. (<parameter>): "pw" fields. * module/oop/goops.scm (<class>, %compute-layout): <read-only> fields are "pw" underneath. * module/rnrs/records/procedural.scm (record-type-vtable) (record-constructor-vtable, make-record-type-descriptor): Use "pw" fields in vtables. * module/srfi/srfi-35.scm (%condition-type-vtable) (struct-layout-for-condition): "pw" fields in vtables. * test-suite/tests/goops.test: * test-suite/tests/structs.test: Use "pw" fields only. * benchmark-suite/benchmarks/structs.bm: Update for make-struct/no-tail, to use pw fields, and also to remove useless tests that the compiler would optimize away. * doc/ref/api-data.texi (Vtables): Add a note about the now-vestigial permissions character and update documentation. (Structure Basics, Meta-Vtables): Update examples. * libguile/hash.c (scm_i_struct_hash): Remove code that would handle opaque/self fields. * libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use "pw" fields. * libguile/struct.c (scm_struct_init): Simplify check for hidden fields. * libguile/values.c (scm_init_values): Field is "pw".
* | Fix bootstrap slot permissions for <class>Andy Wingo2017-09-231-3/+13
| | | | | | | | | | * module/oop/goops.scm: Fix bootstrap slot computation to preserve slot permissions.
* | Merge 'stable-2.2'Andy Wingo2017-09-231-6/+27
|\ \ | |/
| * GOOPS slot access protected via slot accessors, not struct permsAndy Wingo2017-09-231-6/+27
| | | | | | | | | | | | | | * module/oop/goops.scm (opaque-slot?, read-only-slot?): New helpers. (allocate-slots): Protect opaque and read-only slots by wrapping the slot accessors instead of relying on struct permissions. (%compute-layout): Remove opaque-slot case.
* | Remove <int-slot>, <float-slot>, <double-slot>Andy Wingo2017-09-221-4/+1
| | | | | | | | | | * module/oop/goops.scm (<int-slot>, <float-slot>, <double-slot>): Remove slot classes that never did anything.
* | Remove support for tail arrays and self slotsAndy Wingo2017-09-221-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/struct.c (scm_make_struct): Remove support for tail arrays and self slots. (set_vtable_layout_flags): Always initialize the nfields member. (scm_is_valid_vtable_layout): Remove support for tail arrays and self slots. (scm_i_struct_inherit_vtable_magic): No need to issue deprecation warning for self slots, as they are no longer supported. (scm_struct_init): Remove support for tail arrays and self slots. (scm_c_make_structv): Throw an exception if n_tail is not 0. (scm_allocate_struct): Adapt to scm_struct_init change. (scm_i_make_vtable_vtable): Initialize slots manually, to avoid relying on an already-initialized nfields member. (scm_struct_ref, scm_struct_set_x): Simplify. * module/oop/goops.scm: As we now rely on nfields being valid, when recalculating slots during boot we need to avoid resetting nfields of <class>, even temporarily, as that would prevent any further access to <class>!
* | Remove "redefined" class slotAndy Wingo2017-09-141-12/+0
| | | | | | | | | | | | * module/oop/goops.scm (fold-class-slots): Remove "redefined" field from class objects. Redefinable classes are now handled in a layer on top of GOOPS core.
* | remove self field of vtablesAndy Wingo2017-09-141-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/struct.h (SCM_VTABLE_BASE_LAYOUT, scm_vtable_index_self): Remove "self" field. Renumber the other fields. * module/oop/goops.scm (<self-slot>): Remove. (fold-class-slots): Adapt for "self" slot removal. Adapt all users. (class-redefinition): Now that there is no "self" slot to update, use %modify-instance instead of %modify-class. * libguile/goops.c (class_self): Remove. (scm_sys_modify_class): Remove. * libguile/goops.h (scm_sys_modify_class): Remove. * module/rnrs/records/procedural.scm: Import vtable-offset-user. Renumber rtd indexes using vtable-offset-user. * module/srfi/srfi-35.scm (%condition-type-vtable): Remove mention of vtable fields. * module/system/base/types.scm (address->inferior-struct): Adapt for different vtable field layout.
* | Implement class redefinition on top of fixed structsAndy Wingo2017-09-141-202/+352
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/struct.h: Steal another flag for GOOPS. * libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_INDIRECT) (SCM_VTABLE_FLAG_GOOPS_NEEDS_MIGRATION): New flags. (SCM_CLASSF_GOOPS_VALID, SCM_CLASSF_GOOPS_OR_VALID): Remove obsolete definitions. (SCM_IS_A_P): Use the scm_class_of function. * libguile/goops.c (var_class_of_obsolete_indirect_instance): Rename from var_migrate_instance. (scm_is_generic, scm_is_method, scm_sys_init_layout_x): Use scm_class_of instead of the SCM_CLASS_OF macro. (get_indirect_slots): New helper. (scm_class_of): This patch moves us in a direction where we won't be able to separately address a struct's data and its identity. Therefore to check whether a class needs migration, we check an embedded pointer from a slot instead of the vtable data. (scm_sys_struct_data): Remove this temporary function. (scm_sys_modify_instance): Update to swap slot values instead of the data pointers themselves. (scm_sys_modify_class): Use scm_sys_modify_instance. (scm_sys_goops_loaded): Capture class-of-obsolete-indirect-instance instead of migrate-instance. (scm_init_goops_builtins): Don't export the "valid" flag any more; export instead the "indirect" and "needs-migration" flags. * libguile/foreign-object.c (scm_assert_foreign_object_type): Add a FIXME. * libguile/vm-engine.c (class-of): Take away fast path for the time being. * module/oop/goops.scm (class-has-indirect-instances?) (indirect-slots-need-migration?): New helpers. (<class>, <slot>, %class-slot-definition, initialize): Remove use of vtable-flag-goops-valid. (define-class): Always push redefined values through `class-redefinition'. (<redefinable-class>): New public definition. Use it as a metaclass for redefinable classes. Provide a compute-slots function that declares the indirect slots mechanism. Add the "indirect" flag to instances of <redefinable-class>. Create indirect-slots objects for instances of those classes as part of their allocate-instance. (change-object-class, class-of-obsolete-indirect-instance): Update for new representation change. * test-suite/tests/goops.test ("object update"): Add #:metaclass <redefinable-class> to all redefinable classes. For the "hell" test, make the new classes with class-direct-slots, not class-slots; this was an error in the test.
* | Change name of "static" flag indicating static slot allocationAndy Wingo2017-09-141-4/+4
| | | | | | | | | | | | | | | | * libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_STATIC_SLOT_ALLOCATION): Rename from SCM_VTABLE_FLAG_GOOPS_STATIC. * libguile/goops.c (scm_init_goops_builtins): Adapt. * module/oop/goops.scm (class-has-statically-allocated-slots?): (initialize): Adapt.
* | GOOPS instance migration implemented in SchemeAndy Wingo2017-09-141-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | * libguile/goops.c (scm_class_of): Call out directly to the GOOPS-local `migrate-instance' if an instance needs to migrate. (scm_sys_struct_data): New internal temporary function used by the Scheme `migrate-instance'. Exorcise the evil one from the old C implementation. * libguile/goops.h (scm_change_object_class): Remove function used only internally in GOOPS. * module/oop/goops.scm (migrate-instance): Implement the hell/purgatory/etc logic in Scheme instead of C.
* | Remove all deprecated codeAndy Wingo2017-05-221-37/+0
|/ | | | | | | | | | | | | | | | | | | | | * module/ice-9/debug.scm: * module/ice-9/mapping.scm: * module/ice-9/syncase.scm: Delete these deprecated files. * module/Makefile.am: Remove deleted files. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/backtrace.c: * libguile/goops.c: * libguile/numbers.c: * libguile/socket.c: * libguile/srfi-13.c: * module/ice-9/deprecated.scm: * module/ice-9/format.scm: * module/oop/goops.scm: * module/statprof.scm: * module/texinfo/reflection.scm: * module/web/client.scm: * module/web/uri.scm: Remove deprecated code.
* Add disjoint syntax object typeAndy Wingo2017-03-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Add syntax.c and syntax.h. * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (class_syntax, scm_class_of, scm_goops_early_init): * libguile/init.c (scm_init_guile): * libguile/print.c (iprin1): * libguile/tags.h (scm_tc7_syntax): * module/oop/goops.scm (<syntax>): * module/system/base/types.scm (%tc7-syntax, cell->object): * module/system/vm/disassembler.scm (code-annotation): Wire up the new data type. * libguile/syntax.c: * libguile/syntax.h: New files. * module/ice-9/boot-9.scm: Move new definitions to (system syntax internal). * module/system/syntax.scm (print-syntax): New helper. * module/system/vm/assembler.scm (statically-allocatable?) (intern-constant, link-data): Arrange to be able to write syntax objects into images. * module/language/cps/types.scm (&syntax): New type. Remove &hash-table; it was never detected, an internal binding, and we need the bit to avoid going into bignum territory.
* Fix class slot allocation since GOOPS rewriteAndy Wingo2017-03-011-1/+1
| | | | | | | * module/oop/goops.scm (%compute-layout): Fix class slot layout. Before, a #:class that was an argument to #:allocation was getting interpreted as a keyword with a value. * test-suite/tests/goops.test ("#:class slot allocation"): Add test.
* Fix multi-arity dispatch in GOOPSAndy Wingo2017-02-221-1/+1
| | | | | | | * module/oop/goops.scm (multiple-arity-dispatcher): Fix dispatch for max-arity+1 when a generic is already in multiple-arity dispatch. Fixes #24454. * test-suite/tests/goops.test ("dispatch"): Add test.
* Deprecate user asyncsAndy Wingo2016-10-171-3/+3
| | | | | | | | | | | | | | * libguile/async.c: * libguile/async.h: * libguile/deprecated.c: * libguile/deprecated.h (scm_async, scm_async_mark, scm_run_asyncs): Deprecate these functions, which comprise the "users asyncs" facility. * module/oop/goops.scm: Adapt to <async> deprecation. * doc/ref/api-scheduling.texi: * doc/ref/libguile-concepts.texi: * doc/ref/libguile-foreign-objects.texi: * doc/ref/posix.texi: Remove documentation on user asyncs, and replace references to "system asyncs" to be just "asyncs".
* Deprecate arbitersAndy Wingo2016-10-171-2/+4
| | | | | | | | | | | | | | | * libguile/arbiters.c: * libguile/arbiters.h: * test-suite/tests/arbiters.test: Delete files. * libguile/deprecated.c: * libguile/deprecated.h: Move arbiters code here. * doc/ref/api-scheduling.texi: Remove section on arbiters. * libguile.h: * libguile/Makefile.am: * libguile/init.c: * module/oop/goops.scm: * test-suite/Makefile.am: Remove mention of arbiters. * NEWS: Update.
* Add atomic boxesAndy Wingo2016-09-061-1/+2
| | | | | | | | | | | | | | | | | | | | | * doc/ref/api-scheduling.texi (Atomics): New manual section. * libguile.h: Include atomic.h. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Add atomic. * libguile/atomic.c: * libguile/atomic.h: New files. * libguile/atomics-internal.h (scm_atomic_set_scm, scm_atomic_ref_scm) (scm_atomic_swap_scm, scm_atomic_compare_and_swap_scm): New facilities. * libguile/goops.c (class_atomic_box, scm_sys_goops_early_init): Add support for <atomic-box>. Remove duplicate <keyword> fetch. * libguile/init.c (scm_i_init_guile): Call scm_register_atomic_box. * libguile/print.c (iprin1): Add atomic box case. * libguile/tags.h (scm_tc7_atomic_box): New tag. * libguile/validate.h (SCM_VALIDATE_ATOMIC_BOX): New macro. * module/Makefile.am (SOURCES): Add ice-9/atomic.scm. * module/ice-9/atomic.scm: New file. * module/oop/goops.scm (<atomic-box>): New var.
* Add #:static-slot-allocation?Andy Wingo2015-02-061-13/+32
| | | | | | | | | | | | | | | | | | | * libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_STATIC): Reserve the fourth GOOPS flag to indicate that a class has static slot allocation. * libguile/goops.c (scm_init_goops_builtins): Define vtable-flag-goops-static for goops.scm. * module/oop/goops.scm (class-has-statically-allocated-slots?): New helper. (build-slots-list): Instead of the ad-hoc checks for <class> or <slot>, use the new helper. (initialize): Accept #:static-slot-allocation? keyword. * module/system/foreign-object.scm (make-foreign-object-type): Declare foreign object classes as having static slot allocation. * test-suite/tests/goops.test ("static slot allocation"): Add tests.
* Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo2015-01-261-16/+24
|\ | | | | | | | | | | | | | | | | | | Conflicts: libguile/goops.c libguile/vm-engine.h module/oop/goops.scm module/oop/goops/compile.scm module/oop/goops/dispatch.scm test-suite/tests/goops.test
| * Accessor methods only apply to subclasses with their slotAndy Wingo2015-01-261-33/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/goops.c (is_accessor_method, scm_compute_applicable_methods): Fix regression from 51f66c912078a25ab0380c8fc070abb73d178d98 (2009). Accessor methods are added on each subclass on which the slot is present; therefore if a subclass doesn't have a method, then the methods doesn't apply. Truly fixes #17355, unlike 583a23bf104c84d9617222856e188f3f3af4934d. * module/oop/goops.scm (compute-cmethod, compute-getter-method) (compute-setter-method): Revert earlier changes. * test-suite/tests/goops.test ("accessor slots"): Update for new expectations, in agreement with Guile 1.8.
| * Fix accessor struct field inliningAndy Wingo2015-01-243-69/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * module/oop/goops/compile.scm: Inline into goops.scm, leaving a compatible interface stub behind. * module/oop/goops/dispatch.scm: Don't import (oop goops compile), to break circularities. * module/oop/goops.scm: Move (oop goops util) include up to the top, and import (ice-9 match). (compute-cmethod): Move here from compile.scm. Add a special case for accessor methods, so as to fix bug #17355. (compute-getter-method, compute-setter-method): #:procedure slot is now generic. * test-suite/tests/goops.test ("accessor slots"): New test.
* | Fix accessor struct inlining in GOOPSAndy Wingo2015-01-241-25/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes bug #17355. * module/oop/goops.scm (memoize-effective-method!): Adapt to compute-effective-method change. (compute-effective-method, %compute-effective-method): Renamed from compute-cmethod; now a generic protocol. (compute-specialized-effective-method) (%compute-specialized-effective-method): New sub-protocol. (memoize-generic-function-application!): Adapt to call the hard-wired compute-applicable-methods based on the concrete arguments types -- the semantics is that %compute-applicable-methods is the implementation for <generic> functions. Perhaps we should do the same for sort-applicable-methods and method-more-specific?. (compute-getter-method, compute-setter-method): The standard #:procedure is now a generic slot-ref. It wasn't valid to inline field access here, because subtypes could have different field layouts. (compute-applicable-methods): Refactor generic definition to use lexical scoping. (compute-specialized-effective-method): New method for <accessor-method>, which does field access inlining based on the concrete types being applied. * test-suite/tests/goops.test ("accessor slots"): New test.
* | Simplify and optimize slot accessAndy Wingo2015-01-231-85/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * module/oop/goops.scm (fold-slot-slots): Add `slot-ref/raw' slot, which is what the slot-ref slot was. Now the slot-ref slot checks that the slot is bound, if needed. (slot-definition-slot-ref/raw): Define. (make-slot): Adapt. Also, effective slot definition slots have no initargs. (define-standard-accessor-method, bound-check-get, standard-get) (standard-set): Move definitions up. (allocate-slots): Adapt. If the slot has an init thunk, we don't need to check that it's bound. (slot-ref, slot-set!, slot-bound?): Simplify. (class-slot-ref): Use the raw getter so that we can call `slot-unbound' with just the class. (compute-getter-method, compute-setter-method): Simplify to just use the slot-ref / slot-set! functions from the slot. (%initialize-object): Simplify.
* | Export <slot> from GOOPSAndy Wingo2015-01-231-0/+1
| | | | | | | | | | * module/oop/goops.scm (<slot>): Export. This is the way to tell if you have new GOOPS or not: whether <slot> is defined.
* | Simplify GOOPS effective method cache formatAndy Wingo2015-01-231-35/+32
| | | | | | | | | | | | | | * module/oop/goops.scm (single-arity-cache-dispatch) (compute-generic-function-dispatch-procedure) (memoize-effective-method!): Simplify format of effective method cache.
* | Fast generic function dispatch without calling `compile' at runtimeAndy Wingo2015-01-231-213/+224
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * module/oop/goops.scm: Rewrite generic function dispatch to use chained closures instead of compiling specific dispatch procedures. The big speed win before was not allocating rest arguments, which we gain by simply pre-generating dispatchers for arities of up to 20 arguments. Also now a tail call without reshuffling arguments -- which is what dispatch now is -- is just a (mov 0 new-procedure) and (tail-call), which is pretty cheap. (%invalidate-method-cache!): Use the new recompute-generic-function-dispatch-procedure!. (arity-case, multiple-arity-dispatcher, single-arity-dispatcher) (single-arity-cache-dispatch) (compute-generic-function-dispatch-procedure) (recompute-generic-function-dispatch-procedure!): New internal interfaces. (memoize-effective-method!): Update for new interfaces. (memoize-generic-function-application!): Rename from `memoize-method!'.
* | GOOPS cosmeticsAndy Wingo2015-01-231-5/+10
| | | | | | | | | | * module/oop/goops.scm: More commenting. Move around <keyword> in the export section.
* | Update (oop goops save) for <slot> objectsAndy Wingo2015-01-232-34/+26
| | | | | | | | | | | | * module/oop/goops/describe.scm (describe): Remove commented code. * module/oop/goops/save.scm (get-set-for-each, access-for-each): Update these hoary routines for the new <slot> universe.
* | Minor GOOPS cleanupsAndy Wingo2015-01-231-8/+8
| | | | | | | | * module/oop/goops.scm: Minor commenting fixes.
* | Optimize %initialize-objectAndy Wingo2015-01-231-5/+24
| | | | | | | | | | | | * module/oop/goops.scm (%initialize-object): Optimize by inlining the slot initialization, and by avoiding multiple checks for initargs validity.
* | Inline internal slot accessorsAndy Wingo2015-01-231-53/+55
| | | | | | | | | | | | * module/oop/goops.scm (define-slot-accessor): Also define internal accessors without the type check for when we know that the object is a slot. Adapt struct-ref users to use these variants.
* | Inline helpers into slot-ref, slot-set!, etcAndy Wingo2015-01-231-56/+75
| | | | | | | | | | | | | | | | | | * module/oop/goops.scm (%class-slot-definition): New helper. (class-slot-definition): Use the new helper. (get-slot-value-using-name, set-slot-value-using-name!) (test-slot-existence): Remove helpers. (slot-ref, slot-set!, slot-bound?, slot-exists?): Inline helpers for speed.
* | Use a vtable bit to mark <slot> instancesAndy Wingo2015-01-231-19/+32
| | | | | | | | | | | | | | | | | | | | | | * libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_SLOT): Allocate another vtable flag to indicate that instances of this vtable are slots. * libguile/goops.c (scm_init_goops_builtins): Export vtable-flag-goops-slot to Scheme. * module/oop/goops.scm (<slot>, slot?, make-standard-class, initialize): Arrange for <slot> classes to have the vtable-flag-goops.slot. (build-slots-list): Ensure that <slot> slots are statically laid out.
* | Introduce <slot> objects in GOOPSAndy Wingo2015-01-233-407/+539
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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".
* | Beginnings of <slot> slot definition classAndy Wingo2015-01-231-48/+69
| | | | | | | | | | | | | | | | * module/oop/goops.scm (define-macro-folder): Factor out this helper. (fold-class-slots): Implement using define-macro-folder. (fold-slot-slots): New definition, for slots of <slot-definition>. (define-slot-indexer): New helper. Use to define indexes for slots of <class> and of <slot>.
* | The GOOPS "unbound" value is a unique pairAndy Wingo2015-01-233-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/goops.c (SCM_GOOPS_UNBOUND, SCM_GOOPS_UNBOUNDP): Remove internal macros. (scm_make_unbound, scm_unbound_p): Remove internal functions. (scm_sys_clear_fields_x): Add "unbound" parameter, for the init value. * module/oop/goops.scm (*unbound*): Define in Scheme as a simple heap-allocated value. (unbound?): New definition. (%allocate-instance): Pass *unbound* to %clear-fields!. (make-class, slot-definition-init-value) (slot-definition-init-form, make-closure-variable): Use *unbound* instead of (make-unbound), which is now gone. * module/oop/goops/active-slot.scm (compute-get-n-set): Use *unbound* instead of make-unbound. This module uses the GOOPS internals module; perhaps we should export make-unbound or something... * module/oop/goops/save.scm (make-unbound): Export our own make-unbound definition, for use by residualized save code. * module/language/ecmascript/base.scm (<undefined>, *undefined*): Use a unique object kind and instance for the undefined value. * libguile/vm.c (scm_i_vm_mark_stack): Fill the stack with SCM_UNSPECIFIED instead of SCM_UNBOUND.
* | GOOPS: Deprecate "using-class" procs like slot-ref-using-classAndy Wingo2015-01-231-34/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/deprecated.h: * libguile/goops.c: * libguile/goops.h: * libguile/deprecated.c (scm_slot_ref_using_class): (scm_slot_set_using_class_x): (scm_slot_bound_using_class_p): (scm_slot_exists_using_class_p): Deprecate. * module/oop/goops.scm (slot-ref-using-class, slot-set-using-class!) (slot-bound-using-class?, slot-exists-using-class?): Deprecate. Change to check that `class' is indeed the class of `obj', as required, and then dispatch to slot-ref et al.
* | change-object-class refactorAndy Wingo2015-01-231-21/+14
| | | | | | | | | | * module/oop/goops.scm (change-object-class): Refactor to use slot-ref, slot-bound?, and slot-set! instead of the using-class? variants.
* | slot-ref, slot-set! et al bypass "using-class" variantsAndy Wingo2015-01-231-4/+20
| | | | | | | | | | | | | | | | | | * module/oop/goops.scm (slot-ref, slot-set!, slot-bound?, slot-exists?): Bypass slot-ref-using-class, slot-set-using-class!, and so on. Those interfaces are public and have to check that the class is indeed a class, they should check that the object is an instance of the class, and so on, whereas if we get the class via class-of we know that the invariant holds.
* | Manipulate GOOPS vtable flags from Scheme, for speedAndy Wingo2015-01-231-5/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/goops.h: Remove unimplemented declarations of scm_make_next_method, scm_sys_invalidate_method_cache_x, and stklos_version. (scm_sys_invalidate_class_x): Remove helper definition. This was exported in the past but shouldn't have been. * libguile/goops.c (scm_sys_make_vtable_vtable): Rename from scm_sys_make_root_class, and don't do anything about flags. (scm_sys_bless_applicable_struct_vtables_x, scm_class_p) (scm_sys_invalidate_class_x): Remove; we do these in Scheme now. (scm_init_goops_builtins): Define Scheme values for vtable flags. * module/oop/goops.scm (vtable-flag-goops-metaclass) (class-add-flags!, class-clear-flags!, class-has-flags?) (class?, instance?): New definitions. (<class>): Add GOOPS metaclass flags from Scheme. (<applicable-struct-class>, <applicable-struct-with-setter-class>): Add flags from Scheme. (make, initialize): Add class flags as appropriate. (class-redefinition): Clear the "valid" flag on the old class. (check-slot-args): Use instance? instead of a CPL check.
* | GOOPS class slot indices defined as inline valuesAndy Wingo2015-01-231-2/+2
| | | | | | | | * module/oop/goops.scm (define-class-index): Define as inline values.