annotate src/lrecord.h @ 1204:e22b0213b713

[xemacs-hg @ 2003-01-12 11:07:58 by michaels] modules/ChangeLog: 2002-12-16 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c: remove ifdef USE_KKCC. src/ChangeLog: 2003-01-08 Mike Sperber <mike@xemacs.org> * console.h (CDFW_CONSOLE): Don't lead to a crash if we're dealing with a dead window/frame/device/console. 2002-12-20 Mike Sperber <mike@xemacs.org> * ui-gtk.c: Fix typo from Ben's patch: emacs_ffi_data is a typedef, not a struct. emacs_gtk_object_data is a typedef, not a struct. * gtk-glue.c (gdk_event_to_emacs_event): Fix typos from Ben's patch: le -> emacs_event + rearrange the code. * event-gtk.c (gtk_event_to_emacs_event): Fix typos from Ben's patch: ..._UNDERLYING_GDK_EVENT -> ..._GDK_EVENT, ev -> key_event. * device-gtk.c: Fix typo from Ben's patch: x_keysym_map_hash_table -> x_keysym_map_hashtable. 2002-12-19 Mike Sperber <mike@xemacs.org> * menubar-x.c (set_frame_menubar): Initialize protect_me field of popup_data. 2002-12-16 Ben Wing <ben@xemacs.org> Major cleanup of KKCC, etc. KKCC, pdump-related: -- descriptions are written for all objects. this required some changes in the format of some objects, e.g. extents, popup-data, coding system, lstream, lcrecord-list. -- KKCC now handles weakness in markers, hash tables, elsewhere correctly (formerly, you'd eventually get a stack overflow due to endlessly expanding markers). -- textual changes: lrecord_description -> memory_description, struct_description -> sized_memory_description. -- extensive comment describing descriptions and pdump. -- redo XD_UNION so it works inline and change its format to provide sufficient info for pdump. implement XD_UNION in pdump. also add XD_UNION_DYNAMIC_SIZE, which works like XD_UNION except for when auto-computing structure sizes. -- add support for XD_INDIRECT in description offsets (used by extents). -- add support for "description maps", allowing for indirect descriptions that are retrieved from an object at run-time. this generalizes XD_CODING_SYSTEM_END, XD_SPECIFIER_END, etc., which have now been eliminated. -- add a fifth field "flags" to memory_description, to support flags that can be specified for this particular line. Currently defined flags are XD_FLAG_NO_KKCC (KKCC should ignore this entry; useful for the weakness above in markers, etc.), XD_FLAG_NO_PDUMP (pdump should ignore this entry), XD_FLAG_UNION_DEFAULT_ENTRY (in union maps, this specifies a "default" entry for all remaining values), and XD_FLAG_FREE_LISP_OBJECT (for use with lcrecord-lists). -- clean up the kkcc-itis in events, so that the differences between event data as separate objects and as a union are now minimized to a small number of places. with the new XD_UNION, we no longer need event data as separate objects, so this code is no longer ifdef USE_KKCC, but instead ifdef EVENT_DATA_AS_OBJECTS, not used by default. make sure that we explicitly free the separate event data objects when no longer in use, to maintain the invariant the event processing causes no consing. -- also remove other USE_KKCC ifdefs when not necessary. -- allow for KKCC compilation under MS Windows. -- fix README.kkcc. -- dump_add_root_object -> dump_add_root_lisp_object. -- implement dump_add_root_block and use this to handle dump_add_opaque. -- factor out some code duplicated in kkcc and pdump. Other allocation/object-related: -- change various *slots.h so MARKED_SLOT() call no longer includes semicolon. -- free_marker() takes a Lisp_Object not a direct pointer. -- make bit vectors lcrecords, like vectors, and eliminate code that essentially duplicated the lcrecord handling. -- additional asserts in FREE_FIXED_TYPE, formerly duplicated in the various callers of this. -- all lcrecord allocation functions now zero out the returned lcrecords. unnecessary calls to zero_lcrecord removed. add long comment describing these functions. -- extract out process and coding system slots, like for buffers, frames, etc. -- lcrecords now set the type of items sitting on the free list to lcrecord_type_free. -- changes to the way that gap arrays are allocated, for kkcc's benefit -- now, one single memory block with a stretchy array on the end, instead of a separate block holding the array. Error-checking-related: -- now can compile with C++ under MS Windows. clean up compile errors discovered that way. (a few were real problems) -- add C++ error-checking code to verify problems with mismatched GCPRO/UNGCPRO. (there were a few in the kkcc code.) add long comment about how to catch insufficient GCPRO (yes, it's possible using C++). -- add debug_p4(), a simple object printer, when debug_print() doesn't work. -- add dp() and db() as short synonyms of debug_print(), debug_backtrace(). -- `print' tries EXTREMELY hard to avoid core dumping when printing when crashing or from debug_print(), and tries as hard as it reasonably can in other situations. -- Correct the message output upon crashing to be more up-to-date. Event-related: -- document event-matches-key-specifier-p better. -- generalize the dispatch queues formerly duplicated in the various event implementations. add event methods to drain pending events. generalize and clean up QUIT handling, removing event-specific quit processing. allow arbitrary keystrokes, not just ASCII, to be the QUIT char. among other things, this should fix some longstanding bugs in X quit handling. long comment describing the various event queues. -- implement delaying of XFlush() if there are pending expose events. SOMEONE PLEASE TRY THIS OUT. -- Fix `xemacs -batch -l dunnet' under Cygwin. Try to fix under MS Windows but not quite there yet. Other: -- class -> class_ and no more C++ games with this item. new -> new_ in the lwlib code, so far not elsewhere. -- use `struct htentry' not `struct hentry' in elhash.c to avoid debugger confusion with hash.c. -- new macros ALIST_LOOP_3, ALIST_LOOP_4. * README.kkcc: * alloc.c: * alloc.c (deadbeef_memory): * alloc.c (allocate_lisp_storage): * alloc.c (copy_lisp_object): * alloc.c (ALLOCATE_FIXED_TYPE_1): * alloc.c (FREE_FIXED_TYPE): * alloc.c (make_vector_internal): * alloc.c (make_bit_vector_internal): * 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 (struct string_chars_block): * alloc.c (mark_lcrecord_list): * alloc.c (make_lcrecord_list): * alloc.c (alloc_managed_lcrecord): * alloc.c (free_managed_lcrecord): * alloc.c (alloc_automanaged_lcrecord): * alloc.c (staticpro_1): * alloc.c (staticpro): * alloc.c (lispdesc_indirect_count_1): * alloc.c (lispdesc_indirect_description_1): * alloc.c (lispdesc_one_description_line_size): * alloc.c (lispdesc_structure_size): * alloc.c (mark_object_maybe_checking_free): * alloc.c (mark_with_description): * alloc.c (mark_struct_contents): * alloc.c (mark_object): * alloc.c (tick_lcrecord_stats): * alloc.c (free_cons): * alloc.c (free_key_data): * alloc.c (free_button_data): * alloc.c (free_motion_data): * alloc.c (free_process_data): * alloc.c (free_timeout_data): * alloc.c (free_magic_data): * alloc.c (free_magic_eval_data): * alloc.c (free_eval_data): * alloc.c (free_misc_user_data): * alloc.c (free_marker): * alloc.c (compact_string_chars): * alloc.c (gc_sweep): * alloc.c (garbage_collect_1): * alloc.c (Fgarbage_collect): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_early): * alloc.c (init_alloc_once_early): * buffer.c: * buffer.c (mark_buffer): * buffer.c (MARKED_SLOT): * buffer.c (cleanup_buffer_undo_lists): * buffer.c (Fget_file_buffer): * buffer.h (MARKED_SLOT): * bufslots.h: * bytecode.c: * callint.c: * casetab.c: * chartab.c: * chartab.c (symbol_to_char_table_type): * cmdloop.c: * cmdloop.c (Fcommand_loop_1): * config.h.in (new): * conslots.h: * console-gtk-impl.h (struct gtk_frame): * console-impl.h: * console-impl.h (struct console): * console-impl.h (MARKED_SLOT): * console-impl.h (CONSOLE_QUIT_EVENT): * console-msw-impl.h (XM_BUMPQUEUE): * console-msw.c (write_string_to_mswindows_debugging_output): * console-msw.h: * console-stream-impl.h: * console-stream-impl.h (struct stream_console): * console-stream.c: * console-stream.c (stream_init_console): * console-stream.h: * console-tty.c: * console-tty.h: * console-x.h: * console.c: * console.c (mark_console): * console.c (MARKED_SLOT): * console.c (allocate_console): * console.c (get_console_variant): * console.c (create_console): * console.c (delete_console_internal): * console.c (Fset_input_mode): * console.c (Fcurrent_input_mode): * console.c (common_init_complex_vars_of_console): * console.h: * console.h (console_variant): * console.h (device_metrics): * data.c: * data.c (Faref): * data.c (Faset): * data.c (decode_weak_list_type): * database.c: * debug.c (xemacs_debug_loop): * debug.c (FROB): * debug.c (Fadd_debug_class_to_check): * debug.c (Fdelete_debug_class_to_check): * debug.c (Fset_debug_classes_to_check): * debug.c (Fset_debug_class_types_to_check): * debug.c (Fdebug_types_being_checked): * debug.h (DASSERT): * device-gtk.c: * device-impl.h (struct device): * device-impl.h (MARKED_SLOT): * device-msw.c: * device-x.c: * device-x.c (x_init_device_class): * device-x.c (x_comp_visual_info): * device-x.c (x_try_best_visual_class): * device-x.c (x_init_device): * device-x.c (construct_name_list): * device-x.c (x_get_resource_prefix): * device-x.c (Fx_get_resource): * device-x.c (Fx_display_visual_class): * device.c: * device.c (MARKED_SLOT): * device.c (allocate_device): * device.c (Fmake_device): * device.c (delete_device_internal): * device.c (Fset_device_class): * device.h: * devslots.h: * devslots.h (MARKED_SLOT): * dialog-msw.c: * dired-msw.c (mswindows_ls_sort_fcn): * dired-msw.c (mswindows_get_files): * dired-msw.c (mswindows_format_file): * doprnt.c (parse_doprnt_spec): * dumper.c: * dumper.c (struct): * dumper.c (dump_add_root_block): * dumper.c (dump_add_root_struct_ptr): * dumper.c (dump_add_root_lisp_object): * dumper.c (pdump_struct_list_elt): * dumper.c (pdump_get_entry_list): * dumper.c (pdump_backtrace): * dumper.c (pdump_bump_depth): * dumper.c (pdump_register_sub): * dumper.c (pdump_register_object): * dumper.c (pdump_register_struct_contents): * dumper.c (pdump_register_struct): * dumper.c (pdump_store_new_pointer_offsets): * dumper.c (pdump_dump_data): * dumper.c (pdump_reloc_one): * dumper.c (pdump_allocate_offset): * dumper.c (pdump_scan_by_alignment): * dumper.c (pdump_dump_root_blocks): * dumper.c (pdump_dump_rtables): * dumper.c (pdump_dump_root_lisp_objects): * dumper.c (pdump): * dumper.c (pdump_load_finish): * dumper.c (pdump_file_get): * dumper.c (pdump_resource_get): * dumper.c (pdump_load): * editfns.c (save_excursion_restore): * editfns.c (user_login_name): * editfns.c (save_restriction_restore): * elhash.c: * elhash.c (htentry): * elhash.c (struct Lisp_Hash_Table): * elhash.c (HTENTRY_CLEAR_P): * elhash.c (LINEAR_PROBING_LOOP): * elhash.c (check_hash_table_invariants): * elhash.c (mark_hash_table): * elhash.c (hash_table_equal): * elhash.c (print_hash_table_data): * elhash.c (free_hentries): * elhash.c (make_general_lisp_hash_table): * elhash.c (decode_hash_table_weakness): * elhash.c (decode_hash_table_test): * elhash.c (Fcopy_hash_table): * elhash.c (resize_hash_table): * elhash.c (pdump_reorganize_hash_table): * elhash.c (find_htentry): * elhash.c (Fgethash): * elhash.c (Fputhash): * elhash.c (remhash_1): * elhash.c (Fremhash): * elhash.c (Fclrhash): * elhash.c (copy_compress_hentries): * elhash.c (elisp_maphash_unsafe): * elhash.c (finish_marking_weak_hash_tables): * elhash.c (prune_weak_hash_tables): * elhash.h: * emacs.c: * emacs.c (main_1): * emacs.c (main): * emacs.c (shut_down_emacs): * emodules.h (dump_add_root_lisp_object): * eval.c: * eval.c (unwind_to_catch): * eval.c (maybe_signal_error_1): * eval.c (maybe_signal_continuable_error_1): * eval.c (maybe_signal_error): * eval.c (maybe_signal_continuable_error): * eval.c (maybe_signal_error_2): * eval.c (maybe_signal_continuable_error_2): * eval.c (maybe_signal_ferror): * eval.c (maybe_signal_continuable_ferror): * eval.c (maybe_signal_ferror_with_frob): * eval.c (maybe_signal_continuable_ferror_with_frob): * eval.c (maybe_syntax_error): * eval.c (maybe_sferror): * eval.c (maybe_invalid_argument): * eval.c (maybe_invalid_constant): * eval.c (maybe_invalid_operation): * eval.c (maybe_invalid_change): * eval.c (maybe_invalid_state): * eval.c (Feval): * eval.c (call_trapping_problems): * eval.c (call_with_suspended_errors): * eval.c (warn_when_safe_lispobj): * eval.c (warn_when_safe): * eval.c (vars_of_eval): * event-Xt.c: * event-Xt.c (maybe_define_x_key_as_self_inserting_character): * event-Xt.c (x_to_emacs_keysym): * event-Xt.c (x_event_to_emacs_event): * event-Xt.c (emacs_Xt_enqueue_focus_event): * event-Xt.c (emacs_Xt_format_magic_event): * event-Xt.c (emacs_Xt_compare_magic_event): * event-Xt.c (emacs_Xt_hash_magic_event): * event-Xt.c (emacs_Xt_handle_magic_event): * event-Xt.c (Xt_timeout_to_emacs_event): * event-Xt.c (Xt_process_to_emacs_event): * event-Xt.c (signal_special_Xt_user_event): * event-Xt.c (emacs_Xt_next_event): * event-Xt.c (emacs_Xt_event_handler): * event-Xt.c (emacs_Xt_drain_queue): * event-Xt.c (emacs_Xt_event_pending_p): * event-Xt.c (check_if_pending_expose_event): * event-Xt.c (reinit_vars_of_event_Xt): * event-Xt.c (vars_of_event_Xt): * event-gtk.c: * event-gtk.c (IS_MODIFIER_KEY): * event-gtk.c (emacs_gtk_format_magic_event): * event-gtk.c (emacs_gtk_compare_magic_event): * event-gtk.c (emacs_gtk_hash_magic_event): * event-gtk.c (emacs_gtk_handle_magic_event): * event-gtk.c (gtk_to_emacs_keysym): * event-gtk.c (gtk_timeout_to_emacs_event): * event-gtk.c (gtk_process_to_emacs_event): * event-gtk.c (dragndrop_data_received): * event-gtk.c (signal_special_gtk_user_event): * event-gtk.c (emacs_gtk_next_event): * event-gtk.c (gtk_event_to_emacs_event): * event-gtk.c (generic_event_handler): * event-gtk.c (emacs_shell_event_handler): * event-gtk.c (emacs_gtk_drain_queue): * event-gtk.c (emacs_gtk_event_pending_p): * event-gtk.c (reinit_vars_of_event_gtk): * event-gtk.c (vars_of_event_gtk): * event-msw.c: * event-msw.c (struct winsock_stream): * event-msw.c (winsock_reader): * event-msw.c (winsock_writer): * event-msw.c (mswindows_enqueue_dispatch_event): * event-msw.c (mswindows_enqueue_misc_user_event): * event-msw.c (mswindows_enqueue_magic_event): * event-msw.c (mswindows_enqueue_process_event): * event-msw.c (mswindows_enqueue_mouse_button_event): * event-msw.c (mswindows_enqueue_keypress_event): * event-msw.c (mswindows_dequeue_dispatch_event): * event-msw.c (emacs_mswindows_drain_queue): * event-msw.c (mswindows_need_event_in_modal_loop): * event-msw.c (mswindows_need_event): * event-msw.c (mswindows_wm_timer_callback): * event-msw.c (dde_eval_string): * event-msw.c (Fdde_alloc_advise_item): * event-msw.c (mswindows_dde_callback): * event-msw.c (mswindows_wnd_proc): * event-msw.c (remove_timeout_mapper): * event-msw.c (emacs_mswindows_remove_timeout): * event-msw.c (emacs_mswindows_event_pending_p): * event-msw.c (emacs_mswindows_format_magic_event): * event-msw.c (emacs_mswindows_compare_magic_event): * event-msw.c (emacs_mswindows_hash_magic_event): * event-msw.c (emacs_mswindows_handle_magic_event): * event-msw.c (emacs_mswindows_select_console): * event-msw.c (emacs_mswindows_unselect_console): * event-msw.c (reinit_vars_of_event_mswindows): * event-msw.c (vars_of_event_mswindows): * event-stream.c: * event-stream.c (mark_command_builder): * event-stream.c (reset_command_builder_event_chain): * event-stream.c (allocate_command_builder): * event-stream.c (copy_command_builder): * event-stream.c (command_builder_append_event): * event-stream.c (event_stream_event_pending_p): * event-stream.c (event_stream_force_event_pending): * event-stream.c (maybe_read_quit_event): * event-stream.c (event_stream_drain_queue): * event-stream.c (remove_quit_p_event): * event-stream.c (event_stream_quit_p): * event-stream.c (echo_key_event): * event-stream.c (maybe_kbd_translate): * event-stream.c (execute_help_form): * event-stream.c (event_stream_generate_wakeup): * event-stream.c (enqueue_dispatch_event): * event-stream.c (enqueue_magic_eval_event): * event-stream.c (Fenqueue_eval_event): * event-stream.c (enqueue_misc_user_event): * event-stream.c (enqueue_misc_user_event_pos): * event-stream.c (next_event_internal): * event-stream.c (Fnext_event): * event-stream.c (Faccept_process_output): * event-stream.c (execute_internal_event): * event-stream.c (munge_keymap_translate): * event-stream.c (command_builder_find_leaf_no_mule_processing): * event-stream.c (command_builder_find_leaf): * event-stream.c (lookup_command_event): * event-stream.c (is_scrollbar_event): * event-stream.c (execute_command_event): * event-stream.c (Fdispatch_event): * event-stream.c (Fread_key_sequence): * event-stream.c (dribble_out_event): * event-stream.c (vars_of_event_stream): * event-tty.c (tty_timeout_to_emacs_event): * event-tty.c (emacs_tty_next_event): * event-tty.c (emacs_tty_drain_queue): * event-tty.c (reinit_vars_of_event_tty): * event-unixoid.c: * event-unixoid.c (find_tty_or_stream_console_from_fd): * event-unixoid.c (read_event_from_tty_or_stream_desc): * event-unixoid.c (drain_tty_devices): * event-unixoid.c (poll_fds_for_input): * events.c: * events.c (deinitialize_event): * events.c (zero_event): * events.c (mark_event): * events.c (print_event_1): * events.c (print_event): * events.c (event_equal): * events.c (event_hash): * events.c (Fmake_event): * events.c (Fdeallocate_event): * events.c (Fcopy_event): * events.c (map_event_chain_remove): * events.c (character_to_event): * events.c (event_to_character): * events.c (Fevent_to_character): * events.c (format_event_object): * events.c (upshift_event): * events.c (downshift_event): * events.c (event_upshifted_p): * events.c (Fevent_live_p): * events.c (Fevent_type): * events.c (Fevent_timestamp): * events.c (CHECK_EVENT_TYPE): * events.c (CHECK_EVENT_TYPE2): * events.c (CHECK_EVENT_TYPE3): * events.c (Fevent_key): * events.c (Fevent_button): * events.c (Fevent_modifier_bits): * events.c (event_x_y_pixel_internal): * events.c (event_pixel_translation): * events.c (Fevent_process): * events.c (Fevent_function): * events.c (Fevent_object): * events.c (Fevent_properties): * events.c (syms_of_events): * events.c (vars_of_events): * events.h: * events.h (struct event_stream): * events.h (struct Lisp_Key_Data): * events.h (KEY_DATA_KEYSYM): * events.h (EVENT_KEY_KEYSYM): * events.h (struct Lisp_Button_Data): * events.h (EVENT_BUTTON_BUTTON): * events.h (struct Lisp_Motion_Data): * events.h (EVENT_MOTION_X): * events.h (struct Lisp_Process_Data): * events.h (EVENT_PROCESS_PROCESS): * events.h (struct Lisp_Timeout_Data): * events.h (EVENT_TIMEOUT_INTERVAL_ID): * events.h (struct Lisp_Eval_Data): * events.h (EVENT_EVAL_FUNCTION): * events.h (struct Lisp_Misc_User_Data): * events.h (EVENT_MISC_USER_FUNCTION): * events.h (struct Lisp_Magic_Eval_Data): * events.h (EVENT_MAGIC_EVAL_INTERNAL_FUNCTION): * events.h (struct Lisp_Magic_Data): * events.h (EVENT_MAGIC_UNDERLYING): * events.h (EVENT_MAGIC_GDK_EVENT): * events.h (struct Lisp_Event): * events.h (XEVENT_CHANNEL): * events.h (SET_EVENT_TIMESTAMP_ZERO): * events.h (SET_EVENT_CHANNEL): * events.h (SET_EVENT_NEXT): * events.h (XSET_EVENT_TYPE): * events.h (struct command_builder): * extents.c: * extents.c (gap_array_adjust_markers): * extents.c (gap_array_recompute_derived_values): * extents.c (gap_array_move_gap): * extents.c (gap_array_make_gap): * extents.c (gap_array_insert_els): * extents.c (gap_array_delete_els): * extents.c (gap_array_make_marker): * extents.c (gap_array_delete_marker): * extents.c (gap_array_move_marker): * extents.c (make_gap_array): * extents.c (free_gap_array): * extents.c (extent_list_num_els): * extents.c (extent_list_insert): * extents.c (mark_extent_auxiliary): * extents.c (allocate_extent_auxiliary): * extents.c (decode_extent_at_flag): * extents.c (verify_extent_mapper): * extents.c (symbol_to_glyph_layout): * extents.c (syms_of_extents): * faces.c: * file-coding.c: * file-coding.c (struct_detector_category_description =): * file-coding.c (detector_category_dynarr_description_1): * file-coding.c (struct_detector_description =): * file-coding.c (detector_dynarr_description_1): * file-coding.c (MARKED_SLOT): * file-coding.c (mark_coding_system): * file-coding.c (coding_system_extra_description_map): * file-coding.c (coding_system_description): * file-coding.c (allocate_coding_system): * file-coding.c (symbol_to_eol_type): * file-coding.c (Fcoding_system_aliasee): * file-coding.c (set_coding_stream_coding_system): * file-coding.c (struct convert_eol_coding_system): * file-coding.c (struct undecided_coding_system): * file-coding.c (undecided_mark_coding_stream): * file-coding.c (coding_category_symbol_to_id): * file-coding.c (struct gzip_coding_system): * file-coding.c (coding_system_type_create): * file-coding.h: * file-coding.h (struct Lisp_Coding_System): * file-coding.h (CODING_SYSTEM_SLOT_DECLARATION): * file-coding.h (coding_system_variant): * file-coding.h (struct coding_system_methods): * file-coding.h (DEFINE_CODING_SYSTEM_TYPE_WITH_DATA): * file-coding.h (INITIALIZE_CODING_SYSTEM_TYPE_WITH_DATA): * file-coding.h (struct coding_stream): * fileio.c (Fsubstitute_in_file_name): * floatfns.c: * fns.c: * fns.c (base64_encode_1): * frame-gtk.c: * frame-gtk.c (Fgtk_start_drag_internal): * frame-impl.h (struct frame): * frame-impl.h (MARKED_SLOT): * frame-msw.c: * frame-x.c: * frame-x.c (Fcde_start_drag_internal): * frame-x.c (Foffix_start_drag_internal): * frame.c: * frame.c (MARKED_SLOT): * frame.c (allocate_frame_core): * frame.c (delete_frame_internal): * frame.c (Fmouse_position_as_motion_event): * frameslots.h: * frameslots.h (MARKED_SLOT_ARRAY): * free-hook.c: * glyphs-msw.c (mswindows_widget_instantiate): * glyphs-x.c: * glyphs-x.c (convert_EImage_to_XImage): * glyphs.c: * glyphs.c (process_image_string_instantiator): * glyphs.c (mark_image_instance): * glyphs.c (allocate_image_instance): * glyphs.c (unmap_subwindow): * glyphs.c (map_subwindow): * glyphs.c (syms_of_glyphs): * glyphs.c (specifier_type_create_image): * glyphs.h: * glyphs.h (struct text_image_instance): * glyphs.h (struct Lisp_Image_Instance): * gmalloc.c: * gmalloc.c ("C"): * gpmevent.c (Freceive_gpm_event): * gpmevent.c (gpm_next_event_cb): * gpmevent.c (vars_of_gpmevent): * gtk-glue.c (gdk_event_to_emacs_event): * gtk-xemacs.c (gtk_xemacs_class_init): * gui-msw.c: * gui-msw.c (mswindows_handle_gui_wm_command): * gui-msw.c (mswindows_translate_menu_or_dialog_item): * gui-x.c: * gui-x.c (mark_popup_data): * gui-x.c (snarf_widget_value_mapper): * gui-x.c (gcpro_popup_callbacks): * gui-x.c (ungcpro_popup_callbacks): * gui-x.c (free_popup_widget_value_tree): * gui-x.c (popup_selection_callback): * gui-x.h: * gui-x.h (struct popup_data): * gui.c: * gui.c (allocate_gui_item): * gutter.c (decode_gutter_position): * hash.c (NULL_ENTRY): * indent.c (vmotion_1): * indent.c (vmotion_pixels): * input-method-motif.c (res): * input-method-xlib.c (IMInstantiateCallback): * input-method-xlib.c (XIM_init_device): * input-method-xlib.c (res): * intl-encap-win32.c: * intl-encap-win32.c (qxeSHGetDataFromIDList): * intl-win32.c: * intl-win32.c (mswindows_multibyte_cp_type): * intl-win32.c (struct mswindows_multibyte_coding_system): * keymap.c: * keymap.c (make_key_description): * keymap.c (keymap_store): * keymap.c (get_keyelt): * keymap.c (keymap_lookup_1): * keymap.c (define_key_parser): * keymap.c (key_desc_list_to_event): * keymap.c (event_matches_key_specifier_p): * keymap.c (meta_prefix_char_p): * keymap.c (ensure_meta_prefix_char_keymapp): * keymap.c (Fdefine_key): * keymap.c (struct raw_lookup_key_mapper_closure): * keymap.c (raw_lookup_key): * keymap.c (raw_lookup_key_mapper): * keymap.c (lookup_keys): * keymap.c (lookup_events): * keymap.c (Flookup_key): * keymap.c (struct map_keymap_unsorted_closure): * keymap.c (map_keymap_unsorted_mapper): * keymap.c (map_keymap_sorted): * keymap.c (map_keymap_mapper): * keymap.c (map_keymap): * keymap.c (accessible_keymaps_mapper_1): * keymap.c (Faccessible_keymaps): * keymap.c (Fsingle_key_description): * keymap.c (raw_keys_to_keys): * keymap.c (format_raw_keys): * keymap.c (where_is_recursive_mapper): * keymap.c (where_is_internal): * keymap.c (describe_map_mapper_shadow_search): * keymap.c (keymap_lookup_inherited_mapper): * keymap.c (describe_map_mapper): * keymap.h (event_matches_key_specifier_p): * lisp.h: * lisp.h (this): * lisp.h (RETURN_NOT_REACHED): * lisp.h (struct Lisp_Vector): * lisp.h (struct Lisp_Bit_Vector): * lisp.h (UNGCPRO_1): * lisp.h (NUNGCPRO): * lisp.h (NNUNGCPRO): * lisp.h (DECLARE_INLINE_HEADER): * lrecord.h: * lrecord.h (struct lrecord_header): * lrecord.h (struct lcrecord_header): * lrecord.h (lrecord_type): * lrecord.h (struct lrecord_implementation): * lrecord.h (RECORD_DUMPABLE): * lrecord.h (memory_description_type): * lrecord.h (data_description_entry_flags): * lrecord.h (struct memory_description): * lrecord.h (struct sized_memory_description): * lrecord.h (XD_INDIRECT): * lrecord.h (XD_IS_INDIRECT): * lrecord.h (XD_DYNARR_DESC): * lrecord.h (DEFINE_BASIC_LRECORD_IMPLEMENTATION): * lrecord.h (MAKE_LRECORD_IMPLEMENTATION): * lrecord.h (MAKE_EXTERNAL_LRECORD_IMPLEMENTATION): * lrecord.h (alloc_lcrecord_type): * lstream.c: * lstream.c (Lstream_new): * lstream.c (lisp_buffer_marker): * lstream.h: * lstream.h (lstream_implementation): * lstream.h (DEFINE_LSTREAM_IMPLEMENTATION): * lstream.h (DEFINE_LSTREAM_IMPLEMENTATION_WITH_DATA): * marker.c: * marker.c (copy_marker_1): * mem-limits.h: * menubar-gtk.c: * menubar-gtk.c (gtk_popup_menu): * menubar-msw.c: * menubar-msw.c (mswindows_popup_menu): * menubar-x.c (make_dummy_xbutton_event): * menubar-x.c (command_builder_operate_menu_accelerator): * menubar-x.c (menu_accelerator_safe_compare): * menubar-x.c (menu_accelerator_safe_mod_compare): * mule-charset.c: * mule-charset.c (make_charset): * mule-charset.c (Fcharset_property): * mule-coding.c: * mule-coding.c (ccs_description_1): * mule-coding.c (ccs_description =): * mule-coding.c (ccsd_description_1): * mule-coding.c (ccsd_description =): * nt.c (getpwnam): * nt.c (init_mswindows_environment): * nt.c (get_cached_volume_information): * nt.c (mswindows_is_executable): * nt.c (read_unc_volume): * nt.c (mswindows_access): * nt.c (mswindows_link): * nt.c (mswindows_fstat): * nt.c (mswindows_stat): * nt.c (mswindows_executable_type): * nt.c (Fmswindows_short_file_name): * nt.c (Fmswindows_long_file_name): * objects-impl.h (struct Lisp_Color_Instance): * objects-impl.h (struct Lisp_Font_Instance): * objects-tty.c: * objects-x.c (allocate_nearest_color): * objects.c: * objects.c (Fmake_color_instance): * objects.c (Fmake_font_instance): * objects.c (font_instantiate): * opaque.c: * opaque.c (make_opaque): * opaque.c (make_opaque_ptr): * opaque.c (reinit_opaque_early): * opaque.c (init_opaque_once_early): * print.c: * print.c (printing_badness): * print.c (printing_major_badness): * print.c (print_internal): * print.c (debug_p4): * print.c (dp): * print.c (debug_backtrace): * process-nt.c (nt_create_process): * process-nt.c (get_internet_address): * process-unix.c: * process-unix.c (struct unix_process_data): * process-unix.c (get_internet_address): * process-unix.c (unix_alloc_process_data): * process-unix.c (unix_create_process): * process-unix.c (try_to_initialize_subtty): * process-unix.c (unix_kill_child_process): * process-unix.c (process_type_create_unix): * process.c: * process.c (mark_process): * process.c (MARKED_SLOT): * process.c (make_process_internal): * process.c (Fprocess_tty_name): * process.c (decode_signal): * process.h: * procimpl.h: * procimpl.h (struct process_methods): * procimpl.h (struct Lisp_Process): * rangetab.c: * realpath.c (readlink_and_correct_case): * redisplay-x.c (x_window_output_end): * redisplay-x.c (x_redraw_exposed_area): * redisplay-x.c (x_clear_frame): * redisplay.c: * redisplay.h: * redisplay.h (struct rune_dglyph): * redisplay.h (struct rune): * scrollbar.c: * scrollbar.c (create_scrollbar_instance): * specifier.c: * specifier.c (specifier_empty_extra_description_1): * specifier.c (make_specifier_internal): * specifier.c (decode_locale_type): * specifier.c (decode_how_to_add_specification): * specifier.h: * specifier.h (struct specifier_methods): * specifier.h (DEFINE_SPECIFIER_TYPE_WITH_DATA): * specifier.h (INITIALIZE_SPECIFIER_TYPE_WITH_DATA): * symbols.c: * symbols.c (Fsetplist): * symbols.c (default_value): * symbols.c (decode_magic_handler_type): * symbols.c (handler_type_from_function_symbol): * symbols.c (Fdefvaralias): * symbols.c (init_symbols_once_early): * symbols.c (reinit_symbols_early): * symsinit.h: * sysdep.c (sys_subshell): * sysdep.c (tty_init_sys_modes_on_device): * syswindows.h: * text.c (dfc_convert_to_external_format): * text.c (dfc_convert_to_internal_format): * text.c (reinit_eistring_early): * text.c (init_eistring_once_early): * text.c (reinit_vars_of_text): * text.h: * text.h (INC_IBYTEPTR_FMT): * text.h (DEC_IBYTEPTR_FMT): * toolbar.c: * toolbar.c (decode_toolbar_position): * tooltalk.c: * ui-gtk.c: * unexnt.c: * unexnt.c (_start): * unexnt.c (unexec): * unexnt.c (get_section_info): * unicode.c: * unicode.c (vars_of_unicode): * window.c: * window.c (allocate_window): * window.c (new_window_mirror): * window.c (update_mirror_internal): * winslots.h:
author michaels
date Sun, 12 Jan 2003 11:08:22 +0000
parents 25e260cb7994
children 4542b72c005e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* The "lrecord" structure (header of a compound lisp object).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3 Copyright (C) 1996, 2001, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
24 #ifndef INCLUDED_lrecord_h_
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
25 #define INCLUDED_lrecord_h_
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* The "lrecord" type of Lisp object is used for all object types
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 other than a few simple ones. This allows many types to be
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 implemented but only a few bits required in a Lisp object for type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
30 information. (The tradeoff is that each object has its type marked
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
31 in it, thereby increasing its size.) All lrecords begin with a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
32 `struct lrecord_header', which identifies the lisp object type, by
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
33 providing an index into a table of `struct lrecord_implementation',
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
34 which describes the behavior of the lisp object. It also contains
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
35 some other data bits.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 Lrecords are of two types: straight lrecords, and lcrecords.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 Straight lrecords are used for those types of objects that have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 their own allocation routines (typically allocated out of 2K chunks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 of memory called `frob blocks'). These objects have a `struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 lrecord_header' at the top, containing only the bits needed to find
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 the lrecord_implementation for the object. There are special
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
43 routines in alloc.c to create an object of each such type.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45 Lcrecords are used for less common sorts of objects that don't do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46 their own allocation. Each such object is malloc()ed individually,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 and the objects are chained together through a `next' pointer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 Lcrecords have a `struct lcrecord_header' at the top, which
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49 contains a `struct lrecord_header' and a `next' pointer, and are
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
50 allocated using alloc_lcrecord_type() or its variants.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Creating a new lcrecord type is fairly easy; just follow the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 lead of some existing type (e.g. hash tables). Note that you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 do not need to supply all the methods (see below); reasonable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 defaults are provided for many of them. Alternatively, if you're
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 just looking for a way of encapsulating data (which possibly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 could contain Lisp_Objects in it), you may well be able to use
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
58 the opaque type. --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
59 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 struct lrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
63 /* Index into lrecord_implementations_table[]. Objects that have been
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
64 explicitly freed using e.g. free_cons() have lrecord_type_free in this
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
65 field. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 unsigned int type :8;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
67
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 /* If `mark' is 0 after the GC mark phase, the object will be freed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 during the GC sweep phase. There are 2 ways that `mark' can be 1:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
70 - by being referenced from other objects during the GC mark phase
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
71 - because it is permanently on, for c_readonly objects */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
72 unsigned int mark :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
73
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
74 /* 1 if the object resides in logically read-only space, and does not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
75 reference other non-c_readonly objects.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
76 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
77 unsigned int c_readonly :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
78
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 /* 1 if the object is readonly from lisp */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
80 unsigned int lisp_readonly :1;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
81
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
82 unsigned int unused :21;
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
83
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 struct lrecord_implementation;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
87 int lrecord_type_index (const struct lrecord_implementation *implementation);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
89 #define set_lheader_implementation(header,imp) do { \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 struct lrecord_header* SLI_header = (header); \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
91 SLI_header->type = (imp)->lrecord_type_index; \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
92 SLI_header->mark = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
93 SLI_header->c_readonly = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
94 SLI_header->lisp_readonly = 0; \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 struct lcrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 struct lrecord_header lheader;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
101 /* The `next' field is normally used to chain all lcrecords together
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 so that the GC can find (and free) all of them.
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
103 `basic_alloc_lcrecord' threads lcrecords together.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 The `next' field may be used for other purposes as long as some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 other mechanism is provided for letting the GC do its work.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 For example, the event and marker object types allocate members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 out of memory chunks, and are able to find all unmarked members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 by sweeping through the elements of the list of chunks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 struct lcrecord_header *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 /* The `uid' field is just for debugging/printing convenience.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 Having this slot doesn't hurt us much spacewise, since an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 lcrecord already has the above slots plus malloc overhead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 unsigned int uid :31;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 /* The `free' field is a flag that indicates whether this lcrecord
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 is on a "free list". Free lists are used to minimize the number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 of calls to malloc() when we're repeatedly allocating and freeing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 a number of the same sort of lcrecord. Lcrecords on a free list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 always get marked in a different fashion, so we can use this flag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 as a sanity check to make sure that free lists only have freed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 lcrecords and there are no freed lcrecords elsewhere. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 unsigned int free :1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 /* Used for lcrecords in an lcrecord-list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 struct free_lcrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 struct lcrecord_header lcheader;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 Lisp_Object chain;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
137 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
138 #### This should be replaced by a symbol_value_magic_p flag
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 in the Lisp_Symbol lrecord_header. */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
140 lrecord_type_symbol_value_forward, /* 0 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
141 lrecord_type_symbol_value_varalias, /* 1 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
142 lrecord_type_symbol_value_lisp_magic, /* 2 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
143 lrecord_type_symbol_value_buffer_local, /* 3 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
146 lrecord_type_symbol, /* 4 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
147 lrecord_type_subr, /* 5 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
148 lrecord_type_cons, /* 6 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 lrecord_type_vector,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 lrecord_type_string,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 lrecord_type_lcrecord_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 lrecord_type_compiled_function,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 lrecord_type_weak_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154 lrecord_type_bit_vector,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
155 lrecord_type_float,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 lrecord_type_hash_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
157 lrecord_type_lstream,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158 lrecord_type_process,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159 lrecord_type_charset,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
160 lrecord_type_coding_system,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
161 lrecord_type_char_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
162 lrecord_type_char_table_entry,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
163 lrecord_type_range_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
164 lrecord_type_opaque,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
165 lrecord_type_opaque_ptr,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
166 lrecord_type_buffer,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
167 lrecord_type_extent,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168 lrecord_type_extent_info,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 lrecord_type_extent_auxiliary,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
170 lrecord_type_marker,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 lrecord_type_event,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
172 #ifdef EVENT_DATA_AS_OBJECTS
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
173 lrecord_type_key_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
174 lrecord_type_button_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
175 lrecord_type_motion_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
176 lrecord_type_process_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
177 lrecord_type_timeout_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
178 lrecord_type_eval_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
179 lrecord_type_misc_user_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
180 lrecord_type_magic_eval_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
181 lrecord_type_magic_data,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
182 #endif /* EVENT_DATA_AS_OBJECTS */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183 lrecord_type_keymap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
184 lrecord_type_command_builder,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
185 lrecord_type_timeout,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
186 lrecord_type_specifier,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
187 lrecord_type_console,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
188 lrecord_type_device,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 lrecord_type_frame,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 lrecord_type_window,
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
191 lrecord_type_window_mirror,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
192 lrecord_type_window_configuration,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
193 lrecord_type_gui_item,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
194 lrecord_type_popup_data,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
195 lrecord_type_toolbar_button,
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
196 lrecord_type_scrollbar_instance,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
197 lrecord_type_color_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
198 lrecord_type_font_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
199 lrecord_type_image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
200 lrecord_type_glyph,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
201 lrecord_type_face,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
202 lrecord_type_database,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
203 lrecord_type_tooltalk_message,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
204 lrecord_type_tooltalk_pattern,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
205 lrecord_type_ldap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
206 lrecord_type_pgconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
207 lrecord_type_pgresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
208 lrecord_type_devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
209 lrecord_type_mswindows_dialog_id,
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
210 lrecord_type_case_table,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
211 lrecord_type_emacs_ffi,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
212 lrecord_type_emacs_gtk_object,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
213 lrecord_type_emacs_gtk_boxed,
858
2c12fe2da451 [xemacs-hg @ 2002-05-31 09:38:45 by michaels]
michaels
parents: 826
diff changeset
214 lrecord_type_weak_box,
888
201c016cfc12 [xemacs-hg @ 2002-06-28 14:24:07 by michaels]
michaels
parents: 867
diff changeset
215 lrecord_type_ephemeron,
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
216 lrecord_type_free, /* only used for "free" lrecords */
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
217 lrecord_type_undefined, /* only used for debugging */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 lrecord_type_last_built_in_type /* must be last */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
219 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
220
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
221 extern int lrecord_type_count;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 struct lrecord_implementation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
225 const char *name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
226
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
227 /* information for the dumper: is the object dumpable and should it
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
228 be dumped. */
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
229 unsigned int dumpable :1;
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
230
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
231 /* `marker' is called at GC time, to make sure that all Lisp_Objects
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 pointed to by this object get properly marked. It should call
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 the mark_object function on all Lisp_Objects in the object. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 the return value is non-nil, it should be a Lisp_Object to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 marked (don't call the mark_object function explicitly on it,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 because the GC routines will do this). Doing it this way reduces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 recursion, so the object returned should preferably be the one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 with the deepest level of Lisp_Object pointers. This function
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
239 can be NULL, meaning no GC marking is necessary.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
240
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
241 NOTE NOTE NOTE: This is not used by KKCC (which uses the data
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
242 description below instead), unless the data description is missing.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
243 Yes, this currently means there is logic duplication. Eventually the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
244 mark methods will be removed. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 Lisp_Object (*marker) (Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
246
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
247 /* `printer' converts the object to a printed representation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
248 This can be NULL; in this case default_object_printer() will be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
249 used instead. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
251
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
252 /* `finalizer' is called at GC time when the object is about to
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 be freed, and at dump time (FOR_DISKSAVE will be non-zero in this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 case). It should perform any necessary cleanup (e.g. freeing
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
255 malloc()ed memory). This can be NULL, meaning no special
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 finalization is necessary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 WARNING: remember that `finalizer' is called at dump time even
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 though the object is not being freed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 void (*finalizer) (void *header, int for_disksave);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 /* This can be NULL, meaning compare objects with EQ(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
264
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
265 /* `hash' generates hash values for use with hash tables that have
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
266 `equal' as their test function. This can be NULL, meaning use
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
267 the Lisp_Object itself as the hash. But, you must still satisfy
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 the constraint that if two objects are `equal', then they *must*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
269 hash to the same value in order for hash tables to work properly.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
270 This means that `hash' can be NULL only if the `equal' method is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 also NULL. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 unsigned long (*hash) (Lisp_Object, int);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
274 /* Data layout description for your object. See long comment below. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
275 const struct memory_description *description;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
277 /* These functions allow any object type to have builtin property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
278 lists that can be manipulated from the lisp level with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
279 `get', `put', `remprop', and `object-plist'. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 Lisp_Object (*plist) (Lisp_Object obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
285 /* Only one of `static_size' and `size_in_bytes_method' is non-0.
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
286 If both are 0, this type is not instantiable by basic_alloc_lcrecord(). */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
287 Bytecount static_size;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
288 Bytecount (*size_in_bytes_method) (const void *header);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
289
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
290 /* The (constant) index into lrecord_implementations_table */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
291 enum lrecord_type lrecord_type_index;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
292
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 one that does not have an lcrecord_header at the front and which
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
295 is (usually) allocated in frob blocks. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 unsigned int basic_p :1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
299 /* All the built-in lisp object types are enumerated in `enum lrecord_type'.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
300 Additional ones may be defined by a module (none yet). We leave some
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
301 room in `lrecord_implementations_table' for such new lisp object types. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
302 #define MODULE_DEFINABLE_TYPE_COUNT 32
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
304 extern const struct lrecord_implementation *lrecord_implementations_table[lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
308 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 extern int gc_in_progress;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
319 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
320 struct lrecord_header *SCRRH_lheader = (lheader); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321 SCRRH_lheader->c_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322 SCRRH_lheader->lisp_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 SCRRH_lheader->mark = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
324 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 ((void) ((lheader)->lisp_readonly = 1))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
329 #define RECORD_DUMPABLE(lheader) (lrecord_implementations_table[(lheader)->type])->dumpable
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
330
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
331 /* Data description stuff
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
332
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
333 Data layout descriptions describe blocks of memory (in particular, Lisp
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
334 objects and other objects on the heap, and global objects with pointers
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
335 to such heap objects), including their size and a list of the elements
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
336 that need relocating, marking or other special handling. They are
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
337 currently used in two places: by pdump [the new, portable dumper] and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
338 KKCC [the new garbage collector]. The two subsystems use the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
339 descriptions in different ways, and as a result some of the descriptions
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
340 are appropriate only for one or the other, when it is known that only
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
341 that subsystem will use the description. (This is particularly the case
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
342 with objects that can't be dumped, because pdump needs more info than
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
343 KKCC.) However, properly written descriptions are appropriate for both,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
344 and you should strive to write your descriptions that way, since the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
345 dumpable status of an object may change and new uses for the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
346 descriptions may be created. (An example that comes to mind is a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
347 facility for determining the memory usage of XEmacs data structures --
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
348 like `buffer-memory-usage', `window-memory-usage', etc. but more
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
349 general.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
350
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
351 More specifically:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
353 Pdump (the portable dumper) needs to write out all objects in heap
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
354 space, and later on (in another invocation of XEmacs) load them back
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
355 into the heap, relocating all pointers to the heap objects in the global
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
356 data space. ("Heap" means anything malloc()ed, including all Lisp
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
357 objects, and "global data" means anything declared globally or
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
358 `static'.) Pdump, then, needs to be told about the location of all
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
359 global pointers to heap objects, all the description of all such
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
360 objects, including their size and any pointers to other heap (aka
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
361 "relocatable") objects. (Pdump assumes that the heap may occur in
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
362 different places in different invocations -- therefore, it is not enough
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
363 simply to write out the entire heap and later reload it at the same
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
364 location -- but that global data is always in the same place, and hence
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
365 pointers to it do not need to be relocated. This assumption holds true
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
366 in general for modern operating systems, but would be broken, for
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
367 example, in a system without virtual memory, or when dealing with shared
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
368 libraries. Also, unlike unexec, pdump does not usually write out or
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
369 restore objects in the global data space, and thus they need to be
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
370 initialized every time XEmacs is loaded. This is the purpose of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
371 reinit_*() functions throughout XEmacs. [It's possible, however, to make
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
372 pdump restore global data. This must be done, of course, for heap
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
373 pointers, but is also done for other values that are not easy to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
374 recompute -- in particular, values established by the Lisp code loaded
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
375 at dump time.]) Note that the data type `Lisp_Object' is basically just
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
376 a relocatable pointer disguised as a long, and in general pdump treats
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
377 the Lisp_Object values and pointers to Lisp objects (e.g. Lisp_Object
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
378 vs. `struct frame *') identically. (NOTE: This equivalence depends
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
379 crucially on the current "minimal tagbits" implementation of Lisp_Object
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
380 pointers.)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
382 Descriptions are used by pdump in three places: (a) descriptions of Lisp
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
383 objects, referenced in the DEFINE_*LRECORD_*IMPLEMENTATION*() call; (b)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
384 descriptions of global objects to be dumped, registered by
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
385 dump_add_root_block(); (c) descriptions of global pointers to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
386 non-Lisp_Object heap objects, registered by dump_add_root_struct_ptr().
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
387 The descriptions need to tell pdump which elements of your structure are
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
388 Lisp_Objects or structure pointers, plus the descriptions in turn of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
389 non-Lisp_Object structures pointed to. If these structures are you own
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
390 private ones, you will have to write these recursive descriptions
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
391 yourself; otherwise, you are reusing a structure already in existence
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
392 elsewhere and there is probably already a description for it.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
393
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
394 Pdump does not care about Lisp objects that cannot be dumped (the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
395 dumpable flag to DEFINE_*LRECORD_*IMPLEMENTATION*() is 0).
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
396
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
397 KKCC also uses data layout descriptions, but differently. It cares
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
398 about all objects, dumpable or not, but specifically only wants to know
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
399 about Lisp_Objects in your object and in structures pointed to. Thus,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
400 it doesn't care about things like pointers to structures ot other blocks
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
401 of memory with no Lisp Objects in them, which pdump would care a lot
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
402 about.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
403
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
404 Technically, then, you could write your description differently
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
405 depending on whether your object is dumpable -- the full pdump
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
406 description if so, the abbreviated KKCC description if not. In fact,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
407 some descriptions are written this way. This is dangerous, though,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
408 because another use might come along for the data descriptions, that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
409 doesn't care about the dumper flag and makes use of some of the stuff
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
410 normally omitted from the "abbreviated" description -- see above.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
411
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
412 A memory_description is an array of values. (This is actually
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
413 misnamed, in that it does not just describe lrecords, but any
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
414 blocks of memory.) The first value of each line is a type, the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
415 second the offset in the lrecord structure. The third and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
416 following elements are parameters; their presence, type and number
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
417 is type-dependent.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
418
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
419 The description ends with an "XD_END" record.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
420
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
421 The top-level description of an lrecord or lcrecord does not need
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
422 to describe every element, just the ones that need to be relocated,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
423 since the size of the lrecord is known. (The same goes for nested
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
424 structures, whenever the structure size is given, rather than being
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
425 defaulted by specifying 0 for the size.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
426
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
427 A sized_memory_description is a memory_description plus the size of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
428 block of memory. The size field in a sized_memory_description can be
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
429 given as zero, i.e. unspecified, meaning that the last element in the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
430 structure is described in the description and the size of the block can
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
431 therefore be computed from it. (This is useful for stretchy arrays.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
432
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
433 memory_descriptions are used to describe lrecords (the size of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
434 lrecord is elsewhere in its description, attached to its methods, so it
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
435 does not need to be given here) and global objects, where the size is an
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
436 argument to the call to dump_add_root_block().
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
437 sized_memory_descriptions are used for pointers and arrays in
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
438 memory_descriptions and for calls to dump_add_root_struct_ptr(). (####
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
439 It is not obvious why this is so in the latter case. Probably, calls to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
440 dump_add_root_struct_ptr() should use plain memory_descriptions and have
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
441 the size be an argument to the call.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
442
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
443 NOTE: Anywhere that a sized_memory_description occurs inside of a plain
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
444 memory_description, a "description map" can be substituted. Rather than
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
445 being an actual description, this describes how to find the description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
446 by looking inside of the object being described. This is a convenient
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
447 way to describe Lisp objects with subtypes and corresponding
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
448 type-specific data.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 Some example descriptions :
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
451
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
452 struct Lisp_String
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
453 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
454 struct lrecord_header lheader;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
455 Bytecount size;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 858
diff changeset
456 Ibyte *data;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
457 Lisp_Object plist;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
458 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
459
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
460 static const struct memory_description cons_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
461 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
462 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
466 Which means "two lisp objects starting at the 'car' and 'cdr' elements"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
468 static const struct memory_description string_description[] = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
469 { XD_BYTECOUNT, offsetof (Lisp_String, size) },
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
470 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT (0, 1) },
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
471 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
472 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
473 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
474
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
475 "A pointer to string data at 'data', the size of the pointed array being
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
476 the value of the size variable plus 1, and one lisp object at 'plist'"
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
477
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
478 If your object has a pointer to an array of Lisp_Objects in it, something
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
479 like this:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
480
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
481 struct Lisp_Foo
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
482 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
483 ...;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
484 int count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
485 Lisp_Object *objects;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
486 ...;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
487 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
488
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
489 You'd use XD_STRUCT_PTR, something like:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
490
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
491 static const struct memory_description foo_description[] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
492 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
493 { XD_INT, offsetof (Lisp_Foo, count) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
494 { XD_STRUCT_PTR, offsetof (Lisp_Foo, objects),
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
495 XD_INDIRECT (0, 0), &lisp_object_description },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
496 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
497 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
498
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
499 lisp_object_description is declared in alloc.c, like this:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
500
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
501 static const struct memory_description lisp_object_description_1[] = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
502 { XD_LISP_OBJECT, 0 },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
503 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
504 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
505
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
506 const struct sized_memory_description lisp_object_description = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
507 sizeof (Lisp_Object),
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
508 lisp_object_description_1
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
509 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
510
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
511 Another example of XD_STRUCT_PTR:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
513 typedef struct htentry
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
514 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
515 Lisp_Object key;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
516 Lisp_Object value;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
517 } htentry;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
518
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
519 struct Lisp_Hash_Table
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
520 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
521 struct lcrecord_header header;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
522 Elemcount size;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
523 Elemcount count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
524 Elemcount rehash_count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
525 double rehash_size;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
526 double rehash_threshold;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
527 Elemcount golden_ratio;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
528 hash_table_hash_function_t hash_function;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
529 hash_table_test_function_t test_function;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
530 htentry *hentries;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
531 enum hash_table_weakness weakness;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
532 Lisp_Object next_weak; // Used to chain together all of the weak
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
533 // hash tables. Don't mark through this.
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
534 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
535
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
536 static const struct memory_description htentry_description_1[] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
537 { XD_LISP_OBJECT, offsetof (htentry, key) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
538 { XD_LISP_OBJECT, offsetof (htentry, value) },
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
539 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
540 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
541
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
542 static const struct sized_memory_description htentry_description = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
543 sizeof (htentry),
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
544 htentry_description_1
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
545 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
546
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
547 const struct memory_description hash_table_description[] = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
548 { XD_ELEMCOUNT, offsetof (Lisp_Hash_Table, size) },
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
549 { XD_STRUCT_PTR, offsetof (Lisp_Hash_Table, hentries), XD_INDIRECT (0, 1),
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
550 &htentry_description },
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
551 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
552 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
553 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
554
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
555 Note that we don't need to declare all the elements in the structure, just
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
556 the ones that need to be relocated (Lisp_Objects and structures) or that
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
557 need to be referenced as counts for relocated objects.
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
558
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
559 A description map looks like this:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
560
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
561 static const struct sized_memory_description specifier_extra_description_map [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
562 { offsetof (Lisp_Specifier, methods) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
563 { offsetof (struct specifier_methods, extra_description) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
564 { -1 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
565 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
566
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
567 const struct memory_description specifier_description[] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
568 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
569 { XD_STRUCT_ARRAY, offset (Lisp_Specifier, data), 1,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
570 specifier_extra_description_map },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
571 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
572 { XD_END }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
573 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
574
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
575 This would be appropriate for an object that looks like this:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
576
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
577 struct specifier_methods
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
578 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
579 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
580 const struct sized_memory_description *extra_description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
581 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
582 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
583
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
584 struct Lisp_Specifier
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
585 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
586 struct lcrecord_header header;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
587 struct specifier_methods *methods;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
588
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
589 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
590 // type-specific extra data attached to a specifier
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
591 max_align_t data[1];
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
592 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
593
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
594 The description map means "retrieve a pointer into the object at offset
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
595 `offsetof (Lisp_Specifier, methods)' , then in turn retrieve a pointer
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
596 into that object at offset `offsetof (struct specifier_methods,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
597 extra_description)', and that is the sized_memory_description to use."
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
598 There can be any number of indirections, which can be either into
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
599 straight pointers or Lisp_Objects. The way that description maps are
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
600 distinguished from normal sized_memory_descriptions is that in the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
601 former, the memory_description pointer is NULL.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
602
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
603 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
604
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
605
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
606 The existing types :
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
607
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
608
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 XD_LISP_OBJECT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
610
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
611 A Lisp object. This is also the type to use for pointers to other lrecords
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
612 (e.g. struct frame *).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
614 XD_LISP_OBJECT_ARRAY
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
615
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
616 An array of Lisp objects or (equivalently) pointers to lrecords.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
617 The parameter (i.e. third element) is the count. This would be declared
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
618 as Lisp_Object foo[666]. For something declared as Lisp_Object *foo,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
619 use XD_STRUCT_PTR, whose description parameter is a sized_memory_description
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
620 consisting of only XD_LISP_OBJECT and XD_END.
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
621
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 XD_LO_LINK
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
623
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
624 Weak link in a linked list of objects of the same type. This is a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
625 link that does NOT generate a GC reference. Thus the pdumper will
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
626 not automatically add the referenced object to the table of all
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
627 objects to be dumped, and when storing and loading the dumped data
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
628 will automatically prune unreferenced objects in the chain and link
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
629 each referenced object to the next referenced object, even if it's
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
630 many links away. We also need to special handling of a similar
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
631 nature for the root of the chain, which will be a staticpro()ed
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
632 object.
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
633
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 XD_OPAQUE_PTR
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
635
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 Pointer to undumpable data. Must be NULL when dumping.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 XD_STRUCT_PTR
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
639
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
640 Pointer to block of described memory. (This is misnamed: It is NOT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
641 necessarily a pointer to a struct foo.) Parameters are number of
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
642 contiguous blocks and sized_memory_description.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
643
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
644 XD_STRUCT_ARRAY
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
645
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
646 Array of blocks of described memory. Parameters are number of
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
647 structures and sized_memory_description. This differs from XD_STRUCT_PTR
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
648 in that the parameter is declared as struct foo[666] instead of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
649 struct *foo. In other words, the block of memory holding the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
650 structures is within the containing structure, rather than being
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
651 elsewhere, with a pointer in the containing structure.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
653 NOTE NOTE NOTE: Be sure that you understand the difference between
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
654 XD_STRUCT_PTR and XD_STRUCT_ARRAY:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
655 - struct foo bar[666], i.e. 666 inline struct foos
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
656 --> XD_STRUCT_ARRAY, argument 666, pointing to a description of
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
657 struct foo
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
658 - struct foo *bar, i.e. pointer to a block of 666 struct foos
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
659 --> XD_STRUCT_PTR, argument 666, pointing to a description of
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
660 struct foo
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
661 - struct foo *bar[666], i.e. 666 pointers to separate blocks of struct foos
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
662 --> XD_STRUCT_ARRAY, argument 666, pointing to a description of
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
663 a single pointer to struct foo; the description is a single
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
664 XD_STRUCT_PTR, argument 1, which in turn points to a description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
665 of struct foo.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
666
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 XD_OPAQUE_DATA_PTR
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
668
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 Pointer to dumpable opaque data. Parameter is the size of the data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 Pointed data must be relocatable without changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
672 XD_UNION
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
673
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
674 Union of two or more different types of data. Parameters are a constant
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
675 which determines which type the data is (this is usually an XD_INDIRECT,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
676 referring to one of the fields in the structure), and a "sizing lobby" (a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
677 sized_memory_description, which points to a memory_description and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
678 indicates its size). The size field in the sizing lobby describes the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
679 size of the union field in the object, and the memory_description in it
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
680 is referred to as a "union map" and has a special interpretation: The
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
681 offset field is replaced by a constant, which is compared to the first
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
682 parameter of the XD_UNION descriptor to determine if this description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
683 applies to the union data, and XD_INDIRECT references refer to the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
684 containing object and description. Note that the description applies
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
685 "inline" to the union data, like XD_STRUCT_ARRAY and not XD_STRUCT_PTR.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
686 If the union data is a pointer to different types of structures, each
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
687 element in the memory_description should be an XD_STRUCT_PTR. See
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
688 unicode.c, redisplay.c and objects.c for examples of XD_UNION.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
689
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
690 XD_UNION_DYNAMIC_SIZE
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
691
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
692 Same as XD_UNION except that this is used for objects where the size of
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
693 the object containing the union varies depending on the particular value
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
694 of the union constant. That is, an object with plain XD_UNION typically
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
695 has the union declared as `union foo' or as `void *', where an object
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
696 with XD_UNION_DYNAMIC_SIZE typically has the union as the last element,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
697 and declared as something like char foo[1]. With plain XD_UNION, the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
698 object is (usually) of fixed size and always contains enough space for
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
699 the data associated with all possible union constants, and thus the union
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
700 constant can potentially change during the lifetime of the object. With
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
701 XD_UNION_DYNAMIC_SIZE, however, the union constant is fixed at the time
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
702 of creation of the object, and the size of the object is computed
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
703 dynamically at creation time based on the size of the data associated
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
704 with the union constant. Currently, the only difference between XD_UNION
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
705 and XD_UNION_DYNAMIC_SIZE is how the size of the union data is
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
706 calculated, when (a) the structure containing the union has no size
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
707 given; (b) the union occurs as the last element in the structure; and (c)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
708 the union has no size given (in the first-level sized_memory_description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
709 pointed to). In this circumstance, the size of XD_UNION comes from the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
710 max size of the data associated with all possible union constants,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
711 whereas the size of XD_UNION_DYNAMIC_SIZE comes from the size of the data
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
712 associated with the currently specified (and unchangeable) union
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
713 constant.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
714
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 XD_C_STRING
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
716
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 Pointer to a C string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 XD_DOC_STRING
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
720
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 Pointer to a doc string (C string if positive, opaque value if negative)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 XD_INT_RESET
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
724
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 An integer which will be reset to a given value in the dump file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
727 XD_ELEMCOUNT
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
728
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
729 Elemcount value. Used for counts.
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
730
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
731 XD_BYTECOUNT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
732
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
733 Bytecount value. Used for counts.
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
734
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
735 XD_HASHCODE
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
736
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
737 Hashcode value. Used for the results of hashing functions.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 XD_INT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
740
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 int value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 XD_LONG
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
744
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 long value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
747 XD_BYTECOUNT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
748
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
749 bytecount value. Used for counts.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
750
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 XD_END
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
752
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 Special type indicating the end of the array.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 Special macros:
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
757
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
758 XD_INDIRECT (line, delta)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
759 Usable where a count, size, offset or union constant is requested. Gives
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
760 the value of the element which is at line number 'line' in the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
761 description (count starts at zero) and adds delta to it, which must
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
762 (currently) be positive.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
765 enum memory_description_type
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
766 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
767 XD_LISP_OBJECT_ARRAY,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 XD_LISP_OBJECT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 XD_LO_LINK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 XD_OPAQUE_PTR,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 XD_STRUCT_PTR,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
772 XD_STRUCT_ARRAY,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 XD_OPAQUE_DATA_PTR,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
774 XD_UNION,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
775 XD_UNION_DYNAMIC_SIZE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 XD_C_STRING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 XD_DOC_STRING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 XD_INT_RESET,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
779 XD_BYTECOUNT,
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
780 XD_ELEMCOUNT,
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
781 XD_HASHCODE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 XD_INT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 XD_LONG,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
784 XD_END
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
787 enum data_description_entry_flags
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
788 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
789 /* If set, KKCC does not process this entry.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
790
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
791 (1) One obvious use is with things that pdump saves but which do not get
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
792 marked normally -- for example the next and prev fields in a marker. The
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
793 marker chain is weak, with its entries removed when they are finalized.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
794
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
795 (2) This can be set on structures not containing any Lisp objects, or (more
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
796 usefully) on structures that contain Lisp objects but where the objects
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
797 always occur in another structure as well. For example, the extent lists
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
798 kept by a buffer keep the extents in two lists, one sorted by the start
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
799 of the extent and the other by the end. There's no point in marking
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
800 both, since each contains the same objects as the other; but when dumping
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
801 (if we were to dump such a structure), when computing memory size, etc.,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
802 it's crucial to tag both sides.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
803 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
804 XD_FLAG_NO_KKCC = 1,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
805 /* If set, pdump does not process this entry. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
806 XD_FLAG_NO_PDUMP = 2,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
807 /* Indicates that this is a "default" entry in a union map. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
808 XD_FLAG_UNION_DEFAULT_ENTRY = 4,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
809 /* Indicates that this is a free Lisp object we're marking.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
810 Only relevant for ERROR_CHECK_GC. This occurs when we're marking
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
811 lcrecord-lists, where the objects have had their type changed to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
812 lrecord_type_free and also have had their free bit set, but we mark
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
813 them as normal. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
814 XD_FLAG_FREE_LISP_OBJECT = 8,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
815 #if 0
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
816 /* Suggestions for other possible flags: */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
817
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
818 /* Eliminate XD_UNION_DYNAMIC_SIZE and replace it with a flag, like this. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
819 XD_FLAG_UNION_DYNAMIC_SIZE = 16,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
820 /* Require that everyone who uses a description map has to flag it, so
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
821 that it's easy to tell, when looking through the code, where the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
822 description maps are and who's using them. This might also become
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
823 necessary if for some reason the format of the description map is
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
824 expanded and we need to stick a pointer in the second slot (although
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
825 we could still ensure that the second slot in the first entry was NULL
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
826 or <0). */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
827 XD_FLAG_DESCRIPTION_MAP = 32,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
828 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
831 struct memory_description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
832 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
833 enum memory_description_type type;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
834 Bytecount offset;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
835 EMACS_INT data1;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
836 const struct sized_memory_description *data2;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
837 /* Indicates which subsystems process this entry, plus (potentially) other
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
838 flags that apply to this entry. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
839 int flags;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
840 };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
842 struct sized_memory_description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
843 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
844 Bytecount size;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
845 const struct memory_description *description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
846 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
847
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
848 extern const struct sized_memory_description lisp_object_description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
849
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
850 #define XD_INDIRECT(val, delta) (-1 - (Bytecount) ((val) | ((delta) << 8)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
852 #define XD_IS_INDIRECT(code) ((code) < 0)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
853 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
854 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
855
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
856 #define XD_DYNARR_DESC(base_type, sub_desc) \
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
857 { XD_STRUCT_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), sub_desc }, \
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
858 { XD_INT, offsetof (base_type, cur) }, \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
859 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
860
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
866 #if defined (ERROR_CHECK_TYPES)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
867 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 #else
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
869 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
872
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
873 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
874 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
875
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
876 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
877 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof(structtype),0,1,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
878
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
879 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
880 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
881
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
882 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
883 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
884
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
885 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
886 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
887
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
888 #define DEFINE_BASIC_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
889 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,0,sizer,1,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
890
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
891 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
892 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
893
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
894 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
895 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
896 const struct lrecord_implementation lrecord_##c_name = \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
897 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
898 getprop, putprop, remprop, plist, size, sizer, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
899 lrecord_type_##c_name, basic_p }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
900
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
901 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
902 DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
903
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
904 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
905 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
906
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
907 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
908 DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
909
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
910 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
911 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
912
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
913 #define MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
914 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
915 int lrecord_type_##c_name; \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
916 struct lrecord_implementation lrecord_##c_name = \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
917 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
918 getprop, putprop, remprop, plist, size, sizer, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
919 lrecord_type_last_built_in_type, basic_p }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
920
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
921 extern Lisp_Object (*lrecord_markers[]) (Lisp_Object);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
922
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
923 #define INIT_LRECORD_IMPLEMENTATION(type) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
924 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
925 lrecord_markers[lrecord_type_##type] = \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
926 lrecord_implementations_table[lrecord_type_##type]->marker; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
927 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
929 #define INIT_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
930 lrecord_type_##type = lrecord_type_count++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
931 lrecord_##type.lrecord_type_index = lrecord_type_##type; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
932 INIT_LRECORD_IMPLEMENTATION(type); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
933 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
934
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
935 #ifdef HAVE_SHLIB
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
936 /* Allow undefining types in order to support module unloading. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
937
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
938 #define UNDEF_LRECORD_IMPLEMENTATION(type) do { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
939 lrecord_implementations_table[lrecord_type_##type] = NULL; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
940 lrecord_markers[lrecord_type_##type] = NULL; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
941 } while (0)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
942
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
943 #define UNDEF_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
944 if (lrecord_##type.lrecord_type_index == lrecord_type_count - 1) { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
945 /* This is the most recently defined type. Clean up nicely. */ \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
946 lrecord_type_##type = lrecord_type_count--; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
947 } /* Else we can't help leaving a hole with this implementation. */ \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
948 UNDEF_LRECORD_IMPLEMENTATION(type); \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
949 } while (0)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
950
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
951 #endif /* HAVE_SHLIB */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
952
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 #define RECORD_TYPEP(x, ty) \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
957 (LRECORDP (x) && (XRECORD_LHEADER (x)->type == (unsigned int) (ty)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
958
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
959 /* Steps to create a new object:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
960
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
961 1. Declare the struct for your object in a header file somewhere.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
962 Remember that it must begin with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
963
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
964 struct lcrecord_header header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
965
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
966 2. Put the "standard junk" (DECLARE_RECORD()/XFOO/etc.) below the
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
967 struct definition -- see below.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
968
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
969 3. Add this header file to inline.c.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
970
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
971 4. Create the methods for your object. Note that technically you don't
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
972 need any, but you will almost always want at least a mark method.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
973
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
974 4. Create the data layout description for your object. See
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
975 toolbar_button_description below; the comment above in `struct lrecord',
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
976 describing the purpose of the descriptions; and comments elsewhere in
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
977 this file describing the exact syntax of the description structures.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
978
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
979 6. Define your object with DEFINE_LRECORD_IMPLEMENTATION() or some
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
980 variant.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
981
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
982 7. Include the header file in the .c file where you defined the object.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
983
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
984 8. Put a call to INIT_LRECORD_IMPLEMENTATION() for the object in the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
985 .c file's syms_of_foo() function.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
986
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
987 9. Add a type enum for the object to enum lrecord_type, earlier in this
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
988 file.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
989
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
990 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
991
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
992 An example:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
994 ------------------------------ in toolbar.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
995
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
996 struct toolbar_button
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
997 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
998 struct lcrecord_header header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
999
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1000 Lisp_Object next;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1001 Lisp_Object frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1002
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1003 Lisp_Object up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1004 Lisp_Object down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1005 Lisp_Object disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1006
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1007 Lisp_Object cap_up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1008 Lisp_Object cap_down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1009 Lisp_Object cap_disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1010
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1011 Lisp_Object callback;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1012 Lisp_Object enabled_p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1013 Lisp_Object help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1014
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1015 char enabled;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1016 char down;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1017 char pushright;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1018 char blank;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1019
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1020 int x, y;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1021 int width, height;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1022 int dirty;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1023 int vertical;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1024 int border_width;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1025 };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1027 [[ the standard junk: ]]
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1028
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1029 DECLARE_LRECORD (toolbar_button, struct toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1030 #define XTOOLBAR_BUTTON(x) XRECORD (x, toolbar_button, struct toolbar_button)
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1031 #define wrap_toolbar_button(p) wrap_record (p, toolbar_button)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1032 #define TOOLBAR_BUTTONP(x) RECORDP (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1033 #define CHECK_TOOLBAR_BUTTON(x) CHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1034 #define CONCHECK_TOOLBAR_BUTTON(x) CONCHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1035
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1036 ------------------------------ in toolbar.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1037
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1038 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1039
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1040 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1041
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1042 static const struct memory_description toolbar_button_description [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1043 { XD_LISP_OBJECT, offsetof (struct toolbar_button, next) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1044 { XD_LISP_OBJECT, offsetof (struct toolbar_button, frame) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1045 { XD_LISP_OBJECT, offsetof (struct toolbar_button, up_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1046 { XD_LISP_OBJECT, offsetof (struct toolbar_button, down_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1047 { XD_LISP_OBJECT, offsetof (struct toolbar_button, disabled_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1048 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_up_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1049 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_down_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1050 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_disabled_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1051 { XD_LISP_OBJECT, offsetof (struct toolbar_button, callback) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1052 { XD_LISP_OBJECT, offsetof (struct toolbar_button, enabled_p) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1053 { XD_LISP_OBJECT, offsetof (struct toolbar_button, help_string) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1054 { XD_END }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1055 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1056
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1057 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1058 mark_toolbar_button (Lisp_Object obj)
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1059 \{
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1060 struct toolbar_button *data = XTOOLBAR_BUTTON (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1061 mark_object (data->next);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1062 mark_object (data->frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1063 mark_object (data->up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1064 mark_object (data->down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1065 mark_object (data->disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1066 mark_object (data->cap_up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1067 mark_object (data->cap_down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1068 mark_object (data->cap_disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1069 mark_object (data->callback);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1070 mark_object (data->enabled_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1071 return data->help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1072 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1073
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1074 [[ If your object should never escape to Lisp, declare its print method
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1075 as internal_object_printer instead of 0. ]]
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1076
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1077 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-button", toolbar_button,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1078 0, mark_toolbar_button, 0, 0, 0, 0,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1079 toolbar_button_description,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1080 struct toolbar_button);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1081
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1082 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1083
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1084 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1085 syms_of_toolbar (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1086 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1087 INIT_LRECORD_IMPLEMENTATION (toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1088
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1089 ...;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1090 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1091
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1092 ------------------------------ in inline.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1093
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1094 #ifdef HAVE_TOOLBARS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1095 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1096 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1097
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1098 ------------------------------ in lrecord.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1099
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1100 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1101 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1102 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1103 lrecord_type_toolbar_button,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1104 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1105 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1106
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1107
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1108 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1109
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1110 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1111
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1112 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1113
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1114 Note: Object types defined in external dynamically-loaded modules (not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1115 part of the XEmacs main source code) should use DECLARE_EXTERNAL_LRECORD
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1116 and DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION rather than DECLARE_LRECORD
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1117 and DEFINE_LRECORD_IMPLEMENTATION.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1118
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1119 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1120
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1122 #ifdef ERROR_CHECK_TYPES
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1124 # define DECLARE_LRECORD(c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1125 extern const struct lrecord_implementation lrecord_##c_name; \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1126 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1127 structtype * \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1128 error_check_##c_name (Lisp_Object obj, const char *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1129 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1130 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1131 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1132 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1133 } \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1136 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1137 extern int lrecord_type_##c_name; \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1138 extern struct lrecord_implementation lrecord_##c_name; \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1139 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1140 structtype * \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1141 error_check_##c_name (Lisp_Object obj, const char *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1142 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1143 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1144 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1145 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1146 } \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1147 extern Lisp_Object Q##c_name##p
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1148
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1149 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1150 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1151 structtype * \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1152 error_check_##c_name (Lisp_Object obj, const char *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1153 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1154 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1155 assert_at_line (XTYPE (obj) == type_enum, file, line); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1156 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1157 } \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1160 # define XRECORD(x, c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1161 error_check_##c_name (x, __FILE__, __LINE__)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1162 # define XNONRECORD(x, c_name, type_enum, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1163 error_check_##c_name (x, __FILE__, __LINE__)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1165 DECLARE_INLINE_HEADER (
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1166 Lisp_Object
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1167 wrap_record_1 (const void *ptr, enum lrecord_type ty, const char *file,
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1168 int line)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1169 )
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1170 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
1171 Lisp_Object obj = wrap_pointer_1 (ptr);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
1172
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1173 assert_at_line (RECORD_TYPEP (obj, ty), file, line);
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1174 return obj;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1175 }
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1176
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1177 #define wrap_record(ptr, ty) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1178 wrap_record_1 (ptr, lrecord_type_##ty, __FILE__, __LINE__)
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1179
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1180 #else /* not ERROR_CHECK_TYPES */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 # define DECLARE_LRECORD(c_name, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 extern Lisp_Object Q##c_name##p; \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1184 extern const struct lrecord_implementation lrecord_##c_name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1185 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1186 extern Lisp_Object Q##c_name##p; \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
1187 extern int lrecord_type_##c_name; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1188 extern struct lrecord_implementation lrecord_##c_name
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 # define XNONRECORD(x, c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 ((structtype *) XPNTR (x))
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1194 /* wrap_pointer_1 is so named as a suggestion not to use it unless you
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1195 know what you're doing. */
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1196 #define wrap_record(ptr, ty) wrap_pointer_1 (ptr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1198 #endif /* not ERROR_CHECK_TYPES */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1200 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_type_##c_name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 /* Note: we now have two different kinds of type-checking macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 The "old" kind has now been renamed CONCHECK_foo. The reason for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 this is that the CONCHECK_foo macros signal a continuable error,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 allowing the user (through debug-on-error) to substitute a different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 value and return from the signal, which causes the lvalue argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 to get changed. Quite a lot of code would crash if that happened,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 because it did things like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 foo = XCAR (list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 CHECK_STRING (foo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 and later on did XSTRING (XCAR (list)), assuming that the type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 is correct (when it might be wrong, if the user substituted a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 correct value in the debugger).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 To get around this, I made all the CHECK_foo macros signal a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 non-continuable error. Places where a continuable error is OK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 (generally only when called directly on the argument of a Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 primitive) should be changed to use CONCHECK().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 FSF Emacs does not have this problem because RMS took the cheesy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 way out and disabled returning from a signal entirely. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 #define CONCHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1226 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 x = wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 x = wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 #define CHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1234 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 dead_wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 dead_wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1242 /*-------------------------- lcrecord-list -----------------------------*/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1243
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1244 struct lcrecord_list
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1245 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1246 struct lcrecord_header header;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1247 Lisp_Object free;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1248 Elemcount size;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1249 const struct lrecord_implementation *implementation;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1250 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1251
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1252 DECLARE_LRECORD (lcrecord_list, struct lcrecord_list);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1253 #define XLCRECORD_LIST(x) XRECORD (x, lcrecord_list, struct lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1254 #define wrap_lcrecord_list(p) wrap_record (p, lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1255 #define LCRECORD_LISTP(x) RECORDP (x, lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1256 /* #define CHECK_LCRECORD_LIST(x) CHECK_RECORD (x, lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1257 Lcrecord lists should never escape to the Lisp level, so
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1258 functions should not be doing this. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1259
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1260 /* Various ways of allocating lcrecords. All bytes (except lcrecord
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1261 header) are zeroed in returned structure.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1262
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1263 See above for a discussion of the difference between plain lrecords and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1264 lrecords. lcrecords themselves are divided into three types: (1)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1265 auto-managed, (2) hand-managed, and (3) unmanaged. "Managed" refers to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1266 using a special object called an lcrecord-list to keep track of freed
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1267 lcrecords, which can freed with free_lcrecord() or the like and later be
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1268 recycled when a new lcrecord is required, rather than requiring new
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1269 malloc(). Thus, allocation of lcrecords can be very
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1270 cheap. (Technically, the lcrecord-list manager could divide up large
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1271 chunks of memory and allocate out of that, mimicking what happens with
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1272 lrecords. At that point, however, we'd want to rethink the whole
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1273 division between lrecords and lcrecords.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1274
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1275 NOTE: There is a fundamental limitation of lcrecord-lists, which is that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1276 they only handle blocks of a particular, fixed size. Thus, objects that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1277 can be of varying sizes need to do various tricks. These considerations
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1278 in particular dictate the various types of management:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1279
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1280 -- "Auto-managed" means that you just go ahead and allocate the lcrecord
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1281 whenever you want, using alloc_lcrecord_type(), and the appropriate
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1282 lcrecord-list manager is automatically created. To free, you just call
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1283 "free_lcrecord()" and the appropriate lcrecord-list manager is
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1284 automatically located and called. The limitation here of course is that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1285 all your objects are of the same size. (#### Eventually we should have a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1286 more sophisticated system that tracks the sizes seen and creates one
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1287 lcrecord list per size, indexed in a hash table. Usually there are only
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1288 a limited number of sizes, so this works well.)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1289
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1290 -- "Hand-managed" exists because we haven't yet written the more
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1291 sophisticated scheme for auto-handling different-sized lcrecords, as
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1292 described in the end of the last paragraph. In this model, you go ahead
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1293 and create the lcrecord-list objects yourself for the sizes you will
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1294 need, using make_lcrecord_list(). Then, create lcrecords using
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1295 alloc_managed_lcrecord(), passing in the lcrecord-list you created, and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1296 free them with free_managed_lcrecord().
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1297
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1298 -- "Unmanaged" means you simply allocate lcrecords, period. No
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1299 lcrecord-lists, no way to free them. This may be suitable when the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1300 lcrecords are variable-sized and (a) you're too lazy to write the code
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1301 to hand-manage them, or (b) the objects you create are always or almost
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1302 always Lisp-visible, and thus there's no point in freeing them (and it
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1303 wouldn't be safe to do so). You just create them with
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1304 basic_alloc_lcrecord(), and that's it.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1305
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1306 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1307
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1308 Here is an in-depth look at the steps required to create a allocate an
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1309 lcrecord using the hand-managed style. Since this is the most
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1310 complicated, you will learn a lot about the other styles as well. In
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1311 addition, there is useful general information about what freeing an
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1312 lcrecord really entails, and what are the precautions:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1313
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1314 1) Create an lcrecord-list object using make_lcrecord_list(). This is
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1315 often done at initialization. Remember to staticpro_nodump() this
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1316 object! The arguments to make_lcrecord_list() are the same as would be
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1317 passed to basic_alloc_lcrecord().
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1319 2) Instead of calling basic_alloc_lcrecord(), call alloc_managed_lcrecord()
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1320 and pass the lcrecord-list earlier created.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1321
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1322 3) When done with the lcrecord, call free_managed_lcrecord(). The
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1323 standard freeing caveats apply: ** make sure there are no pointers to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1324 the object anywhere! **
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1325
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1326 4) Calling free_managed_lcrecord() is just like kissing the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1327 lcrecord goodbye as if it were garbage-collected. This means:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1328 -- the contents of the freed lcrecord are undefined, and the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1329 contents of something produced by alloc_managed_lcrecord()
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1330 are undefined, just like for basic_alloc_lcrecord().
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1331 -- the mark method for the lcrecord's type will *NEVER* be called
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1332 on freed lcrecords.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1333 -- the finalize method for the lcrecord's type will be called
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1334 at the time that free_managed_lcrecord() is called.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1335 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1336
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1337 /* UNMANAGED MODEL: */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1338 void *basic_alloc_lcrecord (Bytecount size,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1339 const struct lrecord_implementation *);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1340
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1341 /* HAND-MANAGED MODEL: */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1342 Lisp_Object make_lcrecord_list (Elemcount size,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1343 const struct lrecord_implementation
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1344 *implementation);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1345 Lisp_Object alloc_managed_lcrecord (Lisp_Object lcrecord_list);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1346 void free_managed_lcrecord (Lisp_Object lcrecord_list, Lisp_Object lcrecord);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1347
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1348 /* AUTO-MANAGED MODEL: */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1349 void *alloc_automanaged_lcrecord (Bytecount size,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1350 const struct lrecord_implementation *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 #define alloc_lcrecord_type(type, lrecord_implementation) \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1352 ((type *) alloc_automanaged_lcrecord (sizeof (type), lrecord_implementation))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1353 void free_lcrecord (Lisp_Object rec);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1354
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 /* Copy the data from one lcrecord structure into another, but don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 overwrite the header information. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1359 #define copy_sized_lcrecord(dst, src, size) \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1360 memcpy ((char *) (dst) + sizeof (struct lcrecord_header), \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1361 (char *) (src) + sizeof (struct lcrecord_header), \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1362 (size) - sizeof (struct lcrecord_header))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1363
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1364 #define copy_lcrecord(dst, src) copy_sized_lcrecord (dst, src, sizeof (*(dst)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1366 #define zero_sized_lcrecord(lcr, size) \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1367 memset ((char *) (lcr) + sizeof (struct lcrecord_header), 0, \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1368 (size) - sizeof (struct lcrecord_header))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1369
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1370 #define zero_lcrecord(lcr) zero_sized_lcrecord (lcr, sizeof (*(lcr)))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1371
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1372 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1373 Bytecount
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1374 detagged_lisp_object_size (const struct lrecord_header *h)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1375 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1376 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1377 const struct lrecord_implementation *imp = LHEADER_IMPLEMENTATION (h);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1378
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1379 return (imp->size_in_bytes_method ?
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1380 imp->size_in_bytes_method (h) :
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1381 imp->static_size);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1382 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1383
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1384 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1385 Bytecount
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1386 lisp_object_size (Lisp_Object o)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1387 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1388 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1389 return detagged_lisp_object_size (XRECORD_LHEADER (o));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1390 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1391
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1392
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1393 /************************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1394 /* Dumping */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1395 /************************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1396
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1397 /* dump_add_root_struct_ptr (&var, &desc) dumps the structure pointed to by
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1398 `var'. This is for a single relocatable pointer located in the data
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1399 segment (i.e. the block pointed to is in the heap). */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1400 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1401 void dump_add_root_struct_ptr (void *, const struct sized_memory_description *);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1402 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1403 #define dump_add_root_struct_ptr(varaddr,descaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1404 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1405
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1406 /* dump_add_opaque (&var, size) dumps the opaque static structure `var'.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1407 This is for a static block of memory (in the data segment, not the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1408 heap), with no relocatable pointers in it. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1409 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1410 #define dump_add_opaque(varaddr,size) dump_add_root_block (varaddr, size, NULL)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1411 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1412 #define dump_add_opaque(varaddr,size) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1413 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1414
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1415 /* dump_add_root_block (ptr, size, desc) dumps the static structure
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1416 located at `var' of size SIZE and described by DESC. This is for a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1417 static block of memory (in the data segment, not the heap), with
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1418 relocatable pointers in it. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1419 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1420 void dump_add_root_block (const void *ptraddress, Bytecount size,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1421 const struct memory_description *desc);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1422 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1423 #define dump_add_root_block(ptraddress,desc) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1424 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1425
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1426 /* Call dump_add_opaque_int (&int_var) to dump `int_var', of type `int'. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1427 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1428 #define dump_add_opaque_int(int_varaddr) do { \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1429 int *dao_ = (int_varaddr); /* type check */ \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1430 dump_add_opaque (dao_, sizeof (*dao_)); \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1431 } while (0)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1432 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1433 #define dump_add_opaque_int(int_varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1434 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1435
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1436 /* Call dump_add_opaque_fixnum (&fixnum_var) to dump `fixnum_var', of type
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1437 `Fixnum'. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1438 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1439 #define dump_add_opaque_fixnum(fixnum_varaddr) do { \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1440 Fixnum *dao_ = (fixnum_varaddr); /* type check */ \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1441 dump_add_opaque (dao_, sizeof (*dao_)); \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1442 } while (0)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1443 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1444 #define dump_add_opaque_fixnum(fixnum_varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1445 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1446
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1447 /* Call dump_add_root_lisp_object (&var) to ensure that var is properly
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1448 updated after pdump. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1449 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1450 void dump_add_root_lisp_object (Lisp_Object *);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1451 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1452 #define dump_add_root_lisp_object(varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1453 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1454
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1455 /* Call dump_add_weak_lisp_object (&var) to ensure that var is properly
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1456 updated after pdump. var must point to a linked list of objects out of
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1457 which some may not be dumped */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1458 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1459 void dump_add_weak_object_chain (Lisp_Object *);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1460 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1461 #define dump_add_weak_object_chain(varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1462 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1463
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1464 /* Nonzero means Emacs has already been initialized.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1465 Used during startup to detect startup of dumped Emacs. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1466 extern int initialized;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1467
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1468 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1469
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1470 void pdump_objects_unmark (void);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1471 void pdump (void);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1472 int pdump_load (const char *argv0);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1473 void pdump_backtrace (void);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1474 extern unsigned int dump_id;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1475 extern char *pdump_start, *pdump_end;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1476
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1477 #define DUMPEDP(adr) ((((char *)(adr)) < pdump_end) && (((char *)(adr)) >= pdump_start))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1478
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1479 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1480 #define DUMPEDP(adr) 0
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1481 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1482
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1483 /***********************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1484 /* data descriptions */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1485 /***********************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1486
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1487
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1488 #if defined (USE_KKCC) || defined (PDUMP)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1489
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1490 extern int in_pdump;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1491
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1492 EMACS_INT lispdesc_indirect_count_1 (EMACS_INT code,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1493 const struct memory_description *idesc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1494 const void *idata);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1495 const struct sized_memory_description *lispdesc_indirect_description_1
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1496 (const void *obj, const struct sized_memory_description *sdesc);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1497 Bytecount lispdesc_structure_size (const void *obj,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1498 const struct sized_memory_description *
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1499 sdesc);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1500
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1501 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1502 EMACS_INT
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1503 lispdesc_indirect_count (EMACS_INT code,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1504 const struct memory_description *idesc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1505 const void *idata)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1506 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1507 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1508 if (XD_IS_INDIRECT (code))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1509 code = lispdesc_indirect_count_1 (code, idesc, idata);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1510 return code;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1511 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1512
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1513 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1514 const struct sized_memory_description *
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1515 lispdesc_indirect_description (const void *obj,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1516 const struct sized_memory_description *sdesc)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1517 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1518 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1519 if (sdesc->description)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1520 return sdesc;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1521 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1522 return lispdesc_indirect_description_1 (obj, sdesc);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1523 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1524
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1525
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1526 /* Do standard XD_UNION processing. DESC1 is an entry in DESC, which
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1527 describes the entire data structure. Returns NULL (do nothing, nothing
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1528 matched), or a new value for DESC1. In the latter case, assign to DESC1
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1529 in your function and goto union_switcheroo. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1530
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1531 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1532 const struct memory_description *
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1533 lispdesc_process_xd_union (const struct memory_description *desc1,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1534 const struct memory_description *desc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1535 const void *data)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1536 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1537 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1538 int count = 0;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1539 EMACS_INT variant = lispdesc_indirect_count (desc1->data1, desc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1540 data);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1541 desc1 =
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1542 lispdesc_indirect_description (data, desc1->data2)->description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1543
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1544 for (count = 0; desc1[count].type != XD_END; count++)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1545 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1546 if ((desc1[count].flags & XD_FLAG_UNION_DEFAULT_ENTRY) ||
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1547 desc1[count].offset == variant)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1548 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1549 return &desc1[count];
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1550 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1551 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1552
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1553 return NULL;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1554 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1555
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1556 #endif /* defined (USE_KKCC) || defined (PDUMP) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
1558 #endif /* INCLUDED_lrecord_h_ */