Mercurial > hg > xemacs-beta
annotate src/specifier.h @ 5857:6ec4964c1687
Be more careful about echo_buf arithmetic, event-stream.c.
src/ChangeLog addition:
2015-03-12 Aidan Kehoe <kehoea@parhasard.net>
* event-stream.c (lookup_command_event):
Check whether echo_buf_fill_pointer is negative before using it in
arithmetic, avoiding a crash in GC.
Oddly the old code didn't do this check and didn't crash, but its
echo_buf was from malloced memory, not from our string data, so
there may have been more room to manoeuvre.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Thu, 12 Mar 2015 23:31:42 +0000 |
| parents | 56144c8593a8 |
| children |
| rev | line source |
|---|---|
| 428 | 1 /* Generic specifier list implementation |
| 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
| 826 | 3 Copyright (C) 1995, 1996, 2002 Ben Wing |
| 428 | 4 |
| 5 This file is part of XEmacs. | |
| 6 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
| 428 | 8 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
10 option) any later version. |
| 428 | 11 |
| 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 428 | 19 |
| 20 /* Synched up with: Not in FSF. */ | |
| 21 | |
| 440 | 22 #ifndef INCLUDED_specifier_h_ |
| 23 #define INCLUDED_specifier_h_ | |
| 428 | 24 |
| 25 /* | |
| 26 MAGIC SPECIFIERS | |
| 27 ================ | |
| 28 | |
| 29 Magic specifiers are used to provide fallback values for window | |
| 30 system provided specifications, reflecting user preferences on the | |
| 31 window system, such as default fonts, colors, scrollbar thickness | |
| 32 etc. | |
| 33 | |
| 34 A magic specifier consists of two specifier objects. The first one | |
| 35 behaves like a normal specifier in all senses. The second one, a | |
| 36 ghost specifier, is a fallback value for the first one, and contains | |
| 37 values provided by window system, resources etc. which reflect | |
| 38 default settings for values being specified. | |
| 39 | |
| 40 A magic specifier has an "ultimate" fallback value, as any usual | |
| 41 specifier does. This value, an inst-list, is stored in the fallback | |
| 42 slot of the ghost specifier object. | |
| 43 | |
| 44 Ghost specifiers have the following properties: | |
| 45 - Have back pointers to their parent specifiers. | |
| 46 - Do not have instance data. Instead, they share parent's instance | |
| 47 data. | |
| 48 - Have the same methods structure pointer. | |
| 49 - Share parent's caching scheme. | |
| 50 - Store fallback value instead of their parents. | |
| 51 | |
| 52 Ghost specifiers normally are not modifiable at the lisp level, and | |
| 53 only used to supply fallback instance values. They are accessible | |
| 54 via (specifier-fallback), but are read-only. Although, under | |
| 55 certain rare conditions, modification of ghost objects is allowed. | |
| 56 This behavior is controlled by the global variable | |
| 57 Vunlock_ghost_specifiers. It is not exposed to lisp, and is set | |
| 58 during calls to lisp functions which initialize global, device and | |
| 59 frame defaults, such as | |
| 60 init-{global,frame,device}-{faces,toolbars,etc}. | |
| 61 | |
| 62 Thus, values supplied by resources or other means of a window system | |
| 63 stored in externally unmodifiable ghost objects. Regular lisp code | |
| 64 may thus freely modify the normal part of a magic specifier, and | |
| 65 removing a specification for a particular domain causes the | |
| 66 specification to consider ghost-provided fallback values, or its own | |
| 67 fallback value. | |
| 68 | |
| 69 Rules of conduct for magic specifiers | |
| 70 ------------------------------------- | |
| 71 1. recompute_*() functions always operate on the whole specifier | |
| 72 when passed only a ghost object, by substituting it with their | |
| 73 parent bodily object. | |
| 74 2. All specifier methods, except for instantiate method, are passed | |
| 75 the bodily object of the magic specifier. Instantiate method is | |
| 76 passed the specifier being instantiated. | |
| 77 3. Only bodily objects are passed to set_specifier_caching function, | |
| 78 and only these may be cached. | |
| 79 4. All specifiers are added to Vall_specifiers list, both bodily and | |
| 80 ghost. The pair of objects is always removed from the list at the | |
| 81 same time. | |
| 82 */ | |
| 83 | |
| 1204 | 84 extern const struct sized_memory_description specifier_methods_description; |
| 428 | 85 |
| 86 struct specifier_methods | |
| 87 { | |
| 442 | 88 const char *name; |
| 428 | 89 Lisp_Object predicate_symbol; |
| 90 | |
| 91 /* Implementation specific methods: */ | |
| 92 | |
| 93 /* Create method: Initialize specifier data. Optional. */ | |
| 94 void (*create_method) (Lisp_Object specifier); | |
| 95 | |
| 96 /* Mark method: Mark any lisp object within specifier data | |
| 97 structure. Not required if no specifier data are Lisp_Objects. */ | |
| 98 void (*mark_method) (Lisp_Object specifier); | |
| 99 | |
| 100 /* Equal method: Compare two specifiers. This is called after | |
| 101 ensuring that the two specifiers are of the same type, and have | |
| 102 the same specs. Quit is inhibited during the call so it is safe | |
| 103 to call internal_equal(). | |
| 104 | |
| 105 If this function is not present, specifiers considered equal when | |
| 106 the above conditions are met, i.e. as if the method returned | |
| 107 non-zero. */ | |
| 108 int (*equal_method) (Lisp_Object sp1, Lisp_Object sp2, int depth); | |
| 109 | |
| 110 /* Hash method: Hash specifier instance data. This has to hash only | |
| 111 data structure of the specifier, as specs are hashed by the core | |
| 112 code. | |
| 113 | |
| 114 If this function is not present, hashing behaves as if it | |
| 115 returned zero. */ | |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5127
diff
changeset
|
116 Hashcode (*hash_method) (Lisp_Object specifier, int depth, Boolint equalp); |
| 428 | 117 |
| 118 /* Validate method: Given an instantiator, verify that it's | |
| 119 valid for this specifier type. If not, signal an error. | |
| 120 | |
| 121 If this function is not present, all instantiators are considered | |
| 122 valid. */ | |
| 123 void (*validate_method) (Lisp_Object instantiator); | |
| 124 | |
| 434 | 125 |
| 126 /* Copy method: Given an instantiator, copy the bits that we need to | |
| 127 for this specifier type. | |
| 128 | |
| 129 If this function is not present, then Fcopy_tree is used. */ | |
| 130 Lisp_Object (*copy_instantiator_method) (Lisp_Object instantiator); | |
| 131 | |
| 428 | 132 /* Validate-matchspec method: Given a matchspec, verify that it's |
| 133 valid for this specifier type. If not, signal an error. | |
| 134 | |
| 135 If this function is not present, *no* matchspecs are considered | |
| 136 valid. Note that this differs from validate_method(). */ | |
| 137 void (*validate_matchspec_method) (Lisp_Object matchspec); | |
| 138 | |
| 139 /* Instantiate method: Return SPECIFIER instance in DOMAIN, | |
|
4430
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
140 specified by INSTANTIATOR. MATCHSPEC specifies additional |
| 428 | 141 constraints on the instance value (see the docstring for |
| 142 Fspecifier_matching_instance function). MATCHSPEC is passed | |
| 143 Qunbound when no matching constraints are imposed. The method is | |
| 144 called via call_with_suspended_errors(), so allowed to eval | |
| 145 safely. | |
| 146 | |
| 147 DEPTH is a lisp integer denoting current depth of instantiation | |
| 148 calls. This parameter should be passed as the initial depth value | |
| 149 to functions which also instantiate specifiers (of which I can | |
| 150 name specifier_instance) to avoid creating "external" | |
| 151 specification loops. | |
| 152 | |
|
4430
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
153 NO_FALLBACK indicates that the method should not try the fallbacks |
|
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
154 (and thus simply return Qunbound) in case of a failure to instantiate. |
|
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
155 |
| 442 | 156 This method must presume that both INSTANTIATOR and MATCHSPEC are |
| 428 | 157 already validated by the corresponding validate_* methods, and |
| 158 may abort if they are invalid. | |
| 159 | |
| 160 Return value is an instance, which is returned immediately to the | |
| 161 caller, or Qunbound to continue instantiation lookup chain. | |
| 162 | |
| 163 If this function is not present, INSTANTIATOR is used as the | |
| 164 specifier instance. This is the usual case for "simple" | |
| 165 specifiers, like integer and boolean. */ | |
| 166 Lisp_Object (*instantiate_method) (Lisp_Object specifier, | |
| 167 Lisp_Object matchspec, | |
| 168 Lisp_Object domain, | |
| 169 Lisp_Object instantiator, | |
|
4430
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
170 Lisp_Object depth, |
|
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
171 int no_fallback); |
| 428 | 172 |
| 173 /* Going-to-add method: Called when an instantiator is about | |
| 174 to be added to a specifier. This function can specify | |
| 175 that different instantiators should be used instead by | |
| 176 returning an inst-list (possibly containing zero elements). | |
| 177 If the instantiator is fine as-is, return Qt. The | |
| 178 instantiator has been copied with copy-tree, so feel | |
| 179 free to reuse parts of it to create a new instantiator. | |
| 180 The tag-set, however, is not copied and is not canonicalized | |
| 181 (that will be done on the result of this function). */ | |
| 182 Lisp_Object (*going_to_add_method) (Lisp_Object specifier, | |
| 183 Lisp_Object locale, | |
| 184 Lisp_Object tag_set, | |
| 185 Lisp_Object instantiator); | |
| 186 | |
| 187 /* After-change method: Called when the SPECIFIER has just been | |
| 188 changed in LOCALE. The method is called upon: | |
| 189 * Removing and adding specs to/from the specifier; | |
| 190 * Changing the specifier fallback. | |
| 191 | |
| 192 #### The method may have called more than once per each specifier | |
| 193 change. | |
| 194 | |
| 195 #### Do not still know if this can safely eval. */ | |
| 196 void (*after_change_method) (Lisp_Object specifier, | |
| 197 Lisp_Object locale); | |
| 198 | |
| 1204 | 199 /* Specifier extra data: Specifier objects can have extra data, specific |
| 200 to the type of specifier, stored at the end of the object. To have | |
| 201 this, a specifier declares a structure of type `struct TYPE_specifier' | |
| 202 containing the data and uses DEFINE_SPECIFIER_TYPE_WITH_DATA and | |
| 203 INITIALIZE_SPECIFIER_TYPE_WITH_DATA instead of the plain versions. | |
| 204 Then, a pointer to the `struct TYPE_specifier' can be obtained from a | |
| 205 specifier object using SPECIFIER_TYPE_DATA. | |
| 771 | 206 |
| 1204 | 207 A data description of the extra data must also be provided, in the |
| 208 form of a memory_description named TYPE_specifier_description. */ | |
| 209 | |
| 210 /* Description of extra data structure; initialized when | |
| 771 | 211 INITIALIZE_SPECIFIER_TYPE_WITH_DATA is called. */ |
| 1204 | 212 const struct sized_memory_description *extra_description; |
| 771 | 213 |
| 214 /* Size of extra data structure; initialized when | |
| 215 INITIALIZE_SPECIFIER_TYPE_WITH_DATA is called. */ | |
| 428 | 216 int extra_data_size; |
| 217 }; | |
| 218 | |
| 219 struct Lisp_Specifier | |
| 220 { | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
221 NORMAL_LISP_OBJECT_HEADER header; |
| 428 | 222 struct specifier_methods *methods; |
| 223 | |
| 224 /* we keep a chained list of all current specifiers, for GC cleanup | |
| 225 purposes. Do NOT mark through this, or specifiers will never | |
| 226 be GC'd. */ | |
| 227 Lisp_Object next_specifier; | |
| 228 | |
| 229 /* This is a straight list of instantiators. */ | |
| 230 Lisp_Object global_specs; | |
| 231 | |
| 232 /* These are all assoc lists where the key is the type of object the | |
| 233 list represents (buffer, window, etc.) and the associated list is | |
| 234 the actual list of instantiators. */ | |
| 235 Lisp_Object device_specs; | |
| 236 Lisp_Object frame_specs; | |
| 237 /* window_specs is actually a key-assoc weak list. See specifier.c | |
| 238 for an explanation of why (it boils down to the fact that | |
| 239 dead windows can become live again through window configurations). | |
| 240 */ | |
| 241 Lisp_Object window_specs; | |
| 242 Lisp_Object buffer_specs; | |
| 243 | |
| 244 struct specifier_caching *caching; | |
| 245 | |
| 246 /* This can be either nil, for a plain, non-magic specifier object, | |
| 247 t for the normal part of the magic specifier, or #<specifier> for | |
| 248 the ghost part of the magic specifier, a pointer to its parent | |
| 249 object */ | |
| 250 Lisp_Object magic_parent; | |
| 251 | |
| 252 /* Fallback value. For magic specifiers, it is a pointer to the ghost. */ | |
| 253 Lisp_Object fallback; | |
| 254 | |
| 255 /* type-specific extra data attached to a specifier */ | |
| 456 | 256 max_align_t data[1]; |
| 428 | 257 }; |
| 440 | 258 typedef struct Lisp_Specifier Lisp_Specifier; |
| 428 | 259 |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4430
diff
changeset
|
260 DECLARE_LISP_OBJECT (specifier, Lisp_Specifier); |
| 440 | 261 #define XSPECIFIER(x) XRECORD (x, specifier, Lisp_Specifier) |
| 617 | 262 #define wrap_specifier(p) wrap_record (p, specifier) |
| 428 | 263 #define SPECIFIERP(x) RECORDP (x, specifier) |
| 264 #define CHECK_SPECIFIER(x) CHECK_RECORD (x, specifier) | |
| 265 #define CONCHECK_SPECIFIER(x) CONCHECK_RECORD (x, specifier) | |
| 266 | |
| 267 /***** Calling a specifier method *****/ | |
| 268 | |
| 269 #define RAW_SPECMETH(sp, m) ((sp)->methods->m##_method) | |
| 270 #define HAS_SPECMETH_P(sp, m) (!!RAW_SPECMETH (sp, m)) | |
| 271 #define SPECMETH(sp, m, args) (((sp)->methods->m##_method) args) | |
| 272 | |
| 273 /* Call a void-returning specifier method, if it exists. */ | |
| 440 | 274 #define MAYBE_SPECMETH(sp, m, args) do { \ |
| 275 Lisp_Specifier *maybe_specmeth_sp = (sp); \ | |
| 276 if (HAS_SPECMETH_P (maybe_specmeth_sp, m)) \ | |
| 277 SPECMETH (maybe_specmeth_sp, m, args); \ | |
| 428 | 278 } while (0) |
| 279 | |
| 280 /***** Defining new specifier types *****/ | |
| 281 | |
| 1204 | 282 extern const struct sized_memory_description specifier_empty_extra_description; |
| 428 | 283 |
| 800 | 284 #ifdef ERROR_CHECK_TYPES |
| 428 | 285 #define DECLARE_SPECIFIER_TYPE(type) \ |
| 286 extern struct specifier_methods * type##_specifier_methods; \ | |
| 826 | 287 DECLARE_INLINE_HEADER ( \ |
| 288 struct type##_specifier * \ | |
| 440 | 289 error_check_##type##_specifier_data (Lisp_Specifier *sp) \ |
| 826 | 290 ) \ |
| 428 | 291 { \ |
| 292 if (SPECIFIERP (sp->magic_parent)) \ | |
| 293 { \ | |
| 294 assert (SPECIFIER_TYPE_P (sp, type)); \ | |
| 295 sp = XSPECIFIER (sp->magic_parent); \ | |
| 296 } \ | |
| 297 else \ | |
| 298 assert (NILP (sp->magic_parent) || EQ (sp->magic_parent, Qt)); \ | |
| 299 assert (SPECIFIER_TYPE_P (sp, type)); \ | |
| 300 return (struct type##_specifier *) sp->data; \ | |
| 301 } \ | |
| 826 | 302 DECLARE_INLINE_HEADER ( \ |
| 303 Lisp_Specifier * \ | |
| 438 | 304 error_check_##type##_specifier_type (Lisp_Object obj) \ |
| 826 | 305 ) \ |
| 438 | 306 { \ |
| 440 | 307 Lisp_Specifier *sp = XSPECIFIER (obj); \ |
| 438 | 308 assert (SPECIFIER_TYPE_P (sp, type)); \ |
| 309 return sp; \ | |
| 310 } \ | |
| 428 | 311 DECLARE_NOTHING |
| 312 #else | |
| 442 | 313 #define DECLARE_SPECIFIER_TYPE(type) \ |
| 428 | 314 extern struct specifier_methods * type##_specifier_methods |
| 800 | 315 #endif /* ERROR_CHECK_TYPES */ |
| 428 | 316 |
| 442 | 317 #define DEFINE_SPECIFIER_TYPE(type) \ |
| 428 | 318 struct specifier_methods * type##_specifier_methods |
| 319 | |
| 1204 | 320 #define DEFINE_SPECIFIER_TYPE_WITH_DATA(type) \ |
| 321 struct specifier_methods * type##_specifier_methods; \ | |
| 322 static const struct sized_memory_description type##_specifier_description_0 \ | |
| 323 = { \ | |
| 324 sizeof (struct type##_specifier), \ | |
| 325 type##_specifier_description \ | |
| 326 } | |
| 327 | |
| 771 | 328 #define INITIALIZE_SPECIFIER_TYPE(type, obj_name, pred_sym) do { \ |
| 329 type##_specifier_methods = xnew_and_zero (struct specifier_methods); \ | |
| 330 type##_specifier_methods->name = obj_name; \ | |
| 331 type##_specifier_methods->extra_description = \ | |
| 1204 | 332 &specifier_empty_extra_description; \ |
| 771 | 333 defsymbol_nodump (&type##_specifier_methods->predicate_symbol, pred_sym); \ |
| 334 add_entry_to_specifier_type_list (Q##type, type##_specifier_methods); \ | |
| 2367 | 335 dump_add_root_block_ptr (&type##_specifier_methods, \ |
| 771 | 336 &specifier_methods_description); \ |
| 428 | 337 } while (0) |
| 338 | |
| 442 | 339 #define REINITIALIZE_SPECIFIER_TYPE(type) do { \ |
| 428 | 340 staticpro_nodump (&type##_specifier_methods->predicate_symbol); \ |
| 341 } while (0) | |
| 342 | |
| 343 #define INITIALIZE_SPECIFIER_TYPE_WITH_DATA(type, obj_name, pred_sym) \ | |
| 344 do { \ | |
| 345 INITIALIZE_SPECIFIER_TYPE (type, obj_name, pred_sym); \ | |
| 346 type##_specifier_methods->extra_data_size = \ | |
| 347 sizeof (struct type##_specifier); \ | |
|
4430
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
348 type##_specifier_methods->extra_description = \ |
| 1204 | 349 &type##_specifier_description_0; \ |
| 428 | 350 } while (0) |
| 351 | |
| 352 /* Declare that specifier-type TYPE has method METH; used in | |
| 353 initialization routines */ | |
| 354 #define SPECIFIER_HAS_METHOD(type, meth) \ | |
| 355 (type##_specifier_methods->meth##_method = type##_##meth) | |
| 356 | |
| 357 /***** Macros for accessing specifier types *****/ | |
| 358 | |
| 359 #define SPECIFIER_TYPE_P(sp, type) \ | |
| 360 ((sp)->methods == type##_specifier_methods) | |
| 361 | |
| 362 /* Any of the two of the magic spec */ | |
| 363 #define MAGIC_SPECIFIER_P(sp) (!NILP((sp)->magic_parent)) | |
| 364 /* Normal part of the magic specifier */ | |
| 365 #define BODILY_SPECIFIER_P(sp) EQ ((sp)->magic_parent, Qt) | |
| 366 /* Ghost part of the magic specifier */ | |
| 367 #define GHOST_SPECIFIER_P(sp) SPECIFIERP((sp)->magic_parent) | |
| 368 | |
| 369 #define GHOST_SPECIFIER(sp) XSPECIFIER ((sp)->fallback) | |
| 370 | |
| 800 | 371 #ifdef ERROR_CHECK_TYPES |
| 428 | 372 # define SPECIFIER_TYPE_DATA(sp, type) \ |
| 373 error_check_##type##_specifier_data (sp) | |
| 374 #else | |
| 375 # define SPECIFIER_TYPE_DATA(sp, type) \ | |
| 376 ((struct type##_specifier *) \ | |
| 377 (GHOST_SPECIFIER_P(sp) \ | |
| 378 ? XSPECIFIER((sp)->magic_parent)->data \ | |
| 379 : (sp)->data)) | |
| 380 #endif | |
| 381 | |
| 800 | 382 #ifdef ERROR_CHECK_TYPES |
| 438 | 383 # define XSPECIFIER_TYPE(x, type) \ |
| 384 error_check_##type##_specifier_type (x) | |
| 385 #else | |
| 386 # define XSPECIFIER_TYPE(x, type) XSPECIFIER (x) | |
| 800 | 387 #endif /* ERROR_CHECK_TYPES */ |
| 428 | 388 |
| 442 | 389 #define SPECIFIER_TYPEP(x, type) \ |
| 428 | 390 (SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x), type)) |
| 391 #define CHECK_SPECIFIER_TYPE(x, type) do { \ | |
| 392 CHECK_SPECIFIER (x); \ | |
| 393 if (!SPECIFIER_TYPE_P (XSPECIFIER (x), type)) \ | |
| 394 dead_wrong_type_argument \ | |
| 395 (type##_specifier_methods->predicate_symbol, x); \ | |
| 396 } while (0) | |
| 397 #define CONCHECK_SPECIFIER_TYPE(x, type) do { \ | |
| 398 CONCHECK_SPECIFIER (x); \ | |
| 399 if (!(SPECIFIER_TYPEP (x, type))) \ | |
| 400 x = wrong_type_argument \ | |
| 401 (type##_specifier_methods->predicate_symbol, x); \ | |
| 402 } while (0) | |
| 403 | |
| 404 /***** Miscellaneous structures *****/ | |
| 405 | |
| 406 enum spec_locale_type | |
| 407 { | |
| 408 LOCALE_GLOBAL, | |
| 409 LOCALE_DEVICE, | |
| 410 LOCALE_FRAME, | |
| 411 LOCALE_WINDOW, | |
| 412 LOCALE_BUFFER | |
| 413 }; | |
| 414 | |
| 415 enum spec_add_meth | |
| 416 { | |
| 417 SPEC_PREPEND, | |
| 418 SPEC_APPEND, | |
| 419 SPEC_REMOVE_TAG_SET_PREPEND, | |
| 420 SPEC_REMOVE_TAG_SET_APPEND, | |
| 421 SPEC_REMOVE_LOCALE, | |
| 422 SPEC_REMOVE_LOCALE_TYPE, | |
| 423 SPEC_REMOVE_ALL | |
| 424 }; | |
| 425 | |
| 426 struct specifier_caching | |
| 427 { | |
| 3092 | 428 #ifdef NEW_GC |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
429 NORMAL_LISP_OBJECT_HEADER header; |
| 3092 | 430 #endif /* NEW_GC */ |
| 428 | 431 int offset_into_struct_window; |
| 432 void (*value_changed_in_window) (Lisp_Object specifier, struct window *w, | |
| 433 Lisp_Object oldval); | |
| 434 int offset_into_struct_frame; | |
| 435 void (*value_changed_in_frame) (Lisp_Object specifier, struct frame *f, | |
| 436 Lisp_Object oldval); | |
| 444 | 437 int always_recompute; |
| 428 | 438 }; |
| 439 | |
| 3092 | 440 #ifdef NEW_GC |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4430
diff
changeset
|
441 DECLARE_LISP_OBJECT (specifier_caching, struct specifier_caching); |
| 3092 | 442 #define XSPECIFIER_CACHING(x) \ |
| 443 XRECORD (x, specifier_caching, struct specifier_caching) | |
| 444 #define wrap_specifier_caching(p) \ | |
| 445 wrap_record (p, specifier_caching) | |
| 446 #define SPECIFIER_CACHINGP(x) RECORDP (x, specifier_caching) | |
| 447 #define CHECK_SPECIFIER_CACHING(x) \ | |
| 448 CHECK_RECORD (x, specifier_caching) | |
| 449 #define CONCHECK_SPECIFIER_CACHING(x) \ | |
| 450 CONCHECK_RECORD (x, specifier_caching) | |
| 451 #endif /* NEW_GC */ | |
| 452 | |
| 442 | 453 /* #### get image instances out of domains! */ |
| 454 | |
| 2500 | 455 /* #### I think the following should ABORT() rather than return nil |
| 442 | 456 when an invalid domain is given; much more likely we'll catch design |
| 457 errors early. --ben */ | |
| 458 | |
| 459 /* This turns out to be used heavily so we make it a macro to make it | |
| 460 inline. Also, the majority of the time the object will turn out to | |
| 461 be a window so we move it from being checked last to being checked | |
| 462 first. */ | |
| 463 #define DOMAIN_DEVICE(obj) \ | |
| 464 (WINDOWP (obj) ? WINDOW_DEVICE (XWINDOW (obj)) \ | |
| 465 : (FRAMEP (obj) ? FRAME_DEVICE (XFRAME (obj)) \ | |
| 466 : (DEVICEP (obj) ? obj \ | |
| 467 : (IMAGE_INSTANCEP (obj) ? image_instance_device (obj) \ | |
| 468 : Qnil)))) | |
| 469 | |
| 470 #define DOMAIN_FRAME(obj) \ | |
| 471 (WINDOWP (obj) ? WINDOW_FRAME (XWINDOW (obj)) \ | |
| 472 : (FRAMEP (obj) ? obj \ | |
| 473 : (IMAGE_INSTANCEP (obj) ? image_instance_frame (obj) \ | |
| 474 : Qnil))) | |
| 475 | |
| 476 #define DOMAIN_WINDOW(obj) \ | |
| 477 (WINDOWP (obj) ? obj \ | |
| 478 : (IMAGE_INSTANCEP (obj) ? image_instance_window (obj) \ | |
| 479 : Qnil)) | |
| 480 | |
| 481 #define DOMAIN_LIVE_P(obj) \ | |
| 482 (WINDOWP (obj) ? WINDOW_LIVE_P (XWINDOW (obj)) \ | |
| 483 : (FRAMEP (obj) ? FRAME_LIVE_P (XFRAME (obj)) \ | |
| 484 : (DEVICEP (obj) ? DEVICE_LIVE_P (XDEVICE (obj)) \ | |
| 485 : (IMAGE_INSTANCEP (obj) ? image_instance_live_p (obj) \ | |
| 486 : 0)))) | |
| 487 | |
| 488 #define DOMAIN_XDEVICE(obj) \ | |
| 489 (XDEVICE (DOMAIN_DEVICE (obj))) | |
| 490 #define DOMAIN_XFRAME(obj) \ | |
| 491 (XFRAME (DOMAIN_FRAME (obj))) | |
| 492 #define DOMAIN_XWINDOW(obj) \ | |
| 493 (XWINDOW (DOMAIN_WINDOW (obj))) | |
| 494 | |
| 428 | 495 EXFUN (Fcopy_specifier, 6); |
| 496 EXFUN (Fmake_specifier, 1); | |
| 497 EXFUN (Fset_specifier_dirty_flag, 1); | |
| 498 EXFUN (Fspecifier_instance, 4); | |
| 499 EXFUN (Fvalid_specifier_locale_p, 1); | |
| 500 | |
| 501 extern Lisp_Object Qfallback, Qnatnum; | |
| 502 | |
| 503 Lisp_Object make_magic_specifier (Lisp_Object type); | |
| 504 Lisp_Object decode_locale_list (Lisp_Object locale); | |
| 505 extern enum spec_add_meth | |
| 506 decode_how_to_add_specification (Lisp_Object how_to_add); | |
| 507 Lisp_Object decode_specifier_tag_set (Lisp_Object tag_set); | |
| 442 | 508 Lisp_Object decode_domain (Lisp_Object domain); |
| 428 | 509 |
| 510 void add_entry_to_specifier_type_list (Lisp_Object symbol, | |
| 511 struct specifier_methods *meths); | |
| 512 void set_specifier_caching (Lisp_Object specifier, | |
| 513 int struct_window_offset, | |
| 514 void (*value_changed_in_window) | |
| 515 (Lisp_Object specifier, struct window *w, | |
| 516 Lisp_Object oldval), | |
| 517 int struct_frame_offset, | |
| 518 void (*value_changed_in_frame) | |
| 519 (Lisp_Object specifier, struct frame *f, | |
| 444 | 520 Lisp_Object oldval), |
| 521 int always_recompute); | |
| 428 | 522 void set_specifier_fallback (Lisp_Object specifier, |
| 523 Lisp_Object fallback); | |
| 524 void recompute_all_cached_specifiers_in_window (struct window *w); | |
| 525 void recompute_all_cached_specifiers_in_frame (struct frame *f); | |
| 526 | |
| 527 /* Counterparts of Fadd_spec_to_specifier and Fremove_specifier, which | |
| 528 operate directly on ghost objects given a magic specifier. */ | |
| 529 void add_spec_to_ghost_specifier (Lisp_Object specifier, Lisp_Object instantiator, | |
| 530 Lisp_Object locale, Lisp_Object tag_set, | |
| 531 Lisp_Object how_to_add); | |
| 532 void remove_ghost_specifier (Lisp_Object specifier, Lisp_Object locale, | |
| 533 Lisp_Object tag_set, Lisp_Object exact_p); | |
| 534 | |
| 535 int unlock_ghost_specifiers_protected (void); | |
| 536 | |
| 537 void cleanup_specifiers (void); | |
| 538 void prune_specifiers (void); | |
| 539 void setup_device_initial_specifier_tags (struct device *d); | |
| 3659 | 540 void setup_charset_initial_specifier_tags (Lisp_Object charset); |
| 428 | 541 void kill_specifier_buffer_locals (Lisp_Object buffer); |
| 542 | |
| 543 DECLARE_SPECIFIER_TYPE (generic); | |
| 544 #define XGENERIC_SPECIFIER(x) XSPECIFIER_TYPE (x, generic) | |
| 545 #define GENERIC_SPECIFIERP(x) SPECIFIER_TYPEP (x, generic) | |
| 546 #define CHECK_GENERIC_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, generic) | |
| 547 #define CONCHECK_GENERIC_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, generic) | |
| 548 | |
| 549 DECLARE_SPECIFIER_TYPE (integer); | |
|
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
550 #define XFIXNUMEGER_SPECIFIER(x) XSPECIFIER_TYPE (x, integer) |
| 428 | 551 #define INTEGER_SPECIFIERP(x) SPECIFIER_TYPEP (x, integer) |
| 552 #define CHECK_INTEGER_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, integer) | |
| 553 #define CONCHECK_INTEGER_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, integer) | |
| 554 | |
| 555 DECLARE_SPECIFIER_TYPE (natnum); | |
| 556 #define XNATNUM_SPECIFIER(x) XSPECIFIER_TYPE (x, natnum) | |
| 557 #define NATNUM_SPECIFIERP(x) SPECIFIER_TYPEP (x, natnum) | |
| 558 #define CHECK_NATNUM_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, natnum) | |
| 559 #define CONCHECK_NATNUM_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, natnum) | |
| 560 | |
| 561 DECLARE_SPECIFIER_TYPE (boolean); | |
| 562 #define XBOOLEAN_SPECIFIER(x) XSPECIFIER_TYPE (x, boolean) | |
| 563 #define BOOLEAN_SPECIFIERP(x) SPECIFIER_TYPEP (x, boolean) | |
| 564 #define CHECK_BOOLEAN_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, boolean) | |
| 565 #define CONCHECK_BOOLEAN_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, boolean) | |
| 566 | |
| 567 DECLARE_SPECIFIER_TYPE (display_table); | |
| 568 #define XDISPLAYTABLE_SPECIFIER(x) XSPECIFIER_TYPE (x, display_table) | |
| 569 #define DISPLAYTABLE_SPECIFIERP(x) SPECIFIER_TYPEP (x, display_table) | |
| 570 #define CHECK_DISPLAYTABLE_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, display_table) | |
| 571 #define CONCHECK_DISPLAYTABLE_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, display_table) | |
| 572 | |
| 3659 | 573 Lisp_Object define_specifier_tag(Lisp_Object tag, |
|
4430
d00347ec8289
Fix instantiate_method prototype
Didier Verna <didier@xemacs.org>
parents:
3659
diff
changeset
|
574 Lisp_Object device_predicate, |
| 3659 | 575 Lisp_Object charset_predicate); |
| 576 | |
| 440 | 577 #endif /* INCLUDED_specifier_h_ */ |
