diff options
| author | Philipp Stephani | 2017-06-17 19:12:45 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-06-17 19:16:14 +0200 |
| commit | c66a7cce17ac4b9cde6bf49232aaa59c1c73404e (patch) | |
| tree | 8278ec5544496274ef7c85936c3ee5fa4c9ee93c | |
| parent | f8cc7a83006e520e6dce3c64df6dca010624299f (diff) | |
| download | emacs-c66a7cce17ac4b9cde6bf49232aaa59c1c73404e.tar.gz emacs-c66a7cce17ac4b9cde6bf49232aaa59c1c73404e.zip | |
emacs-module.h: Create emacs_env_26
This was part of the original design of the module
API (https://lists.gnu.org/archive/html/emacs-devel/2015-02/msg00960.html),
but I didn't take it into account when adding the should_quit
function.
Instead of duplicating the environment fields or using the C
preprocessor, use configure to build emacs-module.h.
* configure.ac: Expand emacs-module.h template.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | configure.ac | 6 | ||||
| -rw-r--r-- | src/emacs-module.h.in | 106 | ||||
| -rw-r--r-- | src/module-env-25.h (renamed from src/emacs-module.h) | 102 | ||||
| -rw-r--r-- | src/module-env-26.h | 3 |
5 files changed, 116 insertions, 102 deletions
diff --git a/.gitignore b/.gitignore index 1abefeb4326..46ed4a137de 100644 --- a/.gitignore +++ b/.gitignore | |||
| @@ -46,6 +46,7 @@ makefile | |||
| 46 | lib/gnulib.mk | 46 | lib/gnulib.mk |
| 47 | src/config.h | 47 | src/config.h |
| 48 | src/epaths.h | 48 | src/epaths.h |
| 49 | src/emacs-module.h | ||
| 49 | 50 | ||
| 50 | # C-level sources built by 'make'. | 51 | # C-level sources built by 'make'. |
| 51 | lib/alloca.h | 52 | lib/alloca.h |
diff --git a/configure.ac b/configure.ac index 9069e5b58ca..ef61107b025 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -3518,6 +3518,12 @@ AC_SUBST(LIBMODULES) | |||
| 3518 | AC_SUBST(HAVE_MODULES) | 3518 | AC_SUBST(HAVE_MODULES) |
| 3519 | AC_SUBST(MODULES_SUFFIX) | 3519 | AC_SUBST(MODULES_SUFFIX) |
| 3520 | 3520 | ||
| 3521 | AC_CONFIG_FILES([src/emacs-module.h]) | ||
| 3522 | AC_SUBST_FILE([module_env_snippet_25]) | ||
| 3523 | AC_SUBST_FILE([module_env_snippet_26]) | ||
| 3524 | module_env_snippet_25="$srcdir/src/module-env-25.h" | ||
| 3525 | module_env_snippet_26="$srcdir/src/module-env-26.h" | ||
| 3526 | |||
| 3521 | ### Use -lpng if available, unless '--with-png=no'. | 3527 | ### Use -lpng if available, unless '--with-png=no'. |
| 3522 | HAVE_PNG=no | 3528 | HAVE_PNG=no |
| 3523 | LIBPNG= | 3529 | LIBPNG= |
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in new file mode 100644 index 00000000000..339234fdb51 --- /dev/null +++ b/src/emacs-module.h.in | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* emacs-module.h - GNU Emacs module API. | ||
| 2 | |||
| 3 | Copyright (C) 2015-2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or (at | ||
| 10 | your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #ifndef EMACS_MODULE_H | ||
| 21 | #define EMACS_MODULE_H | ||
| 22 | |||
| 23 | #include <stdint.h> | ||
| 24 | #include <stddef.h> | ||
| 25 | |||
| 26 | #ifndef __cplusplus | ||
| 27 | #include <stdbool.h> | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #if defined __cplusplus && __cplusplus >= 201103L | ||
| 31 | # define EMACS_NOEXCEPT noexcept | ||
| 32 | #else | ||
| 33 | # define EMACS_NOEXCEPT | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #ifdef __has_attribute | ||
| 37 | #if __has_attribute(__nonnull__) | ||
| 38 | # define EMACS_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__))) | ||
| 39 | #endif | ||
| 40 | #endif | ||
| 41 | #ifndef EMACS_ATTRIBUTE_NONNULL | ||
| 42 | # define EMACS_ATTRIBUTE_NONNULL(...) | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #ifdef __cplusplus | ||
| 46 | extern "C" { | ||
| 47 | #endif | ||
| 48 | |||
| 49 | /* Current environment. */ | ||
| 50 | typedef struct emacs_env_26 emacs_env; | ||
| 51 | |||
| 52 | /* Opaque pointer representing an Emacs Lisp value. | ||
| 53 | BEWARE: Do not assume NULL is a valid value! */ | ||
| 54 | typedef struct emacs_value_tag *emacs_value; | ||
| 55 | |||
| 56 | enum { emacs_variadic_function = -2 }; | ||
| 57 | |||
| 58 | /* Struct passed to a module init function (emacs_module_init). */ | ||
| 59 | struct emacs_runtime | ||
| 60 | { | ||
| 61 | /* Structure size (for version checking). */ | ||
| 62 | ptrdiff_t size; | ||
| 63 | |||
| 64 | /* Private data; users should not touch this. */ | ||
| 65 | struct emacs_runtime_private *private_members; | ||
| 66 | |||
| 67 | /* Return an environment pointer. */ | ||
| 68 | emacs_env *(*get_environment) (struct emacs_runtime *ert) | ||
| 69 | EMACS_ATTRIBUTE_NONNULL(1); | ||
| 70 | }; | ||
| 71 | |||
| 72 | |||
| 73 | /* Possible Emacs function call outcomes. */ | ||
| 74 | enum emacs_funcall_exit | ||
| 75 | { | ||
| 76 | /* Function has returned normally. */ | ||
| 77 | emacs_funcall_exit_return = 0, | ||
| 78 | |||
| 79 | /* Function has signaled an error using `signal'. */ | ||
| 80 | emacs_funcall_exit_signal = 1, | ||
| 81 | |||
| 82 | /* Function has exit using `throw'. */ | ||
| 83 | emacs_funcall_exit_throw = 2, | ||
| 84 | }; | ||
| 85 | |||
| 86 | struct emacs_env_25 | ||
| 87 | { | ||
| 88 | @module_env_snippet_25@ | ||
| 89 | }; | ||
| 90 | |||
| 91 | struct emacs_env_26 | ||
| 92 | { | ||
| 93 | @module_env_snippet_25@ | ||
| 94 | |||
| 95 | @module_env_snippet_26@ | ||
| 96 | }; | ||
| 97 | |||
| 98 | /* Every module should define a function as follows. */ | ||
| 99 | extern int emacs_module_init (struct emacs_runtime *ert) | ||
| 100 | EMACS_ATTRIBUTE_NONNULL(1); | ||
| 101 | |||
| 102 | #ifdef __cplusplus | ||
| 103 | } | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #endif /* EMACS_MODULE_H */ | ||
diff --git a/src/emacs-module.h b/src/module-env-25.h index f545a27b5fd..17e67004b24 100644 --- a/src/emacs-module.h +++ b/src/module-env-25.h | |||
| @@ -1,90 +1,3 @@ | |||
| 1 | /* emacs-module.h - GNU Emacs module API. | ||
| 2 | |||
| 3 | Copyright (C) 2015-2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or (at | ||
| 10 | your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #ifndef EMACS_MODULE_H | ||
| 21 | #define EMACS_MODULE_H | ||
| 22 | |||
| 23 | #include <stdint.h> | ||
| 24 | #include <stddef.h> | ||
| 25 | |||
| 26 | #ifndef __cplusplus | ||
| 27 | #include <stdbool.h> | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #if defined __cplusplus && __cplusplus >= 201103L | ||
| 31 | # define EMACS_NOEXCEPT noexcept | ||
| 32 | #else | ||
| 33 | # define EMACS_NOEXCEPT | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #ifdef __has_attribute | ||
| 37 | #if __has_attribute(__nonnull__) | ||
| 38 | # define EMACS_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__))) | ||
| 39 | #endif | ||
| 40 | #endif | ||
| 41 | #ifndef EMACS_ATTRIBUTE_NONNULL | ||
| 42 | # define EMACS_ATTRIBUTE_NONNULL(...) | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #ifdef __cplusplus | ||
| 46 | extern "C" { | ||
| 47 | #endif | ||
| 48 | |||
| 49 | /* Current environment. */ | ||
| 50 | typedef struct emacs_env_25 emacs_env; | ||
| 51 | |||
| 52 | /* Opaque pointer representing an Emacs Lisp value. | ||
| 53 | BEWARE: Do not assume NULL is a valid value! */ | ||
| 54 | typedef struct emacs_value_tag *emacs_value; | ||
| 55 | |||
| 56 | enum { emacs_variadic_function = -2 }; | ||
| 57 | |||
| 58 | /* Struct passed to a module init function (emacs_module_init). */ | ||
| 59 | struct emacs_runtime | ||
| 60 | { | ||
| 61 | /* Structure size (for version checking). */ | ||
| 62 | ptrdiff_t size; | ||
| 63 | |||
| 64 | /* Private data; users should not touch this. */ | ||
| 65 | struct emacs_runtime_private *private_members; | ||
| 66 | |||
| 67 | /* Return an environment pointer. */ | ||
| 68 | emacs_env *(*get_environment) (struct emacs_runtime *ert) | ||
| 69 | EMACS_ATTRIBUTE_NONNULL(1); | ||
| 70 | }; | ||
| 71 | |||
| 72 | |||
| 73 | /* Possible Emacs function call outcomes. */ | ||
| 74 | enum emacs_funcall_exit | ||
| 75 | { | ||
| 76 | /* Function has returned normally. */ | ||
| 77 | emacs_funcall_exit_return = 0, | ||
| 78 | |||
| 79 | /* Function has signaled an error using `signal'. */ | ||
| 80 | emacs_funcall_exit_signal = 1, | ||
| 81 | |||
| 82 | /* Function has exit using `throw'. */ | ||
| 83 | emacs_funcall_exit_throw = 2, | ||
| 84 | }; | ||
| 85 | |||
| 86 | struct emacs_env_25 | ||
| 87 | { | ||
| 88 | /* Structure size (for version checking). */ | 1 | /* Structure size (for version checking). */ |
| 89 | ptrdiff_t size; | 2 | ptrdiff_t size; |
| 90 | 3 | ||
| @@ -225,18 +138,3 @@ struct emacs_env_25 | |||
| 225 | 138 | ||
| 226 | ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vec) | 139 | ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vec) |
| 227 | EMACS_ATTRIBUTE_NONNULL(1); | 140 | EMACS_ATTRIBUTE_NONNULL(1); |
| 228 | |||
| 229 | /* Returns whether a quit is pending. */ | ||
| 230 | bool (*should_quit) (emacs_env *env) | ||
| 231 | EMACS_ATTRIBUTE_NONNULL(1); | ||
| 232 | }; | ||
| 233 | |||
| 234 | /* Every module should define a function as follows. */ | ||
| 235 | extern int emacs_module_init (struct emacs_runtime *ert) | ||
| 236 | EMACS_ATTRIBUTE_NONNULL(1); | ||
| 237 | |||
| 238 | #ifdef __cplusplus | ||
| 239 | } | ||
| 240 | #endif | ||
| 241 | |||
| 242 | #endif /* EMACS_MODULE_H */ | ||
diff --git a/src/module-env-26.h b/src/module-env-26.h new file mode 100644 index 00000000000..1ab12d45c84 --- /dev/null +++ b/src/module-env-26.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | /* Returns whether a quit is pending. */ | ||
| 2 | bool (*should_quit) (emacs_env *env) | ||
| 3 | EMACS_ATTRIBUTE_NONNULL(1); | ||