From: Paul Eggert Date: Thu, 19 Nov 2015 15:53:51 +0000 (-0800) Subject: Rename emacs_module.h to module.h X-Git-Tag: emacs-25.0.90~738 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=80f19fb898b574b345b908dfd6a98c965de4136f;p=emacs.git Rename emacs_module.h to module.h * src/module.h: Rename from src/emacs_module.h. All uses changed. --- diff --git a/modules/mod-test/mod-test.c b/modules/mod-test/mod-test.c index 2de53152b1b..db5516ee553 100644 --- a/modules/mod-test/mod-test.c +++ b/modules/mod-test/mod-test.c @@ -1,6 +1,6 @@ #include #include -#include +#include int plugin_is_GPL_compatible; diff --git a/modules/modhelp.py b/modules/modhelp.py index ef41ba5a917..57bed5023c7 100755 --- a/modules/modhelp.py +++ b/modules/modhelp.py @@ -125,7 +125,7 @@ all: ${module}.so ${module}.doc '''), string.Template('${c_file}'): string.Template(''' -#include +#include int plugin_is_GPL_compatible; diff --git a/src/emacs_module.h b/src/emacs_module.h deleted file mode 100644 index 4b774fe6584..00000000000 --- a/src/emacs_module.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - emacs_module.h - Module API - Copyright (C) 2015 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 . -*/ - -#ifndef EMACS_MODULE_H -#define EMACS_MODULE_H - -#include -#include -#include - -#ifdef __cplusplus -#define EMACS_EXTERN_C_BEGIN extern "C" { -#define EMACS_EXTERN_C_END } -#else -#define EMACS_EXTERN_C_BEGIN -#define EMACS_EXTERN_C_END -#endif - -#if defined(__cplusplus) && __cplusplus >= 201103L -#define EMACS_NOEXCEPT noexcept -#else -#define EMACS_NOEXCEPT -#endif - -EMACS_EXTERN_C_BEGIN - -/* Current environement */ -typedef struct emacs_env_25 emacs_env; - -/* Opaque structure pointer representing an Emacs Lisp value */ -typedef struct emacs_value_tag* emacs_value; - -enum emacs_arity { - emacs_variadic_function = -2 -}; - -/* Struct passed to a module init function (emacs_module_init) */ -struct emacs_runtime { - /* Structure size (for version checking) */ - size_t size; - - /* Private data; users should not touch this */ - struct emacs_runtime_private *private_members; - - /* Returns an environment pointer. */ - emacs_env* (*get_environment)(struct emacs_runtime *ert); -}; - - -/* Function prototype for the module init function */ -typedef int (*emacs_init_function)(struct emacs_runtime *ert); - -/* Function prototype for the module Lisp functions */ -typedef emacs_value (*emacs_subr)(emacs_env *env, - int nargs, - emacs_value args[], - void *data); - -/* Function prototype for module user-pointer finalizers */ -typedef void (*emacs_finalizer_function)(void*); - -/* 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) - */ - - size_t size; - - /* Private data; users should not touch this */ - struct emacs_env_private *private_members; - - /* - * Memory management - */ - - - emacs_value (*make_global_ref)(emacs_env *env, - emacs_value any_reference); - - void (*free_global_ref)(emacs_env *env, - emacs_value global_reference); - - /* - * Non-local exit handling - */ - - enum emacs_funcall_exit (*non_local_exit_check)(emacs_env *env); - - void (*non_local_exit_clear)(emacs_env *env); - - enum emacs_funcall_exit (*non_local_exit_get)(emacs_env *env, - emacs_value *non_local_exit_symbol_out, - emacs_value *non_local_exit_data_out); - - void (*non_local_exit_signal)(emacs_env *env, - emacs_value non_local_exit_symbol, - emacs_value non_local_exit_data); - - void (*non_local_exit_throw)(emacs_env *env, - emacs_value tag, - emacs_value value); - - /* - * Function registration - */ - - emacs_value (*make_function)(emacs_env *env, - int min_arity, - int max_arity, - emacs_value (*function)(emacs_env*, int, emacs_value*, void*) EMACS_NOEXCEPT, - const char *documentation, - void *data); - - emacs_value (*funcall)(emacs_env *env, - emacs_value function, - int nargs, - emacs_value args[]); - - emacs_value (*intern)(emacs_env *env, - const char *symbol_name); - - /* - * Type conversion - */ - - emacs_value (*type_of)(emacs_env *env, - emacs_value value); - - bool (*is_not_nil)(emacs_env *env, emacs_value value); - - bool (*eq)(emacs_env *env, emacs_value a, emacs_value b); - - int64_t (*extract_integer)(emacs_env *env, - emacs_value value); - - emacs_value (*make_integer)(emacs_env *env, - int64_t value); - - double (*extract_float)(emacs_env *env, - emacs_value value); - - emacs_value (*make_float)(emacs_env *env, - double value); - - /* - * Copy the content of the lisp string VALUE to BUFFER as an utf8 - * null-terminated string. - * - * SIZE must point to the total size of the buffer. If BUFFER is - * NULL or if SIZE is not big enough, write the required buffer size - * to SIZE and return false. - * - * Note that SIZE must include the last null byte (e.g. "abc" needs - * a buffer of size 4). - * - * Returns true if the string was successfully copied. - */ - - bool (*copy_string_contents)(emacs_env *env, - emacs_value value, - char *buffer, - size_t *size_inout); - - /* - * Create a lisp string from a utf8 encoded string. - */ - emacs_value (*make_string)(emacs_env *env, - const char *contents, size_t length); - - /* - * Embedded pointer type - */ - emacs_value (*make_user_ptr)(emacs_env *env, - void (*fin)(void *) EMACS_NOEXCEPT, - void *ptr); - - void* (*get_user_ptr)(emacs_env *env, emacs_value uptr); - void (*set_user_ptr)(emacs_env *env, emacs_value uptr, void *ptr); - - void (*(*get_user_finalizer)(emacs_env *env, emacs_value uptr))(void *) EMACS_NOEXCEPT; - void (*set_user_finalizer)(emacs_env *env, - emacs_value uptr, - void (*fin)(void *) EMACS_NOEXCEPT); - - /* - * Vector functions - */ - emacs_value (*vec_get) (emacs_env *env, - emacs_value vec, - size_t i); - - void (*vec_set) (emacs_env *env, - emacs_value vec, - size_t i, - emacs_value val); - - size_t (*vec_size) (emacs_env *env, - emacs_value vec); -}; - -EMACS_EXTERN_C_END - -#endif /* EMACS_MODULE_H */ diff --git a/src/module.c b/src/module.c index 6025ce4cfe0..4069b881394 100644 --- a/src/module.c +++ b/src/module.c @@ -24,7 +24,7 @@ along with GNU Emacs. If not, see . */ #include #include "lisp.h" -#include "emacs_module.h" +#include "module.h" #include "dynlib.h" #include "coding.h" #include "verify.h" diff --git a/src/module.h b/src/module.h new file mode 100644 index 00000000000..b4c3ff83b57 --- /dev/null +++ b/src/module.h @@ -0,0 +1,230 @@ +/* + module.h - Module API + Copyright (C) 2015 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 . +*/ + +#ifndef EMACS_MODULE_H +#define EMACS_MODULE_H + +#include +#include +#include + +#ifdef __cplusplus +#define EMACS_EXTERN_C_BEGIN extern "C" { +#define EMACS_EXTERN_C_END } +#else +#define EMACS_EXTERN_C_BEGIN +#define EMACS_EXTERN_C_END +#endif + +#if defined(__cplusplus) && __cplusplus >= 201103L +#define EMACS_NOEXCEPT noexcept +#else +#define EMACS_NOEXCEPT +#endif + +EMACS_EXTERN_C_BEGIN + +/* Current environement */ +typedef struct emacs_env_25 emacs_env; + +/* Opaque structure pointer representing an Emacs Lisp value */ +typedef struct emacs_value_tag* emacs_value; + +enum emacs_arity { + emacs_variadic_function = -2 +}; + +/* Struct passed to a module init function (emacs_module_init) */ +struct emacs_runtime { + /* Structure size (for version checking) */ + size_t size; + + /* Private data; users should not touch this */ + struct emacs_runtime_private *private_members; + + /* Returns an environment pointer. */ + emacs_env* (*get_environment)(struct emacs_runtime *ert); +}; + + +/* Function prototype for the module init function */ +typedef int (*emacs_init_function)(struct emacs_runtime *ert); + +/* Function prototype for the module Lisp functions */ +typedef emacs_value (*emacs_subr)(emacs_env *env, + int nargs, + emacs_value args[], + void *data); + +/* Function prototype for module user-pointer finalizers */ +typedef void (*emacs_finalizer_function)(void*); + +/* 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) + */ + + size_t size; + + /* Private data; users should not touch this */ + struct emacs_env_private *private_members; + + /* + * Memory management + */ + + + emacs_value (*make_global_ref)(emacs_env *env, + emacs_value any_reference); + + void (*free_global_ref)(emacs_env *env, + emacs_value global_reference); + + /* + * Non-local exit handling + */ + + enum emacs_funcall_exit (*non_local_exit_check)(emacs_env *env); + + void (*non_local_exit_clear)(emacs_env *env); + + enum emacs_funcall_exit (*non_local_exit_get)(emacs_env *env, + emacs_value *non_local_exit_symbol_out, + emacs_value *non_local_exit_data_out); + + void (*non_local_exit_signal)(emacs_env *env, + emacs_value non_local_exit_symbol, + emacs_value non_local_exit_data); + + void (*non_local_exit_throw)(emacs_env *env, + emacs_value tag, + emacs_value value); + + /* + * Function registration + */ + + emacs_value (*make_function)(emacs_env *env, + int min_arity, + int max_arity, + emacs_value (*function)(emacs_env*, int, emacs_value*, void*) EMACS_NOEXCEPT, + const char *documentation, + void *data); + + emacs_value (*funcall)(emacs_env *env, + emacs_value function, + int nargs, + emacs_value args[]); + + emacs_value (*intern)(emacs_env *env, + const char *symbol_name); + + /* + * Type conversion + */ + + emacs_value (*type_of)(emacs_env *env, + emacs_value value); + + bool (*is_not_nil)(emacs_env *env, emacs_value value); + + bool (*eq)(emacs_env *env, emacs_value a, emacs_value b); + + int64_t (*extract_integer)(emacs_env *env, + emacs_value value); + + emacs_value (*make_integer)(emacs_env *env, + int64_t value); + + double (*extract_float)(emacs_env *env, + emacs_value value); + + emacs_value (*make_float)(emacs_env *env, + double value); + + /* + * Copy the content of the lisp string VALUE to BUFFER as an utf8 + * null-terminated string. + * + * SIZE must point to the total size of the buffer. If BUFFER is + * NULL or if SIZE is not big enough, write the required buffer size + * to SIZE and return false. + * + * Note that SIZE must include the last null byte (e.g. "abc" needs + * a buffer of size 4). + * + * Returns true if the string was successfully copied. + */ + + bool (*copy_string_contents)(emacs_env *env, + emacs_value value, + char *buffer, + size_t *size_inout); + + /* + * Create a lisp string from a utf8 encoded string. + */ + emacs_value (*make_string)(emacs_env *env, + const char *contents, size_t length); + + /* + * Embedded pointer type + */ + emacs_value (*make_user_ptr)(emacs_env *env, + void (*fin)(void *) EMACS_NOEXCEPT, + void *ptr); + + void* (*get_user_ptr)(emacs_env *env, emacs_value uptr); + void (*set_user_ptr)(emacs_env *env, emacs_value uptr, void *ptr); + + void (*(*get_user_finalizer)(emacs_env *env, emacs_value uptr))(void *) EMACS_NOEXCEPT; + void (*set_user_finalizer)(emacs_env *env, + emacs_value uptr, + void (*fin)(void *) EMACS_NOEXCEPT); + + /* + * Vector functions + */ + emacs_value (*vec_get) (emacs_env *env, + emacs_value vec, + size_t i); + + void (*vec_set) (emacs_env *env, + emacs_value vec, + size_t i, + emacs_value val); + + size_t (*vec_size) (emacs_env *env, + emacs_value vec); +}; + +EMACS_EXTERN_C_END + +#endif /* EMACS_MODULE_H */