comparison src/console.c @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 41dbb7a9d5f2
children
comparison
equal deleted inserted replaced
423:28d9c139be4c 424:11054d720c21
51 in this structure as an individual console's value occupies in 51 in this structure as an individual console's value occupies in
52 that console. Setting the default value also goes through the 52 that console. Setting the default value also goes through the
53 list of consoles and stores into each console that does not say 53 list of consoles and stores into each console that does not say
54 it has a local value. */ 54 it has a local value. */
55 Lisp_Object Vconsole_defaults; 55 Lisp_Object Vconsole_defaults;
56 static void *console_defaults_saved_slots;
56 57
57 /* This structure marks which slots in a console have corresponding 58 /* This structure marks which slots in a console have corresponding
58 default values in console_defaults. 59 default values in console_defaults.
59 Each such slot has a nonzero value in this structure. 60 Each such slot has a nonzero value in this structure.
60 The value has only one nonzero bit. 61 The value has only one nonzero bit.
67 for the slot, but there is no default value for it; the corresponding 68 for the slot, but there is no default value for it; the corresponding
68 slot in console_defaults is not used except to initialize newly-created 69 slot in console_defaults is not used except to initialize newly-created
69 consoles. 70 consoles.
70 71
71 If a slot is -1, then there is a DEFVAR_CONSOLE_LOCAL for it 72 If a slot is -1, then there is a DEFVAR_CONSOLE_LOCAL for it
72 as well as a default value which is used to initialize newly-created 73 as well as a default value which is used to initialize newly-created
73 consoles and as a reset-value when local-vars are killed. 74 consoles and as a reset-value when local-vars are killed.
74 75
75 If a slot is -2, there is no DEFVAR_CONSOLE_LOCAL for it. 76 If a slot is -2, there is no DEFVAR_CONSOLE_LOCAL for it.
76 (The slot is always local, but there's no lisp variable for it.) 77 (The slot is always local, but there's no lisp variable for it.)
77 The default value is only used to initialize newly-creation consoles. 78 The default value is only used to initialize newly-creation consoles.
85 struct console console_local_flags; 86 struct console console_local_flags;
86 87
87 /* This structure holds the names of symbols whose values may be 88 /* This structure holds the names of symbols whose values may be
88 console-local. It is indexed and accessed in the same way as the above. */ 89 console-local. It is indexed and accessed in the same way as the above. */
89 static Lisp_Object Vconsole_local_symbols; 90 static Lisp_Object Vconsole_local_symbols;
91 static void *console_local_symbols_saved_slots;
90 92
91 DEFINE_CONSOLE_TYPE (dead); 93 DEFINE_CONSOLE_TYPE (dead);
92 94
93 Lisp_Object Vconsole_type_list; 95 Lisp_Object Vconsole_type_list;
94 96
95 console_type_entry_dynarr *the_console_type_entry_dynarr; 97 console_type_entry_dynarr *the_console_type_entry_dynarr;
96 98
97 99
98 static Lisp_Object 100 static Lisp_Object
99 mark_console (Lisp_Object obj, void (*markobj) (Lisp_Object)) 101 mark_console (Lisp_Object obj)
100 { 102 {
101 struct console *con = XCONSOLE (obj); 103 struct console *con = XCONSOLE (obj);
102 104
103 #define MARKED_SLOT(x) ((void) (markobj (con->x))); 105 #define MARKED_SLOT(x) mark_object (con->x)
104 #include "conslots.h" 106 #include "conslots.h"
105 #undef MARKED_SLOT 107 #undef MARKED_SLOT
106 108
107 /* Can be zero for Vconsole_defaults, Vconsole_local_symbols */ 109 /* Can be zero for Vconsole_defaults, Vconsole_local_symbols */
108 if (con->conmeths) 110 if (con->conmeths)
109 { 111 {
110 markobj (con->conmeths->symbol); 112 mark_object (con->conmeths->symbol);
111 MAYBE_CONMETH (con, mark_console, (con, markobj)); 113 MAYBE_CONMETH (con, mark_console, (con));
112 } 114 }
113 115
114 return Qnil; 116 return Qnil;
115 } 117 }
116 118
1094 1096
1095 defsymbol (&Qsuspend_hook, "suspend-hook"); 1097 defsymbol (&Qsuspend_hook, "suspend-hook");
1096 defsymbol (&Qsuspend_resume_hook, "suspend-resume-hook"); 1098 defsymbol (&Qsuspend_resume_hook, "suspend-resume-hook");
1097 } 1099 }
1098 1100
1101 static const struct lrecord_description cte_description_1[] = {
1102 { XD_LISP_OBJECT, offsetof(console_type_entry, symbol), 1 },
1103 { XD_STRUCT_PTR, offsetof(console_type_entry, meths), 1, &console_methods_description },
1104 { XD_END }
1105 };
1106
1107 static const struct struct_description cte_description = {
1108 sizeof(console_type_entry),
1109 cte_description_1
1110 };
1111
1112 static const struct lrecord_description cted_description_1[] = {
1113 XD_DYNARR_DESC(console_type_entry_dynarr, &cte_description),
1114 { XD_END }
1115 };
1116
1117 const struct struct_description cted_description = {
1118 sizeof(console_type_entry_dynarr),
1119 cted_description_1
1120 };
1121
1122 static const struct lrecord_description console_methods_description_1[] = {
1123 { XD_LISP_OBJECT, offsetof(struct console_methods, symbol), 2 },
1124 { XD_LISP_OBJECT, offsetof(struct console_methods, image_conversion_list), 1 },
1125 { XD_END }
1126 };
1127
1128 const struct struct_description console_methods_description = {
1129 sizeof(struct console_methods),
1130 console_methods_description_1
1131 };
1132
1133
1099 void 1134 void
1100 console_type_create (void) 1135 console_type_create (void)
1101 { 1136 {
1102 the_console_type_entry_dynarr = Dynarr_new (console_type_entry); 1137 the_console_type_entry_dynarr = Dynarr_new (console_type_entry);
1138 dumpstruct(&the_console_type_entry_dynarr, &cted_description);
1103 1139
1104 Vconsole_type_list = Qnil; 1140 Vconsole_type_list = Qnil;
1105 staticpro (&Vconsole_type_list); 1141 staticpro (&Vconsole_type_list);
1106 1142
1107 /* Initialize the dead console type */ 1143 /* Initialize the dead console type */
1112 Dynarr_reset (the_console_type_entry_dynarr); 1148 Dynarr_reset (the_console_type_entry_dynarr);
1113 Vconsole_type_list = Qnil; 1149 Vconsole_type_list = Qnil;
1114 } 1150 }
1115 1151
1116 void 1152 void
1153 reinit_vars_of_console (void)
1154 {
1155 staticpro_nodump (&Vconsole_list);
1156 Vconsole_list = Qnil;
1157 staticpro_nodump (&Vselected_console);
1158 Vselected_console = Qnil;
1159 }
1160
1161 void
1117 vars_of_console (void) 1162 vars_of_console (void)
1118 { 1163 {
1164 reinit_vars_of_console ();
1165
1119 DEFVAR_LISP ("create-console-hook", &Vcreate_console_hook /* 1166 DEFVAR_LISP ("create-console-hook", &Vcreate_console_hook /*
1120 Function or functions to call when a console is created. 1167 Function or functions to call when a console is created.
1121 One argument, the newly-created console. 1168 One argument, the newly-created console.
1122 This is called after the first frame has been created, but before 1169 This is called after the first frame has been created, but before
1123 calling the `create-device-hook' or `create-frame-hook'. 1170 calling the `create-device-hook' or `create-frame-hook'.
1128 DEFVAR_LISP ("delete-console-hook", &Vdelete_console_hook /* 1175 DEFVAR_LISP ("delete-console-hook", &Vdelete_console_hook /*
1129 Function or functions to call when a console is deleted. 1176 Function or functions to call when a console is deleted.
1130 One argument, the to-be-deleted console. 1177 One argument, the to-be-deleted console.
1131 */ ); 1178 */ );
1132 Vdelete_console_hook = Qnil; 1179 Vdelete_console_hook = Qnil;
1133
1134 staticpro (&Vconsole_list);
1135 Vconsole_list = Qnil;
1136 staticpro (&Vselected_console);
1137 Vselected_console = Qnil;
1138 1180
1139 #ifdef HAVE_WINDOW_SYSTEM 1181 #ifdef HAVE_WINDOW_SYSTEM
1140 Fprovide (intern ("window-system")); 1182 Fprovide (intern ("window-system"));
1141 #endif 1183 #endif
1142 } 1184 }
1182 static void 1224 static void
1183 nuke_all_console_slots (struct console *con, Lisp_Object zap) 1225 nuke_all_console_slots (struct console *con, Lisp_Object zap)
1184 { 1226 {
1185 zero_lcrecord (con); 1227 zero_lcrecord (con);
1186 1228
1187 #define MARKED_SLOT(x) con->x = (zap); 1229 #define MARKED_SLOT(x) con->x = zap
1188 #include "conslots.h" 1230 #include "conslots.h"
1189 #undef MARKED_SLOT 1231 #undef MARKED_SLOT
1190 } 1232 }
1191 1233
1192 void 1234 static void
1193 complex_vars_of_console (void) 1235 common_init_complex_vars_of_console (void)
1194 { 1236 {
1195 /* Make sure all markable slots in console_defaults 1237 /* Make sure all markable slots in console_defaults
1196 are initialized reasonably, so mark_console won't choke. 1238 are initialized reasonably, so mark_console won't choke.
1197 */ 1239 */
1198 struct console *defs = alloc_lcrecord_type (struct console, &lrecord_console); 1240 struct console *defs = alloc_lcrecord_type (struct console, &lrecord_console);
1199 struct console *syms = alloc_lcrecord_type (struct console, &lrecord_console); 1241 struct console *syms = alloc_lcrecord_type (struct console, &lrecord_console);
1200 1242
1201 staticpro (&Vconsole_defaults); 1243 staticpro_nodump (&Vconsole_defaults);
1202 staticpro (&Vconsole_local_symbols); 1244 staticpro_nodump (&Vconsole_local_symbols);
1203 XSETCONSOLE (Vconsole_defaults, defs); 1245 XSETCONSOLE (Vconsole_defaults, defs);
1204 XSETCONSOLE (Vconsole_local_symbols, syms); 1246 XSETCONSOLE (Vconsole_local_symbols, syms);
1205 1247
1206 nuke_all_console_slots (syms, Qnil); 1248 nuke_all_console_slots (syms, Qnil);
1207 nuke_all_console_slots (defs, Qnil); 1249 nuke_all_console_slots (defs, Qnil);
1252 1294
1253 /* #### Warning, 0x4000000 (that's six zeroes) is the largest number 1295 /* #### Warning, 0x4000000 (that's six zeroes) is the largest number
1254 currently allowable due to the XINT() handling of this value. 1296 currently allowable due to the XINT() handling of this value.
1255 With some rearrangement you can get 4 more bits. */ 1297 With some rearrangement you can get 4 more bits. */
1256 } 1298 }
1299 }
1300
1301
1302 #define CONSOLE_SLOTS_SIZE (offsetof (struct console, CONSOLE_SLOTS_LAST_NAME) - offsetof (struct console, CONSOLE_SLOTS_FIRST_NAME) + sizeof (Lisp_Object))
1303 #define CONSOLE_SLOTS_COUNT (CONSOLE_SLOTS_SIZE / sizeof (Lisp_Object))
1304
1305 void
1306 reinit_complex_vars_of_console (void)
1307 {
1308 struct console *defs, *syms;
1309
1310 common_init_complex_vars_of_console ();
1311
1312 defs = XCONSOLE (Vconsole_defaults);
1313 syms = XCONSOLE (Vconsole_local_symbols);
1314 memcpy (&defs->CONSOLE_SLOTS_FIRST_NAME,
1315 console_defaults_saved_slots,
1316 CONSOLE_SLOTS_SIZE);
1317 memcpy (&syms->CONSOLE_SLOTS_FIRST_NAME,
1318 console_local_symbols_saved_slots,
1319 CONSOLE_SLOTS_SIZE);
1320 }
1321
1322
1323 static const struct lrecord_description console_slots_description_1[] = {
1324 { XD_LISP_OBJECT, 0, CONSOLE_SLOTS_COUNT },
1325 { XD_END }
1326 };
1327
1328 static const struct struct_description console_slots_description = {
1329 CONSOLE_SLOTS_SIZE,
1330 console_slots_description_1
1331 };
1332
1333 void
1334 complex_vars_of_console (void)
1335 {
1336 struct console *defs, *syms;
1337
1338 common_init_complex_vars_of_console ();
1339
1340 defs = XCONSOLE (Vconsole_defaults);
1341 syms = XCONSOLE (Vconsole_local_symbols);
1342 console_defaults_saved_slots = &defs->CONSOLE_SLOTS_FIRST_NAME;
1343 console_local_symbols_saved_slots = &syms->CONSOLE_SLOTS_FIRST_NAME;
1344 dumpstruct (&console_defaults_saved_slots, &console_slots_description);
1345 dumpstruct (&console_local_symbols_saved_slots, &console_slots_description);
1257 1346
1258 DEFVAR_CONSOLE_DEFAULTS ("default-function-key-map", function_key_map /* 1347 DEFVAR_CONSOLE_DEFAULTS ("default-function-key-map", function_key_map /*
1259 Default value of `function-key-map' for consoles that don't override it. 1348 Default value of `function-key-map' for consoles that don't override it.
1260 This is the same as (default-value 'function-key-map). 1349 This is the same as (default-value 'function-key-map).
1261 */ ); 1350 */ );