doc: /* Extract, if need be, the bare symbol from SYM, a symbol. */)
(register Lisp_Object sym)
{
- if (BARE_SYMBOL_P (sym))
- return sym;
- /* Type checking is done in the following macro. */
- return SYMBOL_WITH_POS_SYM (sym);
+ CHECK_SYMBOL (sym);
+ return BARE_SYMBOL_P (sym) ? sym : XSYMBOL_WITH_POS_SYM (sym);
}
DEFUN ("symbol-with-pos-pos", Fsymbol_with_pos_pos, Ssymbol_with_pos_pos, 1, 1, 0,
doc: /* Extract the position from a symbol with position. */)
(register Lisp_Object ls)
{
- /* Type checking is done in the following macro. */
- return SYMBOL_WITH_POS_POS (ls);
+ CHECK_TYPE (SYMBOL_WITH_POS_P (ls), Qsymbol_with_pos_p, ls);
+ return XSYMBOL_WITH_POS_POS (ls);
}
DEFUN ("remove-pos-from-symbol", Fremove_pos_from_symbol,
(register Lisp_Object arg)
{
if (SYMBOL_WITH_POS_P (arg))
- return (SYMBOL_WITH_POS_SYM (arg));
+ return XSYMBOL_WITH_POS_SYM (arg);
return arg;
}
if (BARE_SYMBOL_P (sym))
bare = sym;
else if (SYMBOL_WITH_POS_P (sym))
- bare = XSYMBOL_WITH_POS (sym)->sym;
+ bare = XSYMBOL_WITH_POS_SYM (sym);
else
wrong_type_argument (Qsymbolp, sym);
if (FIXNUMP (pos))
position = pos;
else if (SYMBOL_WITH_POS_P (pos))
- position = XSYMBOL_WITH_POS (pos)->pos;
+ position = XSYMBOL_WITH_POS_POS (pos);
else
wrong_type_argument (Qfixnum_or_symbol_with_pos_p, pos);
/* A symbol with position compares the contained symbol, and is
`equal' to the corresponding ordinary symbol. */
- if (symbols_with_pos_enabled)
- {
- if (SYMBOL_WITH_POS_P (o1))
- o1 = SYMBOL_WITH_POS_SYM (o1);
- if (SYMBOL_WITH_POS_P (o2))
- o2 = SYMBOL_WITH_POS_SYM (o2);
- }
+ o1 = maybe_remove_pos_from_symbol (o1);
+ o2 = maybe_remove_pos_from_symbol (o2);
if (BASE_EQ (o1, o2))
return true;
if (TS_NODEP (o1))
return treesit_node_eq (o1, o2);
#endif
- if (SYMBOL_WITH_POS_P(o1)) /* symbols_with_pos_enabled is false. */
- return (BASE_EQ (XSYMBOL_WITH_POS (o1)->sym,
- XSYMBOL_WITH_POS (o2)->sym)
- && BASE_EQ (XSYMBOL_WITH_POS (o1)->pos,
- XSYMBOL_WITH_POS (o2)->pos));
+ if (SYMBOL_WITH_POS_P (o1))
+ {
+ eassert (!symbols_with_pos_enabled);
+ return (BASE_EQ (XSYMBOL_WITH_POS_SYM (o1),
+ XSYMBOL_WITH_POS_SYM (o2))
+ && BASE_EQ (XSYMBOL_WITH_POS_POS (o1),
+ XSYMBOL_WITH_POS_POS (o2)));
+ }
/* Aside from them, only true vectors, char-tables, compiled
functions, and fonts (font-spec, font-entity, font-object)
static EMACS_INT
sxhash_eq (Lisp_Object key)
{
- if (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (key))
- key = SYMBOL_WITH_POS_SYM (key);
- return XHASH (key) ^ XTYPE (key);
+ Lisp_Object k = maybe_remove_pos_from_symbol (key);
+ return XHASH (k) ^ XTYPE (k);
}
static EMACS_INT
hash = sxhash_combine (hash, sxhash_obj (XOVERLAY (obj)->plist, depth));
return hash;
}
- else if (symbols_with_pos_enabled && pvec_type == PVEC_SYMBOL_WITH_POS)
- return sxhash_obj (XSYMBOL_WITH_POS (obj)->sym, depth + 1);
else
- /* Others are 'equal' if they are 'eq', so take their
- address as hash. */
- return XHASH (obj);
+ {
+ if (symbols_with_pos_enabled && pvec_type == PVEC_SYMBOL_WITH_POS)
+ obj = XSYMBOL_WITH_POS_SYM (obj);
+
+ /* Others are 'equal' if they are 'eq', so take their
+ address as hash. */
+ return XHASH (obj);
+ }
}
case Lisp_Cons:
/* See if there's a `:test TEST' among the arguments. */
ptrdiff_t i = get_key_arg (QCtest, nargs, args, used);
- Lisp_Object test = i ? args[i] : Qeql;
- if (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (test))
- test = SYMBOL_WITH_POS_SYM (test);
+ Lisp_Object test = i ? maybe_remove_pos_from_symbol (args[i]) : Qeql;
const struct hash_table_test *testdesc;
if (BASE_EQ (test, Qeq))
testdesc = &hashtest_eq;
return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Symbol_With_Pos);
}
+INLINE Lisp_Object
+XSYMBOL_WITH_POS_SYM (Lisp_Object a)
+{
+ Lisp_Object sym = XSYMBOL_WITH_POS (a)->sym;
+ eassert (BARE_SYMBOL_P (sym));
+ return sym;
+}
+
+INLINE Lisp_Object
+XSYMBOL_WITH_POS_POS (Lisp_Object a)
+{
+ return XSYMBOL_WITH_POS (a)->pos;
+}
+
+INLINE Lisp_Object
+maybe_remove_pos_from_symbol (Lisp_Object x)
+{
+ return (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (x)
+ ? XSYMBOL_WITH_POS_SYM (x) : x);
+}
+
INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED
XBARE_SYMBOL (Lisp_Object a)
{
if (!BARE_SYMBOL_P (a))
{
eassert (symbols_with_pos_enabled);
- a = XSYMBOL_WITH_POS (a)->sym;
+ a = XSYMBOL_WITH_POS_SYM (a);
}
return XBARE_SYMBOL (a);
}
EQ (Lisp_Object x, Lisp_Object y)
{
return BASE_EQ ((symbols_with_pos_enabled && SYMBOL_WITH_POS_P (x)
- ? XSYMBOL_WITH_POS (x)->sym : x),
+ ? XSYMBOL_WITH_POS_SYM (x) : x),
(symbols_with_pos_enabled && SYMBOL_WITH_POS_P (y)
- ? XSYMBOL_WITH_POS (y)->sym : y));
+ ? XSYMBOL_WITH_POS_SYM (y) : y));
}
INLINE intmax_t
return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Overlay);
}
-INLINE Lisp_Object
-SYMBOL_WITH_POS_SYM (Lisp_Object a)
-{
- if (!SYMBOL_WITH_POS_P (a))
- wrong_type_argument (Qsymbol_with_pos_p, a);
- return XSYMBOL_WITH_POS (a)->sym;
-}
-
-INLINE Lisp_Object
-SYMBOL_WITH_POS_POS (Lisp_Object a)
-{
- if (!SYMBOL_WITH_POS_P (a))
- wrong_type_argument (Qsymbol_with_pos_p, a);
- return XSYMBOL_WITH_POS (a)->pos;
-}
-
INLINE bool
USER_PTRP (Lisp_Object x)
{
{
/* If already a symbol, we don't do shorthand-longhand translation,
as promised in the docstring. */
- Lisp_Object sym = (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (name)
- ? XSYMBOL_WITH_POS (name)->sym : name);
+ Lisp_Object sym = maybe_remove_pos_from_symbol (name);
string = XSYMBOL (name)->u.s.name;
tem
= oblookup (obarray, SSDATA (string), SCHARS (string), SBYTES (string));
well, since we accept it as input? */
struct lisp_time t;
enum timeform input_form = decode_lisp_time (time, false, &t, 0);
- if (NILP (form))
- form = current_time_list ? Qlist : Qt;
- if (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (form))
- form = SYMBOL_WITH_POS_SYM (form);
+ form = (!NILP (form) ? maybe_remove_pos_from_symbol (form)
+ : current_time_list ? Qlist : Qt);
if (BASE_EQ (form, Qlist))
return ticks_hz_list4 (t.ticks, t.hz);
if (BASE_EQ (form, Qinteger))