LilyPond-Ruby 0.0.2.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/etc/fonts/conf.d/10-hinting-slight.conf +15 -0
- data/etc/fonts/conf.d/10-scale-bitmap-fonts.conf +83 -0
- data/etc/fonts/conf.d/11-lcdfilter-default.conf +17 -0
- data/etc/fonts/conf.d/20-unhint-small-vera.conf +49 -0
- data/etc/fonts/conf.d/30-metric-aliases.conf +637 -0
- data/etc/fonts/conf.d/40-nonlatin.conf +332 -0
- data/etc/fonts/conf.d/45-generic.conf +136 -0
- data/etc/fonts/conf.d/45-latin.conf +301 -0
- data/etc/fonts/conf.d/48-spacing.conf +16 -0
- data/etc/fonts/conf.d/49-sansserif.conf +22 -0
- data/etc/fonts/conf.d/50-user.conf +16 -0
- data/etc/fonts/conf.d/51-local.conf +7 -0
- data/etc/fonts/conf.d/60-generic.conf +64 -0
- data/etc/fonts/conf.d/60-latin.conf +88 -0
- data/etc/fonts/conf.d/65-fonts-persian.conf +418 -0
- data/etc/fonts/conf.d/65-nonlatin.conf +228 -0
- data/etc/fonts/conf.d/69-unifont.conf +28 -0
- data/etc/fonts/conf.d/80-delicious.conf +19 -0
- data/etc/fonts/conf.d/90-synthetic.conf +64 -0
- data/etc/fonts/conf.d/README +23 -0
- data/etc/fonts/fonts.conf +101 -0
- data/etc/relocate/fontconfig.reloc +2 -0
- data/etc/relocate/guile.reloc +2 -0
- data/etc/relocate/libexec.reloc +1 -0
- data/lib/guile/2.2/ccache/ice-9/and-let-star.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/arrays.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/atomic.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/binary-ports.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/boot-9.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/buffered-input.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/calling.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/channel.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/command-line.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/common-list.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/control.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/curried-definitions.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/debug.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/deprecated.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/documentation.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/eval-string.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/eval.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/expect.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/fdes-finalizers.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/format.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/ftw.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/futures.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/gap-buffer.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/getopt-long.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/hash-table.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/hcons.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/history.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/i18n.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/iconv.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/lineio.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/list.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/local-eval.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/ls.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/mapping.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/match.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/networking.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/null.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/occam-channel.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/optargs.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/peg/cache.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/peg/codegen.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/peg/simplify-tree.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/peg/string-peg.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/peg/using-parsers.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/peg.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/poe.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/poll.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/popen.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/ports.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/posix.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/pretty-print.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/psyntax-pp.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/q.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/r5rs.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/rdelim.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/receive.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/regex.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/runq.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/rw.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/safe-r5rs.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/safe.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/sandbox.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/save-stack.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/scm-style-repl.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/serialize.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/session.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/slib.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/stack-catch.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/streams.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/string-fun.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/suspendable-ports.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/syncase.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/textual-ports.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/threads.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/time.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/top-repl.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/unicode.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/vlist.go +0 -0
- data/lib/guile/2.2/ccache/ice-9/weak-vector.go +0 -0
- data/lib/guile/2.2/ccache/language/brainfuck/compile-scheme.go +0 -0
- data/lib/guile/2.2/ccache/language/brainfuck/compile-tree-il.go +0 -0
- data/lib/guile/2.2/ccache/language/brainfuck/parse.go +0 -0
- data/lib/guile/2.2/ccache/language/brainfuck/spec.go +0 -0
- data/lib/guile/2.2/ccache/language/bytecode/spec.go +0 -0
- data/lib/guile/2.2/ccache/language/bytecode.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/closure-conversion.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/compile-bytecode.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/constructors.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/contification.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/cse.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/dce.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/effects-analysis.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/elide-values.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/handle-interrupts.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/intmap.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/intset.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/licm.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/optimize.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/peel-loops.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/primitives.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/prune-bailouts.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/prune-top-level-scopes.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/reify-primitives.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/renumber.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/rotate-loops.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/self-references.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/simplify.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/slot-allocation.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/spec.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/specialize-numbers.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/specialize-primcalls.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/split-rec.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/type-checks.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/type-fold.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/types.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/utils.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/verify.go +0 -0
- data/lib/guile/2.2/ccache/language/cps/with-cps.go +0 -0
- data/lib/guile/2.2/ccache/language/cps.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/array.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/base.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/compile-tree-il.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/function.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/impl.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/parse.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/spec.go +0 -0
- data/lib/guile/2.2/ccache/language/ecmascript/tokenize.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/bindings.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/boot.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/compile-tree-il.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/falias.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/lexer.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/parser.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/runtime/function-slot.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/runtime/value-slot.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/runtime.go +0 -0
- data/lib/guile/2.2/ccache/language/elisp/spec.go +0 -0
- data/lib/guile/2.2/ccache/language/scheme/compile-tree-il.go +0 -0
- data/lib/guile/2.2/ccache/language/scheme/decompile-tree-il.go +0 -0
- data/lib/guile/2.2/ccache/language/scheme/spec.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/analyze.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/canonicalize.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/compile-cps.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/debug.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/effects.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/fix-letrec.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/optimize.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/peval.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/primitives.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il/spec.go +0 -0
- data/lib/guile/2.2/ccache/language/tree-il.go +0 -0
- data/lib/guile/2.2/ccache/language/value/spec.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/accessors.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/active-slot.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/composite-slot.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/describe.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/internal.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/save.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/simple.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops/stklos.go +0 -0
- data/lib/guile/2.2/ccache/oop/goops.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/arithmetic/bitwise.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/arithmetic/fixnums.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/arithmetic/flonums.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/base.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/bytevectors.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/conditions.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/control.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/enums.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/eval.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/exceptions.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/files.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/hashtables.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/io/ports.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/io/simple.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/lists.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/mutable-pairs.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/mutable-strings.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/programs.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/r5rs.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/records/inspection.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/records/procedural.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/records/syntactic.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/sorting.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/syntax-case.go +0 -0
- data/lib/guile/2.2/ccache/rnrs/unicode.go +0 -0
- data/lib/guile/2.2/ccache/rnrs.go +0 -0
- data/lib/guile/2.2/ccache/scripts/api-diff.go +0 -0
- data/lib/guile/2.2/ccache/scripts/autofrisk.go +0 -0
- data/lib/guile/2.2/ccache/scripts/compile.go +0 -0
- data/lib/guile/2.2/ccache/scripts/disassemble.go +0 -0
- data/lib/guile/2.2/ccache/scripts/display-commentary.go +0 -0
- data/lib/guile/2.2/ccache/scripts/doc-snarf.go +0 -0
- data/lib/guile/2.2/ccache/scripts/frisk.go +0 -0
- data/lib/guile/2.2/ccache/scripts/generate-autoload.go +0 -0
- data/lib/guile/2.2/ccache/scripts/help.go +0 -0
- data/lib/guile/2.2/ccache/scripts/lint.go +0 -0
- data/lib/guile/2.2/ccache/scripts/list.go +0 -0
- data/lib/guile/2.2/ccache/scripts/punify.go +0 -0
- data/lib/guile/2.2/ccache/scripts/read-rfc822.go +0 -0
- data/lib/guile/2.2/ccache/scripts/read-scheme-source.go +0 -0
- data/lib/guile/2.2/ccache/scripts/read-text-outline.go +0 -0
- data/lib/guile/2.2/ccache/scripts/scan-api.go +0 -0
- data/lib/guile/2.2/ccache/scripts/snarf-check-and-output-texi.go +0 -0
- data/lib/guile/2.2/ccache/scripts/snarf-guile-m4-docs.go +0 -0
- data/lib/guile/2.2/ccache/scripts/summarize-guile-TODO.go +0 -0
- data/lib/guile/2.2/ccache/scripts/use2dot.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-1.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-10.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-11.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-111.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-13.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-14.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-16.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-17.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-18.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-19.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-2.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-26.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-27.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-28.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-31.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-34.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-35.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-37.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-38.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-39.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-4/gnu.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-4.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-41.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-42.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-43.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-45.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-6.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-60.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-64.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-67.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-69.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-71.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-8.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-88.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-9/gnu.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-9.go +0 -0
- data/lib/guile/2.2/ccache/srfi/srfi-98.go +0 -0
- data/lib/guile/2.2/ccache/statprof.go +0 -0
- data/lib/guile/2.2/ccache/sxml/apply-templates.go +0 -0
- data/lib/guile/2.2/ccache/sxml/fold.go +0 -0
- data/lib/guile/2.2/ccache/sxml/match.go +0 -0
- data/lib/guile/2.2/ccache/sxml/simple.go +0 -0
- data/lib/guile/2.2/ccache/sxml/ssax/input-parse.go +0 -0
- data/lib/guile/2.2/ccache/sxml/ssax.go +0 -0
- data/lib/guile/2.2/ccache/sxml/transform.go +0 -0
- data/lib/guile/2.2/ccache/sxml/xpath.go +0 -0
- data/lib/guile/2.2/ccache/system/base/ck.go +0 -0
- data/lib/guile/2.2/ccache/system/base/compile.go +0 -0
- data/lib/guile/2.2/ccache/system/base/lalr.go +0 -0
- data/lib/guile/2.2/ccache/system/base/language.go +0 -0
- data/lib/guile/2.2/ccache/system/base/message.go +0 -0
- data/lib/guile/2.2/ccache/system/base/pmatch.go +0 -0
- data/lib/guile/2.2/ccache/system/base/syntax.go +0 -0
- data/lib/guile/2.2/ccache/system/base/target.go +0 -0
- data/lib/guile/2.2/ccache/system/base/types.go +0 -0
- data/lib/guile/2.2/ccache/system/foreign-object.go +0 -0
- data/lib/guile/2.2/ccache/system/foreign.go +0 -0
- data/lib/guile/2.2/ccache/system/repl/command.go +0 -0
- data/lib/guile/2.2/ccache/system/repl/common.go +0 -0
- data/lib/guile/2.2/ccache/system/repl/coop-server.go +0 -0
- data/lib/guile/2.2/ccache/system/repl/debug.go +0 -0
- data/lib/guile/2.2/ccache/system/repl/error-handling.go +0 -0
- data/lib/guile/2.2/ccache/system/repl/repl.go +0 -0
- data/lib/guile/2.2/ccache/system/repl/server.go +0 -0
- data/lib/guile/2.2/ccache/system/syntax.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/assembler.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/coverage.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/debug.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/disassembler.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/dwarf.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/elf.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/frame.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/inspect.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/linker.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/loader.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/program.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/trace.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/trap-state.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/traps.go +0 -0
- data/lib/guile/2.2/ccache/system/vm/vm.go +0 -0
- data/lib/guile/2.2/ccache/system/xref.go +0 -0
- data/lib/guile/2.2/ccache/texinfo/docbook.go +0 -0
- data/lib/guile/2.2/ccache/texinfo/html.go +0 -0
- data/lib/guile/2.2/ccache/texinfo/indexing.go +0 -0
- data/lib/guile/2.2/ccache/texinfo/plain-text.go +0 -0
- data/lib/guile/2.2/ccache/texinfo/reflection.go +0 -0
- data/lib/guile/2.2/ccache/texinfo/serialize.go +0 -0
- data/lib/guile/2.2/ccache/texinfo/string-utils.go +0 -0
- data/lib/guile/2.2/ccache/texinfo.go +0 -0
- data/lib/guile/2.2/ccache/web/client.go +0 -0
- data/lib/guile/2.2/ccache/web/http.go +0 -0
- data/lib/guile/2.2/ccache/web/request.go +0 -0
- data/lib/guile/2.2/ccache/web/response.go +0 -0
- data/lib/guile/2.2/ccache/web/server/http.go +0 -0
- data/lib/guile/2.2/ccache/web/server.go +0 -0
- data/lib/guile/2.2/ccache/web/uri.go +0 -0
- data/lib/guile.rb +19 -0
- data/lib/lilypond/2.24.1/ccache/lily/accreg.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/auto-beam.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/autochange.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/backend-library.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/bar-line.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/breath.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/c++.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/chord-entry.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/chord-ignatzek-names.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/chord-name.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/clip-region.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/color.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/curried-definitions.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-context-properties.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-event-classes.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-grob-interfaces.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-grob-properties.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-grobs.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-markup-commands.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-music-callbacks.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-music-display-methods.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-music-properties.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-music-types.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-note-names.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-stencil-commands.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/define-woodwind-diagrams.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/display-lily.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/display-woodwind-diagrams.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/file-cache.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/flag-styles.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/font-encodings.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/font.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/framework-cairo.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/framework-ps.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/framework-svg.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/fret-diagrams.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/graphviz.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/harp-pedals.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/layout-beam.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/layout-slur.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/lily-library.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/lily.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/ly-syntax-constructors.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/markup-macros.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/markup.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/midi.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/modal-transforms.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/music-functions.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/output-lib.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/output-ps.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/output-svg.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/page.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/paper-system.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/paper.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/parser-clef.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/parser-ly-from-scheme.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/part-combiner.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/predefined-fretboards.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/ps-to-png.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/scheme-engravers.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/scheme-performers.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/script.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/skyline.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/song-util.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/song.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/stencil.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/tablature.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/time-signature-settings.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/time-signature.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/titling.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/to-xml.go +0 -0
- data/lib/lilypond/2.24.1/ccache/lily/translation-functions.go +0 -0
- data/lib/lilypond/builder.rb +161 -0
- data/lib/lilypond-ruby.rb +18 -3
- data/share/emacs/site-lisp/lilypond-font-lock.el +208 -0
- data/share/emacs/site-lisp/lilypond-indent.el +605 -0
- data/share/emacs/site-lisp/lilypond-init.el +21 -0
- data/share/emacs/site-lisp/lilypond-mode.el +1204 -0
- data/share/emacs/site-lisp/lilypond-song.el +556 -0
- data/share/emacs/site-lisp/lilypond-what-beat.el +279 -0
- data/share/emacs/site-lisp/lilypond-words.el +1428 -0
- data/share/guile/2.2/guile-procedures.txt +8860 -0
- data/share/guile/2.2/ice-9/and-let-star.scm +73 -0
- data/share/guile/2.2/ice-9/arrays.scm +70 -0
- data/share/guile/2.2/ice-9/atomic.scm +38 -0
- data/share/guile/2.2/ice-9/binary-ports.scm +53 -0
- data/share/guile/2.2/ice-9/boot-9.scm +4131 -0
- data/share/guile/2.2/ice-9/buffered-input.scm +109 -0
- data/share/guile/2.2/ice-9/calling.scm +326 -0
- data/share/guile/2.2/ice-9/channel.scm +170 -0
- data/share/guile/2.2/ice-9/command-line.scm +477 -0
- data/share/guile/2.2/ice-9/common-list.scm +278 -0
- data/share/guile/2.2/ice-9/control.scm +110 -0
- data/share/guile/2.2/ice-9/curried-definitions.scm +57 -0
- data/share/guile/2.2/ice-9/debug.scm +25 -0
- data/share/guile/2.2/ice-9/deprecated.scm +93 -0
- data/share/guile/2.2/ice-9/documentation.scm +203 -0
- data/share/guile/2.2/ice-9/eval-string.scm +90 -0
- data/share/guile/2.2/ice-9/eval.scm +723 -0
- data/share/guile/2.2/ice-9/expect.scm +171 -0
- data/share/guile/2.2/ice-9/fdes-finalizers.scm +25 -0
- data/share/guile/2.2/ice-9/format.scm +1626 -0
- data/share/guile/2.2/ice-9/ftw.scm +564 -0
- data/share/guile/2.2/ice-9/futures.scm +308 -0
- data/share/guile/2.2/ice-9/gap-buffer.scm +283 -0
- data/share/guile/2.2/ice-9/getopt-long.scm +371 -0
- data/share/guile/2.2/ice-9/hash-table.scm +45 -0
- data/share/guile/2.2/ice-9/hcons.scm +80 -0
- data/share/guile/2.2/ice-9/history.scm +65 -0
- data/share/guile/2.2/ice-9/i18n.scm +531 -0
- data/share/guile/2.2/ice-9/iconv.scm +95 -0
- data/share/guile/2.2/ice-9/lineio.scm +115 -0
- data/share/guile/2.2/ice-9/list.scm +36 -0
- data/share/guile/2.2/ice-9/local-eval.scm +261 -0
- data/share/guile/2.2/ice-9/ls.scm +94 -0
- data/share/guile/2.2/ice-9/mapping.scm +118 -0
- data/share/guile/2.2/ice-9/match.scm +59 -0
- data/share/guile/2.2/ice-9/match.upstream.scm +917 -0
- data/share/guile/2.2/ice-9/networking.scm +94 -0
- data/share/guile/2.2/ice-9/null.scm +34 -0
- data/share/guile/2.2/ice-9/occam-channel.scm +261 -0
- data/share/guile/2.2/ice-9/optargs.scm +381 -0
- data/share/guile/2.2/ice-9/peg/cache.scm +45 -0
- data/share/guile/2.2/ice-9/peg/codegen.scm +359 -0
- data/share/guile/2.2/ice-9/peg/simplify-tree.scm +97 -0
- data/share/guile/2.2/ice-9/peg/string-peg.scm +273 -0
- data/share/guile/2.2/ice-9/peg/using-parsers.scm +116 -0
- data/share/guile/2.2/ice-9/peg.scm +42 -0
- data/share/guile/2.2/ice-9/poe.scm +116 -0
- data/share/guile/2.2/ice-9/poll.scm +172 -0
- data/share/guile/2.2/ice-9/popen.scm +178 -0
- data/share/guile/2.2/ice-9/ports.scm +566 -0
- data/share/guile/2.2/ice-9/posix.scm +75 -0
- data/share/guile/2.2/ice-9/pretty-print.scm +483 -0
- data/share/guile/2.2/ice-9/psyntax-pp.scm +3542 -0
- data/share/guile/2.2/ice-9/psyntax.scm +3326 -0
- data/share/guile/2.2/ice-9/q.scm +153 -0
- data/share/guile/2.2/ice-9/quasisyntax.scm +136 -0
- data/share/guile/2.2/ice-9/r5rs.scm +45 -0
- data/share/guile/2.2/ice-9/r6rs-libraries.scm +242 -0
- data/share/guile/2.2/ice-9/rdelim.scm +208 -0
- data/share/guile/2.2/ice-9/receive.scm +26 -0
- data/share/guile/2.2/ice-9/regex.scm +229 -0
- data/share/guile/2.2/ice-9/runq.scm +241 -0
- data/share/guile/2.2/ice-9/rw.scm +27 -0
- data/share/guile/2.2/ice-9/safe-r5rs.scm +145 -0
- data/share/guile/2.2/ice-9/safe.scm +34 -0
- data/share/guile/2.2/ice-9/sandbox.scm +1399 -0
- data/share/guile/2.2/ice-9/save-stack.scm +58 -0
- data/share/guile/2.2/ice-9/scm-style-repl.scm +279 -0
- data/share/guile/2.2/ice-9/serialize.scm +114 -0
- data/share/guile/2.2/ice-9/session.scm +530 -0
- data/share/guile/2.2/ice-9/slib.scm +33 -0
- data/share/guile/2.2/ice-9/stack-catch.scm +47 -0
- data/share/guile/2.2/ice-9/streams.scm +168 -0
- data/share/guile/2.2/ice-9/string-fun.scm +280 -0
- data/share/guile/2.2/ice-9/suspendable-ports.scm +788 -0
- data/share/guile/2.2/ice-9/syncase.scm +37 -0
- data/share/guile/2.2/ice-9/textual-ports.scm +70 -0
- data/share/guile/2.2/ice-9/threads.scm +392 -0
- data/share/guile/2.2/ice-9/time.scm +58 -0
- data/share/guile/2.2/ice-9/top-repl.scm +78 -0
- data/share/guile/2.2/ice-9/unicode.scm +26 -0
- data/share/guile/2.2/ice-9/vlist.scm +595 -0
- data/share/guile/2.2/ice-9/weak-vector.scm +31 -0
- data/share/guile/2.2/language/brainfuck/compile-scheme.scm +123 -0
- data/share/guile/2.2/language/brainfuck/compile-tree-il.scm +184 -0
- data/share/guile/2.2/language/brainfuck/parse.scm +95 -0
- data/share/guile/2.2/language/brainfuck/spec.scm +43 -0
- data/share/guile/2.2/language/bytecode/spec.scm +42 -0
- data/share/guile/2.2/language/bytecode.scm +104 -0
- data/share/guile/2.2/language/cps/closure-conversion.scm +848 -0
- data/share/guile/2.2/language/cps/compile-bytecode.scm +610 -0
- data/share/guile/2.2/language/cps/constructors.scm +106 -0
- data/share/guile/2.2/language/cps/contification.scm +448 -0
- data/share/guile/2.2/language/cps/cse.scm +414 -0
- data/share/guile/2.2/language/cps/dce.scm +363 -0
- data/share/guile/2.2/language/cps/effects-analysis.scm +597 -0
- data/share/guile/2.2/language/cps/elide-values.scm +88 -0
- data/share/guile/2.2/language/cps/handle-interrupts.scm +69 -0
- data/share/guile/2.2/language/cps/intmap.scm +765 -0
- data/share/guile/2.2/language/cps/intset.scm +830 -0
- data/share/guile/2.2/language/cps/licm.scm +308 -0
- data/share/guile/2.2/language/cps/optimize.scm +135 -0
- data/share/guile/2.2/language/cps/peel-loops.scm +287 -0
- data/share/guile/2.2/language/cps/primitives.scm +141 -0
- data/share/guile/2.2/language/cps/prune-bailouts.scm +86 -0
- data/share/guile/2.2/language/cps/prune-top-level-scopes.scm +63 -0
- data/share/guile/2.2/language/cps/reify-primitives.scm +179 -0
- data/share/guile/2.2/language/cps/renumber.scm +217 -0
- data/share/guile/2.2/language/cps/rotate-loops.scm +239 -0
- data/share/guile/2.2/language/cps/self-references.scm +79 -0
- data/share/guile/2.2/language/cps/simplify.scm +274 -0
- data/share/guile/2.2/language/cps/slot-allocation.scm +1058 -0
- data/share/guile/2.2/language/cps/spec.scm +51 -0
- data/share/guile/2.2/language/cps/specialize-numbers.scm +724 -0
- data/share/guile/2.2/language/cps/specialize-primcalls.scm +87 -0
- data/share/guile/2.2/language/cps/split-rec.scm +174 -0
- data/share/guile/2.2/language/cps/type-checks.scm +72 -0
- data/share/guile/2.2/language/cps/type-fold.scm +455 -0
- data/share/guile/2.2/language/cps/types.scm +1826 -0
- data/share/guile/2.2/language/cps/utils.scm +550 -0
- data/share/guile/2.2/language/cps/verify.scm +304 -0
- data/share/guile/2.2/language/cps/with-cps.scm +145 -0
- data/share/guile/2.2/language/cps.scm +358 -0
- data/share/guile/2.2/language/ecmascript/array.scm +121 -0
- data/share/guile/2.2/language/ecmascript/base.scm +251 -0
- data/share/guile/2.2/language/ecmascript/compile-tree-il.scm +576 -0
- data/share/guile/2.2/language/ecmascript/function.scm +78 -0
- data/share/guile/2.2/language/ecmascript/impl.scm +169 -0
- data/share/guile/2.2/language/ecmascript/parse.scm +352 -0
- data/share/guile/2.2/language/ecmascript/spec.scm +37 -0
- data/share/guile/2.2/language/ecmascript/tokenize.scm +513 -0
- data/share/guile/2.2/language/elisp/bindings.scm +107 -0
- data/share/guile/2.2/language/elisp/boot.el +617 -0
- data/share/guile/2.2/language/elisp/compile-tree-il.scm +812 -0
- data/share/guile/2.2/language/elisp/falias.scm +47 -0
- data/share/guile/2.2/language/elisp/lexer.scm +430 -0
- data/share/guile/2.2/language/elisp/parser.scm +222 -0
- data/share/guile/2.2/language/elisp/runtime/function-slot.scm +63 -0
- data/share/guile/2.2/language/elisp/runtime/value-slot.scm +24 -0
- data/share/guile/2.2/language/elisp/runtime.scm +153 -0
- data/share/guile/2.2/language/elisp/spec.scm +43 -0
- data/share/guile/2.2/language/scheme/compile-tree-il.scm +33 -0
- data/share/guile/2.2/language/scheme/decompile-tree-il.scm +796 -0
- data/share/guile/2.2/language/scheme/spec.scm +63 -0
- data/share/guile/2.2/language/tree-il/analyze.scm +1568 -0
- data/share/guile/2.2/language/tree-il/canonicalize.scm +82 -0
- data/share/guile/2.2/language/tree-il/compile-cps.scm +1149 -0
- data/share/guile/2.2/language/tree-il/debug.scm +246 -0
- data/share/guile/2.2/language/tree-il/effects.scm +591 -0
- data/share/guile/2.2/language/tree-il/fix-letrec.scm +314 -0
- data/share/guile/2.2/language/tree-il/optimize.scm +43 -0
- data/share/guile/2.2/language/tree-il/peval.scm +1669 -0
- data/share/guile/2.2/language/tree-il/primitives.scm +630 -0
- data/share/guile/2.2/language/tree-il/spec.scm +46 -0
- data/share/guile/2.2/language/tree-il.scm +630 -0
- data/share/guile/2.2/language/value/spec.scm +30 -0
- data/share/guile/2.2/oop/goops/accessors.scm +72 -0
- data/share/guile/2.2/oop/goops/active-slot.scm +63 -0
- data/share/guile/2.2/oop/goops/composite-slot.scm +83 -0
- data/share/guile/2.2/oop/goops/describe.scm +189 -0
- data/share/guile/2.2/oop/goops/internal.scm +30 -0
- data/share/guile/2.2/oop/goops/save.scm +874 -0
- data/share/guile/2.2/oop/goops/simple.scm +30 -0
- data/share/guile/2.2/oop/goops/stklos.scm +74 -0
- data/share/guile/2.2/oop/goops.scm +3176 -0
- data/share/guile/2.2/rnrs/arithmetic/bitwise.scm +92 -0
- data/share/guile/2.2/rnrs/arithmetic/fixnums.scm +291 -0
- data/share/guile/2.2/rnrs/arithmetic/flonums.scm +203 -0
- data/share/guile/2.2/rnrs/base.scm +291 -0
- data/share/guile/2.2/rnrs/bytevectors.scm +83 -0
- data/share/guile/2.2/rnrs/conditions.scm +225 -0
- data/share/guile/2.2/rnrs/control.scm +22 -0
- data/share/guile/2.2/rnrs/enums.scm +152 -0
- data/share/guile/2.2/rnrs/eval.scm +39 -0
- data/share/guile/2.2/rnrs/exceptions.scm +276 -0
- data/share/guile/2.2/rnrs/files.scm +96 -0
- data/share/guile/2.2/rnrs/hashtables.scm +190 -0
- data/share/guile/2.2/rnrs/io/ports.scm +554 -0
- data/share/guile/2.2/rnrs/io/simple.scm +167 -0
- data/share/guile/2.2/rnrs/lists.scm +55 -0
- data/share/guile/2.2/rnrs/mutable-pairs.scm +23 -0
- data/share/guile/2.2/rnrs/mutable-strings.scm +23 -0
- data/share/guile/2.2/rnrs/programs.scm +22 -0
- data/share/guile/2.2/rnrs/r5rs.scm +34 -0
- data/share/guile/2.2/rnrs/records/inspection.scm +81 -0
- data/share/guile/2.2/rnrs/records/procedural.scm +289 -0
- data/share/guile/2.2/rnrs/records/syntactic.scm +248 -0
- data/share/guile/2.2/rnrs/sorting.scm +27 -0
- data/share/guile/2.2/rnrs/syntax-case.scm +68 -0
- data/share/guile/2.2/rnrs/unicode.scm +104 -0
- data/share/guile/2.2/rnrs.scm +289 -0
- data/share/guile/2.2/scripts/api-diff.scm +179 -0
- data/share/guile/2.2/scripts/autofrisk.scm +218 -0
- data/share/guile/2.2/scripts/compile.scm +273 -0
- data/share/guile/2.2/scripts/disassemble.scm +38 -0
- data/share/guile/2.2/scripts/display-commentary.scm +67 -0
- data/share/guile/2.2/scripts/doc-snarf.scm +439 -0
- data/share/guile/2.2/scripts/frisk.scm +290 -0
- data/share/guile/2.2/scripts/generate-autoload.scm +144 -0
- data/share/guile/2.2/scripts/help.scm +188 -0
- data/share/guile/2.2/scripts/lint.scm +318 -0
- data/share/guile/2.2/scripts/list.scm +91 -0
- data/share/guile/2.2/scripts/punify.scm +87 -0
- data/share/guile/2.2/scripts/read-rfc822.scm +131 -0
- data/share/guile/2.2/scripts/read-scheme-source.scm +282 -0
- data/share/guile/2.2/scripts/read-text-outline.scm +253 -0
- data/share/guile/2.2/scripts/scan-api.scm +223 -0
- data/share/guile/2.2/scripts/snarf-check-and-output-texi.scm +303 -0
- data/share/guile/2.2/scripts/snarf-guile-m4-docs.scm +86 -0
- data/share/guile/2.2/scripts/summarize-guile-TODO.scm +213 -0
- data/share/guile/2.2/scripts/use2dot.scm +110 -0
- data/share/guile/2.2/srfi/srfi-1.scm +1061 -0
- data/share/guile/2.2/srfi/srfi-10.scm +89 -0
- data/share/guile/2.2/srfi/srfi-11.scm +146 -0
- data/share/guile/2.2/srfi/srfi-111.scm +37 -0
- data/share/guile/2.2/srfi/srfi-13.scm +132 -0
- data/share/guile/2.2/srfi/srfi-14.scm +99 -0
- data/share/guile/2.2/srfi/srfi-16.scm +51 -0
- data/share/guile/2.2/srfi/srfi-17.scm +174 -0
- data/share/guile/2.2/srfi/srfi-18.scm +382 -0
- data/share/guile/2.2/srfi/srfi-19.scm +1470 -0
- data/share/guile/2.2/srfi/srfi-2.scm +31 -0
- data/share/guile/2.2/srfi/srfi-26.scm +66 -0
- data/share/guile/2.2/srfi/srfi-27.scm +96 -0
- data/share/guile/2.2/srfi/srfi-28.scm +34 -0
- data/share/guile/2.2/srfi/srfi-31.scm +35 -0
- data/share/guile/2.2/srfi/srfi-34.scm +84 -0
- data/share/guile/2.2/srfi/srfi-35.scm +351 -0
- data/share/guile/2.2/srfi/srfi-37.scm +234 -0
- data/share/guile/2.2/srfi/srfi-38.scm +207 -0
- data/share/guile/2.2/srfi/srfi-39.scm +55 -0
- data/share/guile/2.2/srfi/srfi-4/gnu.scm +80 -0
- data/share/guile/2.2/srfi/srfi-4.scm +118 -0
- data/share/guile/2.2/srfi/srfi-41.scm +505 -0
- data/share/guile/2.2/srfi/srfi-42/ec.scm +1053 -0
- data/share/guile/2.2/srfi/srfi-42.scm +66 -0
- data/share/guile/2.2/srfi/srfi-43.scm +1077 -0
- data/share/guile/2.2/srfi/srfi-45.scm +93 -0
- data/share/guile/2.2/srfi/srfi-6.scm +29 -0
- data/share/guile/2.2/srfi/srfi-60.scm +73 -0
- data/share/guile/2.2/srfi/srfi-64/testing.scm +1040 -0
- data/share/guile/2.2/srfi/srfi-64.scm +55 -0
- data/share/guile/2.2/srfi/srfi-67/compare.scm +686 -0
- data/share/guile/2.2/srfi/srfi-67.scm +88 -0
- data/share/guile/2.2/srfi/srfi-69.scm +336 -0
- data/share/guile/2.2/srfi/srfi-71.scm +267 -0
- data/share/guile/2.2/srfi/srfi-8.scm +31 -0
- data/share/guile/2.2/srfi/srfi-88.scm +53 -0
- data/share/guile/2.2/srfi/srfi-9/gnu.scm +168 -0
- data/share/guile/2.2/srfi/srfi-9.scm +351 -0
- data/share/guile/2.2/srfi/srfi-98.scm +44 -0
- data/share/guile/2.2/statprof.scm +988 -0
- data/share/guile/2.2/sxml/apply-templates.scm +102 -0
- data/share/guile/2.2/sxml/fold.scm +250 -0
- data/share/guile/2.2/sxml/match.scm +75 -0
- data/share/guile/2.2/sxml/simple.scm +408 -0
- data/share/guile/2.2/sxml/ssax/input-parse.scm +180 -0
- data/share/guile/2.2/sxml/ssax.scm +265 -0
- data/share/guile/2.2/sxml/sxml-match.ss +1181 -0
- data/share/guile/2.2/sxml/transform.scm +298 -0
- data/share/guile/2.2/sxml/upstream/SSAX.scm +3235 -0
- data/share/guile/2.2/sxml/upstream/SXML-tree-trans.scm +249 -0
- data/share/guile/2.2/sxml/upstream/SXPath-old.scm +1216 -0
- data/share/guile/2.2/sxml/upstream/assert.scm +35 -0
- data/share/guile/2.2/sxml/upstream/input-parse.scm +326 -0
- data/share/guile/2.2/sxml/xpath.scm +493 -0
- data/share/guile/2.2/system/base/ck.scm +55 -0
- data/share/guile/2.2/system/base/compile.scm +282 -0
- data/share/guile/2.2/system/base/lalr.scm +51 -0
- data/share/guile/2.2/system/base/lalr.upstream.scm +2096 -0
- data/share/guile/2.2/system/base/language.scm +119 -0
- data/share/guile/2.2/system/base/message.scm +238 -0
- data/share/guile/2.2/system/base/pmatch.scm +68 -0
- data/share/guile/2.2/system/base/syntax.scm +299 -0
- data/share/guile/2.2/system/base/target.scm +152 -0
- data/share/guile/2.2/system/base/types.scm +561 -0
- data/share/guile/2.2/system/foreign-object.scm +91 -0
- data/share/guile/2.2/system/foreign.scm +200 -0
- data/share/guile/2.2/system/repl/command.scm +946 -0
- data/share/guile/2.2/system/repl/common.scm +263 -0
- data/share/guile/2.2/system/repl/coop-server.scm +200 -0
- data/share/guile/2.2/system/repl/debug.scm +210 -0
- data/share/guile/2.2/system/repl/describe.scm +347 -0
- data/share/guile/2.2/system/repl/error-handling.scm +183 -0
- data/share/guile/2.2/system/repl/repl.scm +233 -0
- data/share/guile/2.2/system/repl/server.scm +332 -0
- data/share/guile/2.2/system/syntax.scm +33 -0
- data/share/guile/2.2/system/vm/assembler.scm +2614 -0
- data/share/guile/2.2/system/vm/coverage.scm +351 -0
- data/share/guile/2.2/system/vm/debug.scm +766 -0
- data/share/guile/2.2/system/vm/disassembler.scm +658 -0
- data/share/guile/2.2/system/vm/dwarf.scm +1852 -0
- data/share/guile/2.2/system/vm/elf.scm +1042 -0
- data/share/guile/2.2/system/vm/frame.scm +485 -0
- data/share/guile/2.2/system/vm/inspect.scm +188 -0
- data/share/guile/2.2/system/vm/linker.scm +732 -0
- data/share/guile/2.2/system/vm/loader.scm +27 -0
- data/share/guile/2.2/system/vm/program.scm +312 -0
- data/share/guile/2.2/system/vm/trace.scm +121 -0
- data/share/guile/2.2/system/vm/trap-state.scm +302 -0
- data/share/guile/2.2/system/vm/traps.scm +608 -0
- data/share/guile/2.2/system/vm/vm.scm +32 -0
- data/share/guile/2.2/system/xref.scm +369 -0
- data/share/guile/2.2/texinfo/docbook.scm +240 -0
- data/share/guile/2.2/texinfo/html.scm +279 -0
- data/share/guile/2.2/texinfo/indexing.scm +75 -0
- data/share/guile/2.2/texinfo/plain-text.scm +322 -0
- data/share/guile/2.2/texinfo/reflection.scm +585 -0
- data/share/guile/2.2/texinfo/serialize.scm +300 -0
- data/share/guile/2.2/texinfo/string-utils.scm +410 -0
- data/share/guile/2.2/texinfo.scm +1263 -0
- data/share/guile/2.2/web/client.scm +513 -0
- data/share/guile/2.2/web/http.scm +2043 -0
- data/share/guile/2.2/web/request.scm +326 -0
- data/share/guile/2.2/web/response.scm +379 -0
- data/share/guile/2.2/web/server/http.scm +183 -0
- data/share/guile/2.2/web/server.scm +397 -0
- data/share/guile/2.2/web/uri.scm +552 -0
- data/share/lilypond/2.24.1/fontconfig/0bd3dc0958fa2205aaaa8ebb13e2872b-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/188ac73a183f12857f63bb60a4a6d603-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/32b6488e5b8292a2e95c79d947e009e8-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/3830d5c3ddfd5cd38a049b759396e72e-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/3f7329c5293ffd510edef78f73874cfd-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/4c599c202bc5c08e2d34565a40eac3b2-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/57e423e26b20ab21d0f2f29c145174c3-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/7ef2298fde41cc6eeb7af42e48b7d293-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/826f6b6ef79022e2eac8af26bf4b62f2-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/945677eb7aeaf62f1d50efc3fb3ec7d8-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/95530828ff6c81d309f8258d8d02a23e-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/CACHEDIR.TAG +4 -0
- data/share/lilypond/2.24.1/fontconfig/bf3b770c553c462765856025a94f1ce6-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/c855463f699352c367813e37f3f70ea7-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/d3e5c4ee2ceb1fc347f91d4cefc53bc0-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/d589a48862398ed80a3d6066f4f56f4c-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/d82eb4fd963d448e2fcb7d7b793b5df3-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/e13b20fdb08344e0e664864cc2ede53d-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/e52a45a1c8c8fe895fc0fc8c4e6999b8-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fontconfig/f1f2465696798768e9653f19e17ccdc8-le64.cache-8 +0 -0
- data/share/lilypond/2.24.1/fonts/00-lilypond-fonts.conf +99 -0
- data/share/lilypond/2.24.1/fonts/99-lilypond-fonts.conf +28 -0
- data/share/lilypond/2.24.1/fonts/otf/C059-BdIta.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/C059-Bold.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/C059-Italic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/C059-Roman.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-Bold.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-BoldItalic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-Italic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-Regular.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusSans-Bold.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusSans-BoldItalic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusSans-Italic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/NimbusSans-Regular.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-11.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-13.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-14.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-16.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-18.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-20.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-23.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-26.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/emmentaler-brace.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-bold.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-bolditalic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-italic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-regular.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreheros-bold.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreheros-bolditalic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreheros-italic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreheros-regular.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreschola-bold.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreschola-bolditalic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreschola-italic.otf +0 -0
- data/share/lilypond/2.24.1/fonts/otf/texgyreschola-regular.otf +0 -0
- data/share/lilypond/2.24.1/fonts/source/common-modules-and-initialization.mf +26 -0
- data/share/lilypond/2.24.1/fonts/source/debugging-settings.mf +14 -0
- data/share/lilypond/2.24.1/fonts/source/declare-autometric-parameters.mf +9 -0
- data/share/lilypond/2.24.1/fonts/source/feta-accidentals.mf +58 -0
- data/share/lilypond/2.24.1/fonts/source/feta-accordion.mf +575 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet-generic.mf +16 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet11.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet13.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet14.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet16.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet18.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet20.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet23.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-alphabet26.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-arrow.mf +114 -0
- data/share/lilypond/2.24.1/fonts/source/feta-arrowheads.mf +171 -0
- data/share/lilypond/2.24.1/fonts/source/feta-autometric.mf +303 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-a.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-b.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-c.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-d.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-e.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-f.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-g.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-generic.mf +47 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-h.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces-i.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-braces.mf +125 -0
- data/share/lilypond/2.24.1/fonts/source/feta-brackettips.mf +100 -0
- data/share/lilypond/2.24.1/fonts/source/feta-clefs.mf +963 -0
- data/share/lilypond/2.24.1/fonts/source/feta-dots.mf +37 -0
- data/share/lilypond/2.24.1/fonts/source/feta-dynamics.mf +891 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags-generic.mf +17 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags.mf +926 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags11.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags13.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags14.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags16.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags18.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags20.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags23.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flags26.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-flats.mf +668 -0
- data/share/lilypond/2.24.1/fonts/source/feta-macros.mf +506 -0
- data/share/lilypond/2.24.1/fonts/source/feta-naturals.mf +223 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads-generic.mf +17 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads.mf +2642 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads11.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads13.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads14.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads16.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads18.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads20.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads23.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-noteheads26.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta-numbers.mf +1677 -0
- data/share/lilypond/2.24.1/fonts/source/feta-other-generic.mf +27 -0
- data/share/lilypond/2.24.1/fonts/source/feta-params.mf +323 -0
- data/share/lilypond/2.24.1/fonts/source/feta-parenthesis.mf +63 -0
- data/share/lilypond/2.24.1/fonts/source/feta-pedals.mf +355 -0
- data/share/lilypond/2.24.1/fonts/source/feta-rests.mf +890 -0
- data/share/lilypond/2.24.1/fonts/source/feta-scripts.mf +2206 -0
- data/share/lilypond/2.24.1/fonts/source/feta-sharps.mf +524 -0
- data/share/lilypond/2.24.1/fonts/source/feta-sori-koron.mf +325 -0
- data/share/lilypond/2.24.1/fonts/source/feta-ties.mf +72 -0
- data/share/lilypond/2.24.1/fonts/source/feta-timesignatures.mf +119 -0
- data/share/lilypond/2.24.1/fonts/source/feta-trills.mf +321 -0
- data/share/lilypond/2.24.1/fonts/source/feta11.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta13.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta14.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta16.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta18.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta20.mf +7 -0
- data/share/lilypond/2.24.1/fonts/source/feta23.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/feta26.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-accidentals.mf +483 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-clefs.mf +1636 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-custodes.mf +503 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-dots.mf +62 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-flags.mf +319 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-macros.mf +225 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads-generic.mf +16 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads.mf +2191 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads11.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads13.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads14.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads16.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads18.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads20.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads23.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads26.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-other-generic.mf +24 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-rests.mf +428 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-scripts.mf +284 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan-timesignatures.mf +402 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan11.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan13.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan14.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan16.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan18.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan20.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan23.mf +6 -0
- data/share/lilypond/2.24.1/fonts/source/parmesan26.mf +6 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-11.svg +2525 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-11.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-13.svg +2530 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-13.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-14.svg +2526 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-14.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-16.svg +2523 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-16.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-18.svg +2519 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-18.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-20.svg +2512 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-20.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-23.svg +2506 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-23.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-26.svg +2510 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-26.woff +0 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-brace.svg +1757 -0
- data/share/lilypond/2.24.1/fonts/svg/emmentaler-brace.woff +0 -0
- data/share/lilypond/2.24.1/ly/Welcome_to_LilyPond.ly +45 -0
- data/share/lilypond/2.24.1/ly/arabic.ly +185 -0
- data/share/lilypond/2.24.1/ly/articulate.ly +1013 -0
- data/share/lilypond/2.24.1/ly/bagpipe.ly +368 -0
- data/share/lilypond/2.24.1/ly/base-tkit.ly +135 -0
- data/share/lilypond/2.24.1/ly/catalan.ly +23 -0
- data/share/lilypond/2.24.1/ly/chord-modifiers-init.ly +63 -0
- data/share/lilypond/2.24.1/ly/chord-repetition-init.ly +60 -0
- data/share/lilypond/2.24.1/ly/context-mods-init.ly +119 -0
- data/share/lilypond/2.24.1/ly/declarations-init.ly +167 -0
- data/share/lilypond/2.24.1/ly/deutsch.ly +23 -0
- data/share/lilypond/2.24.1/ly/drumpitch-init.ly +366 -0
- data/share/lilypond/2.24.1/ly/dynamic-scripts-init.ly +54 -0
- data/share/lilypond/2.24.1/ly/english.ly +23 -0
- data/share/lilypond/2.24.1/ly/engraver-init.ly +1619 -0
- data/share/lilypond/2.24.1/ly/espanol.ly +23 -0
- data/share/lilypond/2.24.1/ly/event-listener.ly +241 -0
- data/share/lilypond/2.24.1/ly/festival.ly +38 -0
- data/share/lilypond/2.24.1/ly/generate-documentation.ly +7 -0
- data/share/lilypond/2.24.1/ly/grace-init.ly +56 -0
- data/share/lilypond/2.24.1/ly/graphviz-init.ly +174 -0
- data/share/lilypond/2.24.1/ly/gregorian.ly +268 -0
- data/share/lilypond/2.24.1/ly/guile-debugger.ly +55 -0
- data/share/lilypond/2.24.1/ly/hel-arabic.ly +307 -0
- data/share/lilypond/2.24.1/ly/init.ly +96 -0
- data/share/lilypond/2.24.1/ly/italiano.ly +23 -0
- data/share/lilypond/2.24.1/ly/lilypond-book-preamble.ly +47 -0
- data/share/lilypond/2.24.1/ly/lyrics-tkit.ly +68 -0
- data/share/lilypond/2.24.1/ly/makam.ly +166 -0
- data/share/lilypond/2.24.1/ly/midi-init.ly +59 -0
- data/share/lilypond/2.24.1/ly/music-functions-init.ly +2254 -0
- data/share/lilypond/2.24.1/ly/nederlands.ly +23 -0
- data/share/lilypond/2.24.1/ly/norsk.ly +23 -0
- data/share/lilypond/2.24.1/ly/paper-defaults-init.ly +188 -0
- data/share/lilypond/2.24.1/ly/performer-init.ly +398 -0
- data/share/lilypond/2.24.1/ly/persian.ly +335 -0
- data/share/lilypond/2.24.1/ly/piano-tkit.ly +61 -0
- data/share/lilypond/2.24.1/ly/portugues.ly +23 -0
- data/share/lilypond/2.24.1/ly/predefined-fretboards-init.ly +78 -0
- data/share/lilypond/2.24.1/ly/predefined-guitar-fretboards.ly +506 -0
- data/share/lilypond/2.24.1/ly/predefined-guitar-ninth-fretboards.ly +75 -0
- data/share/lilypond/2.24.1/ly/predefined-mandolin-fretboards.ly +876 -0
- data/share/lilypond/2.24.1/ly/predefined-ukulele-fretboards.ly +1285 -0
- data/share/lilypond/2.24.1/ly/property-init.ly +858 -0
- data/share/lilypond/2.24.1/ly/satb.ly +214 -0
- data/share/lilypond/2.24.1/ly/scale-definitions-init.ly +117 -0
- data/share/lilypond/2.24.1/ly/scheme-sandbox.ly +39 -0
- data/share/lilypond/2.24.1/ly/script-init.ly +94 -0
- data/share/lilypond/2.24.1/ly/spanners-init.ly +146 -0
- data/share/lilypond/2.24.1/ly/ssaattbb.ly +335 -0
- data/share/lilypond/2.24.1/ly/staff-tkit.ly +182 -0
- data/share/lilypond/2.24.1/ly/string-tunings-init.ly +94 -0
- data/share/lilypond/2.24.1/ly/suomi.ly +23 -0
- data/share/lilypond/2.24.1/ly/svenska.ly +23 -0
- data/share/lilypond/2.24.1/ly/swing.ly +362 -0
- data/share/lilypond/2.24.1/ly/text-replacements.ly +150 -0
- data/share/lilypond/2.24.1/ly/titling-init.ly +150 -0
- data/share/lilypond/2.24.1/ly/toc-init.ly +182 -0
- data/share/lilypond/2.24.1/ly/turkish-makam.ly +609 -0
- data/share/lilypond/2.24.1/ly/vlaams.ly +23 -0
- data/share/lilypond/2.24.1/ly/vocal-tkit.ly +103 -0
- data/share/lilypond/2.24.1/ly/voice-tkit.ly +34 -0
- data/share/lilypond/2.24.1/ps/encodingdefs.ps +2611 -0
- data/share/lilypond/2.24.1/ps/lilyponddefs.ps +49 -0
- data/share/lilypond/2.24.1/ps/music-drawing-routines.ps +329 -0
- data/share/lilypond/2.24.1/python/__pycache__/book_base.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/book_docbook.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/book_html.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/book_latex.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/book_snippets.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/book_texinfo.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/convertrules.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/langdefs.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/lilylib.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/midi.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/musicexp.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/musicxml.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/musicxml2ly_conversion.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/__pycache__/utilities.cpython-310.pyc +0 -0
- data/share/lilypond/2.24.1/python/book_base.py +331 -0
- data/share/lilypond/2.24.1/python/book_docbook.py +154 -0
- data/share/lilypond/2.24.1/python/book_html.py +178 -0
- data/share/lilypond/2.24.1/python/book_latex.py +373 -0
- data/share/lilypond/2.24.1/python/book_snippets.py +1052 -0
- data/share/lilypond/2.24.1/python/book_texinfo.py +437 -0
- data/share/lilypond/2.24.1/python/convertrules.py +4764 -0
- data/share/lilypond/2.24.1/python/langdefs.py +131 -0
- data/share/lilypond/2.24.1/python/lilylib.py +141 -0
- data/share/lilypond/2.24.1/python/midi.py +212 -0
- data/share/lilypond/2.24.1/python/musicexp.py +2781 -0
- data/share/lilypond/2.24.1/python/musicxml.py +1905 -0
- data/share/lilypond/2.24.1/python/musicxml2ly_conversion.py +80 -0
- data/share/lilypond/2.24.1/python/utilities.py +280 -0
- data/share/lilypond/2.24.1/scm/lily/accreg.scm +579 -0
- data/share/lilypond/2.24.1/scm/lily/auto-beam.scm +163 -0
- data/share/lilypond/2.24.1/scm/lily/autochange.scm +100 -0
- data/share/lilypond/2.24.1/scm/lily/backend-library.scm +593 -0
- data/share/lilypond/2.24.1/scm/lily/bar-line.scm +1281 -0
- data/share/lilypond/2.24.1/scm/lily/breath.scm +74 -0
- data/share/lilypond/2.24.1/scm/lily/c++.scm +174 -0
- data/share/lilypond/2.24.1/scm/lily/chord-entry.scm +278 -0
- data/share/lilypond/2.24.1/scm/lily/chord-ignatzek-names.scm +304 -0
- data/share/lilypond/2.24.1/scm/lily/chord-name.scm +217 -0
- data/share/lilypond/2.24.1/scm/lily/clip-region.scm +87 -0
- data/share/lilypond/2.24.1/scm/lily/color.scm +757 -0
- data/share/lilypond/2.24.1/scm/lily/curried-definitions.scm +68 -0
- data/share/lilypond/2.24.1/scm/lily/define-context-properties.scm +939 -0
- data/share/lilypond/2.24.1/scm/lily/define-event-classes.scm +142 -0
- data/share/lilypond/2.24.1/scm/lily/define-grob-interfaces.scm +640 -0
- data/share/lilypond/2.24.1/scm/lily/define-grob-properties.scm +1647 -0
- data/share/lilypond/2.24.1/scm/lily/define-grobs.scm +4027 -0
- data/share/lilypond/2.24.1/scm/lily/define-markup-commands.scm +5737 -0
- data/share/lilypond/2.24.1/scm/lily/define-music-callbacks.scm +257 -0
- data/share/lilypond/2.24.1/scm/lily/define-music-display-methods.scm +1350 -0
- data/share/lilypond/2.24.1/scm/lily/define-music-properties.scm +242 -0
- data/share/lilypond/2.24.1/scm/lily/define-music-types.scm +983 -0
- data/share/lilypond/2.24.1/scm/lily/define-note-names.scm +1421 -0
- data/share/lilypond/2.24.1/scm/lily/define-stencil-commands.scm +71 -0
- data/share/lilypond/2.24.1/scm/lily/define-woodwind-diagrams.scm +1215 -0
- data/share/lilypond/2.24.1/scm/lily/display-lily.scm +315 -0
- data/share/lilypond/2.24.1/scm/lily/display-woodwind-diagrams.scm +1985 -0
- data/share/lilypond/2.24.1/scm/lily/document-backend.scm +307 -0
- data/share/lilypond/2.24.1/scm/lily/document-context-mods.scm +98 -0
- data/share/lilypond/2.24.1/scm/lily/document-functions.scm +169 -0
- data/share/lilypond/2.24.1/scm/lily/document-identifiers.scm +76 -0
- data/share/lilypond/2.24.1/scm/lily/document-markup.scm +158 -0
- data/share/lilypond/2.24.1/scm/lily/document-music.scm +146 -0
- data/share/lilypond/2.24.1/scm/lily/document-outside-staff-priorities.scm +40 -0
- data/share/lilypond/2.24.1/scm/lily/document-paper-sizes.scm +71 -0
- data/share/lilypond/2.24.1/scm/lily/document-translation.scm +318 -0
- data/share/lilypond/2.24.1/scm/lily/document-type-predicates.scm +85 -0
- data/share/lilypond/2.24.1/scm/lily/documentation-generate.scm +259 -0
- data/share/lilypond/2.24.1/scm/lily/documentation-lib.scm +207 -0
- data/share/lilypond/2.24.1/scm/lily/file-cache.scm +28 -0
- data/share/lilypond/2.24.1/scm/lily/flag-styles.scm +249 -0
- data/share/lilypond/2.24.1/scm/lily/font-encodings.scm +1242 -0
- data/share/lilypond/2.24.1/scm/lily/font.scm +303 -0
- data/share/lilypond/2.24.1/scm/lily/framework-cairo.scm +26 -0
- data/share/lilypond/2.24.1/scm/lily/framework-ps.scm +896 -0
- data/share/lilypond/2.24.1/scm/lily/framework-svg.scm +172 -0
- data/share/lilypond/2.24.1/scm/lily/fret-diagrams.scm +1261 -0
- data/share/lilypond/2.24.1/scm/lily/graphviz.scm +78 -0
- data/share/lilypond/2.24.1/scm/lily/guile-debugger.scm +90 -0
- data/share/lilypond/2.24.1/scm/lily/harp-pedals.scm +172 -0
- data/share/lilypond/2.24.1/scm/lily/hyphenate-internal-words.scm +51 -0
- data/share/lilypond/2.24.1/scm/lily/layout-beam.scm +73 -0
- data/share/lilypond/2.24.1/scm/lily/layout-slur.scm +45 -0
- data/share/lilypond/2.24.1/scm/lily/lily-library.scm +1446 -0
- data/share/lilypond/2.24.1/scm/lily/lily-sort.scm +116 -0
- data/share/lilypond/2.24.1/scm/lily/lily.scm +929 -0
- data/share/lilypond/2.24.1/scm/lily/ly-syntax-constructors.scm +374 -0
- data/share/lilypond/2.24.1/scm/lily/markup-macros.scm +493 -0
- data/share/lilypond/2.24.1/scm/lily/markup.scm +126 -0
- data/share/lilypond/2.24.1/scm/lily/midi.scm +258 -0
- data/share/lilypond/2.24.1/scm/lily/modal-transforms.scm +337 -0
- data/share/lilypond/2.24.1/scm/lily/music-functions.scm +2878 -0
- data/share/lilypond/2.24.1/scm/lily/output-lib.scm +3377 -0
- data/share/lilypond/2.24.1/scm/lily/output-ps.scm +335 -0
- data/share/lilypond/2.24.1/scm/lily/output-svg.scm +684 -0
- data/share/lilypond/2.24.1/scm/lily/page.scm +321 -0
- data/share/lilypond/2.24.1/scm/lily/paper-system.scm +271 -0
- data/share/lilypond/2.24.1/scm/lily/paper.scm +376 -0
- data/share/lilypond/2.24.1/scm/lily/parser-clef.scm +205 -0
- data/share/lilypond/2.24.1/scm/lily/parser-ly-from-scheme.scm +170 -0
- data/share/lilypond/2.24.1/scm/lily/part-combiner.scm +998 -0
- data/share/lilypond/2.24.1/scm/lily/predefined-fretboards.scm +54 -0
- data/share/lilypond/2.24.1/scm/lily/ps-to-png.scm +182 -0
- data/share/lilypond/2.24.1/scm/lily/scheme-engravers.scm +1813 -0
- data/share/lilypond/2.24.1/scm/lily/scheme-performers.scm +126 -0
- data/share/lilypond/2.24.1/scm/lily/script.scm +416 -0
- data/share/lilypond/2.24.1/scm/lily/skyline.scm +25 -0
- data/share/lilypond/2.24.1/scm/lily/song-util.scm +191 -0
- data/share/lilypond/2.24.1/scm/lily/song.scm +853 -0
- data/share/lilypond/2.24.1/scm/lily/stencil.scm +998 -0
- data/share/lilypond/2.24.1/scm/lily/tablature.scm +392 -0
- data/share/lilypond/2.24.1/scm/lily/time-signature-settings.scm +473 -0
- data/share/lilypond/2.24.1/scm/lily/time-signature.scm +35 -0
- data/share/lilypond/2.24.1/scm/lily/titling.scm +99 -0
- data/share/lilypond/2.24.1/scm/lily/to-xml.scm +254 -0
- data/share/lilypond/2.24.1/scm/lily/translation-functions.scm +1169 -0
- data/share/lilypond/2.24.1/vim/compiler/lilypond.vim +36 -0
- data/share/lilypond/2.24.1/vim/ftdetect/lilypond.vim +4 -0
- data/share/lilypond/2.24.1/vim/ftplugin/lilypond.vim +91 -0
- data/share/lilypond/2.24.1/vim/indent/lilypond.vim +79 -0
- data/share/lilypond/2.24.1/vim/syntax/lilypond-words +1408 -0
- data/share/lilypond/2.24.1/vim/syntax/lilypond-words.vim +3 -0
- data/share/lilypond/2.24.1/vim/syntax/lilypond.vim +104 -0
- data/share/locale/ca/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/cs/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/da/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/de/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/el/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/eo/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/es/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/fi/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/fr/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/it/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/ja/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/nl/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/ru/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/sv/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/tr/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/uk/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/vi/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/zh_CN/LC_MESSAGES/lilypond.mo +0 -0
- data/share/locale/zh_TW/LC_MESSAGES/lilypond.mo +0 -0
- metadata +1135 -4
@@ -0,0 +1,3176 @@
|
|
1
|
+
;;;; goops.scm -- The Guile Object-Oriented Programming System
|
2
|
+
;;;;
|
3
|
+
;;;; Copyright (C) 1998-2003, 2006, 2009-2011, 2013-2015, 2018
|
4
|
+
;;;; Free Software Foundation, Inc.
|
5
|
+
;;;; Copyright (C) 1993-1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
|
6
|
+
;;;;
|
7
|
+
;;;; This library is free software; you can redistribute it and/or
|
8
|
+
;;;; modify it under the terms of the GNU Lesser General Public
|
9
|
+
;;;; License as published by the Free Software Foundation; either
|
10
|
+
;;;; version 3 of the License, or (at your option) any later version.
|
11
|
+
;;;;
|
12
|
+
;;;; This library is distributed in the hope that it will be useful,
|
13
|
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
;;;; Lesser General Public License for more details.
|
16
|
+
;;;;
|
17
|
+
;;;; You should have received a copy of the GNU Lesser General Public
|
18
|
+
;;;; License along with this library; if not, write to the Free Software
|
19
|
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
+
;;;;
|
21
|
+
|
22
|
+
|
23
|
+
;;;;
|
24
|
+
;;;; This file was based upon stklos.stk from the STk distribution
|
25
|
+
;;;; version 4.0.1 by Erick Gallesio <eg@unice.fr>.
|
26
|
+
;;;;
|
27
|
+
|
28
|
+
(define-module (oop goops)
|
29
|
+
#:use-module (srfi srfi-1)
|
30
|
+
#:use-module (ice-9 match)
|
31
|
+
#:use-module ((language tree-il primitives)
|
32
|
+
:select (add-interesting-primitive!))
|
33
|
+
#:export-syntax (define-class class standard-define-class
|
34
|
+
define-generic define-accessor define-method
|
35
|
+
define-extended-generic define-extended-generics
|
36
|
+
method)
|
37
|
+
#:export ( ;; The root of everything.
|
38
|
+
<top>
|
39
|
+
<class> <object>
|
40
|
+
|
41
|
+
;; Slot types.
|
42
|
+
<slot>
|
43
|
+
<foreign-slot> <protected-slot> <hidden-slot> <opaque-slot>
|
44
|
+
<read-only-slot> <self-slot> <protected-opaque-slot>
|
45
|
+
<protected-hidden-slot> <protected-read-only-slot>
|
46
|
+
<scm-slot> <int-slot> <float-slot> <double-slot>
|
47
|
+
|
48
|
+
;; Methods are implementations of generic functions.
|
49
|
+
<method> <accessor-method>
|
50
|
+
|
51
|
+
;; Applicable objects, either procedures or applicable structs.
|
52
|
+
<procedure-class> <applicable>
|
53
|
+
<procedure> <primitive-generic>
|
54
|
+
|
55
|
+
;; Applicable structs.
|
56
|
+
<applicable-struct-class> <applicable-struct-with-setter-class>
|
57
|
+
<applicable-struct> <applicable-struct-with-setter>
|
58
|
+
<generic> <extended-generic>
|
59
|
+
<generic-with-setter> <extended-generic-with-setter>
|
60
|
+
<accessor> <extended-accessor>
|
61
|
+
|
62
|
+
;; Types with their own allocated typecodes.
|
63
|
+
<boolean> <char> <list> <pair> <null> <string> <symbol>
|
64
|
+
<vector> <bytevector> <uvec> <foreign> <hashtable>
|
65
|
+
<fluid> <dynamic-state> <frame> <vm> <vm-continuation>
|
66
|
+
<keyword> <syntax> <atomic-box>
|
67
|
+
|
68
|
+
;; Numbers.
|
69
|
+
<number> <complex> <real> <integer> <fraction>
|
70
|
+
|
71
|
+
;; Unknown.
|
72
|
+
<unknown>
|
73
|
+
|
74
|
+
;; Particular SMOB data types. All SMOB types have
|
75
|
+
;; corresponding classes, which may be obtained via class-of,
|
76
|
+
;; once you have an instance. Perhaps FIXME to provide a
|
77
|
+
;; smob-type-name->class procedure.
|
78
|
+
<promise> <thread> <mutex> <condition-variable>
|
79
|
+
<regexp> <hook> <bitvector> <random-state>
|
80
|
+
<directory> <array> <character-set>
|
81
|
+
<dynamic-object> <guardian> <macro>
|
82
|
+
|
83
|
+
;; Modules.
|
84
|
+
<module>
|
85
|
+
|
86
|
+
;; Ports.
|
87
|
+
<port> <input-port> <output-port> <input-output-port>
|
88
|
+
|
89
|
+
;; Like SMOB types, all port types have their own classes,
|
90
|
+
;; which can be accessed via `class-of' once you have an
|
91
|
+
;; instance. Here we export bindings just for file ports.
|
92
|
+
<file-port>
|
93
|
+
<file-input-port> <file-output-port> <file-input-output-port>
|
94
|
+
|
95
|
+
is-a? class-of
|
96
|
+
ensure-metaclass ensure-metaclass-with-supers
|
97
|
+
make-class
|
98
|
+
make-generic ensure-generic
|
99
|
+
make-extended-generic
|
100
|
+
make-accessor ensure-accessor
|
101
|
+
add-method!
|
102
|
+
class-slot-ref class-slot-set! slot-unbound slot-missing
|
103
|
+
slot-definition-name slot-definition-options
|
104
|
+
slot-definition-allocation
|
105
|
+
|
106
|
+
slot-definition-getter slot-definition-setter
|
107
|
+
slot-definition-accessor
|
108
|
+
slot-definition-init-value slot-definition-init-form
|
109
|
+
slot-definition-init-thunk slot-definition-init-keyword
|
110
|
+
slot-init-function class-slot-definition
|
111
|
+
method-source
|
112
|
+
compute-cpl compute-std-cpl compute-get-n-set compute-slots
|
113
|
+
compute-getter-method compute-setter-method
|
114
|
+
allocate-instance initialize make-instance make
|
115
|
+
no-next-method no-applicable-method no-method
|
116
|
+
change-class update-instance-for-different-class
|
117
|
+
shallow-clone deep-clone
|
118
|
+
class-redefinition
|
119
|
+
apply-generic apply-method apply-methods
|
120
|
+
compute-applicable-methods %compute-applicable-methods
|
121
|
+
method-more-specific? sort-applicable-methods
|
122
|
+
class-subclasses class-methods
|
123
|
+
goops-error
|
124
|
+
min-fixnum max-fixnum
|
125
|
+
|
126
|
+
instance?
|
127
|
+
slot-ref slot-set! slot-bound? slot-exists?
|
128
|
+
class-name class-direct-supers class-direct-subclasses
|
129
|
+
class-direct-methods class-direct-slots class-precedence-list
|
130
|
+
class-slots
|
131
|
+
generic-function-name
|
132
|
+
generic-function-methods method-generic-function
|
133
|
+
method-specializers method-formals
|
134
|
+
primitive-generic-generic enable-primitive-generic!
|
135
|
+
method-procedure accessor-method-slot-definition
|
136
|
+
make find-method get-keyword))
|
137
|
+
|
138
|
+
|
139
|
+
;;;
|
140
|
+
;;; Booting GOOPS is a tortuous process. We begin by loading a small
|
141
|
+
;;; set of primitives from C.
|
142
|
+
;;;
|
143
|
+
(eval-when (expand load eval)
|
144
|
+
(load-extension (string-append "libguile-" (effective-version))
|
145
|
+
"scm_init_goops_builtins")
|
146
|
+
(add-interesting-primitive! 'class-of))
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
;;;
|
152
|
+
;;; We then define the slots that must appear in all classes (<class>
|
153
|
+
;;; objects) and slot definitions (<slot> objects). These slots must
|
154
|
+
;;; appear in order. We'll use this list to statically compute offsets
|
155
|
+
;;; for the various fields, to compute the struct layout for <class>
|
156
|
+
;;; instances, and to compute the slot definition lists for <class>.
|
157
|
+
;;; Because the list is needed at expansion-time, we define it as a
|
158
|
+
;;; macro.
|
159
|
+
;;;
|
160
|
+
(define-syntax macro-fold-left
|
161
|
+
(syntax-rules ()
|
162
|
+
((_ folder seed ()) seed)
|
163
|
+
((_ folder seed (head . tail))
|
164
|
+
(macro-fold-left folder (folder head seed) tail))))
|
165
|
+
|
166
|
+
(define-syntax macro-fold-right
|
167
|
+
(syntax-rules ()
|
168
|
+
((_ folder seed ()) seed)
|
169
|
+
((_ folder seed (head . tail))
|
170
|
+
(folder head (macro-fold-right folder seed tail)))))
|
171
|
+
|
172
|
+
(define-syntax-rule (define-macro-folder macro-folder value ...)
|
173
|
+
(define-syntax macro-folder
|
174
|
+
(lambda (x)
|
175
|
+
(syntax-case x ()
|
176
|
+
((_ fold visit seed)
|
177
|
+
;; The datum->syntax makes it as if each `value' were present
|
178
|
+
;; in the initial form, which allows them to be used as
|
179
|
+
;; (components of) introduced identifiers.
|
180
|
+
#`(fold visit seed #,(datum->syntax #'visit '(value ...))))))))
|
181
|
+
|
182
|
+
(define-macro-folder fold-class-slots
|
183
|
+
(layout #:class <protected-read-only-slot>)
|
184
|
+
(flags #:class <hidden-slot>)
|
185
|
+
(self #:class <self-slot>)
|
186
|
+
(instance-finalizer #:class <hidden-slot>)
|
187
|
+
(print)
|
188
|
+
(name #:class <protected-hidden-slot>)
|
189
|
+
(nfields #:class <hidden-slot>)
|
190
|
+
(%reserved #:class <hidden-slot>)
|
191
|
+
(redefined)
|
192
|
+
(direct-supers)
|
193
|
+
(direct-slots)
|
194
|
+
(direct-subclasses)
|
195
|
+
(direct-methods)
|
196
|
+
(cpl)
|
197
|
+
(slots))
|
198
|
+
|
199
|
+
(define-macro-folder fold-slot-slots
|
200
|
+
(name #:init-keyword #:name)
|
201
|
+
(allocation #:init-keyword #:allocation #:init-value #:instance)
|
202
|
+
(init-keyword #:init-keyword #:init-keyword #:init-value #f)
|
203
|
+
(init-form #:init-keyword #:init-form)
|
204
|
+
(init-value #:init-keyword #:init-value)
|
205
|
+
(init-thunk #:init-keyword #:init-thunk #:init-value #f)
|
206
|
+
(options)
|
207
|
+
(getter #:init-keyword #:getter #:init-value #f)
|
208
|
+
(setter #:init-keyword #:setter #:init-value #f)
|
209
|
+
(accessor #:init-keyword #:accessor #:init-value #f)
|
210
|
+
;; These last don't have #:init-keyword because they are meant to be
|
211
|
+
;; set by `allocate-slots', not in compute-effective-slot-definition.
|
212
|
+
(slot-ref/raw #:init-value #f)
|
213
|
+
(slot-ref #:init-value #f)
|
214
|
+
(slot-set! #:init-value #f)
|
215
|
+
(index #:init-value #f)
|
216
|
+
(size #:init-value #f))
|
217
|
+
|
218
|
+
;;;
|
219
|
+
;;; Statically define variables for slot offsets: `class-index-layout'
|
220
|
+
;;; will be 0, `class-index-flags' will be 1, and so on, and the same
|
221
|
+
;;; for `slot-index-name' and such for <slot>.
|
222
|
+
;;;
|
223
|
+
(let-syntax ((define-slot-indexer
|
224
|
+
(syntax-rules ()
|
225
|
+
((_ define-index prefix)
|
226
|
+
(define-syntax define-index
|
227
|
+
(lambda (x)
|
228
|
+
(define (id-append ctx a b)
|
229
|
+
(datum->syntax ctx (symbol-append (syntax->datum a)
|
230
|
+
(syntax->datum b))))
|
231
|
+
(define (tail-length tail)
|
232
|
+
(syntax-case tail ()
|
233
|
+
((begin) 0)
|
234
|
+
((visit head tail) (1+ (tail-length #'tail)))))
|
235
|
+
(syntax-case x ()
|
236
|
+
((_ (name . _) tail)
|
237
|
+
#`(begin
|
238
|
+
(define-syntax #,(id-append #'name #'prefix #'name)
|
239
|
+
(identifier-syntax #,(tail-length #'tail)))
|
240
|
+
tail)))))))))
|
241
|
+
(define-slot-indexer define-class-index class-index-)
|
242
|
+
(define-slot-indexer define-slot-index slot-index-)
|
243
|
+
(fold-class-slots macro-fold-left define-class-index (begin))
|
244
|
+
(fold-slot-slots macro-fold-left define-slot-index (begin)))
|
245
|
+
|
246
|
+
;;;
|
247
|
+
;;; Structs that are vtables have a "flags" slot, which corresponds to
|
248
|
+
;;; class-index-flags. `vtable-flag-vtable' indicates that instances of
|
249
|
+
;;; a vtable are themselves vtables, and `vtable-flag-validated'
|
250
|
+
;;; indicates that the struct's layout has been validated. goops.c
|
251
|
+
;;; defines a few additional flags: one to indicate that a vtable is
|
252
|
+
;;; actually a class, one to indicate that the class is "valid" (meaning
|
253
|
+
;;; that it hasn't been redefined), and one to indicate that instances
|
254
|
+
;;; of a class are slot definition objects (<slot> instances).
|
255
|
+
;;;
|
256
|
+
(define vtable-flag-goops-metaclass
|
257
|
+
(logior vtable-flag-vtable vtable-flag-goops-class))
|
258
|
+
|
259
|
+
(define-inlinable (class-add-flags! class flags)
|
260
|
+
(struct-set!/unboxed
|
261
|
+
class
|
262
|
+
class-index-flags
|
263
|
+
(logior flags (struct-ref/unboxed class class-index-flags))))
|
264
|
+
|
265
|
+
(define-inlinable (class-clear-flags! class flags)
|
266
|
+
(struct-set!/unboxed
|
267
|
+
class
|
268
|
+
class-index-flags
|
269
|
+
(logand (lognot flags) (struct-ref/unboxed class class-index-flags))))
|
270
|
+
|
271
|
+
(define-inlinable (class-has-flags? class flags)
|
272
|
+
(eqv? flags
|
273
|
+
(logand (struct-ref/unboxed class class-index-flags) flags)))
|
274
|
+
|
275
|
+
(define-inlinable (class? obj)
|
276
|
+
(class-has-flags? (struct-vtable obj) vtable-flag-goops-metaclass))
|
277
|
+
|
278
|
+
(define-inlinable (slot? obj)
|
279
|
+
(and (struct? obj)
|
280
|
+
(class-has-flags? (struct-vtable obj) vtable-flag-goops-slot)))
|
281
|
+
|
282
|
+
(define-inlinable (instance? obj)
|
283
|
+
(and (struct? obj)
|
284
|
+
(class-has-flags? (struct-vtable obj) vtable-flag-goops-class)))
|
285
|
+
|
286
|
+
(define (class-has-statically-allocated-slots? class)
|
287
|
+
(class-has-flags? class vtable-flag-goops-static))
|
288
|
+
|
289
|
+
;;;
|
290
|
+
;;; Now that we know the slots that must be present in classes, and
|
291
|
+
;;; their offsets, we can create the root of the class hierarchy.
|
292
|
+
;;;
|
293
|
+
;;; Note that the `direct-supers', `direct-slots', `cpl', and `slots'
|
294
|
+
;;; fields will be updated later, once we can create slot definition
|
295
|
+
;;; objects and once we have definitions for <top> and <object>.
|
296
|
+
;;;
|
297
|
+
(define <class>
|
298
|
+
(let-syntax ((cons-layout
|
299
|
+
;; A simple way to compute class layout for the concrete
|
300
|
+
;; types used in <class>.
|
301
|
+
(syntax-rules (<protected-read-only-slot>
|
302
|
+
<self-slot>
|
303
|
+
<hidden-slot>
|
304
|
+
<protected-hidden-slot>)
|
305
|
+
((_ (name) tail)
|
306
|
+
(string-append "pw" tail))
|
307
|
+
((_ (name #:class <protected-read-only-slot>) tail)
|
308
|
+
(string-append "pr" tail))
|
309
|
+
((_ (name #:class <self-slot>) tail)
|
310
|
+
(string-append "sr" tail))
|
311
|
+
((_ (name #:class <hidden-slot>) tail)
|
312
|
+
(string-append "uh" tail))
|
313
|
+
((_ (name #:class <protected-hidden-slot>) tail)
|
314
|
+
(string-append "ph" tail)))))
|
315
|
+
(let* ((layout (fold-class-slots macro-fold-right cons-layout ""))
|
316
|
+
(nfields (/ (string-length layout) 2))
|
317
|
+
(<class> (%make-vtable-vtable layout)))
|
318
|
+
(class-add-flags! <class> (logior vtable-flag-goops-class
|
319
|
+
vtable-flag-goops-valid))
|
320
|
+
(struct-set! <class> class-index-name '<class>)
|
321
|
+
(struct-set!/unboxed <class> class-index-nfields nfields)
|
322
|
+
(struct-set! <class> class-index-direct-supers '())
|
323
|
+
(struct-set! <class> class-index-direct-slots '())
|
324
|
+
(struct-set! <class> class-index-direct-subclasses '())
|
325
|
+
(struct-set! <class> class-index-direct-methods '())
|
326
|
+
(struct-set! <class> class-index-cpl '())
|
327
|
+
(struct-set! <class> class-index-slots '())
|
328
|
+
(struct-set! <class> class-index-redefined #f)
|
329
|
+
<class>)))
|
330
|
+
|
331
|
+
;;;
|
332
|
+
;;; Accessors to fields of <class>.
|
333
|
+
;;;
|
334
|
+
(define-syntax-rule (define-class-accessor name docstring field)
|
335
|
+
(define (name obj)
|
336
|
+
docstring
|
337
|
+
(let ((val obj))
|
338
|
+
(unless (class? val)
|
339
|
+
(scm-error 'wrong-type-arg #f "Not a class: ~S"
|
340
|
+
(list val) #f))
|
341
|
+
(struct-ref val field))))
|
342
|
+
|
343
|
+
(define-class-accessor class-name
|
344
|
+
"Return the class name of @var{obj}."
|
345
|
+
class-index-name)
|
346
|
+
(define-class-accessor class-direct-supers
|
347
|
+
"Return the direct superclasses of the class @var{obj}."
|
348
|
+
class-index-direct-supers)
|
349
|
+
(define-class-accessor class-direct-slots
|
350
|
+
"Return the direct slots of the class @var{obj}."
|
351
|
+
class-index-direct-slots)
|
352
|
+
(define-class-accessor class-direct-subclasses
|
353
|
+
"Return the direct subclasses of the class @var{obj}."
|
354
|
+
class-index-direct-subclasses)
|
355
|
+
(define-class-accessor class-direct-methods
|
356
|
+
"Return the direct methods of the class @var{obj}."
|
357
|
+
class-index-direct-methods)
|
358
|
+
(define-class-accessor class-precedence-list
|
359
|
+
"Return the class precedence list of the class @var{obj}."
|
360
|
+
class-index-cpl)
|
361
|
+
(define-class-accessor class-slots
|
362
|
+
"Return the slot list of the class @var{obj}."
|
363
|
+
class-index-slots)
|
364
|
+
|
365
|
+
(define (class-subclasses c)
|
366
|
+
"Compute a list of all subclasses of @var{c}, direct and indirect."
|
367
|
+
(define (all-subclasses c)
|
368
|
+
(cons c (append-map all-subclasses
|
369
|
+
(class-direct-subclasses c))))
|
370
|
+
(delete-duplicates (cdr (all-subclasses c)) eq?))
|
371
|
+
|
372
|
+
(define (class-methods c)
|
373
|
+
"Compute a list of all methods that specialize on @var{c} or
|
374
|
+
subclasses of @var{c}."
|
375
|
+
(delete-duplicates (append-map class-direct-methods
|
376
|
+
(cons c (class-subclasses c)))
|
377
|
+
eq?))
|
378
|
+
|
379
|
+
(define (is-a? obj class)
|
380
|
+
"Return @code{#t} if @var{obj} is an instance of @var{class}, or
|
381
|
+
@code{#f} otherwise."
|
382
|
+
(and (memq class (class-precedence-list (class-of obj))) #t))
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
;;;
|
388
|
+
;;; At this point, <class> is missing slot definitions, but we can't
|
389
|
+
;;; create slot definitions until we have a slot definition class.
|
390
|
+
;;; Continue with manual object creation until we're able to bootstrap
|
391
|
+
;;; more of the protocol. Again, the CPL and class hierarchy slots
|
392
|
+
;;; remain uninitialized.
|
393
|
+
;;;
|
394
|
+
(define* (get-keyword key l #:optional default)
|
395
|
+
"Determine an associated value for the keyword @var{key} from the list
|
396
|
+
@var{l}. The list @var{l} has to consist of an even number of elements,
|
397
|
+
where, starting with the first, every second element is a keyword,
|
398
|
+
followed by its associated value. If @var{l} does not hold a value for
|
399
|
+
@var{key}, the value @var{default} is returned."
|
400
|
+
(unless (keyword? key)
|
401
|
+
(scm-error 'wrong-type-arg #f "Not a keyword: ~S" (list key) #f))
|
402
|
+
(let lp ((l l))
|
403
|
+
(match l
|
404
|
+
(() default)
|
405
|
+
((kw arg . l)
|
406
|
+
(unless (keyword? kw)
|
407
|
+
(scm-error 'wrong-type-arg #f "Not a keyword: ~S" (list kw) #f))
|
408
|
+
(if (eq? kw key) arg (lp l))))))
|
409
|
+
|
410
|
+
(define *unbound* (list 'unbound))
|
411
|
+
|
412
|
+
(define-inlinable (unbound? x)
|
413
|
+
(eq? x *unbound*))
|
414
|
+
|
415
|
+
(define (%allocate-instance class)
|
416
|
+
(let ((obj (allocate-struct class
|
417
|
+
(struct-ref/unboxed class class-index-nfields))))
|
418
|
+
(%clear-fields! obj *unbound*)
|
419
|
+
obj))
|
420
|
+
|
421
|
+
(define <slot>
|
422
|
+
(let-syntax ((cons-layout
|
423
|
+
;; All slots are "pw" in <slot>.
|
424
|
+
(syntax-rules ()
|
425
|
+
((_ _ tail) (string-append "pw" tail)))))
|
426
|
+
(let* ((layout (fold-slot-slots macro-fold-right cons-layout ""))
|
427
|
+
(nfields (/ (string-length layout) 2))
|
428
|
+
(<slot> (make-struct/no-tail <class> (make-struct-layout layout))))
|
429
|
+
(class-add-flags! <slot> (logior vtable-flag-goops-class
|
430
|
+
vtable-flag-goops-slot
|
431
|
+
vtable-flag-goops-valid))
|
432
|
+
(struct-set! <slot> class-index-name '<slot>)
|
433
|
+
(struct-set!/unboxed <slot> class-index-nfields nfields)
|
434
|
+
(struct-set! <slot> class-index-direct-supers '())
|
435
|
+
(struct-set! <slot> class-index-direct-slots '())
|
436
|
+
(struct-set! <slot> class-index-direct-subclasses '())
|
437
|
+
(struct-set! <slot> class-index-direct-methods '())
|
438
|
+
(struct-set! <slot> class-index-cpl (list <slot>))
|
439
|
+
(struct-set! <slot> class-index-slots '())
|
440
|
+
(struct-set! <slot> class-index-redefined #f)
|
441
|
+
<slot>)))
|
442
|
+
|
443
|
+
;;; Access to slot objects is performance-sensitive for slot-ref, so in
|
444
|
+
;;; addition to the type-checking accessors that we export, we also
|
445
|
+
;;; define some internal inlined helpers that just do an unchecked
|
446
|
+
;;; struct-ref in cases where we know the object must be a slot, as
|
447
|
+
;;; when accessing class-slots.
|
448
|
+
;;;
|
449
|
+
(define-syntax-rule (define-slot-accessor name docstring %name field)
|
450
|
+
(begin
|
451
|
+
(define-syntax-rule (%name obj)
|
452
|
+
(struct-ref obj field))
|
453
|
+
(define (name obj)
|
454
|
+
docstring
|
455
|
+
(unless (slot? obj)
|
456
|
+
(scm-error 'wrong-type-arg #f "Not a slot: ~S"
|
457
|
+
(list obj) #f))
|
458
|
+
(%name obj))))
|
459
|
+
|
460
|
+
(define-slot-accessor slot-definition-name
|
461
|
+
"Return the name of @var{obj}."
|
462
|
+
%slot-definition-name slot-index-name)
|
463
|
+
(define-slot-accessor slot-definition-allocation
|
464
|
+
"Return the allocation of the slot @var{obj}."
|
465
|
+
%slot-definition-allocation slot-index-allocation)
|
466
|
+
(define-slot-accessor slot-definition-init-keyword
|
467
|
+
"Return the init keyword of the slot @var{obj}, or @code{#f}."
|
468
|
+
%slot-definition-init-keyword slot-index-init-keyword)
|
469
|
+
(define-slot-accessor slot-definition-init-form
|
470
|
+
"Return the init form of the slot @var{obj}, or the unbound value"
|
471
|
+
%slot-definition-init-form slot-index-init-form)
|
472
|
+
(define-slot-accessor slot-definition-init-value
|
473
|
+
"Return the init value of the slot @var{obj}, or the unbound value."
|
474
|
+
%slot-definition-init-value slot-index-init-value)
|
475
|
+
(define-slot-accessor slot-definition-init-thunk
|
476
|
+
"Return the init thunk of the slot @var{obj}, or @code{#f}."
|
477
|
+
%slot-definition-init-thunk slot-index-init-thunk)
|
478
|
+
(define-slot-accessor slot-definition-options
|
479
|
+
"Return the initargs given when creating the slot @var{obj}."
|
480
|
+
%slot-definition-options slot-index-options)
|
481
|
+
(define-slot-accessor slot-definition-getter
|
482
|
+
"Return the getter of the slot @var{obj}, or @code{#f}."
|
483
|
+
%slot-definition-getter slot-index-getter)
|
484
|
+
(define-slot-accessor slot-definition-setter
|
485
|
+
"Return the setter of the slot @var{obj}, or @code{#f}."
|
486
|
+
%slot-definition-setter slot-index-setter)
|
487
|
+
(define-slot-accessor slot-definition-accessor
|
488
|
+
"Return the accessor of the slot @var{obj}, or @code{#f}."
|
489
|
+
%slot-definition-accessor slot-index-accessor)
|
490
|
+
(define-slot-accessor slot-definition-slot-ref/raw
|
491
|
+
"Return the raw slot-ref procedure of the slot @var{obj}."
|
492
|
+
%slot-definition-slot-ref/raw slot-index-slot-ref/raw)
|
493
|
+
(define-slot-accessor slot-definition-slot-ref
|
494
|
+
"Return the slot-ref procedure of the slot @var{obj}."
|
495
|
+
%slot-definition-slot-ref slot-index-slot-ref)
|
496
|
+
(define-slot-accessor slot-definition-slot-set!
|
497
|
+
"Return the slot-set! procedure of the slot @var{obj}."
|
498
|
+
%slot-definition-slot-set! slot-index-slot-set!)
|
499
|
+
(define-slot-accessor slot-definition-index
|
500
|
+
"Return the allocated struct offset of the slot @var{obj}, or @code{#f}."
|
501
|
+
%slot-definition-index slot-index-index)
|
502
|
+
(define-slot-accessor slot-definition-size
|
503
|
+
"Return the number fields used by the slot @var{obj}, or @code{#f}."
|
504
|
+
%slot-definition-size slot-index-size)
|
505
|
+
|
506
|
+
;; Boot definition.
|
507
|
+
(define (direct-slot-definition-class class initargs)
|
508
|
+
(get-keyword #:class initargs <slot>))
|
509
|
+
|
510
|
+
;; Boot definition.
|
511
|
+
(define (make-slot class initargs)
|
512
|
+
(let ((slot (make-struct/no-tail class)))
|
513
|
+
(define-syntax-rule (init-slot offset kw default)
|
514
|
+
(struct-set! slot offset (get-keyword kw initargs default)))
|
515
|
+
(init-slot slot-index-name #:name #f)
|
516
|
+
(init-slot slot-index-allocation #:allocation #:instance)
|
517
|
+
(init-slot slot-index-init-keyword #:init-keyword #f)
|
518
|
+
(init-slot slot-index-init-form #:init-form *unbound*)
|
519
|
+
(init-slot slot-index-init-value #:init-value *unbound*)
|
520
|
+
(struct-set! slot slot-index-init-thunk
|
521
|
+
(or (get-keyword #:init-thunk initargs #f)
|
522
|
+
(let ((val (%slot-definition-init-value slot)))
|
523
|
+
(if (unbound? val)
|
524
|
+
#f
|
525
|
+
(lambda () val)))))
|
526
|
+
(struct-set! slot slot-index-options initargs)
|
527
|
+
(init-slot slot-index-getter #:getter #f)
|
528
|
+
(init-slot slot-index-setter #:setter #f)
|
529
|
+
(init-slot slot-index-accessor #:accessor #f)
|
530
|
+
(struct-set! slot slot-index-slot-ref/raw #f)
|
531
|
+
(struct-set! slot slot-index-slot-ref #f)
|
532
|
+
(struct-set! slot slot-index-slot-set! #f)
|
533
|
+
(struct-set! slot slot-index-index #f)
|
534
|
+
(struct-set! slot slot-index-size #f)
|
535
|
+
slot))
|
536
|
+
|
537
|
+
;; Boot definition.
|
538
|
+
(define (make class . args)
|
539
|
+
(unless (memq <slot> (class-precedence-list class))
|
540
|
+
(error "Unsupported class: ~S" class))
|
541
|
+
(make-slot class args))
|
542
|
+
|
543
|
+
;; Boot definition.
|
544
|
+
(define (compute-direct-slot-definition class initargs)
|
545
|
+
(apply make (direct-slot-definition-class class initargs) initargs))
|
546
|
+
|
547
|
+
(define (compute-direct-slot-definition-initargs class slot-spec)
|
548
|
+
(match slot-spec
|
549
|
+
((? symbol? name) (list #:name name))
|
550
|
+
(((? symbol? name) . initargs)
|
551
|
+
(cons* #:name name
|
552
|
+
;; If there is an #:init-form, the `class' macro will have
|
553
|
+
;; already added an #:init-thunk. Still, if there isn't an
|
554
|
+
;; #:init-thunk already but we do have an #:init-value,
|
555
|
+
;; synthesize an #:init-thunk initarg. This will ensure
|
556
|
+
;; that the #:init-thunk gets passed on to the effective
|
557
|
+
;; slot definition too.
|
558
|
+
(if (get-keyword #:init-thunk initargs)
|
559
|
+
initargs
|
560
|
+
(let ((value (get-keyword #:init-value initargs *unbound*)))
|
561
|
+
(if (unbound? value)
|
562
|
+
initargs
|
563
|
+
(cons* #:init-thunk (lambda () value) initargs))))))))
|
564
|
+
|
565
|
+
(let ()
|
566
|
+
(define-syntax cons-slot
|
567
|
+
(syntax-rules ()
|
568
|
+
((_ (name #:class class) tail)
|
569
|
+
;; Special case to avoid referencing specialized <slot> kinds,
|
570
|
+
;; which are not defined yet.
|
571
|
+
(cons (list 'name) tail))
|
572
|
+
((_ (name . initargs) tail)
|
573
|
+
(cons (list 'name . initargs) tail))))
|
574
|
+
(define-syntax-rule (initialize-direct-slots! class fold-slots)
|
575
|
+
(let ((specs (fold-slots macro-fold-right cons-slot '())))
|
576
|
+
(define (make-direct-slot-definition spec)
|
577
|
+
(let ((initargs (compute-direct-slot-definition-initargs class spec)))
|
578
|
+
(compute-direct-slot-definition class initargs)))
|
579
|
+
(struct-set! class class-index-direct-slots
|
580
|
+
(map make-direct-slot-definition specs))))
|
581
|
+
|
582
|
+
(initialize-direct-slots! <class> fold-class-slots)
|
583
|
+
(initialize-direct-slots! <slot> fold-slot-slots))
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
;;;
|
589
|
+
;;; OK, at this point we have initialized `direct-slots' on both <class>
|
590
|
+
;;; and <slot>. We need to define a standard way to make subclasses:
|
591
|
+
;;; how to compute the precedence list of subclasses, how to compute the
|
592
|
+
;;; list of slots in a subclass, and what layout to use for instances of
|
593
|
+
;;; those classes.
|
594
|
+
;;;
|
595
|
+
(define (compute-std-cpl c get-direct-supers)
|
596
|
+
"The standard class precedence list computation algorithm."
|
597
|
+
(define (only-non-null lst)
|
598
|
+
(filter (lambda (l) (not (null? l))) lst))
|
599
|
+
|
600
|
+
(define (merge-lists reversed-partial-result inputs)
|
601
|
+
(cond
|
602
|
+
((every null? inputs)
|
603
|
+
(reverse! reversed-partial-result))
|
604
|
+
(else
|
605
|
+
(let* ((candidate (lambda (c)
|
606
|
+
(and (not (any (lambda (l)
|
607
|
+
(memq c (cdr l)))
|
608
|
+
inputs))
|
609
|
+
c)))
|
610
|
+
(candidate-car (lambda (l)
|
611
|
+
(and (not (null? l))
|
612
|
+
(candidate (car l)))))
|
613
|
+
(next (any candidate-car inputs)))
|
614
|
+
(unless next
|
615
|
+
(goops-error "merge-lists: Inconsistent precedence graph"))
|
616
|
+
(let ((remove-next (lambda (l)
|
617
|
+
(if (eq? (car l) next)
|
618
|
+
(cdr l)
|
619
|
+
l))))
|
620
|
+
(merge-lists (cons next reversed-partial-result)
|
621
|
+
(only-non-null (map remove-next inputs))))))))
|
622
|
+
(let ((c-direct-supers (get-direct-supers c)))
|
623
|
+
(merge-lists (list c)
|
624
|
+
(only-non-null (append (map class-precedence-list
|
625
|
+
c-direct-supers)
|
626
|
+
(list c-direct-supers))))))
|
627
|
+
|
628
|
+
;; This version of compute-cpl is replaced with a generic function once
|
629
|
+
;; GOOPS has booted.
|
630
|
+
(define (compute-cpl class)
|
631
|
+
(compute-std-cpl class class-direct-supers))
|
632
|
+
|
633
|
+
(define (effective-slot-definition-class class slot)
|
634
|
+
(class-of slot))
|
635
|
+
|
636
|
+
(define (compute-effective-slot-definition class slot)
|
637
|
+
;; FIXME: Support slot being a list of slots, as in CLOS.
|
638
|
+
(apply make
|
639
|
+
(effective-slot-definition-class class slot)
|
640
|
+
(slot-definition-options slot)))
|
641
|
+
|
642
|
+
(define (build-slots-list dslots cpl)
|
643
|
+
(define (slot-memq slot slots)
|
644
|
+
(let ((name (%slot-definition-name slot)))
|
645
|
+
(let lp ((slots slots))
|
646
|
+
(match slots
|
647
|
+
(() #f)
|
648
|
+
((slot . slots)
|
649
|
+
(or (eq? (%slot-definition-name slot) name) (lp slots)))))))
|
650
|
+
(define (check-cpl slots static-slots)
|
651
|
+
(match static-slots
|
652
|
+
(() #t)
|
653
|
+
((static-slot . static-slots)
|
654
|
+
(when (slot-memq static-slot slots)
|
655
|
+
(scm-error 'misc-error #f
|
656
|
+
"statically allocated inherited field cannot be redefined: ~a"
|
657
|
+
(list (%slot-definition-name static-slot)) '()))
|
658
|
+
(check-cpl slots static-slots))))
|
659
|
+
(define (remove-duplicate-slots slots)
|
660
|
+
(let lp ((slots (reverse slots)) (res '()) (seen '()))
|
661
|
+
(match slots
|
662
|
+
(() res)
|
663
|
+
((slot . slots)
|
664
|
+
(let ((name (%slot-definition-name slot)))
|
665
|
+
(if (memq name seen)
|
666
|
+
(lp slots res seen)
|
667
|
+
(lp slots (cons slot res) (cons name seen))))))))
|
668
|
+
;; For subclases of <class> and <slot>, we need to ensure that the
|
669
|
+
;; <class> or <slot> slots come first.
|
670
|
+
(let ((static-slots
|
671
|
+
(match (filter class-has-statically-allocated-slots? (cdr cpl))
|
672
|
+
(() #f)
|
673
|
+
((class) (struct-ref class class-index-direct-slots))
|
674
|
+
(classes
|
675
|
+
(error "can't subtype multiple classes with static slot allocation"
|
676
|
+
classes)))))
|
677
|
+
(when static-slots
|
678
|
+
(check-cpl dslots static-slots))
|
679
|
+
(let lp ((cpl (cdr cpl)) (res dslots) (static-slots '()))
|
680
|
+
(match cpl
|
681
|
+
(() (remove-duplicate-slots (append static-slots res)))
|
682
|
+
((head . cpl)
|
683
|
+
(let ((new-slots (struct-ref head class-index-direct-slots)))
|
684
|
+
(cond
|
685
|
+
((not static-slots)
|
686
|
+
(lp cpl (append new-slots res) static-slots))
|
687
|
+
((class-has-statically-allocated-slots? head)
|
688
|
+
;; Move static slots to the head of the list.
|
689
|
+
(lp cpl res new-slots))
|
690
|
+
(else
|
691
|
+
(check-cpl new-slots static-slots)
|
692
|
+
(lp cpl (append new-slots res) static-slots)))))))))
|
693
|
+
|
694
|
+
;; Boot definition.
|
695
|
+
(define (compute-get-n-set class slot)
|
696
|
+
(let ((index (struct-ref/unboxed class class-index-nfields)))
|
697
|
+
(struct-set!/unboxed class class-index-nfields (1+ index))
|
698
|
+
index))
|
699
|
+
|
700
|
+
;;; Pre-generate getters and setters for the first 20 slots.
|
701
|
+
(define-syntax define-standard-accessor-method
|
702
|
+
(lambda (stx)
|
703
|
+
(define num-standard-pre-cache 20)
|
704
|
+
(syntax-case stx ()
|
705
|
+
((_ ((proc n) arg ...) body)
|
706
|
+
#`(define proc
|
707
|
+
(let ((cache (vector #,@(map (lambda (n*)
|
708
|
+
#`(lambda (arg ...)
|
709
|
+
(let ((n #,n*))
|
710
|
+
body)))
|
711
|
+
(iota num-standard-pre-cache)))))
|
712
|
+
(lambda (n)
|
713
|
+
(if (< n #,num-standard-pre-cache)
|
714
|
+
(vector-ref cache n)
|
715
|
+
(lambda (arg ...) body)))))))))
|
716
|
+
|
717
|
+
(define-standard-accessor-method ((bound-check-get n) o)
|
718
|
+
(let ((x (struct-ref o n)))
|
719
|
+
(if (unbound? x)
|
720
|
+
(slot-unbound o)
|
721
|
+
x)))
|
722
|
+
|
723
|
+
(define-standard-accessor-method ((standard-get n) o)
|
724
|
+
(struct-ref o n))
|
725
|
+
|
726
|
+
(define-standard-accessor-method ((standard-set n) o v)
|
727
|
+
(struct-set! o n v))
|
728
|
+
|
729
|
+
(define-standard-accessor-method ((unboxed-get n) o)
|
730
|
+
(struct-ref/unboxed o n))
|
731
|
+
|
732
|
+
(define-standard-accessor-method ((unboxed-set n) o v)
|
733
|
+
(struct-set!/unboxed o n v))
|
734
|
+
|
735
|
+
;; Boot definitions.
|
736
|
+
(define (opaque-slot? slot) #f)
|
737
|
+
(define (read-only-slot? slot) #f)
|
738
|
+
(define (unboxed-slot? slot)
|
739
|
+
(memq (%slot-definition-name slot)
|
740
|
+
'(flags instance-finalizer nfields %reserved)))
|
741
|
+
|
742
|
+
(define (allocate-slots class slots)
|
743
|
+
"Transform the computed list of direct slot definitions @var{slots}
|
744
|
+
into a corresponding list of effective slot definitions, allocating
|
745
|
+
slots as we go."
|
746
|
+
(define (make-effective-slot-definition slot)
|
747
|
+
;; `compute-get-n-set' is expected to mutate `nfields' if it
|
748
|
+
;; allocates a field to the object. Pretty strange, but we preserve
|
749
|
+
;; the behavior for backward compatibility.
|
750
|
+
(let* ((slot (compute-effective-slot-definition class slot))
|
751
|
+
(name (%slot-definition-name slot))
|
752
|
+
(index (struct-ref/unboxed class class-index-nfields))
|
753
|
+
(g-n-s (compute-get-n-set class slot))
|
754
|
+
(size (- (struct-ref/unboxed class class-index-nfields) index)))
|
755
|
+
(call-with-values
|
756
|
+
(lambda ()
|
757
|
+
(match g-n-s
|
758
|
+
((? integer?)
|
759
|
+
(unless (= size 1)
|
760
|
+
(error "unexpected return from compute-get-n-set"))
|
761
|
+
(cond
|
762
|
+
((unboxed-slot? slot)
|
763
|
+
(let ((get (unboxed-get g-n-s)))
|
764
|
+
(values get get (unboxed-set g-n-s))))
|
765
|
+
(else
|
766
|
+
(values (standard-get g-n-s)
|
767
|
+
(if (slot-definition-init-thunk slot)
|
768
|
+
(standard-get g-n-s)
|
769
|
+
(bound-check-get g-n-s))
|
770
|
+
(standard-set g-n-s)))))
|
771
|
+
(((? procedure? get) (? procedure? set))
|
772
|
+
(values get
|
773
|
+
(lambda (o)
|
774
|
+
(let ((value (get o)))
|
775
|
+
(if (unbound? value)
|
776
|
+
(slot-unbound class o name)
|
777
|
+
value)))
|
778
|
+
set))))
|
779
|
+
(lambda (get/raw get set)
|
780
|
+
(let ((get (if (opaque-slot? slot)
|
781
|
+
(lambda (o)
|
782
|
+
(error "Slot is opaque" name))
|
783
|
+
get))
|
784
|
+
(set (cond
|
785
|
+
((opaque-slot? slot)
|
786
|
+
(lambda (o v)
|
787
|
+
(error "Slot is opaque" name)))
|
788
|
+
((read-only-slot? slot)
|
789
|
+
(if (unboxed-slot? slot)
|
790
|
+
(lambda (o v)
|
791
|
+
(let ((v* (get/raw o)))
|
792
|
+
(if (zero? v*)
|
793
|
+
;; Allow initialization.
|
794
|
+
(set o v)
|
795
|
+
(error "Slot is read-only" name))))
|
796
|
+
(lambda (o v)
|
797
|
+
(let ((v* (get/raw o)))
|
798
|
+
(if (unbound? v*)
|
799
|
+
;; Allow initialization.
|
800
|
+
(set o v)
|
801
|
+
(error "Slot is read-only" name))))))
|
802
|
+
(else set))))
|
803
|
+
(struct-set! slot slot-index-slot-ref/raw get/raw)
|
804
|
+
(struct-set! slot slot-index-slot-ref get)
|
805
|
+
(struct-set! slot slot-index-slot-set! set)
|
806
|
+
(struct-set! slot slot-index-index index)
|
807
|
+
(struct-set! slot slot-index-size size))))
|
808
|
+
slot))
|
809
|
+
(struct-set!/unboxed class class-index-nfields 0)
|
810
|
+
(map-in-order make-effective-slot-definition slots))
|
811
|
+
|
812
|
+
(define (%compute-layout slots nfields is-class?)
|
813
|
+
(define (slot-protection-and-kind slot)
|
814
|
+
(define (subclass? class parent)
|
815
|
+
(memq parent (class-precedence-list class)))
|
816
|
+
(let ((type (get-keyword #:class (%slot-definition-options slot))))
|
817
|
+
(if (and type (subclass? type <foreign-slot>))
|
818
|
+
(values (cond
|
819
|
+
((subclass? type <self-slot>) #\s)
|
820
|
+
((subclass? type <protected-slot>) #\p)
|
821
|
+
(else #\u))
|
822
|
+
(cond
|
823
|
+
((subclass? type <read-only-slot>) #\r)
|
824
|
+
((subclass? type <hidden-slot>) #\h)
|
825
|
+
(else #\w)))
|
826
|
+
(values #\p #\w))))
|
827
|
+
(let ((layout (make-string (* nfields 2))))
|
828
|
+
(let lp ((n 0) (slots slots))
|
829
|
+
(match slots
|
830
|
+
(()
|
831
|
+
(unless (= n nfields) (error "bad nfields"))
|
832
|
+
(when is-class?
|
833
|
+
(let ((class-layout (struct-ref <class> class-index-layout)))
|
834
|
+
(unless (string-prefix? (symbol->string class-layout) layout)
|
835
|
+
(error "bad layout for class"))))
|
836
|
+
layout)
|
837
|
+
((slot . slots)
|
838
|
+
(unless (= n (%slot-definition-index slot)) (error "bad allocation"))
|
839
|
+
(call-with-values (lambda () (slot-protection-and-kind slot))
|
840
|
+
(lambda (protection kind)
|
841
|
+
(let init ((n n) (size (%slot-definition-size slot)))
|
842
|
+
(cond
|
843
|
+
((zero? size) (lp n slots))
|
844
|
+
(else
|
845
|
+
(unless (< n nfields) (error "bad nfields"))
|
846
|
+
(string-set! layout (* n 2) protection)
|
847
|
+
(string-set! layout (1+ (* n 2)) kind)
|
848
|
+
(init (1+ n) (1- size))))))))))))
|
849
|
+
|
850
|
+
|
851
|
+
|
852
|
+
|
853
|
+
;;;
|
854
|
+
;;; With all of this, we are now able to define subclasses of <class>.
|
855
|
+
;;;
|
856
|
+
(define (%prep-layout! class)
|
857
|
+
(let* ((is-class? (and (memq <class> (struct-ref class class-index-cpl)) #t))
|
858
|
+
(layout (%compute-layout (struct-ref class class-index-slots)
|
859
|
+
(struct-ref/unboxed class class-index-nfields)
|
860
|
+
is-class?)))
|
861
|
+
(%init-layout! class layout)))
|
862
|
+
|
863
|
+
(define (make-standard-class class name dsupers dslots)
|
864
|
+
(let ((z (make-struct/no-tail class)))
|
865
|
+
(define (make-direct-slot-definition dslot)
|
866
|
+
(let ((initargs (compute-direct-slot-definition-initargs z dslot)))
|
867
|
+
(compute-direct-slot-definition z initargs)))
|
868
|
+
|
869
|
+
(struct-set! z class-index-name name)
|
870
|
+
(struct-set!/unboxed z class-index-nfields 0)
|
871
|
+
(struct-set! z class-index-direct-supers dsupers)
|
872
|
+
(struct-set! z class-index-direct-subclasses '())
|
873
|
+
(struct-set! z class-index-direct-methods '())
|
874
|
+
(struct-set! z class-index-redefined #f)
|
875
|
+
(let ((cpl (compute-cpl z)))
|
876
|
+
(struct-set! z class-index-cpl cpl)
|
877
|
+
(when (memq <slot> cpl)
|
878
|
+
(class-add-flags! z vtable-flag-goops-slot))
|
879
|
+
(let* ((dslots (map make-direct-slot-definition dslots))
|
880
|
+
(slots (allocate-slots z (build-slots-list dslots cpl))))
|
881
|
+
(struct-set! z class-index-direct-slots dslots)
|
882
|
+
(struct-set! z class-index-slots slots)))
|
883
|
+
(for-each
|
884
|
+
(lambda (super)
|
885
|
+
(let ((subclasses (struct-ref super class-index-direct-subclasses)))
|
886
|
+
(struct-set! super class-index-direct-subclasses
|
887
|
+
(cons z subclasses))))
|
888
|
+
dsupers)
|
889
|
+
(%prep-layout! z)
|
890
|
+
z))
|
891
|
+
|
892
|
+
(define-syntax define-standard-class
|
893
|
+
(syntax-rules ()
|
894
|
+
((define-standard-class name (super ...) #:metaclass meta slot ...)
|
895
|
+
(define name
|
896
|
+
(make-standard-class meta 'name (list super ...) '(slot ...))))
|
897
|
+
((define-standard-class name (super ...) slot ...)
|
898
|
+
(define-standard-class name (super ...) #:metaclass <class> slot ...))))
|
899
|
+
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
;;;
|
904
|
+
;;; Sweet! Now we can define <top> and <object>, and finish
|
905
|
+
;;; initializing the `direct-subclasses', `direct-supers', and `cpl'
|
906
|
+
;;; slots of <class>.
|
907
|
+
;;;
|
908
|
+
(define-standard-class <top> ())
|
909
|
+
(define-standard-class <object> (<top>))
|
910
|
+
|
911
|
+
;; The inheritance links for <top>, <object>, <class>, and <slot> were
|
912
|
+
;; partially initialized. Correct them here.
|
913
|
+
(struct-set! <object> class-index-direct-subclasses (list <slot> <class>))
|
914
|
+
(struct-set! <class> class-index-direct-supers (list <object>))
|
915
|
+
(struct-set! <slot> class-index-direct-supers (list <object>))
|
916
|
+
(struct-set! <class> class-index-cpl (list <class> <object> <top>))
|
917
|
+
(struct-set! <slot> class-index-cpl (list <slot> <object> <top>))
|
918
|
+
|
919
|
+
|
920
|
+
|
921
|
+
|
922
|
+
;;;
|
923
|
+
;;; We can also define the various slot types, and finish initializing
|
924
|
+
;;; `direct-slots' and `slots' on <class> and <slot>.
|
925
|
+
;;;
|
926
|
+
(define-standard-class <foreign-slot> (<slot>))
|
927
|
+
(define-standard-class <protected-slot> (<foreign-slot>))
|
928
|
+
(define-standard-class <hidden-slot> (<foreign-slot>))
|
929
|
+
(define-standard-class <opaque-slot> (<foreign-slot>))
|
930
|
+
(define-standard-class <read-only-slot> (<foreign-slot>))
|
931
|
+
(define-standard-class <self-slot> (<read-only-slot>))
|
932
|
+
(define-standard-class <protected-opaque-slot> (<protected-slot>
|
933
|
+
<opaque-slot>))
|
934
|
+
(define-standard-class <protected-hidden-slot> (<protected-slot>
|
935
|
+
<hidden-slot>))
|
936
|
+
(define-standard-class <protected-read-only-slot> (<protected-slot>
|
937
|
+
<read-only-slot>))
|
938
|
+
(define-standard-class <scm-slot> (<protected-slot>))
|
939
|
+
(define-standard-class <int-slot> (<foreign-slot>))
|
940
|
+
(define-standard-class <float-slot> (<foreign-slot>))
|
941
|
+
(define-standard-class <double-slot> (<foreign-slot>))
|
942
|
+
|
943
|
+
(define (opaque-slot? slot) (is-a? slot <opaque-slot>))
|
944
|
+
(define (read-only-slot? slot) (is-a? slot <read-only-slot>))
|
945
|
+
(define (unboxed-slot? slot)
|
946
|
+
(and (is-a? slot <foreign-slot>)
|
947
|
+
(not (is-a? slot <self-slot>))
|
948
|
+
(not (is-a? slot <protected-slot>))))
|
949
|
+
|
950
|
+
|
951
|
+
|
952
|
+
;;;
|
953
|
+
;;; Finally! Initialize `direct-slots' and `slots' on <class>, and
|
954
|
+
;;; `slots' on <slot>.
|
955
|
+
;;;
|
956
|
+
(let ()
|
957
|
+
(define-syntax-rule (cons-slot (name . initargs) tail)
|
958
|
+
(cons (list 'name . initargs) tail))
|
959
|
+
(define-syntax-rule (initialize-direct-slots! class fold-slots)
|
960
|
+
(let ((specs (fold-slots macro-fold-right cons-slot '())))
|
961
|
+
(define (make-direct-slot-definition spec)
|
962
|
+
(let ((initargs (compute-direct-slot-definition-initargs class spec)))
|
963
|
+
(compute-direct-slot-definition class initargs)))
|
964
|
+
(struct-set! class class-index-direct-slots
|
965
|
+
(map make-direct-slot-definition specs))))
|
966
|
+
(define (initialize-slots! class)
|
967
|
+
(let ((slots (build-slots-list (class-direct-slots class)
|
968
|
+
(class-precedence-list class))))
|
969
|
+
(struct-set! class class-index-slots (allocate-slots class slots))))
|
970
|
+
|
971
|
+
;; Finish initializing <class> with the specialized slot kinds.
|
972
|
+
(initialize-direct-slots! <class> fold-class-slots)
|
973
|
+
|
974
|
+
(initialize-slots! <class>)
|
975
|
+
(initialize-slots! <slot>)
|
976
|
+
|
977
|
+
;; Now that we're all done with that, mark <class> and <slot> as
|
978
|
+
;; static.
|
979
|
+
(class-add-flags! <class> vtable-flag-goops-static)
|
980
|
+
(class-add-flags! <slot> vtable-flag-goops-static))
|
981
|
+
|
982
|
+
|
983
|
+
|
984
|
+
|
985
|
+
;;;
|
986
|
+
;;; Now, to build out the class hierarchy.
|
987
|
+
;;;
|
988
|
+
|
989
|
+
(define-standard-class <procedure-class> (<class>))
|
990
|
+
|
991
|
+
(define-standard-class <applicable-struct-class>
|
992
|
+
(<procedure-class>))
|
993
|
+
(class-add-flags! <applicable-struct-class>
|
994
|
+
vtable-flag-applicable-vtable)
|
995
|
+
|
996
|
+
(define-standard-class <applicable-struct-with-setter-class>
|
997
|
+
(<applicable-struct-class>))
|
998
|
+
(class-add-flags! <applicable-struct-with-setter-class>
|
999
|
+
vtable-flag-setter-vtable)
|
1000
|
+
|
1001
|
+
(define-standard-class <applicable> (<top>))
|
1002
|
+
(define-standard-class <applicable-struct> (<object> <applicable>)
|
1003
|
+
#:metaclass <applicable-struct-class>
|
1004
|
+
procedure)
|
1005
|
+
(define-standard-class <applicable-struct-with-setter> (<applicable-struct>)
|
1006
|
+
#:metaclass <applicable-struct-with-setter-class>
|
1007
|
+
setter)
|
1008
|
+
(define-standard-class <generic> (<applicable-struct>)
|
1009
|
+
#:metaclass <applicable-struct-class>
|
1010
|
+
methods
|
1011
|
+
(n-specialized #:init-value 0)
|
1012
|
+
(extended-by #:init-value ())
|
1013
|
+
effective-methods)
|
1014
|
+
(define-standard-class <extended-generic> (<generic>)
|
1015
|
+
#:metaclass <applicable-struct-class>
|
1016
|
+
(extends #:init-value ()))
|
1017
|
+
(define-standard-class <generic-with-setter> (<generic>
|
1018
|
+
<applicable-struct-with-setter>)
|
1019
|
+
#:metaclass <applicable-struct-with-setter-class>)
|
1020
|
+
(define-standard-class <accessor> (<generic-with-setter>)
|
1021
|
+
#:metaclass <applicable-struct-with-setter-class>)
|
1022
|
+
(define-standard-class <extended-generic-with-setter> (<extended-generic>
|
1023
|
+
<generic-with-setter>)
|
1024
|
+
#:metaclass <applicable-struct-with-setter-class>)
|
1025
|
+
(define-standard-class <extended-accessor> (<accessor>
|
1026
|
+
<extended-generic-with-setter>)
|
1027
|
+
#:metaclass <applicable-struct-with-setter-class>)
|
1028
|
+
|
1029
|
+
(define-standard-class <method> (<object>)
|
1030
|
+
generic-function
|
1031
|
+
specializers
|
1032
|
+
procedure
|
1033
|
+
formals
|
1034
|
+
body
|
1035
|
+
make-procedure)
|
1036
|
+
(define-standard-class <accessor-method> (<method>)
|
1037
|
+
(slot-definition #:init-keyword #:slot-definition))
|
1038
|
+
|
1039
|
+
(define-standard-class <boolean> (<top>))
|
1040
|
+
(define-standard-class <char> (<top>))
|
1041
|
+
(define-standard-class <list> (<top>))
|
1042
|
+
;; Not all pairs are lists, but there is code out there that relies on
|
1043
|
+
;; (is-a? '(1 2 3) <list>) to work. Terrible. How to fix?
|
1044
|
+
(define-standard-class <pair> (<list>))
|
1045
|
+
(define-standard-class <null> (<list>))
|
1046
|
+
(define-standard-class <string> (<top>))
|
1047
|
+
(define-standard-class <symbol> (<top>))
|
1048
|
+
(define-standard-class <vector> (<top>))
|
1049
|
+
(define-standard-class <foreign> (<top>))
|
1050
|
+
(define-standard-class <hashtable> (<top>))
|
1051
|
+
(define-standard-class <fluid> (<top>))
|
1052
|
+
(define-standard-class <dynamic-state> (<top>))
|
1053
|
+
(define-standard-class <frame> (<top>))
|
1054
|
+
(define-standard-class <vm-continuation> (<top>))
|
1055
|
+
(define-standard-class <bytevector> (<top>))
|
1056
|
+
(define-standard-class <uvec> (<bytevector>))
|
1057
|
+
(define-standard-class <array> (<top>))
|
1058
|
+
(define-standard-class <bitvector> (<top>))
|
1059
|
+
(define-standard-class <number> (<top>))
|
1060
|
+
(define-standard-class <complex> (<number>))
|
1061
|
+
(define-standard-class <real> (<complex>))
|
1062
|
+
(define-standard-class <integer> (<real>))
|
1063
|
+
(define-standard-class <fraction> (<real>))
|
1064
|
+
(define-standard-class <keyword> (<top>))
|
1065
|
+
(define-standard-class <syntax> (<top>))
|
1066
|
+
(define-standard-class <atomic-box> (<top>))
|
1067
|
+
(define-standard-class <unknown> (<top>))
|
1068
|
+
(define-standard-class <procedure> (<applicable>)
|
1069
|
+
#:metaclass <procedure-class>)
|
1070
|
+
(define-standard-class <primitive-generic> (<procedure>)
|
1071
|
+
#:metaclass <procedure-class>)
|
1072
|
+
(define-standard-class <port> (<top>))
|
1073
|
+
(define-standard-class <input-port> (<port>))
|
1074
|
+
(define-standard-class <output-port> (<port>))
|
1075
|
+
(define-standard-class <input-output-port> (<input-port> <output-port>))
|
1076
|
+
|
1077
|
+
(define (inherit-applicable! class)
|
1078
|
+
"An internal routine to redefine a SMOB class that was added after
|
1079
|
+
GOOPS was loaded, and on which scm_set_smob_apply installed an apply
|
1080
|
+
function."
|
1081
|
+
;; Why not use class-redefinition? We would, except that loading the
|
1082
|
+
;; compiler to compile effective methods can happen while GOOPS has
|
1083
|
+
;; only been partially loaded, and loading the compiler might cause
|
1084
|
+
;; SMOB types to be defined that need this facility. Instead we make
|
1085
|
+
;; a very specific hack, not a general solution. Probably the right
|
1086
|
+
;; solution is to avoid using the compiler, but that is another kettle
|
1087
|
+
;; of fish.
|
1088
|
+
(unless (memq <applicable> (class-precedence-list class))
|
1089
|
+
(unless (null? (class-slots class))
|
1090
|
+
(error "SMOB object has slots?"))
|
1091
|
+
(for-each
|
1092
|
+
(lambda (super)
|
1093
|
+
(let ((subclasses (struct-ref super class-index-direct-subclasses)))
|
1094
|
+
(struct-set! super class-index-direct-subclasses
|
1095
|
+
(delq class subclasses))))
|
1096
|
+
(struct-ref class class-index-direct-supers))
|
1097
|
+
(struct-set! class class-index-direct-supers (list <applicable>))
|
1098
|
+
(struct-set! class class-index-cpl (compute-cpl class))
|
1099
|
+
(let ((subclasses (struct-ref <applicable> class-index-direct-subclasses)))
|
1100
|
+
(struct-set! <applicable> class-index-direct-subclasses
|
1101
|
+
(cons class subclasses)))))
|
1102
|
+
|
1103
|
+
|
1104
|
+
|
1105
|
+
|
1106
|
+
;;;
|
1107
|
+
;;; At this point we have defined the class hierarchy, and it's time to
|
1108
|
+
;;; move on to instance allocation and generics. Once we have generics,
|
1109
|
+
;;; we'll fill out the metaobject protocol.
|
1110
|
+
;;;
|
1111
|
+
;;; Here we define a limited version of `make', so that we can allocate
|
1112
|
+
;;; instances of specific classes. This definition will be replaced
|
1113
|
+
;;; later.
|
1114
|
+
;;;
|
1115
|
+
(define (%invalidate-method-cache! gf)
|
1116
|
+
(slot-set! gf 'effective-methods '())
|
1117
|
+
(recompute-generic-function-dispatch-procedure! gf))
|
1118
|
+
|
1119
|
+
;; Boot definition.
|
1120
|
+
(define (invalidate-method-cache! gf)
|
1121
|
+
(%invalidate-method-cache! gf))
|
1122
|
+
|
1123
|
+
(define (make class . args)
|
1124
|
+
(cond
|
1125
|
+
((or (eq? class <generic>) (eq? class <accessor>))
|
1126
|
+
(let ((z (make-struct/no-tail class #f '() 0 '())))
|
1127
|
+
(set-procedure-property! z 'name (get-keyword #:name args #f))
|
1128
|
+
(invalidate-method-cache! z)
|
1129
|
+
(when (eq? class <accessor>)
|
1130
|
+
(let ((setter (get-keyword #:setter args #f)))
|
1131
|
+
(when setter
|
1132
|
+
(slot-set! z 'setter setter))))
|
1133
|
+
z))
|
1134
|
+
(else
|
1135
|
+
(let ((z (%allocate-instance class)))
|
1136
|
+
(cond
|
1137
|
+
((or (eq? class <method>) (eq? class <accessor-method>))
|
1138
|
+
(for-each (match-lambda
|
1139
|
+
((kw slot default)
|
1140
|
+
(slot-set! z slot (get-keyword kw args default))))
|
1141
|
+
'((#:generic-function generic-function #f)
|
1142
|
+
(#:specializers specializers ())
|
1143
|
+
(#:procedure procedure #f)
|
1144
|
+
(#:formals formals ())
|
1145
|
+
(#:body body ())
|
1146
|
+
(#:make-procedure make-procedure #f))))
|
1147
|
+
((memq <class> (class-precedence-list class))
|
1148
|
+
(class-add-flags! z (logior vtable-flag-goops-class
|
1149
|
+
vtable-flag-goops-valid))
|
1150
|
+
(for-each (match-lambda
|
1151
|
+
((kw slot default)
|
1152
|
+
(slot-set! z slot (get-keyword kw args default))))
|
1153
|
+
'((#:name name ???)
|
1154
|
+
(#:dsupers direct-supers ())
|
1155
|
+
(#:slots direct-slots ()))))
|
1156
|
+
(else
|
1157
|
+
(error "boot `make' does not support this class" class)))
|
1158
|
+
z))))
|
1159
|
+
|
1160
|
+
|
1161
|
+
|
1162
|
+
|
1163
|
+
;;;
|
1164
|
+
;;; Slot access.
|
1165
|
+
;;;
|
1166
|
+
;;; Before we go on, some notes about class redefinition. In GOOPS,
|
1167
|
+
;;; classes can be redefined. Redefinition of a class marks the class
|
1168
|
+
;;; as invalid, and instances will be lazily migrated over to the new
|
1169
|
+
;;; representation as they are accessed. Migration happens when
|
1170
|
+
;;; `class-of' is called on an instance. For more technical details on
|
1171
|
+
;;; object redefinition, see struct.h.
|
1172
|
+
;;;
|
1173
|
+
;;; In the following interfaces, class-of handles the redefinition
|
1174
|
+
;;; protocol. I would think though that there is some thread-unsafety
|
1175
|
+
;;; here though as the { class, object data } pair needs to be accessed
|
1176
|
+
;;; atomically, not the { class, object } pair.
|
1177
|
+
;;;
|
1178
|
+
(define-inlinable (%class-slot-definition class slot-name kt kf)
|
1179
|
+
(let lp ((slots (struct-ref class class-index-slots)))
|
1180
|
+
(match slots
|
1181
|
+
((slot . slots)
|
1182
|
+
(if (eq? (%slot-definition-name slot) slot-name)
|
1183
|
+
(kt slot)
|
1184
|
+
(lp slots)))
|
1185
|
+
(_ (kf)))))
|
1186
|
+
|
1187
|
+
(define (class-slot-definition class slot-name)
|
1188
|
+
(unless (class? class)
|
1189
|
+
(scm-error 'wrong-type-arg #f "Not a class: ~S" (list class) #f))
|
1190
|
+
(%class-slot-definition class slot-name
|
1191
|
+
(lambda (slot) slot)
|
1192
|
+
(lambda () #f)))
|
1193
|
+
|
1194
|
+
(define (slot-ref obj slot-name)
|
1195
|
+
"Return the value from @var{obj}'s slot with the nam var{slot_name}."
|
1196
|
+
(let ((class (class-of obj)))
|
1197
|
+
(define (have-slot slot)
|
1198
|
+
((%slot-definition-slot-ref slot) obj))
|
1199
|
+
(define (no-slot)
|
1200
|
+
(unless (symbol? slot-name)
|
1201
|
+
(scm-error 'wrong-type-arg #f "Not a symbol: ~S"
|
1202
|
+
(list slot-name) #f))
|
1203
|
+
(let ((val (slot-missing class obj slot-name)))
|
1204
|
+
(if (unbound? val)
|
1205
|
+
(slot-unbound class obj slot-name)
|
1206
|
+
val)))
|
1207
|
+
(%class-slot-definition class slot-name have-slot no-slot)))
|
1208
|
+
|
1209
|
+
(define (slot-set! obj slot-name value)
|
1210
|
+
"Set the slot named @var{slot_name} of @var{obj} to @var{value}."
|
1211
|
+
(let ((class (class-of obj)))
|
1212
|
+
(define (have-slot slot)
|
1213
|
+
((%slot-definition-slot-set! slot) obj value))
|
1214
|
+
(define (no-slot)
|
1215
|
+
(unless (symbol? slot-name)
|
1216
|
+
(scm-error 'wrong-type-arg #f "Not a symbol: ~S"
|
1217
|
+
(list slot-name) #f))
|
1218
|
+
(slot-missing class obj slot-name value))
|
1219
|
+
|
1220
|
+
(%class-slot-definition class slot-name have-slot no-slot)))
|
1221
|
+
|
1222
|
+
(define (slot-bound? obj slot-name)
|
1223
|
+
"Return the value from @var{obj}'s slot with the nam var{slot_name}."
|
1224
|
+
(let ((class (class-of obj)))
|
1225
|
+
(define (have-slot slot)
|
1226
|
+
(not (unbound? ((%slot-definition-slot-ref/raw slot) obj))))
|
1227
|
+
(define (no-slot)
|
1228
|
+
(unless (symbol? slot-name)
|
1229
|
+
(scm-error 'wrong-type-arg #f "Not a symbol: ~S"
|
1230
|
+
(list slot-name) #f))
|
1231
|
+
(not (unbound? (slot-missing class obj slot-name))))
|
1232
|
+
(%class-slot-definition class slot-name have-slot no-slot)))
|
1233
|
+
|
1234
|
+
(define (slot-exists? obj slot-name)
|
1235
|
+
"Return @code{#t} if @var{obj} has a slot named @var{slot_name}."
|
1236
|
+
(define (have-slot slot) #t)
|
1237
|
+
(define (no-slot)
|
1238
|
+
(unless (symbol? slot-name)
|
1239
|
+
(scm-error 'wrong-type-arg #f "Not a symbol: ~S"
|
1240
|
+
(list slot-name) #f))
|
1241
|
+
#f)
|
1242
|
+
(%class-slot-definition (class-of obj) slot-name have-slot no-slot))
|
1243
|
+
|
1244
|
+
(begin-deprecated
|
1245
|
+
(define (check-slot-args class obj slot-name)
|
1246
|
+
(unless (eq? class (class-of obj))
|
1247
|
+
(scm-error 'wrong-type-arg #f "~S is not the class of ~S"
|
1248
|
+
(list class obj) #f))
|
1249
|
+
(unless (symbol? slot-name)
|
1250
|
+
(scm-error 'wrong-type-arg #f "Not a symbol: ~S"
|
1251
|
+
(list slot-name) #f)))
|
1252
|
+
|
1253
|
+
(define (slot-ref-using-class class obj slot-name)
|
1254
|
+
(issue-deprecation-warning "slot-ref-using-class is deprecated. "
|
1255
|
+
"Use slot-ref instead.")
|
1256
|
+
(check-slot-args class obj slot-name)
|
1257
|
+
(slot-ref obj slot-name))
|
1258
|
+
|
1259
|
+
(define (slot-set-using-class! class obj slot-name value)
|
1260
|
+
(issue-deprecation-warning "slot-set-using-class! is deprecated. "
|
1261
|
+
"Use slot-set! instead.")
|
1262
|
+
(check-slot-args class obj slot-name)
|
1263
|
+
(slot-set! obj slot-name value))
|
1264
|
+
|
1265
|
+
(define (slot-bound-using-class? class obj slot-name)
|
1266
|
+
(issue-deprecation-warning "slot-bound-using-class? is deprecated. "
|
1267
|
+
"Use slot-bound? instead.")
|
1268
|
+
(check-slot-args class obj slot-name)
|
1269
|
+
(slot-bound? obj slot-name))
|
1270
|
+
|
1271
|
+
(define (slot-exists-using-class? class obj slot-name)
|
1272
|
+
(issue-deprecation-warning "slot-exists-using-class? is deprecated. "
|
1273
|
+
"Use slot-exists? instead.")
|
1274
|
+
(check-slot-args class obj slot-name)
|
1275
|
+
(slot-exists? obj slot-name)))
|
1276
|
+
|
1277
|
+
|
1278
|
+
|
1279
|
+
|
1280
|
+
;;;
|
1281
|
+
;;; Method accessors.
|
1282
|
+
;;;
|
1283
|
+
(define (method-generic-function obj)
|
1284
|
+
"Return the generic function for the method @var{obj}."
|
1285
|
+
(unless (is-a? obj <method>)
|
1286
|
+
(scm-error 'wrong-type-arg #f "Not a method: ~S"
|
1287
|
+
(list obj) #f))
|
1288
|
+
(slot-ref obj 'generic-function))
|
1289
|
+
|
1290
|
+
(define (method-specializers obj)
|
1291
|
+
"Return specializers of the method @var{obj}."
|
1292
|
+
(unless (is-a? obj <method>)
|
1293
|
+
(scm-error 'wrong-type-arg #f "Not a method: ~S"
|
1294
|
+
(list obj) #f))
|
1295
|
+
(slot-ref obj 'specializers))
|
1296
|
+
|
1297
|
+
(define (method-procedure obj)
|
1298
|
+
"Return the procedure of the method @var{obj}."
|
1299
|
+
(unless (is-a? obj <method>)
|
1300
|
+
(scm-error 'wrong-type-arg #f "Not a method: ~S"
|
1301
|
+
(list obj) #f))
|
1302
|
+
(slot-ref obj 'procedure))
|
1303
|
+
|
1304
|
+
|
1305
|
+
|
1306
|
+
|
1307
|
+
;;;
|
1308
|
+
;;; Generic functions!
|
1309
|
+
;;;
|
1310
|
+
;;; Generic functions have an applicable-methods cache associated with
|
1311
|
+
;;; them. Every distinct set of types that is dispatched through a
|
1312
|
+
;;; generic adds an entry to the cache. A composite dispatch procedure
|
1313
|
+
;;; is recomputed every time an entry gets added to the cache, or when
|
1314
|
+
;;; the cache is invalidated.
|
1315
|
+
;;;
|
1316
|
+
;;; In steady-state, this dispatch procedure is never regenerated; but
|
1317
|
+
;;; during warm-up there is some churn.
|
1318
|
+
;;;
|
1319
|
+
;;; So what is the deal if warm-up happens in a multithreaded context?
|
1320
|
+
;;; There is indeed a window between missing the cache for a certain set
|
1321
|
+
;;; of arguments, and then updating the cache with the newly computed
|
1322
|
+
;;; applicable methods. One of the updaters is liable to lose their new
|
1323
|
+
;;; entry.
|
1324
|
+
;;;
|
1325
|
+
;;; This is actually OK though, because a subsequent cache miss for the
|
1326
|
+
;;; race loser will just cause memoization to try again. The cache will
|
1327
|
+
;;; eventually be consistent. We're not mutating the old part of the
|
1328
|
+
;;; cache, just consing on the new entry.
|
1329
|
+
;;;
|
1330
|
+
;;; It doesn't even matter if the dispatch procedure and the cache are
|
1331
|
+
;;; inconsistent -- most likely the type-set that lost the dispatch
|
1332
|
+
;;; procedure race will simply re-trigger a memoization, but since the
|
1333
|
+
;;; winner isn't in the effective-methods cache, it will likely also
|
1334
|
+
;;; re-trigger a memoization, and the cache will finally be consistent.
|
1335
|
+
;;; As you can see there is a possibility for ping-pong effects, but
|
1336
|
+
;;; it's unlikely given the shortness of the window between slot-set!
|
1337
|
+
;;; invocations.
|
1338
|
+
;;;
|
1339
|
+
;;; We probably do need to use atomic access primitives to correctly
|
1340
|
+
;;; handle concurrency, but that's a more general Guile concern.
|
1341
|
+
;;;
|
1342
|
+
|
1343
|
+
(define-syntax arity-case
|
1344
|
+
(lambda (x)
|
1345
|
+
(syntax-case x ()
|
1346
|
+
;; (arity-case n 2 foo bar)
|
1347
|
+
;; => (case n
|
1348
|
+
;; ((0) (foo))
|
1349
|
+
;; ((1) (foo a))
|
1350
|
+
;; ((2) (foo a b))
|
1351
|
+
;; (else bar))
|
1352
|
+
((arity-case n max form alternate)
|
1353
|
+
(let ((max (syntax->datum #'max)))
|
1354
|
+
#`(case n
|
1355
|
+
#,@(let lp ((n 0))
|
1356
|
+
(let ((ids (map (lambda (n)
|
1357
|
+
(let* ((n (+ (char->integer #\a) n))
|
1358
|
+
(c (integer->char n)))
|
1359
|
+
(datum->syntax #'here (symbol c))))
|
1360
|
+
(iota n))))
|
1361
|
+
#`(((#,n) (form #,@ids))
|
1362
|
+
. #,(if (< n max)
|
1363
|
+
(lp (1+ n))
|
1364
|
+
#'()))))
|
1365
|
+
(else alternate)))))))
|
1366
|
+
|
1367
|
+
;;;
|
1368
|
+
;;; These dispatchers are set as the "procedure" field of <generic>
|
1369
|
+
;;; instances. Unlike CLOS, in GOOPS a generic function can have
|
1370
|
+
;;; multiple arities.
|
1371
|
+
;;;
|
1372
|
+
;;; We pre-generate fast dispatchers for applications of up to 20
|
1373
|
+
;;; arguments. More arguments than that will go through slower generic
|
1374
|
+
;;; routines that cons arguments into a rest list.
|
1375
|
+
;;;
|
1376
|
+
(define (multiple-arity-dispatcher fv miss)
|
1377
|
+
(define-syntax dispatch
|
1378
|
+
(lambda (x)
|
1379
|
+
(define (build-clauses args)
|
1380
|
+
(let ((len (length (syntax->datum args))))
|
1381
|
+
#`((#,args ((vector-ref fv #,len) . #,args))
|
1382
|
+
. #,(syntax-case args ()
|
1383
|
+
(() #'())
|
1384
|
+
((arg ... _) (build-clauses #'(arg ...)))))))
|
1385
|
+
(syntax-case x ()
|
1386
|
+
((dispatch arg ...)
|
1387
|
+
#`(case-lambda
|
1388
|
+
#,@(build-clauses #'(arg ...))
|
1389
|
+
(args (apply miss args)))))))
|
1390
|
+
(arity-case (1- (vector-length fv)) 20 dispatch
|
1391
|
+
(lambda args
|
1392
|
+
(let ((nargs (length args)))
|
1393
|
+
(if (< nargs (vector-length fv))
|
1394
|
+
(apply (vector-ref fv nargs) args)
|
1395
|
+
(apply miss args))))))
|
1396
|
+
|
1397
|
+
;;;
|
1398
|
+
;;; The above multiple-arity-dispatcher is entirely sufficient, and
|
1399
|
+
;;; should be fast enough. Still, for no good reason we also have an
|
1400
|
+
;;; arity dispatcher for generics that are only called with one arity.
|
1401
|
+
;;;
|
1402
|
+
(define (single-arity-dispatcher f nargs miss)
|
1403
|
+
(define-syntax-rule (dispatch arg ...)
|
1404
|
+
(case-lambda
|
1405
|
+
((arg ...) (f arg ...))
|
1406
|
+
(args (apply miss args))))
|
1407
|
+
(arity-case nargs 20 dispatch
|
1408
|
+
(lambda args
|
1409
|
+
(if (eqv? (length args) nargs)
|
1410
|
+
(apply f args)
|
1411
|
+
(apply miss args)))))
|
1412
|
+
|
1413
|
+
;;;
|
1414
|
+
;;; The guts of generic function dispatch are here. Once we've selected
|
1415
|
+
;;; an arity, we need to map from arguments to effective method. Until
|
1416
|
+
;;; we have `eqv?' specializers, this map is entirely a function of the
|
1417
|
+
;;; types (classes) of the arguments. So, we look in the cache to see
|
1418
|
+
;;; if we have seen this set of concrete types, and if so we apply the
|
1419
|
+
;;; previously computed effective method. Otherwise we miss the cache,
|
1420
|
+
;;; so we'll have to compute the right answer for this set of types, add
|
1421
|
+
;;; the mapping to the cache, and apply the newly computed method.
|
1422
|
+
;;;
|
1423
|
+
;;; The cached mapping is invalidated whenever a new method is defined
|
1424
|
+
;;; on this generic, or whenever the class hierarchy of any method
|
1425
|
+
;;; specializer changes.
|
1426
|
+
;;;
|
1427
|
+
(define (single-arity-cache-dispatch cache nargs cache-miss)
|
1428
|
+
(match cache
|
1429
|
+
(() cache-miss)
|
1430
|
+
(((typev . cmethod) . cache)
|
1431
|
+
(cond
|
1432
|
+
((eqv? nargs (vector-length typev))
|
1433
|
+
(let ((cache-miss (single-arity-cache-dispatch cache nargs cache-miss)))
|
1434
|
+
(define (type-ref n)
|
1435
|
+
(and (< n nargs) (vector-ref typev n)))
|
1436
|
+
(define-syntax args-match?
|
1437
|
+
(syntax-rules ()
|
1438
|
+
((args-match?) #t)
|
1439
|
+
((args-match? (arg type) (arg* type*) ...)
|
1440
|
+
;; Check that the arg has the exact type that we saw. It
|
1441
|
+
;; could be that `type' is #f, which indicates the end of
|
1442
|
+
;; the specializers list. Once all specializers have been
|
1443
|
+
;; examined, we don't need to look at any more arguments
|
1444
|
+
;; to know that this is a cache hit.
|
1445
|
+
(or (not type)
|
1446
|
+
(and (eq? (class-of arg) type)
|
1447
|
+
(args-match? (arg* type*) ...))))))
|
1448
|
+
(define-syntax dispatch
|
1449
|
+
(lambda (x)
|
1450
|
+
(define (bind-types types k)
|
1451
|
+
(let lp ((types types) (n 0))
|
1452
|
+
(syntax-case types ()
|
1453
|
+
(() (k))
|
1454
|
+
((type . types)
|
1455
|
+
#`(let ((type (type-ref #,n)))
|
1456
|
+
#,(lp #'types (1+ n)))))))
|
1457
|
+
(syntax-case x ()
|
1458
|
+
((dispatch arg ...)
|
1459
|
+
(with-syntax (((type ...) (generate-temporaries #'(arg ...))))
|
1460
|
+
(bind-types
|
1461
|
+
#'(type ...)
|
1462
|
+
(lambda ()
|
1463
|
+
#'(lambda (arg ...)
|
1464
|
+
(if (args-match? (arg type) ...)
|
1465
|
+
(cmethod arg ...)
|
1466
|
+
(cache-miss arg ...))))))))))
|
1467
|
+
(arity-case nargs 20 dispatch
|
1468
|
+
(lambda args
|
1469
|
+
(define (args-match? args)
|
1470
|
+
(let lp ((args args) (n 0))
|
1471
|
+
(match args
|
1472
|
+
((arg . args)
|
1473
|
+
(or (not (vector-ref typev n))
|
1474
|
+
(and (eq? (vector-ref typev n) (class-of arg))
|
1475
|
+
(lp args (1+ n)))))
|
1476
|
+
(_ #t))))
|
1477
|
+
(if (args-match? args)
|
1478
|
+
(apply cmethod args)
|
1479
|
+
(apply cache-miss args))))))
|
1480
|
+
(else
|
1481
|
+
(single-arity-cache-dispatch cache nargs cache-miss))))))
|
1482
|
+
|
1483
|
+
(define (compute-generic-function-dispatch-procedure gf)
|
1484
|
+
(define (seen-arities cache)
|
1485
|
+
(let lp ((arities 0) (cache cache))
|
1486
|
+
(match cache
|
1487
|
+
(() arities)
|
1488
|
+
(((typev . cmethod) . cache)
|
1489
|
+
(lp (logior arities (ash 1 (vector-length typev)))
|
1490
|
+
cache)))))
|
1491
|
+
(define (cache-miss . args)
|
1492
|
+
(memoize-generic-function-application! gf args)
|
1493
|
+
(apply gf args))
|
1494
|
+
(let* ((cache (slot-ref gf 'effective-methods))
|
1495
|
+
(arities (seen-arities cache))
|
1496
|
+
(max-arity (let lp ((max -1))
|
1497
|
+
(if (< arities (ash 1 (1+ max)))
|
1498
|
+
max
|
1499
|
+
(lp (1+ max))))))
|
1500
|
+
(cond
|
1501
|
+
((= max-arity -1)
|
1502
|
+
;; Nothing in the cache.
|
1503
|
+
cache-miss)
|
1504
|
+
((= arities (ash 1 max-arity))
|
1505
|
+
;; Only one arity in the cache.
|
1506
|
+
(let* ((nargs max-arity)
|
1507
|
+
(f (single-arity-cache-dispatch cache nargs cache-miss)))
|
1508
|
+
(single-arity-dispatcher f nargs cache-miss)))
|
1509
|
+
(else
|
1510
|
+
;; Multiple arities.
|
1511
|
+
(let ((fv (make-vector (1+ max-arity) #f)))
|
1512
|
+
(let lp ((n 0))
|
1513
|
+
(when (<= n max-arity)
|
1514
|
+
(let ((f (single-arity-cache-dispatch cache n cache-miss)))
|
1515
|
+
(vector-set! fv n f)
|
1516
|
+
(lp (1+ n)))))
|
1517
|
+
(multiple-arity-dispatcher fv cache-miss))))))
|
1518
|
+
|
1519
|
+
(define (recompute-generic-function-dispatch-procedure! gf)
|
1520
|
+
(slot-set! gf 'procedure
|
1521
|
+
(compute-generic-function-dispatch-procedure gf)))
|
1522
|
+
|
1523
|
+
(define (memoize-effective-method! gf args applicable)
|
1524
|
+
(define (record-types args)
|
1525
|
+
(let ((typev (make-vector (length args) #f)))
|
1526
|
+
(let lp ((n 0) (args args))
|
1527
|
+
(when (and (< n (slot-ref gf 'n-specialized))
|
1528
|
+
(pair? args))
|
1529
|
+
(match args
|
1530
|
+
((arg . args)
|
1531
|
+
(vector-set! typev n (class-of arg))
|
1532
|
+
(lp (1+ n) args)))))
|
1533
|
+
typev))
|
1534
|
+
(let* ((typev (record-types args))
|
1535
|
+
(compute-effective-method (if (eq? (class-of gf) <generic>)
|
1536
|
+
%compute-effective-method
|
1537
|
+
compute-effective-method))
|
1538
|
+
(cmethod (compute-effective-method gf applicable typev))
|
1539
|
+
(cache (acons typev cmethod (slot-ref gf 'effective-methods))))
|
1540
|
+
(slot-set! gf 'effective-methods cache)
|
1541
|
+
(recompute-generic-function-dispatch-procedure! gf)
|
1542
|
+
cmethod))
|
1543
|
+
|
1544
|
+
;;;
|
1545
|
+
;;; If a method refers to `next-method' in its body, that method will be
|
1546
|
+
;;; able to dispatch to the next most specific method. The exact
|
1547
|
+
;;; `next-method' implementation is only known at runtime, as it is a
|
1548
|
+
;;; function of which precise argument types are being dispatched, which
|
1549
|
+
;;; might be subclasses of the method's declared specializers.
|
1550
|
+
;;;
|
1551
|
+
;;; Guile implements `next-method' by binding it as a closure variable.
|
1552
|
+
;;; An effective method is bound to a specific `next-method' by the
|
1553
|
+
;;; `make-procedure' slot of a <method>, which returns the new closure.
|
1554
|
+
;;;
|
1555
|
+
(define (%compute-specialized-effective-method gf method types next-method)
|
1556
|
+
(match (slot-ref method 'make-procedure)
|
1557
|
+
(#f (method-procedure method))
|
1558
|
+
(make-procedure (make-procedure next-method))))
|
1559
|
+
|
1560
|
+
(define (compute-specialized-effective-method gf method types next-method)
|
1561
|
+
(%compute-specialized-effective-method gf method types next-method))
|
1562
|
+
|
1563
|
+
(define (%compute-effective-method gf methods types)
|
1564
|
+
(match methods
|
1565
|
+
((method . methods)
|
1566
|
+
(let ((compute-specialized-effective-method
|
1567
|
+
(if (and (eq? (class-of gf) <generic>)
|
1568
|
+
(eq? (class-of method) <method>))
|
1569
|
+
%compute-specialized-effective-method
|
1570
|
+
compute-specialized-effective-method)))
|
1571
|
+
(compute-specialized-effective-method
|
1572
|
+
gf method types
|
1573
|
+
(match methods
|
1574
|
+
(()
|
1575
|
+
(lambda args
|
1576
|
+
(no-next-method gf args)))
|
1577
|
+
(methods
|
1578
|
+
(let ((compute-effective-method (if (eq? (class-of gf) <generic>)
|
1579
|
+
%compute-effective-method
|
1580
|
+
compute-effective-method)))
|
1581
|
+
(compute-effective-method gf methods types)))))))))
|
1582
|
+
|
1583
|
+
;; Boot definition; overrided with a generic later.
|
1584
|
+
(define (compute-effective-method gf methods types)
|
1585
|
+
(%compute-effective-method gf methods types))
|
1586
|
+
|
1587
|
+
;;;
|
1588
|
+
;;; Memoization
|
1589
|
+
;;;
|
1590
|
+
|
1591
|
+
(define (memoize-generic-function-application! gf args)
|
1592
|
+
(let ((applicable ((if (eq? (class-of gf) <generic>)
|
1593
|
+
%compute-applicable-methods
|
1594
|
+
compute-applicable-methods)
|
1595
|
+
gf args)))
|
1596
|
+
(cond (applicable
|
1597
|
+
(memoize-effective-method! gf args applicable))
|
1598
|
+
(else
|
1599
|
+
(no-applicable-method gf args)))))
|
1600
|
+
|
1601
|
+
(define no-applicable-method
|
1602
|
+
(make <generic> #:name 'no-applicable-method))
|
1603
|
+
|
1604
|
+
(%goops-early-init)
|
1605
|
+
|
1606
|
+
;; Then load the rest of GOOPS
|
1607
|
+
|
1608
|
+
|
1609
|
+
;; FIXME: deprecate.
|
1610
|
+
(define min-fixnum (- (expt 2 29)))
|
1611
|
+
(define max-fixnum (- (expt 2 29) 1))
|
1612
|
+
|
1613
|
+
;;
|
1614
|
+
;; goops-error
|
1615
|
+
;;
|
1616
|
+
(define (goops-error format-string . args)
|
1617
|
+
(scm-error 'goops-error #f format-string args '()))
|
1618
|
+
|
1619
|
+
;;;
|
1620
|
+
;;; {Meta classes}
|
1621
|
+
;;;
|
1622
|
+
|
1623
|
+
(define ensure-metaclass-with-supers
|
1624
|
+
(let ((table-of-metas '()))
|
1625
|
+
(lambda (meta-supers)
|
1626
|
+
(let ((entry (assoc meta-supers table-of-metas)))
|
1627
|
+
(if entry
|
1628
|
+
;; Found a previously created metaclass
|
1629
|
+
(cdr entry)
|
1630
|
+
;; Create a new meta-class which inherit from "meta-supers"
|
1631
|
+
(let ((new (make <class> #:dsupers meta-supers
|
1632
|
+
#:slots '()
|
1633
|
+
#:name (gensym "metaclass"))))
|
1634
|
+
(set! table-of-metas (cons (cons meta-supers new) table-of-metas))
|
1635
|
+
new))))))
|
1636
|
+
|
1637
|
+
(define (ensure-metaclass supers)
|
1638
|
+
(if (null? supers)
|
1639
|
+
<class>
|
1640
|
+
(let* ((all-metas (map (lambda (x) (class-of x)) supers))
|
1641
|
+
(all-cpls (append-map (lambda (m)
|
1642
|
+
(cdr (class-precedence-list m)))
|
1643
|
+
all-metas))
|
1644
|
+
(needed-metas '()))
|
1645
|
+
;; Find the most specific metaclasses. The new metaclass will be
|
1646
|
+
;; a subclass of these.
|
1647
|
+
(for-each
|
1648
|
+
(lambda (meta)
|
1649
|
+
(when (and (not (member meta all-cpls))
|
1650
|
+
(not (member meta needed-metas)))
|
1651
|
+
(set! needed-metas (append needed-metas (list meta)))))
|
1652
|
+
all-metas)
|
1653
|
+
;; Now return a subclass of the metaclasses we found.
|
1654
|
+
(if (null? (cdr needed-metas))
|
1655
|
+
(car needed-metas) ; If there's only one, just use it.
|
1656
|
+
(ensure-metaclass-with-supers needed-metas)))))
|
1657
|
+
|
1658
|
+
;;;
|
1659
|
+
;;; {Classes}
|
1660
|
+
;;;
|
1661
|
+
|
1662
|
+
;;; (define-class NAME (SUPER ...) SLOT-DEFINITION ... OPTION ...)
|
1663
|
+
;;;
|
1664
|
+
;;; SLOT-DEFINITION ::= INSTANCE-OF-<SLOT> | (SLOT-NAME OPTION ...)
|
1665
|
+
;;; OPTION ::= KEYWORD VALUE
|
1666
|
+
;;;
|
1667
|
+
|
1668
|
+
(define (make-class supers slots . options)
|
1669
|
+
(define (find-duplicate l)
|
1670
|
+
(match l
|
1671
|
+
(() #f)
|
1672
|
+
((head . tail)
|
1673
|
+
(if (memq head tail)
|
1674
|
+
head
|
1675
|
+
(find-duplicate tail)))))
|
1676
|
+
(define (slot-spec->name slot-spec)
|
1677
|
+
(match slot-spec
|
1678
|
+
(((? symbol? name) . args) name)
|
1679
|
+
;; We can get here when redefining classes.
|
1680
|
+
((? slot? slot) (%slot-definition-name slot))))
|
1681
|
+
|
1682
|
+
(let* ((name (get-keyword #:name options *unbound*))
|
1683
|
+
(supers (if (not (or-map (lambda (class)
|
1684
|
+
(memq <object>
|
1685
|
+
(class-precedence-list class)))
|
1686
|
+
supers))
|
1687
|
+
(append supers (list <object>))
|
1688
|
+
supers))
|
1689
|
+
(metaclass (or (get-keyword #:metaclass options #f)
|
1690
|
+
(ensure-metaclass supers))))
|
1691
|
+
|
1692
|
+
;; Verify that all direct slots are different and that we don't inherit
|
1693
|
+
;; several time from the same class
|
1694
|
+
(let ((tmp1 (find-duplicate supers))
|
1695
|
+
(tmp2 (find-duplicate (map slot-spec->name slots))))
|
1696
|
+
(if tmp1
|
1697
|
+
(goops-error "make-class: super class ~S is duplicate in class ~S"
|
1698
|
+
tmp1 name))
|
1699
|
+
(if tmp2
|
1700
|
+
(goops-error "make-class: slot ~S is duplicate in class ~S"
|
1701
|
+
tmp2 name)))
|
1702
|
+
|
1703
|
+
;; Everything seems correct, build the class
|
1704
|
+
(apply make metaclass
|
1705
|
+
#:dsupers supers
|
1706
|
+
#:slots slots
|
1707
|
+
#:name name
|
1708
|
+
options)))
|
1709
|
+
|
1710
|
+
;;; (class (SUPER ...) SLOT-DEFINITION ... OPTION ...)
|
1711
|
+
;;;
|
1712
|
+
;;; SLOT-DEFINITION ::= SLOT-NAME | (SLOT-NAME OPTION ...)
|
1713
|
+
;;; OPTION ::= KEYWORD VALUE
|
1714
|
+
;;;
|
1715
|
+
(define-syntax class
|
1716
|
+
(lambda (x)
|
1717
|
+
(define (parse-options options)
|
1718
|
+
(syntax-case options ()
|
1719
|
+
(() #'())
|
1720
|
+
((kw arg . options) (keyword? (syntax->datum #'kw))
|
1721
|
+
(with-syntax ((options (parse-options #'options)))
|
1722
|
+
(syntax-case #'kw ()
|
1723
|
+
(#:init-form
|
1724
|
+
#'(kw 'arg #:init-thunk (lambda () arg) . options))
|
1725
|
+
(_
|
1726
|
+
#'(kw arg . options)))))))
|
1727
|
+
(define (check-valid-kwargs args)
|
1728
|
+
(syntax-case args ()
|
1729
|
+
(() #'())
|
1730
|
+
((kw arg . args) (keyword? (syntax->datum #'kw))
|
1731
|
+
#`(kw arg . #,(check-valid-kwargs #'args)))))
|
1732
|
+
(define (parse-slots-and-kwargs args)
|
1733
|
+
(syntax-case args ()
|
1734
|
+
(()
|
1735
|
+
#'(() ()))
|
1736
|
+
((kw . _) (keyword? (syntax->datum #'kw))
|
1737
|
+
#`(() #,(check-valid-kwargs args)))
|
1738
|
+
(((name option ...) args ...)
|
1739
|
+
(with-syntax (((slots kwargs) (parse-slots-and-kwargs #'(args ...)))
|
1740
|
+
((option ...) (parse-options #'(option ...))))
|
1741
|
+
#'(((list 'name option ...) . slots) kwargs)))
|
1742
|
+
((name args ...) (symbol? (syntax->datum #'name))
|
1743
|
+
(with-syntax (((slots kwargs) (parse-slots-and-kwargs #'(args ...))))
|
1744
|
+
#'(('(name) . slots) kwargs)))))
|
1745
|
+
(syntax-case x ()
|
1746
|
+
((class (super ...) arg ...)
|
1747
|
+
(with-syntax ((((slot-def ...) (option ...))
|
1748
|
+
(parse-slots-and-kwargs #'(arg ...))))
|
1749
|
+
#'(make-class (list super ...)
|
1750
|
+
(list slot-def ...)
|
1751
|
+
option ...))))))
|
1752
|
+
|
1753
|
+
(define-syntax define-class-pre-definition
|
1754
|
+
(lambda (x)
|
1755
|
+
(syntax-case x ()
|
1756
|
+
((_ (k arg rest ...) out ...)
|
1757
|
+
(keyword? (syntax->datum #'k))
|
1758
|
+
(case (syntax->datum #'k)
|
1759
|
+
((#:getter #:setter)
|
1760
|
+
#'(define-class-pre-definition (rest ...)
|
1761
|
+
out ...
|
1762
|
+
(when (or (not (defined? 'arg))
|
1763
|
+
(not (is-a? arg <generic>)))
|
1764
|
+
(toplevel-define!
|
1765
|
+
'arg
|
1766
|
+
(ensure-generic (if (defined? 'arg) arg #f) 'arg)))))
|
1767
|
+
((#:accessor)
|
1768
|
+
#'(define-class-pre-definition (rest ...)
|
1769
|
+
out ...
|
1770
|
+
(when (or (not (defined? 'arg))
|
1771
|
+
(not (is-a? arg <accessor>)))
|
1772
|
+
(toplevel-define!
|
1773
|
+
'arg
|
1774
|
+
(ensure-accessor (if (defined? 'arg) arg #f) 'arg)))))
|
1775
|
+
(else
|
1776
|
+
#'(define-class-pre-definition (rest ...) out ...))))
|
1777
|
+
((_ () out ...)
|
1778
|
+
#'(begin out ...)))))
|
1779
|
+
|
1780
|
+
;; Some slot options require extra definitions to be made. In
|
1781
|
+
;; particular, we want to make sure that the generic function objects
|
1782
|
+
;; which represent accessors exist before `make-class' tries to add
|
1783
|
+
;; methods to them.
|
1784
|
+
(define-syntax define-class-pre-definitions
|
1785
|
+
(lambda (x)
|
1786
|
+
(syntax-case x ()
|
1787
|
+
((_ () out ...)
|
1788
|
+
#'(begin out ...))
|
1789
|
+
((_ (slot rest ...) out ...)
|
1790
|
+
(keyword? (syntax->datum #'slot))
|
1791
|
+
#'(begin out ...))
|
1792
|
+
((_ (slot rest ...) out ...)
|
1793
|
+
(identifier? #'slot)
|
1794
|
+
#'(define-class-pre-definitions (rest ...)
|
1795
|
+
out ...))
|
1796
|
+
((_ ((slotname slotopt ...) rest ...) out ...)
|
1797
|
+
#'(define-class-pre-definitions (rest ...)
|
1798
|
+
out ... (define-class-pre-definition (slotopt ...)))))))
|
1799
|
+
|
1800
|
+
(define-syntax-rule (define-class name supers slot ...)
|
1801
|
+
(begin
|
1802
|
+
(define-class-pre-definitions (slot ...))
|
1803
|
+
(if (and (defined? 'name)
|
1804
|
+
(is-a? name <class>)
|
1805
|
+
(memq <object> (class-precedence-list name)))
|
1806
|
+
(class-redefinition name
|
1807
|
+
(class supers slot ... #:name 'name))
|
1808
|
+
(toplevel-define! 'name (class supers slot ... #:name 'name)))))
|
1809
|
+
|
1810
|
+
(define-syntax-rule (standard-define-class arg ...)
|
1811
|
+
(define-class arg ...))
|
1812
|
+
|
1813
|
+
;;;
|
1814
|
+
;;; {Generic functions and accessors}
|
1815
|
+
;;;
|
1816
|
+
|
1817
|
+
;; Apparently the desired semantics are that we extend previous
|
1818
|
+
;; procedural definitions, but that if `name' was already a generic, we
|
1819
|
+
;; overwrite its definition.
|
1820
|
+
(define-syntax define-generic
|
1821
|
+
(lambda (x)
|
1822
|
+
(syntax-case x ()
|
1823
|
+
((define-generic name) (symbol? (syntax->datum #'name))
|
1824
|
+
#'(define name
|
1825
|
+
(if (and (defined? 'name) (is-a? name <generic>))
|
1826
|
+
(make <generic> #:name 'name)
|
1827
|
+
(ensure-generic (if (defined? 'name) name #f) 'name)))))))
|
1828
|
+
|
1829
|
+
(define-syntax define-extended-generic
|
1830
|
+
(lambda (x)
|
1831
|
+
(syntax-case x ()
|
1832
|
+
((define-extended-generic name val) (symbol? (syntax->datum #'name))
|
1833
|
+
#'(define name (make-extended-generic val 'name))))))
|
1834
|
+
|
1835
|
+
(define-syntax define-extended-generics
|
1836
|
+
(lambda (x)
|
1837
|
+
(define (id-append ctx a b)
|
1838
|
+
(datum->syntax ctx (symbol-append (syntax->datum a) (syntax->datum b))))
|
1839
|
+
(syntax-case x ()
|
1840
|
+
((define-extended-generic (name ...) #:prefix (prefix ...))
|
1841
|
+
(and (and-map symbol? (syntax->datum #'(name ...)))
|
1842
|
+
(and-map symbol? (syntax->datum #'(prefix ...))))
|
1843
|
+
(with-syntax ((((val ...)) (map (lambda (name)
|
1844
|
+
(map (lambda (prefix)
|
1845
|
+
(id-append name prefix name))
|
1846
|
+
#'(prefix ...)))
|
1847
|
+
#'(name ...))))
|
1848
|
+
#'(begin
|
1849
|
+
(define-extended-generic name (list val ...))
|
1850
|
+
...))))))
|
1851
|
+
|
1852
|
+
(define* (make-generic #:optional name)
|
1853
|
+
(make <generic> #:name name))
|
1854
|
+
|
1855
|
+
(define* (make-extended-generic gfs #:optional name)
|
1856
|
+
(let* ((gfs (if (list? gfs) gfs (list gfs)))
|
1857
|
+
(gws? (any (lambda (gf) (is-a? gf <generic-with-setter>)) gfs)))
|
1858
|
+
(let ((ans (if gws?
|
1859
|
+
(let* ((sname (and name (make-setter-name name)))
|
1860
|
+
(setters
|
1861
|
+
(append-map (lambda (gf)
|
1862
|
+
(if (is-a? gf <generic-with-setter>)
|
1863
|
+
(list (ensure-generic (setter gf)
|
1864
|
+
sname))
|
1865
|
+
'()))
|
1866
|
+
gfs))
|
1867
|
+
(es (make <extended-generic-with-setter>
|
1868
|
+
#:name name
|
1869
|
+
#:extends gfs
|
1870
|
+
#:setter (make <extended-generic>
|
1871
|
+
#:name sname
|
1872
|
+
#:extends setters))))
|
1873
|
+
(extended-by! setters (setter es))
|
1874
|
+
es)
|
1875
|
+
(make <extended-generic>
|
1876
|
+
#:name name
|
1877
|
+
#:extends gfs))))
|
1878
|
+
(extended-by! gfs ans)
|
1879
|
+
ans)))
|
1880
|
+
|
1881
|
+
(define (extended-by! gfs eg)
|
1882
|
+
(for-each (lambda (gf)
|
1883
|
+
(slot-set! gf 'extended-by
|
1884
|
+
(cons eg (slot-ref gf 'extended-by))))
|
1885
|
+
gfs)
|
1886
|
+
(invalidate-method-cache! eg))
|
1887
|
+
|
1888
|
+
(define (not-extended-by! gfs eg)
|
1889
|
+
(for-each (lambda (gf)
|
1890
|
+
(slot-set! gf 'extended-by
|
1891
|
+
(delq! eg (slot-ref gf 'extended-by))))
|
1892
|
+
gfs)
|
1893
|
+
(invalidate-method-cache! eg))
|
1894
|
+
|
1895
|
+
(define* (ensure-generic old-definition #:optional name)
|
1896
|
+
(cond ((is-a? old-definition <generic>) old-definition)
|
1897
|
+
((procedure-with-setter? old-definition)
|
1898
|
+
(make <generic-with-setter>
|
1899
|
+
#:name name
|
1900
|
+
#:default (procedure old-definition)
|
1901
|
+
#:setter (setter old-definition)))
|
1902
|
+
((procedure? old-definition)
|
1903
|
+
(if (generic-capability? old-definition) old-definition
|
1904
|
+
(make <generic> #:name name #:default old-definition)))
|
1905
|
+
(else (make <generic> #:name name))))
|
1906
|
+
|
1907
|
+
;; same semantics as <generic>
|
1908
|
+
(define-syntax-rule (define-accessor name)
|
1909
|
+
(define name
|
1910
|
+
(cond ((not (defined? 'name)) (ensure-accessor #f 'name))
|
1911
|
+
((is-a? name <accessor>) (make <accessor> #:name 'name))
|
1912
|
+
(else (ensure-accessor name 'name)))))
|
1913
|
+
|
1914
|
+
(define (make-setter-name name)
|
1915
|
+
(string->symbol (string-append "setter:" (symbol->string name))))
|
1916
|
+
|
1917
|
+
(define* (make-accessor #:optional name)
|
1918
|
+
(make <accessor>
|
1919
|
+
#:name name
|
1920
|
+
#:setter (make <generic>
|
1921
|
+
#:name (and name (make-setter-name name)))))
|
1922
|
+
|
1923
|
+
(define* (ensure-accessor proc #:optional name)
|
1924
|
+
(cond ((and (is-a? proc <accessor>)
|
1925
|
+
(is-a? (setter proc) <generic>))
|
1926
|
+
proc)
|
1927
|
+
((is-a? proc <generic-with-setter>)
|
1928
|
+
(upgrade-accessor proc (setter proc)))
|
1929
|
+
((is-a? proc <generic>)
|
1930
|
+
(upgrade-accessor proc (make-generic name)))
|
1931
|
+
((procedure-with-setter? proc)
|
1932
|
+
(make <accessor>
|
1933
|
+
#:name name
|
1934
|
+
#:default (procedure proc)
|
1935
|
+
#:setter (ensure-generic (setter proc) name)))
|
1936
|
+
((procedure? proc)
|
1937
|
+
(ensure-accessor (if (generic-capability? proc)
|
1938
|
+
(make <generic> #:name name #:default proc)
|
1939
|
+
(ensure-generic proc name))
|
1940
|
+
name))
|
1941
|
+
(else
|
1942
|
+
(make-accessor name))))
|
1943
|
+
|
1944
|
+
(define (upgrade-accessor generic setter)
|
1945
|
+
(let ((methods (slot-ref generic 'methods))
|
1946
|
+
(gws (make (if (is-a? generic <extended-generic>)
|
1947
|
+
<extended-generic-with-setter>
|
1948
|
+
<accessor>)
|
1949
|
+
#:name (generic-function-name generic)
|
1950
|
+
#:extended-by (slot-ref generic 'extended-by)
|
1951
|
+
#:setter setter)))
|
1952
|
+
(when (is-a? generic <extended-generic>)
|
1953
|
+
(let ((gfs (slot-ref generic 'extends)))
|
1954
|
+
(not-extended-by! gfs generic)
|
1955
|
+
(slot-set! gws 'extends gfs)
|
1956
|
+
(extended-by! gfs gws)))
|
1957
|
+
;; Steal old methods
|
1958
|
+
(for-each (lambda (method)
|
1959
|
+
(slot-set! method 'generic-function gws))
|
1960
|
+
methods)
|
1961
|
+
(slot-set! gws 'methods methods)
|
1962
|
+
(invalidate-method-cache! gws)
|
1963
|
+
gws))
|
1964
|
+
|
1965
|
+
;;;
|
1966
|
+
;;; {Methods}
|
1967
|
+
;;;
|
1968
|
+
|
1969
|
+
;; Note: `a' and `b' can have unequal lengths (i.e. one can be one
|
1970
|
+
;; element longer than the other when we have a dotted parameter
|
1971
|
+
;; list). For instance, with the call
|
1972
|
+
;;
|
1973
|
+
;; (M 1)
|
1974
|
+
;;
|
1975
|
+
;; with
|
1976
|
+
;;
|
1977
|
+
;; (define-method M (a . l) ....)
|
1978
|
+
;; (define-method M (a) ....)
|
1979
|
+
;;
|
1980
|
+
;; we consider that the second method is more specific.
|
1981
|
+
;;
|
1982
|
+
;; Precondition: `a' and `b' are methods and are applicable to `types'.
|
1983
|
+
(define (%method-more-specific? a b types)
|
1984
|
+
(let lp ((a-specializers (method-specializers a))
|
1985
|
+
(b-specializers (method-specializers b))
|
1986
|
+
(types types))
|
1987
|
+
(cond
|
1988
|
+
;; (a) less specific than (a b ...) or (a . b)
|
1989
|
+
((null? a-specializers) #t)
|
1990
|
+
;; (a b ...) or (a . b) less specific than (a)
|
1991
|
+
((null? b-specializers) #f)
|
1992
|
+
;; (a . b) less specific than (a b ...)
|
1993
|
+
((not (pair? a-specializers)) #f)
|
1994
|
+
;; (a b ...) more specific than (a . b)
|
1995
|
+
((not (pair? b-specializers)) #t)
|
1996
|
+
(else
|
1997
|
+
(let ((a-specializer (car a-specializers))
|
1998
|
+
(b-specializer (car b-specializers))
|
1999
|
+
(a-specializers (cdr a-specializers))
|
2000
|
+
(b-specializers (cdr b-specializers))
|
2001
|
+
(type (car types))
|
2002
|
+
(types (cdr types)))
|
2003
|
+
(if (eq? a-specializer b-specializer)
|
2004
|
+
(lp a-specializers b-specializers types)
|
2005
|
+
(let lp ((cpl (class-precedence-list type)))
|
2006
|
+
(let ((elt (car cpl)))
|
2007
|
+
(cond
|
2008
|
+
((eq? a-specializer elt) #t)
|
2009
|
+
((eq? b-specializer elt) #f)
|
2010
|
+
(else (lp (cdr cpl))))))))))))
|
2011
|
+
|
2012
|
+
(define (%sort-applicable-methods methods types)
|
2013
|
+
(sort methods (lambda (a b) (%method-more-specific? a b types))))
|
2014
|
+
|
2015
|
+
(define (generic-function-methods obj)
|
2016
|
+
"Return the methods of the generic function @var{obj}."
|
2017
|
+
(define (fold-upward method-lists gf)
|
2018
|
+
(cond
|
2019
|
+
((is-a? gf <extended-generic>)
|
2020
|
+
(let lp ((method-lists method-lists) (gfs (slot-ref gf 'extends)))
|
2021
|
+
(match gfs
|
2022
|
+
(() method-lists)
|
2023
|
+
((gf . gfs)
|
2024
|
+
(lp (fold-upward (cons (slot-ref gf 'methods) method-lists) gf)
|
2025
|
+
gfs)))))
|
2026
|
+
(else method-lists)))
|
2027
|
+
(define (fold-downward method-lists gf)
|
2028
|
+
(let lp ((method-lists (cons (slot-ref gf 'methods) method-lists))
|
2029
|
+
(gfs (slot-ref gf 'extended-by)))
|
2030
|
+
(match gfs
|
2031
|
+
(() method-lists)
|
2032
|
+
((gf . gfs)
|
2033
|
+
(lp (fold-downward method-lists gf) gfs)))))
|
2034
|
+
(unless (is-a? obj <generic>)
|
2035
|
+
(scm-error 'wrong-type-arg #f "Not a generic: ~S"
|
2036
|
+
(list obj) #f))
|
2037
|
+
(concatenate (fold-downward (fold-upward '() obj) obj)))
|
2038
|
+
|
2039
|
+
(define (%compute-applicable-methods gf args)
|
2040
|
+
(define (method-applicable? m types)
|
2041
|
+
(let ((specs (method-specializers m)))
|
2042
|
+
(cond
|
2043
|
+
((and (is-a? m <accessor-method>)
|
2044
|
+
(or (null? specs) (null? types)
|
2045
|
+
(not (eq? (car specs) (car types)))))
|
2046
|
+
;; Slot accessor methods are added to each subclass with the
|
2047
|
+
;; slot. They only apply to that specific concrete class, which
|
2048
|
+
;; appears as the first argument.
|
2049
|
+
#f)
|
2050
|
+
(else
|
2051
|
+
(let lp ((specs specs) (types types))
|
2052
|
+
(cond
|
2053
|
+
((null? specs) (null? types))
|
2054
|
+
((not (pair? specs)) #t)
|
2055
|
+
((null? types) #f)
|
2056
|
+
(else
|
2057
|
+
(and (memq (car specs) (class-precedence-list (car types)))
|
2058
|
+
(lp (cdr specs) (cdr types))))))))))
|
2059
|
+
(let ((n (length args))
|
2060
|
+
(types (map class-of args)))
|
2061
|
+
(let lp ((methods (generic-function-methods gf))
|
2062
|
+
(applicable '()))
|
2063
|
+
(if (null? methods)
|
2064
|
+
(and (not (null? applicable))
|
2065
|
+
(%sort-applicable-methods applicable types))
|
2066
|
+
(let ((m (car methods)))
|
2067
|
+
(lp (cdr methods)
|
2068
|
+
(if (method-applicable? m types)
|
2069
|
+
(cons m applicable)
|
2070
|
+
applicable)))))))
|
2071
|
+
|
2072
|
+
(define compute-applicable-methods %compute-applicable-methods)
|
2073
|
+
|
2074
|
+
(define (toplevel-define! name val)
|
2075
|
+
(module-define! (current-module) name val))
|
2076
|
+
|
2077
|
+
(define-syntax define-method
|
2078
|
+
(syntax-rules (setter)
|
2079
|
+
((_ ((setter name) . args) body ...)
|
2080
|
+
(begin
|
2081
|
+
(when (or (not (defined? 'name))
|
2082
|
+
(not (is-a? name <accessor>)))
|
2083
|
+
(toplevel-define! 'name
|
2084
|
+
(ensure-accessor
|
2085
|
+
(if (defined? 'name) name #f) 'name)))
|
2086
|
+
(add-method! (setter name) (method args body ...))))
|
2087
|
+
((_ (name . args) body ...)
|
2088
|
+
(begin
|
2089
|
+
;; FIXME: this code is how it always was, but it's quite cracky:
|
2090
|
+
;; it will only define the generic function if it was undefined
|
2091
|
+
;; before (ok), or *was defined to #f*. The latter is crack. But
|
2092
|
+
;; there are bootstrap issues about fixing this -- change it to
|
2093
|
+
;; (is-a? name <generic>) and see.
|
2094
|
+
(when (or (not (defined? 'name))
|
2095
|
+
(not name))
|
2096
|
+
(toplevel-define! 'name (make <generic> #:name 'name)))
|
2097
|
+
(add-method! name (method args body ...))))))
|
2098
|
+
|
2099
|
+
(define-syntax method
|
2100
|
+
(lambda (x)
|
2101
|
+
(define (parse-args args)
|
2102
|
+
(let lp ((ls args) (formals '()) (specializers '()))
|
2103
|
+
(syntax-case ls ()
|
2104
|
+
(((f s) . rest)
|
2105
|
+
(and (identifier? #'f) (identifier? #'s))
|
2106
|
+
(lp #'rest
|
2107
|
+
(cons #'f formals)
|
2108
|
+
(cons #'s specializers)))
|
2109
|
+
((f . rest)
|
2110
|
+
(identifier? #'f)
|
2111
|
+
(lp #'rest
|
2112
|
+
(cons #'f formals)
|
2113
|
+
(cons #'<top> specializers)))
|
2114
|
+
(()
|
2115
|
+
(list (reverse formals)
|
2116
|
+
(reverse (cons #''() specializers))))
|
2117
|
+
(tail
|
2118
|
+
(identifier? #'tail)
|
2119
|
+
(list (append (reverse formals) #'tail)
|
2120
|
+
(reverse (cons #'<top> specializers)))))))
|
2121
|
+
|
2122
|
+
(define (find-free-id exp referent)
|
2123
|
+
(syntax-case exp ()
|
2124
|
+
((x . y)
|
2125
|
+
(or (find-free-id #'x referent)
|
2126
|
+
(find-free-id #'y referent)))
|
2127
|
+
(x
|
2128
|
+
(identifier? #'x)
|
2129
|
+
(let ((id (datum->syntax #'x referent)))
|
2130
|
+
(and (free-identifier=? #'x id) id)))
|
2131
|
+
(_ #f)))
|
2132
|
+
|
2133
|
+
(define (compute-procedure formals body)
|
2134
|
+
(syntax-case body ()
|
2135
|
+
((body0 ...)
|
2136
|
+
(with-syntax ((formals formals))
|
2137
|
+
#'(lambda formals body0 ...)))))
|
2138
|
+
|
2139
|
+
(define (->proper args)
|
2140
|
+
(let lp ((ls args) (out '()))
|
2141
|
+
(syntax-case ls ()
|
2142
|
+
((x . xs) (lp #'xs (cons #'x out)))
|
2143
|
+
(() (reverse out))
|
2144
|
+
(tail (reverse (cons #'tail out))))))
|
2145
|
+
|
2146
|
+
(define (compute-make-procedure formals body next-method)
|
2147
|
+
(syntax-case body ()
|
2148
|
+
((body ...)
|
2149
|
+
(with-syntax ((next-method next-method))
|
2150
|
+
(syntax-case formals ()
|
2151
|
+
((formal ...)
|
2152
|
+
#'(lambda (real-next-method)
|
2153
|
+
(lambda (formal ...)
|
2154
|
+
(let ((next-method (lambda args
|
2155
|
+
(if (null? args)
|
2156
|
+
(real-next-method formal ...)
|
2157
|
+
(apply real-next-method args)))))
|
2158
|
+
body ...))))
|
2159
|
+
(formals
|
2160
|
+
(with-syntax (((formal ...) (->proper #'formals)))
|
2161
|
+
#'(lambda (real-next-method)
|
2162
|
+
(lambda formals
|
2163
|
+
(let ((next-method (lambda args
|
2164
|
+
(if (null? args)
|
2165
|
+
(apply real-next-method formal ...)
|
2166
|
+
(apply real-next-method args)))))
|
2167
|
+
body ...))))))))))
|
2168
|
+
|
2169
|
+
(define (compute-procedures formals body)
|
2170
|
+
;; So, our use of this is broken, because it operates on the
|
2171
|
+
;; pre-expansion source code. It's equivalent to just searching
|
2172
|
+
;; for referent in the datums. Ah well.
|
2173
|
+
(let ((id (find-free-id body 'next-method)))
|
2174
|
+
(if id
|
2175
|
+
;; return a make-procedure
|
2176
|
+
(values #'#f
|
2177
|
+
(compute-make-procedure formals body id))
|
2178
|
+
(values (compute-procedure formals body)
|
2179
|
+
#'#f))))
|
2180
|
+
|
2181
|
+
(syntax-case x ()
|
2182
|
+
((_ args) #'(method args (if #f #f)))
|
2183
|
+
((_ args body0 body1 ...)
|
2184
|
+
(with-syntax (((formals (specializer ...)) (parse-args #'args)))
|
2185
|
+
(call-with-values
|
2186
|
+
(lambda ()
|
2187
|
+
(compute-procedures #'formals #'(body0 body1 ...)))
|
2188
|
+
(lambda (procedure make-procedure)
|
2189
|
+
(with-syntax ((procedure procedure)
|
2190
|
+
(make-procedure make-procedure))
|
2191
|
+
#'(make <method>
|
2192
|
+
#:specializers (cons* specializer ...)
|
2193
|
+
#:formals 'formals
|
2194
|
+
#:body '(body0 body1 ...)
|
2195
|
+
#:make-procedure make-procedure
|
2196
|
+
#:procedure procedure)))))))))
|
2197
|
+
|
2198
|
+
;;;
|
2199
|
+
;;; {Utilities}
|
2200
|
+
;;;
|
2201
|
+
;;; These are useful when dealing with method specializers, which might
|
2202
|
+
;;; have a rest argument.
|
2203
|
+
;;;
|
2204
|
+
|
2205
|
+
(define (map* fn . l) ; A map which accepts dotted lists (arg lists
|
2206
|
+
(cond ; must be "isomorph"
|
2207
|
+
((null? (car l)) '())
|
2208
|
+
((pair? (car l)) (cons (apply fn (map car l))
|
2209
|
+
(apply map* fn (map cdr l))))
|
2210
|
+
(else (apply fn l))))
|
2211
|
+
|
2212
|
+
(define (for-each* fn . l) ; A for-each which accepts dotted lists (arg lists
|
2213
|
+
(cond ; must be "isomorph"
|
2214
|
+
((null? (car l)) '())
|
2215
|
+
((pair? (car l)) (apply fn (map car l)) (apply for-each* fn (map cdr l)))
|
2216
|
+
(else (apply fn l))))
|
2217
|
+
|
2218
|
+
(define (length* ls)
|
2219
|
+
(do ((n 0 (+ 1 n))
|
2220
|
+
(ls ls (cdr ls)))
|
2221
|
+
((not (pair? ls)) n)))
|
2222
|
+
|
2223
|
+
;;;
|
2224
|
+
;;; {add-method!}
|
2225
|
+
;;;
|
2226
|
+
|
2227
|
+
(define (add-method-in-classes! m)
|
2228
|
+
;; Add method in all the classes which appears in its specializers list
|
2229
|
+
(for-each* (lambda (x)
|
2230
|
+
(let ((dm (class-direct-methods x)))
|
2231
|
+
(unless (memq m dm)
|
2232
|
+
(struct-set! x class-index-direct-methods (cons m dm)))))
|
2233
|
+
(method-specializers m)))
|
2234
|
+
|
2235
|
+
(define (remove-method-in-classes! m)
|
2236
|
+
;; Remove method in all the classes which appears in its specializers list
|
2237
|
+
(for-each* (lambda (x)
|
2238
|
+
(struct-set! x
|
2239
|
+
class-index-direct-methods
|
2240
|
+
(delv! m (class-direct-methods x))))
|
2241
|
+
(method-specializers m)))
|
2242
|
+
|
2243
|
+
(define (compute-new-list-of-methods gf new)
|
2244
|
+
(let ((new-spec (method-specializers new))
|
2245
|
+
(methods (slot-ref gf 'methods)))
|
2246
|
+
(let loop ((l methods))
|
2247
|
+
(if (null? l)
|
2248
|
+
(cons new methods)
|
2249
|
+
(if (equal? (method-specializers (car l)) new-spec)
|
2250
|
+
(begin
|
2251
|
+
;; This spec. list already exists. Remove old method from dependents
|
2252
|
+
(remove-method-in-classes! (car l))
|
2253
|
+
(set-car! l new)
|
2254
|
+
methods)
|
2255
|
+
(loop (cdr l)))))))
|
2256
|
+
|
2257
|
+
(define (method-n-specializers m)
|
2258
|
+
(length* (slot-ref m 'specializers)))
|
2259
|
+
|
2260
|
+
(define (calculate-n-specialized gf)
|
2261
|
+
(fold (lambda (m n) (max n (method-n-specializers m)))
|
2262
|
+
0
|
2263
|
+
(generic-function-methods gf)))
|
2264
|
+
|
2265
|
+
(define (invalidate-method-cache! gf)
|
2266
|
+
(slot-set! gf 'n-specialized (calculate-n-specialized gf))
|
2267
|
+
(%invalidate-method-cache! gf)
|
2268
|
+
(for-each (lambda (gf) (invalidate-method-cache! gf))
|
2269
|
+
(slot-ref gf 'extended-by)))
|
2270
|
+
|
2271
|
+
(define internal-add-method!
|
2272
|
+
(method ((gf <generic>) (m <method>))
|
2273
|
+
(slot-set! m 'generic-function gf)
|
2274
|
+
(slot-set! gf 'methods (compute-new-list-of-methods gf m))
|
2275
|
+
(invalidate-method-cache! gf)
|
2276
|
+
(add-method-in-classes! m)
|
2277
|
+
*unspecified*))
|
2278
|
+
|
2279
|
+
(define-generic add-method!)
|
2280
|
+
|
2281
|
+
((method-procedure internal-add-method!) add-method! internal-add-method!)
|
2282
|
+
|
2283
|
+
(define-method (add-method! (proc <procedure>) (m <method>))
|
2284
|
+
(if (generic-capability? proc)
|
2285
|
+
(begin
|
2286
|
+
(enable-primitive-generic! proc)
|
2287
|
+
(add-method! proc m))
|
2288
|
+
(next-method)))
|
2289
|
+
|
2290
|
+
(define-method (add-method! (pg <primitive-generic>) (m <method>))
|
2291
|
+
(add-method! (primitive-generic-generic pg) m))
|
2292
|
+
|
2293
|
+
(define-method (add-method! obj (m <method>))
|
2294
|
+
(goops-error "~S is not a valid generic function" obj))
|
2295
|
+
|
2296
|
+
;;;
|
2297
|
+
;;; {Access to meta objects}
|
2298
|
+
;;;
|
2299
|
+
|
2300
|
+
;;;
|
2301
|
+
;;; Methods
|
2302
|
+
;;;
|
2303
|
+
(define-method (method-source (m <method>))
|
2304
|
+
(let* ((spec (map* class-name (slot-ref m 'specializers)))
|
2305
|
+
(src (procedure-source (slot-ref m 'procedure))))
|
2306
|
+
(and src
|
2307
|
+
(let ((args (cadr src))
|
2308
|
+
(body (cddr src)))
|
2309
|
+
(cons 'method
|
2310
|
+
(cons (map* list args spec)
|
2311
|
+
body))))))
|
2312
|
+
|
2313
|
+
(define-method (method-formals (m <method>))
|
2314
|
+
(slot-ref m 'formals))
|
2315
|
+
|
2316
|
+
;;;
|
2317
|
+
;;; Slots
|
2318
|
+
;;;
|
2319
|
+
(define (slot-init-function class slot-name)
|
2320
|
+
(%slot-definition-init-thunk (or (class-slot-definition class slot-name)
|
2321
|
+
(error "slot not found" slot-name))))
|
2322
|
+
|
2323
|
+
(define (accessor-method-slot-definition obj)
|
2324
|
+
"Return the slot definition of the accessor @var{obj}."
|
2325
|
+
(slot-ref obj 'slot-definition))
|
2326
|
+
|
2327
|
+
|
2328
|
+
;;;
|
2329
|
+
;;; {Standard methods used by the C runtime}
|
2330
|
+
;;;
|
2331
|
+
|
2332
|
+
;;; Methods to compare objects
|
2333
|
+
;;;
|
2334
|
+
|
2335
|
+
;; Have to do this in a strange order because equal? is used in the
|
2336
|
+
;; add-method! implementation; we need to make sure that when the
|
2337
|
+
;; primitive is extended, that the generic has a method. =
|
2338
|
+
(define g-equal? (make-generic 'equal?))
|
2339
|
+
;; When this generic gets called, we will have already checked eq? and
|
2340
|
+
;; eqv? -- the purpose of this generic is to extend equality. So by
|
2341
|
+
;; default, there is no extension, thus the #f return.
|
2342
|
+
(add-method! g-equal? (method (x y) #f))
|
2343
|
+
(set-primitive-generic! equal? g-equal?)
|
2344
|
+
|
2345
|
+
;;;
|
2346
|
+
;;; methods to display/write an object
|
2347
|
+
;;;
|
2348
|
+
|
2349
|
+
; Code for writing objects must test that the slots they use are
|
2350
|
+
; bound. Otherwise a slot-unbound method will be called and will
|
2351
|
+
; conduct to an infinite loop.
|
2352
|
+
|
2353
|
+
;; Write
|
2354
|
+
(define (display-address o file)
|
2355
|
+
(display (number->string (object-address o) 16) file))
|
2356
|
+
|
2357
|
+
(define-method (write o file)
|
2358
|
+
(display "#<instance " file)
|
2359
|
+
(display-address o file)
|
2360
|
+
(display #\> file))
|
2361
|
+
|
2362
|
+
(define write-object (primitive-generic-generic write))
|
2363
|
+
|
2364
|
+
(define-method (write (o <object>) file)
|
2365
|
+
(let ((class (class-of o)))
|
2366
|
+
(if (slot-bound? class 'name)
|
2367
|
+
(begin
|
2368
|
+
(display "#<" file)
|
2369
|
+
(display (class-name class) file)
|
2370
|
+
(display #\space file)
|
2371
|
+
(display-address o file)
|
2372
|
+
(display #\> file))
|
2373
|
+
(next-method))))
|
2374
|
+
|
2375
|
+
(define-method (write (slot <slot>) file)
|
2376
|
+
(let ((class (class-of slot)))
|
2377
|
+
(if (and (slot-bound? class 'name)
|
2378
|
+
(slot-bound? slot 'name))
|
2379
|
+
(begin
|
2380
|
+
(display "#<" file)
|
2381
|
+
(display (class-name class) file)
|
2382
|
+
(display #\space file)
|
2383
|
+
(display (%slot-definition-name slot) file)
|
2384
|
+
(display #\space file)
|
2385
|
+
(display-address slot file)
|
2386
|
+
(display #\> file))
|
2387
|
+
(next-method))))
|
2388
|
+
|
2389
|
+
(define-method (write (class <class>) file)
|
2390
|
+
(let ((meta (class-of class)))
|
2391
|
+
(if (and (slot-bound? class 'name)
|
2392
|
+
(slot-bound? meta 'name))
|
2393
|
+
(begin
|
2394
|
+
(display "#<" file)
|
2395
|
+
(display (class-name meta) file)
|
2396
|
+
(display #\space file)
|
2397
|
+
(display (class-name class) file)
|
2398
|
+
(display #\space file)
|
2399
|
+
(display-address class file)
|
2400
|
+
(display #\> file))
|
2401
|
+
(next-method))))
|
2402
|
+
|
2403
|
+
(define-method (write (gf <generic>) file)
|
2404
|
+
(let ((meta (class-of gf)))
|
2405
|
+
(if (and (slot-bound? meta 'name)
|
2406
|
+
(slot-bound? gf 'methods))
|
2407
|
+
(begin
|
2408
|
+
(display "#<" file)
|
2409
|
+
(display (class-name meta) file)
|
2410
|
+
(let ((name (generic-function-name gf)))
|
2411
|
+
(if name
|
2412
|
+
(begin
|
2413
|
+
(display #\space file)
|
2414
|
+
(display name file))))
|
2415
|
+
(display " (" file)
|
2416
|
+
(display (length (generic-function-methods gf)) file)
|
2417
|
+
(display ")>" file))
|
2418
|
+
(next-method))))
|
2419
|
+
|
2420
|
+
(define-method (write (o <method>) file)
|
2421
|
+
(let ((meta (class-of o)))
|
2422
|
+
(if (and (slot-bound? meta 'name)
|
2423
|
+
(slot-bound? o 'specializers))
|
2424
|
+
(begin
|
2425
|
+
(display "#<" file)
|
2426
|
+
(display (class-name meta) file)
|
2427
|
+
(display #\space file)
|
2428
|
+
(display (map* (lambda (spec)
|
2429
|
+
(if (slot-bound? spec 'name)
|
2430
|
+
(slot-ref spec 'name)
|
2431
|
+
spec))
|
2432
|
+
(method-specializers o))
|
2433
|
+
file)
|
2434
|
+
(display #\space file)
|
2435
|
+
(display-address o file)
|
2436
|
+
(display #\> file))
|
2437
|
+
(next-method))))
|
2438
|
+
|
2439
|
+
;; Display (do the same thing as write by default)
|
2440
|
+
(define-method (display o file)
|
2441
|
+
(write-object o file))
|
2442
|
+
|
2443
|
+
;;;
|
2444
|
+
;;; Handling of duplicate bindings in the module system
|
2445
|
+
;;;
|
2446
|
+
|
2447
|
+
(define (find-subclass super name)
|
2448
|
+
(let lp ((classes (class-direct-subclasses super)))
|
2449
|
+
(cond
|
2450
|
+
((null? classes)
|
2451
|
+
(error "class not found" name))
|
2452
|
+
((and (slot-bound? (car classes) 'name)
|
2453
|
+
(eq? (class-name (car classes)) name))
|
2454
|
+
(car classes))
|
2455
|
+
(else
|
2456
|
+
(lp (cdr classes))))))
|
2457
|
+
|
2458
|
+
;; A record type.
|
2459
|
+
(define <module> (find-subclass <top> '<module>))
|
2460
|
+
|
2461
|
+
(define-method (merge-generics (module <module>)
|
2462
|
+
(name <symbol>)
|
2463
|
+
(int1 <module>)
|
2464
|
+
(val1 <top>)
|
2465
|
+
(int2 <module>)
|
2466
|
+
(val2 <top>)
|
2467
|
+
(var <top>)
|
2468
|
+
(val <top>))
|
2469
|
+
#f)
|
2470
|
+
|
2471
|
+
(define-method (merge-generics (module <module>)
|
2472
|
+
(name <symbol>)
|
2473
|
+
(int1 <module>)
|
2474
|
+
(val1 <generic>)
|
2475
|
+
(int2 <module>)
|
2476
|
+
(val2 <generic>)
|
2477
|
+
(var <top>)
|
2478
|
+
(val <boolean>))
|
2479
|
+
(and (not (eq? val1 val2))
|
2480
|
+
(make-variable (make-extended-generic (list val2 val1) name))))
|
2481
|
+
|
2482
|
+
(define-method (merge-generics (module <module>)
|
2483
|
+
(name <symbol>)
|
2484
|
+
(int1 <module>)
|
2485
|
+
(val1 <generic>)
|
2486
|
+
(int2 <module>)
|
2487
|
+
(val2 <generic>)
|
2488
|
+
(var <top>)
|
2489
|
+
(gf <extended-generic>))
|
2490
|
+
(and (not (memq val2 (slot-ref gf 'extends)))
|
2491
|
+
(begin
|
2492
|
+
(slot-set! gf
|
2493
|
+
'extends
|
2494
|
+
(cons val2 (delq! val2 (slot-ref gf 'extends))))
|
2495
|
+
(slot-set! val2
|
2496
|
+
'extended-by
|
2497
|
+
(cons gf (delq! gf (slot-ref val2 'extended-by))))
|
2498
|
+
(invalidate-method-cache! gf)
|
2499
|
+
var)))
|
2500
|
+
|
2501
|
+
(module-define! duplicate-handlers 'merge-generics merge-generics)
|
2502
|
+
|
2503
|
+
(define-method (merge-accessors (module <module>)
|
2504
|
+
(name <symbol>)
|
2505
|
+
(int1 <module>)
|
2506
|
+
(val1 <top>)
|
2507
|
+
(int2 <module>)
|
2508
|
+
(val2 <top>)
|
2509
|
+
(var <top>)
|
2510
|
+
(val <top>))
|
2511
|
+
#f)
|
2512
|
+
|
2513
|
+
(define-method (merge-accessors (module <module>)
|
2514
|
+
(name <symbol>)
|
2515
|
+
(int1 <module>)
|
2516
|
+
(val1 <accessor>)
|
2517
|
+
(int2 <module>)
|
2518
|
+
(val2 <accessor>)
|
2519
|
+
(var <top>)
|
2520
|
+
(val <top>))
|
2521
|
+
(merge-generics module name int1 val1 int2 val2 var val))
|
2522
|
+
|
2523
|
+
(module-define! duplicate-handlers 'merge-accessors merge-accessors)
|
2524
|
+
|
2525
|
+
;;;
|
2526
|
+
;;; slot access
|
2527
|
+
;;;
|
2528
|
+
|
2529
|
+
(define (class-slot-ref class slot-name)
|
2530
|
+
(let ((slot (class-slot-definition class slot-name)))
|
2531
|
+
(unless (memq (%slot-definition-allocation slot) '(#:class #:each-subclass))
|
2532
|
+
(slot-missing class slot-name))
|
2533
|
+
(let ((x ((%slot-definition-slot-ref/raw slot) #f)))
|
2534
|
+
(if (unbound? x)
|
2535
|
+
(slot-unbound class slot-name)
|
2536
|
+
x))))
|
2537
|
+
|
2538
|
+
(define (class-slot-set! class slot-name value)
|
2539
|
+
(let ((slot (class-slot-definition class slot-name)))
|
2540
|
+
(unless (memq (%slot-definition-allocation slot) '(#:class #:each-subclass))
|
2541
|
+
(slot-missing class slot-name))
|
2542
|
+
((%slot-definition-slot-set! slot) #f value)))
|
2543
|
+
|
2544
|
+
(define-method (slot-unbound (c <class>) (o <object>) s)
|
2545
|
+
(goops-error "Slot `~S' is unbound in object ~S" s o))
|
2546
|
+
|
2547
|
+
(define-method (slot-unbound (c <class>) s)
|
2548
|
+
(goops-error "Slot `~S' is unbound in class ~S" s c))
|
2549
|
+
|
2550
|
+
(define-method (slot-unbound (o <object>))
|
2551
|
+
(goops-error "Unbound slot in object ~S" o))
|
2552
|
+
|
2553
|
+
(define-method (slot-missing (c <class>) (o <object>) s)
|
2554
|
+
(goops-error "No slot with name `~S' in object ~S" s o))
|
2555
|
+
|
2556
|
+
(define-method (slot-missing (c <class>) s)
|
2557
|
+
(goops-error "No class slot with name `~S' in class ~S" s c))
|
2558
|
+
|
2559
|
+
|
2560
|
+
(define-method (slot-missing (c <class>) (o <object>) s value)
|
2561
|
+
(slot-missing c o s))
|
2562
|
+
|
2563
|
+
;;; Methods for the possible error we can encounter when calling a gf
|
2564
|
+
|
2565
|
+
(define-method (no-next-method (gf <generic>) args)
|
2566
|
+
(goops-error "No next method when calling ~S\nwith arguments ~S" gf args))
|
2567
|
+
|
2568
|
+
(define-method (no-applicable-method (gf <generic>) args)
|
2569
|
+
(goops-error "No applicable method for ~S in call ~S"
|
2570
|
+
gf (cons (generic-function-name gf) args)))
|
2571
|
+
|
2572
|
+
(define-method (no-method (gf <generic>) args)
|
2573
|
+
(goops-error "No method defined for ~S" gf))
|
2574
|
+
|
2575
|
+
;;;
|
2576
|
+
;;; {Cloning functions (from rdeline@CS.CMU.EDU)}
|
2577
|
+
;;;
|
2578
|
+
|
2579
|
+
(define-method (shallow-clone (self <object>))
|
2580
|
+
(let* ((class (class-of self))
|
2581
|
+
(clone (%allocate-instance class))
|
2582
|
+
(slots (map slot-definition-name (class-slots class))))
|
2583
|
+
(for-each (lambda (slot)
|
2584
|
+
(when (slot-bound? self slot)
|
2585
|
+
(slot-set! clone slot (slot-ref self slot))))
|
2586
|
+
slots)
|
2587
|
+
clone))
|
2588
|
+
|
2589
|
+
(define-method (deep-clone (self <object>))
|
2590
|
+
(let* ((class (class-of self))
|
2591
|
+
(clone (%allocate-instance class))
|
2592
|
+
(slots (map slot-definition-name (class-slots class))))
|
2593
|
+
(for-each (lambda (slot)
|
2594
|
+
(when (slot-bound? self slot)
|
2595
|
+
(slot-set! clone slot
|
2596
|
+
(let ((value (slot-ref self slot)))
|
2597
|
+
(if (instance? value)
|
2598
|
+
(deep-clone value)
|
2599
|
+
value)))))
|
2600
|
+
slots)
|
2601
|
+
clone))
|
2602
|
+
|
2603
|
+
;;;
|
2604
|
+
;;; {Class redefinition utilities}
|
2605
|
+
;;;
|
2606
|
+
|
2607
|
+
;;; (class-redefinition OLD NEW)
|
2608
|
+
;;;
|
2609
|
+
|
2610
|
+
;;; Has correct the following conditions:
|
2611
|
+
|
2612
|
+
;;; Methods
|
2613
|
+
;;;
|
2614
|
+
;;; 1. New accessor specializers refer to new header
|
2615
|
+
;;;
|
2616
|
+
;;; Classes
|
2617
|
+
;;;
|
2618
|
+
;;; 1. New class cpl refers to the new class header
|
2619
|
+
;;; 2. Old class header exists on old super classes direct-subclass lists
|
2620
|
+
;;; 3. New class header exists on new super classes direct-subclass lists
|
2621
|
+
|
2622
|
+
(define-method (class-redefinition (old <class>) (new <class>))
|
2623
|
+
;; Work on direct methods:
|
2624
|
+
;; 1. Remove accessor methods from the old class
|
2625
|
+
;; 2. Patch the occurences of new in the specializers by old
|
2626
|
+
;; 3. Displace the methods from old to new
|
2627
|
+
(remove-class-accessors! old) ;; -1-
|
2628
|
+
(let ((methods (class-direct-methods new)))
|
2629
|
+
(for-each (lambda (m)
|
2630
|
+
(update-direct-method! m new old)) ;; -2-
|
2631
|
+
methods)
|
2632
|
+
(struct-set! new
|
2633
|
+
class-index-direct-methods
|
2634
|
+
(append methods (class-direct-methods old))))
|
2635
|
+
|
2636
|
+
;; Substitute old for new in new cpl
|
2637
|
+
(set-car! (struct-ref new class-index-cpl) old)
|
2638
|
+
|
2639
|
+
;; Remove the old class from the direct-subclasses list of its super classes
|
2640
|
+
(for-each (lambda (c) (struct-set! c class-index-direct-subclasses
|
2641
|
+
(delv! old (class-direct-subclasses c))))
|
2642
|
+
(class-direct-supers old))
|
2643
|
+
|
2644
|
+
;; Replace the new class with the old in the direct-subclasses of the supers
|
2645
|
+
(for-each (lambda (c)
|
2646
|
+
(struct-set! c class-index-direct-subclasses
|
2647
|
+
(cons old (delv! new (class-direct-subclasses c)))))
|
2648
|
+
(class-direct-supers new))
|
2649
|
+
|
2650
|
+
;; Swap object headers
|
2651
|
+
(%modify-class old new)
|
2652
|
+
|
2653
|
+
;; Now old is NEW!
|
2654
|
+
|
2655
|
+
;; Redefine all the subclasses of old to take into account modification
|
2656
|
+
(for-each
|
2657
|
+
(lambda (c)
|
2658
|
+
(update-direct-subclass! c new old))
|
2659
|
+
(class-direct-subclasses new))
|
2660
|
+
|
2661
|
+
;; Invalidate class so that subsequent instances slot accesses invoke
|
2662
|
+
;; change-object-class
|
2663
|
+
(struct-set! new class-index-redefined old)
|
2664
|
+
(class-clear-flags! new vtable-flag-goops-valid) ;must come after slot-set!
|
2665
|
+
|
2666
|
+
old)
|
2667
|
+
|
2668
|
+
;;;
|
2669
|
+
;;; remove-class-accessors!
|
2670
|
+
;;;
|
2671
|
+
|
2672
|
+
(define-method (remove-class-accessors! (c <class>))
|
2673
|
+
(for-each (lambda (m)
|
2674
|
+
(when (is-a? m <accessor-method>)
|
2675
|
+
(let ((gf (slot-ref m 'generic-function)))
|
2676
|
+
;; remove the method from its GF
|
2677
|
+
(slot-set! gf 'methods
|
2678
|
+
(delq1! m (slot-ref gf 'methods)))
|
2679
|
+
(invalidate-method-cache! gf)
|
2680
|
+
;; remove the method from its specializers
|
2681
|
+
(remove-method-in-classes! m))))
|
2682
|
+
(class-direct-methods c)))
|
2683
|
+
|
2684
|
+
;;;
|
2685
|
+
;;; update-direct-method!
|
2686
|
+
;;;
|
2687
|
+
|
2688
|
+
(define-method (update-direct-method! (m <method>)
|
2689
|
+
(old <class>)
|
2690
|
+
(new <class>))
|
2691
|
+
(let loop ((l (method-specializers m)))
|
2692
|
+
;; Note: the <top> in dotted list is never used.
|
2693
|
+
;; So we can work as if we had only proper lists.
|
2694
|
+
(when (pair? l)
|
2695
|
+
(when (eqv? (car l) old)
|
2696
|
+
(set-car! l new))
|
2697
|
+
(loop (cdr l)))))
|
2698
|
+
|
2699
|
+
;;;
|
2700
|
+
;;; update-direct-subclass!
|
2701
|
+
;;;
|
2702
|
+
|
2703
|
+
(define-method (update-direct-subclass! (c <class>)
|
2704
|
+
(old <class>)
|
2705
|
+
(new <class>))
|
2706
|
+
(class-redefinition c
|
2707
|
+
(make-class (class-direct-supers c)
|
2708
|
+
(class-direct-slots c)
|
2709
|
+
#:name (class-name c)
|
2710
|
+
#:metaclass (class-of c))))
|
2711
|
+
|
2712
|
+
;;;
|
2713
|
+
;;; {Utilities for INITIALIZE methods}
|
2714
|
+
;;;
|
2715
|
+
|
2716
|
+
;;; compute-slot-accessors
|
2717
|
+
;;;
|
2718
|
+
(define (compute-slot-accessors class slots)
|
2719
|
+
(for-each
|
2720
|
+
(lambda (slot)
|
2721
|
+
(let ((getter (%slot-definition-getter slot))
|
2722
|
+
(setter (%slot-definition-setter slot))
|
2723
|
+
(accessor-setter setter)
|
2724
|
+
(accessor (%slot-definition-accessor slot)))
|
2725
|
+
(when getter
|
2726
|
+
(add-method! getter (compute-getter-method class slot)))
|
2727
|
+
(when setter
|
2728
|
+
(add-method! setter (compute-setter-method class slot)))
|
2729
|
+
(when accessor
|
2730
|
+
(add-method! accessor (compute-getter-method class slot))
|
2731
|
+
(add-method! (accessor-setter accessor)
|
2732
|
+
(compute-setter-method class slot)))))
|
2733
|
+
slots))
|
2734
|
+
|
2735
|
+
(define-method (compute-getter-method (class <class>) slot)
|
2736
|
+
(make <accessor-method>
|
2737
|
+
#:specializers (list class)
|
2738
|
+
#:procedure (slot-definition-slot-ref slot)
|
2739
|
+
#:slot-definition slot))
|
2740
|
+
|
2741
|
+
(define-method (compute-setter-method (class <class>) slot)
|
2742
|
+
(make <accessor-method>
|
2743
|
+
#:specializers (list class <top>)
|
2744
|
+
#:procedure (slot-definition-slot-set! slot)
|
2745
|
+
#:slot-definition slot))
|
2746
|
+
|
2747
|
+
(define (make-generic-bound-check-getter proc)
|
2748
|
+
(lambda (o)
|
2749
|
+
(let ((val (proc o)))
|
2750
|
+
(if (unbound? val)
|
2751
|
+
(slot-unbound o)
|
2752
|
+
val))))
|
2753
|
+
|
2754
|
+
;;; compute-cpl
|
2755
|
+
;;;
|
2756
|
+
|
2757
|
+
;; Replace the bootstrap compute-cpl with this definition.
|
2758
|
+
(define compute-cpl
|
2759
|
+
(make <generic> #:name 'compute-cpl))
|
2760
|
+
|
2761
|
+
(define-method (compute-cpl (class <class>))
|
2762
|
+
(compute-std-cpl class class-direct-supers))
|
2763
|
+
|
2764
|
+
;;; compute-get-n-set
|
2765
|
+
;;;
|
2766
|
+
(define compute-get-n-set
|
2767
|
+
(make <generic> #:name 'compute-get-n-set))
|
2768
|
+
|
2769
|
+
(define-method (compute-get-n-set (class <class>) s)
|
2770
|
+
(define (class-slot-init-value)
|
2771
|
+
(let ((thunk (slot-definition-init-thunk s)))
|
2772
|
+
(if thunk
|
2773
|
+
(thunk)
|
2774
|
+
(slot-definition-init-value s))))
|
2775
|
+
|
2776
|
+
(define (make-closure-variable class value)
|
2777
|
+
(list (lambda (o) value)
|
2778
|
+
(lambda (o v) (set! value v))))
|
2779
|
+
|
2780
|
+
(case (slot-definition-allocation s)
|
2781
|
+
((#:instance) ;; Instance slot
|
2782
|
+
;; get-n-set is just its offset
|
2783
|
+
(let ((already-allocated (struct-ref/unboxed class class-index-nfields)))
|
2784
|
+
(struct-set!/unboxed class class-index-nfields (+ already-allocated 1))
|
2785
|
+
already-allocated))
|
2786
|
+
|
2787
|
+
((#:class) ;; Class slot
|
2788
|
+
;; Class-slots accessors are implemented as 2 closures around
|
2789
|
+
;; a Scheme variable. As instance slots, class slots must be
|
2790
|
+
;; unbound at init time.
|
2791
|
+
(let ((name (slot-definition-name s)))
|
2792
|
+
(if (memq name (map slot-definition-name (class-direct-slots class)))
|
2793
|
+
;; This slot is direct; create a new shared variable
|
2794
|
+
(make-closure-variable class (class-slot-init-value))
|
2795
|
+
;; Slot is inherited. Find its definition in superclass
|
2796
|
+
(let lp ((cpl (cdr (class-precedence-list class))))
|
2797
|
+
(match cpl
|
2798
|
+
((super . cpl)
|
2799
|
+
(let ((s (class-slot-definition super name)))
|
2800
|
+
(if s
|
2801
|
+
(list (slot-definition-slot-ref s)
|
2802
|
+
(slot-definition-slot-set! s))
|
2803
|
+
;; Multiple inheritance means that we might have
|
2804
|
+
;; to look deeper in the CPL.
|
2805
|
+
(lp cpl)))))))))
|
2806
|
+
|
2807
|
+
((#:each-subclass) ;; slot shared by instances of direct subclass.
|
2808
|
+
;; (Thomas Buerger, April 1998)
|
2809
|
+
(make-closure-variable class (class-slot-init-value)))
|
2810
|
+
|
2811
|
+
((#:virtual) ;; No allocation
|
2812
|
+
;; slot-ref and slot-set! function must be given by the user
|
2813
|
+
(let ((get (get-keyword #:slot-ref (slot-definition-options s) #f))
|
2814
|
+
(set (get-keyword #:slot-set! (slot-definition-options s) #f)))
|
2815
|
+
(unless (and get set)
|
2816
|
+
(goops-error "You must supply a #:slot-ref and a #:slot-set! in ~S" s))
|
2817
|
+
(list get set)))
|
2818
|
+
(else (next-method))))
|
2819
|
+
|
2820
|
+
(define-method (compute-get-n-set (o <object>) s)
|
2821
|
+
(goops-error "Allocation \"~S\" is unknown" (slot-definition-allocation s)))
|
2822
|
+
|
2823
|
+
(define-method (compute-slots (class <class>))
|
2824
|
+
(build-slots-list (class-direct-slots class)
|
2825
|
+
(class-precedence-list class)))
|
2826
|
+
|
2827
|
+
;;;
|
2828
|
+
;;; {Initialize}
|
2829
|
+
;;;
|
2830
|
+
|
2831
|
+
;; FIXME: This could be much more efficient.
|
2832
|
+
(define (%initialize-object obj initargs)
|
2833
|
+
"Initialize the object @var{obj} with the given arguments
|
2834
|
+
var{initargs}."
|
2835
|
+
(define (valid-initargs? initargs)
|
2836
|
+
(match initargs
|
2837
|
+
(() #t)
|
2838
|
+
(((? keyword?) _ . initargs) (valid-initargs? initargs))
|
2839
|
+
(_ #f)))
|
2840
|
+
(unless (instance? obj)
|
2841
|
+
(scm-error 'wrong-type-arg #f "Not an object: ~S"
|
2842
|
+
(list obj) #f))
|
2843
|
+
(unless (valid-initargs? initargs)
|
2844
|
+
(scm-error 'wrong-type-arg #f "Invalid initargs: ~S"
|
2845
|
+
(list initargs) #f))
|
2846
|
+
(let ((class (class-of obj)))
|
2847
|
+
(define (get-initarg kw)
|
2848
|
+
(if kw
|
2849
|
+
;; Inlined get-keyword to avoid checking initargs for validity
|
2850
|
+
;; each time.
|
2851
|
+
(let lp ((initargs initargs))
|
2852
|
+
(match initargs
|
2853
|
+
((kw* val . initargs)
|
2854
|
+
(if (eq? kw* kw)
|
2855
|
+
val
|
2856
|
+
(lp initargs)))
|
2857
|
+
(_ *unbound*)))
|
2858
|
+
*unbound*))
|
2859
|
+
(let lp ((slots (struct-ref class class-index-slots)))
|
2860
|
+
(match slots
|
2861
|
+
(() obj)
|
2862
|
+
((slot . slots)
|
2863
|
+
(define (initialize-slot! value)
|
2864
|
+
((%slot-definition-slot-set! slot) obj value))
|
2865
|
+
(let ((initarg (get-initarg (%slot-definition-init-keyword slot))))
|
2866
|
+
(cond
|
2867
|
+
((not (unbound? initarg))
|
2868
|
+
(initialize-slot! initarg))
|
2869
|
+
((%slot-definition-init-thunk slot)
|
2870
|
+
=> (lambda (init-thunk)
|
2871
|
+
(unless (memq (slot-definition-allocation slot)
|
2872
|
+
'(#:class #:each-subclass))
|
2873
|
+
(initialize-slot! (init-thunk)))))))
|
2874
|
+
(lp slots))))))
|
2875
|
+
|
2876
|
+
(define-method (initialize (object <object>) initargs)
|
2877
|
+
(%initialize-object object initargs))
|
2878
|
+
|
2879
|
+
(define-method (initialize (slot <slot>) initargs)
|
2880
|
+
(next-method)
|
2881
|
+
(struct-set! slot slot-index-options initargs)
|
2882
|
+
(let ((init-thunk (%slot-definition-init-thunk slot)))
|
2883
|
+
(when init-thunk
|
2884
|
+
(unless (thunk? init-thunk)
|
2885
|
+
(goops-error "Bad init-thunk for slot `~S': ~S"
|
2886
|
+
(%slot-definition-name slot) init-thunk)))))
|
2887
|
+
|
2888
|
+
(define-method (initialize (class <class>) initargs)
|
2889
|
+
(define (make-direct-slot-definition dslot)
|
2890
|
+
(let ((initargs (compute-direct-slot-definition-initargs class dslot)))
|
2891
|
+
(compute-direct-slot-definition class initargs)))
|
2892
|
+
|
2893
|
+
(next-method)
|
2894
|
+
(class-add-flags! class (logior vtable-flag-goops-class
|
2895
|
+
vtable-flag-goops-valid))
|
2896
|
+
(struct-set! class class-index-name (get-keyword #:name initargs '???))
|
2897
|
+
(struct-set!/unboxed class class-index-nfields 0)
|
2898
|
+
(struct-set! class class-index-direct-supers
|
2899
|
+
(get-keyword #:dsupers initargs '()))
|
2900
|
+
(struct-set! class class-index-direct-subclasses '())
|
2901
|
+
(struct-set! class class-index-direct-methods '())
|
2902
|
+
(struct-set! class class-index-redefined #f)
|
2903
|
+
(struct-set! class class-index-cpl (compute-cpl class))
|
2904
|
+
(when (get-keyword #:static-slot-allocation? initargs #f)
|
2905
|
+
(match (filter class-has-statically-allocated-slots?
|
2906
|
+
(class-precedence-list class))
|
2907
|
+
(()
|
2908
|
+
(class-add-flags! class vtable-flag-goops-static))
|
2909
|
+
(classes
|
2910
|
+
(error "Class has superclasses with static slot allocation" classes))))
|
2911
|
+
(struct-set! class class-index-direct-slots
|
2912
|
+
(map (lambda (slot)
|
2913
|
+
(if (slot? slot)
|
2914
|
+
slot
|
2915
|
+
(make-direct-slot-definition slot)))
|
2916
|
+
(get-keyword #:slots initargs '())))
|
2917
|
+
(struct-set! class class-index-slots
|
2918
|
+
(allocate-slots class (compute-slots class)))
|
2919
|
+
|
2920
|
+
;; This is a hack.
|
2921
|
+
(when (memq <slot> (struct-ref class class-index-cpl))
|
2922
|
+
(class-add-flags! class vtable-flag-goops-slot))
|
2923
|
+
|
2924
|
+
;; Build getters - setters - accessors
|
2925
|
+
(compute-slot-accessors class (struct-ref class class-index-slots))
|
2926
|
+
|
2927
|
+
;; Update the "direct-subclasses" of each inherited classes
|
2928
|
+
(for-each (lambda (x)
|
2929
|
+
(let ((dsubs (struct-ref x class-index-direct-subclasses)))
|
2930
|
+
(struct-set! x class-index-direct-subclasses
|
2931
|
+
(cons class dsubs))))
|
2932
|
+
(struct-ref class class-index-direct-supers))
|
2933
|
+
|
2934
|
+
;; Compute struct layout of instances, set the `layout' slot, and
|
2935
|
+
;; update class flags.
|
2936
|
+
(%prep-layout! class))
|
2937
|
+
|
2938
|
+
(define (initialize-object-procedure object initargs)
|
2939
|
+
(let ((proc (get-keyword #:procedure initargs #f)))
|
2940
|
+
(cond ((not proc))
|
2941
|
+
((pair? proc)
|
2942
|
+
(apply slot-set! object 'procedure proc))
|
2943
|
+
(else
|
2944
|
+
(slot-set! object 'procedure proc)))))
|
2945
|
+
|
2946
|
+
(define-method (initialize (applicable-struct <applicable-struct>) initargs)
|
2947
|
+
(next-method)
|
2948
|
+
(initialize-object-procedure applicable-struct initargs))
|
2949
|
+
|
2950
|
+
(define-method (initialize (applicable-struct <applicable-struct-with-setter>)
|
2951
|
+
initargs)
|
2952
|
+
(next-method)
|
2953
|
+
(slot-set! applicable-struct 'setter (get-keyword #:setter initargs #f)))
|
2954
|
+
|
2955
|
+
(define-method (initialize (generic <generic>) initargs)
|
2956
|
+
(let ((previous-definition (get-keyword #:default initargs #f))
|
2957
|
+
(name (get-keyword #:name initargs #f)))
|
2958
|
+
(next-method)
|
2959
|
+
(slot-set! generic 'methods (if (is-a? previous-definition <procedure>)
|
2960
|
+
(list (method args
|
2961
|
+
(apply previous-definition args)))
|
2962
|
+
'()))
|
2963
|
+
(if name
|
2964
|
+
(set-procedure-property! generic 'name name))
|
2965
|
+
(invalidate-method-cache! generic)))
|
2966
|
+
|
2967
|
+
(define-method (initialize (eg <extended-generic>) initargs)
|
2968
|
+
(next-method)
|
2969
|
+
(slot-set! eg 'extends (get-keyword #:extends initargs '())))
|
2970
|
+
|
2971
|
+
(define dummy-procedure (lambda args *unspecified*))
|
2972
|
+
|
2973
|
+
(define-method (initialize (method <method>) initargs)
|
2974
|
+
(next-method)
|
2975
|
+
(slot-set! method 'generic-function (get-keyword #:generic-function initargs #f))
|
2976
|
+
(slot-set! method 'specializers (get-keyword #:specializers initargs '()))
|
2977
|
+
(slot-set! method 'procedure
|
2978
|
+
(get-keyword #:procedure initargs #f))
|
2979
|
+
(slot-set! method 'formals (get-keyword #:formals initargs '()))
|
2980
|
+
(slot-set! method 'body (get-keyword #:body initargs '()))
|
2981
|
+
(slot-set! method 'make-procedure (get-keyword #:make-procedure initargs #f)))
|
2982
|
+
|
2983
|
+
|
2984
|
+
;;;
|
2985
|
+
;;; {Change-class}
|
2986
|
+
;;;
|
2987
|
+
|
2988
|
+
(define (change-object-class old-instance old-class new-class)
|
2989
|
+
(let ((new-instance (allocate-instance new-class '())))
|
2990
|
+
;; Initialize the slots of the new instance
|
2991
|
+
(for-each
|
2992
|
+
(lambda (slot)
|
2993
|
+
(if (and (slot-exists? old-instance slot)
|
2994
|
+
(eq? (%slot-definition-allocation
|
2995
|
+
(class-slot-definition old-class slot))
|
2996
|
+
#:instance)
|
2997
|
+
(slot-bound? old-instance slot))
|
2998
|
+
;; Slot was present and allocated in old instance; copy it
|
2999
|
+
(slot-set! new-instance slot (slot-ref old-instance slot))
|
3000
|
+
;; slot was absent; initialize it with its default value
|
3001
|
+
(let ((init (slot-init-function new-class slot)))
|
3002
|
+
(when init
|
3003
|
+
(slot-set! new-instance slot (init))))))
|
3004
|
+
(map slot-definition-name (class-slots new-class)))
|
3005
|
+
;; Exchange old and new instance in place to keep pointers valid
|
3006
|
+
(%modify-instance old-instance new-instance)
|
3007
|
+
;; Allow class specific updates of instances (which now are swapped)
|
3008
|
+
(update-instance-for-different-class new-instance old-instance)
|
3009
|
+
old-instance))
|
3010
|
+
|
3011
|
+
|
3012
|
+
(define-method (update-instance-for-different-class (old-instance <object>)
|
3013
|
+
(new-instance
|
3014
|
+
<object>))
|
3015
|
+
;;not really important what we do, we just need a default method
|
3016
|
+
new-instance)
|
3017
|
+
|
3018
|
+
(define-method (change-class (old-instance <object>) (new-class <class>))
|
3019
|
+
(change-object-class old-instance (class-of old-instance) new-class))
|
3020
|
+
|
3021
|
+
;;;
|
3022
|
+
;;; {make}
|
3023
|
+
;;;
|
3024
|
+
;;; A new definition which overwrites the previous one which was built-in
|
3025
|
+
;;;
|
3026
|
+
|
3027
|
+
(define-method (allocate-instance (class <class>) initargs)
|
3028
|
+
(%allocate-instance class))
|
3029
|
+
|
3030
|
+
(define-method (make-instance (class <class>) . initargs)
|
3031
|
+
(let ((instance (allocate-instance class initargs)))
|
3032
|
+
(initialize instance initargs)
|
3033
|
+
instance))
|
3034
|
+
|
3035
|
+
(define make make-instance)
|
3036
|
+
|
3037
|
+
;;;
|
3038
|
+
;;; {apply-generic}
|
3039
|
+
;;;
|
3040
|
+
;;; Protocol for calling generic functions, intended to be used when
|
3041
|
+
;;; applying subclasses of <generic> and <generic-with-setter>. The
|
3042
|
+
;;; code below is similar to the first MOP described in AMOP.
|
3043
|
+
;;;
|
3044
|
+
;;; Note that standard generic functions dispatch only on the classes of
|
3045
|
+
;;; the arguments, and the result of such dispatch can be memoized. The
|
3046
|
+
;;; `dispatch-generic-function-application-from-cache' routine
|
3047
|
+
;;; implements this. `apply-generic' isn't called currently; the
|
3048
|
+
;;; generic function MOP was never fully implemented in GOOPS. However
|
3049
|
+
;;; now that GOOPS is implemented entirely in Scheme (2015) it's much
|
3050
|
+
;;; easier to complete this work. Contributions gladly accepted!
|
3051
|
+
;;; Please read the AMOP first though :)
|
3052
|
+
;;;
|
3053
|
+
;;; The protocol is:
|
3054
|
+
;;;
|
3055
|
+
;;; + apply-generic (gf args)
|
3056
|
+
;;; + compute-applicable-methods (gf args ...)
|
3057
|
+
;;; + sort-applicable-methods (gf methods args)
|
3058
|
+
;;; + apply-methods (gf methods args)
|
3059
|
+
;;;
|
3060
|
+
;;; apply-methods calls make-next-method to build the "continuation" of
|
3061
|
+
;;; a method. Applying a next-method will call apply-next-method which
|
3062
|
+
;;; in turn will call apply again to call effectively the following
|
3063
|
+
;;; method. (This paragraph is out of date but is kept so that maybe it
|
3064
|
+
;;; illuminates some future hack.)
|
3065
|
+
;;;
|
3066
|
+
|
3067
|
+
(define-method (apply-generic (gf <generic>) args)
|
3068
|
+
(when (null? (slot-ref gf 'methods))
|
3069
|
+
(no-method gf args))
|
3070
|
+
(let ((methods (compute-applicable-methods gf args)))
|
3071
|
+
(if methods
|
3072
|
+
(apply-methods gf (sort-applicable-methods gf methods args) args)
|
3073
|
+
(no-applicable-method gf args))))
|
3074
|
+
|
3075
|
+
;; compute-applicable-methods is bound to %compute-applicable-methods.
|
3076
|
+
(define compute-applicable-methods
|
3077
|
+
(let ((gf (make <generic> #:name 'compute-applicable-methods)))
|
3078
|
+
(add-method! gf (method ((gf <generic>) args)
|
3079
|
+
(%compute-applicable-methods gf args)))
|
3080
|
+
gf))
|
3081
|
+
|
3082
|
+
(define-method (sort-applicable-methods (gf <generic>) methods args)
|
3083
|
+
(%sort-applicable-methods methods (map class-of args)))
|
3084
|
+
|
3085
|
+
(define-method (method-more-specific? (m1 <method>) (m2 <method>) targs)
|
3086
|
+
(%method-more-specific? m1 m2 targs))
|
3087
|
+
|
3088
|
+
(define compute-effective-method
|
3089
|
+
(let ((gf (make <generic> #:name 'compute-effective-method)))
|
3090
|
+
(add-method! gf (method ((gf <generic>) methods typev)
|
3091
|
+
(%compute-effective-method gf methods typev)))
|
3092
|
+
gf))
|
3093
|
+
|
3094
|
+
(define compute-specialized-effective-method
|
3095
|
+
(let ((gf (make <generic> #:name 'compute-specialized-effective-method)))
|
3096
|
+
(add-method!
|
3097
|
+
gf
|
3098
|
+
(method ((gf <generic>) (method <method>) typev next)
|
3099
|
+
(%compute-specialized-effective-method gf method typev next)))
|
3100
|
+
gf))
|
3101
|
+
|
3102
|
+
(define-method (compute-specialized-effective-method (gf <generic>)
|
3103
|
+
(m <accessor-method>)
|
3104
|
+
typev
|
3105
|
+
next)
|
3106
|
+
(let ((name (slot-definition-name (accessor-method-slot-definition m))))
|
3107
|
+
(match typev
|
3108
|
+
(#(class)
|
3109
|
+
(slot-definition-slot-ref (class-slot-definition class name)))
|
3110
|
+
(#(class _)
|
3111
|
+
(slot-definition-slot-set! (class-slot-definition class name)))
|
3112
|
+
(_
|
3113
|
+
(next-method)))))
|
3114
|
+
|
3115
|
+
(define-method (apply-method (gf <generic>) methods build-next args)
|
3116
|
+
(apply (method-procedure (car methods))
|
3117
|
+
(build-next (cdr methods) args)
|
3118
|
+
args))
|
3119
|
+
|
3120
|
+
(define-method (apply-methods (gf <generic>) (l <list>) args)
|
3121
|
+
(letrec ((next (lambda (procs args)
|
3122
|
+
(lambda new-args
|
3123
|
+
(let ((a (if (null? new-args) args new-args)))
|
3124
|
+
(if (null? procs)
|
3125
|
+
(no-next-method gf a)
|
3126
|
+
(apply-method gf procs next a)))))))
|
3127
|
+
(apply-method gf l next args)))
|
3128
|
+
|
3129
|
+
;; We don't want the following procedure to turn up in backtraces:
|
3130
|
+
(for-each (lambda (proc)
|
3131
|
+
(set-procedure-property! proc 'system-procedure #t))
|
3132
|
+
(list slot-unbound
|
3133
|
+
slot-missing
|
3134
|
+
no-next-method
|
3135
|
+
no-applicable-method
|
3136
|
+
no-method
|
3137
|
+
))
|
3138
|
+
|
3139
|
+
;;;
|
3140
|
+
;;; {Final initialization}
|
3141
|
+
;;;
|
3142
|
+
|
3143
|
+
;; Tell C code that the main bulk of Goops has been loaded
|
3144
|
+
(%goops-loaded)
|
3145
|
+
|
3146
|
+
|
3147
|
+
|
3148
|
+
|
3149
|
+
;;;
|
3150
|
+
;;; {SMOB and port classes}
|
3151
|
+
;;;
|
3152
|
+
|
3153
|
+
(begin-deprecated
|
3154
|
+
(define-public <arbiter> (find-subclass <top> '<arbiter>))
|
3155
|
+
(define-public <async> (find-subclass <top> '<async>)))
|
3156
|
+
|
3157
|
+
(define <promise> (find-subclass <top> '<promise>))
|
3158
|
+
(define <thread> (find-subclass <top> '<thread>))
|
3159
|
+
(define <mutex> (find-subclass <top> '<mutex>))
|
3160
|
+
(define <condition-variable> (find-subclass <top> '<condition-variable>))
|
3161
|
+
(define <regexp> (find-subclass <top> '<regexp>))
|
3162
|
+
(define <hook> (find-subclass <top> '<hook>))
|
3163
|
+
(define <bitvector> (find-subclass <top> '<bitvector>))
|
3164
|
+
(define <random-state> (find-subclass <top> '<random-state>))
|
3165
|
+
(define <directory> (find-subclass <top> '<directory>))
|
3166
|
+
(define <array> (find-subclass <top> '<array>))
|
3167
|
+
(define <character-set> (find-subclass <top> '<character-set>))
|
3168
|
+
(define <dynamic-object> (find-subclass <top> '<dynamic-object>))
|
3169
|
+
(define <guardian> (find-subclass <applicable> '<guardian>))
|
3170
|
+
(define <macro> (find-subclass <top> '<macro>))
|
3171
|
+
|
3172
|
+
(define (define-class-subtree class)
|
3173
|
+
(define! (class-name class) class)
|
3174
|
+
(for-each define-class-subtree (class-direct-subclasses class)))
|
3175
|
+
|
3176
|
+
(define-class-subtree (find-subclass <port> '<file-port>))
|