comparison src/objects.c @ 934:c925bacdda60

[xemacs-hg @ 2002-07-29 09:21:12 by michaels] 2002-07-17 Marcus Crestani <crestani@informatik.uni-tuebingen.de> Markus Kaltenbach <makalten@informatik.uni-tuebingen.de> Mike Sperber <mike@xemacs.org> configure flag to turn these changes on: --use-kkcc First we added a dumpable flag to lrecord_implementation. It shows, if the object is dumpable and should be processed by the dumper. * lrecord.h (struct lrecord_implementation): added dumpable flag (MAKE_LRECORD_IMPLEMENTATION): fitted the different makro definitions to the new lrecord_implementation and their calls. Then we changed mark_object, that it no longer needs a mark method for those types that have pdump descritions. * alloc.c: (mark_object): If the object has a description, the new mark algorithm is called, and the object is marked according to its description. Otherwise it uses the mark method like before. These procedures mark objects according to their descriptions. They are modeled on the corresponding pdumper procedures. (mark_with_description): (get_indirect_count): (structure_size): (mark_struct_contents): These procedures still call mark_object, this is needed while there are Lisp_Objects without descriptions left. We added pdump descriptions for many Lisp_Objects: * extents.c: extent_auxiliary_description * database.c: database_description * gui.c: gui_item_description * scrollbar.c: scrollbar_instance_description * toolbar.c: toolbar_button_description * event-stream.c: command_builder_description * mule-charset.c: charset_description * device-msw.c: devmode_description * dialog-msw.c: mswindows_dialog_id_description * eldap.c: ldap_description * postgresql.c: pgconn_description pgresult_description * tooltalk.c: tooltalk_message_description tooltalk_pattern_description * ui-gtk.c: emacs_ffi_description emacs_gtk_object_description * events.c: * events.h: * event-stream.c: * event-Xt.c: * event-gtk.c: * event-tty.c: To write a pdump description for Lisp_Event, we converted every struct in the union event to a Lisp_Object. So we created nine new Lisp_Objects: Lisp_Key_Data, Lisp_Button_Data, Lisp_Motion_Data, Lisp_Process_Data, Lisp_Timeout_Data, Lisp_Eval_Data, Lisp_Misc_User_Data, Lisp_Magic_Data, Lisp_Magic_Eval_Data. We also wrote makro selectors and mutators for the fields of the new designed Lisp_Event and added everywhere these new abstractions. We implemented XD_UNION support in (mark_with_description), so we can describe exspecially console/device specific data with XD_UNION. To describe with XD_UNION, we added a field to these objects, which holds the variant type of the object. This field is initialized in the appendant constructor. The variant is an integer, it has also to be described in an description, if XD_UNION is used. XD_UNION is used in following descriptions: * console.c: console_description (get_console_variant): returns the variant (create_console): added variant initialization * console.h (console_variant): the different console types * console-impl.h (struct console): added enum console_variant contype * device.c: device_description (Fmake_device): added variant initialization * device-impl.h (struct device): added enum console_variant devtype * objects.c: image_instance_description font_instance_description (Fmake_color_instance): added variant initialization (Fmake_font_instance): added variant initialization * objects-impl.h (struct Lisp_Color_Instance): added color_instance_type * objects-impl.h (struct Lisp_Font_Instance): added font_instance_type * process.c: process_description (make_process_internal): added variant initialization * process.h (process_variant): the different process types
author michaels
date Mon, 29 Jul 2002 09:21:25 +0000
parents d4ba25667ff4
children e22b0213b713
comparison
equal deleted inserted replaced
933:f6bc42928b34 934:c925bacdda60
33 #include "glyphs.h" 33 #include "glyphs.h"
34 #include "objects-impl.h" 34 #include "objects-impl.h"
35 #include "specifier.h" 35 #include "specifier.h"
36 #include "window.h" 36 #include "window.h"
37 37
38 #ifdef USE_KKCC
39 #include "objects-tty-impl.h"
40 #endif /* USE_KKCC */
41
38 /* Objects that are substituted when an instantiation fails. 42 /* Objects that are substituted when an instantiation fails.
39 If we leave in the Qunbound value, we will probably get crashes. */ 43 If we leave in the Qunbound value, we will probably get crashes. */
40 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance; 44 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance;
41 45
42 /* Authors: Ben Wing, Chuck Thompson */ 46 /* Authors: Ben Wing, Chuck Thompson */
55 /**************************************************************************** 59 /****************************************************************************
56 * Color-Instance Object * 60 * Color-Instance Object *
57 ****************************************************************************/ 61 ****************************************************************************/
58 62
59 Lisp_Object Qcolor_instancep; 63 Lisp_Object Qcolor_instancep;
64
65 #ifdef USE_KKCC
66 static const struct lrecord_description empty_color_instance_data_description [] = {
67 { XD_END }
68 };
69
70 static const struct lrecord_description tty_color_instance_data_description [] = {
71 { XD_LISP_OBJECT, offsetof (struct tty_color_instance_data, symbol) },
72 { XD_END }
73 };
74
75 static const struct struct_description color_instance_data_description []= {
76 { dead_console, empty_color_instance_data_description},
77 { tty_console, tty_color_instance_data_description},
78 { gtk_console, empty_color_instance_data_description},
79 { x_console, empty_color_instance_data_description},
80 { mswindows_console, empty_color_instance_data_description},
81 { stream_console, empty_color_instance_data_description},
82 { XD_END }
83 };
84
85 static const struct lrecord_description color_instance_description[] = {
86 { XD_INT, offsetof (Lisp_Color_Instance, color_instance_type) },
87 { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, name)},
88 { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, device)},
89 { XD_UNION, offsetof (Lisp_Color_Instance, data),
90 XD_INDIRECT (0, 0), color_instance_data_description },
91 {XD_END}
92 };
93 #endif /* USE_KKCC */
60 94
61 static Lisp_Object 95 static Lisp_Object
62 mark_color_instance (Lisp_Object obj) 96 mark_color_instance (Lisp_Object obj)
63 { 97 {
64 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); 98 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
120 !d ? LISP_HASH (obj) 154 !d ? LISP_HASH (obj)
121 : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth), 155 : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth),
122 LISP_HASH (obj))); 156 LISP_HASH (obj)));
123 } 157 }
124 158
159 #ifdef USE_KKCC
160 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance,
161 0, /*dumpable-flag*/
162 mark_color_instance, print_color_instance,
163 finalize_color_instance, color_instance_equal,
164 color_instance_hash,
165 color_instance_description,
166 Lisp_Color_Instance);
167 #else /* not USE_KKCC */
125 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance, 168 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance,
126 mark_color_instance, print_color_instance, 169 mark_color_instance, print_color_instance,
127 finalize_color_instance, color_instance_equal, 170 finalize_color_instance, color_instance_equal,
128 color_instance_hash, 0, 171 color_instance_hash, 0,
129 Lisp_Color_Instance); 172 Lisp_Color_Instance);
173 #endif /* not USE_KKCC */
130 174
131 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /* 175 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /*
132 Return a new `color-instance' object named NAME (a string). 176 Return a new `color-instance' object named NAME (a string).
133 177
134 Optional argument DEVICE specifies the device this object applies to 178 Optional argument DEVICE specifies the device this object applies to
155 199
156 c = alloc_lcrecord_type (Lisp_Color_Instance, &lrecord_color_instance); 200 c = alloc_lcrecord_type (Lisp_Color_Instance, &lrecord_color_instance);
157 c->name = name; 201 c->name = name;
158 c->device = device; 202 c->device = device;
159 c->data = 0; 203 c->data = 0;
204 #ifdef USE_KKCC
205 c->color_instance_type = get_console_variant(XDEVICE_TYPE(c->device));
206 #endif /* USE_KKCC */
160 207
161 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance, 208 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance,
162 (c, name, device, 209 (c, name, device,
163 decode_error_behavior_flag (noerror))); 210 decode_error_behavior_flag (noerror)));
164 if (!retval) 211 if (!retval)
229 276
230 Lisp_Object Qfont_instancep; 277 Lisp_Object Qfont_instancep;
231 278
232 static Lisp_Object font_instance_truename_internal (Lisp_Object xfont, 279 static Lisp_Object font_instance_truename_internal (Lisp_Object xfont,
233 Error_Behavior errb); 280 Error_Behavior errb);
281 #ifdef USE_KKCC
282 static const struct lrecord_description empty_font_instance_data_description [] = {
283 { XD_END }
284 };
285
286 static const struct lrecord_description tty_font_instance_data_description [] = {
287 { XD_LISP_OBJECT, offsetof (struct tty_font_instance_data, charset) },
288 { XD_END }
289 };
290
291 static const struct struct_description font_instance_data_description []= {
292 { dead_console, empty_font_instance_data_description},
293 { tty_console, tty_font_instance_data_description},
294 { gtk_console, empty_font_instance_data_description},
295 { x_console, empty_font_instance_data_description},
296 { mswindows_console, empty_font_instance_data_description},
297 { stream_console, empty_font_instance_data_description},
298 { XD_END }
299 };
300
301 static const struct lrecord_description font_instance_description[] = {
302 { XD_INT, offsetof (Lisp_Font_Instance, font_instance_type) },
303 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, name)},
304 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, truename)},
305 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, device)},
306 { XD_UNION, offsetof (Lisp_Font_Instance, data),
307 XD_INDIRECT (0, 0), font_instance_data_description },
308 {XD_END}
309 };
310 #endif /* USE_KKCC */
311
234 312
235 static Lisp_Object 313 static Lisp_Object
236 mark_font_instance (Lisp_Object obj) 314 mark_font_instance (Lisp_Object obj)
237 { 315 {
238 Lisp_Font_Instance *f = XFONT_INSTANCE (obj); 316 Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
292 return internal_hash (font_instance_truename_internal 370 return internal_hash (font_instance_truename_internal
293 (obj, ERROR_ME_DEBUG_WARN), 371 (obj, ERROR_ME_DEBUG_WARN),
294 depth + 1); 372 depth + 1);
295 } 373 }
296 374
375 #ifdef USE_KKCC
376 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance,
377 0, /*dumpable-flag*/
378 mark_font_instance, print_font_instance,
379 finalize_font_instance, font_instance_equal,
380 font_instance_hash, font_instance_description, Lisp_Font_Instance);
381 #else /* not USE_KKCC */
297 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance, 382 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance,
298 mark_font_instance, print_font_instance, 383 mark_font_instance, print_font_instance,
299 finalize_font_instance, font_instance_equal, 384 finalize_font_instance, font_instance_equal,
300 font_instance_hash, 0, Lisp_Font_Instance); 385 font_instance_hash, 0, Lisp_Font_Instance);
386 #endif /* not USE_KKCC */
387
301 388
302 DEFUN ("make-font-instance", Fmake_font_instance, 1, 3, 0, /* 389 DEFUN ("make-font-instance", Fmake_font_instance, 1, 3, 0, /*
303 Return a new `font-instance' object named NAME. 390 Return a new `font-instance' object named NAME.
304 DEVICE specifies the device this object applies to and defaults to the 391 DEVICE specifies the device this object applies to and defaults to the
305 selected device. An error is signalled if the font is unknown or cannot 392 selected device. An error is signalled if the font is unknown or cannot
328 f->name = name; 415 f->name = name;
329 f->truename = Qnil; 416 f->truename = Qnil;
330 f->device = device; 417 f->device = device;
331 418
332 f->data = 0; 419 f->data = 0;
420 #ifdef USE_KKCC
421 f->font_instance_type = get_console_variant(XDEVICE_TYPE(f->device));
422 #endif /* USE_KKCC */
333 423
334 /* Stick some default values here ... */ 424 /* Stick some default values here ... */
335 f->ascent = f->height = 1; 425 f->ascent = f->height = 1;
336 f->descent = 0; 426 f->descent = 0;
337 f->width = 1; 427 f->width = 1;