From c644523bd8a23e518c91b61a1b8520e866b715b9 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 7 Aug 2012 17:37:21 +0400 Subject: [PATCH] Revert and cleanup Lisp_Cons, Lisp_Misc and Lisp_Symbol things. * src/lisp.h (struct Lisp_Symbol): Change xname to meaningful name since all xname users are fixed long time ago. Do not use INTERNAL_FIELD. (set_symbol_name, set_symbol_function, set_symbol_plist): (set_symbol_next, set_overlay_plist): New function. (struct Lisp_Cons): Do not use INTERNAL_FIELD. (struct Lisp_Overlay): Likewise. (CVAR, MVAR, SVAR): Remove. * src/alloc.c, src/buffer.c, src/buffer.h, src/bytecode.c: * src/cmds.c, src/data.c, src/doc.c, src/eval.c, src/fns.c: * src/keyboard.c, src/lread.c, src/nsselect.m, src/xterm.c: Adjust users. * src/.gdbinit: Change to use name field of struct Lisp_Symbol where appropriate. * admin/coccinelle/overlay.cocci, admin/coccinelle/symbol.cocci: Remove. --- admin/ChangeLog | 4 ++ admin/coccinelle/overlay.cocci | 28 -------- admin/coccinelle/symbol.cocci | 32 --------- src/.gdbinit | 6 +- src/ChangeLog | 17 +++++ src/alloc.c | 56 ++++++++-------- src/buffer.c | 30 ++++----- src/buffer.h | 6 +- src/bytecode.c | 2 +- src/cmds.c | 7 +- src/data.c | 34 +++++----- src/doc.c | 2 +- src/eval.c | 14 ++-- src/fns.c | 10 +-- src/keyboard.c | 8 +-- src/lisp.h | 116 ++++++++++++++++++--------------- src/lread.c | 18 ++--- src/nsselect.m | 2 +- src/xterm.c | 2 +- 19 files changed, 184 insertions(+), 210 deletions(-) delete mode 100644 admin/coccinelle/overlay.cocci delete mode 100644 admin/coccinelle/symbol.cocci diff --git a/admin/ChangeLog b/admin/ChangeLog index bc1b4247d3..79a55707dd 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,3 +1,7 @@ +2012-08-07 Dmitry Antipov + + * coccinelle/overlay.cocci, coccinelle/symbol.cocci: Remove. + 2012-08-02 Paul Eggert Port to Solaris 8. diff --git a/admin/coccinelle/overlay.cocci b/admin/coccinelle/overlay.cocci deleted file mode 100644 index 2be141e833..0000000000 --- a/admin/coccinelle/overlay.cocci +++ /dev/null @@ -1,28 +0,0 @@ -// Change direct access to Lisp_Object fields of struct -// Lisp_Overlay to MVAR. Beginning M denotes "misc", and -// MVAR is likely to be used for other second-class objects. -@@ -struct Lisp_Overlay *V; -Lisp_Object O; -@@ -( -- V->start -+ MVAR (V, start) -| -- V->end -+ MVAR (V, end) -| -- V->plist -+ MVAR (V, plist) - -| - -- XOVERLAY (O)->start -+ MVAR (XOVERLAY (O), start) -| -- XOVERLAY (O)->end -+ MVAR (XOVERLAY (O), end) -| -- XOVERLAY (O)->plist -+ MVAR (XOVERLAY (O), plist) -) diff --git a/admin/coccinelle/symbol.cocci b/admin/coccinelle/symbol.cocci deleted file mode 100644 index c988fabc25..0000000000 --- a/admin/coccinelle/symbol.cocci +++ /dev/null @@ -1,32 +0,0 @@ -// Change direct access to Lisp_Object fields of struct Lisp_Symbol to SVAR. -@@ -struct Lisp_Symbol *S; -Lisp_Object O; -@@ -( -- S->xname -+ SVAR (S, xname) -| -- S->val.value -+ SVAR (S, val.value) -| -- S->function -+ SVAR (S, function) -| -- S->plist -+ SVAR (S, plist) - -| - -- XSYMBOL (O)->xname -+ SVAR (XSYMBOL (O), xname) -| -- XSYMBOL (O)->val.value -+ SVAR (XSYMBOL (O), val.value) -| -- XSYMBOL (O)->function -+ SVAR (XSYMBOL (O), function) -| -- XSYMBOL (O)->plist -+ SVAR (XSYMBOL (O), plist) -) diff --git a/src/.gdbinit b/src/.gdbinit index ef534d4591..48d15e89e2 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -1047,7 +1047,7 @@ end define xprintsym xgetptr $arg0 set $sym = (struct Lisp_Symbol *) $ptr - xgetptr $sym->xname_ + xgetptr $sym->name set $sym_name = (struct Lisp_String *) $ptr xprintstr $sym_name end @@ -1218,7 +1218,7 @@ xgetptr globals.f_Vsystem_type # $ptr is NULL in temacs if ($ptr != 0) set $tem = (struct Lisp_Symbol *) $ptr - xgetptr $tem->xname_ + xgetptr $tem->name set $tem = (struct Lisp_String *) $ptr set $tem = (char *) $tem->data @@ -1241,7 +1241,7 @@ commands silent xgetptr globals.f_Vinitial_window_system set $tem = (struct Lisp_Symbol *) $ptr - xgetptr $tem->xname_ + xgetptr $tem->name set $tem = (struct Lisp_String *) $ptr set $tem = (char *) $tem->data # If we are running in synchronous mode, we want a chance to look diff --git a/src/ChangeLog b/src/ChangeLog index c363b258f4..61eae16670 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2012-08-07 Dmitry Antipov + + Revert and cleanup Lisp_Cons, Lisp_Misc and Lisp_Symbol things. + * lisp.h (struct Lisp_Symbol): Change xname to meaningful + name since all xname users are fixed long time ago. Do not + use INTERNAL_FIELD. + (set_symbol_name, set_symbol_function, set_symbol_plist): + (set_symbol_next, set_overlay_plist): New function. + (struct Lisp_Cons): Do not use INTERNAL_FIELD. + (struct Lisp_Overlay): Likewise. + (CVAR, MVAR, SVAR): Remove. + * alloc.c, buffer.c, buffer.h, bytecode.c, cmds.c, data.c: + * doc.c, eval.c, fns.c, keyboard.c, lread.c, nsselect.m: + * xterm.c: Adjust users. + * .gdbinit: Change to use name field of struct Lisp_Symbol + where appropriate. + 2012-08-07 Dmitry Antipov Basic functions to set Lisp_Object and pointer slots of intervals. diff --git a/src/alloc.c b/src/alloc.c index a9ce48172a..b6fe6fa2eb 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2691,7 +2691,7 @@ free_cons (struct Lisp_Cons *ptr) { ptr->u.chain = cons_free_list; #if GC_MARK_STACK - CVAR (ptr, car) = Vdead; + ptr->car = Vdead; #endif cons_free_list = ptr; consing_since_gc -= sizeof *ptr; @@ -3522,12 +3522,12 @@ Its value and function definition are void, and its property list is nil. */) MALLOC_UNBLOCK_INPUT; p = XSYMBOL (val); - SVAR (p, xname) = name; - SVAR (p, plist) = Qnil; + set_symbol_name (val, name); + set_symbol_plist (val, Qnil); p->redirect = SYMBOL_PLAINVAL; SET_SYMBOL_VAL (p, Qunbound); - SVAR (p, function) = Qunbound; - p->next = NULL; + set_symbol_function (val, Qunbound); + set_symbol_next (val, NULL); p->gcmarkbit = 0; p->interned = SYMBOL_UNINTERNED; p->constant = 0; @@ -3654,7 +3654,7 @@ build_overlay (Lisp_Object start, Lisp_Object end, Lisp_Object plist) overlay = allocate_misc (Lisp_Misc_Overlay); OVERLAY_START (overlay) = start; OVERLAY_END (overlay) = end; - OVERLAY_PLIST (overlay) = plist; + set_overlay_plist (overlay, plist); XOVERLAY (overlay)->next = NULL; return overlay; } @@ -4299,7 +4299,7 @@ live_cons_p (struct mem_node *m, void *p) && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) && (b != cons_block || offset / sizeof b->conses[0] < cons_block_index) - && !EQ (CVAR ((struct Lisp_Cons *) p, car), Vdead)); + && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); } else return 0; @@ -4325,7 +4325,7 @@ live_symbol_p (struct mem_node *m, void *p) && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0]) && (b != symbol_block || offset / sizeof b->symbols[0] < symbol_block_index) - && !EQ (SVAR (((struct Lisp_Symbol *)p), function), Vdead)); + && !EQ (((struct Lisp_Symbol *)p)->function, Vdead)); } else return 0; @@ -5831,9 +5831,9 @@ mark_overlay (struct Lisp_Overlay *ptr) for (; ptr && !ptr->gcmarkbit; ptr = ptr->next) { ptr->gcmarkbit = 1; - mark_object (MVAR (ptr, start)); - mark_object (MVAR (ptr, end)); - mark_object (MVAR (ptr, plist)); + mark_object (ptr->start); + mark_object (ptr->end); + mark_object (ptr->plist); } } @@ -6067,8 +6067,8 @@ mark_object (Lisp_Object arg) break; CHECK_ALLOCATED_AND_LIVE (live_symbol_p); ptr->gcmarkbit = 1; - mark_object (SVAR (ptr, function)); - mark_object (SVAR (ptr, plist)); + mark_object (ptr->function); + mark_object (ptr->plist); switch (ptr->redirect) { case SYMBOL_PLAINVAL: mark_object (SYMBOL_VAL (ptr)); break; @@ -6099,9 +6099,9 @@ mark_object (Lisp_Object arg) break; default: abort (); } - if (!PURE_POINTER_P (XSTRING (SVAR (ptr, xname)))) - MARK_STRING (XSTRING (SVAR (ptr, xname))); - MARK_INTERVAL_TREE (STRING_INTERVALS (SVAR (ptr, xname))); + if (!PURE_POINTER_P (XSTRING (ptr->name))) + MARK_STRING (XSTRING (ptr->name)); + MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->name)); ptr = ptr->next; if (ptr) @@ -6163,14 +6163,14 @@ mark_object (Lisp_Object arg) CHECK_ALLOCATED_AND_LIVE (live_cons_p); CONS_MARK (ptr); /* If the cdr is nil, avoid recursion for the car. */ - if (EQ (CVAR (ptr, u.cdr), Qnil)) + if (EQ (ptr->u.cdr, Qnil)) { - obj = CVAR (ptr, car); + obj = ptr->car; cdr_count = 0; goto loop; } - mark_object (CVAR (ptr, car)); - obj = CVAR (ptr, u.cdr); + mark_object (ptr->car); + obj = ptr->u.cdr; cdr_count++; if (cdr_count == mark_object_loop_halt) abort (); @@ -6319,7 +6319,7 @@ gc_sweep (void) cblk->conses[pos].u.chain = cons_free_list; cons_free_list = &cblk->conses[pos]; #if GC_MARK_STACK - CVAR (cons_free_list, car) = Vdead; + cons_free_list->car = Vdead; #endif } else @@ -6467,7 +6467,7 @@ gc_sweep (void) /* Check if the symbol was created during loadup. In such a case it might be pointed to by pure bytecode which we don't trace, so we conservatively assume that it is live. */ - int pure_p = PURE_POINTER_P (XSTRING (sym->s.INTERNAL_FIELD (xname))); + int pure_p = PURE_POINTER_P (XSTRING (sym->s.name)); if (!sym->s.gcmarkbit && !pure_p) { @@ -6476,7 +6476,7 @@ gc_sweep (void) sym->s.next = symbol_free_list; symbol_free_list = &sym->s; #if GC_MARK_STACK - SVAR (symbol_free_list, function) = Vdead; + symbol_free_list->function = Vdead; #endif ++this_free; } @@ -6484,7 +6484,7 @@ gc_sweep (void) { ++num_used; if (!pure_p) - UNMARK_STRING (XSTRING (sym->s.INTERNAL_FIELD (xname))); + UNMARK_STRING (XSTRING (sym->s.name)); sym->s.gcmarkbit = 0; } } @@ -6669,10 +6669,10 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) XSETSYMBOL (tem, sym); val = find_symbol_value (tem); if (EQ (val, obj) - || EQ (SVAR (sym, function), obj) - || (!NILP (SVAR (sym, function)) - && COMPILEDP (SVAR (sym, function)) - && EQ (AREF (SVAR (sym, function), COMPILED_BYTECODE), obj)) + || EQ (sym->function, obj) + || (!NILP (sym->function) + && COMPILEDP (sym->function) + && EQ (AREF (sym->function, COMPILED_BYTECODE), obj)) || (!NILP (val) && COMPILEDP (val) && EQ (AREF (val, COMPILED_BYTECODE), obj))) diff --git a/src/buffer.c b/src/buffer.c index df1b232839..7d0e1b641a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -419,17 +419,17 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list) Lisp_Object overlay, start, end; struct Lisp_Marker *m; - eassert (MARKERP (MVAR (list, start))); - m = XMARKER (MVAR (list, start)); + eassert (MARKERP (list->start)); + m = XMARKER (list->start); start = build_marker (b, m->charpos, m->bytepos); XMARKER (start)->insertion_type = m->insertion_type; - eassert (MARKERP (MVAR (list, end))); - m = XMARKER (MVAR (list, end)); + eassert (MARKERP (list->end)); + m = XMARKER (list->end); end = build_marker (b, m->charpos, m->bytepos); XMARKER (end)->insertion_type = m->insertion_type; - overlay = build_overlay (start, end, Fcopy_sequence (MVAR (list, plist))); + overlay = build_overlay (start, end, Fcopy_sequence (list->plist)); if (tail) tail = tail->next = XOVERLAY (overlay); else @@ -659,11 +659,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */) static void drop_overlay (struct buffer *b, struct Lisp_Overlay *ov) { - eassert (b == XBUFFER (Fmarker_buffer (MVAR (ov, start)))); - modify_overlay (b, marker_position (MVAR (ov, start)), - marker_position (MVAR (ov, end))); - Fset_marker (MVAR (ov, start), Qnil, Qnil); - Fset_marker (MVAR (ov, end), Qnil, Qnil); + eassert (b == XBUFFER (Fmarker_buffer (ov->start))); + modify_overlay (b, marker_position (ov->start), + marker_position (ov->end)); + Fset_marker (ov->start, Qnil, Qnil); + Fset_marker (ov->end, Qnil, Qnil); } @@ -3889,7 +3889,7 @@ OVERLAY. */) { CHECK_OVERLAY (overlay); - return Fcopy_sequence (MVAR (XOVERLAY (overlay), plist)); + return Fcopy_sequence (XOVERLAY (overlay)->plist); } @@ -4065,7 +4065,7 @@ DEFUN ("overlay-get", Foverlay_get, Soverlay_get, 2, 2, 0, (Lisp_Object overlay, Lisp_Object prop) { CHECK_OVERLAY (overlay); - return lookup_char_property (MVAR (XOVERLAY (overlay), plist), prop, 0); + return lookup_char_property (XOVERLAY (overlay)->plist, prop, 0); } DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, @@ -4080,7 +4080,7 @@ VALUE will be returned.*/) buffer = Fmarker_buffer (OVERLAY_START (overlay)); - for (tail = MVAR (XOVERLAY (overlay), plist); + for (tail = XOVERLAY (overlay)->plist; CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail))) if (EQ (XCAR (tail), prop)) @@ -4091,8 +4091,8 @@ VALUE will be returned.*/) } /* It wasn't in the list, so add it to the front. */ changed = !NILP (value); - MVAR (XOVERLAY (overlay), plist) - = Fcons (prop, Fcons (value, MVAR (XOVERLAY (overlay), plist))); + set_overlay_plist + (overlay, Fcons (prop, Fcons (value, XOVERLAY (overlay)->plist))); found: if (! NILP (buffer)) { diff --git a/src/buffer.h b/src/buffer.h index 54e7ef288e..9618fc6ded 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -991,15 +991,15 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) /* Return the marker that stands for where OV starts in the buffer. */ -#define OVERLAY_START(OV) MVAR (XOVERLAY (OV), start) +#define OVERLAY_START(OV) XOVERLAY (OV)->start /* Return the marker that stands for where OV ends in the buffer. */ -#define OVERLAY_END(OV) MVAR (XOVERLAY (OV), end) +#define OVERLAY_END(OV) XOVERLAY (OV)->end /* Return the plist of overlay OV. */ -#define OVERLAY_PLIST(OV) MVAR (XOVERLAY (OV), plist) +#define OVERLAY_PLIST(OV) XOVERLAY (OV)->plist /* Return the actual buffer position for the marker P. We assume you know which buffer it's pointing into. */ diff --git a/src/bytecode.c b/src/bytecode.c index 49369de33e..5ac8b4fa2b 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -818,7 +818,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, && !EQ (val, Qunbound) && !XSYMBOL (sym)->redirect && !SYMBOL_CONSTANT_P (sym)) - SVAR (XSYMBOL (sym), val.value) = val; + SET_SYMBOL_VAL (XSYMBOL (sym), val); else { BEFORE_POTENTIAL_GC (); diff --git a/src/cmds.c b/src/cmds.c index 4512f56206..c06a9edd16 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -447,12 +447,11 @@ internal_self_insert (int c, EMACS_INT n) and the hook has a non-nil `no-self-insert' property, return right away--don't really self-insert. */ if (SYMBOLP (sym) && ! NILP (sym) - && ! NILP (SVAR (XSYMBOL (sym), function)) - && SYMBOLP (SVAR (XSYMBOL (sym), function))) + && ! NILP (XSYMBOL (sym)->function) + && SYMBOLP (XSYMBOL (sym)->function)) { Lisp_Object prop; - prop = Fget (SVAR (XSYMBOL (sym), function), - intern ("no-self-insert")); + prop = Fget (XSYMBOL (sym)->function, intern ("no-self-insert")); if (! NILP (prop)) return 1; } diff --git a/src/data.c b/src/data.c index 3a8e0b11d6..c4519fc5e0 100644 --- a/src/data.c +++ b/src/data.c @@ -562,7 +562,7 @@ DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); - return (EQ (SVAR (XSYMBOL (symbol), function), Qunbound) ? Qnil : Qt); + return EQ (XSYMBOL (symbol)->function, Qunbound) ? Qnil : Qt; } DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, @@ -585,7 +585,7 @@ Return SYMBOL. */) CHECK_SYMBOL (symbol); if (NILP (symbol) || EQ (symbol, Qt)) xsignal1 (Qsetting_constant, symbol); - SVAR (XSYMBOL (symbol), function) = Qunbound; + set_symbol_function (symbol, Qunbound); return symbol; } @@ -594,8 +594,8 @@ DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); - if (!EQ (SVAR (XSYMBOL (symbol), function), Qunbound)) - return SVAR (XSYMBOL (symbol), function); + if (!EQ (XSYMBOL (symbol)->function, Qunbound)) + return XSYMBOL (symbol)->function; xsignal1 (Qvoid_function, symbol); } @@ -604,7 +604,7 @@ DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); - return SVAR (XSYMBOL (symbol), plist); + return XSYMBOL (symbol)->plist; } DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, @@ -628,7 +628,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, if (NILP (symbol) || EQ (symbol, Qt)) xsignal1 (Qsetting_constant, symbol); - function = SVAR (XSYMBOL (symbol), function); + function = XSYMBOL (symbol)->function; if (!NILP (Vautoload_queue) && !EQ (function, Qunbound)) Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue); @@ -636,13 +636,13 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, if (CONSP (function) && EQ (XCAR (function), Qautoload)) Fput (symbol, Qautoload, XCDR (function)); - SVAR (XSYMBOL (symbol), function) = definition; + set_symbol_function (symbol, definition); /* Handle automatic advice activation. */ - if (CONSP (SVAR (XSYMBOL (symbol), plist)) + if (CONSP (XSYMBOL (symbol)->plist) && !NILP (Fget (symbol, Qad_advice_info))) { call2 (Qad_activate_internal, symbol, Qnil); - definition = SVAR (XSYMBOL (symbol), function); + definition = XSYMBOL (symbol)->function; } return definition; } @@ -657,8 +657,8 @@ The return value is undefined. */) (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring) { CHECK_SYMBOL (symbol); - if (CONSP (SVAR (XSYMBOL (symbol), function)) - && EQ (XCAR (SVAR (XSYMBOL (symbol), function)), Qautoload)) + if (CONSP (XSYMBOL (symbol)->function) + && EQ (XCAR (XSYMBOL (symbol)->function), Qautoload)) LOADHIST_ATTACH (Fcons (Qt, symbol)); if (!NILP (Vpurify_flag) /* If `definition' is a keymap, immutable (and copying) is wrong. */ @@ -679,7 +679,7 @@ DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0, (register Lisp_Object symbol, Lisp_Object newplist) { CHECK_SYMBOL (symbol); - SVAR (XSYMBOL (symbol), plist) = newplist; + set_symbol_plist (symbol, newplist); return newplist; } @@ -2019,12 +2019,12 @@ indirect_function (register Lisp_Object object) { if (!SYMBOLP (hare) || EQ (hare, Qunbound)) break; - hare = SVAR (XSYMBOL (hare), function); + hare = XSYMBOL (hare)->function; if (!SYMBOLP (hare) || EQ (hare, Qunbound)) break; - hare = SVAR (XSYMBOL (hare), function); + hare = XSYMBOL (hare)->function; - tortoise = SVAR (XSYMBOL (tortoise), function); + tortoise = XSYMBOL (tortoise)->function; if (EQ (hare, tortoise)) xsignal1 (Qcyclic_function_indirection, object); @@ -2048,7 +2048,7 @@ function chain of symbols. */) /* Optimize for no indirection. */ result = object; if (SYMBOLP (result) && !EQ (result, Qunbound) - && (result = SVAR (XSYMBOL (result), function), SYMBOLP (result))) + && (result = XSYMBOL (result)->function, SYMBOLP (result))) result = indirect_function (result); if (!EQ (result, Qunbound)) return result; @@ -3196,7 +3196,7 @@ syms_of_data (void) defsubr (&Ssubr_arity); defsubr (&Ssubr_name); - SVAR (XSYMBOL (Qwholenump), function) = SVAR (XSYMBOL (Qnatnump), function); + set_symbol_function (Qwholenump, XSYMBOL (Qnatnump)->function); DEFVAR_LISP ("most-positive-fixnum", Vmost_positive_fixnum, doc: /* The largest value that is representable in a Lisp integer. */); diff --git a/src/doc.c b/src/doc.c index 9445ff745b..d17e90f11c 100644 --- a/src/doc.c +++ b/src/doc.c @@ -508,7 +508,7 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset) { /* Don't use indirect_function here, or defaliases will apply their docstrings to the base functions (Bug#2603). */ - Lisp_Object fun = SYMBOLP (obj) ? SVAR (XSYMBOL (obj), function) : obj; + Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj; /* The type determines where the docstring is stored. */ diff --git a/src/eval.c b/src/eval.c index 63700f36d0..d648be81b8 100644 --- a/src/eval.c +++ b/src/eval.c @@ -976,7 +976,7 @@ definitions to shadow the loaded ones for use in file byte-compilation. */) tem = Fassq (sym, environment); if (NILP (tem)) { - def = SVAR (XSYMBOL (sym), function); + def = XSYMBOL (sym)->function; if (!EQ (def, Qunbound)) continue; } @@ -1893,9 +1893,9 @@ this does nothing and returns nil. */) CHECK_STRING (file); /* If function is defined and not as an autoload, don't override. */ - if (!EQ (SVAR (XSYMBOL (function), function), Qunbound) - && !(CONSP (SVAR (XSYMBOL (function), function)) - && EQ (XCAR (SVAR (XSYMBOL (function), function)), Qautoload))) + if (!EQ (XSYMBOL (function)->function, Qunbound) + && !(CONSP (XSYMBOL (function)->function) + && EQ (XCAR (XSYMBOL (function)->function), Qautoload))) return Qnil; if (NILP (Vpurify_flag)) @@ -2081,7 +2081,7 @@ eval_sub (Lisp_Object form) /* Optimize for no indirection. */ fun = original_fun; if (SYMBOLP (fun) && !EQ (fun, Qunbound) - && (fun = SVAR (XSYMBOL (fun), function), SYMBOLP (fun))) + && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) fun = indirect_function (fun); if (SUBRP (fun)) @@ -2266,7 +2266,7 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) /* Optimize for no indirection. */ if (SYMBOLP (fun) && !EQ (fun, Qunbound) - && (fun = SVAR (XSYMBOL (fun), function), SYMBOLP (fun))) + && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) fun = indirect_function (fun); if (EQ (fun, Qunbound)) { @@ -2771,7 +2771,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) /* Optimize for no indirection. */ fun = original_fun; if (SYMBOLP (fun) && !EQ (fun, Qunbound) - && (fun = SVAR (XSYMBOL (fun), function), SYMBOLP (fun))) + && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) fun = indirect_function (fun); if (SUBRP (fun)) diff --git a/src/fns.c b/src/fns.c index 739ffcaea2..8496d2de93 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1868,7 +1868,7 @@ This is the last value stored with `(put SYMBOL PROPNAME VALUE)'. */) (Lisp_Object symbol, Lisp_Object propname) { CHECK_SYMBOL (symbol); - return Fplist_get (SVAR (XSYMBOL (symbol), plist), propname); + return Fplist_get (XSYMBOL (symbol)->plist, propname); } DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0, @@ -1910,8 +1910,8 @@ It can be retrieved with `(get SYMBOL PROPNAME)'. */) (Lisp_Object symbol, Lisp_Object propname, Lisp_Object value) { CHECK_SYMBOL (symbol); - SVAR (XSYMBOL (symbol), plist) - = Fplist_put (SVAR (XSYMBOL (symbol), plist), propname, value); + set_symbol_plist + (symbol, Fplist_put (XSYMBOL (symbol)->plist, propname, value)); return value; } @@ -2053,8 +2053,8 @@ internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o2), depth + 1, props)) return 0; - o1 = MVAR (XOVERLAY (o1), plist); - o2 = MVAR (XOVERLAY (o2), plist); + o1 = XOVERLAY (o1)->plist; + o2 = XOVERLAY (o2)->plist; goto tail_recurse; } if (MARKERP (o1)) diff --git a/src/keyboard.c b/src/keyboard.c index ce14dfdafe..633cf4c4a3 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7896,7 +7896,7 @@ parse_menu_item (Lisp_Object item, int inmenubar) (such as lmenu.el set it up), check if the original command matches the cached command. */ && !(SYMBOLP (def) - && EQ (tem, SVAR (XSYMBOL (def), function))))) + && EQ (tem, XSYMBOL (def)->function)))) keys = Qnil; } @@ -8830,9 +8830,9 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, /* Handle a symbol whose function definition is a keymap or an array. */ if (SYMBOLP (next) && !NILP (Ffboundp (next)) - && (ARRAYP (SVAR (XSYMBOL (next), function)) - || KEYMAPP (SVAR (XSYMBOL (next), function)))) - next = Fautoload_do_load (SVAR (XSYMBOL (next), function), next, Qnil); + && (ARRAYP (XSYMBOL (next)->function) + || KEYMAPP (XSYMBOL (next)->function))) + next = Fautoload_do_load (XSYMBOL (next)->function, next, Qnil); /* If the keymap gives a function, not an array, then call the function with one arg and use diff --git a/src/lisp.h b/src/lisp.h index b6a3644404..873264af4a 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -633,10 +633,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) #define CHECK_TYPE(ok, Qxxxp, x) \ do { if (!(ok)) wrong_type_argument (Qxxxp, (x)); } while (0) -/* Lisp fields are usually hidden from most code and accessed - via special macros. Only select pieces of code, like the GC, - are allowed to use INTERNAL_FIELD directly. Objects which - aren't using this convention should be fixed. */ +/* Deprecated and will be removed soon. */ #define INTERNAL_FIELD(field) field ## _ @@ -648,20 +645,15 @@ typedef struct interval *INTERVAL; #define CHECK_STRING_OR_BUFFER(x) \ CHECK_TYPE (STRINGP (x) || BUFFERP (x), Qbuffer_or_string_p, x) -/* Most code should use this macro to - access Lisp fields in struct Lisp_Cons. */ - -#define CVAR(cons, field) ((cons)->INTERNAL_FIELD (field)) - struct Lisp_Cons { /* Car of this cons cell. */ - Lisp_Object INTERNAL_FIELD (car); + Lisp_Object car; union { /* Cdr of this cons cell. */ - Lisp_Object INTERNAL_FIELD (cdr); + Lisp_Object cdr; /* Used to chain conses on a free list. */ struct Lisp_Cons *chain; @@ -675,8 +667,8 @@ struct Lisp_Cons fields are not accessible as lvalues. (What if we want to switch to a copying collector someday? Cached cons cell field addresses may be invalidated at arbitrary points.) */ -#define XCAR_AS_LVALUE(c) (CVAR (XCONS (c), car)) -#define XCDR_AS_LVALUE(c) (CVAR (XCONS (c), u.cdr)) +#define XCAR_AS_LVALUE(c) (XCONS (c)->car) +#define XCDR_AS_LVALUE(c) (XCONS (c)->u.cdr) /* Use these from normal code. */ #define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c)) @@ -1067,11 +1059,6 @@ enum symbol_redirect SYMBOL_FORWARDED = 3 }; -/* Most code should use this macro to access - Lisp fields in struct Lisp_Symbol. */ - -#define SVAR(sym, field) ((sym)->INTERNAL_FIELD (field)) - struct Lisp_Symbol { unsigned gcmarkbit : 1; @@ -1096,25 +1083,23 @@ struct Lisp_Symbol special (with `defvar' etc), and shouldn't be lexically bound. */ unsigned declared_special : 1; - /* The symbol's name, as a Lisp string. - The name "xname" is used to intentionally break code referring to - the old field "name" of type pointer to struct Lisp_String. */ - Lisp_Object INTERNAL_FIELD (xname); + /* The symbol's name, as a Lisp string. */ + Lisp_Object name; /* Value of the symbol or Qunbound if unbound. Which alternative of the union is used depends on the `redirect' field above. */ union { - Lisp_Object INTERNAL_FIELD (value); + Lisp_Object value; struct Lisp_Symbol *alias; struct Lisp_Buffer_Local_Value *blv; union Lisp_Fwd *fwd; } val; /* Function value of the symbol or Qunbound if not fboundp. */ - Lisp_Object INTERNAL_FIELD (function); + Lisp_Object function; /* The symbol's property list. */ - Lisp_Object INTERNAL_FIELD (plist); + Lisp_Object plist; /* Next symbol in obarray bucket, if the symbol is interned. */ struct Lisp_Symbol *next; @@ -1122,43 +1107,42 @@ struct Lisp_Symbol /* Value is name of symbol. */ -#define SYMBOL_VAL(sym) \ - (eassert ((sym)->redirect == SYMBOL_PLAINVAL), SVAR (sym, val.value)) -#define SYMBOL_ALIAS(sym) \ +#define SYMBOL_VAL(sym) \ + (eassert ((sym)->redirect == SYMBOL_PLAINVAL), sym->val.value) +#define SYMBOL_ALIAS(sym) \ (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias) -#define SYMBOL_BLV(sym) \ +#define SYMBOL_BLV(sym) \ (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv) -#define SYMBOL_FWD(sym) \ +#define SYMBOL_FWD(sym) \ (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd) -#define SET_SYMBOL_VAL(sym, v) \ - (eassert ((sym)->redirect == SYMBOL_PLAINVAL), SVAR (sym, val.value) = (v)) -#define SET_SYMBOL_ALIAS(sym, v) \ +#define SET_SYMBOL_VAL(sym, v) \ + (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v)) +#define SET_SYMBOL_ALIAS(sym, v) \ (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias = (v)) -#define SET_SYMBOL_BLV(sym, v) \ +#define SET_SYMBOL_BLV(sym, v) \ (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv = (v)) -#define SET_SYMBOL_FWD(sym, v) \ +#define SET_SYMBOL_FWD(sym, v) \ (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd = (v)) -#define SYMBOL_NAME(sym) \ - LISP_MAKE_RVALUE (SVAR (XSYMBOL (sym), xname)) +#define SYMBOL_NAME(sym) XSYMBOL (sym)->name /* Value is non-zero if SYM is an interned symbol. */ -#define SYMBOL_INTERNED_P(sym) \ - (XSYMBOL (sym)->interned != SYMBOL_UNINTERNED) +#define SYMBOL_INTERNED_P(sym) \ + (XSYMBOL (sym)->interned != SYMBOL_UNINTERNED) /* Value is non-zero if SYM is interned in initial_obarray. */ -#define SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P(sym) \ - (XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY) +#define SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P(sym) \ + (XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY) /* Value is non-zero if symbol is considered a constant, i.e. its value cannot be changed (there is an exception for keyword symbols, whose value can be set to the keyword symbol itself). */ -#define SYMBOL_CONSTANT_P(sym) XSYMBOL (sym)->constant +#define SYMBOL_CONSTANT_P(sym) XSYMBOL (sym)->constant -#define DEFSYM(sym, name) \ +#define DEFSYM(sym, name) \ do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0) @@ -1289,11 +1273,6 @@ static double const DEFAULT_REHASH_THRESHOLD = 0.8; static double const DEFAULT_REHASH_SIZE = 1.5; -/* Most code should use this macro to access - Lisp fields in a different misc objects. */ - -#define MVAR(misc, field) ((misc)->INTERNAL_FIELD (field)) - /* These structures are used for various misc types. */ struct Lisp_Misc_Any /* Supertype of all Misc types. */ @@ -1363,9 +1342,9 @@ struct Lisp_Overlay unsigned gcmarkbit : 1; int spacer : 15; struct Lisp_Overlay *next; - Lisp_Object INTERNAL_FIELD (start); - Lisp_Object INTERNAL_FIELD (end); - Lisp_Object INTERNAL_FIELD (plist); + Lisp_Object start; + Lisp_Object end; + Lisp_Object plist; }; /* Hold a C pointer for later use. @@ -2406,6 +2385,41 @@ set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) gc_aset (h->index, idx, val); } +/* Use these functions to set Lisp_Object + or pointer slots of struct Lisp_Symbol. */ + +LISP_INLINE void +set_symbol_name (Lisp_Object sym, Lisp_Object name) +{ + XSYMBOL (sym)->name = name; +} + +LISP_INLINE void +set_symbol_function (Lisp_Object sym, Lisp_Object function) +{ + XSYMBOL (sym)->function = function; +} + +LISP_INLINE void +set_symbol_plist (Lisp_Object sym, Lisp_Object plist) +{ + XSYMBOL (sym)->plist = plist; +} + +LISP_INLINE void +set_symbol_next (Lisp_Object sym, struct Lisp_Symbol *next) +{ + XSYMBOL (sym)->next = next; +} + +/* Set overlay's property list. */ + +LISP_INLINE void +set_overlay_plist (Lisp_Object overlay, Lisp_Object plist) +{ + XOVERLAY (overlay)->plist = plist; +} + /* Defined in data.c. */ extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; diff --git a/src/lread.c b/src/lread.c index 4763f82e45..5d26b7f6b2 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3717,9 +3717,9 @@ it defaults to the value of `obarray'. */) ptr = aref_addr (obarray, XINT(tem)); if (SYMBOLP (*ptr)) - XSYMBOL (sym)->next = XSYMBOL (*ptr); + set_symbol_next (sym, XSYMBOL (*ptr)); else - XSYMBOL (sym)->next = 0; + set_symbol_next (sym, NULL); *ptr = sym; return sym; } @@ -3816,7 +3816,7 @@ OBARRAY defaults to the value of the variable `obarray'. */) XSETSYMBOL (following, XSYMBOL (tail)->next); if (EQ (following, tem)) { - XSYMBOL (tail)->next = XSYMBOL (following)->next; + set_symbol_next (tail, XSYMBOL (following)->next); break; } } @@ -3926,13 +3926,12 @@ init_obarray (void) /* Fmake_symbol inits fields of new symbols with Qunbound and Qnil, so those two need to be fixed manually. */ SET_SYMBOL_VAL (XSYMBOL (Qunbound), Qunbound); - SVAR (XSYMBOL (Qunbound), function) = Qunbound; - SVAR (XSYMBOL (Qunbound), plist) = Qnil; - /* XSYMBOL (Qnil)->function = Qunbound; */ + set_symbol_function (Qunbound, Qunbound); + set_symbol_plist (Qunbound, Qnil); SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil); XSYMBOL (Qnil)->constant = 1; XSYMBOL (Qnil)->declared_special = 1; - SVAR (XSYMBOL (Qnil), plist) = Qnil; + set_symbol_plist (Qnil, Qnil); Qt = intern_c_string ("t"); SET_SYMBOL_VAL (XSYMBOL (Qt), Qt); @@ -3951,10 +3950,11 @@ init_obarray (void) void defsubr (struct Lisp_Subr *sname) { - Lisp_Object sym; + Lisp_Object sym, tem; sym = intern_c_string (sname->symbol_name); XSETTYPED_PVECTYPE (sname, size, PVEC_SUBR); - XSETSUBR (SVAR (XSYMBOL (sym), function), sname); + XSETSUBR (tem, sname); + set_symbol_function (sym, tem); } #ifdef NOTDEF /* Use fset in subr.el now! */ diff --git a/src/nsselect.m b/src/nsselect.m index e8c3f85011..e0bbfe5863 100644 --- a/src/nsselect.m +++ b/src/nsselect.m @@ -62,7 +62,7 @@ symbol_to_nsstring (Lisp_Object sym) if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; if (EQ (sym, QTEXT)) return NSStringPboardType; - return [NSString stringWithUTF8String: SSDATA (SVAR (XSYMBOL (sym), xname))]; + return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))]; } static NSPasteboard * diff --git a/src/xterm.c b/src/xterm.c index 85b9cc8dfb..e56c19e03e 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10123,7 +10123,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) terminal->kboard->next_kboard = all_kboards; all_kboards = terminal->kboard; - if (!EQ (SVAR (XSYMBOL (Qvendor_specific_keysyms), function), Qunbound)) + if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound)) { char *vendor = ServerVendor (dpy); -- 2.20.1