Mercurial > hg > xemacs-beta
annotate src/lrecord.h @ 5157:1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-03-18 Ben Wing <ben@xemacs.org>
* diagnose.el (show-memory-usage):
Rewrite to take into account API changes in memory-usage functions.
src/ChangeLog addition:
2010-03-18 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (disksave_object_finalization_1):
* alloc.c (lisp_object_storage_size):
* alloc.c (listu):
* alloc.c (listn):
* alloc.c (Fobject_memory_usage_stats):
* alloc.c (compute_memusage_stats_length):
* alloc.c (Fobject_memory_usage):
* alloc.c (Ftotal_object_memory_usage):
* alloc.c (malloced_storage_size):
* alloc.c (common_init_alloc_early):
* alloc.c (reinit_alloc_objects_early):
* alloc.c (reinit_alloc_early):
* alloc.c (init_alloc_once_early):
* alloc.c (syms_of_alloc):
* alloc.c (reinit_vars_of_alloc):
* buffer.c:
* buffer.c (struct buffer_stats):
* buffer.c (compute_buffer_text_usage):
* buffer.c (compute_buffer_usage):
* buffer.c (buffer_memory_usage):
* buffer.c (buffer_objects_create):
* buffer.c (syms_of_buffer):
* buffer.c (vars_of_buffer):
* console-impl.h (struct console_methods):
* dynarr.c (Dynarr_memory_usage):
* emacs.c (main_1):
* events.c (clear_event_resource):
* extents.c:
* extents.c (compute_buffer_extent_usage):
* extents.c (extent_objects_create):
* extents.h:
* faces.c:
* faces.c (compute_face_cachel_usage):
* faces.c (face_objects_create):
* faces.h:
* general-slots.h:
* glyphs.c:
* glyphs.c (compute_glyph_cachel_usage):
* glyphs.c (glyph_objects_create):
* glyphs.h:
* lisp.h:
* lisp.h (struct usage_stats):
* lrecord.h:
* lrecord.h (enum lrecord_type):
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE):
* lrecord.h (DEFINE_DUMPABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_SIZABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_FROB_BLOCK_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_SIZABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (MAKE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_MODULE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_MODULE_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_MODULE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_MODULE_SIZABLE_LISP_OBJECT):
* lrecord.h (MAKE_MODULE_LISP_OBJECT):
* lrecord.h (INIT_LISP_OBJECT):
* lrecord.h (INIT_MODULE_LISP_OBJECT):
* lrecord.h (UNDEF_LISP_OBJECT):
* lrecord.h (UNDEF_MODULE_LISP_OBJECT):
* lrecord.h (DECLARE_LISP_OBJECT):
* lrecord.h (DECLARE_MODULE_API_LISP_OBJECT):
* lrecord.h (DECLARE_MODULE_LISP_OBJECT):
* lstream.c:
* lstream.c (syms_of_lstream):
* lstream.c (vars_of_lstream):
* marker.c:
* marker.c (compute_buffer_marker_usage):
* mc-alloc.c (mc_alloced_storage_size):
* mc-alloc.h:
* mule-charset.c:
* mule-charset.c (struct charset_stats):
* mule-charset.c (compute_charset_usage):
* mule-charset.c (charset_memory_usage):
* mule-charset.c (mule_charset_objects_create):
* mule-charset.c (syms_of_mule_charset):
* mule-charset.c (vars_of_mule_charset):
* redisplay.c:
* redisplay.c (compute_rune_dynarr_usage):
* redisplay.c (compute_display_block_dynarr_usage):
* redisplay.c (compute_glyph_block_dynarr_usage):
* redisplay.c (compute_display_line_dynarr_usage):
* redisplay.c (compute_line_start_cache_dynarr_usage):
* redisplay.h:
* scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage):
* scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):
* scrollbar-x.c (x_compute_scrollbar_instance_usage):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h:
* symbols.c:
* symbols.c (reinit_symbol_objects_early):
* symbols.c (init_symbols_once_early):
* symbols.c (reinit_symbols_early):
* symbols.c (defsymbol_massage_name_1):
* symsinit.h:
* ui-gtk.c:
* ui-gtk.c (emacs_gtk_object_getprop):
* ui-gtk.c (emacs_gtk_object_putprop):
* ui-gtk.c (ui_gtk_objects_create):
* unicode.c (compute_from_unicode_table_size_1):
* unicode.c (compute_to_unicode_table_size_1):
* unicode.c (compute_from_unicode_table_size):
* unicode.c (compute_to_unicode_table_size):
* window.c:
* window.c (struct window_stats):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
* window.c (window_memory_usage):
* window.c (window_objects_create):
* window.c (syms_of_window):
* window.c (vars_of_window):
* window.h:
Redo memory-usage mechanism, make it general; add way of dynamically
initializing Lisp object types -- OBJECT_HAS_METHOD(), similar to
CONSOLE_HAS_METHOD().
(1) Create OBJECT_HAS_METHOD(), OBJECT_HAS_PROPERTY() etc. for
specifying that a Lisp object type has a particular method or
property. Call such methods with OBJECT_METH, MAYBE_OBJECT_METH,
OBJECT_METH_OR_GIVEN; retrieve properties with OBJECT_PROPERTY.
Methods that formerly required a DEFINE_*GENERAL_LISP_OBJECT() to
specify them (getprop, putprop, remprop, plist, disksave) now
instead use the dynamic-method mechanism. The main benefit of
this is that new methods or properties can be added without
requiring that the declaration statements of all existing methods
be modified. We have to make the `struct lrecord_implementation'
non-const, but I don't think this should have any effect on speed --
the only possible method that's really speed-critical is the
mark method, and we already extract those out into a separate
(non-const) array for increased cache locality.
Object methods need to be reinitialized after pdump, so we put
them in separate functions such as face_objects_create(),
extent_objects_create() and call them appropriately from emacs.c
The only current object property (`memusage_stats_list') that
objects can specify is a Lisp object and gets staticpro()ed so it
only needs to be set during dump time, but because it references
symbols that might not exist in a syms_of_() function, we
initialize it in vars_of_(). There is also an object property
(`num_extra_memusage_stats') that is automatically initialized based
on `memusage_stats_list'; we do that in reinit_vars_of_alloc(),
which is called after all vars_of_() functions are called.
`disksaver' method was renamed `disksave' to correspond with the
name normally given to the function (e.g. disksave_lstream()).
(2) Generalize the memory-usage mechanism in `buffer-memory-usage',
`window-memory-usage', `charset-memory-usage' into an object-type-
specific mechanism called by a single function
`object-memory-usage'. (Former function `object-memory-usage'
renamed to `total-object-memory-usage'). Generalize the mechanism
of different "slices" so that we can have different "classes" of
memory described and different "slices" onto each class; `t'
separates classes, `nil' separates slices. Currently we have
three classes defined: the memory of an object itself,
non-Lisp-object memory associated with the object (e.g. arrays or
dynarrs stored as fields in the object), and Lisp-object memory
associated with the object (other internal Lisp objects stored in
the object). This isn't completely finished yet and we might need
to further separate the "other internal Lisp objects" class into
two classes.
The memory-usage mechanism uses a `struct usage_stats' (renamed
from `struct overhead_stats') to describe a malloc-view onto a set
of allocated memory (listing how much was requested and various
types of overhead) and a more general `struct generic_usage_stats'
(with a `struct usage_stats' in it) to hold all statistics about
object memory. `struct generic_usage_stats' contains an array of
32 Bytecounts, which are statistics of unspecified semantics. The
intention is that individual types declare a corresponding struct
(e.g. `struct window_stats') with the same structure but with
specific fields in place of the array, corresponding to specific
statistics. The number of such statistics is an object property
computed from the list of tags (Lisp symbols describing the
statistics) stored in `memusage_stats_list'. The idea here is to
allow particular object types to customize the number and
semantics of the statistics where completely avoiding consing.
This doesn't matter so much yet, but the intention is to have the
memory usage of all objects computed at the end of GC, at the same
time as other statistics are currently computed. The values for
all statistics for a single type would be added up to compute
aggregate values for all objects of a specific type. To make this
efficient, we can't allow any memory allocation at all.
(3) Create some additional functions for creating lists that
specify the elements directly as args rather than indirectly through
an array: listn() (number of args given), listu() (list terminated
by Qunbound).
(4) Delete a bit of remaining unused C window_config stuff, also
unused lrecord_type_popup_data.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 18 Mar 2010 10:50:06 -0500 |
parents | 88bd4f3ef8e4 |
children | 9e0b43d3095c |
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 |
3263 | 190 #else /* not NEW_GC */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
191 #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
|
192 #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
|
193 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
|
194 #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
|
195 #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
|
196 #define LISP_OBJECT_FROB_BLOCK_P(obj) (XRECORD_LHEADER_IMPLEMENTATION(obj)->frob_block_p) |
3263 | 197 #endif /* not NEW_GC */ |
3024 | 198 |
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
|
199 #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
|
200 |
1743 | 201 BEGIN_C_DECLS |
1650 | 202 |
428 | 203 struct lrecord_header |
204 { | |
1204 | 205 /* Index into lrecord_implementations_table[]. Objects that have been |
206 explicitly freed using e.g. free_cons() have lrecord_type_free in this | |
207 field. */ | |
442 | 208 unsigned int type :8; |
209 | |
3263 | 210 #ifdef NEW_GC |
2720 | 211 /* 1 if the object is readonly from lisp */ |
212 unsigned int lisp_readonly :1; | |
213 | |
214 /* The `free' field is a flag that indicates whether this lrecord | |
215 is currently free or not. This is used for error checking and | |
216 debugging. */ | |
217 unsigned int free :1; | |
218 | |
3063 | 219 /* The `uid' field is just for debugging/printing convenience. Having |
220 this slot doesn't hurt us spacewise, since the bits are unused | |
221 anyway. (The bits are used for strings, though.) */ | |
2720 | 222 unsigned int uid :22; |
223 | |
3263 | 224 #else /* not NEW_GC */ |
442 | 225 /* If `mark' is 0 after the GC mark phase, the object will be freed |
226 during the GC sweep phase. There are 2 ways that `mark' can be 1: | |
227 - by being referenced from other objects during the GC mark phase | |
228 - because it is permanently on, for c_readonly objects */ | |
229 unsigned int mark :1; | |
230 | |
231 /* 1 if the object resides in logically read-only space, and does not | |
232 reference other non-c_readonly objects. | |
233 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */ | |
234 unsigned int c_readonly :1; | |
235 | |
428 | 236 /* 1 if the object is readonly from lisp */ |
442 | 237 unsigned int lisp_readonly :1; |
771 | 238 |
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
239 /* 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 elsewhere. */ |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
247 unsigned int free :1; |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
248 |
3063 | 249 /* The `uid' field is just for debugging/printing convenience. Having |
250 this slot doesn't hurt us spacewise, since the bits are unused | |
251 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
|
252 unsigned int uid :20; |
934 | 253 |
3263 | 254 #endif /* not NEW_GC */ |
428 | 255 }; |
256 | |
257 struct lrecord_implementation; | |
442 | 258 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
|
259 extern int lrecord_uid_counter[]; |
428 | 260 |
3263 | 261 #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
|
262 #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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 SLI_header->uid = lrecord_uid_counter[(imp)->lrecord_type_index]++; \ |
2720 | 268 } while (0) |
3263 | 269 #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
|
270 #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
|
271 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
|
272 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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 SLI_header->uid = lrecord_uid_counter[(imp)->lrecord_type_index]++; \ |
428 | 278 } while (0) |
3263 | 279 #endif /* not NEW_GC */ |
428 | 280 |
3263 | 281 #ifndef NEW_GC |
3024 | 282 struct old_lcrecord_header |
428 | 283 { |
284 struct lrecord_header lheader; | |
285 | |
442 | 286 /* The `next' field is normally used to chain all lcrecords together |
428 | 287 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
|
288 `old_alloc_sized_lcrecord' threads lcrecords together. |
428 | 289 |
290 The `next' field may be used for other purposes as long as some | |
291 other mechanism is provided for letting the GC do its work. | |
292 | |
293 For example, the event and marker object types allocate members | |
294 out of memory chunks, and are able to find all unmarked members | |
295 by sweeping through the elements of the list of chunks. */ | |
3024 | 296 struct old_lcrecord_header *next; |
428 | 297 }; |
298 | |
299 /* Used for lcrecords in an lcrecord-list. */ | |
300 struct free_lcrecord_header | |
301 { | |
3024 | 302 struct old_lcrecord_header lcheader; |
428 | 303 Lisp_Object chain; |
304 }; | |
3263 | 305 #endif /* not NEW_GC */ |
428 | 306 |
3931 | 307 /* DON'T FORGET to update .gdbinit.in if you change this list. */ |
442 | 308 enum lrecord_type |
309 { | |
310 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast. | |
311 #### This should be replaced by a symbol_value_magic_p flag | |
312 in the Lisp_Symbol lrecord_header. */ | |
2720 | 313 lrecord_type_symbol_value_forward, /* 0 */ |
3092 | 314 lrecord_type_symbol_value_varalias, |
315 lrecord_type_symbol_value_lisp_magic, | |
316 lrecord_type_symbol_value_buffer_local, | |
442 | 317 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local, |
3092 | 318 lrecord_type_symbol, |
319 lrecord_type_subr, | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3931
diff
changeset
|
320 lrecord_type_multiple_value, |
3092 | 321 lrecord_type_cons, |
322 lrecord_type_vector, | |
323 lrecord_type_string, | |
3263 | 324 #ifndef NEW_GC |
442 | 325 lrecord_type_lcrecord_list, |
3263 | 326 #endif /* not NEW_GC */ |
3092 | 327 lrecord_type_compiled_function, |
328 lrecord_type_weak_list, | |
329 lrecord_type_bit_vector, | |
330 lrecord_type_float, | |
331 lrecord_type_hash_table, | |
332 lrecord_type_lstream, | |
333 lrecord_type_process, | |
334 lrecord_type_charset, | |
335 lrecord_type_coding_system, | |
336 lrecord_type_char_table, | |
337 lrecord_type_char_table_entry, | |
338 lrecord_type_range_table, | |
339 lrecord_type_opaque, | |
340 lrecord_type_opaque_ptr, | |
341 lrecord_type_buffer, | |
342 lrecord_type_extent, | |
343 lrecord_type_extent_info, | |
344 lrecord_type_extent_auxiliary, | |
345 lrecord_type_marker, | |
346 lrecord_type_event, | |
2720 | 347 #ifdef EVENT_DATA_AS_OBJECTS /* not defined */ |
934 | 348 lrecord_type_key_data, |
349 lrecord_type_button_data, | |
350 lrecord_type_motion_data, | |
351 lrecord_type_process_data, | |
352 lrecord_type_timeout_data, | |
353 lrecord_type_eval_data, | |
354 lrecord_type_misc_user_data, | |
355 lrecord_type_magic_eval_data, | |
356 lrecord_type_magic_data, | |
1204 | 357 #endif /* EVENT_DATA_AS_OBJECTS */ |
3092 | 358 lrecord_type_keymap, |
359 lrecord_type_command_builder, | |
360 lrecord_type_timeout, | |
361 lrecord_type_specifier, | |
362 lrecord_type_console, | |
363 lrecord_type_device, | |
364 lrecord_type_frame, | |
365 lrecord_type_window, | |
366 lrecord_type_window_mirror, | |
367 lrecord_type_gui_item, | |
368 lrecord_type_toolbar_button, | |
369 lrecord_type_scrollbar_instance, | |
370 lrecord_type_color_instance, | |
371 lrecord_type_font_instance, | |
372 lrecord_type_image_instance, | |
373 lrecord_type_glyph, | |
374 lrecord_type_face, | |
3931 | 375 lrecord_type_fc_config, |
3094 | 376 lrecord_type_fc_pattern, |
3092 | 377 lrecord_type_database, |
378 lrecord_type_tooltalk_message, | |
379 lrecord_type_tooltalk_pattern, | |
380 lrecord_type_ldap, | |
381 lrecord_type_pgconn, | |
382 lrecord_type_pgresult, | |
383 lrecord_type_devmode, | |
384 lrecord_type_mswindows_dialog_id, | |
385 lrecord_type_case_table, | |
386 lrecord_type_emacs_ffi, | |
387 lrecord_type_emacs_gtk_object, | |
388 lrecord_type_emacs_gtk_boxed, | |
389 lrecord_type_weak_box, | |
390 lrecord_type_ephemeron, | |
391 lrecord_type_bignum, | |
392 lrecord_type_ratio, | |
393 lrecord_type_bigfloat, | |
3263 | 394 #ifndef NEW_GC |
454 | 395 lrecord_type_free, /* only used for "free" lrecords */ |
396 lrecord_type_undefined, /* only used for debugging */ | |
3263 | 397 #endif /* not NEW_GC */ |
3092 | 398 #ifdef NEW_GC |
4930
9f04877ce07e
fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents:
4844
diff
changeset
|
399 /* See comment up top explaining why these extra object types must exist. */ |
3092 | 400 lrecord_type_string_indirect_data, |
401 lrecord_type_string_direct_data, | |
402 lrecord_type_hash_table_entry, | |
403 lrecord_type_syntax_cache, | |
404 lrecord_type_buffer_text, | |
405 lrecord_type_compiled_function_args, | |
406 lrecord_type_tty_console, | |
407 lrecord_type_stream_console, | |
408 lrecord_type_dynarr, | |
409 lrecord_type_face_cachel, | |
410 lrecord_type_face_cachel_dynarr, | |
411 lrecord_type_glyph_cachel, | |
412 lrecord_type_glyph_cachel_dynarr, | |
413 lrecord_type_x_device, | |
414 lrecord_type_gtk_device, | |
415 lrecord_type_tty_device, | |
416 lrecord_type_mswindows_device, | |
417 lrecord_type_msprinter_device, | |
418 lrecord_type_x_frame, | |
419 lrecord_type_gtk_frame, | |
420 lrecord_type_mswindows_frame, | |
421 lrecord_type_gap_array_marker, | |
422 lrecord_type_gap_array, | |
423 lrecord_type_extent_list_marker, | |
424 lrecord_type_extent_list, | |
425 lrecord_type_stack_of_extents, | |
426 lrecord_type_tty_color_instance_data, | |
427 lrecord_type_tty_font_instance_data, | |
428 lrecord_type_specifier_caching, | |
429 lrecord_type_expose_ignore, | |
430 #endif /* NEW_GC */ | |
431 lrecord_type_last_built_in_type /* must be last */ | |
442 | 432 }; |
433 | |
1632 | 434 extern MODULE_API int lrecord_type_count; |
428 | 435 |
436 struct lrecord_implementation | |
437 { | |
2367 | 438 const Ascbyte *name; |
442 | 439 |
934 | 440 /* information for the dumper: is the object dumpable and should it |
441 be dumped. */ | |
442 unsigned int dumpable :1; | |
443 | |
442 | 444 /* `marker' is called at GC time, to make sure that all Lisp_Objects |
428 | 445 pointed to by this object get properly marked. It should call |
446 the mark_object function on all Lisp_Objects in the object. If | |
447 the return value is non-nil, it should be a Lisp_Object to be | |
448 marked (don't call the mark_object function explicitly on it, | |
449 because the GC routines will do this). Doing it this way reduces | |
450 recursion, so the object returned should preferably be the one | |
451 with the deepest level of Lisp_Object pointers. This function | |
1204 | 452 can be NULL, meaning no GC marking is necessary. |
453 | |
454 NOTE NOTE NOTE: This is not used by KKCC (which uses the data | |
455 description below instead), unless the data description is missing. | |
456 Yes, this currently means there is logic duplication. Eventually the | |
457 mark methods will be removed. */ | |
428 | 458 Lisp_Object (*marker) (Lisp_Object); |
442 | 459 |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
460 /* `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
|
461 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
|
462 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
|
463 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
|
464 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
|
465 external_object_printer() (for objects visible at Lisp level). */ |
428 | 466 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag); |
442 | 467 |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
468 /* `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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 void (*finalizer) (Lisp_Object obj); |
442 | 474 |
428 | 475 /* 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
|
476 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
|
477 int foldcase); |
442 | 478 |
479 /* `hash' generates hash values for use with hash tables that have | |
480 `equal' as their test function. This can be NULL, meaning use | |
481 the Lisp_Object itself as the hash. But, you must still satisfy | |
482 the constraint that if two objects are `equal', then they *must* | |
483 hash to the same value in order for hash tables to work properly. | |
484 This means that `hash' can be NULL only if the `equal' method is | |
485 also NULL. */ | |
2515 | 486 Hashcode (*hash) (Lisp_Object, int); |
428 | 487 |
1204 | 488 /* Data layout description for your object. See long comment below. */ |
489 const struct memory_description *description; | |
428 | 490 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
491 /* 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
|
492 `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
|
493 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
|
494 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
|
495 try.*/ |
665 | 496 Bytecount static_size; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
497 Bytecount (*size_in_bytes_method) (Lisp_Object); |
442 | 498 |
499 /* The (constant) index into lrecord_implementations_table */ | |
500 enum lrecord_type lrecord_type_index; | |
501 | |
3263 | 502 #ifndef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
503 /* A "frob-block" lrecord is any lrecord that's not an lcrecord, i.e. |
3024 | 504 one that does not have an old_lcrecord_header at the front and which |
1204 | 505 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
|
506 unsigned int frob_block_p :1; |
3263 | 507 #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
|
508 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
509 /**********************************************************************/ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
510 /* Remaining stuff is not assignable statically using |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
511 DEFINE_*_LISP_OBJECT, but must be assigned with OBJECT_HAS_METHOD |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
512 or the like. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
513 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
514 /* 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
|
515 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
|
516 `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
|
517 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
|
518 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
|
519 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
|
520 Lisp_Object (*plist) (Lisp_Object obj); |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
521 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
522 /* `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
|
523 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
|
524 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
|
525 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
|
526 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
|
527 on. |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
528 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
529 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
|
530 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
|
531 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
|
532 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
533 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
|
534 be NULL. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
535 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
|
536 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
537 #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
|
538 /* Return memory-usage information about the object in question, stored |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
539 into STATS. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
540 void (*memory_usage) (Lisp_Object obj, struct generic_usage_stats *stats); |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
541 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
542 /* Number of additional type-specific statistics related to memory usage. |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
543 Automatically calculated (see compute_memusage_stats_length()) based |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
544 on the value placed in `memusage_stats_list'. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
545 Elemcount num_extra_memusage_stats; |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
546 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
547 /* 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
|
548 Qnil or Qt can be present to separate off different slices. Qnil |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
549 separates different slices within the same type of statistics. |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
550 Qt separates slices corresponding to different types of statistics. |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
551 If Qt is not present, all slices describe extra non-Lisp-Object memory |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
552 associated with a Lisp object. If Qt is present, slices after Qt |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
553 describe non-Lisp-Object memory and slices before Qt describe |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
554 Lisp-Object memory logically associated with the object. For example, |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
555 if the object is a table, then Lisp-Object memory might be the entries |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
556 in the table. This info is only advisory since it will duplicate |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
557 memory described elsewhere and since it may not be possible to be |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
558 completely accurate if the same object occurs multiple times in the |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
559 table. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
560 Lisp_Object memusage_stats_list; |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
561 #endif /* MEMORY_USAGE_STATS */ |
428 | 562 }; |
563 | |
617 | 564 /* All the built-in lisp object types are enumerated in `enum lrecord_type'. |
442 | 565 Additional ones may be defined by a module (none yet). We leave some |
566 room in `lrecord_implementations_table' for such new lisp object types. */ | |
567 #define MODULE_DEFINABLE_TYPE_COUNT 32 | |
568 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
569 extern MODULE_API struct lrecord_implementation * |
1632 | 570 lrecord_implementations_table[lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT]; |
428 | 571 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
572 /* 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
|
573 (struct lrecord_implementation) */ |
428 | 574 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \ |
442 | 575 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj)) |
576 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type] | |
428 | 577 |
3092 | 578 #include "gc.h" |
579 | |
580 #ifdef NEW_GC | |
581 #include "vdb.h" | |
582 #endif /* NEW_GC */ | |
583 | |
428 | 584 extern int gc_in_progress; |
585 | |
3263 | 586 #ifdef NEW_GC |
2720 | 587 #include "mc-alloc.h" |
588 | |
2994 | 589 #ifdef ALLOC_TYPE_STATS |
2720 | 590 void init_lrecord_stats (void); |
591 void inc_lrecord_stats (Bytecount size, const struct lrecord_header *h); | |
592 void dec_lrecord_stats (Bytecount size_including_overhead, | |
593 const struct lrecord_header *h); | |
3092 | 594 int lrecord_stats_heap_size (void); |
2994 | 595 #endif /* ALLOC_TYPE_STATS */ |
2720 | 596 |
597 /* Tell mc-alloc how to call a finalizer. */ | |
3092 | 598 #define MC_ALLOC_CALL_FINALIZER(ptr) \ |
599 { \ | |
600 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ | |
601 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \ | |
602 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \ | |
603 && !LRECORD_FREE_P (MCACF_lheader) ) \ | |
604 { \ | |
605 const struct lrecord_implementation *MCACF_implementation \ | |
606 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ | |
607 if (MCACF_implementation && MCACF_implementation->finalizer) \ | |
608 { \ | |
609 GC_STAT_FINALIZED; \ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
610 MCACF_implementation->finalizer (MCACF_obj); \ |
3092 | 611 } \ |
612 } \ | |
613 } while (0) | |
2720 | 614 |
615 /* Tell mc-alloc how to call a finalizer for disksave. */ | |
616 #define MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE(ptr) \ | |
617 { \ | |
618 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ | |
619 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \ | |
620 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \ | |
621 && !LRECORD_FREE_P (MCACF_lheader) ) \ | |
622 { \ | |
623 const struct lrecord_implementation *MCACF_implementation \ | |
624 = 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
|
625 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
|
626 MCACF_implementation->disksave (MCACF_obj); \ |
2720 | 627 } \ |
628 } while (0) | |
629 | |
630 #define LRECORD_FREE_P(ptr) \ | |
631 (((struct lrecord_header *) ptr)->free) | |
632 | |
633 #define MARK_LRECORD_AS_FREE(ptr) \ | |
634 ((void) (((struct lrecord_header *) ptr)->free = 1)) | |
635 | |
636 #define MARK_LRECORD_AS_NOT_FREE(ptr) \ | |
637 ((void) (((struct lrecord_header *) ptr)->free = 0)) | |
638 | |
639 #define MARKED_RECORD_P(obj) MARKED_P (obj) | |
640 #define MARKED_RECORD_HEADER_P(lheader) MARKED_P (lheader) | |
641 #define MARK_RECORD_HEADER(lheader) MARK (lheader) | |
642 #define UNMARK_RECORD_HEADER(lheader) UNMARK (lheader) | |
643 | |
644 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly) | |
645 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \ | |
646 ((void) ((lheader)->lisp_readonly = 1)) | |
647 #define MARK_LRECORD_AS_LISP_READONLY(ptr) \ | |
648 ((void) (((struct lrecord_header *) ptr)->lisp_readonly = 1)) | |
649 | |
3263 | 650 #else /* not NEW_GC */ |
2720 | 651 |
5059
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
652 enum lrecord_alloc_status |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
653 { |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
654 ALLOC_IN_USE, |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
655 ALLOC_FREE, |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
656 ALLOC_ON_FREE_LIST |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
657 }; |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
658 |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
659 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
|
660 enum lrecord_alloc_status status); |
c8f90d61dcf3
fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
661 |
2720 | 662 #define LRECORD_FREE_P(ptr) \ |
663 (((struct lrecord_header *) ptr)->type == lrecord_type_free) | |
664 | |
665 #define MARK_LRECORD_AS_FREE(ptr) \ | |
666 ((void) (((struct lrecord_header *) ptr)->type = lrecord_type_free)) | |
667 | |
442 | 668 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark) |
428 | 669 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark) |
670 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1)) | |
671 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0)) | |
672 | |
673 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly) | |
674 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly) | |
442 | 675 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \ |
676 struct lrecord_header *SCRRH_lheader = (lheader); \ | |
677 SCRRH_lheader->c_readonly = 1; \ | |
678 SCRRH_lheader->lisp_readonly = 1; \ | |
679 SCRRH_lheader->mark = 1; \ | |
680 } while (0) | |
428 | 681 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \ |
682 ((void) ((lheader)->lisp_readonly = 1)) | |
3263 | 683 #endif /* not NEW_GC */ |
1676 | 684 |
685 #ifdef USE_KKCC | |
686 #define RECORD_DESCRIPTION(lheader) lrecord_memory_descriptions[(lheader)->type] | |
687 #else /* not USE_KKCC */ | |
442 | 688 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type] |
1676 | 689 #endif /* not USE_KKCC */ |
428 | 690 |
934 | 691 #define RECORD_DUMPABLE(lheader) (lrecord_implementations_table[(lheader)->type])->dumpable |
1204 | 692 |
693 /* Data description stuff | |
934 | 694 |
1204 | 695 Data layout descriptions describe blocks of memory (in particular, Lisp |
696 objects and other objects on the heap, and global objects with pointers | |
697 to such heap objects), including their size and a list of the elements | |
698 that need relocating, marking or other special handling. They are | |
699 currently used in two places: by pdump [the new, portable dumper] and | |
700 KKCC [the new garbage collector]. The two subsystems use the | |
701 descriptions in different ways, and as a result some of the descriptions | |
702 are appropriate only for one or the other, when it is known that only | |
703 that subsystem will use the description. (This is particularly the case | |
704 with objects that can't be dumped, because pdump needs more info than | |
705 KKCC.) However, properly written descriptions are appropriate for both, | |
706 and you should strive to write your descriptions that way, since the | |
707 dumpable status of an object may change and new uses for the | |
708 descriptions may be created. (An example that comes to mind is a | |
709 facility for determining the memory usage of XEmacs data structures -- | |
710 like `buffer-memory-usage', `window-memory-usage', etc. but more | |
711 general.) | |
712 | |
713 More specifically: | |
428 | 714 |
1204 | 715 Pdump (the portable dumper) needs to write out all objects in heap |
716 space, and later on (in another invocation of XEmacs) load them back | |
717 into the heap, relocating all pointers to the heap objects in the global | |
718 data space. ("Heap" means anything malloc()ed, including all Lisp | |
719 objects, and "global data" means anything declared globally or | |
720 `static'.) Pdump, then, needs to be told about the location of all | |
721 global pointers to heap objects, all the description of all such | |
722 objects, including their size and any pointers to other heap (aka | |
723 "relocatable") objects. (Pdump assumes that the heap may occur in | |
724 different places in different invocations -- therefore, it is not enough | |
725 simply to write out the entire heap and later reload it at the same | |
726 location -- but that global data is always in the same place, and hence | |
727 pointers to it do not need to be relocated. This assumption holds true | |
728 in general for modern operating systems, but would be broken, for | |
729 example, in a system without virtual memory, or when dealing with shared | |
730 libraries. Also, unlike unexec, pdump does not usually write out or | |
731 restore objects in the global data space, and thus they need to be | |
732 initialized every time XEmacs is loaded. This is the purpose of the | |
733 reinit_*() functions throughout XEmacs. [It's possible, however, to make | |
734 pdump restore global data. This must be done, of course, for heap | |
735 pointers, but is also done for other values that are not easy to | |
736 recompute -- in particular, values established by the Lisp code loaded | |
737 at dump time.]) Note that the data type `Lisp_Object' is basically just | |
738 a relocatable pointer disguised as a long, and in general pdump treats | |
739 the Lisp_Object values and pointers to Lisp objects (e.g. Lisp_Object | |
740 vs. `struct frame *') identically. (NOTE: This equivalence depends | |
741 crucially on the current "minimal tagbits" implementation of Lisp_Object | |
742 pointers.) | |
428 | 743 |
1204 | 744 Descriptions are used by pdump in three places: (a) descriptions of Lisp |
745 objects, referenced in the DEFINE_*LRECORD_*IMPLEMENTATION*() call; (b) | |
746 descriptions of global objects to be dumped, registered by | |
747 dump_add_root_block(); (c) descriptions of global pointers to | |
2367 | 748 non-Lisp_Object heap objects, registered by dump_add_root_block_ptr(). |
1204 | 749 The descriptions need to tell pdump which elements of your structure are |
750 Lisp_Objects or structure pointers, plus the descriptions in turn of the | |
751 non-Lisp_Object structures pointed to. If these structures are you own | |
752 private ones, you will have to write these recursive descriptions | |
753 yourself; otherwise, you are reusing a structure already in existence | |
754 elsewhere and there is probably already a description for it. | |
755 | |
756 Pdump does not care about Lisp objects that cannot be dumped (the | |
757 dumpable flag to DEFINE_*LRECORD_*IMPLEMENTATION*() is 0). | |
758 | |
759 KKCC also uses data layout descriptions, but differently. It cares | |
760 about all objects, dumpable or not, but specifically only wants to know | |
761 about Lisp_Objects in your object and in structures pointed to. Thus, | |
762 it doesn't care about things like pointers to structures ot other blocks | |
763 of memory with no Lisp Objects in them, which pdump would care a lot | |
764 about. | |
765 | |
766 Technically, then, you could write your description differently | |
767 depending on whether your object is dumpable -- the full pdump | |
768 description if so, the abbreviated KKCC description if not. In fact, | |
769 some descriptions are written this way. This is dangerous, though, | |
770 because another use might come along for the data descriptions, that | |
771 doesn't care about the dumper flag and makes use of some of the stuff | |
772 normally omitted from the "abbreviated" description -- see above. | |
773 | |
5094 | 774 A memory_description is an array of values. The first value of each |
775 line is a type, the second the offset in the lrecord structure. The | |
776 third and following elements are parameters; their presence, type and | |
777 number is type-dependent. | |
771 | 778 |
1204 | 779 The description ends with an "XD_END" record. |
771 | 780 |
781 The top-level description of an lrecord or lcrecord does not need | |
782 to describe every element, just the ones that need to be relocated, | |
783 since the size of the lrecord is known. (The same goes for nested | |
784 structures, whenever the structure size is given, rather than being | |
785 defaulted by specifying 0 for the size.) | |
786 | |
1204 | 787 A sized_memory_description is a memory_description plus the size of the |
788 block of memory. The size field in a sized_memory_description can be | |
789 given as zero, i.e. unspecified, meaning that the last element in the | |
790 structure is described in the description and the size of the block can | |
791 therefore be computed from it. (This is useful for stretchy arrays.) | |
792 | |
793 memory_descriptions are used to describe lrecords (the size of the | |
794 lrecord is elsewhere in its description, attached to its methods, so it | |
795 does not need to be given here) and global objects, where the size is an | |
796 argument to the call to dump_add_root_block(). | |
797 sized_memory_descriptions are used for pointers and arrays in | |
2367 | 798 memory_descriptions and for calls to dump_add_root_block_ptr(). (#### |
1204 | 799 It is not obvious why this is so in the latter case. Probably, calls to |
2367 | 800 dump_add_root_block_ptr() should use plain memory_descriptions and have |
1204 | 801 the size be an argument to the call.) |
802 | |
803 NOTE: Anywhere that a sized_memory_description occurs inside of a plain | |
804 memory_description, a "description map" can be substituted. Rather than | |
805 being an actual description, this describes how to find the description | |
806 by looking inside of the object being described. This is a convenient | |
807 way to describe Lisp objects with subtypes and corresponding | |
808 type-specific data. | |
428 | 809 |
810 Some example descriptions : | |
440 | 811 |
814 | 812 struct Lisp_String |
813 { | |
814 struct lrecord_header lheader; | |
815 Bytecount size; | |
867 | 816 Ibyte *data; |
814 | 817 Lisp_Object plist; |
818 }; | |
819 | |
1204 | 820 static const struct memory_description cons_description[] = { |
440 | 821 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) }, |
822 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) }, | |
428 | 823 { XD_END } |
824 }; | |
825 | |
440 | 826 Which means "two lisp objects starting at the 'car' and 'cdr' elements" |
428 | 827 |
1204 | 828 static const struct memory_description string_description[] = { |
814 | 829 { XD_BYTECOUNT, offsetof (Lisp_String, size) }, |
1204 | 830 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT (0, 1) }, |
814 | 831 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) }, |
832 { XD_END } | |
833 }; | |
834 | |
835 "A pointer to string data at 'data', the size of the pointed array being | |
836 the value of the size variable plus 1, and one lisp object at 'plist'" | |
837 | |
838 If your object has a pointer to an array of Lisp_Objects in it, something | |
839 like this: | |
840 | |
841 struct Lisp_Foo | |
842 { | |
843 ...; | |
844 int count; | |
845 Lisp_Object *objects; | |
846 ...; | |
847 } | |
848 | |
2367 | 849 You'd use XD_BLOCK_PTR, something like: |
814 | 850 |
1204 | 851 static const struct memory_description foo_description[] = { |
852 ... | |
853 { XD_INT, offsetof (Lisp_Foo, count) }, | |
2367 | 854 { XD_BLOCK_PTR, offsetof (Lisp_Foo, objects), |
2551 | 855 XD_INDIRECT (0, 0), { &lisp_object_description } }, |
1204 | 856 ... |
857 }; | |
858 | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4937
diff
changeset
|
859 lisp_object_description is declared in gc.c, like this: |
1204 | 860 |
861 static const struct memory_description lisp_object_description_1[] = { | |
814 | 862 { XD_LISP_OBJECT, 0 }, |
863 { XD_END } | |
864 }; | |
865 | |
1204 | 866 const struct sized_memory_description lisp_object_description = { |
814 | 867 sizeof (Lisp_Object), |
1204 | 868 lisp_object_description_1 |
814 | 869 }; |
870 | |
2367 | 871 Another example of XD_BLOCK_PTR: |
428 | 872 |
1204 | 873 typedef struct htentry |
814 | 874 { |
875 Lisp_Object key; | |
876 Lisp_Object value; | |
1204 | 877 } htentry; |
814 | 878 |
879 struct Lisp_Hash_Table | |
880 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
881 NORMAL_LISP_OBJECT_HEADER header; |
814 | 882 Elemcount size; |
883 Elemcount count; | |
884 Elemcount rehash_count; | |
885 double rehash_size; | |
886 double rehash_threshold; | |
887 Elemcount golden_ratio; | |
888 hash_table_hash_function_t hash_function; | |
889 hash_table_test_function_t test_function; | |
1204 | 890 htentry *hentries; |
814 | 891 enum hash_table_weakness weakness; |
892 Lisp_Object next_weak; // Used to chain together all of the weak | |
893 // hash tables. Don't mark through this. | |
894 }; | |
895 | |
1204 | 896 static const struct memory_description htentry_description_1[] = { |
897 { XD_LISP_OBJECT, offsetof (htentry, key) }, | |
898 { XD_LISP_OBJECT, offsetof (htentry, value) }, | |
814 | 899 { XD_END } |
900 }; | |
901 | |
1204 | 902 static const struct sized_memory_description htentry_description = { |
903 sizeof (htentry), | |
904 htentry_description_1 | |
814 | 905 }; |
906 | |
1204 | 907 const struct memory_description hash_table_description[] = { |
814 | 908 { XD_ELEMCOUNT, offsetof (Lisp_Hash_Table, size) }, |
2367 | 909 { XD_BLOCK_PTR, offsetof (Lisp_Hash_Table, hentries), XD_INDIRECT (0, 1), |
2551 | 910 { &htentry_description } }, |
814 | 911 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) }, |
912 { XD_END } | |
913 }; | |
914 | |
915 Note that we don't need to declare all the elements in the structure, just | |
916 the ones that need to be relocated (Lisp_Objects and structures) or that | |
917 need to be referenced as counts for relocated objects. | |
918 | |
1204 | 919 A description map looks like this: |
920 | |
921 static const struct sized_memory_description specifier_extra_description_map [] = { | |
922 { offsetof (Lisp_Specifier, methods) }, | |
923 { offsetof (struct specifier_methods, extra_description) }, | |
924 { -1 } | |
925 }; | |
926 | |
927 const struct memory_description specifier_description[] = { | |
928 ... | |
2367 | 929 { XD_BLOCK_ARRAY, offset (Lisp_Specifier, data), 1, |
2551 | 930 { specifier_extra_description_map } }, |
1204 | 931 ... |
932 { XD_END } | |
933 }; | |
934 | |
935 This would be appropriate for an object that looks like this: | |
936 | |
937 struct specifier_methods | |
938 { | |
939 ... | |
940 const struct sized_memory_description *extra_description; | |
941 ... | |
942 }; | |
943 | |
944 struct Lisp_Specifier | |
945 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
946 NORMAL_LISP_OBJECT_HEADER header; |
1204 | 947 struct specifier_methods *methods; |
948 | |
949 ... | |
950 // type-specific extra data attached to a specifier | |
951 max_align_t data[1]; | |
952 }; | |
953 | |
954 The description map means "retrieve a pointer into the object at offset | |
955 `offsetof (Lisp_Specifier, methods)' , then in turn retrieve a pointer | |
956 into that object at offset `offsetof (struct specifier_methods, | |
957 extra_description)', and that is the sized_memory_description to use." | |
958 There can be any number of indirections, which can be either into | |
959 straight pointers or Lisp_Objects. The way that description maps are | |
960 distinguished from normal sized_memory_descriptions is that in the | |
961 former, the memory_description pointer is NULL. | |
962 | |
963 --ben | |
964 | |
814 | 965 |
966 The existing types : | |
967 | |
968 | |
428 | 969 XD_LISP_OBJECT |
1204 | 970 |
971 A Lisp object. This is also the type to use for pointers to other lrecords | |
972 (e.g. struct frame *). | |
428 | 973 |
440 | 974 XD_LISP_OBJECT_ARRAY |
1204 | 975 |
771 | 976 An array of Lisp objects or (equivalently) pointers to lrecords. |
977 The parameter (i.e. third element) is the count. This would be declared | |
978 as Lisp_Object foo[666]. For something declared as Lisp_Object *foo, | |
2367 | 979 use XD_BLOCK_PTR, whose description parameter is a sized_memory_description |
771 | 980 consisting of only XD_LISP_OBJECT and XD_END. |
440 | 981 |
428 | 982 XD_LO_LINK |
1204 | 983 |
771 | 984 Weak link in a linked list of objects of the same type. This is a |
985 link that does NOT generate a GC reference. Thus the pdumper will | |
986 not automatically add the referenced object to the table of all | |
987 objects to be dumped, and when storing and loading the dumped data | |
988 will automatically prune unreferenced objects in the chain and link | |
989 each referenced object to the next referenced object, even if it's | |
990 many links away. We also need to special handling of a similar | |
991 nature for the root of the chain, which will be a staticpro()ed | |
992 object. | |
432 | 993 |
428 | 994 XD_OPAQUE_PTR |
1204 | 995 |
428 | 996 Pointer to undumpable data. Must be NULL when dumping. |
997 | |
2551 | 998 XD_OPAQUE_PTR_CONVERTIBLE |
999 | |
1000 Pointer to data which is not directly dumpable but can be converted | |
1001 to a dumpable, opaque external representation. The parameter is | |
1002 a pointer to an opaque_convert_functions struct. | |
1003 | |
1004 XD_OPAQUE_DATA_CONVERTIBLE | |
1005 | |
1006 Data which is not directly dumpable but can be converted to a | |
1007 dumpable, opaque external representation. The parameter is a | |
1008 pointer to an opaque_convert_functions struct. | |
1009 | |
2367 | 1010 XD_BLOCK_PTR |
1204 | 1011 |
771 | 1012 Pointer to block of described memory. (This is misnamed: It is NOT |
1013 necessarily a pointer to a struct foo.) Parameters are number of | |
1204 | 1014 contiguous blocks and sized_memory_description. |
771 | 1015 |
2367 | 1016 XD_BLOCK_ARRAY |
1204 | 1017 |
771 | 1018 Array of blocks of described memory. Parameters are number of |
2367 | 1019 structures and sized_memory_description. This differs from XD_BLOCK_PTR |
771 | 1020 in that the parameter is declared as struct foo[666] instead of |
1021 struct *foo. In other words, the block of memory holding the | |
1022 structures is within the containing structure, rather than being | |
1023 elsewhere, with a pointer in the containing structure. | |
428 | 1024 |
1204 | 1025 NOTE NOTE NOTE: Be sure that you understand the difference between |
2367 | 1026 XD_BLOCK_PTR and XD_BLOCK_ARRAY: |
1204 | 1027 - struct foo bar[666], i.e. 666 inline struct foos |
2367 | 1028 --> XD_BLOCK_ARRAY, argument 666, pointing to a description of |
1204 | 1029 struct foo |
1030 - struct foo *bar, i.e. pointer to a block of 666 struct foos | |
2367 | 1031 --> XD_BLOCK_PTR, argument 666, pointing to a description of |
1204 | 1032 struct foo |
1033 - struct foo *bar[666], i.e. 666 pointers to separate blocks of struct foos | |
2367 | 1034 --> XD_BLOCK_ARRAY, argument 666, pointing to a description of |
1204 | 1035 a single pointer to struct foo; the description is a single |
2367 | 1036 XD_BLOCK_PTR, argument 1, which in turn points to a description |
1204 | 1037 of struct foo. |
1038 | |
2367 | 1039 NOTE also that an XD_BLOCK_PTR of 666 foos is equivalent to an |
1040 XD_BLOCK_PTR of 1 bar, where the description of `bar' is an | |
1041 XD_BLOCK_ARRAY of 666 foos. | |
1042 | |
428 | 1043 XD_OPAQUE_DATA_PTR |
1204 | 1044 |
428 | 1045 Pointer to dumpable opaque data. Parameter is the size of the data. |
1046 Pointed data must be relocatable without changes. | |
1047 | |
771 | 1048 XD_UNION |
1204 | 1049 |
1050 Union of two or more different types of data. Parameters are a constant | |
1051 which determines which type the data is (this is usually an XD_INDIRECT, | |
1052 referring to one of the fields in the structure), and a "sizing lobby" (a | |
1053 sized_memory_description, which points to a memory_description and | |
1054 indicates its size). The size field in the sizing lobby describes the | |
1055 size of the union field in the object, and the memory_description in it | |
1056 is referred to as a "union map" and has a special interpretation: The | |
1057 offset field is replaced by a constant, which is compared to the first | |
1058 parameter of the XD_UNION descriptor to determine if this description | |
1059 applies to the union data, and XD_INDIRECT references refer to the | |
1060 containing object and description. Note that the description applies | |
2367 | 1061 "inline" to the union data, like XD_BLOCK_ARRAY and not XD_BLOCK_PTR. |
1204 | 1062 If the union data is a pointer to different types of structures, each |
2367 | 1063 element in the memory_description should be an XD_BLOCK_PTR. See |
1204 | 1064 unicode.c, redisplay.c and objects.c for examples of XD_UNION. |
1065 | |
1066 XD_UNION_DYNAMIC_SIZE | |
1067 | |
1068 Same as XD_UNION except that this is used for objects where the size of | |
1069 the object containing the union varies depending on the particular value | |
1070 of the union constant. That is, an object with plain XD_UNION typically | |
1071 has the union declared as `union foo' or as `void *', where an object | |
1072 with XD_UNION_DYNAMIC_SIZE typically has the union as the last element, | |
2367 | 1073 and declared as something like Rawbyte foo[1]. With plain XD_UNION, the |
1204 | 1074 object is (usually) of fixed size and always contains enough space for |
1075 the data associated with all possible union constants, and thus the union | |
1076 constant can potentially change during the lifetime of the object. With | |
1077 XD_UNION_DYNAMIC_SIZE, however, the union constant is fixed at the time | |
1078 of creation of the object, and the size of the object is computed | |
1079 dynamically at creation time based on the size of the data associated | |
1080 with the union constant. Currently, the only difference between XD_UNION | |
1081 and XD_UNION_DYNAMIC_SIZE is how the size of the union data is | |
1082 calculated, when (a) the structure containing the union has no size | |
1083 given; (b) the union occurs as the last element in the structure; and (c) | |
1084 the union has no size given (in the first-level sized_memory_description | |
1085 pointed to). In this circumstance, the size of XD_UNION comes from the | |
1086 max size of the data associated with all possible union constants, | |
1087 whereas the size of XD_UNION_DYNAMIC_SIZE comes from the size of the data | |
1088 associated with the currently specified (and unchangeable) union | |
1089 constant. | |
771 | 1090 |
2367 | 1091 XD_ASCII_STRING |
1204 | 1092 |
2367 | 1093 Pointer to a C string, purely ASCII. |
428 | 1094 |
1095 XD_DOC_STRING | |
1204 | 1096 |
2367 | 1097 Pointer to a doc string (C string in pure ASCII if positive, |
1098 opaque value if negative) | |
428 | 1099 |
1100 XD_INT_RESET | |
1204 | 1101 |
428 | 1102 An integer which will be reset to a given value in the dump file. |
1103 | |
1204 | 1104 XD_ELEMCOUNT |
771 | 1105 |
665 | 1106 Elemcount value. Used for counts. |
647 | 1107 |
665 | 1108 XD_BYTECOUNT |
1204 | 1109 |
665 | 1110 Bytecount value. Used for counts. |
647 | 1111 |
665 | 1112 XD_HASHCODE |
1204 | 1113 |
665 | 1114 Hashcode value. Used for the results of hashing functions. |
428 | 1115 |
1116 XD_INT | |
1204 | 1117 |
428 | 1118 int value. Used for counts. |
1119 | |
1120 XD_LONG | |
1204 | 1121 |
428 | 1122 long value. Used for counts. |
1123 | |
771 | 1124 XD_BYTECOUNT |
1204 | 1125 |
771 | 1126 bytecount value. Used for counts. |
1127 | |
428 | 1128 XD_END |
1204 | 1129 |
428 | 1130 Special type indicating the end of the array. |
1131 | |
1132 | |
1133 Special macros: | |
1204 | 1134 |
1135 XD_INDIRECT (line, delta) | |
1136 Usable where a count, size, offset or union constant is requested. Gives | |
1137 the value of the element which is at line number 'line' in the | |
1138 description (count starts at zero) and adds delta to it, which must | |
1139 (currently) be positive. | |
428 | 1140 */ |
1141 | |
1204 | 1142 enum memory_description_type |
647 | 1143 { |
440 | 1144 XD_LISP_OBJECT_ARRAY, |
428 | 1145 XD_LISP_OBJECT, |
3092 | 1146 #ifdef NEW_GC |
1147 XD_LISP_OBJECT_BLOCK_PTR, | |
1148 #endif /* NEW_GC */ | |
428 | 1149 XD_LO_LINK, |
1150 XD_OPAQUE_PTR, | |
2551 | 1151 XD_OPAQUE_PTR_CONVERTIBLE, |
1152 XD_OPAQUE_DATA_CONVERTIBLE, | |
1153 XD_OPAQUE_DATA_PTR, | |
2367 | 1154 XD_BLOCK_PTR, |
1155 XD_BLOCK_ARRAY, | |
771 | 1156 XD_UNION, |
1204 | 1157 XD_UNION_DYNAMIC_SIZE, |
2367 | 1158 XD_ASCII_STRING, |
428 | 1159 XD_DOC_STRING, |
1160 XD_INT_RESET, | |
665 | 1161 XD_BYTECOUNT, |
1162 XD_ELEMCOUNT, | |
1163 XD_HASHCODE, | |
428 | 1164 XD_INT, |
1165 XD_LONG, | |
1204 | 1166 XD_END |
428 | 1167 }; |
1168 | |
1204 | 1169 enum data_description_entry_flags |
647 | 1170 { |
1204 | 1171 /* If set, KKCC does not process this entry. |
1172 | |
1173 (1) One obvious use is with things that pdump saves but which do not get | |
1174 marked normally -- for example the next and prev fields in a marker. The | |
1175 marker chain is weak, with its entries removed when they are finalized. | |
1176 | |
1177 (2) This can be set on structures not containing any Lisp objects, or (more | |
1178 usefully) on structures that contain Lisp objects but where the objects | |
1179 always occur in another structure as well. For example, the extent lists | |
1180 kept by a buffer keep the extents in two lists, one sorted by the start | |
1181 of the extent and the other by the end. There's no point in marking | |
1182 both, since each contains the same objects as the other; but when dumping | |
1183 (if we were to dump such a structure), when computing memory size, etc., | |
1184 it's crucial to tag both sides. | |
1185 */ | |
1186 XD_FLAG_NO_KKCC = 1, | |
1187 /* If set, pdump does not process this entry. */ | |
1188 XD_FLAG_NO_PDUMP = 2, | |
1189 /* Indicates that this is a "default" entry in a union map. */ | |
1190 XD_FLAG_UNION_DEFAULT_ENTRY = 4, | |
3263 | 1191 #ifndef NEW_GC |
1204 | 1192 /* Indicates that this is a free Lisp object we're marking. |
1193 Only relevant for ERROR_CHECK_GC. This occurs when we're marking | |
1194 lcrecord-lists, where the objects have had their type changed to | |
1195 lrecord_type_free and also have had their free bit set, but we mark | |
1196 them as normal. */ | |
1429 | 1197 XD_FLAG_FREE_LISP_OBJECT = 8 |
3263 | 1198 #endif /* not NEW_GC */ |
1204 | 1199 #if 0 |
1429 | 1200 , |
1204 | 1201 /* Suggestions for other possible flags: */ |
1202 | |
1203 /* Eliminate XD_UNION_DYNAMIC_SIZE and replace it with a flag, like this. */ | |
1204 XD_FLAG_UNION_DYNAMIC_SIZE = 16, | |
1205 /* Require that everyone who uses a description map has to flag it, so | |
1206 that it's easy to tell, when looking through the code, where the | |
1207 description maps are and who's using them. This might also become | |
1208 necessary if for some reason the format of the description map is | |
1209 expanded and we need to stick a pointer in the second slot (although | |
1210 we could still ensure that the second slot in the first entry was NULL | |
1211 or <0). */ | |
1429 | 1212 XD_FLAG_DESCRIPTION_MAP = 32 |
1204 | 1213 #endif |
428 | 1214 }; |
1215 | |
2551 | 1216 union memory_contents_description |
1217 { | |
1218 /* The first element is used by static initializers only. We always read | |
1219 from one of the other two pointers. */ | |
1220 const void *write_only; | |
1221 const struct sized_memory_description *descr; | |
1222 const struct opaque_convert_functions *funcs; | |
1223 }; | |
1224 | |
1204 | 1225 struct memory_description |
1226 { | |
1227 enum memory_description_type type; | |
1228 Bytecount offset; | |
1229 EMACS_INT data1; | |
2551 | 1230 union memory_contents_description data2; |
1204 | 1231 /* Indicates which subsystems process this entry, plus (potentially) other |
1232 flags that apply to this entry. */ | |
1233 int flags; | |
1234 }; | |
428 | 1235 |
1204 | 1236 struct sized_memory_description |
1237 { | |
1238 Bytecount size; | |
1239 const struct memory_description *description; | |
1240 }; | |
1241 | |
2551 | 1242 |
1243 struct opaque_convert_functions | |
1244 { | |
1245 /* Used by XD_OPAQUE_PTR_CONVERTIBLE and | |
1246 XD_OPAQUE_DATA_CONVERTIBLE */ | |
1247 | |
1248 /* Converter to external representation, for those objects from | |
1249 external libraries that can't be directly dumped as opaque data | |
1250 because they contain pointers. This is called at dump time to | |
1251 convert to an opaque, pointer-less representation. | |
1252 | |
1253 This function must put a pointer to the opaque result in *data | |
1254 and its size in *size. */ | |
1255 void (*convert)(const void *object, void **data, Bytecount *size); | |
1256 | |
1257 /* Post-conversion cleanup. Optional (null if not provided). | |
1258 | |
1259 When provided it will be called post-dumping to free any storage | |
1260 allocated for the conversion results. */ | |
1261 void (*convert_free)(const void *object, void *data, Bytecount size); | |
1262 | |
1263 /* De-conversion. | |
1264 | |
1265 At reload time, rebuilds the object from the converted form. | |
1266 "object" is 0 for the PTR case, return is ignored in the DATA | |
1267 case. */ | |
1268 void *(*deconvert)(void *object, void *data, Bytecount size); | |
1269 | |
1270 }; | |
1271 | |
1204 | 1272 extern const struct sized_memory_description lisp_object_description; |
1273 | |
1274 #define XD_INDIRECT(val, delta) (-1 - (Bytecount) ((val) | ((delta) << 8))) | |
428 | 1275 |
1204 | 1276 #define XD_IS_INDIRECT(code) ((code) < 0) |
1277 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255) | |
1278 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8) | |
1279 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1280 /* 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
|
1281 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
|
1282 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
|
1283 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
|
1284 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
|
1285 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1286 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
|
1287 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1288 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
|
1289 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
|
1290 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
|
1291 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
|
1292 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1293 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
|
1294 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
|
1295 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
|
1296 (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
|
1297 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
|
1298 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
|
1299 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
|
1300 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
|
1301 mechanism for defining these objects. |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1302 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1303 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
|
1304 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1305 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
|
1306 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
|
1307 and other info such as the size of the structure containing the object. |
428 | 1308 */ |
1309 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1310 /* #### FIXME What's going on here? */ |
800 | 1311 #if defined (ERROR_CHECK_TYPES) |
1312 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype) | |
428 | 1313 #else |
800 | 1314 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype) |
428 | 1315 #endif |
1316 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1317 /********* The dumpable versions *********** */ |
934 | 1318 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1319 #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
|
1320 MAKE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof (structtype),0,0,structtype) |
934 | 1321 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1322 #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
|
1323 MAKE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,0,structtype) |
934 | 1324 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1325 #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
|
1326 MAKE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof(structtype),0,1,structtype) |
934 | 1327 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1328 #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
|
1329 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
|
1330 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1331 #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
|
1332 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
|
1333 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1334 #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
|
1335 DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT(name,c_name,marker,internal_object_printer,0,0,0,desc,sizer,structtype) |
934 | 1336 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1337 /********* The non-dumpable versions *********** */ |
934 | 1338 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1339 #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
|
1340 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
|
1341 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1342 #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
|
1343 MAKE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,0,structtype) |
934 | 1344 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1345 #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
|
1346 MAKE_LISP_OBJECT(name,c_name,0 /*non-dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof(structtype),0,1,structtype) |
934 | 1347 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1348 #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
|
1349 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
|
1350 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1351 #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
|
1352 DEFINE_NODUMP_LISP_OBJECT(name,c_name,marker,internal_object_printer,0,0,0,desc,structtype) |
934 | 1353 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1354 #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
|
1355 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
|
1356 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1357 /********* MAKE_LISP_OBJECT, the underlying macro *********** */ |
934 | 1358 |
3263 | 1359 #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
|
1360 #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
|
1361 equal,hash,desc,size,sizer,frob_block_p,structtype) \ |
2720 | 1362 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
|
1363 struct lrecord_implementation lrecord_##c_name = \ |
2720 | 1364 { 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
|
1365 size, sizer, lrecord_type_##c_name } |
3263 | 1366 #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
|
1367 #define MAKE_LISP_OBJECT(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,size,sizer,frob_block_p,structtype) \ |
1204 | 1368 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
|
1369 struct lrecord_implementation lrecord_##c_name = \ |
934 | 1370 { 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
|
1371 size, sizer, lrecord_type_##c_name, frob_block_p } |
3263 | 1372 #endif /* not NEW_GC */ |
934 | 1373 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1374 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1375 /********* The module dumpable versions *********** */ |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1376 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1377 #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
|
1378 MAKE_MODULE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,sizeof (structtype),0,0,structtype) |
934 | 1379 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1380 #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
|
1381 MAKE_MODULE_LISP_OBJECT(name,c_name,1 /*dumpable*/,marker,printer,nuker,equal,hash,desc,0,sizer,0,structtype) |
934 | 1382 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1383 /********* The module non-dumpable versions *********** */ |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1384 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1385 #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
|
1386 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
|
1387 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
|
1388 nuker,equal,hash,desc,sizeof (structtype),0,0,structtype) |
934 | 1389 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1390 #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
|
1391 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
|
1392 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
|
1393 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
|
1394 |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1395 /********* MAKE_MODULE_LISP_OBJECT, the underlying macro *********** */ |
934 | 1396 |
3263 | 1397 #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
|
1398 #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
|
1399 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
|
1400 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
|
1401 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
|
1402 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
|
1403 { 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
|
1404 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
|
1405 #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
|
1406 #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
|
1407 nuker,equal,hash,desc,size,sizer,frob_block_p,structtype) \ |
2720 | 1408 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \ |
1409 int lrecord_type_##c_name; \ | |
1410 struct lrecord_implementation lrecord_##c_name = \ | |
1411 { 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
|
1412 size, sizer, lrecord_type_last_built_in_type, frob_block_p } |
3263 | 1413 #endif /* not NEW_GC */ |
934 | 1414 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1415 #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
|
1416 #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
|
1417 do \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1418 { \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1419 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
|
1420 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
|
1421 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
|
1422 num_extra_memusage_stats = -1; \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1423 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
|
1424 memusage_stats_list); \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1425 } while (0) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1426 #else |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1427 #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
|
1428 #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
|
1429 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1430 #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
|
1431 do \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1432 { \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1433 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
|
1434 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
|
1435 } while (0) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1436 |
1676 | 1437 #ifdef USE_KKCC |
1438 extern MODULE_API const struct memory_description *lrecord_memory_descriptions[]; | |
1439 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1440 #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
|
1441 INIT_LISP_OBJECT_BEGINNING (type); \ |
1676 | 1442 lrecord_memory_descriptions[lrecord_type_##type] = \ |
1443 lrecord_implementations_table[lrecord_type_##type]->description; \ | |
1444 } while (0) | |
1445 #else /* not USE_KKCC */ | |
1632 | 1446 extern MODULE_API Lisp_Object (*lrecord_markers[]) (Lisp_Object); |
442 | 1447 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1448 #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
|
1449 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
|
1450 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
|
1451 lrecord_implementations_table[lrecord_type_##type]->marker; \ |
442 | 1452 } while (0) |
1676 | 1453 #endif /* not USE_KKCC */ |
428 | 1454 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1455 #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
|
1456 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
|
1457 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
|
1458 INIT_LISP_OBJECT (type); \ |
444 | 1459 } while (0) |
1460 | |
996 | 1461 #ifdef HAVE_SHLIB |
1462 /* Allow undefining types in order to support module unloading. */ | |
1463 | |
1676 | 1464 #ifdef USE_KKCC |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1465 #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
|
1466 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
|
1467 lrecord_memory_descriptions[lrecord_type_##type] = NULL; \ |
1676 | 1468 } while (0) |
1469 #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
|
1470 #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
|
1471 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
|
1472 lrecord_markers[lrecord_type_##type] = NULL; \ |
996 | 1473 } while (0) |
1676 | 1474 #endif /* not USE_KKCC */ |
996 | 1475 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1476 #define UNDEF_MODULE_LISP_OBJECT(type) do { \ |
996 | 1477 if (lrecord_##type.lrecord_type_index == lrecord_type_count - 1) { \ |
1478 /* This is the most recently defined type. Clean up nicely. */ \ | |
1479 lrecord_type_##type = lrecord_type_count--; \ | |
1480 } /* 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
|
1481 UNDEF_LISP_OBJECT(type); \ |
996 | 1482 } while (0) |
1483 | |
1484 #endif /* HAVE_SHLIB */ | |
1485 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1486 /*************** 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
|
1487 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
|
1488 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1489 /* 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
|
1490 initialization routines */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1491 #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
|
1492 (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
|
1493 /* 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
|
1494 #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
|
1495 (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
|
1496 /* 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
|
1497 #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
|
1498 (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
|
1499 /* 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
|
1500 #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
|
1501 (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
|
1502 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1503 /* 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
|
1504 #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
|
1505 (!!(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
|
1506 /* 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
|
1507 #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
|
1508 ((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
|
1509 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1510 /* 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
|
1511 #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
|
1512 do \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1513 { \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1514 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
|
1515 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
|
1516 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
|
1517 ((_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
|
1518 } while (0) |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1519 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1520 /* 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
|
1521 Multiply-evaluates OBJ. */ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1522 #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
|
1523 (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
|
1524 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1525 #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
|
1526 |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1527 /************** Other stuff **************/ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1528 |
428 | 1529 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record) |
1530 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a)) | |
1531 | |
1532 #define RECORD_TYPEP(x, ty) \ | |
647 | 1533 (LRECORDP (x) && (XRECORD_LHEADER (x)->type == (unsigned int) (ty))) |
442 | 1534 |
1535 /* Steps to create a new object: | |
1536 | |
1537 1. Declare the struct for your object in a header file somewhere. | |
1538 Remember that it must begin with | |
1539 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1540 NORMAL_LISP_OBJECT_HEADER header; |
442 | 1541 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1542 2. Put the "standard junk" (DECLARE_LISP_OBJECT()/XFOO/etc.) below the |
617 | 1543 struct definition -- see below. |
442 | 1544 |
1545 3. Add this header file to inline.c. | |
1546 | |
1547 4. Create the methods for your object. Note that technically you don't | |
1548 need any, but you will almost always want at least a mark method. | |
1549 | |
1204 | 1550 4. Create the data layout description for your object. See |
1551 toolbar_button_description below; the comment above in `struct lrecord', | |
1552 describing the purpose of the descriptions; and comments elsewhere in | |
1553 this file describing the exact syntax of the description structures. | |
1554 | |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1555 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
|
1556 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
|
1557 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
|
1558 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
|
1559 Nondumpable objects are generally those associated with display, |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1560 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
|
1561 (e.g. a window-system window). |
442 | 1562 |
1204 | 1563 7. Include the header file in the .c file where you defined the object. |
442 | 1564 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1565 8. Put a call to INIT_LISP_OBJECT() for the object in the |
442 | 1566 .c file's syms_of_foo() function. |
1567 | |
1204 | 1568 9. Add a type enum for the object to enum lrecord_type, earlier in this |
442 | 1569 file. |
1570 | |
1204 | 1571 --ben |
1572 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1573 An example: |
428 | 1574 |
442 | 1575 ------------------------------ in toolbar.h ----------------------------- |
1576 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1577 struct toolbar_button |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1578 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1579 NORMAL_LISP_OBJECT_HEADER header; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1580 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1581 Lisp_Object next; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1582 Lisp_Object frame; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1583 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1584 Lisp_Object up_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1585 Lisp_Object down_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1586 Lisp_Object disabled_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1587 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1588 Lisp_Object cap_up_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1589 Lisp_Object cap_down_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1590 Lisp_Object cap_disabled_glyph; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1591 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1592 Lisp_Object callback; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1593 Lisp_Object enabled_p; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1594 Lisp_Object help_string; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1595 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1596 char enabled; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1597 char down; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1598 char pushright; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1599 char blank; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1600 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1601 int x, y; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1602 int width, height; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1603 int dirty; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1604 int vertical; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1605 int border_width; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1606 }; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1607 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1608 [[ the standard junk: ]] |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1609 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1610 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
|
1611 #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
|
1612 #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
|
1613 #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
|
1614 #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
|
1615 #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
|
1616 |
442 | 1617 ------------------------------ in toolbar.c ----------------------------- |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1618 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1619 #include "toolbar.h" |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1620 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1621 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1622 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1623 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
|
1624 { 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
|
1625 { 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
|
1626 { 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
|
1627 { 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
|
1628 { 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
|
1629 { 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
|
1630 { 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
|
1631 { 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
|
1632 { 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
|
1633 { 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
|
1634 { 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
|
1635 { XD_END } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1636 }; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1637 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1638 static Lisp_Object |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1639 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
|
1640 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1641 struct toolbar_button *tb; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1642 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1643 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
|
1644 tb->next = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1645 tb->frame = wrap_frame (f); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1646 tb->up_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1647 tb->down_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1648 tb->disabled_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1649 tb->cap_up_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1650 tb->cap_down_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1651 tb->cap_disabled_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1652 tb->callback = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1653 tb->enabled_p = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1654 tb->help_string = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1655 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1656 tb->pushright = pushright; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1657 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
|
1658 tb->dirty = 1; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1659 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1660 return wrap_toolbar_button (tb); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1661 } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1662 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1663 static Lisp_Object |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1664 mark_toolbar_button (Lisp_Object obj) |
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 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
|
1667 mark_object (data->next); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1668 mark_object (data->frame); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1669 mark_object (data->up_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1670 mark_object (data->down_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1671 mark_object (data->disabled_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1672 mark_object (data->cap_up_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1673 mark_object (data->cap_down_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1674 mark_object (data->cap_disabled_glyph); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1675 mark_object (data->callback); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1676 mark_object (data->enabled_p); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1677 return data->help_string; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1678 } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1679 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1680 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
|
1681 mark_toolbar_button, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1682 external_object_printer, 0, 0, 0, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1683 toolbar_button_description, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1684 struct toolbar_button); |
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 void |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1689 syms_of_toolbar (void) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1690 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1691 INIT_LISP_OBJECT (toolbar_button); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1692 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1693 ...; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1694 } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1695 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1696 ------------------------------ in inline.c ----------------------------- |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1697 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1698 #ifdef HAVE_TOOLBARS |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1699 #include "toolbar.h" |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1700 #endif |
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 ------------------------------ in lrecord.h ----------------------------- |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1703 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1704 enum lrecord_type |
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 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1707 lrecord_type_toolbar_button, |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1708 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1709 }; |
442 | 1710 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1711 ------------------------------ in .gdbinit.in.in ----------------------------- |
442 | 1712 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1713 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1714 else |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1715 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
|
1716 pstructtype toolbar_button |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1717 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1718 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1719 ... |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1720 end |
442 | 1721 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1722 --ben |
1204 | 1723 |
442 | 1724 */ |
1725 | |
1726 /* | |
1727 | |
1728 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
|
1729 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
|
1730 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
|
1731 and DEFINE_*_LISP_OBJECT. The MODULE versions declare and |
3029 | 1732 allocate an enumerator for the type being defined. |
442 | 1733 |
1734 */ | |
1735 | |
428 | 1736 |
800 | 1737 #ifdef ERROR_CHECK_TYPES |
428 | 1738 |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1739 # 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
|
1740 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
|
1741 DECLARE_INLINE_HEADER ( \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1742 structtype * \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1743 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
|
1744 ) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1745 { \ |
788 | 1746 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
|
1747 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
|
1748 } \ |
428 | 1749 extern Lisp_Object Q##c_name##p |
1750 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1751 # 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
|
1752 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
|
1753 DECLARE_INLINE_HEADER ( \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1754 structtype * \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1755 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
|
1756 ) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1757 { \ |
1632 | 1758 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
|
1759 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
|
1760 } \ |
1632 | 1761 extern MODULE_API Lisp_Object Q##c_name##p |
1762 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1763 # 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
|
1764 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
|
1765 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
|
1766 DECLARE_INLINE_HEADER ( \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1767 structtype * \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1768 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
|
1769 ) \ |
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
1770 { \ |
788 | 1771 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
|
1772 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
|
1773 } \ |
444 | 1774 extern Lisp_Object Q##c_name##p |
442 | 1775 |
788 | 1776 # define XRECORD(x, c_name, structtype) \ |
1777 error_check_##c_name (x, __FILE__, __LINE__) | |
428 | 1778 |
826 | 1779 DECLARE_INLINE_HEADER ( |
1780 Lisp_Object | |
2367 | 1781 wrap_record_1 (const void *ptr, enum lrecord_type ty, const Ascbyte *file, |
800 | 1782 int line) |
826 | 1783 ) |
617 | 1784 { |
793 | 1785 Lisp_Object obj = wrap_pointer_1 (ptr); |
1786 | |
788 | 1787 assert_at_line (RECORD_TYPEP (obj, ty), file, line); |
617 | 1788 return obj; |
1789 } | |
1790 | |
788 | 1791 #define wrap_record(ptr, ty) \ |
1792 wrap_record_1 (ptr, lrecord_type_##ty, __FILE__, __LINE__) | |
617 | 1793 |
800 | 1794 #else /* not ERROR_CHECK_TYPES */ |
428 | 1795 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1796 # define DECLARE_LISP_OBJECT(c_name, structtype) \ |
428 | 1797 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
|
1798 extern struct lrecord_implementation lrecord_##c_name |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1799 # 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
|
1800 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
|
1801 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
|
1802 # define DECLARE_MODULE_LISP_OBJECT(c_name, structtype) \ |
442 | 1803 extern Lisp_Object Q##c_name##p; \ |
647 | 1804 extern int lrecord_type_##c_name; \ |
444 | 1805 extern struct lrecord_implementation lrecord_##c_name |
428 | 1806 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x)) |
617 | 1807 /* wrap_pointer_1 is so named as a suggestion not to use it unless you |
1808 know what you're doing. */ | |
1809 #define wrap_record(ptr, ty) wrap_pointer_1 (ptr) | |
428 | 1810 |
800 | 1811 #endif /* not ERROR_CHECK_TYPES */ |
428 | 1812 |
442 | 1813 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_type_##c_name) |
428 | 1814 |
1815 /* Note: we now have two different kinds of type-checking macros. | |
1816 The "old" kind has now been renamed CONCHECK_foo. The reason for | |
1817 this is that the CONCHECK_foo macros signal a continuable error, | |
1818 allowing the user (through debug-on-error) to substitute a different | |
1819 value and return from the signal, which causes the lvalue argument | |
1820 to get changed. Quite a lot of code would crash if that happened, | |
1821 because it did things like | |
1822 | |
1823 foo = XCAR (list); | |
1824 CHECK_STRING (foo); | |
1825 | |
1826 and later on did XSTRING (XCAR (list)), assuming that the type | |
1827 is correct (when it might be wrong, if the user substituted a | |
1828 correct value in the debugger). | |
1829 | |
1830 To get around this, I made all the CHECK_foo macros signal a | |
1831 non-continuable error. Places where a continuable error is OK | |
1832 (generally only when called directly on the argument of a Lisp | |
1833 primitive) should be changed to use CONCHECK(). | |
1834 | |
1835 FSF Emacs does not have this problem because RMS took the cheesy | |
1836 way out and disabled returning from a signal entirely. */ | |
1837 | |
1838 #define CONCHECK_RECORD(x, c_name) do { \ | |
442 | 1839 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \ |
428 | 1840 x = wrong_type_argument (Q##c_name##p, x); \ |
1841 } while (0) | |
1842 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\ | |
1843 if (XTYPE (x) != lisp_enum) \ | |
1844 x = wrong_type_argument (predicate, x); \ | |
1845 } while (0) | |
1846 #define CHECK_RECORD(x, c_name) do { \ | |
442 | 1847 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \ |
428 | 1848 dead_wrong_type_argument (Q##c_name##p, x); \ |
1849 } while (0) | |
1850 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \ | |
1851 if (XTYPE (x) != lisp_enum) \ | |
1852 dead_wrong_type_argument (predicate, x); \ | |
1853 } while (0) | |
1854 | |
3263 | 1855 #ifndef NEW_GC |
1204 | 1856 /*-------------------------- lcrecord-list -----------------------------*/ |
1857 | |
1858 struct lcrecord_list | |
1859 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1860 NORMAL_LISP_OBJECT_HEADER header; |
1204 | 1861 Lisp_Object free; |
1862 Elemcount size; | |
1863 const struct lrecord_implementation *implementation; | |
1864 }; | |
1865 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1866 DECLARE_LISP_OBJECT (lcrecord_list, struct lcrecord_list); |
1204 | 1867 #define XLCRECORD_LIST(x) XRECORD (x, lcrecord_list, struct lcrecord_list) |
1868 #define wrap_lcrecord_list(p) wrap_record (p, lcrecord_list) | |
1869 #define LCRECORD_LISTP(x) RECORDP (x, lcrecord_list) | |
1870 /* #define CHECK_LCRECORD_LIST(x) CHECK_RECORD (x, lcrecord_list) | |
1871 Lcrecord lists should never escape to the Lisp level, so | |
1872 functions should not be doing this. */ | |
1873 | |
826 | 1874 /* Various ways of allocating lcrecords. All bytes (except lcrecord |
1204 | 1875 header) are zeroed in returned structure. |
1876 | |
1877 See above for a discussion of the difference between plain lrecords and | |
1878 lrecords. lcrecords themselves are divided into three types: (1) | |
1879 auto-managed, (2) hand-managed, and (3) unmanaged. "Managed" refers to | |
1880 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
|
1881 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
|
1882 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
|
1883 requiring new malloc(). Thus, allocation of lcrecords can be very |
1204 | 1884 cheap. (Technically, the lcrecord-list manager could divide up large |
1885 chunks of memory and allocate out of that, mimicking what happens with | |
1886 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
|
1887 division between lrecords and lcrecords.) |
1204 | 1888 |
1889 NOTE: There is a fundamental limitation of lcrecord-lists, which is that | |
1890 they only handle blocks of a particular, fixed size. Thus, objects that | |
1891 can be of varying sizes need to do various tricks. These considerations | |
1892 in particular dictate the various types of management: | |
1893 | |
1894 -- "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
|
1895 whenever you want, using ALLOC_NORMAL_LISP_OBJECT(), and the appropriate |
1204 | 1896 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
|
1897 "free_normal_lisp_object()" and the appropriate lcrecord-list manager is |
1204 | 1898 automatically located and called. The limitation here of course is that |
1899 all your objects are of the same size. (#### Eventually we should have a | |
1900 more sophisticated system that tracks the sizes seen and creates one | |
1901 lcrecord list per size, indexed in a hash table. Usually there are only | |
1902 a limited number of sizes, so this works well.) | |
826 | 1903 |
1204 | 1904 -- "Hand-managed" exists because we haven't yet written the more |
1905 sophisticated scheme for auto-handling different-sized lcrecords, as | |
1906 described in the end of the last paragraph. In this model, you go ahead | |
1907 and create the lcrecord-list objects yourself for the sizes you will | |
1908 need, using make_lcrecord_list(). Then, create lcrecords using | |
1909 alloc_managed_lcrecord(), passing in the lcrecord-list you created, and | |
1910 free them with free_managed_lcrecord(). | |
1911 | |
1912 -- "Unmanaged" means you simply allocate lcrecords, period. No | |
1913 lcrecord-lists, no way to free them. This may be suitable when the | |
1914 lcrecords are variable-sized and (a) you're too lazy to write the code | |
1915 to hand-manage them, or (b) the objects you create are always or almost | |
1916 always Lisp-visible, and thus there's no point in freeing them (and it | |
1917 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
|
1918 ALLOC_SIZED_LISP_OBJECT(), and that's it. |
1204 | 1919 |
1920 --ben | |
1921 | |
1922 Here is an in-depth look at the steps required to create a allocate an | |
1923 lcrecord using the hand-managed style. Since this is the most | |
1924 complicated, you will learn a lot about the other styles as well. In | |
1925 addition, there is useful general information about what freeing an | |
1926 lcrecord really entails, and what are the precautions: | |
1927 | |
1928 1) Create an lcrecord-list object using make_lcrecord_list(). This is | |
1929 often done at initialization. Remember to staticpro_nodump() this | |
1930 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
|
1931 passed to ALLOC_SIZED_LISP_OBJECT(). |
428 | 1932 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1933 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
|
1934 alloc_managed_lcrecord() and pass the lcrecord-list earlier created. |
1204 | 1935 |
1936 3) When done with the lcrecord, call free_managed_lcrecord(). The | |
1937 standard freeing caveats apply: ** make sure there are no pointers to | |
1938 the object anywhere! ** | |
1939 | |
1940 4) Calling free_managed_lcrecord() is just like kissing the | |
1941 lcrecord goodbye as if it were garbage-collected. This means: | |
1942 -- the contents of the freed lcrecord are undefined, and the | |
1943 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
|
1944 are undefined, just like for ALLOC_SIZED_LISP_OBJECT(). |
1204 | 1945 -- the mark method for the lcrecord's type will *NEVER* be called |
1946 on freed lcrecords. | |
1947 -- the finalize method for the lcrecord's type will be called | |
1948 at the time that free_managed_lcrecord() is called. | |
1949 */ | |
1950 | |
1951 /* UNMANAGED MODEL: */ | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1952 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
|
1953 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
|
1954 const struct lrecord_implementation *); |
1204 | 1955 |
1956 /* HAND-MANAGED MODEL: */ | |
1957 Lisp_Object make_lcrecord_list (Elemcount size, | |
1958 const struct lrecord_implementation | |
1959 *implementation); | |
1960 Lisp_Object alloc_managed_lcrecord (Lisp_Object lcrecord_list); | |
1961 void free_managed_lcrecord (Lisp_Object lcrecord_list, Lisp_Object lcrecord); | |
1962 | |
1963 /* AUTO-MANAGED MODEL: */ | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1964 MODULE_API Lisp_Object |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1965 alloc_automanaged_sized_lcrecord (Bytecount size, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1966 const struct lrecord_implementation *imp); |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1967 MODULE_API Lisp_Object |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1968 alloc_automanaged_lcrecord (const struct lrecord_implementation *imp); |
3017 | 1969 |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
1970 #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
|
1971 ((type *) XPNTR (alloc_automanaged_lcrecord (sizeof (type), imp))) |
2720 | 1972 |
3024 | 1973 void old_free_lcrecord (Lisp_Object rec); |
771 | 1974 |
3263 | 1975 #else /* NEW_GC */ |
2720 | 1976 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1977 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
|
1978 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
|
1979 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
|
1980 const struct lrecord_implementation *imp); |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1981 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
|
1982 Lisp_Object noseeum_alloc_lrecord (const struct lrecord_implementation *imp); |
3092 | 1983 |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1984 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
|
1985 const struct lrecord_implementation *imp); |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1986 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
|
1987 int elemcount, |
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
1988 const struct lrecord_implementation *imp); |
2720 | 1989 |
3263 | 1990 #endif /* NEW_GC */ |
3017 | 1991 |
1204 | 1992 DECLARE_INLINE_HEADER ( |
1993 Bytecount | |
1994 detagged_lisp_object_size (const struct lrecord_header *h) | |
1995 ) | |
1996 { | |
1997 const struct lrecord_implementation *imp = LHEADER_IMPLEMENTATION (h); | |
1998 | |
1999 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
|
2000 imp->size_in_bytes_method (wrap_pointer_1 (h)) : |
1204 | 2001 imp->static_size); |
2002 } | |
2003 | |
2004 DECLARE_INLINE_HEADER ( | |
2005 Bytecount | |
2006 lisp_object_size (Lisp_Object o) | |
2007 ) | |
2008 { | |
2009 return detagged_lisp_object_size (XRECORD_LHEADER (o)); | |
2010 } | |
2011 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
2012 struct usage_stats; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2013 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2014 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
|
2015 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
|
2016 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
|
2017 #ifdef MEMORY_USAGE_STATS |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2018 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
|
2019 struct usage_stats *ustats); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2020 #endif /* MEMORY_USAGE_STATS */ |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2021 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
|
2022 |
1204 | 2023 |
2024 /************************************************************************/ | |
2025 /* Dumping */ | |
2026 /************************************************************************/ | |
2027 | |
2367 | 2028 /* dump_add_root_block_ptr (&var, &desc) dumps the structure pointed to by |
1204 | 2029 `var'. This is for a single relocatable pointer located in the data |
2367 | 2030 segment (i.e. the block pointed to is in the heap). |
2031 | |
2032 If the structure pointed to is not a `struct' but an array, you should | |
2033 set the size field of the sized_memory_description to 0, and use | |
2034 XD_BLOCK_ARRAY in the inner memory_description. | |
2035 | |
2036 NOTE that a "root struct pointer" could also be described using | |
2037 dump_add_root_block(), with SIZE == sizeof (void *), and a description | |
2038 containing a single XD_BLOCK_PTR entry, offset 0, size 1, with a | |
2039 structure description the same as the value passed to | |
2040 dump_add_root_block_ptr(). That would require an extra level of | |
2041 description, though, as compared to using dump_add_root_block_ptr(), | |
2042 and thus this function is generally more convenient. | |
2043 */ | |
1204 | 2044 #ifdef PDUMP |
2367 | 2045 void dump_add_root_block_ptr (void *, const struct sized_memory_description *); |
1204 | 2046 #else |
2367 | 2047 #define dump_add_root_block_ptr(varaddr, descaddr) DO_NOTHING |
1204 | 2048 #endif |
2049 | |
2050 /* dump_add_opaque (&var, size) dumps the opaque static structure `var'. | |
2051 This is for a static block of memory (in the data segment, not the | |
2052 heap), with no relocatable pointers in it. */ | |
2053 #ifdef PDUMP | |
2054 #define dump_add_opaque(varaddr,size) dump_add_root_block (varaddr, size, NULL) | |
2055 #else | |
2056 #define dump_add_opaque(varaddr,size) DO_NOTHING | |
2057 #endif | |
2058 | |
2059 /* dump_add_root_block (ptr, size, desc) dumps the static structure | |
2060 located at `var' of size SIZE and described by DESC. This is for a | |
2061 static block of memory (in the data segment, not the heap), with | |
2062 relocatable pointers in it. */ | |
2063 #ifdef PDUMP | |
2064 void dump_add_root_block (const void *ptraddress, Bytecount size, | |
2065 const struct memory_description *desc); | |
2066 #else | |
2367 | 2067 #define dump_add_root_block(ptraddress, size, desc) DO_NOTHING |
1204 | 2068 #endif |
2069 | |
2070 /* Call dump_add_opaque_int (&int_var) to dump `int_var', of type `int'. */ | |
2071 #ifdef PDUMP | |
2072 #define dump_add_opaque_int(int_varaddr) do { \ | |
2073 int *dao_ = (int_varaddr); /* type check */ \ | |
2074 dump_add_opaque (dao_, sizeof (*dao_)); \ | |
2075 } while (0) | |
2076 #else | |
2077 #define dump_add_opaque_int(int_varaddr) DO_NOTHING | |
2078 #endif | |
2079 | |
2080 /* Call dump_add_opaque_fixnum (&fixnum_var) to dump `fixnum_var', of type | |
2081 `Fixnum'. */ | |
2082 #ifdef PDUMP | |
2083 #define dump_add_opaque_fixnum(fixnum_varaddr) do { \ | |
2084 Fixnum *dao_ = (fixnum_varaddr); /* type check */ \ | |
2085 dump_add_opaque (dao_, sizeof (*dao_)); \ | |
2086 } while (0) | |
2087 #else | |
2088 #define dump_add_opaque_fixnum(fixnum_varaddr) DO_NOTHING | |
2089 #endif | |
2090 | |
2091 /* Call dump_add_root_lisp_object (&var) to ensure that var is properly | |
2092 updated after pdump. */ | |
2093 #ifdef PDUMP | |
2094 void dump_add_root_lisp_object (Lisp_Object *); | |
2095 #else | |
2096 #define dump_add_root_lisp_object(varaddr) DO_NOTHING | |
2097 #endif | |
2098 | |
2099 /* Call dump_add_weak_lisp_object (&var) to ensure that var is properly | |
2100 updated after pdump. var must point to a linked list of objects out of | |
2101 which some may not be dumped */ | |
2102 #ifdef PDUMP | |
2103 void dump_add_weak_object_chain (Lisp_Object *); | |
2104 #else | |
2105 #define dump_add_weak_object_chain(varaddr) DO_NOTHING | |
2106 #endif | |
2107 | |
2108 /* Nonzero means Emacs has already been initialized. | |
2109 Used during startup to detect startup of dumped Emacs. */ | |
1632 | 2110 extern MODULE_API int initialized; |
1204 | 2111 |
2112 #ifdef PDUMP | |
1688 | 2113 #include "dumper.h" |
3263 | 2114 #ifdef NEW_GC |
2720 | 2115 #define DUMPEDP(adr) 0 |
3263 | 2116 #else /* not NEW_GC */ |
2367 | 2117 #define DUMPEDP(adr) ((((Rawbyte *) (adr)) < pdump_end) && \ |
2118 (((Rawbyte *) (adr)) >= pdump_start)) | |
3263 | 2119 #endif /* not NEW_GC */ |
1204 | 2120 #else |
2121 #define DUMPEDP(adr) 0 | |
2122 #endif | |
2123 | |
1330 | 2124 #define OBJECT_DUMPED_P(obj) DUMPEDP (XPNTR (obj)) |
2125 | |
1204 | 2126 /***********************************************************************/ |
2127 /* data descriptions */ | |
2128 /***********************************************************************/ | |
2129 | |
2130 | |
2131 #if defined (USE_KKCC) || defined (PDUMP) | |
2132 | |
2133 extern int in_pdump; | |
2134 | |
2135 EMACS_INT lispdesc_indirect_count_1 (EMACS_INT code, | |
2136 const struct memory_description *idesc, | |
2137 const void *idata); | |
2138 const struct sized_memory_description *lispdesc_indirect_description_1 | |
2139 (const void *obj, const struct sized_memory_description *sdesc); | |
2367 | 2140 Bytecount lispdesc_block_size_1 (const void *obj, Bytecount size, |
2141 const struct memory_description *desc); | |
2142 | |
2143 DECLARE_INLINE_HEADER ( | |
2144 Bytecount lispdesc_block_size (const void *obj, | |
2145 const struct sized_memory_description *sdesc)) | |
2146 { | |
2147 return lispdesc_block_size_1 (obj, sdesc->size, sdesc->description); | |
2148 } | |
1204 | 2149 |
2150 DECLARE_INLINE_HEADER ( | |
2151 EMACS_INT | |
2152 lispdesc_indirect_count (EMACS_INT code, | |
2153 const struct memory_description *idesc, | |
2154 const void *idata) | |
2155 ) | |
2156 { | |
2157 if (XD_IS_INDIRECT (code)) | |
2158 code = lispdesc_indirect_count_1 (code, idesc, idata); | |
2159 return code; | |
2160 } | |
2161 | |
2162 DECLARE_INLINE_HEADER ( | |
2163 const struct sized_memory_description * | |
2164 lispdesc_indirect_description (const void *obj, | |
2165 const struct sized_memory_description *sdesc) | |
2166 ) | |
2167 { | |
2168 if (sdesc->description) | |
2169 return sdesc; | |
2170 else | |
2171 return lispdesc_indirect_description_1 (obj, sdesc); | |
2172 } | |
2173 | |
2174 | |
2175 /* Do standard XD_UNION processing. DESC1 is an entry in DESC, which | |
2176 describes the entire data structure. Returns NULL (do nothing, nothing | |
2177 matched), or a new value for DESC1. In the latter case, assign to DESC1 | |
2178 in your function and goto union_switcheroo. */ | |
2179 | |
2180 DECLARE_INLINE_HEADER ( | |
2181 const struct memory_description * | |
2182 lispdesc_process_xd_union (const struct memory_description *desc1, | |
2183 const struct memory_description *desc, | |
2184 const void *data) | |
2185 ) | |
2186 { | |
2187 int count = 0; | |
2188 EMACS_INT variant = lispdesc_indirect_count (desc1->data1, desc, | |
2189 data); | |
2190 desc1 = | |
2551 | 2191 lispdesc_indirect_description (data, desc1->data2.descr)->description; |
1204 | 2192 |
2193 for (count = 0; desc1[count].type != XD_END; count++) | |
2194 { | |
2195 if ((desc1[count].flags & XD_FLAG_UNION_DEFAULT_ENTRY) || | |
2196 desc1[count].offset == variant) | |
2197 { | |
2198 return &desc1[count]; | |
2199 } | |
2200 } | |
2201 | |
2202 return NULL; | |
2203 } | |
2204 | |
2205 #endif /* defined (USE_KKCC) || defined (PDUMP) */ | |
428 | 2206 |
1743 | 2207 END_C_DECLS |
1650 | 2208 |
440 | 2209 #endif /* INCLUDED_lrecord_h_ */ |