union of the possible values (struct Lisp_Objfwd, struct
Lisp_Intfwd, etc.). The pointer is packaged inside a struct to
help static checking. */
-typedef struct { void *fwdptr; } lispfwd;
+typedef struct { void const *fwdptr; } lispfwd;
\f
/* Interned state of a symbol. */
sym->u.s.val.blv = v;
}
INLINE void
-SET_SYMBOL_FWD (struct Lisp_Symbol *sym, void *v)
+SET_SYMBOL_FWD (struct Lisp_Symbol *sym, void const *v)
{
eassume (sym->u.s.redirect == SYMBOL_FORWARDED && v);
sym->u.s.val.fwd.fwdptr = v;
INLINE enum Lisp_Fwd_Type
XFWDTYPE (lispfwd a)
{
- enum Lisp_Fwd_Type *p = a.fwdptr;
+ enum Lisp_Fwd_Type const *p = a.fwdptr;
return *p;
}
return XFWDTYPE (a) == Lisp_Fwd_Buffer_Obj;
}
-INLINE struct Lisp_Buffer_Objfwd *
+INLINE struct Lisp_Buffer_Objfwd const *
XBUFFER_OBJFWD (lispfwd a)
{
eassert (BUFFER_OBJFWDP (a));
CALLN is overkill for simple usages like 'Finsert (1, &text);'. */
#define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
-extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *);
-extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *);
-extern void defvar_bool (struct Lisp_Boolfwd *, const char *, bool *);
-extern void defvar_int (struct Lisp_Intfwd *, const char *, intmax_t *);
-extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int);
+extern void defvar_lisp (struct Lisp_Objfwd const *, char const *);
+extern void defvar_lisp_nopro (struct Lisp_Objfwd const *, char const *);
+extern void defvar_bool (struct Lisp_Boolfwd const *, char const *);
+extern void defvar_int (struct Lisp_Intfwd const *, char const *);
+extern void defvar_kboard (struct Lisp_Kboard_Objfwd const *, char const *);
/* Macros we use to define forwarded Lisp variables.
These are used in the syms_of_FILENAME functions.
#define DEFVAR_LISP(lname, vname, doc) \
do { \
- static struct Lisp_Objfwd o_fwd; \
- defvar_lisp (&o_fwd, lname, &globals.f_ ## vname); \
+ static struct Lisp_Objfwd const o_fwd \
+ = {Lisp_Fwd_Obj, &globals.f_##vname}; \
+ defvar_lisp (&o_fwd, lname); \
} while (false)
#define DEFVAR_LISP_NOPRO(lname, vname, doc) \
do { \
- static struct Lisp_Objfwd o_fwd; \
- defvar_lisp_nopro (&o_fwd, lname, &globals.f_ ## vname); \
+ static struct Lisp_Objfwd const o_fwd \
+ = {Lisp_Fwd_Obj, &globals.f_##vname}; \
+ defvar_lisp_nopro (&o_fwd, lname); \
} while (false)
#define DEFVAR_BOOL(lname, vname, doc) \
do { \
- static struct Lisp_Boolfwd b_fwd; \
- defvar_bool (&b_fwd, lname, &globals.f_ ## vname); \
+ static struct Lisp_Boolfwd const b_fwd \
+ = {Lisp_Fwd_Bool, &globals.f_##vname}; \
+ defvar_bool (&b_fwd, lname); \
} while (false)
#define DEFVAR_INT(lname, vname, doc) \
do { \
- static struct Lisp_Intfwd i_fwd; \
- defvar_int (&i_fwd, lname, &globals.f_ ## vname); \
+ static struct Lisp_Intfwd const i_fwd \
+ = {Lisp_Fwd_Int, &globals.f_##vname}; \
+ defvar_int (&i_fwd, lname); \
} while (false)
#define DEFVAR_KBOARD(lname, vname, doc) \
do { \
- static struct Lisp_Kboard_Objfwd ko_fwd; \
- defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \
+ static struct Lisp_Kboard_Objfwd const ko_fwd \
+ = {Lisp_Fwd_Kboard_Obj, offsetof (KBOARD, vname##_)}; \
+ defvar_kboard (&ko_fwd, lname); \
} while (false)
\f
C variable of type intmax_t. Sample call (with "xx" to fool make-docfile):
DEFxxVAR_INT ("emacs-priority", &emacs_priority, "Documentation"); */
void
-defvar_int (struct Lisp_Intfwd *i_fwd,
- const char *namestring, intmax_t *address)
+defvar_int (struct Lisp_Intfwd const *i_fwd, char const *namestring)
{
- Lisp_Object sym;
- sym = intern_c_string (namestring);
- i_fwd->type = Lisp_Fwd_Int;
- i_fwd->intvar = address;
+ Lisp_Object sym = intern_c_string (namestring);
XSYMBOL (sym)->u.s.declared_special = true;
XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
SET_SYMBOL_FWD (XSYMBOL (sym), i_fwd);
}
-/* Similar but define a variable whose value is t if address contains 1,
- nil if address contains 0. */
+/* Similar but define a variable whose value is t if 1, nil if 0. */
void
-defvar_bool (struct Lisp_Boolfwd *b_fwd,
- const char *namestring, bool *address)
+defvar_bool (struct Lisp_Boolfwd const *b_fwd, char const *namestring)
{
- Lisp_Object sym;
- sym = intern_c_string (namestring);
- b_fwd->type = Lisp_Fwd_Bool;
- b_fwd->boolvar = address;
+ Lisp_Object sym = intern_c_string (namestring);
XSYMBOL (sym)->u.s.declared_special = true;
XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
SET_SYMBOL_FWD (XSYMBOL (sym), b_fwd);
gc-marked for some other reason, since marking the same slot twice
can cause trouble with strings. */
void
-defvar_lisp_nopro (struct Lisp_Objfwd *o_fwd,
- const char *namestring, Lisp_Object *address)
+defvar_lisp_nopro (struct Lisp_Objfwd const *o_fwd, char const *namestring)
{
- Lisp_Object sym;
- sym = intern_c_string (namestring);
- o_fwd->type = Lisp_Fwd_Obj;
- o_fwd->objvar = address;
+ Lisp_Object sym = intern_c_string (namestring);
XSYMBOL (sym)->u.s.declared_special = true;
XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
SET_SYMBOL_FWD (XSYMBOL (sym), o_fwd);
}
void
-defvar_lisp (struct Lisp_Objfwd *o_fwd,
- const char *namestring, Lisp_Object *address)
+defvar_lisp (struct Lisp_Objfwd const *o_fwd, char const *namestring)
{
- defvar_lisp_nopro (o_fwd, namestring, address);
- staticpro (address);
+ defvar_lisp_nopro (o_fwd, namestring);
+ staticpro (o_fwd->objvar);
}
/* Similar but define a variable whose value is the Lisp Object stored
at a particular offset in the current kboard object. */
void
-defvar_kboard (struct Lisp_Kboard_Objfwd *ko_fwd,
- const char *namestring, int offset)
+defvar_kboard (struct Lisp_Kboard_Objfwd const *ko_fwd, char const *namestring)
{
- Lisp_Object sym;
- sym = intern_c_string (namestring);
- ko_fwd->type = Lisp_Fwd_Kboard_Obj;
- ko_fwd->offset = offset;
+ Lisp_Object sym = intern_c_string (namestring);
XSYMBOL (sym)->u.s.declared_special = true;
XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
SET_SYMBOL_FWD (XSYMBOL (sym), ko_fwd);