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