aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2019-04-24 23:12:35 +0200
committerPhilipp Stephani2019-04-24 23:12:35 +0200
commitd2e1bac47816fa1f48482faeebf7fa562a5b0e40 (patch)
tree85eda43e37e3df0b74a2d82cf313c28bbfefa27c /src
parent4c90369d77d3db1cbd37df7857e4706176fd7ba2 (diff)
downloademacs-d2e1bac47816fa1f48482faeebf7fa562a5b0e40.tar.gz
emacs-d2e1bac47816fa1f48482faeebf7fa562a5b0e40.zip
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.c4
-rw-r--r--src/emacs-module.c36
-rw-r--r--src/lisp.h30
-rw-r--r--src/print.c4
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'. */)
337 fun = XCDR (fun); 337 fun = XCDR (fun);
338 if (SUBRP (fun)) 338 if (SUBRP (fun))
339 doc = make_fixnum (XSUBR (fun)->doc); 339 doc = make_fixnum (XSUBR (fun)->doc);
340#ifdef HAVE_MODULES
340 else if (MODULE_FUNCTIONP (fun)) 341 else if (MODULE_FUNCTIONP (fun))
341 doc = XMODULE_FUNCTION (fun)->documentation; 342 doc = module_function_documentation (XMODULE_FUNCTION (fun));
343#endif
342 else if (COMPILEDP (fun)) 344 else if (COMPILEDP (fun))
343 { 345 {
344 if (PVSIZE (fun) <= COMPILED_DOC_STRING) 346 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)
471 value_to_lisp (value)); 471 value_to_lisp (value));
472} 472}
473 473
474/* Function prototype for the module Lisp functions. */
475typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
476 emacs_value [], void *);
477
478/* Module function. */
479
480/* A function environment is an auxiliary structure returned by
481 `module_make_function' to store information about a module
482 function. It is stored in a pseudovector. Its members correspond
483 to the arguments given to `module_make_function'. */
484
485struct Lisp_Module_Function
486{
487 union vectorlike_header header;
488
489 /* Fields traced by GC; these must come first. */
490 Lisp_Object documentation;
491
492 /* Fields ignored by GC. */
493 ptrdiff_t min_arity, max_arity;
494 emacs_subr subr;
495 void *data;
496} GCALIGNED_STRUCT;
497
474static struct Lisp_Module_Function * 498static struct Lisp_Module_Function *
475allocate_module_function (void) 499allocate_module_function (void)
476{ 500{
@@ -901,6 +925,18 @@ module_function_arity (const struct Lisp_Module_Function *const function)
901 maxargs == MANY ? Qmany : make_fixnum (maxargs)); 925 maxargs == MANY ? Qmany : make_fixnum (maxargs));
902} 926}
903 927
928Lisp_Object
929module_function_documentation (const struct Lisp_Module_Function *function)
930{
931 return function->documentation;
932}
933
934void *
935module_function_address (const struct Lisp_Module_Function *function)
936{
937 return function->subr;
938}
939
904 940
905/* Helper functions. */ 941/* Helper functions. */
906 942
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);
4151extern void unexec_free (void *); 4151extern void unexec_free (void *);
4152#endif 4152#endif
4153 4153
4154#define EMACS_MODULE_GMP 4154/* The definition of Lisp_Module_Function depends on emacs-module.h,
4155#include "emacs-module.h" 4155 so we don't define it here. It's defined in emacs-module.c. */
4156
4157/* Function prototype for the module Lisp functions. */
4158typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
4159 emacs_value [], void *);
4160
4161/* Module function. */
4162
4163/* A function environment is an auxiliary structure returned by
4164 `module_make_function' to store information about a module
4165 function. It is stored in a pseudovector. Its members correspond
4166 to the arguments given to `module_make_function'. */
4167
4168struct Lisp_Module_Function
4169{
4170 union vectorlike_header header;
4171
4172 /* Fields traced by GC; these must come first. */
4173 Lisp_Object documentation;
4174
4175 /* Fields ignored by GC. */
4176 ptrdiff_t min_arity, max_arity;
4177 emacs_subr subr;
4178 void *data;
4179} GCALIGNED_STRUCT;
4180 4156
4181INLINE bool 4157INLINE bool
4182MODULE_FUNCTIONP (Lisp_Object o) 4158MODULE_FUNCTIONP (Lisp_Object o)
@@ -4198,6 +4174,8 @@ extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p);
4198/* Defined in emacs-module.c. */ 4174/* Defined in emacs-module.c. */
4199extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *); 4175extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *);
4200extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *); 4176extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *);
4177extern Lisp_Object module_function_documentation (const struct Lisp_Module_Function *);
4178extern void *module_function_address (const struct Lisp_Module_Function *);
4201extern void mark_modules (void); 4179extern void mark_modules (void);
4202extern void init_module_assertions (bool); 4180extern void init_module_assertions (bool);
4203extern void syms_of_module (void); 4181extern 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,
1787 case PVEC_MODULE_FUNCTION: 1787 case PVEC_MODULE_FUNCTION:
1788 { 1788 {
1789 print_c_string ("#<module function ", printcharfun); 1789 print_c_string ("#<module function ", printcharfun);
1790 void *ptr = XMODULE_FUNCTION (obj)->subr; 1790 void *ptr = module_function_address (XMODULE_FUNCTION (obj));
1791 const char *file = NULL; 1791 const char *file = NULL;
1792 const char *symbol = NULL; 1792 const char *symbol = NULL;
1793 dynlib_addr (ptr, &file, &symbol); 1793 dynlib_addr (ptr, &file, &symbol);
1794 1794