aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/lisp.h b/src/lisp.h
index b6c46687b28..94f1152a56e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -320,7 +320,8 @@ error !;
320#define lisp_h_NILP(x) EQ (x, Qnil) 320#define lisp_h_NILP(x) EQ (x, Qnil)
321#define lisp_h_SET_SYMBOL_VAL(sym, v) \ 321#define lisp_h_SET_SYMBOL_VAL(sym, v) \
322 (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v)) 322 (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v))
323#define lisp_h_SYMBOL_CONSTANT_P(sym) (XSYMBOL (sym)->constant) 323#define lisp_h_SYMBOL_CONSTANT_P(sym) (XSYMBOL (sym)->trapped_write == SYMBOL_NOWRITE)
324#define lisp_h_SYMBOL_TRAPPED_WRITE_P(sym) (XSYMBOL (sym)->trapped_write)
324#define lisp_h_SYMBOL_VAL(sym) \ 325#define lisp_h_SYMBOL_VAL(sym) \
325 (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value) 326 (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value)
326#define lisp_h_SYMBOLP(x) (XTYPE (x) == Lisp_Symbol) 327#define lisp_h_SYMBOLP(x) (XTYPE (x) == Lisp_Symbol)
@@ -375,6 +376,7 @@ error !;
375# define NILP(x) lisp_h_NILP (x) 376# define NILP(x) lisp_h_NILP (x)
376# define SET_SYMBOL_VAL(sym, v) lisp_h_SET_SYMBOL_VAL (sym, v) 377# define SET_SYMBOL_VAL(sym, v) lisp_h_SET_SYMBOL_VAL (sym, v)
377# define SYMBOL_CONSTANT_P(sym) lisp_h_SYMBOL_CONSTANT_P (sym) 378# define SYMBOL_CONSTANT_P(sym) lisp_h_SYMBOL_CONSTANT_P (sym)
379# define SYMBOL_TRAPPED_WRITE_P(sym) lisp_h_SYMBOL_TRAPPED_WRITE_P (sym)
378# define SYMBOL_VAL(sym) lisp_h_SYMBOL_VAL (sym) 380# define SYMBOL_VAL(sym) lisp_h_SYMBOL_VAL (sym)
379# define SYMBOLP(x) lisp_h_SYMBOLP (x) 381# define SYMBOLP(x) lisp_h_SYMBOLP (x)
380# define VECTORLIKEP(x) lisp_h_VECTORLIKEP (x) 382# define VECTORLIKEP(x) lisp_h_VECTORLIKEP (x)
@@ -600,6 +602,9 @@ extern void char_table_set (Lisp_Object, int, Lisp_Object);
600/* Defined in data.c. */ 602/* Defined in data.c. */
601extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object); 603extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
602extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object); 604extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object);
605extern void notify_variable_watchers (Lisp_Object symbol, Lisp_Object newval,
606 Lisp_Object operation, Lisp_Object where);
607
603 608
604#ifdef CANNOT_DUMP 609#ifdef CANNOT_DUMP
605enum { might_dump = false }; 610enum { might_dump = false };
@@ -632,6 +637,13 @@ enum symbol_redirect
632 SYMBOL_FORWARDED = 3 637 SYMBOL_FORWARDED = 3
633}; 638};
634 639
640enum symbol_trapped_write
641{
642 SYMBOL_UNTRAPPED_WRITE = 0,
643 SYMBOL_NOWRITE = 1,
644 SYMBOL_TRAPPED_WRITE = 2
645};
646
635struct Lisp_Symbol 647struct Lisp_Symbol
636{ 648{
637 bool_bf gcmarkbit : 1; 649 bool_bf gcmarkbit : 1;
@@ -643,10 +655,10 @@ struct Lisp_Symbol
643 3 : it's a forwarding variable, the value is in `forward'. */ 655 3 : it's a forwarding variable, the value is in `forward'. */
644 ENUM_BF (symbol_redirect) redirect : 3; 656 ENUM_BF (symbol_redirect) redirect : 3;
645 657
646 /* Non-zero means symbol is constant, i.e. changing its value 658 /* 0 : normal case, just set the value
647 should signal an error. If the value is 3, then the var 659 1 : constant, cannot set, e.g. nil, t, :keywords.
648 can be changed, but only by `defconst'. */ 660 2 : trap the write, call watcher functions. */
649 unsigned constant : 2; 661 ENUM_BF (symbol_trapped_write) trapped_write : 2;
650 662
651 /* Interned state of the symbol. This is an enumerator from 663 /* Interned state of the symbol. This is an enumerator from
652 enum symbol_interned. */ 664 enum symbol_interned. */
@@ -1850,9 +1862,20 @@ SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (Lisp_Object sym)
1850 return XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY; 1862 return XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY;
1851} 1863}
1852 1864
1853/* Value is non-zero if symbol is considered a constant, i.e. its 1865/* Value is non-zero if symbol cannot be changed through a simple set,
1854 value cannot be changed (there is an exception for keyword symbols, 1866 i.e. it's a constant (e.g. nil, t, :keywords), or it has some
1855 whose value can be set to the keyword symbol itself). */ 1867 watching functions. */
1868
1869INLINE int
1870(SYMBOL_TRAPPED_WRITE_P) (Lisp_Object sym)
1871{
1872 return lisp_h_SYMBOL_TRAPPED_WRITE_P (sym);
1873}
1874
1875/* Value is non-zero if symbol cannot be changed at all, i.e. it's a
1876 constant (e.g. nil, t, :keywords). Code that actually wants to
1877 write to SYM, should also check whether there are any watching
1878 functions. */
1856 1879
1857INLINE int 1880INLINE int
1858(SYMBOL_CONSTANT_P) (Lisp_Object sym) 1881(SYMBOL_CONSTANT_P) (Lisp_Object sym)
@@ -3286,6 +3309,12 @@ set_symbol_next (Lisp_Object sym, struct Lisp_Symbol *next)
3286 XSYMBOL (sym)->next = next; 3309 XSYMBOL (sym)->next = next;
3287} 3310}
3288 3311
3312INLINE void
3313make_symbol_constant (Lisp_Object sym)
3314{
3315 XSYMBOL (sym)->trapped_write = SYMBOL_NOWRITE;
3316}
3317
3289/* Buffer-local (also frame-local) variable access functions. */ 3318/* Buffer-local (also frame-local) variable access functions. */
3290 3319
3291INLINE int 3320INLINE int
@@ -3394,7 +3423,13 @@ extern _Noreturn void args_out_of_range (Lisp_Object, Lisp_Object);
3394extern _Noreturn void args_out_of_range_3 (Lisp_Object, Lisp_Object, 3423extern _Noreturn void args_out_of_range_3 (Lisp_Object, Lisp_Object,
3395 Lisp_Object); 3424 Lisp_Object);
3396extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *); 3425extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *);
3397extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool); 3426enum Set_Internal_Bind {
3427 SET_INTERNAL_SET,
3428 SET_INTERNAL_BIND,
3429 SET_INTERNAL_UNBIND
3430};
3431extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object,
3432 enum Set_Internal_Bind);
3398extern void syms_of_data (void); 3433extern void syms_of_data (void);
3399extern void swap_in_global_binding (struct Lisp_Symbol *); 3434extern void swap_in_global_binding (struct Lisp_Symbol *);
3400 3435
@@ -3877,6 +3912,7 @@ extern _Noreturn void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object);
3877extern _Noreturn void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object, 3912extern _Noreturn void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object,
3878 Lisp_Object); 3913 Lisp_Object);
3879extern _Noreturn void signal_error (const char *, Lisp_Object); 3914extern _Noreturn void signal_error (const char *, Lisp_Object);
3915extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector);
3880extern Lisp_Object eval_sub (Lisp_Object form); 3916extern Lisp_Object eval_sub (Lisp_Object form);
3881extern Lisp_Object apply1 (Lisp_Object, Lisp_Object); 3917extern Lisp_Object apply1 (Lisp_Object, Lisp_Object);
3882extern Lisp_Object call0 (Lisp_Object); 3918extern Lisp_Object call0 (Lisp_Object);