diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-12 18:20:12 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-12 18:21:32 -0800 |
commit | 65563fd7714271582d5146c09202c0f7a0631fe5 (patch) | |
tree | 3da5c2a4dec51d8d53f1b8cc7b7de072bd2577d9 | |
parent | e39d96ebe4c342885433afc28232197ce398fe71 (diff) | |
download | emacs-65563fd7714271582d5146c09202c0f7a0631fe5.tar.gz |
Better support for future plugins
See the thread containing:
http://lists.gnu.org/archive/html/emacs-devel/2015-02/msg00720.html
* lib-src/make-docfile.c (write_globals): Generate code that #defines
Qxxx macros other than Qnil only if DEFINE_NONNIL_Q_SYMBOL_MACROS.
Qnil is safe to define even in plugins, since it must be zero for
other reasons.
* src/lisp.h (DEFINE_LISP_SYMBOL): New macro, replacing and simplifying
DEFINE_LISP_SYMBOL_BEGIN / DEFINE_LISP_SYMBOL_END. All uses changed.
(DEFINE_NONNIL_Q_SYMBOL_MACROS): New macro, defaulting to true.
-rw-r--r-- | lib-src/ChangeLog | 10 | ||||
-rw-r--r-- | lib-src/make-docfile.c | 27 | ||||
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/lisp.h | 13 |
4 files changed, 41 insertions, 16 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 8d2c95e671c..534d253cabb 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,13 @@ +2015-02-13 Paul Eggert <eggert@cs.ucla.edu> + + Better support for future plugins + See the thread containing: + http://lists.gnu.org/archive/html/emacs-devel/2015-02/msg00720.html + * make-docfile.c (write_globals): Generate code that #defines + Qxxx macros other than Qnil only if DEFINE_NONNIL_Q_SYMBOL_MACROS. + Qnil is safe to define even in plugins, since it must be zero for + other reasons. + 2015-01-24 Paul Eggert <eggert@cs.ucla.edu> Fix a couple of AM_V_GEN bugs diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 79d421a0a8e..a7943e3118c 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -707,12 +707,9 @@ write_globals (void) globals[i].name, globals[i].name); } else if (globals[i].type == SYMBOL) - printf (("DEFINE_LISP_SYMBOL_BEGIN (%s)\n" - "#define i%s %d\n" - "#define %s builtin_lisp_symbol (i%s)\n" - "DEFINE_LISP_SYMBOL_END (%s)\n\n"), - globals[i].name, globals[i].name, symnum++, - globals[i].name, globals[i].name, globals[i].name); + printf (("#define i%s %d\n" + "DEFINE_LISP_SYMBOL (%s)\n"), + globals[i].name, symnum++, globals[i].name); else { if (globals[i].flags & DEFUN_noreturn) @@ -740,15 +737,19 @@ write_globals (void) puts ("#ifdef DEFINE_SYMBOLS"); puts ("static char const *const defsym_name[] = {"); for (int i = 0; i < num_globals; i++) - { - if (globals[i].type == SYMBOL) - printf ("\t\"%s\",\n", globals[i].v.svalue); - while (i + 1 < num_globals - && strcmp (globals[i].name, globals[i + 1].name) == 0) - i++; - } + if (globals[i].type == SYMBOL) + printf ("\t\"%s\",\n", globals[i].v.svalue); puts ("};"); puts ("#endif"); + + puts ("#define Qnil builtin_lisp_symbol (0)"); + puts ("#if DEFINE_NONNIL_Q_SYMBOL_MACROS"); + num_symbols = 0; + for (int i = 0; i < num_globals; i++) + if (globals[i].type == SYMBOL && num_symbols++ != 0) + printf ("# define %s builtin_lisp_symbol (%d)\n", + globals[i].name, num_symbols - 1); + puts ("#endif"); } diff --git a/src/ChangeLog b/src/ChangeLog index f8e65d5d91d..6d246fb52c6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2015-02-13 Paul Eggert <eggert@cs.ucla.edu> + + Better support for future plugins + * lisp.h (DEFINE_LISP_SYMBOL): New macro, replacing and simplifying + DEFINE_LISP_SYMBOL_BEGIN / DEFINE_LISP_SYMBOL_END. All uses changed. + (DEFINE_NONNIL_Q_SYMBOL_MACROS): New macro, defaulting to true. + 2015-02-11 Martin Rudalics <rudalics@gmx.at> * w32term.c (w32_read_socket): In SIZE_MAXIMIZED and diff --git a/src/lisp.h b/src/lisp.h index 6c7b51fea06..7795c90e5cc 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -740,11 +740,18 @@ struct Lisp_Symbol /* Declare extern constants for Lisp symbols. These can be helpful when using a debugger like GDB, on older platforms where the debug format does not represent C macros. */ -#define DEFINE_LISP_SYMBOL_BEGIN(name) \ - DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name) -#define DEFINE_LISP_SYMBOL_END(name) \ +#define DEFINE_LISP_SYMBOL(name) \ + DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name) \ DEFINE_GDB_SYMBOL_END (LISP_INITIALLY (XLI_BUILTIN_LISPSYM (i##name))) +/* By default, define macros for Qt, etc., as this leads to a bit + better performance in the core Emacs interpreter. A plugin can + define DEFINE_NONNIL_Q_SYMBOL_MACROS to be false, to be portable to + other Emacs instances that assign different values to Qt, etc. */ +#ifndef DEFINE_NONNIL_Q_SYMBOL_MACROS +# define DEFINE_NONNIL_Q_SYMBOL_MACROS true +#endif + #include "globals.h" /* Convert a Lisp_Object to the corresponding EMACS_INT and vice versa. |