[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/lexspaces 64e442b 04/17: Add SYMBOL_FUNCTION accessor function
From: |
Andrea Corallo |
Subject: |
scratch/lexspaces 64e442b 04/17: Add SYMBOL_FUNCTION accessor function |
Date: |
Fri, 8 May 2020 16:43:07 -0400 (EDT) |
branch: scratch/lexspaces
commit 64e442b4ddc086c3e4af3fdab73df5cebc9cfdf6
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>
Add SYMBOL_FUNCTION accessor function
---
src/alloc.c | 19 ++++++++++---------
src/cmds.c | 6 +++---
src/data.c | 18 +++++++++---------
src/doc.c | 2 +-
src/eval.c | 14 +++++++-------
src/keyboard.c | 8 ++++----
src/lisp.h | 11 +++++++++--
src/lread.c | 2 +-
src/pdumper.c | 4 ++--
src/xterm.c | 2 +-
10 files changed, 47 insertions(+), 39 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index e7ba4dd..4bbc6e3 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4510,7 +4510,7 @@ live_symbol_holding (struct mem_node *m, void *p)
{
cp = ptr_bounds_copy (cp, b);
struct Lisp_Symbol *s = p = cp -= offset % sizeof b->symbols[0];
- if (!deadp (s->u.s.function))
+ if (!deadp (SYMBOL_FUNCTION (s)))
return make_lisp_symbol (s);
}
}
@@ -6647,8 +6647,8 @@ mark_object (Lisp_Object arg)
CHECK_ALLOCATED_AND_LIVE_SYMBOL ();
set_symbol_marked(ptr);
/* Attempt to catch bogus objects. */
- eassert (valid_lisp_object_p (ptr->u.s.function));
- mark_object (ptr->u.s.function);
+ eassert (valid_lisp_object_p (SYMBOL_FUNCTION (ptr)));
+ mark_object (SYMBOL_FUNCTION (ptr));
mark_object (ptr->u.s.plist);
switch (ptr->u.s.redirect)
{
@@ -7004,7 +7004,8 @@ sweep_symbols (void)
}
sym->u.s.next = symbol_free_list;
symbol_free_list = sym;
- symbol_free_list->u.s.function = dead_object ();
+ /* FIXME */
+ symbol_free_list->u.s._function = dead_object ();
++this_free;
}
else
@@ -7012,7 +7013,7 @@ sweep_symbols (void)
++num_used;
sym->u.s.gcmarkbit = 0;
/* Attempt to catch bogus objects. */
- eassert (valid_lisp_object_p (sym->u.s.function));
+ eassert (valid_lisp_object_p (SYMBOL_FUNCTION (sym)));
}
}
@@ -7166,10 +7167,10 @@ symbol_uses_obj (Lisp_Object symbol, Lisp_Object obj)
struct Lisp_Symbol *sym = XSYMBOL (symbol);
Lisp_Object val = find_symbol_value (symbol);
return (EQ (val, obj)
- || EQ (sym->u.s.function, obj)
- || (!NILP (sym->u.s.function)
- && COMPILEDP (sym->u.s.function)
- && EQ (AREF (sym->u.s.function, COMPILED_BYTECODE), obj))
+ || EQ (SYMBOL_FUNCTION (sym), obj)
+ || (!NILP (SYMBOL_FUNCTION (sym))
+ && COMPILEDP (SYMBOL_FUNCTION (sym))
+ && EQ (AREF (SYMBOL_FUNCTION (sym), COMPILED_BYTECODE), obj))
|| (!NILP (val)
&& COMPILEDP (val)
&& EQ (AREF (val, COMPILED_BYTECODE), obj)));
diff --git a/src/cmds.c b/src/cmds.c
index 9f96f21..9dbd9cf 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -423,11 +423,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 (XSYMBOL (sym)->u.s.function)
- && SYMBOLP (XSYMBOL (sym)->u.s.function))
+ && ! NILP (SYMBOL_FUNCTION (XSYMBOL (sym)))
+ && SYMBOLP (SYMBOL_FUNCTION (XSYMBOL (sym))))
{
Lisp_Object prop;
- prop = Fget (XSYMBOL (sym)->u.s.function, intern ("no-self-insert"));
+ prop = Fget (SYMBOL_FUNCTION (XSYMBOL (sym)), intern
("no-self-insert"));
if (! NILP (prop))
return 1;
}
diff --git a/src/data.c b/src/data.c
index 1ab203f..3a3df61 100644
--- a/src/data.c
+++ b/src/data.c
@@ -693,7 +693,7 @@ DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0,
(Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);
- return NILP (XSYMBOL (symbol)->u.s.function) ? Qnil : Qt;
+ return NILP (SYMBOL_FUNCTION (XSYMBOL (symbol))) ? Qnil : Qt;
}
DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0,
@@ -737,7 +737,7 @@ DEFUN ("symbol-function", Fsymbol_function,
Ssymbol_function, 1, 1, 0,
(Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);
- return XSYMBOL (symbol)->u.s.function;
+ return SYMBOL_FUNCTION (XSYMBOL (symbol));
}
DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0,
@@ -771,7 +771,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
think this one little sanity check is worth its cost, but anyway. */
xsignal1 (Qsetting_constant, symbol);
- function = XSYMBOL (symbol)->u.s.function;
+ function = SYMBOL_FUNCTION (XSYMBOL (symbol));
if (!NILP (Vautoload_queue) && !NILP (function))
Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
@@ -811,7 +811,7 @@ The return value is undefined. */)
{ /* Only add autoload entries after dumping, because the ones before are
not useful and else we get loads of them from the loaddefs.el. */
- if (AUTOLOADP (XSYMBOL (symbol)->u.s.function))
+ if (AUTOLOADP (SYMBOL_FUNCTION (XSYMBOL (symbol))))
/* Remember that the function was already an autoload. */
LOADHIST_ATTACH (Fcons (Qt, symbol));
LOADHIST_ATTACH (Fcons (autoload ? Qautoload : Qdefun, symbol));
@@ -2174,12 +2174,12 @@ indirect_function (register Lisp_Object object)
{
if (!SYMBOLP (hare) || NILP (hare))
break;
- hare = XSYMBOL (hare)->u.s.function;
+ hare = SYMBOL_FUNCTION (XSYMBOL (hare));
if (!SYMBOLP (hare) || NILP (hare))
break;
- hare = XSYMBOL (hare)->u.s.function;
+ hare = SYMBOL_FUNCTION (XSYMBOL (hare));
- tortoise = XSYMBOL (tortoise)->u.s.function;
+ tortoise = SYMBOL_FUNCTION (XSYMBOL (tortoise));
if (EQ (hare, tortoise))
xsignal1 (Qcyclic_function_indirection, object);
@@ -2201,7 +2201,7 @@ function chain of symbols. */)
/* Optimize for no indirection. */
result = object;
if (SYMBOLP (result) && !NILP (result)
- && (result = XSYMBOL (result)->u.s.function, SYMBOLP (result)))
+ && (result = SYMBOL_FUNCTION (XSYMBOL (result)), SYMBOLP (result)))
result = indirect_function (result);
if (!NILP (result))
return result;
@@ -3993,7 +3993,7 @@ syms_of_data (void)
defsubr (&Sbool_vector_count_consecutive);
defsubr (&Sbool_vector_count_population);
- set_symbol_function (Qwholenump, XSYMBOL (Qnatnump)->u.s.function);
+ set_symbol_function (Qwholenump, SYMBOL_FUNCTION (XSYMBOL (Qnatnump)));
DEFVAR_LISP ("most-positive-fixnum", Vmost_positive_fixnum,
doc: /* The greatest integer that is represented efficiently.
diff --git a/src/doc.c b/src/doc.c
index 285c0db..4193ef7 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -483,7 +483,7 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset)
{
/* 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)->u.s.function : obj;
+ Lisp_Object fun = SYMBOLP (obj) ? SYMBOL_FUNCTION (XSYMBOL (obj)) : obj;
/* The type determines where the docstring is stored. */
diff --git a/src/eval.c b/src/eval.c
index 014905c..7e2fbca 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1041,7 +1041,7 @@ definitions to shadow the loaded ones for use in file
byte-compilation. */)
tem = Fassq (sym, environment);
if (NILP (tem))
{
- def = XSYMBOL (sym)->u.s.function;
+ def = SYMBOL_FUNCTION (XSYMBOL (sym));
if (!NILP (def))
continue;
}
@@ -1985,8 +1985,8 @@ this does nothing and returns nil. */)
CHECK_STRING (file);
/* If function is defined and not as an autoload, don't override. */
- if (!NILP (XSYMBOL (function)->u.s.function)
- && !AUTOLOADP (XSYMBOL (function)->u.s.function))
+ if (!NILP (SYMBOL_FUNCTION (XSYMBOL (function)))
+ && !AUTOLOADP (SYMBOL_FUNCTION (XSYMBOL (function))))
return Qnil;
if (!NILP (Vpurify_flag) && EQ (docstring, make_fixnum (0)))
@@ -2208,7 +2208,7 @@ eval_sub (Lisp_Object form)
fun = original_fun;
if (!SYMBOLP (fun))
fun = Ffunction (list1 (fun));
- else if (!NILP (fun) && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
+ else if (!NILP (fun) && (fun = SYMBOL_FUNCTION (XSYMBOL (fun)), SYMBOLP
(fun)))
fun = indirect_function (fun);
if (SUBRP (fun))
@@ -2385,7 +2385,7 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
/* Optimize for no indirection. */
if (SYMBOLP (fun) && !NILP (fun)
- && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
+ && (fun = SYMBOL_FUNCTION (XSYMBOL (fun)), SYMBOLP (fun)))
{
fun = indirect_function (fun);
if (NILP (fun))
@@ -2787,7 +2787,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
/* Optimize for no indirection. */
fun = original_fun;
if (SYMBOLP (fun) && !NILP (fun)
- && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
+ && (fun = SYMBOL_FUNCTION (XSYMBOL (fun)), SYMBOLP (fun)))
fun = indirect_function (fun);
if (SUBRP (fun))
@@ -3093,7 +3093,7 @@ function with `&rest' args, or `unevalled' for a special
form. */)
function = original;
if (SYMBOLP (function) && !NILP (function))
{
- function = XSYMBOL (function)->u.s.function;
+ function = SYMBOL_FUNCTION (XSYMBOL (function));
if (SYMBOLP (function))
function = indirect_function (function);
}
diff --git a/src/keyboard.c b/src/keyboard.c
index c94d794..ff4c201 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7877,7 +7877,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, XSYMBOL (def)->u.s.function))))
+ && EQ (tem, SYMBOL_FUNCTION (XSYMBOL (def))))))
keys = Qnil;
}
@@ -9149,9 +9149,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 (XSYMBOL (next)->u.s.function)
- || KEYMAPP (XSYMBOL (next)->u.s.function)))
- next = Fautoload_do_load (XSYMBOL (next)->u.s.function, next, Qnil);
+ && (ARRAYP (SYMBOL_FUNCTION (XSYMBOL (next)))
+ || KEYMAPP (SYMBOL_FUNCTION (XSYMBOL (next)))))
+ next = Fautoload_do_load (SYMBOL_FUNCTION (XSYMBOL (next)), 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 eff7d30..7bf8222 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -852,7 +852,7 @@ struct Lisp_Symbol
} val;
/* Function value of the symbol or Qnil if not fboundp. */
- Lisp_Object function;
+ Lisp_Object _function;
/* The symbol's property list. */
Lisp_Object plist;
@@ -2216,6 +2216,12 @@ SYMBOL_VAL (struct Lisp_Symbol *sym)
return XBINDING (sym->u.s.val.value)->b[curr_lexspace];
}
+INLINE Lisp_Object
+SYMBOL_FUNCTION (struct Lisp_Symbol *sym)
+{
+ return sym->u.s._function;
+}
+
INLINE struct Lisp_Symbol *
SYMBOL_ALIAS (struct Lisp_Symbol *sym)
{
@@ -3423,7 +3429,8 @@ set_hash_value_slot (struct Lisp_Hash_Table *h, ptrdiff_t
idx, Lisp_Object val)
INLINE void
set_symbol_function (Lisp_Object sym, Lisp_Object function)
{
- XSYMBOL (sym)->u.s.function = function;
+ /* FIXME */
+ XSYMBOL (sym)->u.s._function = function;
}
INLINE void
diff --git a/src/lread.c b/src/lread.c
index 59bf529..2e6c1cc 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -4395,7 +4395,7 @@ defalias (struct Lisp_Subr *sname, char *string)
{
Lisp_Object sym;
sym = intern (string);
- XSETSUBR (XSYMBOL (sym)->u.s.function, sname);
+ XSETSUBR (SYMBOL_FUNCTION (XSYMBOL (sym)), sname);
}
#endif /* NOTDEF */
diff --git a/src/pdumper.c b/src/pdumper.c
index a94145e..20dd2ff 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2427,7 +2427,7 @@ dump_symbol (struct dump_context *ctx,
Lisp_Object object,
dump_off offset)
{
-#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_999DC26DEC
+#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_B160ED845C
# error "Lisp_Symbol changed. See CHECK_STRUCTS comment in config.h."
#endif
#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_ADB4F5B113)
@@ -2486,7 +2486,7 @@ dump_symbol (struct dump_context *ctx,
default:
emacs_abort ();
}
- dump_field_lv (ctx, &out, symbol, &symbol->u.s.function, WEIGHT_NORMAL);
+ dump_field_lv (ctx, &out, symbol, &symbol->u.s._function, WEIGHT_NORMAL);
dump_field_lv (ctx, &out, symbol, &symbol->u.s.plist, WEIGHT_NORMAL);
dump_field_lv_rawptr (ctx, &out, symbol, &symbol->u.s.next, Lisp_Symbol,
WEIGHT_STRONG);
diff --git a/src/xterm.c b/src/xterm.c
index 7989cec..78615bd 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12881,7 +12881,7 @@ x_term_init (Lisp_Object display_name, char
*xrm_option, char *resource_name)
{
terminal->kboard = allocate_kboard (Qx);
- if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->u.s.function, Qunbound))
+ if (!EQ (SYMBOL_FUNCTION (XSYMBOL (Qvendor_specific_keysyms)),
Qunbound))
{
char *vendor = ServerVendor (dpy);
- branch scratch/lexspaces created (now e2f183c), Andrea Corallo, 2020/05/08
- scratch/lexspaces 67e28d9 02/17: Adding binding pseudovector, Andrea Corallo, 2020/05/08
- scratch/lexspaces 2d1e916 01/17: Add lexspaces.c, Andrea Corallo, 2020/05/08
- scratch/lexspaces 64e442b 04/17: Add SYMBOL_FUNCTION accessor function,
Andrea Corallo <=
- scratch/lexspaces 02d8ef2 05/17: Move symbol value into separate binding, Andrea Corallo, 2020/05/08
- scratch/lexspaces 3a57250 06/17: Add lexspace-make-from, Andrea Corallo, 2020/05/08
- scratch/lexspaces 7fecbf5 08/17: Add lexspace redirection, Andrea Corallo, 2020/05/08
- scratch/lexspaces 09821e3 03/17: Store symbol value into the binding, Andrea Corallo, 2020/05/08
- scratch/lexspaces 04ac507 14/17: Remove unnecessary assertion, Andrea Corallo, 2020/05/08
- scratch/lexspaces 00108a5 15/17: Fix sweep_symbols, Andrea Corallo, 2020/05/08
- scratch/lexspaces 295ac3d 07/17: Make in-lexspace do something, Andrea Corallo, 2020/05/08
- scratch/lexspaces 610552d 10/17: Add SYMBOL_FUNC_LEXSPACE, Andrea Corallo, 2020/05/08
- scratch/lexspaces 9091913 13/17: Rename lexspace-make-from -> lexspace-make, Andrea Corallo, 2020/05/08
- scratch/lexspaces e2f183c 17/17: Shallow setters by default are not a good idea, Andrea Corallo, 2020/05/08