Mercurial > hg > xemacs-beta
annotate src/objects.c @ 5127:a9c41067dd88 ben-lisp-object
more cleanups, terminology clarification, lots of doc work
-------------------- ChangeLog entries follow: --------------------
man/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* internals/internals.texi (Introduction to Allocation):
* internals/internals.texi (Integers and Characters):
* internals/internals.texi (Allocation from Frob Blocks):
* internals/internals.texi (lrecords):
* internals/internals.texi (Low-level allocation):
Rewrite section on allocation of Lisp objects to reflect the new
reality. Remove references to nonexistent XSETINT and XSETCHAR.
modules/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c (allocate_pgconn):
* postgresql/postgresql.c (allocate_pgresult):
* postgresql/postgresql.h (struct Lisp_PGconn):
* postgresql/postgresql.h (struct Lisp_PGresult):
* ldap/eldap.c (allocate_ldap):
* ldap/eldap.h (struct Lisp_LDAP):
Same changes as in src/ dir. See large log there in ChangeLog,
but basically:
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
../hlo/src/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (old_alloc_sized_lcrecord):
* alloc.c (very_old_free_lcrecord):
* alloc.c (copy_lisp_object):
* alloc.c (zero_sized_lisp_object):
* alloc.c (zero_nonsized_lisp_object):
* alloc.c (lisp_object_storage_size):
* alloc.c (free_normal_lisp_object):
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC):
* alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT):
* alloc.c (Fcons):
* alloc.c (noseeum_cons):
* alloc.c (make_float):
* alloc.c (make_bignum):
* alloc.c (make_bignum_bg):
* alloc.c (make_ratio):
* alloc.c (make_ratio_bg):
* alloc.c (make_ratio_rt):
* alloc.c (make_bigfloat):
* alloc.c (make_bigfloat_bf):
* alloc.c (size_vector):
* alloc.c (make_compiled_function):
* alloc.c (Fmake_symbol):
* alloc.c (allocate_extent):
* alloc.c (allocate_event):
* alloc.c (make_key_data):
* alloc.c (make_button_data):
* alloc.c (make_motion_data):
* alloc.c (make_process_data):
* alloc.c (make_timeout_data):
* alloc.c (make_magic_data):
* alloc.c (make_magic_eval_data):
* alloc.c (make_eval_data):
* alloc.c (make_misc_user_data):
* alloc.c (Fmake_marker):
* alloc.c (noseeum_make_marker):
* alloc.c (size_string_direct_data):
* alloc.c (make_uninit_string):
* alloc.c (make_string_nocopy):
* alloc.c (mark_lcrecord_list):
* alloc.c (alloc_managed_lcrecord):
* alloc.c (free_managed_lcrecord):
* alloc.c (sweep_lcrecords_1):
* alloc.c (malloced_storage_size):
* buffer.c (allocate_buffer):
* buffer.c (compute_buffer_usage):
* buffer.c (DEFVAR_BUFFER_LOCAL_1):
* buffer.c (nuke_all_buffer_slots):
* buffer.c (common_init_complex_vars_of_buffer):
* buffer.h (struct buffer_text):
* buffer.h (struct buffer):
* bytecode.c:
* bytecode.c (make_compiled_function_args):
* bytecode.c (size_compiled_function_args):
* bytecode.h (struct compiled_function_args):
* casetab.c (allocate_case_table):
* casetab.h (struct Lisp_Case_Table):
* charset.h (struct Lisp_Charset):
* chartab.c (fill_char_table):
* chartab.c (Fmake_char_table):
* chartab.c (make_char_table_entry):
* chartab.c (copy_char_table_entry):
* chartab.c (Fcopy_char_table):
* chartab.c (put_char_table):
* chartab.h (struct Lisp_Char_Table_Entry):
* chartab.h (struct Lisp_Char_Table):
* console-gtk-impl.h (struct gtk_device):
* console-gtk-impl.h (struct gtk_frame):
* console-impl.h (struct console):
* console-msw-impl.h (struct Lisp_Devmode):
* console-msw-impl.h (struct mswindows_device):
* console-msw-impl.h (struct msprinter_device):
* console-msw-impl.h (struct mswindows_frame):
* console-msw-impl.h (struct mswindows_dialog_id):
* console-stream-impl.h (struct stream_console):
* console-stream.c (stream_init_console):
* console-tty-impl.h (struct tty_console):
* console-tty-impl.h (struct tty_device):
* console-tty.c (allocate_tty_console_struct):
* console-x-impl.h (struct x_device):
* console-x-impl.h (struct x_frame):
* console.c (allocate_console):
* console.c (nuke_all_console_slots):
* console.c (DEFVAR_CONSOLE_LOCAL_1):
* console.c (common_init_complex_vars_of_console):
* data.c (make_weak_list):
* data.c (make_weak_box):
* data.c (make_ephemeron):
* database.c:
* database.c (struct Lisp_Database):
* database.c (allocate_database):
* database.c (finalize_database):
* device-gtk.c (allocate_gtk_device_struct):
* device-impl.h (struct device):
* device-msw.c:
* device-msw.c (mswindows_init_device):
* device-msw.c (msprinter_init_device):
* device-msw.c (finalize_devmode):
* device-msw.c (allocate_devmode):
* device-tty.c (allocate_tty_device_struct):
* device-x.c (allocate_x_device_struct):
* device.c:
* device.c (nuke_all_device_slots):
* device.c (allocate_device):
* dialog-msw.c (handle_question_dialog_box):
* elhash.c:
* elhash.c (struct Lisp_Hash_Table):
* elhash.c (finalize_hash_table):
* elhash.c (make_general_lisp_hash_table):
* elhash.c (Fcopy_hash_table):
* elhash.h (htentry):
* emacs.c (main_1):
* eval.c:
* eval.c (size_multiple_value):
* event-stream.c (finalize_command_builder):
* event-stream.c (allocate_command_builder):
* event-stream.c (free_command_builder):
* event-stream.c (event_stream_generate_wakeup):
* event-stream.c (event_stream_resignal_wakeup):
* event-stream.c (event_stream_disable_wakeup):
* event-stream.c (event_stream_wakeup_pending_p):
* events.h (struct Lisp_Timeout):
* events.h (struct command_builder):
* extents-impl.h:
* extents-impl.h (struct extent_auxiliary):
* extents-impl.h (struct extent_info):
* extents-impl.h (set_extent_no_chase_aux_field):
* extents-impl.h (set_extent_no_chase_normal_field):
* extents.c:
* extents.c (gap_array_marker):
* extents.c (gap_array):
* extents.c (extent_list_marker):
* extents.c (extent_list):
* extents.c (stack_of_extents):
* extents.c (gap_array_make_marker):
* extents.c (extent_list_make_marker):
* extents.c (allocate_extent_list):
* extents.c (SLOT):
* extents.c (mark_extent_auxiliary):
* extents.c (allocate_extent_auxiliary):
* extents.c (attach_extent_auxiliary):
* extents.c (size_gap_array):
* extents.c (finalize_extent_info):
* extents.c (allocate_extent_info):
* extents.c (uninit_buffer_extents):
* extents.c (allocate_soe):
* extents.c (copy_extent):
* extents.c (vars_of_extents):
* extents.h:
* faces.c (allocate_face):
* faces.h (struct Lisp_Face):
* faces.h (struct face_cachel):
* file-coding.c:
* file-coding.c (finalize_coding_system):
* file-coding.c (sizeof_coding_system):
* file-coding.c (Fcopy_coding_system):
* file-coding.h (struct Lisp_Coding_System):
* file-coding.h (MARKED_SLOT):
* fns.c (size_bit_vector):
* font-mgr.c:
* font-mgr.c (finalize_fc_pattern):
* font-mgr.c (print_fc_pattern):
* font-mgr.c (Ffc_pattern_p):
* font-mgr.c (Ffc_pattern_create):
* font-mgr.c (Ffc_name_parse):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.c (Ffc_pattern_duplicate):
* font-mgr.c (Ffc_pattern_add):
* font-mgr.c (Ffc_pattern_del):
* font-mgr.c (Ffc_pattern_get):
* font-mgr.c (fc_config_create_using):
* font-mgr.c (fc_strlist_to_lisp_using):
* font-mgr.c (fontset_to_list):
* font-mgr.c (Ffc_config_p):
* font-mgr.c (Ffc_config_up_to_date):
* font-mgr.c (Ffc_config_build_fonts):
* font-mgr.c (Ffc_config_get_cache):
* font-mgr.c (Ffc_config_get_fonts):
* font-mgr.c (Ffc_config_set_current):
* font-mgr.c (Ffc_config_get_blanks):
* font-mgr.c (Ffc_config_get_rescan_interval):
* font-mgr.c (Ffc_config_set_rescan_interval):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_app_font_clear):
* font-mgr.c (size):
* font-mgr.c (Ffc_config_substitute):
* font-mgr.c (Ffc_font_render_prepare):
* font-mgr.c (Ffc_font_match):
* font-mgr.c (Ffc_font_sort):
* font-mgr.c (finalize_fc_config):
* font-mgr.c (print_fc_config):
* font-mgr.h:
* font-mgr.h (struct fc_pattern):
* font-mgr.h (XFC_PATTERN):
* font-mgr.h (struct fc_config):
* font-mgr.h (XFC_CONFIG):
* frame-gtk.c (allocate_gtk_frame_struct):
* frame-impl.h (struct frame):
* frame-msw.c (mswindows_init_frame_1):
* frame-x.c (allocate_x_frame_struct):
* frame.c (nuke_all_frame_slots):
* frame.c (allocate_frame_core):
* gc.c:
* gc.c (GC_CHECK_NOT_FREE):
* glyphs.c (finalize_image_instance):
* glyphs.c (allocate_image_instance):
* glyphs.c (Fcolorize_image_instance):
* glyphs.c (allocate_glyph):
* glyphs.c (unmap_subwindow_instance_cache_mapper):
* glyphs.c (register_ignored_expose):
* glyphs.h (struct Lisp_Image_Instance):
* glyphs.h (struct Lisp_Glyph):
* glyphs.h (struct glyph_cachel):
* glyphs.h (struct expose_ignore):
* gui.c (allocate_gui_item):
* gui.h (struct Lisp_Gui_Item):
* keymap.c (struct Lisp_Keymap):
* keymap.c (make_keymap):
* lisp.h:
* lisp.h (struct Lisp_String_Direct_Data):
* lisp.h (struct Lisp_String_Indirect_Data):
* lisp.h (struct Lisp_Vector):
* lisp.h (struct Lisp_Bit_Vector):
* lisp.h (DECLARE_INLINE_LISP_BIT_VECTOR):
* lisp.h (struct weak_box):
* lisp.h (struct ephemeron):
* lisp.h (struct weak_list):
* lrecord.h:
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER):
* lrecord.h (struct lcrecord_list):
* lstream.c (finalize_lstream):
* lstream.c (sizeof_lstream):
* lstream.c (Lstream_new):
* lstream.c (Lstream_delete):
* lstream.h (struct lstream):
* marker.c:
* marker.c (finalize_marker):
* marker.c (compute_buffer_marker_usage):
* mule-charset.c:
* mule-charset.c (make_charset):
* mule-charset.c (compute_charset_usage):
* objects-impl.h (struct Lisp_Color_Instance):
* objects-impl.h (struct Lisp_Font_Instance):
* objects-tty-impl.h (struct tty_color_instance_data):
* objects-tty-impl.h (struct tty_font_instance_data):
* objects-tty.c (tty_initialize_color_instance):
* objects-tty.c (tty_initialize_font_instance):
* objects.c (finalize_color_instance):
* objects.c (Fmake_color_instance):
* objects.c (finalize_font_instance):
* objects.c (Fmake_font_instance):
* objects.c (reinit_vars_of_objects):
* opaque.c:
* opaque.c (sizeof_opaque):
* opaque.c (make_opaque_ptr):
* opaque.c (free_opaque_ptr):
* opaque.h:
* opaque.h (Lisp_Opaque):
* opaque.h (Lisp_Opaque_Ptr):
* print.c (printing_unreadable_lcrecord):
* print.c (external_object_printer):
* print.c (debug_p4):
* process.c (finalize_process):
* process.c (make_process_internal):
* procimpl.h (struct Lisp_Process):
* rangetab.c (Fmake_range_table):
* rangetab.c (Fcopy_range_table):
* rangetab.h (struct Lisp_Range_Table):
* scrollbar.c:
* scrollbar.c (create_scrollbar_instance):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h (struct scrollbar_instance):
* specifier.c (finalize_specifier):
* specifier.c (sizeof_specifier):
* specifier.c (set_specifier_caching):
* specifier.h (struct Lisp_Specifier):
* specifier.h (struct specifier_caching):
* symeval.h:
* symeval.h (SYMBOL_VALUE_MAGIC_P):
* symeval.h (DEFVAR_SYMVAL_FWD):
* symsinit.h:
* syntax.c (init_buffer_syntax_cache):
* syntax.h (struct syntax_cache):
* toolbar.c:
* toolbar.c (allocate_toolbar_button):
* toolbar.c (update_toolbar_button):
* toolbar.h (struct toolbar_button):
* tooltalk.c (struct Lisp_Tooltalk_Message):
* tooltalk.c (make_tooltalk_message):
* tooltalk.c (struct Lisp_Tooltalk_Pattern):
* tooltalk.c (make_tooltalk_pattern):
* ui-gtk.c:
* ui-gtk.c (allocate_ffi_data):
* ui-gtk.c (emacs_gtk_object_finalizer):
* ui-gtk.c (allocate_emacs_gtk_object_data):
* ui-gtk.c (allocate_emacs_gtk_boxed_data):
* ui-gtk.h:
* window-impl.h (struct window):
* window-impl.h (struct window_mirror):
* window.c (finalize_window):
* window.c (allocate_window):
* window.c (new_window_mirror):
* window.c (mark_window_as_deleted):
* window.c (make_dummy_parent):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
Overall point of this change and previous ones in this repository:
(1) Introduce new, clearer terminology: everything other than int
or char is a "record" object, which comes in two types: "normal
objects" and "frob-block objects". Fix up all places that
referred to frob-block objects as "simple", "basic", etc.
(2) Provide an advertised interface for doing operations on Lisp
objects, including creating new types, that is clean and
consistent in its naming, uses the above-referenced terms and
avoids referencing "lrecords", "old lcrecords", etc., which should
hide under the surface.
(3) Make the size_in_bytes and finalizer methods take a
Lisp_Object rather than a void * for consistency with other methods.
(4) Separate finalizer method into finalizer and disksaver, so
that normal finalize methods don't have to worry about disksaving.
Other specifics:
(1) Renaming:
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
implementation->basic_p -> implementation->frob_block_p
ALLOCATE_FIXED_TYPE_AND_SET_IMPL -> ALLOC_FROB_BLOCK_LISP_OBJECT
*FCCONFIG*, wrap_fcconfig -> *FC_CONFIG*, wrap_fc_config
*FCPATTERN*, wrap_fcpattern -> *FC_PATTERN*, wrap_fc_pattern
(the last two changes make the naming of these macros consistent
with the naming of all other macros, since the objects are named
fc-config and fc-pattern with a hyphen)
(2) Lots of documentation fixes in lrecord.h.
(3) Eliminate macros for copying, freeing, zeroing objects, getting
their storage size. Instead, new functions:
zero_sized_lisp_object()
zero_nonsized_lisp_object()
lisp_object_storage_size()
free_normal_lisp_object()
(copy_lisp_object() already exists)
LISP_OBJECT_FROB_BLOCK_P() (actually a macro)
Eliminated:
free_lrecord()
zero_lrecord()
copy_lrecord()
copy_sized_lrecord()
old_copy_lcrecord()
old_copy_sized_lcrecord()
old_zero_lcrecord()
old_zero_sized_lcrecord()
LISP_OBJECT_STORAGE_SIZE()
COPY_SIZED_LISP_OBJECT()
COPY_SIZED_LCRECORD()
COPY_LISP_OBJECT()
ZERO_LISP_OBJECT()
FREE_LISP_OBJECT()
(4) Catch the remaining places where lrecord stuff was used directly
and use the advertised interface, e.g. alloc_sized_lrecord() ->
ALLOC_SIZED_LISP_OBJECT().
(5) Make certain statically-declared pseudo-objects
(buffer_local_flags, console_local_flags) have their lheader
initialized correctly, so things like copy_lisp_object() can work
on them. Make extent_auxiliary_defaults a proper heap object
Vextent_auxiliary_defaults, and make extent auxiliaries dumpable
so that this object can be dumped. allocate_extent_auxiliary()
now just creates the object, and attach_extent_auxiliary()
creates an extent auxiliary and attaches to an extent, like the
old allocate_extent_auxiliary().
(6) Create EXTENT_AUXILIARY_SLOTS macro, similar to the foo-slots.h
files but in a macro instead of a file. The purpose is to avoid
duplication when iterating over all the slots in an extent auxiliary.
Use it.
(7) In lstream.c, don't zero out object after allocation because
allocation routines take care of this.
(8) In marker.c, fix a mistake in computing marker overhead.
(9) In print.c, clean up printing_unreadable_lcrecord(),
external_object_printer() to avoid lots of ifdef NEW_GC's.
(10) Separate toolbar-button allocation into a separate
allocate_toolbar_button() function for use in the example code
in lrecord.h.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Mar 2010 04:08:17 -0600 |
parents | b5df3737028a |
children | 7be849cb8828 |
rev | line source |
---|---|
428 | 1 /* Generic Objects and Functions. |
2 Copyright (C) 1995 Free Software Foundation, Inc. | |
3 Copyright (C) 1995 Board of Trustees, University of Illinois. | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
4 Copyright (C) 1995, 1996, 2002, 2004, 2005, 2010 Ben Wing. |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: Not in FSF. */ | |
24 | |
25 #include <config.h> | |
26 #include "lisp.h" | |
27 | |
771 | 28 #include "buffer.h" |
872 | 29 #include "device-impl.h" |
428 | 30 #include "elhash.h" |
31 #include "faces.h" | |
32 #include "frame.h" | |
800 | 33 #include "glyphs.h" |
872 | 34 #include "objects-impl.h" |
428 | 35 #include "specifier.h" |
36 #include "window.h" | |
37 | |
1204 | 38 #ifdef HAVE_TTY |
39 #include "console-tty.h" | |
40 #endif | |
934 | 41 |
428 | 42 /* Objects that are substituted when an instantiation fails. |
43 If we leave in the Qunbound value, we will probably get crashes. */ | |
44 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance; | |
45 | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
46 /* Author: Ben Wing; some earlier code from Chuck Thompson, Jamie |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
47 Zawinski. */ |
428 | 48 |
2268 | 49 DOESNT_RETURN |
428 | 50 finalose (void *ptr) |
51 { | |
793 | 52 Lisp_Object obj = wrap_pointer_1 (ptr); |
53 | |
563 | 54 invalid_operation |
428 | 55 ("Can't dump an emacs containing window system objects", obj); |
56 } | |
57 | |
58 | |
59 /**************************************************************************** | |
60 * Color-Instance Object * | |
61 ****************************************************************************/ | |
62 | |
63 Lisp_Object Qcolor_instancep; | |
64 | |
1204 | 65 static const struct memory_description color_instance_data_description_1 []= { |
66 #ifdef HAVE_TTY | |
3092 | 67 #ifdef NEW_GC |
68 { XD_LISP_OBJECT, tty_console }, | |
69 #else /* not NEW_GC */ | |
2551 | 70 { XD_BLOCK_PTR, tty_console, 1, { &tty_color_instance_data_description } }, |
3092 | 71 #endif /* not NEW_GC */ |
1204 | 72 #endif |
934 | 73 { XD_END } |
74 }; | |
75 | |
1204 | 76 static const struct sized_memory_description color_instance_data_description = { |
77 sizeof (void *), color_instance_data_description_1 | |
934 | 78 }; |
79 | |
1204 | 80 static const struct memory_description color_instance_description[] = { |
934 | 81 { XD_INT, offsetof (Lisp_Color_Instance, color_instance_type) }, |
82 { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, name)}, | |
83 { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, device)}, | |
1204 | 84 { XD_UNION, offsetof (Lisp_Color_Instance, data), |
2551 | 85 XD_INDIRECT (0, 0), { &color_instance_data_description } }, |
934 | 86 {XD_END} |
87 }; | |
88 | |
428 | 89 static Lisp_Object |
90 mark_color_instance (Lisp_Object obj) | |
91 { | |
440 | 92 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); |
428 | 93 mark_object (c->name); |
94 if (!NILP (c->device)) /* Vthe_null_color_instance */ | |
95 MAYBE_DEVMETH (XDEVICE (c->device), mark_color_instance, (c)); | |
96 | |
97 return c->device; | |
98 } | |
99 | |
100 static void | |
101 print_color_instance (Lisp_Object obj, Lisp_Object printcharfun, | |
102 int escapeflag) | |
103 { | |
440 | 104 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); |
428 | 105 if (print_readably) |
4846 | 106 printing_unreadable_lcrecord (obj, 0); |
800 | 107 write_fmt_string_lisp (printcharfun, "#<color-instance %s", 1, c->name); |
108 write_fmt_string_lisp (printcharfun, " on %s", 1, c->device); | |
428 | 109 if (!NILP (c->device)) /* Vthe_null_color_instance */ |
110 MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance, | |
111 (c, printcharfun, escapeflag)); | |
800 | 112 write_fmt_string (printcharfun, " 0x%x>", c->header.uid); |
428 | 113 } |
114 | |
115 static void | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
116 finalize_color_instance (Lisp_Object obj) |
428 | 117 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
118 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); |
428 | 119 |
120 if (!NILP (c->device)) | |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
121 MAYBE_DEVMETH (XDEVICE (c->device), finalize_color_instance, (c)); |
428 | 122 } |
123 | |
124 static int | |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
125 color_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
126 int UNUSED (foldcase)) |
428 | 127 { |
440 | 128 Lisp_Color_Instance *c1 = XCOLOR_INSTANCE (obj1); |
129 Lisp_Color_Instance *c2 = XCOLOR_INSTANCE (obj2); | |
428 | 130 |
131 return (c1 == c2) || | |
132 (EQ (c1->device, c2->device) && | |
133 DEVICEP (c1->device) && | |
134 HAS_DEVMETH_P (XDEVICE (c1->device), color_instance_equal) && | |
135 DEVMETH (XDEVICE (c1->device), color_instance_equal, (c1, c2, depth))); | |
136 } | |
137 | |
2515 | 138 static Hashcode |
428 | 139 color_instance_hash (Lisp_Object obj, int depth) |
140 { | |
440 | 141 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); |
428 | 142 struct device *d = DEVICEP (c->device) ? XDEVICE (c->device) : 0; |
143 | |
2515 | 144 return HASH2 ((Hashcode) d, |
428 | 145 !d ? LISP_HASH (obj) |
146 : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth), | |
147 LISP_HASH (obj))); | |
148 } | |
149 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
150 DEFINE_NODUMP_LISP_OBJECT ("color-instance", color_instance, |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
151 mark_color_instance, print_color_instance, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
152 finalize_color_instance, color_instance_equal, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
153 color_instance_hash, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
154 color_instance_description, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
155 Lisp_Color_Instance); |
428 | 156 |
157 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /* | |
158 Return a new `color-instance' object named NAME (a string). | |
159 | |
160 Optional argument DEVICE specifies the device this object applies to | |
161 and defaults to the selected device. | |
162 | |
163 An error is signaled if the color is unknown or cannot be allocated; | |
444 | 164 however, if optional argument NOERROR is non-nil, nil is simply |
165 returned in this case. (And if NOERROR is other than t, a warning may | |
428 | 166 be issued.) |
167 | |
168 The returned object is a normal, first-class lisp object. The way you | |
169 `deallocate' the color is the way you deallocate any other lisp object: | |
170 you drop all pointers to it and allow it to be garbage collected. When | |
171 these objects are GCed, the underlying window-system data (e.g. X object) | |
172 is deallocated as well. | |
173 */ | |
444 | 174 (name, device, noerror)) |
428 | 175 { |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
176 Lisp_Object obj; |
440 | 177 Lisp_Color_Instance *c; |
428 | 178 int retval; |
179 | |
180 CHECK_STRING (name); | |
793 | 181 device = wrap_device (decode_device (device)); |
428 | 182 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
183 obj = ALLOC_NORMAL_LISP_OBJECT (color_instance); |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
184 c = XCOLOR_INSTANCE (obj); |
428 | 185 c->name = name; |
186 c->device = device; | |
187 c->data = 0; | |
1204 | 188 c->color_instance_type = get_console_variant (XDEVICE_TYPE (c->device)); |
428 | 189 |
190 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance, | |
191 (c, name, device, | |
444 | 192 decode_error_behavior_flag (noerror))); |
428 | 193 if (!retval) |
194 return Qnil; | |
195 | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
196 return obj; |
428 | 197 } |
198 | |
199 DEFUN ("color-instance-p", Fcolor_instance_p, 1, 1, 0, /* | |
200 Return non-nil if OBJECT is a color instance. | |
201 */ | |
202 (object)) | |
203 { | |
204 return COLOR_INSTANCEP (object) ? Qt : Qnil; | |
205 } | |
206 | |
207 DEFUN ("color-instance-name", Fcolor_instance_name, 1, 1, 0, /* | |
208 Return the name used to allocate COLOR-INSTANCE. | |
209 */ | |
210 (color_instance)) | |
211 { | |
212 CHECK_COLOR_INSTANCE (color_instance); | |
213 return XCOLOR_INSTANCE (color_instance)->name; | |
214 } | |
215 | |
216 DEFUN ("color-instance-rgb-components", Fcolor_instance_rgb_components, 1, 1, 0, /* | |
217 Return a three element list containing the red, green, and blue | |
218 color components of COLOR-INSTANCE, or nil if unknown. | |
219 Component values range from 0 to 65535. | |
220 */ | |
221 (color_instance)) | |
222 { | |
440 | 223 Lisp_Color_Instance *c; |
428 | 224 |
225 CHECK_COLOR_INSTANCE (color_instance); | |
226 c = XCOLOR_INSTANCE (color_instance); | |
227 | |
228 if (NILP (c->device)) | |
229 return Qnil; | |
230 | |
231 return MAYBE_LISP_DEVMETH (XDEVICE (c->device), | |
232 color_instance_rgb_components, | |
233 (c)); | |
234 } | |
235 | |
236 DEFUN ("valid-color-name-p", Fvalid_color_name_p, 1, 2, 0, /* | |
237 Return true if COLOR names a valid color for the current device. | |
238 | |
239 Valid color names for X are listed in the file /usr/lib/X11/rgb.txt, or | |
240 whatever the equivalent is on your system. | |
241 | |
242 Valid color names for TTY are those which have an ISO 6429 (ANSI) sequence. | |
243 In addition to being a color this may be one of a number of attributes | |
244 such as `blink'. | |
245 */ | |
246 (color, device)) | |
247 { | |
248 struct device *d = decode_device (device); | |
249 | |
250 CHECK_STRING (color); | |
251 return MAYBE_INT_DEVMETH (d, valid_color_name_p, (d, color)) ? Qt : Qnil; | |
252 } | |
253 | |
2527 | 254 DEFUN ("color-list", Fcolor_list, 0, 1, 0, /* |
255 Return a list of color names. | |
256 DEVICE specifies which device to return names for, and defaults to the | |
257 currently selected device. | |
258 */ | |
259 (device)) | |
260 { | |
261 device = wrap_device (decode_device (device)); | |
262 | |
263 return MAYBE_LISP_DEVMETH (XDEVICE (device), color_list, ()); | |
264 } | |
265 | |
428 | 266 |
267 /*************************************************************************** | |
268 * Font-Instance Object * | |
269 ***************************************************************************/ | |
270 | |
271 Lisp_Object Qfont_instancep; | |
272 | |
273 static Lisp_Object font_instance_truename_internal (Lisp_Object xfont, | |
578 | 274 Error_Behavior errb); |
934 | 275 |
1204 | 276 static const struct memory_description font_instance_data_description_1 []= { |
277 #ifdef HAVE_TTY | |
3092 | 278 #ifdef NEW_GC |
279 { XD_LISP_OBJECT, tty_console }, | |
280 #else /* not NEW_GC */ | |
281 { XD_BLOCK_PTR, tty_console, 1, { &tty_font_instance_data_description } }, | |
282 #endif /* not NEW_GC */ | |
1204 | 283 #endif |
934 | 284 { XD_END } |
285 }; | |
286 | |
1204 | 287 static const struct sized_memory_description font_instance_data_description = { |
288 sizeof (void *), font_instance_data_description_1 | |
934 | 289 }; |
290 | |
1204 | 291 static const struct memory_description font_instance_description[] = { |
934 | 292 { XD_INT, offsetof (Lisp_Font_Instance, font_instance_type) }, |
293 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, name)}, | |
294 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, truename)}, | |
295 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, device)}, | |
3094 | 296 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, charset)}, |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
297 { XD_UNION, offsetof (Lisp_Font_Instance, data), |
2551 | 298 XD_INDIRECT (0, 0), { &font_instance_data_description } }, |
1204 | 299 { XD_END } |
934 | 300 }; |
301 | |
428 | 302 |
303 static Lisp_Object | |
304 mark_font_instance (Lisp_Object obj) | |
305 { | |
440 | 306 Lisp_Font_Instance *f = XFONT_INSTANCE (obj); |
428 | 307 |
308 mark_object (f->name); | |
872 | 309 mark_object (f->truename); |
428 | 310 if (!NILP (f->device)) /* Vthe_null_font_instance */ |
311 MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f)); | |
312 | |
313 return f->device; | |
314 } | |
315 | |
316 static void | |
317 print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | |
318 { | |
440 | 319 Lisp_Font_Instance *f = XFONT_INSTANCE (obj); |
428 | 320 if (print_readably) |
4846 | 321 printing_unreadable_lcrecord (obj, 0); |
800 | 322 write_fmt_string_lisp (printcharfun, "#<font-instance %S", 1, f->name); |
323 write_fmt_string_lisp (printcharfun, " on %s", 1, f->device); | |
428 | 324 if (!NILP (f->device)) |
3659 | 325 { |
326 MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance, | |
327 (f, printcharfun, escapeflag)); | |
328 | |
329 } | |
800 | 330 write_fmt_string (printcharfun, " 0x%x>", f->header.uid); |
428 | 331 } |
332 | |
333 static void | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
334 finalize_font_instance (Lisp_Object obj) |
428 | 335 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
336 Lisp_Font_Instance *f = XFONT_INSTANCE (obj); |
428 | 337 |
338 if (!NILP (f->device)) | |
339 { | |
340 MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f)); | |
341 } | |
342 } | |
343 | |
344 /* Fonts are equal if they resolve to the same name. | |
345 Since we call `font-truename' to do this, and since font-truename is lazy, | |
346 this means the `equal' could cause XListFonts to be run the first time. | |
347 */ | |
348 static int | |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
349 font_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
350 int UNUSED (foldcase)) |
428 | 351 { |
352 /* #### should this be moved into a device method? */ | |
793 | 353 return internal_equal (font_instance_truename_internal |
354 (obj1, ERROR_ME_DEBUG_WARN), | |
355 font_instance_truename_internal | |
356 (obj2, ERROR_ME_DEBUG_WARN), | |
428 | 357 depth + 1); |
358 } | |
359 | |
2515 | 360 static Hashcode |
428 | 361 font_instance_hash (Lisp_Object obj, int depth) |
362 { | |
793 | 363 return internal_hash (font_instance_truename_internal |
364 (obj, ERROR_ME_DEBUG_WARN), | |
428 | 365 depth + 1); |
366 } | |
367 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
368 DEFINE_NODUMP_LISP_OBJECT ("font-instance", font_instance, |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
369 mark_font_instance, print_font_instance, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
370 finalize_font_instance, font_instance_equal, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
371 font_instance_hash, font_instance_description, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
372 Lisp_Font_Instance); |
934 | 373 |
428 | 374 |
3094 | 375 /* #### Why is this exposed to Lisp? Used in: |
376 x-frob-font-size, gtk-font-menu-load-font, x-font-menu-load-font-xft, | |
377 x-font-menu-load-font-core, mswindows-font-menu-load-font, | |
378 mswindows-frob-font-style-and-sizify, mswindows-frob-font-size. */ | |
379 DEFUN ("make-font-instance", Fmake_font_instance, 1, 4, 0, /* | |
428 | 380 Return a new `font-instance' object named NAME. |
381 DEVICE specifies the device this object applies to and defaults to the | |
382 selected device. An error is signalled if the font is unknown or cannot | |
383 be allocated; however, if NOERROR is non-nil, nil is simply returned in | |
3094 | 384 this case. CHARSET is used internally. #### make helper function? |
428 | 385 |
386 The returned object is a normal, first-class lisp object. The way you | |
387 `deallocate' the font is the way you deallocate any other lisp object: | |
388 you drop all pointers to it and allow it to be garbage collected. When | |
3094 | 389 these objects are GCed, the underlying GUI data is deallocated as well. |
428 | 390 */ |
3094 | 391 (name, device, noerror, charset)) |
428 | 392 { |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
393 Lisp_Object obj; |
440 | 394 Lisp_Font_Instance *f; |
428 | 395 int retval = 0; |
578 | 396 Error_Behavior errb = decode_error_behavior_flag (noerror); |
428 | 397 |
398 if (ERRB_EQ (errb, ERROR_ME)) | |
399 CHECK_STRING (name); | |
400 else if (!STRINGP (name)) | |
401 return Qnil; | |
402 | |
793 | 403 device = wrap_device (decode_device (device)); |
428 | 404 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
405 obj = ALLOC_NORMAL_LISP_OBJECT (font_instance); |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
406 f = XFONT_INSTANCE (obj); |
428 | 407 f->name = name; |
872 | 408 f->truename = Qnil; |
428 | 409 f->device = device; |
410 | |
411 f->data = 0; | |
1204 | 412 f->font_instance_type = get_console_variant (XDEVICE_TYPE (f->device)); |
428 | 413 |
414 /* Stick some default values here ... */ | |
415 f->ascent = f->height = 1; | |
416 f->descent = 0; | |
417 f->width = 1; | |
3094 | 418 f->charset = charset; |
428 | 419 f->proportional_p = 0; |
420 | |
421 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance, | |
422 (f, name, device, errb)); | |
423 | |
424 if (!retval) | |
425 return Qnil; | |
426 | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
427 return obj; |
428 | 428 } |
429 | |
430 DEFUN ("font-instance-p", Ffont_instance_p, 1, 1, 0, /* | |
431 Return non-nil if OBJECT is a font instance. | |
432 */ | |
433 (object)) | |
434 { | |
435 return FONT_INSTANCEP (object) ? Qt : Qnil; | |
436 } | |
437 | |
438 DEFUN ("font-instance-name", Ffont_instance_name, 1, 1, 0, /* | |
439 Return the name used to allocate FONT-INSTANCE. | |
440 */ | |
441 (font_instance)) | |
442 { | |
443 CHECK_FONT_INSTANCE (font_instance); | |
444 return XFONT_INSTANCE (font_instance)->name; | |
445 } | |
446 | |
447 DEFUN ("font-instance-ascent", Ffont_instance_ascent, 1, 1, 0, /* | |
448 Return the ascent in pixels of FONT-INSTANCE. | |
449 The returned value is the maximum ascent for all characters in the font, | |
450 where a character's ascent is the number of pixels above (and including) | |
451 the baseline. | |
452 */ | |
453 (font_instance)) | |
454 { | |
455 CHECK_FONT_INSTANCE (font_instance); | |
456 return make_int (XFONT_INSTANCE (font_instance)->ascent); | |
457 } | |
458 | |
459 DEFUN ("font-instance-descent", Ffont_instance_descent, 1, 1, 0, /* | |
460 Return the descent in pixels of FONT-INSTANCE. | |
461 The returned value is the maximum descent for all characters in the font, | |
462 where a character's descent is the number of pixels below the baseline. | |
463 \(Many characters to do not have any descent. Typical characters with a | |
464 descent are lowercase p and lowercase g.) | |
465 */ | |
466 (font_instance)) | |
467 { | |
468 CHECK_FONT_INSTANCE (font_instance); | |
469 return make_int (XFONT_INSTANCE (font_instance)->descent); | |
470 } | |
471 | |
472 DEFUN ("font-instance-width", Ffont_instance_width, 1, 1, 0, /* | |
473 Return the width in pixels of FONT-INSTANCE. | |
474 The returned value is the average width for all characters in the font. | |
475 */ | |
476 (font_instance)) | |
477 { | |
478 CHECK_FONT_INSTANCE (font_instance); | |
479 return make_int (XFONT_INSTANCE (font_instance)->width); | |
480 } | |
481 | |
482 DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p, 1, 1, 0, /* | |
483 Return whether FONT-INSTANCE is proportional. | |
484 This means that different characters in the font have different widths. | |
485 */ | |
486 (font_instance)) | |
487 { | |
488 CHECK_FONT_INSTANCE (font_instance); | |
489 return XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil; | |
490 } | |
491 | |
492 static Lisp_Object | |
493 font_instance_truename_internal (Lisp_Object font_instance, | |
578 | 494 Error_Behavior errb) |
428 | 495 { |
440 | 496 Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance); |
497 | |
428 | 498 if (NILP (f->device)) |
499 { | |
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4426
diff
changeset
|
500 maybe_signal_error (Qgui_error, |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4426
diff
changeset
|
501 "can't determine truename: " |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4426
diff
changeset
|
502 "no device for font instance", |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4426
diff
changeset
|
503 font_instance, Qfont, errb); |
428 | 504 return Qnil; |
505 } | |
440 | 506 |
428 | 507 return DEVMETH_OR_GIVEN (XDEVICE (f->device), |
508 font_instance_truename, (f, errb), f->name); | |
509 } | |
510 | |
511 DEFUN ("font-instance-truename", Ffont_instance_truename, 1, 1, 0, /* | |
512 Return the canonical name of FONT-INSTANCE. | |
513 Font names are patterns which may match any number of fonts, of which | |
514 the first found is used. This returns an unambiguous name for that font | |
515 \(but not necessarily its only unambiguous name). | |
516 */ | |
517 (font_instance)) | |
518 { | |
519 CHECK_FONT_INSTANCE (font_instance); | |
520 return font_instance_truename_internal (font_instance, ERROR_ME); | |
521 } | |
522 | |
3094 | 523 DEFUN ("font-instance-charset", Ffont_instance_charset, 1, 1, 0, /* |
524 Return the Mule charset that FONT-INSTANCE was allocated to handle. | |
525 */ | |
526 (font_instance)) | |
527 { | |
528 CHECK_FONT_INSTANCE (font_instance); | |
529 return XFONT_INSTANCE (font_instance)->charset; | |
530 } | |
531 | |
428 | 532 DEFUN ("font-instance-properties", Ffont_instance_properties, 1, 1, 0, /* |
533 Return the properties (an alist or nil) of FONT-INSTANCE. | |
534 */ | |
535 (font_instance)) | |
536 { | |
440 | 537 Lisp_Font_Instance *f; |
428 | 538 |
539 CHECK_FONT_INSTANCE (font_instance); | |
540 f = XFONT_INSTANCE (font_instance); | |
541 | |
542 if (NILP (f->device)) | |
543 return Qnil; | |
544 | |
545 return MAYBE_LISP_DEVMETH (XDEVICE (f->device), | |
546 font_instance_properties, (f)); | |
547 } | |
548 | |
2527 | 549 DEFUN ("font-list", Ffont_list, 1, 3, 0, /* |
428 | 550 Return a list of font names matching the given pattern. |
551 DEVICE specifies which device to search for names, and defaults to the | |
552 currently selected device. | |
553 */ | |
1701 | 554 (pattern, device, maxnumber)) |
428 | 555 { |
556 CHECK_STRING (pattern); | |
793 | 557 device = wrap_device (decode_device (device)); |
428 | 558 |
2527 | 559 return MAYBE_LISP_DEVMETH (XDEVICE (device), font_list, (pattern, device, |
1701 | 560 maxnumber)); |
428 | 561 } |
562 | |
563 | |
564 /**************************************************************************** | |
565 Color Object | |
566 ***************************************************************************/ | |
1204 | 567 |
568 static const struct memory_description color_specifier_description[] = { | |
569 { XD_LISP_OBJECT, offsetof (struct color_specifier, face) }, | |
570 { XD_LISP_OBJECT, offsetof (struct color_specifier, face_property) }, | |
571 { XD_END } | |
572 }; | |
573 | |
574 DEFINE_SPECIFIER_TYPE_WITH_DATA (color); | |
428 | 575 /* Qcolor defined in general.c */ |
576 | |
577 static void | |
578 color_create (Lisp_Object obj) | |
579 { | |
440 | 580 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); |
428 | 581 |
582 COLOR_SPECIFIER_FACE (color) = Qnil; | |
583 COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil; | |
584 } | |
585 | |
586 static void | |
587 color_mark (Lisp_Object obj) | |
588 { | |
440 | 589 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); |
428 | 590 |
591 mark_object (COLOR_SPECIFIER_FACE (color)); | |
592 mark_object (COLOR_SPECIFIER_FACE_PROPERTY (color)); | |
593 } | |
594 | |
595 /* No equal or hash methods; ignore the face the color is based off | |
596 of for `equal' */ | |
597 | |
598 static Lisp_Object | |
2286 | 599 color_instantiate (Lisp_Object specifier, Lisp_Object UNUSED (matchspec), |
428 | 600 Lisp_Object domain, Lisp_Object instantiator, |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
601 Lisp_Object depth, int no_fallback) |
428 | 602 { |
603 /* When called, we're inside of call_with_suspended_errors(), | |
604 so we can freely error. */ | |
442 | 605 Lisp_Object device = DOMAIN_DEVICE (domain); |
428 | 606 struct device *d = XDEVICE (device); |
607 | |
608 if (COLOR_INSTANCEP (instantiator)) | |
609 { | |
610 /* If we are on the same device then we're done. Otherwise change | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
611 the instantiator to the name used to generate the pixel and let the |
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
612 STRINGP case deal with it. */ |
428 | 613 if (NILP (device) /* Vthe_null_color_instance */ |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
614 || EQ (device, XCOLOR_INSTANCE (instantiator)->device)) |
428 | 615 return instantiator; |
616 else | |
617 instantiator = Fcolor_instance_name (instantiator); | |
618 } | |
619 | |
620 if (STRINGP (instantiator)) | |
621 { | |
622 /* First, look to see if we can retrieve a cached value. */ | |
623 Lisp_Object instance = | |
624 Fgethash (instantiator, d->color_instance_cache, Qunbound); | |
625 /* Otherwise, make a new one. */ | |
626 if (UNBOUNDP (instance)) | |
627 { | |
628 /* make sure we cache the failures, too. */ | |
629 instance = Fmake_color_instance (instantiator, device, Qt); | |
630 Fputhash (instantiator, instance, d->color_instance_cache); | |
631 } | |
632 | |
633 return NILP (instance) ? Qunbound : instance; | |
634 } | |
635 else if (VECTORP (instantiator)) | |
636 { | |
637 switch (XVECTOR_LENGTH (instantiator)) | |
638 { | |
639 case 0: | |
640 if (DEVICE_TTY_P (d)) | |
641 return Vthe_null_color_instance; | |
642 else | |
563 | 643 gui_error ("Color instantiator [] only valid on TTY's", |
428 | 644 device); |
645 | |
646 case 1: | |
647 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier)))) | |
563 | 648 gui_error ("Color specifier not attached to a face", |
428 | 649 instantiator); |
650 return (FACE_PROPERTY_INSTANCE_1 | |
651 (Fget_face (XVECTOR_DATA (instantiator)[0]), | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
652 COLOR_SPECIFIER_FACE_PROPERTY |
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
653 (XCOLOR_SPECIFIER (specifier)), |
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
654 domain, ERROR_ME, no_fallback, depth)); |
428 | 655 |
656 case 2: | |
657 return (FACE_PROPERTY_INSTANCE_1 | |
658 (Fget_face (XVECTOR_DATA (instantiator)[0]), | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
659 XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, |
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
660 no_fallback, depth)); |
428 | 661 |
662 default: | |
2500 | 663 ABORT (); |
428 | 664 } |
665 } | |
666 else if (NILP (instantiator)) | |
667 { | |
668 if (DEVICE_TTY_P (d)) | |
669 return Vthe_null_color_instance; | |
670 else | |
563 | 671 gui_error ("Color instantiator [] only valid on TTY's", |
428 | 672 device); |
673 } | |
674 else | |
2500 | 675 ABORT (); /* The spec validation routines are screwed up. */ |
428 | 676 |
677 return Qunbound; | |
678 } | |
679 | |
680 static void | |
681 color_validate (Lisp_Object instantiator) | |
682 { | |
683 if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator)) | |
684 return; | |
685 if (VECTORP (instantiator)) | |
686 { | |
687 if (XVECTOR_LENGTH (instantiator) > 2) | |
563 | 688 sferror ("Inheritance vector must be of size 0 - 2", |
428 | 689 instantiator); |
690 else if (XVECTOR_LENGTH (instantiator) > 0) | |
691 { | |
692 Lisp_Object face = XVECTOR_DATA (instantiator)[0]; | |
693 | |
694 Fget_face (face); | |
695 if (XVECTOR_LENGTH (instantiator) == 2) | |
696 { | |
697 Lisp_Object field = XVECTOR_DATA (instantiator)[1]; | |
698 if (!EQ (field, Qforeground) && !EQ (field, Qbackground)) | |
563 | 699 invalid_constant |
428 | 700 ("Inheritance field must be `foreground' or `background'", |
701 field); | |
702 } | |
703 } | |
704 } | |
705 else | |
563 | 706 invalid_argument ("Invalid color instantiator", instantiator); |
428 | 707 } |
708 | |
709 static void | |
710 color_after_change (Lisp_Object specifier, Lisp_Object locale) | |
711 { | |
712 Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier)); | |
713 Lisp_Object property = | |
714 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)); | |
715 if (!NILP (face)) | |
448 | 716 { |
717 face_property_was_changed (face, property, locale); | |
718 if (BUFFERP (locale)) | |
719 XBUFFER (locale)->buffer_local_face_property = 1; | |
720 } | |
428 | 721 } |
722 | |
723 void | |
724 set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property) | |
725 { | |
440 | 726 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); |
428 | 727 |
728 COLOR_SPECIFIER_FACE (color) = face; | |
729 COLOR_SPECIFIER_FACE_PROPERTY (color) = property; | |
730 } | |
731 | |
732 DEFUN ("color-specifier-p", Fcolor_specifier_p, 1, 1, 0, /* | |
733 Return t if OBJECT is a color specifier. | |
734 | |
442 | 735 See `make-color-specifier' for a description of possible color instantiators. |
428 | 736 */ |
737 (object)) | |
738 { | |
739 return COLOR_SPECIFIERP (object) ? Qt : Qnil; | |
740 } | |
741 | |
742 | |
743 /**************************************************************************** | |
744 Font Object | |
745 ***************************************************************************/ | |
1204 | 746 |
747 static const struct memory_description font_specifier_description[] = { | |
748 { XD_LISP_OBJECT, offsetof (struct font_specifier, face) }, | |
749 { XD_LISP_OBJECT, offsetof (struct font_specifier, face_property) }, | |
750 { XD_END } | |
751 }; | |
752 | |
753 DEFINE_SPECIFIER_TYPE_WITH_DATA (font); | |
428 | 754 /* Qfont defined in general.c */ |
755 | |
756 static void | |
757 font_create (Lisp_Object obj) | |
758 { | |
440 | 759 Lisp_Specifier *font = XFONT_SPECIFIER (obj); |
428 | 760 |
761 FONT_SPECIFIER_FACE (font) = Qnil; | |
762 FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil; | |
763 } | |
764 | |
765 static void | |
766 font_mark (Lisp_Object obj) | |
767 { | |
440 | 768 Lisp_Specifier *font = XFONT_SPECIFIER (obj); |
428 | 769 |
770 mark_object (FONT_SPECIFIER_FACE (font)); | |
771 mark_object (FONT_SPECIFIER_FACE_PROPERTY (font)); | |
772 } | |
773 | |
774 /* No equal or hash methods; ignore the face the font is based off | |
775 of for `equal' */ | |
776 | |
777 #ifdef MULE | |
778 | |
872 | 779 /* Given a truename font spec (i.e. the font spec should have its registry |
780 field filled in), does it support displaying characters from CHARSET? */ | |
781 | |
782 static int | |
428 | 783 font_spec_matches_charset (struct device *d, Lisp_Object charset, |
867 | 784 const Ibyte *nonreloc, Lisp_Object reloc, |
872 | 785 Bytecount offset, Bytecount length, |
3659 | 786 enum font_specifier_matchspec_stages stage) |
428 | 787 { |
788 return DEVMETH_OR_GIVEN (d, font_spec_matches_charset, | |
872 | 789 (d, charset, nonreloc, reloc, offset, length, |
790 stage), | |
428 | 791 1); |
792 } | |
793 | |
794 static void | |
795 font_validate_matchspec (Lisp_Object matchspec) | |
796 { | |
872 | 797 CHECK_CONS (matchspec); |
798 Fget_charset (XCAR (matchspec)); | |
3659 | 799 |
800 do | |
801 { | |
802 if (EQ(XCDR(matchspec), Qinitial)) | |
803 { | |
804 break; | |
805 } | |
806 if (EQ(XCDR(matchspec), Qfinal)) | |
807 { | |
808 break; | |
809 } | |
810 | |
811 invalid_argument("Invalid font matchspec stage", | |
812 XCDR(matchspec)); | |
813 } while (0); | |
428 | 814 } |
815 | |
872 | 816 void |
817 initialize_charset_font_caches (struct device *d) | |
818 { | |
819 /* Note that the following tables are bi-level. */ | |
820 d->charset_font_cache_stage_1 = | |
821 make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); | |
822 d->charset_font_cache_stage_2 = | |
823 make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); | |
824 } | |
825 | |
826 void | |
827 invalidate_charset_font_caches (Lisp_Object charset) | |
828 { | |
829 /* Invalidate font cache entries for charset on all devices. */ | |
830 Lisp_Object devcons, concons, hash_table; | |
831 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
832 { | |
833 struct device *d = XDEVICE (XCAR (devcons)); | |
834 hash_table = Fgethash (charset, d->charset_font_cache_stage_1, | |
835 Qunbound); | |
836 if (!UNBOUNDP (hash_table)) | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
837 Fclrhash (hash_table); |
872 | 838 hash_table = Fgethash (charset, d->charset_font_cache_stage_2, |
839 Qunbound); | |
840 if (!UNBOUNDP (hash_table)) | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
841 Fclrhash (hash_table); |
872 | 842 } |
843 } | |
428 | 844 |
874 | 845 #endif /* MULE */ |
846 | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
847 /* It's a little non-obvious what's going on here. Specifically: |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
848 |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
849 MATCHSPEC is a somewhat bogus way in the specifier mechanism of passing |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
850 in additional information needed to instantiate some object. For fonts, |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
851 it's a cons of (CHARSET . SECOND-STAGE-P). SECOND-STAGE-P, if set, |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
852 means "try harder to find an appropriate font" and is a very bogus way |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
853 of dealing with the fact that it may not be possible to may a charset |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
854 directly onto a font; it's used esp. under Windows. @@#### We need to |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
855 change this so that MATCHSPEC is just a character. |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
856 |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
857 When redisplay is building up its structure, and needs font info, it |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
858 calls functions in faces.c such as ensure_face_cachel_complete() (map |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
859 fonts needed for a string of text) or |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
860 ensure_face_cachel_contains_charset() (map fonts needed for a charset |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
861 derived from a single character). The former function calls the latter; |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
862 the latter calls face_property_matching_instance(); this constructs the |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
863 MATCHSPEC and calls specifier_instance_no_quit() twice (first stage and |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
864 second stage, updating MATCHSPEC appropriately). That function, in |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
865 turn, looks up the appropriate specifier method to do the instantiation, |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
866 which, lo and behold, is this function here (because we set it in |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
867 initialization using `SPECIFIER_HAS_METHOD (font, instantiate);'). We |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
868 in turn call the device method `find_charset_font', which maps to |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
869 mswindows_find_charset_font(), x_find_charset_font(), or similar, in |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
870 objects-msw.c or the like. |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
871 |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
872 --ben */ |
874 | 873 |
428 | 874 static Lisp_Object |
2333 | 875 font_instantiate (Lisp_Object UNUSED (specifier), |
876 Lisp_Object USED_IF_MULE (matchspec), | |
428 | 877 Lisp_Object domain, Lisp_Object instantiator, |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
878 Lisp_Object depth, int no_fallback) |
428 | 879 { |
880 /* When called, we're inside of call_with_suspended_errors(), | |
881 so we can freely error. */ | |
442 | 882 Lisp_Object device = DOMAIN_DEVICE (domain); |
428 | 883 struct device *d = XDEVICE (device); |
884 Lisp_Object instance; | |
872 | 885 Lisp_Object charset = Qnil; |
1204 | 886 #ifdef MULE |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
887 enum font_specifier_matchspec_stages stage = STAGE_INITIAL; |
428 | 888 |
889 if (!UNBOUNDP (matchspec)) | |
872 | 890 { |
891 charset = Fget_charset (XCAR (matchspec)); | |
3659 | 892 |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
893 #define FROB(new_stage, enumstage) \ |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
894 if (EQ(Q##new_stage, XCDR(matchspec))) \ |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
895 { \ |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
896 stage = enumstage; \ |
3659 | 897 } |
898 | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
899 FROB (initial, STAGE_INITIAL) |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
900 else FROB (final, STAGE_FINAL) |
3659 | 901 else assert(0); |
902 | |
903 #undef FROB | |
904 | |
872 | 905 } |
428 | 906 #endif |
907 | |
908 if (FONT_INSTANCEP (instantiator)) | |
909 { | |
910 if (NILP (device) | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
911 || EQ (device, XFONT_INSTANCE (instantiator)->device)) |
428 | 912 { |
913 #ifdef MULE | |
872 | 914 if (font_spec_matches_charset (d, charset, 0, |
428 | 915 Ffont_instance_truename |
916 (instantiator), | |
872 | 917 0, -1, stage)) |
1204 | 918 #endif |
428 | 919 return instantiator; |
920 } | |
921 instantiator = Ffont_instance_name (instantiator); | |
922 } | |
923 | |
924 if (STRINGP (instantiator)) | |
925 { | |
874 | 926 #ifdef MULE |
3659 | 927 /* #### rename these caches. */ |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
928 Lisp_Object cache = stage == STAGE_FINAL ? |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
929 d->charset_font_cache_stage_2 : |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
930 d->charset_font_cache_stage_1; |
874 | 931 #else |
932 Lisp_Object cache = d->font_instance_cache; | |
933 #endif | |
872 | 934 |
428 | 935 #ifdef MULE |
872 | 936 if (!NILP (charset)) |
428 | 937 { |
938 /* The instantiator is a font spec that could match many | |
939 different fonts. We need to find one of those fonts | |
940 whose registry matches the registry of the charset in | |
941 MATCHSPEC. This is potentially a very slow operation, | |
942 as it involves doing an XListFonts() or equivalent to | |
943 iterate over all possible fonts, and a regexp match | |
944 on each one. So we cache the results. */ | |
945 Lisp_Object matching_font = Qunbound; | |
872 | 946 Lisp_Object hash_table = Fgethash (charset, cache, Qunbound); |
428 | 947 if (UNBOUNDP (hash_table)) |
948 { | |
949 /* need to make a sub hash table. */ | |
950 hash_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, | |
951 HASH_TABLE_EQUAL); | |
872 | 952 Fputhash (charset, hash_table, cache); |
428 | 953 } |
954 else | |
955 matching_font = Fgethash (instantiator, hash_table, Qunbound); | |
956 | |
957 if (UNBOUNDP (matching_font)) | |
958 { | |
959 /* make sure we cache the failures, too. */ | |
960 matching_font = | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
961 DEVMETH_OR_GIVEN (d, find_charset_font, |
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
962 (device, instantiator, charset, stage), |
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
963 instantiator); |
428 | 964 Fputhash (instantiator, matching_font, hash_table); |
965 } | |
966 if (NILP (matching_font)) | |
967 return Qunbound; | |
968 instantiator = matching_font; | |
969 } | |
970 #endif /* MULE */ | |
971 | |
972 /* First, look to see if we can retrieve a cached value. */ | |
872 | 973 instance = Fgethash (instantiator, cache, Qunbound); |
428 | 974 /* Otherwise, make a new one. */ |
975 if (UNBOUNDP (instance)) | |
976 { | |
977 /* make sure we cache the failures, too. */ | |
3094 | 978 instance = Fmake_font_instance (instantiator, device, Qt, charset); |
872 | 979 Fputhash (instantiator, instance, cache); |
428 | 980 } |
981 | |
982 return NILP (instance) ? Qunbound : instance; | |
983 } | |
984 else if (VECTORP (instantiator)) | |
985 { | |
3659 | 986 Lisp_Object match_inst = Qunbound; |
428 | 987 assert (XVECTOR_LENGTH (instantiator) == 1); |
3659 | 988 |
989 match_inst = face_property_matching_instance | |
990 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
991 charset, domain, ERROR_ME, no_fallback, depth, STAGE_INITIAL); |
3659 | 992 |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
993 if (UNBOUNDP(match_inst)) |
3659 | 994 { |
995 match_inst = face_property_matching_instance | |
996 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
997 charset, domain, ERROR_ME, no_fallback, depth, STAGE_FINAL); |
3659 | 998 } |
999 | |
1000 return match_inst; | |
1001 | |
428 | 1002 } |
1003 else if (NILP (instantiator)) | |
1004 return Qunbound; | |
1005 else | |
2500 | 1006 ABORT (); /* Eh? */ |
428 | 1007 |
1008 return Qunbound; | |
1009 } | |
1010 | |
1011 static void | |
1012 font_validate (Lisp_Object instantiator) | |
1013 { | |
1014 if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator)) | |
1015 return; | |
1016 if (VECTORP (instantiator)) | |
1017 { | |
1018 if (XVECTOR_LENGTH (instantiator) != 1) | |
1019 { | |
563 | 1020 sferror |
428 | 1021 ("Vector length must be one for font inheritance", instantiator); |
1022 } | |
1023 Fget_face (XVECTOR_DATA (instantiator)[0]); | |
1024 } | |
1025 else | |
563 | 1026 invalid_argument ("Must be string, vector, or font-instance", |
428 | 1027 instantiator); |
1028 } | |
1029 | |
1030 static void | |
1031 font_after_change (Lisp_Object specifier, Lisp_Object locale) | |
1032 { | |
1033 Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier)); | |
1034 Lisp_Object property = | |
1035 FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier)); | |
1036 if (!NILP (face)) | |
448 | 1037 { |
1038 face_property_was_changed (face, property, locale); | |
1039 if (BUFFERP (locale)) | |
1040 XBUFFER (locale)->buffer_local_face_property = 1; | |
1041 } | |
428 | 1042 } |
1043 | |
1044 void | |
1045 set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property) | |
1046 { | |
440 | 1047 Lisp_Specifier *font = XFONT_SPECIFIER (obj); |
428 | 1048 |
1049 FONT_SPECIFIER_FACE (font) = face; | |
1050 FONT_SPECIFIER_FACE_PROPERTY (font) = property; | |
1051 } | |
1052 | |
1053 DEFUN ("font-specifier-p", Ffont_specifier_p, 1, 1, 0, /* | |
1054 Return non-nil if OBJECT is a font specifier. | |
1055 | |
442 | 1056 See `make-font-specifier' for a description of possible font instantiators. |
428 | 1057 */ |
1058 (object)) | |
1059 { | |
1060 return FONT_SPECIFIERP (object) ? Qt : Qnil; | |
1061 } | |
1062 | |
1063 | |
1064 /***************************************************************************** | |
1065 Face Boolean Object | |
1066 ****************************************************************************/ | |
1204 | 1067 |
1068 static const struct memory_description face_boolean_specifier_description[] = { | |
1069 { XD_LISP_OBJECT, offsetof (struct face_boolean_specifier, face) }, | |
1070 { XD_LISP_OBJECT, offsetof (struct face_boolean_specifier, face_property) }, | |
1071 { XD_END } | |
1072 }; | |
1073 | |
1074 DEFINE_SPECIFIER_TYPE_WITH_DATA (face_boolean); | |
428 | 1075 Lisp_Object Qface_boolean; |
1076 | |
1077 static void | |
1078 face_boolean_create (Lisp_Object obj) | |
1079 { | |
440 | 1080 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); |
428 | 1081 |
1082 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil; | |
1083 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil; | |
1084 } | |
1085 | |
1086 static void | |
1087 face_boolean_mark (Lisp_Object obj) | |
1088 { | |
440 | 1089 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); |
428 | 1090 |
1091 mark_object (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean)); | |
1092 mark_object (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean)); | |
1093 } | |
1094 | |
1095 /* No equal or hash methods; ignore the face the face-boolean is based off | |
1096 of for `equal' */ | |
1097 | |
1098 static Lisp_Object | |
2286 | 1099 face_boolean_instantiate (Lisp_Object specifier, |
1100 Lisp_Object UNUSED (matchspec), | |
428 | 1101 Lisp_Object domain, Lisp_Object instantiator, |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
1102 Lisp_Object depth, int no_fallback) |
428 | 1103 { |
1104 /* When called, we're inside of call_with_suspended_errors(), | |
1105 so we can freely error. */ | |
1106 if (NILP (instantiator) || EQ (instantiator, Qt)) | |
1107 return instantiator; | |
1108 else if (VECTORP (instantiator)) | |
1109 { | |
1110 Lisp_Object retval; | |
1111 Lisp_Object prop; | |
1112 int instantiator_len = XVECTOR_LENGTH (instantiator); | |
1113 | |
1114 assert (instantiator_len >= 1 && instantiator_len <= 3); | |
1115 if (instantiator_len > 1) | |
1116 prop = XVECTOR_DATA (instantiator)[1]; | |
1117 else | |
1118 { | |
1119 if (NILP (FACE_BOOLEAN_SPECIFIER_FACE | |
1120 (XFACE_BOOLEAN_SPECIFIER (specifier)))) | |
563 | 1121 gui_error |
428 | 1122 ("Face-boolean specifier not attached to a face", instantiator); |
1123 prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY | |
1124 (XFACE_BOOLEAN_SPECIFIER (specifier)); | |
1125 } | |
1126 | |
1127 retval = (FACE_PROPERTY_INSTANCE_1 | |
1128 (Fget_face (XVECTOR_DATA (instantiator)[0]), | |
4426
515b91f904c1
Fix specifier inheritance behavior
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
1129 prop, domain, ERROR_ME, no_fallback, depth)); |
428 | 1130 |
1131 if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2])) | |
1132 retval = NILP (retval) ? Qt : Qnil; | |
1133 | |
1134 return retval; | |
1135 } | |
1136 else | |
2500 | 1137 ABORT (); /* Eh? */ |
428 | 1138 |
1139 return Qunbound; | |
1140 } | |
1141 | |
1142 static void | |
1143 face_boolean_validate (Lisp_Object instantiator) | |
1144 { | |
1145 if (NILP (instantiator) || EQ (instantiator, Qt)) | |
1146 return; | |
1147 else if (VECTORP (instantiator) && | |
1148 (XVECTOR_LENGTH (instantiator) >= 1 && | |
1149 XVECTOR_LENGTH (instantiator) <= 3)) | |
1150 { | |
1151 Lisp_Object face = XVECTOR_DATA (instantiator)[0]; | |
1152 | |
1153 Fget_face (face); | |
1154 | |
1155 if (XVECTOR_LENGTH (instantiator) > 1) | |
1156 { | |
1157 Lisp_Object field = XVECTOR_DATA (instantiator)[1]; | |
1158 if (!EQ (field, Qunderline) | |
1159 && !EQ (field, Qstrikethru) | |
1160 && !EQ (field, Qhighlight) | |
1161 && !EQ (field, Qdim) | |
1162 && !EQ (field, Qblinking) | |
1163 && !EQ (field, Qreverse)) | |
563 | 1164 invalid_constant ("Invalid face-boolean inheritance field", |
428 | 1165 field); |
1166 } | |
1167 } | |
1168 else if (VECTORP (instantiator)) | |
563 | 1169 sferror ("Wrong length for face-boolean inheritance spec", |
428 | 1170 instantiator); |
1171 else | |
563 | 1172 invalid_argument ("Face-boolean instantiator must be nil, t, or vector", |
428 | 1173 instantiator); |
1174 } | |
1175 | |
1176 static void | |
1177 face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale) | |
1178 { | |
1179 Lisp_Object face = | |
1180 FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier)); | |
1181 Lisp_Object property = | |
1182 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier)); | |
1183 if (!NILP (face)) | |
448 | 1184 { |
1185 face_property_was_changed (face, property, locale); | |
1186 if (BUFFERP (locale)) | |
1187 XBUFFER (locale)->buffer_local_face_property = 1; | |
1188 } | |
428 | 1189 } |
1190 | |
1191 void | |
1192 set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face, | |
1193 Lisp_Object property) | |
1194 { | |
440 | 1195 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); |
428 | 1196 |
1197 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face; | |
1198 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property; | |
1199 } | |
1200 | |
1201 DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p, 1, 1, 0, /* | |
1202 Return non-nil if OBJECT is a face-boolean specifier. | |
1203 | |
442 | 1204 See `make-face-boolean-specifier' for a description of possible |
1205 face-boolean instantiators. | |
428 | 1206 */ |
1207 (object)) | |
1208 { | |
1209 return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil; | |
1210 } | |
1211 | |
1212 | |
1213 /************************************************************************/ | |
1214 /* initialization */ | |
1215 /************************************************************************/ | |
1216 | |
1217 void | |
1218 syms_of_objects (void) | |
1219 { | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1220 INIT_LISP_OBJECT (color_instance); |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1221 INIT_LISP_OBJECT (font_instance); |
442 | 1222 |
428 | 1223 DEFSUBR (Fcolor_specifier_p); |
1224 DEFSUBR (Ffont_specifier_p); | |
1225 DEFSUBR (Fface_boolean_specifier_p); | |
1226 | |
563 | 1227 DEFSYMBOL_MULTIWORD_PREDICATE (Qcolor_instancep); |
428 | 1228 DEFSUBR (Fmake_color_instance); |
1229 DEFSUBR (Fcolor_instance_p); | |
1230 DEFSUBR (Fcolor_instance_name); | |
1231 DEFSUBR (Fcolor_instance_rgb_components); | |
1232 DEFSUBR (Fvalid_color_name_p); | |
2527 | 1233 DEFSUBR (Fcolor_list); |
428 | 1234 |
563 | 1235 DEFSYMBOL_MULTIWORD_PREDICATE (Qfont_instancep); |
428 | 1236 DEFSUBR (Fmake_font_instance); |
1237 DEFSUBR (Ffont_instance_p); | |
1238 DEFSUBR (Ffont_instance_name); | |
1239 DEFSUBR (Ffont_instance_ascent); | |
1240 DEFSUBR (Ffont_instance_descent); | |
1241 DEFSUBR (Ffont_instance_width); | |
3094 | 1242 DEFSUBR (Ffont_instance_charset); |
428 | 1243 DEFSUBR (Ffont_instance_proportional_p); |
1244 DEFSUBR (Ffont_instance_truename); | |
1245 DEFSUBR (Ffont_instance_properties); | |
2527 | 1246 DEFSUBR (Ffont_list); |
428 | 1247 |
1248 /* Qcolor, Qfont defined in general.c */ | |
563 | 1249 DEFSYMBOL (Qface_boolean); |
428 | 1250 } |
1251 | |
1252 void | |
1253 specifier_type_create_objects (void) | |
1254 { | |
1255 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p"); | |
1256 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p"); | |
1257 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean", | |
1258 "face-boolean-specifier-p"); | |
1259 | |
1260 SPECIFIER_HAS_METHOD (color, instantiate); | |
1261 SPECIFIER_HAS_METHOD (font, instantiate); | |
1262 SPECIFIER_HAS_METHOD (face_boolean, instantiate); | |
1263 | |
1264 SPECIFIER_HAS_METHOD (color, validate); | |
1265 SPECIFIER_HAS_METHOD (font, validate); | |
1266 SPECIFIER_HAS_METHOD (face_boolean, validate); | |
1267 | |
1268 SPECIFIER_HAS_METHOD (color, create); | |
1269 SPECIFIER_HAS_METHOD (font, create); | |
1270 SPECIFIER_HAS_METHOD (face_boolean, create); | |
1271 | |
1272 SPECIFIER_HAS_METHOD (color, mark); | |
1273 SPECIFIER_HAS_METHOD (font, mark); | |
1274 SPECIFIER_HAS_METHOD (face_boolean, mark); | |
1275 | |
1276 SPECIFIER_HAS_METHOD (color, after_change); | |
1277 SPECIFIER_HAS_METHOD (font, after_change); | |
1278 SPECIFIER_HAS_METHOD (face_boolean, after_change); | |
1279 | |
1280 #ifdef MULE | |
1281 SPECIFIER_HAS_METHOD (font, validate_matchspec); | |
1282 #endif | |
1283 } | |
1284 | |
1285 void | |
1286 reinit_specifier_type_create_objects (void) | |
1287 { | |
1288 REINITIALIZE_SPECIFIER_TYPE (color); | |
1289 REINITIALIZE_SPECIFIER_TYPE (font); | |
1290 REINITIALIZE_SPECIFIER_TYPE (face_boolean); | |
1291 } | |
1292 | |
1293 void | |
1294 reinit_vars_of_objects (void) | |
1295 { | |
1296 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1297 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (color_instance); |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1298 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); |
428 | 1299 c->name = Qnil; |
1300 c->device = Qnil; | |
1301 c->data = 0; | |
1302 | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1303 Vthe_null_color_instance = obj; |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1304 staticpro_nodump (&Vthe_null_color_instance); |
428 | 1305 } |
1306 | |
1307 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1308 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (font_instance); |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1309 Lisp_Font_Instance *f = XFONT_INSTANCE (obj); |
428 | 1310 f->name = Qnil; |
872 | 1311 f->truename = Qnil; |
428 | 1312 f->device = Qnil; |
1313 f->data = 0; | |
1314 | |
1315 f->ascent = f->height = 0; | |
1316 f->descent = 0; | |
1317 f->width = 0; | |
1318 f->proportional_p = 0; | |
1319 | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1320 Vthe_null_font_instance = obj; |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3017
diff
changeset
|
1321 staticpro_nodump (&Vthe_null_font_instance); |
428 | 1322 } |
1323 } | |
1324 | |
1325 void | |
1326 vars_of_objects (void) | |
1327 { | |
1328 } |