summaryrefslogtreecommitdiff
path: root/src/emacs-module.h.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/emacs-module.h.in')
-rw-r--r--src/emacs-module.h.in38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
index 898021dc5e6..cd75c0907e4 100644
--- a/src/emacs-module.h.in
+++ b/src/emacs-module.h.in
@@ -42,6 +42,12 @@ information how to write modules and use this header file.
# define EMACS_NOEXCEPT
#endif
+#if defined __cplusplus && __cplusplus >= 201703L
+# define EMACS_NOEXCEPT_TYPEDEF noexcept
+#else
+# define EMACS_NOEXCEPT_TYPEDEF
+#endif
+
#ifdef __has_attribute
#if __has_attribute(__nonnull__)
# define EMACS_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
@@ -56,7 +62,7 @@ extern "C" {
#endif
/* Current environment. */
-typedef struct emacs_env_27 emacs_env;
+typedef struct emacs_env_@emacs_major_version@ emacs_env;
/* Opaque pointer representing an Emacs Lisp value.
BEWARE: Do not assume NULL is a valid value! */
@@ -74,10 +80,25 @@ struct emacs_runtime
struct emacs_runtime_private *private_members;
/* Return an environment pointer. */
- emacs_env *(*get_environment) (struct emacs_runtime *ert)
+ emacs_env *(*get_environment) (struct emacs_runtime *runtime)
EMACS_ATTRIBUTE_NONNULL(1);
};
+/* Type aliases for function pointer types used in the module API.
+ Note that we don't use these aliases directly in the API to be able
+ to mark the function arguments as 'noexcept' before C++20.
+ However, users can use them if they want. */
+
+/* Function prototype for the module Lisp functions. These must not
+ throw C++ exceptions. */
+typedef emacs_value (*emacs_function) (emacs_env *env, ptrdiff_t nargs,
+ emacs_value *args,
+ void *data)
+ EMACS_NOEXCEPT_TYPEDEF EMACS_ATTRIBUTE_NONNULL (1);
+
+/* Function prototype for module user-pointer and function finalizers.
+ These must not throw C++ exceptions. */
+typedef void (*emacs_finalizer) (void *data) EMACS_NOEXCEPT_TYPEDEF;
/* Possible Emacs function call outcomes. */
enum emacs_funcall_exit
@@ -131,8 +152,19 @@ struct emacs_env_27
@module_env_snippet_27@
};
+struct emacs_env_28
+{
+@module_env_snippet_25@
+
+@module_env_snippet_26@
+
+@module_env_snippet_27@
+
+@module_env_snippet_28@
+};
+
/* Every module should define a function as follows. */
-extern int emacs_module_init (struct emacs_runtime *ert)
+extern int emacs_module_init (struct emacs_runtime *runtime)
EMACS_NOEXCEPT
EMACS_ATTRIBUTE_NONNULL(1);