* src/lisp.h (SVAR): New macro. Adjust users.
* src/alloc.c, 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/xterm.c: Users changed.
* admin/coccinelle/symbol.cocci: Semantic patch to replace direct
access to Lisp_Object members of struct Lisp_Symbol to SVAR.
+2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * coccinelle/symbol.cocci: Semantic patch to replace direct
+ access to Lisp_Object members of struct Lisp_Symbol to SVAR.
+
2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
* coccinelle/process.cocci: Semantic patch to replace direct
+2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Use INTERNAL_FIELD for symbols.
+ * lisp.h (SVAR): New macro. Adjust users.
+ * alloc.c, bytecode.c, cmds.c, data.c, doc.c, eval.c:
+ * fns.c, keyboard.c, lread.c, xterm.c: Users changed.
+
2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
Use INTERNAL_FIELD for processes.
MALLOC_UNBLOCK_INPUT;
p = XSYMBOL (val);
- p->xname = name;
- p->plist = Qnil;
+ SVAR (p, xname) = name;
+ SVAR (p, plist) = Qnil;
p->redirect = SYMBOL_PLAINVAL;
SET_SYMBOL_VAL (p, Qunbound);
- p->function = Qunbound;
+ SVAR (p, function) = Qunbound;
p->next = NULL;
p->gcmarkbit = 0;
p->interned = SYMBOL_UNINTERNED;
&& offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0])
&& (b != symbol_block
|| offset / sizeof b->symbols[0] < symbol_block_index)
- && !EQ (((struct Lisp_Symbol *) p)->function, Vdead));
+ && !EQ (SVAR (((struct Lisp_Symbol *)p), function), Vdead));
}
else
return 0;
break;
CHECK_ALLOCATED_AND_LIVE (live_symbol_p);
ptr->gcmarkbit = 1;
- mark_object (ptr->function);
- mark_object (ptr->plist);
+ mark_object (SVAR (ptr, function));
+ mark_object (SVAR (ptr, plist));
switch (ptr->redirect)
{
case SYMBOL_PLAINVAL: mark_object (SYMBOL_VAL (ptr)); break;
break;
default: abort ();
}
- if (!PURE_POINTER_P (XSTRING (ptr->xname)))
- MARK_STRING (XSTRING (ptr->xname));
- MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->xname));
+ if (!PURE_POINTER_P (XSTRING (SVAR (ptr, xname))))
+ MARK_STRING (XSTRING (SVAR (ptr, xname)));
+ MARK_INTERVAL_TREE (STRING_INTERVALS (SVAR (ptr, xname)));
ptr = ptr->next;
if (ptr)
/* 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.xname));
+ int pure_p = PURE_POINTER_P (XSTRING (sym->s.INTERNAL_FIELD (xname)));
if (!sym->s.gcmarkbit && !pure_p)
{
sym->s.next = symbol_free_list;
symbol_free_list = &sym->s;
#if GC_MARK_STACK
- symbol_free_list->function = Vdead;
+ SVAR (symbol_free_list, function) = Vdead;
#endif
++this_free;
}
{
++num_used;
if (!pure_p)
- UNMARK_STRING (XSTRING (sym->s.xname));
+ UNMARK_STRING (XSTRING (sym->s.INTERNAL_FIELD (xname)));
sym->s.gcmarkbit = 0;
}
}
XSETSYMBOL (tem, sym);
val = find_symbol_value (tem);
if (EQ (val, obj)
- || EQ (sym->function, obj)
- || (!NILP (sym->function)
- && COMPILEDP (sym->function)
- && EQ (AREF (sym->function, COMPILED_BYTECODE), obj))
+ || EQ (SVAR (sym, function), obj)
+ || (!NILP (SVAR (sym, function))
+ && COMPILEDP (SVAR (sym, function))
+ && EQ (AREF (SVAR (sym, function), COMPILED_BYTECODE), obj))
|| (!NILP (val)
&& COMPILEDP (val)
&& EQ (AREF (val, COMPILED_BYTECODE), obj)))
&& !EQ (val, Qunbound)
&& !XSYMBOL (sym)->redirect
&& !SYMBOL_CONSTANT_P (sym))
- XSYMBOL (sym)->val.value = val;
+ SVAR (XSYMBOL (sym), val.value) = val;
else
{
BEFORE_POTENTIAL_GC ();
/* If we expanded an abbrev which has a hook,
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 (XSYMBOL (sym)->function)
- && SYMBOLP (XSYMBOL (sym)->function))
+ if (SYMBOLP (sym) && ! NILP (sym)
+ && ! NILP (SVAR (XSYMBOL (sym), function))
+ && SYMBOLP (SVAR (XSYMBOL (sym), function)))
{
Lisp_Object prop;
- prop = Fget (XSYMBOL (sym)->function, intern ("no-self-insert"));
+ prop = Fget (SVAR (XSYMBOL (sym), function),
+ intern ("no-self-insert"));
if (! NILP (prop))
return 1;
}
(register Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);
- return (EQ (XSYMBOL (symbol)->function, Qunbound) ? Qnil : Qt);
+ return (EQ (SVAR (XSYMBOL (symbol), function), Qunbound) ? Qnil : Qt);
}
DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0,
CHECK_SYMBOL (symbol);
if (NILP (symbol) || EQ (symbol, Qt))
xsignal1 (Qsetting_constant, symbol);
- XSYMBOL (symbol)->function = Qunbound;
+ SVAR (XSYMBOL (symbol), function) = Qunbound;
return symbol;
}
(register Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);
- if (!EQ (XSYMBOL (symbol)->function, Qunbound))
- return XSYMBOL (symbol)->function;
+ if (!EQ (SVAR (XSYMBOL (symbol), function), Qunbound))
+ return SVAR (XSYMBOL (symbol), function);
xsignal1 (Qvoid_function, symbol);
}
(register Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);
- return XSYMBOL (symbol)->plist;
+ return SVAR (XSYMBOL (symbol), plist);
}
DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0,
if (NILP (symbol) || EQ (symbol, Qt))
xsignal1 (Qsetting_constant, symbol);
- function = XSYMBOL (symbol)->function;
+ function = SVAR (XSYMBOL (symbol), function);
if (!NILP (Vautoload_queue) && !EQ (function, Qunbound))
Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
if (CONSP (function) && EQ (XCAR (function), Qautoload))
Fput (symbol, Qautoload, XCDR (function));
- XSYMBOL (symbol)->function = definition;
+ SVAR (XSYMBOL (symbol), function) = definition;
/* Handle automatic advice activation. */
- if (CONSP (XSYMBOL (symbol)->plist)
+ if (CONSP (SVAR (XSYMBOL (symbol), plist))
&& !NILP (Fget (symbol, Qad_advice_info)))
{
call2 (Qad_activate_internal, symbol, Qnil);
- definition = XSYMBOL (symbol)->function;
+ definition = SVAR (XSYMBOL (symbol), function);
}
return definition;
}
(register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring)
{
CHECK_SYMBOL (symbol);
- if (CONSP (XSYMBOL (symbol)->function)
- && EQ (XCAR (XSYMBOL (symbol)->function), Qautoload))
+ if (CONSP (SVAR (XSYMBOL (symbol), function))
+ && EQ (XCAR (SVAR (XSYMBOL (symbol), function)), Qautoload))
LOADHIST_ATTACH (Fcons (Qt, symbol));
if (!NILP (Vpurify_flag)
/* If `definition' is a keymap, immutable (and copying) is wrong. */
(register Lisp_Object symbol, Lisp_Object newplist)
{
CHECK_SYMBOL (symbol);
- XSYMBOL (symbol)->plist = newplist;
+ SVAR (XSYMBOL (symbol), plist) = newplist;
return newplist;
}
{
if (!SYMBOLP (hare) || EQ (hare, Qunbound))
break;
- hare = XSYMBOL (hare)->function;
+ hare = SVAR (XSYMBOL (hare), function);
if (!SYMBOLP (hare) || EQ (hare, Qunbound))
break;
- hare = XSYMBOL (hare)->function;
+ hare = SVAR (XSYMBOL (hare), function);
- tortoise = XSYMBOL (tortoise)->function;
+ tortoise = SVAR (XSYMBOL (tortoise), function);
if (EQ (hare, tortoise))
xsignal1 (Qcyclic_function_indirection, object);
/* Optimize for no indirection. */
result = object;
if (SYMBOLP (result) && !EQ (result, Qunbound)
- && (result = XSYMBOL (result)->function, SYMBOLP (result)))
+ && (result = SVAR (XSYMBOL (result), function), SYMBOLP (result)))
result = indirect_function (result);
if (!EQ (result, Qunbound))
return result;
defsubr (&Ssubr_arity);
defsubr (&Ssubr_name);
- XSYMBOL (Qwholenump)->function = XSYMBOL (Qnatnump)->function;
+ SVAR (XSYMBOL (Qwholenump), function) = SVAR (XSYMBOL (Qnatnump), function);
DEFVAR_LISP ("most-positive-fixnum", Vmost_positive_fixnum,
doc: /* The largest value that is representable in a Lisp integer. */);
{
/* Don't use indirect_function here, or defaliases will apply their
docstrings to the base functions (Bug#2603). */
- Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj;
+ Lisp_Object fun = SYMBOLP (obj) ? SVAR (XSYMBOL (obj), function) : obj;
/* The type determines where the docstring is stored. */
tem = Fassq (sym, environment);
if (NILP (tem))
{
- def = XSYMBOL (sym)->function;
+ def = SVAR (XSYMBOL (sym), function);
if (!EQ (def, Qunbound))
continue;
}
CHECK_STRING (file);
/* If function is defined and not as an autoload, don't override. */
- if (!EQ (XSYMBOL (function)->function, Qunbound)
- && !(CONSP (XSYMBOL (function)->function)
- && EQ (XCAR (XSYMBOL (function)->function), Qautoload)))
+ if (!EQ (SVAR (XSYMBOL (function), function), Qunbound)
+ && !(CONSP (SVAR (XSYMBOL (function), function))
+ && EQ (XCAR (SVAR (XSYMBOL (function), function)), Qautoload)))
return Qnil;
if (NILP (Vpurify_flag))
/* Optimize for no indirection. */
fun = original_fun;
if (SYMBOLP (fun) && !EQ (fun, Qunbound)
- && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+ && (fun = SVAR (XSYMBOL (fun), function), SYMBOLP (fun)))
fun = indirect_function (fun);
if (SUBRP (fun))
/* Optimize for no indirection. */
if (SYMBOLP (fun) && !EQ (fun, Qunbound)
- && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+ && (fun = SVAR (XSYMBOL (fun), function), SYMBOLP (fun)))
fun = indirect_function (fun);
if (EQ (fun, Qunbound))
{
/* Optimize for no indirection. */
fun = original_fun;
if (SYMBOLP (fun) && !EQ (fun, Qunbound)
- && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+ && (fun = SVAR (XSYMBOL (fun), function), SYMBOLP (fun)))
fun = indirect_function (fun);
if (SUBRP (fun))
(Lisp_Object symbol, Lisp_Object propname)
{
CHECK_SYMBOL (symbol);
- return Fplist_get (XSYMBOL (symbol)->plist, propname);
+ return Fplist_get (SVAR (XSYMBOL (symbol), plist), propname);
}
DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0,
(Lisp_Object symbol, Lisp_Object propname, Lisp_Object value)
{
CHECK_SYMBOL (symbol);
- XSYMBOL (symbol)->plist
- = Fplist_put (XSYMBOL (symbol)->plist, propname, value);
+ SVAR (XSYMBOL (symbol), plist)
+ = Fplist_put (SVAR (XSYMBOL (symbol), plist), propname, value);
return value;
}
\f
/* If the command is an alias for another
(such as lmenu.el set it up), check if the
original command matches the cached command. */
- && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function))))
+ && !(SYMBOLP (def)
+ && EQ (tem, SVAR (XSYMBOL (def), function)))))
keys = Qnil;
}
/* Handle a symbol whose function definition is a keymap
or an array. */
if (SYMBOLP (next) && !NILP (Ffboundp (next))
- && (ARRAYP (XSYMBOL (next)->function)
- || KEYMAPP (XSYMBOL (next)->function)))
- next = Fautoload_do_load (XSYMBOL (next)->function, next, Qnil);
+ && (ARRAYP (SVAR (XSYMBOL (next), function))
+ || KEYMAPP (SVAR (XSYMBOL (next), function))))
+ next = Fautoload_do_load (SVAR (XSYMBOL (next), function), next, Qnil);
/* If the keymap gives a function, not an
array, then call the function with one arg and use
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;
/* 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 xname;
+ Lisp_Object INTERNAL_FIELD (xname);
/* Value of the symbol or Qunbound if unbound. Which alternative of the
union is used depends on the `redirect' field above. */
union {
- Lisp_Object value;
+ Lisp_Object INTERNAL_FIELD (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 function;
+ Lisp_Object INTERNAL_FIELD (function);
/* The symbol's property list. */
- Lisp_Object plist;
+ Lisp_Object INTERNAL_FIELD (plist);
/* Next symbol in obarray bucket, if the symbol is interned. */
struct Lisp_Symbol *next;
/* Value is name of symbol. */
#define SYMBOL_VAL(sym) \
- (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value)
+ (eassert ((sym)->redirect == SYMBOL_PLAINVAL), SVAR (sym, val.value))
#define SYMBOL_ALIAS(sym) \
(eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias)
#define SYMBOL_BLV(sym) \
#define SYMBOL_FWD(sym) \
(eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd)
#define SET_SYMBOL_VAL(sym, v) \
- (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v))
+ (eassert ((sym)->redirect == SYMBOL_PLAINVAL), SVAR (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) \
(eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd = (v))
#define SYMBOL_NAME(sym) \
- LISP_MAKE_RVALUE (XSYMBOL (sym)->xname)
+ LISP_MAKE_RVALUE (SVAR (XSYMBOL (sym), xname))
/* Value is non-zero if SYM is an interned symbol. */
/* 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);
- XSYMBOL (Qunbound)->function = Qunbound;
- XSYMBOL (Qunbound)->plist = Qnil;
+ SVAR (XSYMBOL (Qunbound), function) = Qunbound;
+ SVAR (XSYMBOL (Qunbound), plist) = Qnil;
/* XSYMBOL (Qnil)->function = Qunbound; */
SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil);
XSYMBOL (Qnil)->constant = 1;
XSYMBOL (Qnil)->declared_special = 1;
- XSYMBOL (Qnil)->plist = Qnil;
+ SVAR (XSYMBOL (Qnil), plist) = Qnil;
Qt = intern_c_string ("t");
SET_SYMBOL_VAL (XSYMBOL (Qt), Qt);
Lisp_Object sym;
sym = intern_c_string (sname->symbol_name);
XSETTYPED_PVECTYPE (sname, size, PVEC_SUBR);
- XSETSUBR (XSYMBOL (sym)->function, sname);
+ XSETSUBR (SVAR (XSYMBOL (sym), function), sname);
}
#ifdef NOTDEF /* Use fset in subr.el now! */
terminal->kboard->next_kboard = all_kboards;
all_kboards = terminal->kboard;
- if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound))
+ if (!EQ (SVAR (XSYMBOL (Qvendor_specific_keysyms), function), Qunbound))
{
char *vendor = ServerVendor (dpy);