diff options
author | Philipp Stephani <phst@google.com> | 2019-04-24 23:12:35 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2019-04-24 23:12:35 +0200 |
commit | d2e1bac47816fa1f48482faeebf7fa562a5b0e40 (patch) | |
tree | 85eda43e37e3df0b74a2d82cf313c28bbfefa27c /src | |
parent | 4c90369d77d3db1cbd37df7857e4706176fd7ba2 (diff) | |
download | emacs-d2e1bac47816fa1f48482faeebf7fa562a5b0e40.tar.gz |
Move definition of Lisp_Module_Function to emacs-module.c.
* src/lisp.h: Remove include of emacs-module.h. Remove definition
of Lisp_Module_Function structure.
* src/emacs-module.c (module_function_documentation)
(module_function_address): New accessor functions for module function
fields.
(emacs_subr, struct Lisp_Module_Function): Move from lisp.h.
* src/print.c (print_vectorlike):
* src/doc.c (Fdocumentation): Use the new accessor functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/doc.c | 4 | ||||
-rw-r--r-- | src/emacs-module.c | 36 | ||||
-rw-r--r-- | src/lisp.h | 30 | ||||
-rw-r--r-- | src/print.c | 4 |
4 files changed, 45 insertions, 29 deletions
diff --git a/src/doc.c b/src/doc.c index 372e376c625..3fa0eaac202 100644 --- a/src/doc.c +++ b/src/doc.c @@ -337,8 +337,10 @@ string is passed through `substitute-command-keys'. */) fun = XCDR (fun); if (SUBRP (fun)) doc = make_fixnum (XSUBR (fun)->doc); +#ifdef HAVE_MODULES else if (MODULE_FUNCTIONP (fun)) - doc = XMODULE_FUNCTION (fun)->documentation; + doc = module_function_documentation (XMODULE_FUNCTION (fun)); +#endif else if (COMPILEDP (fun)) { if (PVSIZE (fun) <= COMPILED_DOC_STRING) diff --git a/src/emacs-module.c b/src/emacs-module.c index 41ce9ef03e4..b6a12386267 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -471,6 +471,30 @@ module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value) value_to_lisp (value)); } +/* Function prototype for the module Lisp functions. */ +typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t, + emacs_value [], void *); + +/* Module function. */ + +/* A function environment is an auxiliary structure returned by + `module_make_function' to store information about a module + function. It is stored in a pseudovector. Its members correspond + to the arguments given to `module_make_function'. */ + +struct Lisp_Module_Function +{ + union vectorlike_header header; + + /* Fields traced by GC; these must come first. */ + Lisp_Object documentation; + + /* Fields ignored by GC. */ + ptrdiff_t min_arity, max_arity; + emacs_subr subr; + void *data; +} GCALIGNED_STRUCT; + static struct Lisp_Module_Function * allocate_module_function (void) { @@ -901,6 +925,18 @@ module_function_arity (const struct Lisp_Module_Function *const function) maxargs == MANY ? Qmany : make_fixnum (maxargs)); } +Lisp_Object +module_function_documentation (const struct Lisp_Module_Function *function) +{ + return function->documentation; +} + +void * +module_function_address (const struct Lisp_Module_Function *function) +{ + return function->subr; +} + /* Helper functions. */ diff --git a/src/lisp.h b/src/lisp.h index 70b2aa270e0..8dc44291a8f 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4151,32 +4151,8 @@ extern void *unexec_realloc (void *, size_t); extern void unexec_free (void *); #endif -#define EMACS_MODULE_GMP -#include "emacs-module.h" - -/* Function prototype for the module Lisp functions. */ -typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t, - emacs_value [], void *); - -/* Module function. */ - -/* A function environment is an auxiliary structure returned by - `module_make_function' to store information about a module - function. It is stored in a pseudovector. Its members correspond - to the arguments given to `module_make_function'. */ - -struct Lisp_Module_Function -{ - union vectorlike_header header; - - /* Fields traced by GC; these must come first. */ - Lisp_Object documentation; - - /* Fields ignored by GC. */ - ptrdiff_t min_arity, max_arity; - emacs_subr subr; - void *data; -} GCALIGNED_STRUCT; +/* The definition of Lisp_Module_Function depends on emacs-module.h, + so we don't define it here. It's defined in emacs-module.c. */ INLINE bool MODULE_FUNCTIONP (Lisp_Object o) @@ -4198,6 +4174,8 @@ extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p); /* Defined in emacs-module.c. */ extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *); extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *); +extern Lisp_Object module_function_documentation (const struct Lisp_Module_Function *); +extern void *module_function_address (const struct Lisp_Module_Function *); extern void mark_modules (void); extern void init_module_assertions (bool); extern void syms_of_module (void); diff --git a/src/print.c b/src/print.c index 081e5574b73..8b163e3ee39 100644 --- a/src/print.c +++ b/src/print.c @@ -1787,8 +1787,8 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, case PVEC_MODULE_FUNCTION: { print_c_string ("#<module function ", printcharfun); - void *ptr = XMODULE_FUNCTION (obj)->subr; - const char *file = NULL; + void *ptr = module_function_address (XMODULE_FUNCTION (obj)); + const char *file = NULL; const char *symbol = NULL; dynlib_addr (ptr, &file, &symbol); |