emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c66a7cc: emacs-module.h: Create emacs_env_26


From: Philipp Stephani
Subject: [Emacs-diffs] master c66a7cc: emacs-module.h: Create emacs_env_26
Date: Sat, 17 Jun 2017 13:16:40 -0400 (EDT)

branch: master
commit c66a7cce17ac4b9cde6bf49232aaa59c1c73404e
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    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.
---
 .gitignore                              |   1 +
 configure.ac                            |   6 ++
 src/emacs-module.h.in                   | 106 ++++++++++++++++++++++++++++++++
 src/{emacs-module.h => module-env-25.h} | 102 ------------------------------
 src/module-env-26.h                     |   3 +
 5 files changed, 116 insertions(+), 102 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1abefeb..46ed4a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,6 +46,7 @@ makefile
 lib/gnulib.mk
 src/config.h
 src/epaths.h
+src/emacs-module.h
 
 # C-level sources built by 'make'.
 lib/alloca.h
diff --git a/configure.ac b/configure.ac
index 9069e5b..ef61107 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3518,6 +3518,12 @@ AC_SUBST(LIBMODULES)
 AC_SUBST(HAVE_MODULES)
 AC_SUBST(MODULES_SUFFIX)
 
+AC_CONFIG_FILES([src/emacs-module.h])
+AC_SUBST_FILE([module_env_snippet_25])
+AC_SUBST_FILE([module_env_snippet_26])
+module_env_snippet_25="$srcdir/src/module-env-25.h"
+module_env_snippet_26="$srcdir/src/module-env-26.h"
+
 ### Use -lpng if available, unless '--with-png=no'.
 HAVE_PNG=no
 LIBPNG=
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
new file mode 100644
index 0000000..339234f
--- /dev/null
+++ b/src/emacs-module.h.in
@@ -0,0 +1,106 @@
+/* emacs-module.h - GNU Emacs module API.
+
+Copyright (C) 2015-2017 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef EMACS_MODULE_H
+#define EMACS_MODULE_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#if defined __cplusplus && __cplusplus >= 201103L
+# define EMACS_NOEXCEPT noexcept
+#else
+# define EMACS_NOEXCEPT
+#endif
+
+#ifdef __has_attribute
+#if __has_attribute(__nonnull__)
+# define EMACS_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
+#endif
+#endif
+#ifndef EMACS_ATTRIBUTE_NONNULL
+# define EMACS_ATTRIBUTE_NONNULL(...)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Current environment.  */
+typedef struct emacs_env_26 emacs_env;
+
+/* Opaque pointer representing an Emacs Lisp value.
+   BEWARE: Do not assume NULL is a valid value!  */
+typedef struct emacs_value_tag *emacs_value;
+
+enum { emacs_variadic_function = -2 };
+
+/* Struct passed to a module init function (emacs_module_init).  */
+struct emacs_runtime
+{
+  /* Structure size (for version checking).  */
+  ptrdiff_t size;
+
+  /* Private data; users should not touch this.  */
+  struct emacs_runtime_private *private_members;
+
+  /* Return an environment pointer.  */
+  emacs_env *(*get_environment) (struct emacs_runtime *ert)
+    EMACS_ATTRIBUTE_NONNULL(1);
+};
+
+
+/* Possible Emacs function call outcomes.  */
+enum emacs_funcall_exit
+{
+  /* Function has returned normally.  */
+  emacs_funcall_exit_return = 0,
+
+  /* Function has signaled an error using `signal'.  */
+  emacs_funcall_exit_signal = 1,
+
+  /* Function has exit using `throw'.  */
+  emacs_funcall_exit_throw = 2,
+};
+
+struct emacs_env_25
+{
address@hidden@
+};
+
+struct emacs_env_26
+{
address@hidden@
+
address@hidden@
+};
+
+/* Every module should define a function as follows.  */
+extern int emacs_module_init (struct emacs_runtime *ert)
+  EMACS_ATTRIBUTE_NONNULL(1);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* EMACS_MODULE_H */
diff --git a/src/emacs-module.h b/src/module-env-25.h
similarity index 62%
rename from src/emacs-module.h
rename to src/module-env-25.h
index f545a27..17e6700 100644
--- a/src/emacs-module.h
+++ b/src/module-env-25.h
@@ -1,90 +1,3 @@
-/* emacs-module.h - GNU Emacs module API.
-
-Copyright (C) 2015-2017 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or (at
-your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef EMACS_MODULE_H
-#define EMACS_MODULE_H
-
-#include <stdint.h>
-#include <stddef.h>
-
-#ifndef __cplusplus
-#include <stdbool.h>
-#endif
-
-#if defined __cplusplus && __cplusplus >= 201103L
-# define EMACS_NOEXCEPT noexcept
-#else
-# define EMACS_NOEXCEPT
-#endif
-
-#ifdef __has_attribute
-#if __has_attribute(__nonnull__)
-# define EMACS_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
-#endif
-#endif
-#ifndef EMACS_ATTRIBUTE_NONNULL
-# define EMACS_ATTRIBUTE_NONNULL(...)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Current environment.  */
-typedef struct emacs_env_25 emacs_env;
-
-/* Opaque pointer representing an Emacs Lisp value.
-   BEWARE: Do not assume NULL is a valid value!  */
-typedef struct emacs_value_tag *emacs_value;
-
-enum { emacs_variadic_function = -2 };
-
-/* Struct passed to a module init function (emacs_module_init).  */
-struct emacs_runtime
-{
-  /* Structure size (for version checking).  */
-  ptrdiff_t size;
-
-  /* Private data; users should not touch this.  */
-  struct emacs_runtime_private *private_members;
-
-  /* Return an environment pointer.  */
-  emacs_env *(*get_environment) (struct emacs_runtime *ert)
-    EMACS_ATTRIBUTE_NONNULL(1);
-};
-
-
-/* Possible Emacs function call outcomes.  */
-enum emacs_funcall_exit
-{
-  /* Function has returned normally.  */
-  emacs_funcall_exit_return = 0,
-
-  /* Function has signaled an error using `signal'.  */
-  emacs_funcall_exit_signal = 1,
-
-  /* Function has exit using `throw'.  */
-  emacs_funcall_exit_throw = 2,
-};
-
-struct emacs_env_25
-{
   /* Structure size (for version checking).  */
   ptrdiff_t size;
 
@@ -225,18 +138,3 @@ struct emacs_env_25
 
   ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vec)
     EMACS_ATTRIBUTE_NONNULL(1);
-
-  /* Returns whether a quit is pending.  */
-  bool (*should_quit) (emacs_env *env)
-    EMACS_ATTRIBUTE_NONNULL(1);
-};
-
-/* Every module should define a function as follows.  */
-extern int emacs_module_init (struct emacs_runtime *ert)
-  EMACS_ATTRIBUTE_NONNULL(1);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* EMACS_MODULE_H */
diff --git a/src/module-env-26.h b/src/module-env-26.h
new file mode 100644
index 0000000..1ab12d4
--- /dev/null
+++ b/src/module-env-26.h
@@ -0,0 +1,3 @@
+  /* Returns whether a quit is pending.  */
+  bool (*should_quit) (emacs_env *env)
+    EMACS_ATTRIBUTE_NONNULL(1);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]