X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fspecifier.c;h=017663d40f70ac1cf887168a9098fabc13770d20;hb=a94c84beadc87325e2bfa14f85ab48fe5d965c36;hp=7fa2e3a6f02db189eafdee77be2a832202571180;hpb=59eec5f21669e81977b5b1fe9bf717cab49cf7fb;p=chise%2Fxemacs-chise.git.1 diff --git a/src/specifier.c b/src/specifier.c index 7fa2e3a..017663d 100644 --- a/src/specifier.c +++ b/src/specifier.c @@ -354,16 +354,21 @@ specifier_hash (Lisp_Object obj, int depth) internal_hash (s->buffer_specs, depth + 1)); } +inline static size_t +aligned_sizeof_specifier (size_t specifier_type_specific_size) +{ + return ALIGN_SIZE (offsetof (Lisp_Specifier, data) + + specifier_type_specific_size, + ALIGNOF (max_align_t)); +} + static size_t sizeof_specifier (const void *header) { - if (GHOST_SPECIFIER_P ((Lisp_Specifier *) header)) - return offsetof (Lisp_Specifier, data); - else - { - const Lisp_Specifier *p = (const Lisp_Specifier *) header; - return offsetof (Lisp_Specifier, data) + p->methods->extra_data_size; - } + const Lisp_Specifier *p = (const Lisp_Specifier *) header; + return aligned_sizeof_specifier (GHOST_SPECIFIER_P (p) + ? 0 + : p->methods->extra_data_size); } static const struct lrecord_description specifier_methods_description_1[] = { @@ -442,7 +447,7 @@ valid_specifier_type_p (Lisp_Object type) DEFUN ("valid-specifier-type-p", Fvalid_specifier_type_p, 1, 1, 0, /* Given a SPECIFIER-TYPE, return non-nil if it is valid. -Valid types are 'generic, 'integer, boolean, 'color, 'font, 'image, +Valid types are 'generic, 'integer, 'boolean, 'color, 'font, 'image, 'face-boolean, and 'toolbar. */ (specifier_type)) @@ -476,8 +481,7 @@ make_specifier_internal (struct specifier_methods *spec_meths, { Lisp_Object specifier; Lisp_Specifier *sp = (Lisp_Specifier *) - alloc_lcrecord (offsetof (Lisp_Specifier, data) + data_size, - &lrecord_specifier); + alloc_lcrecord (aligned_sizeof_specifier (data_size), &lrecord_specifier); sp->methods = spec_meths; sp->global_specs = Qnil; @@ -549,7 +553,7 @@ device, global), and then the instance (i.e. actual value) is retrieved in a specific domain (window, frame, device) by looking through the possible instantiators (i.e. settings). This process is called \"instantiation\". - + To put settings into a specifier, use `set-specifier', or the lower-level functions `add-spec-to-specifier' and `add-spec-list-to-specifier'. You can also temporarily bind a setting @@ -1783,7 +1787,7 @@ specifier_add_spec (Lisp_Object specifier, Lisp_Object locale, tem = nconc2 (*orig_inst_list, list_to_build_up); else { - abort (); + ABORT (); tem = Qnil; } @@ -1986,8 +1990,8 @@ with the function `specifier-spec-list' or `specifier-specs'. } DEFUN ("add-spec-list-to-specifier", Fadd_spec_list_to_specifier, 2, 3, 0, /* -Add a spec-list (a list of specifications) to SPECIFIER. -The format of a spec-list is +Add SPEC-LIST (a list of specifications) to SPECIFIER. +The format of SPEC-LIST is ((LOCALE (TAG-SET . INSTANTIATOR) ...) ...) @@ -2490,7 +2494,7 @@ specifier_instance_from_inst_list (Lisp_Object specifier, /* The instantiate method is allowed to call eval. Since it is quite common for this function to get called from somewhere in redisplay we need to make sure that quits are ignored. Otherwise - Fsignal will abort. */ + Fsignal will ABORT. */ specbind (Qinhibit_quit, Qt); LIST_LOOP (rest, inst_list) @@ -2556,11 +2560,8 @@ specifier_instance (Lisp_Object specifier, Lisp_Object matchspec, Lisp_Object window = Qnil; Lisp_Object frame = Qnil; Lisp_Object device = Qnil; - Lisp_Object tag = Qnil; - struct device *d; - Lisp_Specifier *sp; - - sp = XSPECIFIER (specifier); + Lisp_Object tag = Qnil; /* #### currently unused */ + Lisp_Specifier *sp = XSPECIFIER (specifier); /* Attempt to determine buffer, window, frame, and device from the domain. */ @@ -2579,20 +2580,19 @@ specifier_instance (Lisp_Object specifier, Lisp_Object matchspec, No. Errors are handled in Lisp primitives implementation. Invalid domain is a design error here - kkm. */ - abort (); + ABORT (); if (NILP (buffer) && !NILP (window)) - buffer = XWINDOW (window)->buffer; + buffer = WINDOW_BUFFER (XWINDOW (window)); if (NILP (frame) && !NILP (window)) frame = XWINDOW (window)->frame; if (NILP (device)) /* frame had better exist; if device is undeterminable, something really went wrong. */ - device = XFRAME (frame)->device; + device = FRAME_DEVICE (XFRAME (frame)); - /* device had better be determined by now; abort if not. */ - d = XDEVICE (device); - tag = DEVICE_CLASS (d); + /* device had better be determined by now; ABORT if not. */ + tag = DEVICE_CLASS (XDEVICE (device)); depth = make_int (1 + XINT (depth)); if (XINT (depth) > 20) @@ -2836,7 +2836,8 @@ set_specifier_caching (Lisp_Object specifier, int struct_window_offset, int struct_frame_offset, void (*value_changed_in_frame) (Lisp_Object specifier, struct frame *f, - Lisp_Object oldval)) + Lisp_Object oldval), + int always_recompute) { Lisp_Specifier *sp = XSPECIFIER (specifier); assert (!GHOST_SPECIFIER_P (sp)); @@ -2847,6 +2848,7 @@ set_specifier_caching (Lisp_Object specifier, int struct_window_offset, sp->caching->value_changed_in_window = value_changed_in_window; sp->caching->offset_into_struct_frame = struct_frame_offset; sp->caching->value_changed_in_frame = value_changed_in_frame; + sp->caching->always_recompute = always_recompute; Vcached_specifiers = Fcons (specifier, Vcached_specifiers); if (BODILY_SPECIFIER_P (sp)) GHOST_SPECIFIER(sp)->caching = sp->caching; @@ -2858,7 +2860,7 @@ recompute_one_cached_specifier_in_window (Lisp_Object specifier, struct window *w) { Lisp_Object window; - Lisp_Object newval, *location; + Lisp_Object newval, *location, oldval; assert (!GHOST_SPECIFIER_P (XSPECIFIER (specifier))); @@ -2879,9 +2881,9 @@ recompute_one_cached_specifier_in_window (Lisp_Object specifier, calling equal is no good either as this doesn't take into account things attached to the specifier - for instance strings on extents. --andyp */ - if (!EQ (newval, *location)) + if (!EQ (newval, *location) || XSPECIFIER (specifier)->caching->always_recompute) { - Lisp_Object oldval = *location; + oldval = *location; *location = newval; (XSPECIFIER (specifier)->caching->value_changed_in_window) (specifier, w, oldval); @@ -2893,7 +2895,7 @@ recompute_one_cached_specifier_in_frame (Lisp_Object specifier, struct frame *f) { Lisp_Object frame; - Lisp_Object newval, *location; + Lisp_Object newval, *location, oldval; assert (!GHOST_SPECIFIER_P (XSPECIFIER (specifier))); @@ -2907,9 +2909,9 @@ recompute_one_cached_specifier_in_frame (Lisp_Object specifier, method. */ location = (Lisp_Object *) ((char *) f + XSPECIFIER (specifier)->caching->offset_into_struct_frame); - if (!EQ (newval, *location)) + if (!EQ (newval, *location) || XSPECIFIER (specifier)->caching->always_recompute) { - Lisp_Object oldval = *location; + oldval = *location; *location = newval; (XSPECIFIER (specifier)->caching->value_changed_in_frame) (specifier, f, oldval); @@ -3269,7 +3271,7 @@ void specifier_type_create (void) { the_specifier_type_entry_dynarr = Dynarr_new (specifier_type_entry); - dumpstruct (&the_specifier_type_entry_dynarr, &sted_description); + dump_add_root_struct_ptr (&the_specifier_type_entry_dynarr, &sted_description); Vspecifier_type_list = Qnil; staticpro (&Vspecifier_type_list); @@ -3313,7 +3315,7 @@ vars_of_specifier (void) /* Do NOT mark through this, or specifiers will never be GC'd. This is the same deal as for weak hash tables. */ Vall_specifiers = Qnil; - pdump_wire_list (&Vall_specifiers); + dump_add_weak_object_chain (&Vall_specifiers); Vuser_defined_tags = Qnil; staticpro (&Vuser_defined_tags);