Mercurial > hg > xemacs-beta
annotate src/lrecord.h @ 5353:38e24b8be4ea
Improve the lexical scoping in #'block, #'return-from.
lisp/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el:
* bytecomp.el (byte-compile-initial-macro-environment):
Shadow `block', `return-from' here, we implement them differently
when byte-compiling.
* bytecomp.el (byte-compile-active-blocks): New.
* bytecomp.el (byte-compile-block-1): New.
* bytecomp.el (byte-compile-return-from-1): New.
* bytecomp.el (return-from-1): New.
* bytecomp.el (block-1): New.
These are two aliases that exist to have their own associated
byte-compile functions, which functions implement `block' and
`return-from'.
* cl-extra.el (cl-macroexpand-all):
Fix a bug here when macros in the environment have been compiled.
* cl-macs.el (block):
* cl-macs.el (return):
* cl-macs.el (return-from):
Be more careful about lexical scope in these macros.
* cl.el:
* cl.el ('cl-block-wrapper): Removed.
* cl.el ('cl-block-throw): Removed.
These aren't needed in code generated by this XEmacs. They
shouldn't be needed in code generated by XEmacs 21.4, but if it
turns out the packages do need them, we can put them back.
2011-01-30 Mike Sperber <mike@xemacs.org>
* font-lock.el (font-lock-fontify-pending-extents): Don't fail if
`font-lock-mode' is unset, which can happen in the middle of
`revert-buffer'.
2011-01-23 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete):
* cl-macs.el (delq):
* cl-macs.el (remove):
* cl-macs.el (remq):
Don't use the compiler macro if these functions were given the
wrong number of arguments, as happens in lisp-tests.el.
* cl-seq.el (remove, remq): Removed.
I added these to subr.el, and forgot to remove them from here.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-setq, byte-compile-set):
Remove kludge allowing keywords' values to be set, all the code
that does that is gone.
* cl-compat.el (elt-satisfies-test-p):
* faces.el (set-face-parent):
* faces.el (face-doc-string):
* gtk-font-menu.el:
* gtk-font-menu.el (gtk-reset-device-font-menus):
* msw-font-menu.el:
* msw-font-menu.el (mswindows-reset-device-font-menus):
* package-get.el (package-get-installedp):
* select.el (select-convert-from-image-data):
* sound.el:
* sound.el (load-sound-file):
* x-font-menu.el (x-reset-device-font-menus-core):
Don't quote keywords, they're self-quoting, and the
win from backward-compatibility is sufficiently small now that the
style problem overrides it.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (block, return-from): Require that NAME be a symbol
in these macros, as always documented in the #'block docstring and
as required by Common Lisp.
* descr-text.el (unidata-initialize-unihan-database):
Correct the use of non-symbols in #'block and #'return-from in
this function.
2011-01-15 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (concatenate): Accept more complicated TYPEs in this
function, handing the sequences over to #'coerce if we don't
understand them here.
* cl-macs.el (inline): Don't proclaim #'concatenate as inline, its
compiler macro is more useful than doing that.
2011-01-11 Aidan Kehoe <kehoea@parhasard.net>
* subr.el (delete, delq, remove, remq): Move #'remove, #'remq
here, they don't belong in cl-seq.el; move #'delete, #'delq here
from fns.c, implement them in terms of #'delete*, allowing support
for sequences generally.
* update-elc.el (do-autoload-commands): Use #'delete*, not #'delq
here, now the latter's no longer dumped.
* cl-macs.el (delete, delq): Add compiler macros transforming
#'delete and #'delq to #'delete* calls.
2011-01-10 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box): Correct a misplaced parenthesis
here, thank you Mats Lidell in 87zkr9gqrh.fsf@mail.contactor.se !
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box):
* list-mode.el (display-completion-list):
These functions used to use cl-parsing-keywords; change them to
use defun* instead, fixing the build. (Not sure what led to me
not including this change in d1b17a33450b!)
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (define-star-compiler-macros):
Make sure the form has ITEM and LIST specified before attempting
to change to calls with explicit tests; necessary for some tests
in lisp-tests.el to compile correctly.
(stable-union, stable-intersection): Add compiler macros for these
functions, in the same way we do for most of the other functions
in cl-seq.el.
2011-01-01 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (dolist, dotimes, do-symbols, macrolet)
(symbol-macrolet):
Define these macros with defmacro* instead of parsing the argument
list by hand, for the sake of style and readability; use backquote
where appropriate, instead of calling #'list and and friends, for
the same reason.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* x-misc.el (device-x-display):
Provide this function, documented in the Lispref for years, but
not existing previously. Thank you Julian Bradfield, thank you
Jeff Mincy.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl-seq.el:
Move the heavy lifting from this file to C. Dump the
cl-parsing-keywords macro, but don't use defun* for the functions
we define that do take keywords, dynamic scope lossage makes that
not practical.
* subr.el (sort, fillarray): Move these aliases here.
(map-plist): #'nsublis is now built-in, but at this point #'eql
isn't necessarily available as a test; use #'eq.
* obsolete.el (cl-delete-duplicates): Make this available for old
compiler macros and old code.
(memql): Document that this is equivalent to #'member*, and worse.
* cl.el (adjoin, subst): Removed. These are in C.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* simple.el (assoc-ignore-case): Remove a duplicate definition of
this function (it's already in subr.el).
* iso8859-1.el (char-width):
On non-Mule, make this function equivalent to that produced by
(constantly 1), but preserve its docstring.
* subr.el (subst-char-in-string): Define this in terms of
#'substitute, #'nsubstitute.
(string-width): Define this using #'reduce and #'char-width.
(char-width): Give this a simpler definition, it makes far more
sense to check for mule at load time and redefine, as we do in
iso8859-1.el.
(store-substring): Implement this in terms of #'replace, now
#'replace is cheap.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* update-elc.el (lisp-files-needed-for-byte-compilation)
(lisp-files-needing-early-byte-compilation):
cl-macs belongs in the former, not the latter, it is as
fundamental as bytecomp.el.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl.el:
Provde the Common Lisp program-error, type-error as error
symbols. This doesn't nearly go far enough for anyone using the
Common Lisp errors.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete-duplicates):
If the form has an incorrect number of arguments, don't attempt a
compiler macroexpansion.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (cl-safe-expr-p):
Forms that start with the symbol lambda are also safe.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
For these functions' compiler macros, the optimisation is safe
even if the first and the last arguments have side effects, since
they're only used the once.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (inline-side-effect-free-compiler-macros):
Unroll a loop here at macro-expansion time, so these compiler
macros are compiled. Use #'eql instead of #'eq in a couple of
places for better style.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (notany, notevery): Avoid some dynamic scope
stupidity with local variable names in these functions, when they
weren't prefixed with cl-; go into some more detail in the doc
strings.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns): #'remove, #'remq are
free of side-effects.
(side-effect-and-error-free-fns):
Drop dot, dot-marker from the list.
2010-11-17 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (coerce):
In the argument list, name the first argument OBJECT, not X; the
former name was always used in the doc string and is clearer.
Handle vector type specifications which include the length of the
target sequence, error if there's a mismatch.
* cl-macs.el (cl-make-type-test): Handle type specifications
starting with the symbol 'eql.
2010-11-14 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (eql): Don't remove the byte-compile property of this
symbol. That was necessary to override a bug in bytecomp.el where
#'eql was confused with #'eq, which bug we no longer have.
If neither expression is constant, don't attempt to handle the
expression in this compiler macro, leave it to byte-compile-eql,
which produces better code anyway.
* bytecomp.el (eq): #'eql is not the function associated with the
byte-eq byte code.
(byte-compile-eql): Add an explicit compile method for this
function, for cases where the cl-macs compiler macro hasn't
reduced it to #'eq or #'equal.
2010-10-25 Aidan Kehoe <kehoea@parhasard.net>
Add compiler macros and compilation sanity-checking for various
functions that take keywords.
* byte-optimize.el (side-effect-free-fns): #'symbol-value is
side-effect free and not error free.
* bytecomp.el (byte-compile-normal-call): Check keyword argument
lists for sanity; store information about the positions where
keyword arguments start using the new byte-compile-keyword-start
property.
* cl-macs.el (cl-const-expr-val): Take a new optional argument,
cl-not-constant, defaulting to nil, in this function; return it if
the expression is not constant.
(cl-non-fixnum-number-p): Make this into a separate function, we
want to pass it to #'every.
(eql): Use it.
(define-star-compiler-macros): Use the same code to generate the
member*, assoc* and rassoc* compiler macros; special-case some
code in #'add-to-list in subr.el.
(remove, remq): Add compiler macros for these two functions, in
preparation for #'remove being in C.
(define-foo-if-compiler-macros): Transform (remove-if-not ...) calls to
(remove ... :if-not) at compile time, which will be a real win
once the latter is in C.
(define-substitute-if-compiler-macros)
(define-subst-if-compiler-macros): Similarly for these functions.
(delete-duplicates): Change this compiler macro to use
#'plists-equal; if we don't have information about the type of
SEQUENCE at compile time, don't bother attempting to inline the
call, the function will be in C soon enough.
(equalp): Remove an old commented-out compiler macro for this, if
we want to see it it's in version control.
(subst-char-in-string): Transform this to a call to nsubstitute or
nsubstitute, if that is appropriate.
* cl.el (ldiff): Don't call setf here, this makes for a load-time
dependency problem in cl-macs.el
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* term/vt100.el:
Refer to XEmacs, not GNU Emacs, in permissions.
* term/bg-mouse.el:
* term/sup-mouse.el:
Put copyright notice in canonical "Copyright DATE AUTHOR" form.
Refer to XEmacs, not GNU Emacs, in permissions.
* site-load.el:
Add permission boilerplate.
* mule/canna-leim.el:
* alist.el:
Refer to XEmacs, not APEL/this program, in permissions.
* mule/canna-leim.el:
Remove my copyright, I've assigned it to the FSF.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* gtk.el:
* gtk-widget-accessors.el:
* gtk-package.el:
* gtk-marshal.el:
* gtk-compose.el:
* gnome.el:
Add copyright notice based on internal evidence.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* easymenu.el: Add reference to COPYING to permission notice.
* gutter.el:
* gutter-items.el:
* menubar-items.el:
Fix typo "Xmacs" in permissions notice.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* auto-save.el:
* font.el:
* fontconfig.el:
* mule/kinsoku.el:
Add "part of XEmacs" text to permission notice.
2010-10-14 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns):
* cl-macs.el (remf, getf):
* cl-extra.el (tailp, cl-set-getf, cl-do-remf):
* cl.el (ldiff, endp):
Tighten up Common Lisp compatibility for #'ldiff, #'endp, #'tailp;
add circularity checking for the first two.
#'cl-set-getf and #'cl-do-remf were Lisp implementations of
#'plist-put and #'plist-remprop; change the names to aliases,
changes the macros that use them to using #'plist-put and
#'plist-remprop directly.
2010-10-12 Aidan Kehoe <kehoea@parhasard.net>
* abbrev.el (fundamental-mode-abbrev-table, global-abbrev-table):
Create both these abbrev tables using the usual
#'define-abbrev-table calls, rather than attempting to
special-case them.
* cl-extra.el: Force cl-macs to be loaded here, if cl-extra.el is
being loaded interpreted. Previously other, later files would
redundantly call (load "cl-macs") when interpreted, it's more
reasonable to do it here, once.
* cmdloop.el (read-quoted-char-radix): Use defcustom here, we
don't have any dump-order dependencies that would prevent that.
* custom.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling, rely on cl-extra.el in the
former case and the appropriate entry in bytecomp-load-hook in the
latter. Get rid of custom-declare-variable-list, we have no
dump-time dependencies that would require it.
* faces.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling.
* packages.el: Remove some inaccurate comments.
* post-gc.el (cleanup-simple-finalizers): Use #'delete-if-not
here, now the order of preloaded-file-list has been changed to
make it available.
* subr.el (custom-declare-variable-list): Remove. No need for it.
Also remove a stub define-abbrev-table from this file, given the
current order of preloaded-file-list there's no need for it.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are
also constant.
(byte-compile-initial-macro-environment): In #'the, if FORM is
constant and does not match TYPE, warn at byte-compile time.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* backquote.el (bq-vector-contents, bq-list*): Remove; the former
is equivalent to (append VECTOR nil), the latter to (list* ...).
(bq-process-2): Use (append VECTOR nil) instead of using
#'bq-vector-contents to convert to a list.
(bq-process-1): Now we use list* instead of bq-list
* subr.el (list*): Moved from cl.el, since it is now required to
be available the first time a backquoted form is encountered.
* cl.el (list*): Move to subr.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* test-harness.el (Check-Message):
Add an omitted comma here, thank you the buildbot.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* hash-table.el (hash-table-key-list, hash-table-value-list)
(hash-table-key-value-alist, hash-table-key-value-plist):
Remove some useless #'nreverse calls in these files; our hash
tables have no order, it's not helpful to pretend they do.
* behavior.el (read-behavior):
Do the same in this file, in some code evidently copied from
hash-table.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* info.el (Info-insert-dir):
* format.el (format-deannotate-region):
* files.el (cd, save-buffers-kill-emacs):
Use #'some, #'every and related functions for applying boolean
operations to lists, instead of rolling our own ones that cons and
don't short-circuit.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-initial-macro-environment):
* cl-macs.el (the):
Rephrase the docstring, make its implementation when compiling
files a little nicer.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* descr-text.el (unidata-initialize-unicodedata-database)
(unidata-initialize-unihan-database, describe-char-unicode-data)
(describe-char-unicode-data):
Wrap calls to the database functions with (with-fboundp ...),
avoiding byte compile warnings on builds without support for the
database functions.
(describe-char): (reduce #'max ...), not (apply #'max ...), no
need to cons needlessly.
(describe-char): Remove a redundant lambda wrapping
#'extent-properties.
(describe-char-unicode-data): Call #'nsubst when replacing "" with
nil in the result of #'split-string, instead of consing inside
mapcar.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* x-faces.el (x-available-font-sizes):
* specifier.el (let-specifier):
* package-ui.el (pui-add-required-packages):
* msw-faces.el (mswindows-available-font-sizes):
* modeline.el (modeline-minor-mode-menu):
* minibuf.el (minibuf-directory-files):
Replace the O2N (delq nil (mapcar (lambda (W) (and X Y)) Z)) with
the ON (mapcan (lambda (W) (and X (list Y))) Z) in these files.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
When these functions are handed more than two arguments, and those
arguments have no side effects, transform to a series of two
argument calls, avoiding funcall in the byte-compiled code.
* mule/mule-cmds.el (finish-set-language-environment):
Take advantage of this change in a function called 256 times at
startup.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-function-form, byte-compile-quote)
(byte-compile-quote-form):
Warn at compile time, and error at runtime, if a (quote ...) or a
(function ...) form attempts to quote more than one object.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc
(mapcar ...)) to (mapcan ...); warn about use of the first idiom.
* update-elc.el (do-autoload-commands):
* packages.el (packages-find-package-library-path):
* frame.el (frame-list):
* extents.el (extent-descendants):
* etags.el (buffer-tag-table-files):
* dumped-lisp.el (preloaded-file-list):
* device.el (device-list):
* bytecomp-runtime.el (proclaim-inline, proclaim-notinline)
Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files.
* bytecomp-runtime.el (eval-when-compile, eval-and-compile):
In passing, mention that these macros also evaluate the body when
interpreted.
tests/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Test lexical scope for `block', `return-from'; add a
Known-Bug-Expect-Failure for a contorted example that fails when
byte-compiled.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 07 Feb 2011 12:01:24 +0000 |
parents | b5611afbcc76 |
children | 308d34e9f07d |
rev | line source |
---|---|
428 | 1 /* The "lrecord" structure (header of a compound lisp object). |
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. | |
5125 | 3 Copyright (C) 1996, 2001, 2002, 2004, 2005, 2009, 2010 Ben Wing. |
428 | 4 |
5 This file is part of XEmacs. | |
6 | |
7 XEmacs is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2, or (at your option) any | |
10 later version. | |
11 | |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with XEmacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | |
22 /* Synched up with: Not in FSF. */ | |
23 | |
2367 | 24 /* This file has been Mule-ized, Ben Wing, 10-13-04. */ |
25 | |
440 | 26 #ifndef INCLUDED_lrecord_h_ |
27 #define INCLUDED_lrecord_h_ | |
428 | 28 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
29 /* All objects other than char and int are implemented as structures and |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
30 passed by reference. Such objects are called "record objects" ("record" |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
31 is another term for "structure"). The "wrapped" value of such an object |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
32 (i.e. when stored in a variable of type Lisp_Object) is simply the raw |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
33 pointer coerced to an integral type the same size as the pointer |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
34 (usually `long'). |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
35 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
36 Under old-GC (i.e. when NEW_GC is not defined), there are two kinds of |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
37 record objects: normal objects (those allocated on their own with |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
38 xmalloc()) and frob-block objects (those allocated as pieces of large, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
39 usually 2K, chunks of memory known as "frob blocks"). Under NEW_GC, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
40 there is only one type of record object. Stuff below that applies to |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
41 frob-block objects is assumed to apply to the same type of object as |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
42 normal objects under NEW_GC. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
43 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
44 Record objects have a header at the beginning of their structure, which |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
45 is used internally to identify the type of the object (so that an |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
46 object's type can be recovered from its pointer); in addition, it holds |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
47 a few flags and a "UID", which for most objects is shown when it is |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
48 printed, and is primarily useful for debugging purposes. The header of |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
49 a normal object is declared as NORMAL_LISP_OBJECT_HEADER and that of a |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
50 frob-block object FROB_BLOCK_LISP_OBJECT_HEADER. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
51 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
52 FROB_BLOCK_LISP_OBJECT_HEADER boils down to a `struct lrecord_header'. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
53 This is a 32-bit value made up of bit fields, where 8 bits are used to |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
54 hold the type, 2 or 3 bits are used for flags associated with the |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
55 garbage collector, and the remaining 21 or 22 bits hold the UID. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
56 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
57 Under NEW_GC, NORMAL_LISP_OBJECT_HEADER also resolves to `struct |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
58 lrecord_header'. Under old-GC, however, NORMAL_LISP_OBJECT_HEADER |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
59 resolves to a `struct old_lcrecord_header' (note the `c'), which is a |
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
60 larger structure -- on 32-bit machines it occupies 2 machine words |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
61 instead of 1. Such an object is known internally as an "lcrecord". The |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
62 first word of `struct old_lcrecord_header' is an embedded `struct |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
63 lrecord_header' with the same information as for frob-block objects; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
64 that way, all objects can be cast to a `struct lrecord_header' to |
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
65 determine their type or other info. The other word is a pointer, used |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
66 to thread all lcrecords together in one big linked list. |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
67 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
68 Under old-GC, normal objects (i.e. lcrecords) are allocated in |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
69 individual chunks using the underlying allocator (i.e. xmalloc(), which |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
70 is a thin wrapper around malloc()). Frob-block objects are more |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
71 efficient than normal objects, as they have a smaller header and don't |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
72 have the additional memory overhead associated with malloc() -- instead, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
73 as mentioned above, they are carved out of 2K chunks of memory called |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
74 "frob blocks"). However, it is slightly more tricky to create such |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
75 objects, as they require special routines in alloc.c to create an object |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
76 of each such type and to sweep them during garbage collection. In |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
77 addition, there is currently no mechanism for handling variable-sized |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
78 frob-block objects (e.g. vectors), whereas variable-sized normal objects |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
79 are not a problem. Frob-block objects are typically used for basic |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
80 objects that exist in large numbers, such as `cons' or `string'. |
2720 | 81 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
82 Note that strings are an apparent exception to the statement above that |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
83 variable-sized objects can't be handled. Under old-GC strings work as |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
84 follows. A string consists of two parts -- a fixed-size "string header" |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
85 that is allocated as a standard frob-block object, and a "string-chars" |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
86 structure that is allocated out of special 8K-sized frob blocks that |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
87 have a dedicated garbage-collection handler that compacts the blocks |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
88 during the sweep stage, relocating the string-chars data (but not the |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
89 string headers) to eliminate gaps. Strings larger than 8K are not |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
90 placed in frob blocks, but instead are stored as individually malloc()ed |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
91 blocks of memory. Strings larger than 8K are called "big strings" and |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
92 those smaller than 8K are called "small strings". |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
93 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
94 Under new-GC, there is no difference between big and small strings, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
95 just as there is no difference between normal and frob-block objects. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
96 There is only one allocation method, which is capable of handling |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
97 variable-sized objects. This apparently allocates all objects in |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
98 frob blocks according to the size of the object. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
99 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
100 To create a new normal Lisp object, see the toolbar-button example |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
101 below. To create a new frob-block Lisp object, follow the lead of |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
102 one of the existing frob-block objects, such as extents or events. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
103 Note that you do not need to supply all the methods (see below); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
104 reasonable defaults are provided for many of them. Alternatively, if |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
105 you're just looking for a way of encapsulating data (which possibly |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
106 could contain Lisp_Objects in it), you may well be able to use the |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
107 opaque type. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
108 */ |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
109 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
110 /* |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
111 How to declare a Lisp object: |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
112 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
113 NORMAL_LISP_OBJECT_HEADER: |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
114 Header for normal objects |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
115 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
116 FROB_BLOCK_LISP_OBJECT_HEADER: |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
117 Header for frob-block objects |
428 | 118 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
119 How to allocate a Lisp object: |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
120 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
121 - For normal objects of a fixed size, simply call |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
122 ALLOC_NORMAL_LISP_OBJECT (type), where TYPE is the name of the type |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
123 (e.g. toolbar_button). Such objects can be freed manually using |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
124 free_normal_lisp_object. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
125 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
126 - For normal objects whose size can vary (and hence which have a |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
127 size_in_bytes_method rather than a static_size), call |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
128 ALLOC_SIZED_LISP_OBJECT (size, type), where TYPE is the |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
129 name of the type. NOTE: You cannot call free_normal_lisp_object() on such |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
130 on object! (At least when not NEW_GC) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
131 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
132 - For frob-block objects, use |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
133 ALLOC_FROB_BLOCK_LISP_OBJECT (type, lisp_type, var, lrec_ptr). |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
134 But these objects need special handling; if you don't understand this, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
135 just ignore it. |
428 | 136 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
137 - Some lrecords, which are used totally internally, use the |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
138 noseeum-* functions for debugging reasons. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
139 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
140 Other operations: |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
141 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
142 - copy_lisp_object (dst, src) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
143 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
144 - zero_nonsized_lisp_object (obj), zero_sized_lisp_object (obj, size): |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
145 BUT NOTE, it is not necessary to zero out newly allocated Lisp objects. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
146 This happens automatically. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
147 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
148 - lisp_object_size (obj): Return the size of a Lisp object. NOTE: This |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
149 requires that the object is properly initialized. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
150 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
151 - lisp_object_storage_size (obj, stats): Return the storage size of a |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
152 Lisp objcet, including malloc or frob-block overhead; also, if STATS |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
153 is non-NULL, accumulate info about the size and overhead into STATS. |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
154 */ |
4930
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
155 |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
156 #ifdef NEW_GC |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
157 /* |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
158 There are some limitations under New-GC that lead to the creation of a |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
159 large number of new internal object types. I'm not completely sure what |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
160 all of them are, but they are at least partially related to limitations |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
161 on finalizers. Something else must be going on as well, because |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
162 non-dumpable, non-finalizable objects like devices and frames also have |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
163 their window-system-specific substructures converted into Lisp objects. |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
164 It must have something to do with the fact that these substructures |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
165 contain pointers to Lisp objects, but it's not completely clear why -- |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
166 object descriptions exist to indicate the size of these structures and |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
167 the Lisp object pointers within them. |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
168 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
169 At least one definite issue is that under New-GC dumpable objects cannot |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
170 contain any finalizers (see pdump_register_object()). This means that |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
171 any substructures in dumpable objects that are allocated separately and |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
172 normally freed in a finalizer need instead to be made into actual Lisp |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
173 objects. If those structures are Dynarrs, they need to be made into |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
174 Dynarr Lisp objects (e.g. face-cachel-dynarr or glyph-cachel-dynarr), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
175 which are created using Dynarr_lisp_new() or Dynarr_new_new2(). |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
176 Furthermore, the objects contained in the Dynarr also need to be Lisp |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
177 objects (e.g. face-cachel or glyph-cachel). |
4930
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
178 |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
179 --ben |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
180 */ |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
181 #endif |
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
182 |
3263 | 183 #ifdef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
184 #define ALLOC_NORMAL_LISP_OBJECT(type) alloc_lrecord (&lrecord_##type) |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
185 #define ALLOC_SIZED_LISP_OBJECT(size, type) \ |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
186 alloc_sized_lrecord (size, &lrecord_##type) |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
187 #define NORMAL_LISP_OBJECT_HEADER struct lrecord_header |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
188 #define FROB_BLOCK_LISP_OBJECT_HEADER struct lrecord_header |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
189 #define LISP_OBJECT_FROB_BLOCK_P(obj) 0 |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
190 #define IF_NEW_GC(x) x |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
191 #define IF_OLD_GC(x) 0 |
3263 | 192 #else /* not NEW_GC */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
193 #define ALLOC_NORMAL_LISP_OBJECT(type) alloc_automanaged_lcrecord (&lrecord_##type) |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
194 #define ALLOC_SIZED_LISP_OBJECT(size, type) \ |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
195 old_alloc_sized_lcrecord (size, &lrecord_##type) |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
196 #define NORMAL_LISP_OBJECT_HEADER struct old_lcrecord_header |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
197 #define FROB_BLOCK_LISP_OBJECT_HEADER struct lrecord_header |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
198 #define LISP_OBJECT_FROB_BLOCK_P(obj) (XRECORD_LHEADER_IMPLEMENTATION(obj)->frob_block_p) |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
199 #define IF_NEW_GC(x) 0 |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
200 #define IF_OLD_GC(x) x |
3263 | 201 #endif /* not NEW_GC */ |
3024 | 202 |
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
203 #define LISP_OBJECT_UID(obj) (XRECORD_LHEADER (obj)->uid) |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
204 |
1743 | 205 BEGIN_C_DECLS |
1650 | 206 |
428 | 207 struct lrecord_header |
208 { | |
1204 | 209 /* Index into lrecord_implementations_table[]. Objects that have been |
210 explicitly freed using e.g. free_cons() have lrecord_type_free in this | |
211 field. */ | |
442 | 212 unsigned int type :8; |
213 | |
3263 | 214 #ifdef NEW_GC |
2720 | 215 /* 1 if the object is readonly from lisp */ |
216 unsigned int lisp_readonly :1; | |
217 | |
218 /* The `free' field is a flag that indicates whether this lrecord | |
219 is currently free or not. This is used for error checking and | |
220 debugging. */ | |
221 unsigned int free :1; | |
222 | |
3063 | 223 /* The `uid' field is just for debugging/printing convenience. Having |
224 this slot doesn't hurt us spacewise, since the bits are unused | |
225 anyway. (The bits are used for strings, though.) */ | |
2720 | 226 unsigned int uid :22; |
227 | |
3263 | 228 #else /* not NEW_GC */ |
442 | 229 /* If `mark' is 0 after the GC mark phase, the object will be freed |
230 during the GC sweep phase. There are 2 ways that `mark' can be 1: | |
231 - by being referenced from other objects during the GC mark phase | |
232 - because it is permanently on, for c_readonly objects */ | |
233 unsigned int mark :1; | |
234 | |
235 /* 1 if the object resides in logically read-only space, and does not | |
236 reference other non-c_readonly objects. | |
237 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */ | |
238 unsigned int c_readonly :1; | |
239 | |
428 | 240 /* 1 if the object is readonly from lisp */ |
442 | 241 unsigned int lisp_readonly :1; |
771 | 242 |
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
243 /* The `free' field is currently used only for lcrecords under old-GC. |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
244 It is a flag that indicates whether this lcrecord is on a "free list". |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
245 Free lists are used to minimize the number of calls to malloc() when |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
246 we're repeatedly allocating and freeing a number of the same sort of |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
247 lcrecord. Lcrecords on a free list always get marked in a different |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
248 fashion, so we can use this flag as a sanity check to make sure that |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
249 free lists only have freed lcrecords and there are no freed lcrecords |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
250 elsewhere. */ |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
251 unsigned int free :1; |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
252 |
3063 | 253 /* The `uid' field is just for debugging/printing convenience. Having |
254 this slot doesn't hurt us spacewise, since the bits are unused | |
255 anyway. (The bits are used for strings, though.) */ | |
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
256 unsigned int uid :20; |
934 | 257 |
3263 | 258 #endif /* not NEW_GC */ |
428 | 259 }; |
260 | |
261 struct lrecord_implementation; | |
442 | 262 int lrecord_type_index (const struct lrecord_implementation *implementation); |
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
263 extern int lrecord_uid_counter[]; |
428 | 264 |
3263 | 265 #ifdef NEW_GC |
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
266 #define set_lheader_implementation(header,imp) do { \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
267 struct lrecord_header* SLI_header = (header); \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
268 SLI_header->type = (imp)->lrecord_type_index; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
269 SLI_header->lisp_readonly = 0; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
270 SLI_header->free = 0; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
271 SLI_header->uid = lrecord_uid_counter[(imp)->lrecord_type_index]++; \ |
2720 | 272 } while (0) |
3263 | 273 #else /* not NEW_GC */ |
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
274 #define set_lheader_implementation(header,imp) do { \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
275 struct lrecord_header* SLI_header = (header); \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
276 SLI_header->type = (imp)->lrecord_type_index; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
277 SLI_header->mark = 0; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
278 SLI_header->c_readonly = 0; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
279 SLI_header->lisp_readonly = 0; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
280 SLI_header->free = 0; \ |
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
281 SLI_header->uid = lrecord_uid_counter[(imp)->lrecord_type_index]++; \ |
428 | 282 } while (0) |
3263 | 283 #endif /* not NEW_GC */ |
428 | 284 |
3263 | 285 #ifndef NEW_GC |
3024 | 286 struct old_lcrecord_header |
428 | 287 { |
288 struct lrecord_header lheader; | |
289 | |
442 | 290 /* The `next' field is normally used to chain all lcrecords together |
428 | 291 so that the GC can find (and free) all of them. |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
292 `old_alloc_sized_lcrecord' threads lcrecords together. |
428 | 293 |
294 The `next' field may be used for other purposes as long as some | |
295 other mechanism is provided for letting the GC do its work. | |
296 | |
297 For example, the event and marker object types allocate members | |
298 out of memory chunks, and are able to find all unmarked members | |
299 by sweeping through the elements of the list of chunks. */ | |
3024 | 300 struct old_lcrecord_header *next; |
428 | 301 }; |
302 | |
303 /* Used for lcrecords in an lcrecord-list. */ | |
304 struct free_lcrecord_header | |
305 { | |
3024 | 306 struct old_lcrecord_header lcheader; |
428 | 307 Lisp_Object chain; |
308 }; | |
3263 | 309 #endif /* not NEW_GC */ |
428 | 310 |
3931 | 311 /* DON'T FORGET to update .gdbinit.in if you change this list. */ |
442 | 312 enum lrecord_type |
313 { | |
314 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast. | |
315 #### This should be replaced by a symbol_value_magic_p flag | |
316 in the Lisp_Symbol lrecord_header. */ | |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
317 /* Don't assign any type to 0, so in case we come across zeroed memory |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
318 it will be more obvious when printed */ |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
319 lrecord_type_symbol_value_forward = 1, |
3092 | 320 lrecord_type_symbol_value_varalias, |
321 lrecord_type_symbol_value_lisp_magic, | |
322 lrecord_type_symbol_value_buffer_local, | |
442 | 323 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local, |
3092 | 324 lrecord_type_symbol, |
325 lrecord_type_subr, | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3931
diff
changeset
|
326 lrecord_type_multiple_value, |
3092 | 327 lrecord_type_cons, |
328 lrecord_type_vector, | |
329 lrecord_type_string, | |
3263 | 330 #ifndef NEW_GC |
442 | 331 lrecord_type_lcrecord_list, |
3263 | 332 #endif /* not NEW_GC */ |
3092 | 333 lrecord_type_compiled_function, |
334 lrecord_type_weak_list, | |
335 lrecord_type_bit_vector, | |
336 lrecord_type_float, | |
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5180
diff
changeset
|
337 lrecord_type_hash_table_test, |
3092 | 338 lrecord_type_hash_table, |
339 lrecord_type_lstream, | |
340 lrecord_type_process, | |
341 lrecord_type_charset, | |
342 lrecord_type_coding_system, | |
343 lrecord_type_char_table, | |
344 lrecord_type_char_table_entry, | |
345 lrecord_type_range_table, | |
346 lrecord_type_opaque, | |
347 lrecord_type_opaque_ptr, | |
348 lrecord_type_buffer, | |
349 lrecord_type_extent, | |
350 lrecord_type_extent_info, | |
351 lrecord_type_extent_auxiliary, | |
352 lrecord_type_marker, | |
353 lrecord_type_event, | |
2720 | 354 #ifdef EVENT_DATA_AS_OBJECTS /* not defined */ |
934 | 355 lrecord_type_key_data, |
356 lrecord_type_button_data, | |
357 lrecord_type_motion_data, | |
358 lrecord_type_process_data, | |
359 lrecord_type_timeout_data, | |
360 lrecord_type_eval_data, | |
361 lrecord_type_misc_user_data, | |
362 lrecord_type_magic_eval_data, | |
363 lrecord_type_magic_data, | |
1204 | 364 #endif /* EVENT_DATA_AS_OBJECTS */ |
3092 | 365 lrecord_type_keymap, |
366 lrecord_type_command_builder, | |
367 lrecord_type_timeout, | |
368 lrecord_type_specifier, | |
369 lrecord_type_console, | |
370 lrecord_type_device, | |
371 lrecord_type_frame, | |
372 lrecord_type_window, | |
373 lrecord_type_window_mirror, | |
374 lrecord_type_gui_item, | |
375 lrecord_type_toolbar_button, | |
376 lrecord_type_scrollbar_instance, | |
377 lrecord_type_color_instance, | |
378 lrecord_type_font_instance, | |
379 lrecord_type_image_instance, | |
380 lrecord_type_glyph, | |
381 lrecord_type_face, | |
3931 | 382 lrecord_type_fc_config, |
3094 | 383 lrecord_type_fc_pattern, |
3092 | 384 lrecord_type_database, |
385 lrecord_type_tooltalk_message, | |
386 lrecord_type_tooltalk_pattern, | |
387 lrecord_type_ldap, | |
388 lrecord_type_pgconn, | |
389 lrecord_type_pgresult, | |
390 lrecord_type_devmode, | |
391 lrecord_type_mswindows_dialog_id, | |
392 lrecord_type_case_table, | |
393 lrecord_type_emacs_ffi, | |
394 lrecord_type_emacs_gtk_object, | |
395 lrecord_type_emacs_gtk_boxed, | |
396 lrecord_type_weak_box, | |
397 lrecord_type_ephemeron, | |
398 lrecord_type_bignum, | |
399 lrecord_type_ratio, | |
400 lrecord_type_bigfloat, | |
3263 | 401 #ifndef NEW_GC |
454 | 402 lrecord_type_free, /* only used for "free" lrecords */ |
403 lrecord_type_undefined, /* only used for debugging */ | |
3263 | 404 #endif /* not NEW_GC */ |
3092 | 405 #ifdef NEW_GC |
4930
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
406 /* See comment up top explaining why these extra object types must exist. */ |
3092 | 407 lrecord_type_string_indirect_data, |
408 lrecord_type_string_direct_data, | |
409 lrecord_type_hash_table_entry, | |
410 lrecord_type_syntax_cache, | |
411 lrecord_type_buffer_text, | |
412 lrecord_type_compiled_function_args, | |
413 lrecord_type_tty_console, | |
414 lrecord_type_stream_console, | |
415 lrecord_type_dynarr, | |
416 lrecord_type_face_cachel, | |
417 lrecord_type_face_cachel_dynarr, | |
418 lrecord_type_glyph_cachel, | |
419 lrecord_type_glyph_cachel_dynarr, | |
420 lrecord_type_x_device, | |
421 lrecord_type_gtk_device, | |
422 lrecord_type_tty_device, | |
423 lrecord_type_mswindows_device, | |
424 lrecord_type_msprinter_device, | |
425 lrecord_type_x_frame, | |
426 lrecord_type_gtk_frame, | |
427 lrecord_type_mswindows_frame, | |
428 lrecord_type_gap_array_marker, | |
429 lrecord_type_gap_array, | |
430 lrecord_type_extent_list_marker, | |
431 lrecord_type_extent_list, | |
432 lrecord_type_stack_of_extents, | |
433 lrecord_type_tty_color_instance_data, | |
434 lrecord_type_tty_font_instance_data, | |
435 lrecord_type_specifier_caching, | |
436 lrecord_type_expose_ignore, | |
437 #endif /* NEW_GC */ | |
438 lrecord_type_last_built_in_type /* must be last */ | |
442 | 439 }; |
440 | |
1632 | 441 extern MODULE_API int lrecord_type_count; |
428 | 442 |
443 struct lrecord_implementation | |
444 { | |
2367 | 445 const Ascbyte *name; |
442 | 446 |
934 | 447 /* information for the dumper: is the object dumpable and should it |
448 be dumped. */ | |
449 unsigned int dumpable :1; | |
450 | |
442 | 451 /* `marker' is called at GC time, to make sure that all Lisp_Objects |
428 | 452 pointed to by this object get properly marked. It should call |
453 the mark_object function on all Lisp_Objects in the object. If | |
454 the return value is non-nil, it should be a Lisp_Object to be | |
455 marked (don't call the mark_object function explicitly on it, | |
456 because the GC routines will do this). Doing it this way reduces | |
457 recursion, so the object returned should preferably be the one | |
458 with the deepest level of Lisp_Object pointers. This function | |
1204 | 459 can be NULL, meaning no GC marking is necessary. |
460 | |
461 NOTE NOTE NOTE: This is not used by KKCC (which uses the data | |
462 description below instead), unless the data description is missing. | |
463 Yes, this currently means there is logic duplication. Eventually the | |
464 mark methods will be removed. */ | |
428 | 465 Lisp_Object (*marker) (Lisp_Object); |
442 | 466 |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
467 /* `printer' converts the object to a printed representation. `printer' |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
468 should never be NULL (if so, you will get an assertion failure when |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
469 trying to print such an object). Either supply a specific printing |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
470 method, or use the default methods internal_object_printer() (for |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
471 internal objects that should not be visible at Lisp level) or |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
472 external_object_printer() (for objects visible at Lisp level). */ |
428 | 473 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag); |
442 | 474 |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
475 /* `finalizer' is called at GC time when the object is about to be freed. |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
476 It should perform any necessary cleanup, such as freeing malloc()ed |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
477 memory or releasing pointers or handles to objects created in external |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
478 libraries, such as window-system windows or file handles. This can be |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
479 NULL, meaning no special finalization is necessary. */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
480 void (*finalizer) (Lisp_Object obj); |
442 | 481 |
428 | 482 /* This can be NULL, meaning compare objects with EQ(). */ |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
483 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth, |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
484 int foldcase); |
442 | 485 |
486 /* `hash' generates hash values for use with hash tables that have | |
487 `equal' as their test function. This can be NULL, meaning use | |
488 the Lisp_Object itself as the hash. But, you must still satisfy | |
489 the constraint that if two objects are `equal', then they *must* | |
490 hash to the same value in order for hash tables to work properly. | |
491 This means that `hash' can be NULL only if the `equal' method is | |
492 also NULL. */ | |
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5180
diff
changeset
|
493 Hashcode (*hash) (Lisp_Object, int, Boolint); |
428 | 494 |
1204 | 495 /* Data layout description for your object. See long comment below. */ |
496 const struct memory_description *description; | |
428 | 497 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
498 /* Only one of `static_size' and `size_in_bytes_method' is non-0. If |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
499 `static_size' is 0, this type is not instantiable by |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
500 ALLOC_NORMAL_LISP_OBJECT(). If both are 0 (this should never happen), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
501 this object cannot be instantiated; you will get an abort() if you |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
502 try.*/ |
665 | 503 Bytecount static_size; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
504 Bytecount (*size_in_bytes_method) (Lisp_Object); |
442 | 505 |
506 /* The (constant) index into lrecord_implementations_table */ | |
507 enum lrecord_type lrecord_type_index; | |
508 | |
3263 | 509 #ifndef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
510 /* A "frob-block" lrecord is any lrecord that's not an lcrecord, i.e. |
3024 | 511 one that does not have an old_lcrecord_header at the front and which |
1204 | 512 is (usually) allocated in frob blocks. */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
513 unsigned int frob_block_p :1; |
3263 | 514 #endif /* not NEW_GC */ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
515 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
516 /**********************************************************************/ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
517 /* Remaining stuff is not assignable statically using |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
518 DEFINE_*_LISP_OBJECT, but must be assigned with OBJECT_HAS_METHOD, |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
519 OBJECT_HAS_PROPERTY or the like. */ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
520 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
521 /* These functions allow any object type to have builtin property |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
522 lists that can be manipulated from the lisp level with |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
523 `get', `put', `remprop', and `object-plist'. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
524 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop); |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
525 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val); |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
526 int (*remprop) (Lisp_Object obj, Lisp_Object prop); |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
527 Lisp_Object (*plist) (Lisp_Object obj); |
5255
b5611afbcc76
Support process plists, for greater GNU compatibility.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
528 Lisp_Object (*setplist) (Lisp_Object obj, Lisp_Object newplist); |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
529 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
530 /* `disksave' is called at dump time. It is used for objects that |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
531 contain pointers or handles to objects created in external libraries, |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
532 such as window-system windows or file handles. Such external objects |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
533 cannot be dumped, so it is necessary to release them at dump time and |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
534 arrange somehow or other for them to be resurrected if necessary later |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
535 on. |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
536 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
537 It seems that even non-dumpable objects may be around at dump time, |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
538 and a disksave may be provided. (In fact, the only object currently |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
539 with a disksave, lstream, is non-dumpable.) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
540 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
541 Objects rarely need to provide this method; most of the time it will |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
542 be NULL. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
543 void (*disksave) (Lisp_Object); |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
544 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
545 #ifdef MEMORY_USAGE_STATS |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
546 /* Return memory-usage information about the object in question, stored |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
547 into STATS. |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
548 |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
549 Two types of information are stored: storage (including overhead) for |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
550 ancillary non-Lisp structures attached to the object, and storage |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
551 (including overhead) for ancillary Lisp objects attached to the |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
552 object. The third type of memory-usage information (storage for the |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
553 object itself) is not noted here, because it's computed automatically |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
554 by the calling function. Also, the computed storage for ancillary |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
555 Lisp objects is the sum of all three source of memory associated with |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
556 the Lisp object: the object itself, ancillary non-Lisp structures and |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
557 ancillary Lisp objects. Note also that the `struct usage_stats u' at |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
558 the beginning of the STATS structure is for ancillary non-Lisp usage |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
559 *ONLY*; do not store any memory into it related to ancillary Lisp |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
560 objects. |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
561 |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
562 Note that it may be subjective which Lisp objects are considered |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
563 "attached" to the object. Some guidelines: |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
564 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
565 -- Lisp objects which are "internal" to the main object and not |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
566 accessible except through the main object should be included |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
567 -- Objects linked by a weak reference should *NOT* be included |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
568 */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
569 void (*memory_usage) (Lisp_Object obj, struct generic_usage_stats *stats); |
5158
9e0b43d3095c
more cleanups to object-memory-usage stuff
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
570 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
571 /* List of tags to be given to the extra statistics, one per statistic. |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
572 Qnil or Qt can be present to separate off different slices. Qnil |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
573 separates different slices within the same group of statistics. |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
574 These represent different ways of partitioning the same memory space. |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
575 Qt separates different groups; these represent different spaces of |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
576 memory. |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
577 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
578 If Qt is not present, all slices describe extra non-Lisp-Object memory |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
579 associated with a Lisp object. If Qt is present, slices before Qt |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
580 describe non-Lisp-Object memory, as before, and slices after Qt |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
581 describe ancillary Lisp-Object memory logically associated with the |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
582 object. For example, if the object is a table, then ancillary |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
583 Lisp-Object memory might be the entries in the table. This info is |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
584 only advisory since it will duplicate memory described elsewhere and |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
585 since it may not be possible to be completely accurate, e.g. it may |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
586 not be clear what to count in "ancillary objects", and the value may |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
587 be too high if the same object occurs multiple times in the table. */ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
588 Lisp_Object memusage_stats_list; |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
589 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
590 /* --------------------------------------------------------------------- */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
591 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
592 /* The following are automatically computed based on the value in |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
593 `memusage_stats_list' (see compute_memusage_stats_length()). */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
594 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
595 /* Total number of additional type-specific statistics related to memory |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
596 usage. */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
597 Elemcount num_extra_memusage_stats; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
598 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
599 /* Number of additional type-specific statistics belonging to the first |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
600 slice of the group describing non-Lisp-Object memory usage for this |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
601 object. These stats occur starting at offset 0. */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
602 Elemcount num_extra_nonlisp_memusage_stats; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
603 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
604 /* The offset into the extra statistics at which the Lisp-Object |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
605 memory-usage statistics begin. */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
606 Elemcount offset_lisp_ancillary_memusage_stats; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
607 |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
608 /* Number of additional type-specific statistics belonging to the first |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
609 slice of the group describing Lisp-Object memory usage for this |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
610 object. These stats occur starting at offset |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
611 `offset_lisp_ancillary_memusage_stats'. */ |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
612 Elemcount num_extra_lisp_ancillary_memusage_stats; |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
613 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
614 #endif /* MEMORY_USAGE_STATS */ |
428 | 615 }; |
616 | |
617 | 617 /* All the built-in lisp object types are enumerated in `enum lrecord_type'. |
442 | 618 Additional ones may be defined by a module (none yet). We leave some |
619 room in `lrecord_implementations_table' for such new lisp object types. */ | |
620 #define MODULE_DEFINABLE_TYPE_COUNT 32 | |
621 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
622 extern MODULE_API struct lrecord_implementation * |
1632 | 623 lrecord_implementations_table[lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT]; |
428 | 624 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
625 /* Given a Lisp object, return its implementation |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
626 (struct lrecord_implementation) */ |
428 | 627 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \ |
442 | 628 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj)) |
629 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type] | |
428 | 630 |
3092 | 631 #include "gc.h" |
632 | |
633 #ifdef NEW_GC | |
634 #include "vdb.h" | |
635 #endif /* NEW_GC */ | |
636 | |
428 | 637 extern int gc_in_progress; |
638 | |
3263 | 639 #ifdef NEW_GC |
2720 | 640 #include "mc-alloc.h" |
641 | |
2994 | 642 #ifdef ALLOC_TYPE_STATS |
2720 | 643 void init_lrecord_stats (void); |
644 void inc_lrecord_stats (Bytecount size, const struct lrecord_header *h); | |
645 void dec_lrecord_stats (Bytecount size_including_overhead, | |
646 const struct lrecord_header *h); | |
3092 | 647 int lrecord_stats_heap_size (void); |
2994 | 648 #endif /* ALLOC_TYPE_STATS */ |
2720 | 649 |
650 /* Tell mc-alloc how to call a finalizer. */ | |
3092 | 651 #define MC_ALLOC_CALL_FINALIZER(ptr) \ |
652 { \ | |
653 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ | |
654 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \ | |
655 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \ | |
656 && !LRECORD_FREE_P (MCACF_lheader) ) \ | |
657 { \ | |
658 const struct lrecord_implementation *MCACF_implementation \ | |
659 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ | |
660 if (MCACF_implementation && MCACF_implementation->finalizer) \ | |
661 { \ | |
662 GC_STAT_FINALIZED; \ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
663 MCACF_implementation->finalizer (MCACF_obj); \ |
3092 | 664 } \ |
665 } \ | |
666 } while (0) | |
2720 | 667 |
668 /* Tell mc-alloc how to call a finalizer for disksave. */ | |
669 #define MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE(ptr) \ | |
670 { \ | |
671 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ | |
672 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \ | |
673 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \ | |
674 && !LRECORD_FREE_P (MCACF_lheader) ) \ | |
675 { \ | |
676 const struct lrecord_implementation *MCACF_implementation \ | |
677 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
678 if (MCACF_implementation && MCACF_implementation->disksave) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
679 MCACF_implementation->disksave (MCACF_obj); \ |
2720 | 680 } \ |
681 } while (0) | |
682 | |
683 #define LRECORD_FREE_P(ptr) \ | |
684 (((struct lrecord_header *) ptr)->free) | |
685 | |
686 #define MARK_LRECORD_AS_FREE(ptr) \ | |
687 ((void) (((struct lrecord_header *) ptr)->free = 1)) | |
688 | |
689 #define MARK_LRECORD_AS_NOT_FREE(ptr) \ | |
690 ((void) (((struct lrecord_header *) ptr)->free = 0)) | |
691 | |
692 #define MARKED_RECORD_P(obj) MARKED_P (obj) | |
693 #define MARKED_RECORD_HEADER_P(lheader) MARKED_P (lheader) | |
694 #define MARK_RECORD_HEADER(lheader) MARK (lheader) | |
695 #define UNMARK_RECORD_HEADER(lheader) UNMARK (lheader) | |
696 | |
697 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly) | |
698 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \ | |
699 ((void) ((lheader)->lisp_readonly = 1)) | |
700 #define MARK_LRECORD_AS_LISP_READONLY(ptr) \ | |
701 ((void) (((struct lrecord_header *) ptr)->lisp_readonly = 1)) | |
702 | |
3263 | 703 #else /* not NEW_GC */ |
2720 | 704 |
5059
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
705 enum lrecord_alloc_status |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
706 { |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
707 ALLOC_IN_USE, |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
708 ALLOC_FREE, |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
709 ALLOC_ON_FREE_LIST |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
710 }; |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
711 |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
712 void tick_lrecord_stats (const struct lrecord_header *h, |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
713 enum lrecord_alloc_status status); |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
714 |
2720 | 715 #define LRECORD_FREE_P(ptr) \ |
716 (((struct lrecord_header *) ptr)->type == lrecord_type_free) | |
717 | |
718 #define MARK_LRECORD_AS_FREE(ptr) \ | |
719 ((void) (((struct lrecord_header *) ptr)->type = lrecord_type_free)) | |
720 | |
442 | 721 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark) |
428 | 722 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark) |
723 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1)) | |
724 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0)) | |
725 | |
726 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly) | |
727 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly) | |
442 | 728 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \ |
729 struct lrecord_header *SCRRH_lheader = (lheader); \ | |
730 SCRRH_lheader->c_readonly = 1; \ | |
731 SCRRH_lheader->lisp_readonly = 1; \ | |
732 SCRRH_lheader->mark = 1; \ | |
733 } while (0) | |
428 | 734 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \ |
735 ((void) ((lheader)->lisp_readonly = 1)) | |
3263 | 736 #endif /* not NEW_GC */ |
1676 | 737 |
738 #ifdef USE_KKCC | |
739 #define RECORD_DESCRIPTION(lheader) lrecord_memory_descriptions[(lheader)->type] | |
740 #else /* not USE_KKCC */ | |
442 | 741 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type] |
1676 | 742 #endif /* not USE_KKCC */ |
428 | 743 |
934 | 744 #define RECORD_DUMPABLE(lheader) (lrecord_implementations_table[(lheader)->type])->dumpable |
1204 | 745 |
746 /* Data description stuff | |
934 | 747 |
1204 | 748 Data layout descriptions describe blocks of memory (in particular, Lisp |
749 objects and other objects on the heap, and global objects with pointers | |
750 to such heap objects), including their size and a list of the elements | |
751 that need relocating, marking or other special handling. They are | |
752 currently used in two places: by pdump [the new, portable dumper] and | |
753 KKCC [the new garbage collector]. The two subsystems use the | |
754 descriptions in different ways, and as a result some of the descriptions | |
755 are appropriate only for one or the other, when it is known that only | |
756 that subsystem will use the description. (This is particularly the case | |
757 with objects that can't be dumped, because pdump needs more info than | |
758 KKCC.) However, properly written descriptions are appropriate for both, | |
759 and you should strive to write your descriptions that way, since the | |
760 dumpable status of an object may change and new uses for the | |
761 descriptions may be created. (An example that comes to mind is a | |
762 facility for determining the memory usage of XEmacs data structures -- | |
763 like `buffer-memory-usage', `window-memory-usage', etc. but more | |
764 general.) | |
765 | |
766 More specifically: | |
428 | 767 |
1204 | 768 Pdump (the portable dumper) needs to write out all objects in heap |
769 space, and later on (in another invocation of XEmacs) load them back | |
770 into the heap, relocating all pointers to the heap objects in the global | |
771 data space. ("Heap" means anything malloc()ed, including all Lisp | |
772 objects, and "global data" means anything declared globally or | |
773 `static'.) Pdump, then, needs to be told about the location of all | |
774 global pointers to heap objects, all the description of all such | |
775 objects, including their size and any pointers to other heap (aka | |
776 "relocatable") objects. (Pdump assumes that the heap may occur in | |
777 different places in different invocations -- therefore, it is not enough | |
778 simply to write out the entire heap and later reload it at the same | |
779 location -- but that global data is always in the same place, and hence | |
780 pointers to it do not need to be relocated. This assumption holds true | |
781 in general for modern operating systems, but would be broken, for | |
782 example, in a system without virtual memory, or when dealing with shared | |
783 libraries. Also, unlike unexec, pdump does not usually write out or | |
784 restore objects in the global data space, and thus they need to be | |
785 initialized every time XEmacs is loaded. This is the purpose of the | |
786 reinit_*() functions throughout XEmacs. [It's possible, however, to make | |
787 pdump restore global data. This must be done, of course, for heap | |
788 pointers, but is also done for other values that are not easy to | |
789 recompute -- in particular, values established by the Lisp code loaded | |
790 at dump time.]) Note that the data type `Lisp_Object' is basically just | |
791 a relocatable pointer disguised as a long, and in general pdump treats | |
792 the Lisp_Object values and pointers to Lisp objects (e.g. Lisp_Object | |
793 vs. `struct frame *') identically. (NOTE: This equivalence depends | |
794 crucially on the current "minimal tagbits" implementation of Lisp_Object | |
795 pointers.) | |
428 | 796 |
1204 | 797 Descriptions are used by pdump in three places: (a) descriptions of Lisp |
798 objects, referenced in the DEFINE_*LRECORD_*IMPLEMENTATION*() call; (b) | |
799 descriptions of global objects to be dumped, registered by | |
800 dump_add_root_block(); (c) descriptions of global pointers to | |
2367 | 801 non-Lisp_Object heap objects, registered by dump_add_root_block_ptr(). |
1204 | 802 The descriptions need to tell pdump which elements of your structure are |
803 Lisp_Objects or structure pointers, plus the descriptions in turn of the | |
804 non-Lisp_Object structures pointed to. If these structures are you own | |
805 private ones, you will have to write these recursive descriptions | |
806 yourself; otherwise, you are reusing a structure already in existence | |
807 elsewhere and there is probably already a description for it. | |
808 | |
809 Pdump does not care about Lisp objects that cannot be dumped (the | |
810 dumpable flag to DEFINE_*LRECORD_*IMPLEMENTATION*() is 0). | |
811 | |
812 KKCC also uses data layout descriptions, but differently. It cares | |
813 about all objects, dumpable or not, but specifically only wants to know | |
814 about Lisp_Objects in your object and in structures pointed to. Thus, | |
815 it doesn't care about things like pointers to structures ot other blocks | |
816 of memory with no Lisp Objects in them, which pdump would care a lot | |
817 about. | |
818 | |
819 Technically, then, you could write your description differently | |
820 depending on whether your object is dumpable -- the full pdump | |
821 description if so, the abbreviated KKCC description if not. In fact, | |
822 some descriptions are written this way. This is dangerous, though, | |
823 because another use might come along for the data descriptions, that | |
824 doesn't care about the dumper flag and makes use of some of the stuff | |
825 normally omitted from the "abbreviated" description -- see above. | |
826 | |
5094 | 827 A memory_description is an array of values. The first value of each |
828 line is a type, the second the offset in the lrecord structure. The | |
829 third and following elements are parameters; their presence, type and | |
830 number is type-dependent. | |
771 | 831 |
1204 | 832 The description ends with an "XD_END" record. |
771 | 833 |
834 The top-level description of an lrecord or lcrecord does not need | |
835 to describe every element, just the ones that need to be relocated, | |
836 since the size of the lrecord is known. (The same goes for nested | |
837 structures, whenever the structure size is given, rather than being | |
838 defaulted by specifying 0 for the size.) | |
839 | |
1204 | 840 A sized_memory_description is a memory_description plus the size of the |
841 block of memory. The size field in a sized_memory_description can be | |
842 given as zero, i.e. unspecified, meaning that the last element in the | |
843 structure is described in the description and the size of the block can | |
844 therefore be computed from it. (This is useful for stretchy arrays.) | |
845 | |
846 memory_descriptions are used to describe lrecords (the size of the | |
847 lrecord is elsewhere in its description, attached to its methods, so it | |
848 does not need to be given here) and global objects, where the size is an | |
849 argument to the call to dump_add_root_block(). | |
850 sized_memory_descriptions are used for pointers and arrays in | |
2367 | 851 memory_descriptions and for calls to dump_add_root_block_ptr(). (#### |
1204 | 852 It is not obvious why this is so in the latter case. Probably, calls to |
2367 | 853 dump_add_root_block_ptr() should use plain memory_descriptions and have |
1204 | 854 the size be an argument to the call.) |
855 | |
856 NOTE: Anywhere that a sized_memory_description occurs inside of a plain | |
857 memory_description, a "description map" can be substituted. Rather than | |
858 being an actual description, this describes how to find the description | |
859 by looking inside of the object being described. This is a convenient | |
860 way to describe Lisp objects with subtypes and corresponding | |
861 type-specific data. | |
428 | 862 |
863 Some example descriptions : | |
440 | 864 |
814 | 865 struct Lisp_String |
866 { | |
867 struct lrecord_header lheader; | |
868 Bytecount size; | |
867 | 869 Ibyte *data; |
814 | 870 Lisp_Object plist; |
871 }; | |
872 | |
1204 | 873 static const struct memory_description cons_description[] = { |
440 | 874 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) }, |
875 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) }, | |
428 | 876 { XD_END } |
877 }; | |
878 | |
440 | 879 Which means "two lisp objects starting at the 'car' and 'cdr' elements" |
428 | 880 |
1204 | 881 static const struct memory_description string_description[] = { |
814 | 882 { XD_BYTECOUNT, offsetof (Lisp_String, size) }, |
1204 | 883 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT (0, 1) }, |
814 | 884 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) }, |
885 { XD_END } | |
886 }; | |
887 | |
888 "A pointer to string data at 'data', the size of the pointed array being | |
889 the value of the size variable plus 1, and one lisp object at 'plist'" | |
890 | |
891 If your object has a pointer to an array of Lisp_Objects in it, something | |
892 like this: | |
893 | |
894 struct Lisp_Foo | |
895 { | |
896 ...; | |
897 int count; | |
898 Lisp_Object *objects; | |
899 ...; | |
900 } | |
901 | |
2367 | 902 You'd use XD_BLOCK_PTR, something like: |
814 | 903 |
1204 | 904 static const struct memory_description foo_description[] = { |
905 ... | |
906 { XD_INT, offsetof (Lisp_Foo, count) }, | |
2367 | 907 { XD_BLOCK_PTR, offsetof (Lisp_Foo, objects), |
2551 | 908 XD_INDIRECT (0, 0), { &lisp_object_description } }, |
1204 | 909 ... |
910 }; | |
911 | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4937
diff
changeset
|
912 lisp_object_description is declared in gc.c, like this: |
1204 | 913 |
914 static const struct memory_description lisp_object_description_1[] = { | |
814 | 915 { XD_LISP_OBJECT, 0 }, |
916 { XD_END } | |
917 }; | |
918 | |
1204 | 919 const struct sized_memory_description lisp_object_description = { |
814 | 920 sizeof (Lisp_Object), |
1204 | 921 lisp_object_description_1 |
814 | 922 }; |
923 | |
2367 | 924 Another example of XD_BLOCK_PTR: |
428 | 925 |
1204 | 926 typedef struct htentry |
814 | 927 { |
928 Lisp_Object key; | |
929 Lisp_Object value; | |
1204 | 930 } htentry; |
814 | 931 |
932 struct Lisp_Hash_Table | |
933 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
934 NORMAL_LISP_OBJECT_HEADER header; |
814 | 935 Elemcount size; |
936 Elemcount count; | |
937 Elemcount rehash_count; | |
938 double rehash_size; | |
939 double rehash_threshold; | |
940 Elemcount golden_ratio; | |
941 hash_table_hash_function_t hash_function; | |
942 hash_table_test_function_t test_function; | |
1204 | 943 htentry *hentries; |
814 | 944 enum hash_table_weakness weakness; |
945 Lisp_Object next_weak; // Used to chain together all of the weak | |
946 // hash tables. Don't mark through this. | |
947 }; | |
948 | |
1204 | 949 static const struct memory_description htentry_description_1[] = { |
950 { XD_LISP_OBJECT, offsetof (htentry, key) }, | |
951 { XD_LISP_OBJECT, offsetof (htentry, value) }, | |
814 | 952 { XD_END } |
953 }; | |
954 | |
1204 | 955 static const struct sized_memory_description htentry_description = { |
956 sizeof (htentry), | |
957 htentry_description_1 | |
814 | 958 }; |
959 | |
1204 | 960 const struct memory_description hash_table_description[] = { |
814 | 961 { XD_ELEMCOUNT, offsetof (Lisp_Hash_Table, size) }, |
2367 | 962 { XD_BLOCK_PTR, offsetof (Lisp_Hash_Table, hentries), XD_INDIRECT (0, 1), |
2551 | 963 { &htentry_description } }, |
814 | 964 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) }, |
965 { XD_END } | |
966 }; | |
967 | |
968 Note that we don't need to declare all the elements in the structure, just | |
969 the ones that need to be relocated (Lisp_Objects and structures) or that | |
970 need to be referenced as counts for relocated objects. | |
971 | |
1204 | 972 A description map looks like this: |
973 | |
974 static const struct sized_memory_description specifier_extra_description_map [] = { | |
975 { offsetof (Lisp_Specifier, methods) }, | |
976 { offsetof (struct specifier_methods, extra_description) }, | |
977 { -1 } | |
978 }; | |
979 | |
980 const struct memory_description specifier_description[] = { | |
981 ... | |
2367 | 982 { XD_BLOCK_ARRAY, offset (Lisp_Specifier, data), 1, |
2551 | 983 { specifier_extra_description_map } }, |
1204 | 984 ... |
985 { XD_END } | |
986 }; | |
987 | |
988 This would be appropriate for an object that looks like this: | |
989 | |
990 struct specifier_methods | |
991 { | |
992 ... | |
993 const struct sized_memory_description *extra_description; | |
994 ... | |
995 }; | |
996 | |
997 struct Lisp_Specifier | |
998 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
999 NORMAL_LISP_OBJECT_HEADER header; |
1204 | 1000 struct specifier_methods *methods; |
1001 | |
1002 ... | |
1003 // type-specific extra data attached to a specifier | |
1004 max_align_t data[1]; | |
1005 }; | |
1006 | |
1007 The description map means "retrieve a pointer into the object at offset | |
1008 `offsetof (Lisp_Specifier, methods)' , then in turn retrieve a pointer | |
1009 into that object at offset `offsetof (struct specifier_methods, | |
1010 extra_description)', and that is the sized_memory_description to use." | |
1011 There can be any number of indirections, which can be either into | |
1012 straight pointers or Lisp_Objects. The way that description maps are | |
1013 distinguished from normal sized_memory_descriptions is that in the | |
1014 former, the memory_description pointer is NULL. | |
1015 | |
1016 --ben | |
1017 | |
814 | 1018 |
1019 The existing types : | |
1020 | |
1021 | |
428 | 1022 XD_LISP_OBJECT |
1204 | 1023 |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1024 A Lisp_Object. This is also the type to use for pointers to other lrecords |
1204 | 1025 (e.g. struct frame *). |
428 | 1026 |
440 | 1027 XD_LISP_OBJECT_ARRAY |
1204 | 1028 |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1029 An array of Lisp_Objects or (equivalently) pointers to lrecords. |
771 | 1030 The parameter (i.e. third element) is the count. This would be declared |
1031 as Lisp_Object foo[666]. For something declared as Lisp_Object *foo, | |
2367 | 1032 use XD_BLOCK_PTR, whose description parameter is a sized_memory_description |
771 | 1033 consisting of only XD_LISP_OBJECT and XD_END. |
440 | 1034 |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1035 XD_INLINE_LISP_OBJECT_BLOCK_PTR |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1036 |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1037 An pointer to a contiguous block of inline Lisp objects -- i.e., the Lisp |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1038 object itself rather than a Lisp_Object pointer is stored in the block. |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1039 This is used only under NEW_GC and is useful for increased efficiency when |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1040 an array of the same kind of object is needed. Examples of the use of this |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1041 type are Lisp dynarrs, where the array elements are inline Lisp objects |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1042 rather than non-Lisp structures, as is normally the case; and hash tables, |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1043 where the key/value pairs are encapsulated as hash-table-entry objects and |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1044 an array of inline hash-table-entry objects is stored. |
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1045 |
428 | 1046 XD_LO_LINK |
1204 | 1047 |
771 | 1048 Weak link in a linked list of objects of the same type. This is a |
1049 link that does NOT generate a GC reference. Thus the pdumper will | |
1050 not automatically add the referenced object to the table of all | |
1051 objects to be dumped, and when storing and loading the dumped data | |
1052 will automatically prune unreferenced objects in the chain and link | |
1053 each referenced object to the next referenced object, even if it's | |
1054 many links away. We also need to special handling of a similar | |
1055 nature for the root of the chain, which will be a staticpro()ed | |
1056 object. | |
432 | 1057 |
428 | 1058 XD_OPAQUE_PTR |
1204 | 1059 |
428 | 1060 Pointer to undumpable data. Must be NULL when dumping. |
1061 | |
2551 | 1062 XD_OPAQUE_PTR_CONVERTIBLE |
1063 | |
1064 Pointer to data which is not directly dumpable but can be converted | |
1065 to a dumpable, opaque external representation. The parameter is | |
1066 a pointer to an opaque_convert_functions struct. | |
1067 | |
1068 XD_OPAQUE_DATA_CONVERTIBLE | |
1069 | |
1070 Data which is not directly dumpable but can be converted to a | |
1071 dumpable, opaque external representation. The parameter is a | |
1072 pointer to an opaque_convert_functions struct. | |
1073 | |
2367 | 1074 XD_BLOCK_PTR |
1204 | 1075 |
771 | 1076 Pointer to block of described memory. (This is misnamed: It is NOT |
1077 necessarily a pointer to a struct foo.) Parameters are number of | |
1204 | 1078 contiguous blocks and sized_memory_description. |
771 | 1079 |
2367 | 1080 XD_BLOCK_ARRAY |
1204 | 1081 |
771 | 1082 Array of blocks of described memory. Parameters are number of |
2367 | 1083 structures and sized_memory_description. This differs from XD_BLOCK_PTR |
771 | 1084 in that the parameter is declared as struct foo[666] instead of |
1085 struct *foo. In other words, the block of memory holding the | |
1086 structures is within the containing structure, rather than being | |
1087 elsewhere, with a pointer in the containing structure. | |
428 | 1088 |
1204 | 1089 NOTE NOTE NOTE: Be sure that you understand the difference between |
2367 | 1090 XD_BLOCK_PTR and XD_BLOCK_ARRAY: |
1204 | 1091 - struct foo bar[666], i.e. 666 inline struct foos |
2367 | 1092 --> XD_BLOCK_ARRAY, argument 666, pointing to a description of |
1204 | 1093 struct foo |
1094 - struct foo *bar, i.e. pointer to a block of 666 struct foos | |
2367 | 1095 --> XD_BLOCK_PTR, argument 666, pointing to a description of |
1204 | 1096 struct foo |
1097 - struct foo *bar[666], i.e. 666 pointers to separate blocks of struct foos | |
2367 | 1098 --> XD_BLOCK_ARRAY, argument 666, pointing to a description of |
1204 | 1099 a single pointer to struct foo; the description is a single |
2367 | 1100 XD_BLOCK_PTR, argument 1, which in turn points to a description |
1204 | 1101 of struct foo. |
1102 | |
2367 | 1103 NOTE also that an XD_BLOCK_PTR of 666 foos is equivalent to an |
1104 XD_BLOCK_PTR of 1 bar, where the description of `bar' is an | |
1105 XD_BLOCK_ARRAY of 666 foos. | |
1106 | |
428 | 1107 XD_OPAQUE_DATA_PTR |
1204 | 1108 |
428 | 1109 Pointer to dumpable opaque data. Parameter is the size of the data. |
1110 Pointed data must be relocatable without changes. | |
1111 | |
771 | 1112 XD_UNION |
1204 | 1113 |
1114 Union of two or more different types of data. Parameters are a constant | |
1115 which determines which type the data is (this is usually an XD_INDIRECT, | |
1116 referring to one of the fields in the structure), and a "sizing lobby" (a | |
1117 sized_memory_description, which points to a memory_description and | |
1118 indicates its size). The size field in the sizing lobby describes the | |
1119 size of the union field in the object, and the memory_description in it | |
1120 is referred to as a "union map" and has a special interpretation: The | |
1121 offset field is replaced by a constant, which is compared to the first | |
1122 parameter of the XD_UNION descriptor to determine if this description | |
1123 applies to the union data, and XD_INDIRECT references refer to the | |
1124 containing object and description. Note that the description applies | |
2367 | 1125 "inline" to the union data, like XD_BLOCK_ARRAY and not XD_BLOCK_PTR. |
1204 | 1126 If the union data is a pointer to different types of structures, each |
2367 | 1127 element in the memory_description should be an XD_BLOCK_PTR. See |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
1128 unicode.c, redisplay.c and fontcolor.c for examples of XD_UNION. |
1204 | 1129 |
1130 XD_UNION_DYNAMIC_SIZE | |
1131 | |
1132 Same as XD_UNION except that this is used for objects where the size of | |
1133 the object containing the union varies depending on the particular value | |
1134 of the union constant. That is, an object with plain XD_UNION typically | |
1135 has the union declared as `union foo' or as `void *', where an object | |
1136 with XD_UNION_DYNAMIC_SIZE typically has the union as the last element, | |
2367 | 1137 and declared as something like Rawbyte foo[1]. With plain XD_UNION, the |
1204 | 1138 object is (usually) of fixed size and always contains enough space for |
1139 the data associated with all possible union constants, and thus the union | |
1140 constant can potentially change during the lifetime of the object. With | |
1141 XD_UNION_DYNAMIC_SIZE, however, the union constant is fixed at the time | |
1142 of creation of the object, and the size of the object is computed | |
1143 dynamically at creation time based on the size of the data associated | |
1144 with the union constant. Currently, the only difference between XD_UNION | |
1145 and XD_UNION_DYNAMIC_SIZE is how the size of the union data is | |
1146 calculated, when (a) the structure containing the union has no size | |
1147 given; (b) the union occurs as the last element in the structure; and (c) | |
1148 the union has no size given (in the first-level sized_memory_description | |
1149 pointed to). In this circumstance, the size of XD_UNION comes from the | |
1150 max size of the data associated with all possible union constants, | |
1151 whereas the size of XD_UNION_DYNAMIC_SIZE comes from the size of the data | |
1152 associated with the currently specified (and unchangeable) union | |
1153 constant. | |
771 | 1154 |
2367 | 1155 XD_ASCII_STRING |
1204 | 1156 |
2367 | 1157 Pointer to a C string, purely ASCII. |
428 | 1158 |
1159 XD_DOC_STRING | |
1204 | 1160 |
2367 | 1161 Pointer to a doc string (C string in pure ASCII if positive, |
1162 opaque value if negative) | |
428 | 1163 |
1164 XD_INT_RESET | |
1204 | 1165 |
428 | 1166 An integer which will be reset to a given value in the dump file. |
1167 | |
1204 | 1168 XD_ELEMCOUNT |
771 | 1169 |
665 | 1170 Elemcount value. Used for counts. |
647 | 1171 |
665 | 1172 XD_BYTECOUNT |
1204 | 1173 |
665 | 1174 Bytecount value. Used for counts. |
647 | 1175 |
665 | 1176 XD_HASHCODE |
1204 | 1177 |
665 | 1178 Hashcode value. Used for the results of hashing functions. |
428 | 1179 |
1180 XD_INT | |
1204 | 1181 |
428 | 1182 int value. Used for counts. |
1183 | |
1184 XD_LONG | |
1204 | 1185 |
428 | 1186 long value. Used for counts. |
1187 | |
771 | 1188 XD_BYTECOUNT |
1204 | 1189 |
771 | 1190 bytecount value. Used for counts. |
1191 | |
428 | 1192 XD_END |
1204 | 1193 |
428 | 1194 Special type indicating the end of the array. |
1195 | |
1196 | |
1197 Special macros: | |
1204 | 1198 |
1199 XD_INDIRECT (line, delta) | |
1200 Usable where a count, size, offset or union constant is requested. Gives | |
1201 the value of the element which is at line number 'line' in the | |
1202 description (count starts at zero) and adds delta to it, which must | |
1203 (currently) be positive. | |
428 | 1204 */ |
1205 | |
1204 | 1206 enum memory_description_type |
647 | 1207 { |
440 | 1208 XD_LISP_OBJECT_ARRAY, |
428 | 1209 XD_LISP_OBJECT, |
3092 | 1210 #ifdef NEW_GC |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1211 XD_INLINE_LISP_OBJECT_BLOCK_PTR, |
3092 | 1212 #endif /* NEW_GC */ |
428 | 1213 XD_LO_LINK, |
1214 XD_OPAQUE_PTR, | |
2551 | 1215 XD_OPAQUE_PTR_CONVERTIBLE, |
1216 XD_OPAQUE_DATA_CONVERTIBLE, | |
1217 XD_OPAQUE_DATA_PTR, | |
2367 | 1218 XD_BLOCK_PTR, |
1219 XD_BLOCK_ARRAY, | |
771 | 1220 XD_UNION, |
1204 | 1221 XD_UNION_DYNAMIC_SIZE, |
2367 | 1222 XD_ASCII_STRING, |
428 | 1223 XD_DOC_STRING, |
1224 XD_INT_RESET, | |
665 | 1225 XD_BYTECOUNT, |
1226 XD_ELEMCOUNT, | |
1227 XD_HASHCODE, | |
428 | 1228 XD_INT, |
1229 XD_LONG, | |
1204 | 1230 XD_END |
428 | 1231 }; |
1232 | |
1204 | 1233 enum data_description_entry_flags |
647 | 1234 { |
1204 | 1235 /* If set, KKCC does not process this entry. |
1236 | |
1237 (1) One obvious use is with things that pdump saves but which do not get | |
1238 marked normally -- for example the next and prev fields in a marker. The | |
1239 marker chain is weak, with its entries removed when they are finalized. | |
1240 | |
1241 (2) This can be set on structures not containing any Lisp objects, or (more | |
1242 usefully) on structures that contain Lisp objects but where the objects | |
1243 always occur in another structure as well. For example, the extent lists | |
1244 kept by a buffer keep the extents in two lists, one sorted by the start | |
1245 of the extent and the other by the end. There's no point in marking | |
1246 both, since each contains the same objects as the other; but when dumping | |
1247 (if we were to dump such a structure), when computing memory size, etc., | |
1248 it's crucial to tag both sides. | |
1249 */ | |
1250 XD_FLAG_NO_KKCC = 1, | |
1251 /* If set, pdump does not process this entry. */ | |
1252 XD_FLAG_NO_PDUMP = 2, | |
1253 /* Indicates that this is a "default" entry in a union map. */ | |
1254 XD_FLAG_UNION_DEFAULT_ENTRY = 4, | |
3263 | 1255 #ifndef NEW_GC |
1204 | 1256 /* Indicates that this is a free Lisp object we're marking. |
1257 Only relevant for ERROR_CHECK_GC. This occurs when we're marking | |
1258 lcrecord-lists, where the objects have had their type changed to | |
1259 lrecord_type_free and also have had their free bit set, but we mark | |
1260 them as normal. */ | |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1261 XD_FLAG_FREE_LISP_OBJECT = 8, |
3263 | 1262 #endif /* not NEW_GC */ |
1204 | 1263 #if 0 |
1264 /* Suggestions for other possible flags: */ | |
1265 | |
1266 /* Eliminate XD_UNION_DYNAMIC_SIZE and replace it with a flag, like this. */ | |
1267 XD_FLAG_UNION_DYNAMIC_SIZE = 16, | |
1268 /* Require that everyone who uses a description map has to flag it, so | |
1269 that it's easy to tell, when looking through the code, where the | |
1270 description maps are and who's using them. This might also become | |
1271 necessary if for some reason the format of the description map is | |
1272 expanded and we need to stick a pointer in the second slot (although | |
1273 we could still ensure that the second slot in the first entry was NULL | |
1274 or <0). */ | |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1275 XD_FLAG_DESCRIPTION_MAP = 32, |
1204 | 1276 #endif |
428 | 1277 }; |
1278 | |
2551 | 1279 union memory_contents_description |
1280 { | |
1281 /* The first element is used by static initializers only. We always read | |
1282 from one of the other two pointers. */ | |
1283 const void *write_only; | |
1284 const struct sized_memory_description *descr; | |
1285 const struct opaque_convert_functions *funcs; | |
1286 }; | |
1287 | |
1204 | 1288 struct memory_description |
1289 { | |
1290 enum memory_description_type type; | |
1291 Bytecount offset; | |
1292 EMACS_INT data1; | |
2551 | 1293 union memory_contents_description data2; |
1204 | 1294 /* Indicates which subsystems process this entry, plus (potentially) other |
1295 flags that apply to this entry. */ | |
1296 int flags; | |
1297 }; | |
428 | 1298 |
1204 | 1299 struct sized_memory_description |
1300 { | |
1301 Bytecount size; | |
1302 const struct memory_description *description; | |
1303 }; | |
1304 | |
2551 | 1305 |
1306 struct opaque_convert_functions | |
1307 { | |
1308 /* Used by XD_OPAQUE_PTR_CONVERTIBLE and | |
1309 XD_OPAQUE_DATA_CONVERTIBLE */ | |
1310 | |
1311 /* Converter to external representation, for those objects from | |
1312 external libraries that can't be directly dumped as opaque data | |
1313 because they contain pointers. This is called at dump time to | |
1314 convert to an opaque, pointer-less representation. | |
1315 | |
1316 This function must put a pointer to the opaque result in *data | |
1317 and its size in *size. */ | |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1318 void (*convert) (const void *object, void **data, Bytecount *size); |
2551 | 1319 |
1320 /* Post-conversion cleanup. Optional (null if not provided). | |
1321 | |
1322 When provided it will be called post-dumping to free any storage | |
1323 allocated for the conversion results. */ | |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1324 void (*convert_free) (const void *object, void *data, Bytecount size); |
2551 | 1325 |
1326 /* De-conversion. | |
1327 | |
1328 At reload time, rebuilds the object from the converted form. | |
1329 "object" is 0 for the PTR case, return is ignored in the DATA | |
1330 case. */ | |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5160
diff
changeset
|
1331 void *(*deconvert) (void *object, void *data, Bytecount size); |
2551 | 1332 |
1333 }; | |
1334 | |
1204 | 1335 extern const struct sized_memory_description lisp_object_description; |
1336 | |
1337 #define XD_INDIRECT(val, delta) (-1 - (Bytecount) ((val) | ((delta) << 8))) | |
428 | 1338 |
1204 | 1339 #define XD_IS_INDIRECT(code) ((code) < 0) |
1340 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255) | |
1341 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8) | |
1342 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1343 /* DEFINE_*_LISP_OBJECT is for objects with constant size. (Either |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1344 DEFINE_DUMPABLE_LISP_OBJECT for objects that can be saved in a dumped |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1345 executable, or DEFINE_NODUMP_LISP_OBJECT for objects that cannot be |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1346 saved -- e.g. that contain pointers to non-persistent external objects |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1347 such as window-system windows.) |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1348 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1349 DEFINE_*_SIZABLE_LISP_OBJECT is for objects whose size varies. |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1350 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1351 DEFINE_*_FROB_BLOCK_LISP_OBJECT is for objects that are allocated in |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1352 large blocks ("frob blocks"), which are parceled up individually. Such |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1353 objects need special handling in alloc.c. This does not apply to |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1354 NEW_GC, because it does this automatically. |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1355 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1356 DEFINE_*_INTERNAL_LISP_OBJECT is for "internal" objects that should |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1357 never be visible on the Lisp level. This is a shorthand for the most |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1358 common type of internal objects, which have no equal or hash method |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1359 (since they generally won't appear in hash tables), no finalizer and |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1360 internal_object_printer() as their print method (which prints that the |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1361 object is internal and shouldn't be visible externally). For internal |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1362 objects needing a finalizer, equal or hash method, or wanting to |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1363 customize the print method, use the normal DEFINE_*_LISP_OBJECT |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
1364 mechanism for defining these objects. |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1365 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1366 DEFINE_MODULE_* is for objects defined in an external module. |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1367 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1368 MAKE_LISP_OBJECT and MAKE_MODULE_LISP_OBJECT are what underlies all of |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1369 these; they define a structure containing pointers to object methods |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1370 and other info such as the size of the structure containing the object. |
428 | 1371 */ |
1372 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1373 /* #### FIXME What's going on here? */ |
800 | 1374 #if defined (ERROR_CHECK_TYPES) |
1375 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype) | |
428 | 1376 #else |
800 | 1377 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype) |
428 | 1378 #endif |
1379 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1380 /********* The dumpable versions *********** */ |
934 | 1381 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1382 #define DEFINE_DUMPABLE_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1383 MAKE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof (structtype),0,0,structtype) |
934 | 1384 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1385 #define DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1386 MAKE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,0,structtype) |
934 | 1387 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1388 #define DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1389 MAKE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof(structtype),0,1,structtype) |
934 | 1390 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1391 #define DEFINE_DUMPABLE_FROB_BLOCK_SIZABLE_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1392 MAKE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,1,structtype) |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1393 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1394 #define DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT(name,c_name,marker,desc,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1395 DEFINE_DUMPABLE_LISP_OBJECT(name,c_name,marker,internal_object_printer,0,0,0,desc,structtype) |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1396 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1397 #define DEFINE_DUMPABLE_SIZABLE_INTERNAL_LISP_OBJECT(name,c_name,marker,desc,sizer,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1398 DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT(name,c_name,marker,internal_object_printer,0,0,0,desc,sizer,structtype) |
934 | 1399 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1400 /********* The non-dumpable versions *********** */ |
934 | 1401 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1402 #define DEFINE_NODUMP_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1403 MAKE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof (structtype),0,0,structtype) |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1404 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1405 #define DEFINE_NODUMP_SIZABLE_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1406 MAKE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,0,structtype) |
934 | 1407 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1408 #define DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1409 MAKE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof(structtype),0,1,structtype) |
934 | 1410 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1411 #define DEFINE_NODUMP_FROB_BLOCK_SIZABLE_LISP_OBJECT(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1412 MAKE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,1,structtype) |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1413 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1414 #define DEFINE_NODUMP_INTERNAL_LISP_OBJECT(name,c_name,marker,desc,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1415 DEFINE_NODUMP_LISP_OBJECT(name,c_name,marker,internal_object_printer,0,0,0,desc,structtype) |
934 | 1416 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1417 #define DEFINE_NODUMP_SIZABLE_INTERNAL_LISP_OBJECT(name,c_name,marker,desc,sizer,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1418 DEFINE_NODUMP_SIZABLE_LISP_OBJECT(name,c_name,marker,internal_object_printer,0,0,0,desc,sizer,structtype) |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1419 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1420 /********* MAKE_LISP_OBJECT, the underlying macro *********** */ |
934 | 1421 |
3263 | 1422 #ifdef NEW_GC |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1423 #define MAKE_LISP_OBJECT(name,c_name,dumpable,marker,printer,nuker, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1424 equal,hash,desc,size,sizer,frob_block_p,structtype) \ |
2720 | 1425 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1426 struct lrecord_implementation lrecord_##c_name = \ |
2720 | 1427 { name, dumpable, marker, printer, nuker, equal, hash, desc, \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1428 size, sizer, lrecord_type_##c_name } |
3263 | 1429 #else /* not NEW_GC */ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1430 #define MAKE_LISP_OBJECT(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,size,sizer,frob_block_p,structtype) \ |
1204 | 1431 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1432 struct lrecord_implementation lrecord_##c_name = \ |
934 | 1433 { name, dumpable, marker, printer, nuker, equal, hash, desc, \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1434 size, sizer, lrecord_type_##c_name, frob_block_p } |
3263 | 1435 #endif /* not NEW_GC */ |
934 | 1436 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1437 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1438 /********* The module dumpable versions *********** */ |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1439 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1440 #define DEFINE_DUMPABLE_MODULE_LISP_OBJECT(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1441 MAKE_MODULE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof (structtype),0,0,structtype) |
934 | 1442 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1443 #define DEFINE_DUMPABLE_MODULE_SIZABLE_LISP_OBJECT(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,sizer,structtype) \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1444 MAKE_MODULE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,0,structtype) |
934 | 1445 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1446 /********* The module non-dumpable versions *********** */ |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1447 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1448 #define DEFINE_NODUMP_MODULE_LISP_OBJECT(name,c_name,dumpable,marker, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1449 printer,nuker,equal,hash,desc,structtype) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1450 MAKE_MODULE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1451 nuker,equal,hash,desc,sizeof (structtype),0,0,structtype) |
934 | 1452 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1453 #define DEFINE_NODUMP_MODULE_SIZABLE_LISP_OBJECT(name,c_name,dumpable, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1454 marker,printer,nuker,equal,hash,desc,sizer,structtype) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1455 MAKE_MODULE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1456 nuker,equal,hash,desc,0,sizer,0,structtype) |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1457 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1458 /********* MAKE_MODULE_LISP_OBJECT, the underlying macro *********** */ |
934 | 1459 |
3263 | 1460 #ifdef NEW_GC |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1461 #define MAKE_MODULE_LISP_OBJECT(name,c_name,dumpable,marker,printer, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1462 nuker,equal,hash,desc,size,sizer,frob_block_p,structtype) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1463 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1464 int lrecord_type_##c_name; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1465 struct lrecord_implementation lrecord_##c_name = \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1466 { name, dumpable, marker, printer, nuker, equal, hash, desc, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1467 size, sizer, lrecord_type_last_built_in_type } |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1468 #else /* not NEW_GC */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1469 #define MAKE_MODULE_LISP_OBJECT(name,c_name,dumpable,marker,printer, \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1470 nuker,equal,hash,desc,size,sizer,frob_block_p,structtype) \ |
2720 | 1471 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \ |
1472 int lrecord_type_##c_name; \ | |
1473 struct lrecord_implementation lrecord_##c_name = \ | |
1474 { name, dumpable, marker, printer, nuker, equal, hash, desc, \ | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1475 size, sizer, lrecord_type_last_built_in_type, frob_block_p } |
3263 | 1476 #endif /* not NEW_GC */ |
934 | 1477 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1478 #ifdef MEMORY_USAGE_STATS |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1479 #define INIT_MEMORY_USAGE_STATS(type) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1480 do \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1481 { \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1482 lrecord_implementations_table[lrecord_type_##type]-> \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1483 memusage_stats_list = Qnil; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1484 lrecord_implementations_table[lrecord_type_##type]-> \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1485 num_extra_memusage_stats = -1; \ |
5158
9e0b43d3095c
more cleanups to object-memory-usage stuff
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1486 lrecord_implementations_table[lrecord_type_##type]-> \ |
9e0b43d3095c
more cleanups to object-memory-usage stuff
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
1487 num_extra_nonlisp_memusage_stats = -1; \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1488 staticpro (&lrecord_implementations_table[lrecord_type_##type]-> \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1489 memusage_stats_list); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1490 } while (0) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1491 #else |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1492 #define INIT_MEMORY_USAGE_STATS(type) DO_NOTHING |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1493 #endif /* (not) MEMORY_USAGE_STATS */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1494 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1495 #define INIT_LISP_OBJECT_BEGINNING(type) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1496 do \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1497 { \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1498 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1499 INIT_MEMORY_USAGE_STATS (type); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1500 } while (0) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1501 |
1676 | 1502 #ifdef USE_KKCC |
1503 extern MODULE_API const struct memory_description *lrecord_memory_descriptions[]; | |
1504 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1505 #define INIT_LISP_OBJECT(type) do { \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1506 INIT_LISP_OBJECT_BEGINNING (type); \ |
1676 | 1507 lrecord_memory_descriptions[lrecord_type_##type] = \ |
1508 lrecord_implementations_table[lrecord_type_##type]->description; \ | |
1509 } while (0) | |
1510 #else /* not USE_KKCC */ | |
1632 | 1511 extern MODULE_API Lisp_Object (*lrecord_markers[]) (Lisp_Object); |
442 | 1512 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1513 #define INIT_LISP_OBJECT(type) do { \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1514 INIT_LISP_OBJECT_BEGINNING (type); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1515 lrecord_markers[lrecord_type_##type] = \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1516 lrecord_implementations_table[lrecord_type_##type]->marker; \ |
442 | 1517 } while (0) |
1676 | 1518 #endif /* not USE_KKCC */ |
428 | 1519 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1520 #define INIT_MODULE_LISP_OBJECT(type) do { \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1521 lrecord_type_##type = lrecord_type_count++; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1522 lrecord_##type.lrecord_type_index = lrecord_type_##type; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1523 INIT_LISP_OBJECT (type); \ |
444 | 1524 } while (0) |
1525 | |
996 | 1526 #ifdef HAVE_SHLIB |
1527 /* Allow undefining types in order to support module unloading. */ | |
1528 | |
1676 | 1529 #ifdef USE_KKCC |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1530 #define UNDEF_LISP_OBJECT(type) do { \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1531 lrecord_implementations_table[lrecord_type_##type] = NULL; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1532 lrecord_memory_descriptions[lrecord_type_##type] = NULL; \ |
1676 | 1533 } while (0) |
1534 #else /* not USE_KKCC */ | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1535 #define UNDEF_LISP_OBJECT(type) do { \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1536 lrecord_implementations_table[lrecord_type_##type] = NULL; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1537 lrecord_markers[lrecord_type_##type] = NULL; \ |
996 | 1538 } while (0) |
1676 | 1539 #endif /* not USE_KKCC */ |
996 | 1540 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1541 #define UNDEF_MODULE_LISP_OBJECT(type) do { \ |
996 | 1542 if (lrecord_##type.lrecord_type_index == lrecord_type_count - 1) { \ |
1543 /* This is the most recently defined type. Clean up nicely. */ \ | |
1544 lrecord_type_##type = lrecord_type_count--; \ | |
1545 } /* Else we can't help leaving a hole with this implementation. */ \ | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1546 UNDEF_LISP_OBJECT(type); \ |
996 | 1547 } while (0) |
1548 | |
1549 #endif /* HAVE_SHLIB */ | |
1550 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1551 /*************** Macros for declaring that a Lisp object has a |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1552 particular method, or for calling such a method. ********/ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1553 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1554 /* Declare that object-type TYPE has method M; used in |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1555 initialization routines */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1556 #define OBJECT_HAS_METHOD(type, m) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1557 (lrecord_##type.m = type##_##m) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1558 /* Same but the method name come before the type */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1559 #define OBJECT_HAS_PREMETHOD(type, m) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1560 (lrecord_##type.m = m##_##type) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1561 /* Same but the name of the method is explicitly given */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1562 #define OBJECT_HAS_NAMED_METHOD(type, m, func) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1563 (lrecord_##type.m = (func)) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1564 /* Object type has a property with the given value. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1565 #define OBJECT_HAS_PROPERTY(type, prop, val) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1566 (lrecord_##type.prop = (val)) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1567 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1568 /* Does the given object method exist? */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1569 #define HAS_OBJECT_METH_P(obj, m) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1570 (!!(XRECORD_LHEADER_IMPLEMENTATION (obj)->m)) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1571 /* Call an object method. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1572 #define OBJECT_METH(obj, m, args) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1573 ((XRECORD_LHEADER_IMPLEMENTATION (obj)->m) args) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1574 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1575 /* Call an object method, if it exists. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1576 #define MAYBE_OBJECT_METH(obj, m, args) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1577 do \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1578 { \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1579 const struct lrecord_implementation *_mom_imp = \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1580 XRECORD_LHEADER_IMPLEMENTATION (obj); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1581 if (_mom_imp->m) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1582 ((_mom_imp->m) args); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1583 } while (0) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1584 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1585 /* Call an object method, if it exists, or return GIVEN. NOTE: |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1586 Multiply-evaluates OBJ. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1587 #define OBJECT_METH_OR_GIVEN(obj, m, args, given) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1588 (HAS_OBJECT_METH_P (obj, m) ? OBJECT_METH (obj, m, args) : (given)) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1589 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1590 #define OBJECT_PROPERTY(obj, prop) (XRECORD_LHEADER_IMPLEMENTATION (obj)->prop) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1591 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1592 /************** Other stuff **************/ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1593 |
428 | 1594 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record) |
1595 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a)) | |
1596 | |
1597 #define RECORD_TYPEP(x, ty) \ | |
647 | 1598 (LRECORDP (x) && (XRECORD_LHEADER (x)->type == (unsigned int) (ty))) |
442 | 1599 |
1600 /* Steps to create a new object: | |
1601 | |
1602 1. Declare the struct for your object in a header file somewhere. | |
1603 Remember that it must begin with | |
1604 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1605 NORMAL_LISP_OBJECT_HEADER header; |
442 | 1606 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1607 2. Put the "standard junk" (DECLARE_LISP_OBJECT()/XFOO/etc.) below the |
617 | 1608 struct definition -- see below. |
442 | 1609 |
1610 3. Add this header file to inline.c. | |
1611 | |
1612 4. Create the methods for your object. Note that technically you don't | |
1613 need any, but you will almost always want at least a mark method. | |
1614 | |
1204 | 1615 4. Create the data layout description for your object. See |
1616 toolbar_button_description below; the comment above in `struct lrecord', | |
1617 describing the purpose of the descriptions; and comments elsewhere in | |
1618 this file describing the exact syntax of the description structures. | |
1619 | |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1620 6. Define your object with DEFINE_*_LISP_OBJECT() or some |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1621 variant. At the minimum, you need to decide whether your object can |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1622 be dumped. Objects that are created as part of the loadup process and |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1623 need to be persistent across dumping should be created dumpable. |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1624 Nondumpable objects are generally those associated with display, |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1625 particularly those containing a pointer to an external library object |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1626 (e.g. a window-system window). |
442 | 1627 |
1204 | 1628 7. Include the header file in the .c file where you defined the object. |
442 | 1629 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1630 8. Put a call to INIT_LISP_OBJECT() for the object in the |
442 | 1631 .c file's syms_of_foo() function. |
1632 | |
1204 | 1633 9. Add a type enum for the object to enum lrecord_type, earlier in this |
442 | 1634 file. |
1635 | |
1204 | 1636 --ben |
1637 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1638 An example: |
428 | 1639 |
442 | 1640 ------------------------------ in toolbar.h ----------------------------- |
1641 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1642 struct toolbar_button |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1643 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1644 NORMAL_LISP_OBJECT_HEADER header; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1645 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1646 Lisp_Object next; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1647 Lisp_Object frame; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1648 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1649 Lisp_Object up_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1650 Lisp_Object down_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1651 Lisp_Object disabled_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1652 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1653 Lisp_Object cap_up_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1654 Lisp_Object cap_down_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1655 Lisp_Object cap_disabled_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1656 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1657 Lisp_Object callback; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1658 Lisp_Object enabled_p; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1659 Lisp_Object help_string; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1660 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1661 char enabled; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1662 char down; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1663 char pushright; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1664 char blank; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1665 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1666 int x, y; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1667 int width, height; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1668 int dirty; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1669 int vertical; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1670 int border_width; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1671 }; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1672 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1673 [[ the standard junk: ]] |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1674 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1675 DECLARE_LISP_OBJECT (toolbar_button, struct toolbar_button); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1676 #define XTOOLBAR_BUTTON(x) XRECORD (x, toolbar_button, struct toolbar_button) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1677 #define wrap_toolbar_button(p) wrap_record (p, toolbar_button) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1678 #define TOOLBAR_BUTTONP(x) RECORDP (x, toolbar_button) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1679 #define CHECK_TOOLBAR_BUTTON(x) CHECK_RECORD (x, toolbar_button) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1680 #define CONCHECK_TOOLBAR_BUTTON(x) CONCHECK_RECORD (x, toolbar_button) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1681 |
442 | 1682 ------------------------------ in toolbar.c ----------------------------- |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1683 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1684 #include "toolbar.h" |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1685 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1686 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1687 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1688 static const struct memory_description toolbar_button_description [] = { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1689 { XD_LISP_OBJECT, offsetof (struct toolbar_button, next) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1690 { XD_LISP_OBJECT, offsetof (struct toolbar_button, frame) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1691 { XD_LISP_OBJECT, offsetof (struct toolbar_button, up_glyph) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1692 { XD_LISP_OBJECT, offsetof (struct toolbar_button, down_glyph) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1693 { XD_LISP_OBJECT, offsetof (struct toolbar_button, disabled_glyph) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1694 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_up_glyph) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1695 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_down_glyph) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1696 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_disabled_glyph) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1697 { XD_LISP_OBJECT, offsetof (struct toolbar_button, callback) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1698 { XD_LISP_OBJECT, offsetof (struct toolbar_button, enabled_p) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1699 { XD_LISP_OBJECT, offsetof (struct toolbar_button, help_string) }, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1700 { XD_END } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1701 }; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1702 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1703 static Lisp_Object |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1704 allocate_toolbar_button (struct frame *f, int pushright) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1705 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1706 struct toolbar_button *tb; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1707 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1708 tb = XTOOLBAR_BUTTON (ALLOC_NORMAL_LISP_OBJECT (toolbar_button)); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1709 tb->next = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1710 tb->frame = wrap_frame (f); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1711 tb->up_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1712 tb->down_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1713 tb->disabled_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1714 tb->cap_up_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1715 tb->cap_down_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1716 tb->cap_disabled_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1717 tb->callback = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1718 tb->enabled_p = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1719 tb->help_string = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1720 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1721 tb->pushright = pushright; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1722 tb->x = tb->y = tb->width = tb->height = -1; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1723 tb->dirty = 1; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1724 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1725 return wrap_toolbar_button (tb); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1726 } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1727 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1728 static Lisp_Object |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1729 mark_toolbar_button (Lisp_Object obj) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1730 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1731 struct toolbar_button *data = XTOOLBAR_BUTTON (obj); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1732 mark_object (data->next); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1733 mark_object (data->frame); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1734 mark_object (data->up_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1735 mark_object (data->down_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1736 mark_object (data->disabled_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1737 mark_object (data->cap_up_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1738 mark_object (data->cap_down_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1739 mark_object (data->cap_disabled_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1740 mark_object (data->callback); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1741 mark_object (data->enabled_p); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1742 return data->help_string; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1743 } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1744 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1745 DEFINE_NODUMP_LISP_OBJECT ("toolbar-button", toolbar_button, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1746 mark_toolbar_button, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1747 external_object_printer, 0, 0, 0, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1748 toolbar_button_description, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1749 struct toolbar_button); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1750 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1751 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1752 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1753 void |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1754 syms_of_toolbar (void) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1755 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1756 INIT_LISP_OBJECT (toolbar_button); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1757 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1758 ...; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1759 } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1760 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1761 ------------------------------ in inline.c ----------------------------- |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1762 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1763 #ifdef HAVE_TOOLBARS |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1764 #include "toolbar.h" |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1765 #endif |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1766 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1767 ------------------------------ in lrecord.h ----------------------------- |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1768 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1769 enum lrecord_type |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1770 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1771 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1772 lrecord_type_toolbar_button, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1773 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1774 }; |
442 | 1775 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1776 ------------------------------ in .gdbinit.in.in ----------------------------- |
442 | 1777 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1778 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1779 else |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1780 if $lrecord_type == lrecord_type_toolbar_button |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1781 pstructtype toolbar_button |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1782 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1783 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1784 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1785 end |
442 | 1786 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1787 --ben |
1204 | 1788 |
442 | 1789 */ |
1790 | |
1791 /* | |
1792 | |
1793 Note: Object types defined in external dynamically-loaded modules (not | |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1794 part of the XEmacs main source code) should use DECLARE_*_MODULE_LISP_OBJECT |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1795 and DEFINE_*_MODULE_LISP_OBJECT rather than DECLARE_*_LISP_OBJECT |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1796 and DEFINE_*_LISP_OBJECT. The MODULE versions declare and |
3029 | 1797 allocate an enumerator for the type being defined. |
442 | 1798 |
1799 */ | |
1800 | |
428 | 1801 |
800 | 1802 #ifdef ERROR_CHECK_TYPES |
428 | 1803 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1804 # define DECLARE_LISP_OBJECT(c_name, structtype) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1805 extern struct lrecord_implementation lrecord_##c_name; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1806 DECLARE_INLINE_HEADER ( \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1807 structtype * \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1808 error_check_##c_name (Lisp_Object obj, const Ascbyte *file, int line) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1809 ) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1810 { \ |
788 | 1811 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1812 return (structtype *) XPNTR (obj); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1813 } \ |
428 | 1814 extern Lisp_Object Q##c_name##p |
1815 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1816 # define DECLARE_MODULE_API_LISP_OBJECT(c_name, structtype) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1817 extern MODULE_API struct lrecord_implementation lrecord_##c_name; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1818 DECLARE_INLINE_HEADER ( \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1819 structtype * \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1820 error_check_##c_name (Lisp_Object obj, const Ascbyte *file, int line) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1821 ) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1822 { \ |
1632 | 1823 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1824 return (structtype *) XPNTR (obj); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1825 } \ |
1632 | 1826 extern MODULE_API Lisp_Object Q##c_name##p |
1827 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1828 # define DECLARE_MODULE_LISP_OBJECT(c_name, structtype) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1829 extern int lrecord_type_##c_name; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1830 extern struct lrecord_implementation lrecord_##c_name; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1831 DECLARE_INLINE_HEADER ( \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1832 structtype * \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1833 error_check_##c_name (Lisp_Object obj, const Ascbyte *file, int line) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1834 ) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1835 { \ |
788 | 1836 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1837 return (structtype *) XPNTR (obj); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1838 } \ |
444 | 1839 extern Lisp_Object Q##c_name##p |
442 | 1840 |
788 | 1841 # define XRECORD(x, c_name, structtype) \ |
1842 error_check_##c_name (x, __FILE__, __LINE__) | |
428 | 1843 |
826 | 1844 DECLARE_INLINE_HEADER ( |
1845 Lisp_Object | |
2367 | 1846 wrap_record_1 (const void *ptr, enum lrecord_type ty, const Ascbyte *file, |
800 | 1847 int line) |
826 | 1848 ) |
617 | 1849 { |
793 | 1850 Lisp_Object obj = wrap_pointer_1 (ptr); |
1851 | |
788 | 1852 assert_at_line (RECORD_TYPEP (obj, ty), file, line); |
617 | 1853 return obj; |
1854 } | |
1855 | |
788 | 1856 #define wrap_record(ptr, ty) \ |
1857 wrap_record_1 (ptr, lrecord_type_##ty, __FILE__, __LINE__) | |
617 | 1858 |
800 | 1859 #else /* not ERROR_CHECK_TYPES */ |
428 | 1860 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1861 # define DECLARE_LISP_OBJECT(c_name, structtype) \ |
428 | 1862 extern Lisp_Object Q##c_name##p; \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1863 extern struct lrecord_implementation lrecord_##c_name |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1864 # define DECLARE_MODULE_API_LISP_OBJECT(c_name, structtype) \ |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1865 extern MODULE_API Lisp_Object Q##c_name##p; \ |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1866 extern MODULE_API struct lrecord_implementation lrecord_##c_name |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1867 # define DECLARE_MODULE_LISP_OBJECT(c_name, structtype) \ |
442 | 1868 extern Lisp_Object Q##c_name##p; \ |
647 | 1869 extern int lrecord_type_##c_name; \ |
444 | 1870 extern struct lrecord_implementation lrecord_##c_name |
428 | 1871 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x)) |
617 | 1872 /* wrap_pointer_1 is so named as a suggestion not to use it unless you |
1873 know what you're doing. */ | |
1874 #define wrap_record(ptr, ty) wrap_pointer_1 (ptr) | |
428 | 1875 |
800 | 1876 #endif /* not ERROR_CHECK_TYPES */ |
428 | 1877 |
442 | 1878 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_type_##c_name) |
428 | 1879 |
1880 /* Note: we now have two different kinds of type-checking macros. | |
1881 The "old" kind has now been renamed CONCHECK_foo. The reason for | |
1882 this is that the CONCHECK_foo macros signal a continuable error, | |
1883 allowing the user (through debug-on-error) to substitute a different | |
1884 value and return from the signal, which causes the lvalue argument | |
1885 to get changed. Quite a lot of code would crash if that happened, | |
1886 because it did things like | |
1887 | |
1888 foo = XCAR (list); | |
1889 CHECK_STRING (foo); | |
1890 | |
1891 and later on did XSTRING (XCAR (list)), assuming that the type | |
1892 is correct (when it might be wrong, if the user substituted a | |
1893 correct value in the debugger). | |
1894 | |
1895 To get around this, I made all the CHECK_foo macros signal a | |
1896 non-continuable error. Places where a continuable error is OK | |
1897 (generally only when called directly on the argument of a Lisp | |
1898 primitive) should be changed to use CONCHECK(). | |
1899 | |
1900 FSF Emacs does not have this problem because RMS took the cheesy | |
1901 way out and disabled returning from a signal entirely. */ | |
1902 | |
1903 #define CONCHECK_RECORD(x, c_name) do { \ | |
442 | 1904 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \ |
428 | 1905 x = wrong_type_argument (Q##c_name##p, x); \ |
1906 } while (0) | |
1907 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\ | |
1908 if (XTYPE (x) != lisp_enum) \ | |
1909 x = wrong_type_argument (predicate, x); \ | |
1910 } while (0) | |
1911 #define CHECK_RECORD(x, c_name) do { \ | |
442 | 1912 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \ |
428 | 1913 dead_wrong_type_argument (Q##c_name##p, x); \ |
1914 } while (0) | |
1915 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \ | |
1916 if (XTYPE (x) != lisp_enum) \ | |
1917 dead_wrong_type_argument (predicate, x); \ | |
1918 } while (0) | |
1919 | |
3263 | 1920 #ifndef NEW_GC |
1204 | 1921 /*-------------------------- lcrecord-list -----------------------------*/ |
1922 | |
1923 struct lcrecord_list | |
1924 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1925 NORMAL_LISP_OBJECT_HEADER header; |
1204 | 1926 Lisp_Object free; |
1927 Elemcount size; | |
1928 const struct lrecord_implementation *implementation; | |
1929 }; | |
1930 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1931 DECLARE_LISP_OBJECT (lcrecord_list, struct lcrecord_list); |
1204 | 1932 #define XLCRECORD_LIST(x) XRECORD (x, lcrecord_list, struct lcrecord_list) |
1933 #define wrap_lcrecord_list(p) wrap_record (p, lcrecord_list) | |
1934 #define LCRECORD_LISTP(x) RECORDP (x, lcrecord_list) | |
1935 /* #define CHECK_LCRECORD_LIST(x) CHECK_RECORD (x, lcrecord_list) | |
1936 Lcrecord lists should never escape to the Lisp level, so | |
1937 functions should not be doing this. */ | |
1938 | |
826 | 1939 /* Various ways of allocating lcrecords. All bytes (except lcrecord |
1204 | 1940 header) are zeroed in returned structure. |
1941 | |
1942 See above for a discussion of the difference between plain lrecords and | |
1943 lrecords. lcrecords themselves are divided into three types: (1) | |
1944 auto-managed, (2) hand-managed, and (3) unmanaged. "Managed" refers to | |
1945 using a special object called an lcrecord-list to keep track of freed | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1946 lcrecords, which can freed with free_normal_lisp_object() or the like |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1947 and later be recycled when a new lcrecord is required, rather than |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1948 requiring new malloc(). Thus, allocation of lcrecords can be very |
1204 | 1949 cheap. (Technically, the lcrecord-list manager could divide up large |
1950 chunks of memory and allocate out of that, mimicking what happens with | |
1951 lrecords. At that point, however, we'd want to rethink the whole | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1952 division between lrecords and lcrecords.) |
1204 | 1953 |
1954 NOTE: There is a fundamental limitation of lcrecord-lists, which is that | |
1955 they only handle blocks of a particular, fixed size. Thus, objects that | |
1956 can be of varying sizes need to do various tricks. These considerations | |
1957 in particular dictate the various types of management: | |
1958 | |
1959 -- "Auto-managed" means that you just go ahead and allocate the lcrecord | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1960 whenever you want, using ALLOC_NORMAL_LISP_OBJECT(), and the appropriate |
1204 | 1961 lcrecord-list manager is automatically created. To free, you just call |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1962 "free_normal_lisp_object()" and the appropriate lcrecord-list manager is |
1204 | 1963 automatically located and called. The limitation here of course is that |
1964 all your objects are of the same size. (#### Eventually we should have a | |
1965 more sophisticated system that tracks the sizes seen and creates one | |
1966 lcrecord list per size, indexed in a hash table. Usually there are only | |
1967 a limited number of sizes, so this works well.) | |
826 | 1968 |
1204 | 1969 -- "Hand-managed" exists because we haven't yet written the more |
1970 sophisticated scheme for auto-handling different-sized lcrecords, as | |
1971 described in the end of the last paragraph. In this model, you go ahead | |
1972 and create the lcrecord-list objects yourself for the sizes you will | |
1973 need, using make_lcrecord_list(). Then, create lcrecords using | |
1974 alloc_managed_lcrecord(), passing in the lcrecord-list you created, and | |
1975 free them with free_managed_lcrecord(). | |
1976 | |
1977 -- "Unmanaged" means you simply allocate lcrecords, period. No | |
1978 lcrecord-lists, no way to free them. This may be suitable when the | |
1979 lcrecords are variable-sized and (a) you're too lazy to write the code | |
1980 to hand-manage them, or (b) the objects you create are always or almost | |
1981 always Lisp-visible, and thus there's no point in freeing them (and it | |
1982 wouldn't be safe to do so). You just create them with | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1983 ALLOC_SIZED_LISP_OBJECT(), and that's it. |
1204 | 1984 |
1985 --ben | |
1986 | |
1987 Here is an in-depth look at the steps required to create a allocate an | |
1988 lcrecord using the hand-managed style. Since this is the most | |
1989 complicated, you will learn a lot about the other styles as well. In | |
1990 addition, there is useful general information about what freeing an | |
1991 lcrecord really entails, and what are the precautions: | |
1992 | |
1993 1) Create an lcrecord-list object using make_lcrecord_list(). This is | |
1994 often done at initialization. Remember to staticpro_nodump() this | |
1995 object! The arguments to make_lcrecord_list() are the same as would be | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1996 passed to ALLOC_SIZED_LISP_OBJECT(). |
428 | 1997 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1998 2) Instead of calling ALLOC_SIZED_LISP_OBJECT(), call |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1999 alloc_managed_lcrecord() and pass the lcrecord-list earlier created. |
1204 | 2000 |
2001 3) When done with the lcrecord, call free_managed_lcrecord(). The | |
2002 standard freeing caveats apply: ** make sure there are no pointers to | |
2003 the object anywhere! ** | |
2004 | |
2005 4) Calling free_managed_lcrecord() is just like kissing the | |
2006 lcrecord goodbye as if it were garbage-collected. This means: | |
2007 -- the contents of the freed lcrecord are undefined, and the | |
2008 contents of something produced by alloc_managed_lcrecord() | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2009 are undefined, just like for ALLOC_SIZED_LISP_OBJECT(). |
1204 | 2010 -- the mark method for the lcrecord's type will *NEVER* be called |
2011 on freed lcrecords. | |
2012 -- the finalize method for the lcrecord's type will be called | |
2013 at the time that free_managed_lcrecord() is called. | |
2014 */ | |
2015 | |
2016 /* UNMANAGED MODEL: */ | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2017 Lisp_Object old_alloc_lcrecord (const struct lrecord_implementation *); |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2018 Lisp_Object old_alloc_sized_lcrecord (Bytecount size, |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2019 const struct lrecord_implementation *); |
1204 | 2020 |
2021 /* HAND-MANAGED MODEL: */ | |
2022 Lisp_Object make_lcrecord_list (Elemcount size, | |
2023 const struct lrecord_implementation | |
2024 *implementation); | |
2025 Lisp_Object alloc_managed_lcrecord (Lisp_Object lcrecord_list); | |
2026 void free_managed_lcrecord (Lisp_Object lcrecord_list, Lisp_Object lcrecord); | |
2027 | |
2028 /* AUTO-MANAGED MODEL: */ | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2029 MODULE_API Lisp_Object |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2030 alloc_automanaged_sized_lcrecord (Bytecount size, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2031 const struct lrecord_implementation *imp); |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2032 MODULE_API Lisp_Object |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2033 alloc_automanaged_lcrecord (const struct lrecord_implementation *imp); |
3017 | 2034 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2035 #define old_alloc_lcrecord_type(type, imp) \ |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2036 ((type *) XPNTR (alloc_automanaged_lcrecord (sizeof (type), imp))) |
2720 | 2037 |
3024 | 2038 void old_free_lcrecord (Lisp_Object rec); |
771 | 2039 |
3263 | 2040 #else /* NEW_GC */ |
2720 | 2041 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2042 MODULE_API Lisp_Object alloc_sized_lrecord (Bytecount size, |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2043 const struct lrecord_implementation *imp); |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2044 Lisp_Object noseeum_alloc_sized_lrecord (Bytecount size, |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2045 const struct lrecord_implementation *imp); |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2046 MODULE_API Lisp_Object alloc_lrecord (const struct lrecord_implementation *imp); |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2047 Lisp_Object noseeum_alloc_lrecord (const struct lrecord_implementation *imp); |
3092 | 2048 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2049 MODULE_API Lisp_Object alloc_lrecord_array (int elemcount, |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2050 const struct lrecord_implementation *imp); |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2051 MODULE_API Lisp_Object alloc_sized_lrecord_array (Bytecount size, |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2052 int elemcount, |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2053 const struct lrecord_implementation *imp); |
2720 | 2054 |
3263 | 2055 #endif /* NEW_GC */ |
3017 | 2056 |
1204 | 2057 DECLARE_INLINE_HEADER ( |
2058 Bytecount | |
2059 detagged_lisp_object_size (const struct lrecord_header *h) | |
2060 ) | |
2061 { | |
2062 const struct lrecord_implementation *imp = LHEADER_IMPLEMENTATION (h); | |
2063 | |
2064 return (imp->size_in_bytes_method ? | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2065 imp->size_in_bytes_method (wrap_pointer_1 (h)) : |
1204 | 2066 imp->static_size); |
2067 } | |
2068 | |
2069 DECLARE_INLINE_HEADER ( | |
2070 Bytecount | |
2071 lisp_object_size (Lisp_Object o) | |
2072 ) | |
2073 { | |
2074 return detagged_lisp_object_size (XRECORD_LHEADER (o)); | |
2075 } | |
2076 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
2077 struct usage_stats; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2078 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2079 MODULE_API void copy_lisp_object (Lisp_Object dst, Lisp_Object src); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2080 MODULE_API void zero_sized_lisp_object (Lisp_Object obj, Bytecount size); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2081 MODULE_API void zero_nonsized_lisp_object (Lisp_Object obj); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2082 Bytecount lisp_object_storage_size (Lisp_Object obj, |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
2083 struct usage_stats *ustats); |
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
2084 Bytecount lisp_object_memory_usage_full (Lisp_Object object, |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
2085 Bytecount *storage_size, |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
2086 Bytecount *extra_nonlisp_storage, |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
2087 Bytecount *extra_lisp_storage, |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
2088 struct generic_usage_stats *stats); |
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
2089 Bytecount lisp_object_memory_usage (Lisp_Object object); |
5179
14fda1dbdb26
add memory usage info for specifiers
Ben Wing <ben@xemacs.org>
parents:
5170
diff
changeset
|
2090 Bytecount tree_memory_usage (Lisp_Object arg, int vectorp); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2091 void free_normal_lisp_object (Lisp_Object obj); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2092 |
1204 | 2093 |
2094 /************************************************************************/ | |
2095 /* Dumping */ | |
2096 /************************************************************************/ | |
2097 | |
2367 | 2098 /* dump_add_root_block_ptr (&var, &desc) dumps the structure pointed to by |
1204 | 2099 `var'. This is for a single relocatable pointer located in the data |
2367 | 2100 segment (i.e. the block pointed to is in the heap). |
2101 | |
2102 If the structure pointed to is not a `struct' but an array, you should | |
2103 set the size field of the sized_memory_description to 0, and use | |
2104 XD_BLOCK_ARRAY in the inner memory_description. | |
2105 | |
2106 NOTE that a "root struct pointer" could also be described using | |
2107 dump_add_root_block(), with SIZE == sizeof (void *), and a description | |
2108 containing a single XD_BLOCK_PTR entry, offset 0, size 1, with a | |
2109 structure description the same as the value passed to | |
2110 dump_add_root_block_ptr(). That would require an extra level of | |
2111 description, though, as compared to using dump_add_root_block_ptr(), | |
2112 and thus this function is generally more convenient. | |
2113 */ | |
1204 | 2114 #ifdef PDUMP |
2367 | 2115 void dump_add_root_block_ptr (void *, const struct sized_memory_description *); |
1204 | 2116 #else |
2367 | 2117 #define dump_add_root_block_ptr(varaddr, descaddr) DO_NOTHING |
1204 | 2118 #endif |
2119 | |
2120 /* dump_add_opaque (&var, size) dumps the opaque static structure `var'. | |
2121 This is for a static block of memory (in the data segment, not the | |
2122 heap), with no relocatable pointers in it. */ | |
2123 #ifdef PDUMP | |
2124 #define dump_add_opaque(varaddr,size) dump_add_root_block (varaddr, size, NULL) | |
2125 #else | |
2126 #define dump_add_opaque(varaddr,size) DO_NOTHING | |
2127 #endif | |
2128 | |
2129 /* dump_add_root_block (ptr, size, desc) dumps the static structure | |
2130 located at `var' of size SIZE and described by DESC. This is for a | |
2131 static block of memory (in the data segment, not the heap), with | |
2132 relocatable pointers in it. */ | |
2133 #ifdef PDUMP | |
2134 void dump_add_root_block (const void *ptraddress, Bytecount size, | |
2135 const struct memory_description *desc); | |
2136 #else | |
2367 | 2137 #define dump_add_root_block(ptraddress, size, desc) DO_NOTHING |
1204 | 2138 #endif |
2139 | |
2140 /* Call dump_add_opaque_int (&int_var) to dump `int_var', of type `int'. */ | |
2141 #ifdef PDUMP | |
2142 #define dump_add_opaque_int(int_varaddr) do { \ | |
2143 int *dao_ = (int_varaddr); /* type check */ \ | |
2144 dump_add_opaque (dao_, sizeof (*dao_)); \ | |
2145 } while (0) | |
2146 #else | |
2147 #define dump_add_opaque_int(int_varaddr) DO_NOTHING | |
2148 #endif | |
2149 | |
2150 /* Call dump_add_opaque_fixnum (&fixnum_var) to dump `fixnum_var', of type | |
2151 `Fixnum'. */ | |
2152 #ifdef PDUMP | |
2153 #define dump_add_opaque_fixnum(fixnum_varaddr) do { \ | |
2154 Fixnum *dao_ = (fixnum_varaddr); /* type check */ \ | |
2155 dump_add_opaque (dao_, sizeof (*dao_)); \ | |
2156 } while (0) | |
2157 #else | |
2158 #define dump_add_opaque_fixnum(fixnum_varaddr) DO_NOTHING | |
2159 #endif | |
2160 | |
2161 /* Call dump_add_root_lisp_object (&var) to ensure that var is properly | |
2162 updated after pdump. */ | |
2163 #ifdef PDUMP | |
2164 void dump_add_root_lisp_object (Lisp_Object *); | |
2165 #else | |
2166 #define dump_add_root_lisp_object(varaddr) DO_NOTHING | |
2167 #endif | |
2168 | |
2169 /* Call dump_add_weak_lisp_object (&var) to ensure that var is properly | |
2170 updated after pdump. var must point to a linked list of objects out of | |
2171 which some may not be dumped */ | |
2172 #ifdef PDUMP | |
2173 void dump_add_weak_object_chain (Lisp_Object *); | |
2174 #else | |
2175 #define dump_add_weak_object_chain(varaddr) DO_NOTHING | |
2176 #endif | |
2177 | |
2178 /* Nonzero means Emacs has already been initialized. | |
2179 Used during startup to detect startup of dumped Emacs. */ | |
1632 | 2180 extern MODULE_API int initialized; |
1204 | 2181 |
2182 #ifdef PDUMP | |
1688 | 2183 #include "dumper.h" |
3263 | 2184 #ifdef NEW_GC |
2720 | 2185 #define DUMPEDP(adr) 0 |
3263 | 2186 #else /* not NEW_GC */ |
2367 | 2187 #define DUMPEDP(adr) ((((Rawbyte *) (adr)) < pdump_end) && \ |
2188 (((Rawbyte *) (adr)) >= pdump_start)) | |
3263 | 2189 #endif /* not NEW_GC */ |
1204 | 2190 #else |
2191 #define DUMPEDP(adr) 0 | |
2192 #endif | |
2193 | |
1330 | 2194 #define OBJECT_DUMPED_P(obj) DUMPEDP (XPNTR (obj)) |
2195 | |
1204 | 2196 /***********************************************************************/ |
2197 /* data descriptions */ | |
2198 /***********************************************************************/ | |
2199 | |
2200 | |
2201 #if defined (USE_KKCC) || defined (PDUMP) | |
2202 | |
2203 extern int in_pdump; | |
2204 | |
2205 EMACS_INT lispdesc_indirect_count_1 (EMACS_INT code, | |
2206 const struct memory_description *idesc, | |
2207 const void *idata); | |
2208 const struct sized_memory_description *lispdesc_indirect_description_1 | |
2209 (const void *obj, const struct sized_memory_description *sdesc); | |
2367 | 2210 Bytecount lispdesc_block_size_1 (const void *obj, Bytecount size, |
2211 const struct memory_description *desc); | |
2212 | |
2213 DECLARE_INLINE_HEADER ( | |
2214 Bytecount lispdesc_block_size (const void *obj, | |
2215 const struct sized_memory_description *sdesc)) | |
2216 { | |
2217 return lispdesc_block_size_1 (obj, sdesc->size, sdesc->description); | |
2218 } | |
1204 | 2219 |
2220 DECLARE_INLINE_HEADER ( | |
2221 EMACS_INT | |
2222 lispdesc_indirect_count (EMACS_INT code, | |
2223 const struct memory_description *idesc, | |
2224 const void *idata) | |
2225 ) | |
2226 { | |
2227 if (XD_IS_INDIRECT (code)) | |
2228 code = lispdesc_indirect_count_1 (code, idesc, idata); | |
2229 return code; | |
2230 } | |
2231 | |
2232 DECLARE_INLINE_HEADER ( | |
2233 const struct sized_memory_description * | |
2234 lispdesc_indirect_description (const void *obj, | |
2235 const struct sized_memory_description *sdesc) | |
2236 ) | |
2237 { | |
2238 if (sdesc->description) | |
2239 return sdesc; | |
2240 else | |
2241 return lispdesc_indirect_description_1 (obj, sdesc); | |
2242 } | |
2243 | |
2244 | |
2245 /* Do standard XD_UNION processing. DESC1 is an entry in DESC, which | |
2246 describes the entire data structure. Returns NULL (do nothing, nothing | |
2247 matched), or a new value for DESC1. In the latter case, assign to DESC1 | |
2248 in your function and goto union_switcheroo. */ | |
2249 | |
2250 DECLARE_INLINE_HEADER ( | |
2251 const struct memory_description * | |
2252 lispdesc_process_xd_union (const struct memory_description *desc1, | |
2253 const struct memory_description *desc, | |
2254 const void *data) | |
2255 ) | |
2256 { | |
2257 int count = 0; | |
2258 EMACS_INT variant = lispdesc_indirect_count (desc1->data1, desc, | |
2259 data); | |
2260 desc1 = | |
2551 | 2261 lispdesc_indirect_description (data, desc1->data2.descr)->description; |
1204 | 2262 |
2263 for (count = 0; desc1[count].type != XD_END; count++) | |
2264 { | |
2265 if ((desc1[count].flags & XD_FLAG_UNION_DEFAULT_ENTRY) || | |
2266 desc1[count].offset == variant) | |
2267 { | |
2268 return &desc1[count]; | |
2269 } | |
2270 } | |
2271 | |
2272 return NULL; | |
2273 } | |
2274 | |
2275 #endif /* defined (USE_KKCC) || defined (PDUMP) */ | |
428 | 2276 |
1743 | 2277 END_C_DECLS |
1650 | 2278 |
440 | 2279 #endif /* INCLUDED_lrecord_h_ */ |