diff options
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
| @@ -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. */ | ||
| 475 | typedef 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 | |||
| 485 | struct 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 | |||
| 474 | static struct Lisp_Module_Function * | 498 | static struct Lisp_Module_Function * |
| 475 | allocate_module_function (void) | 499 | allocate_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 | ||
| 928 | Lisp_Object | ||
| 929 | module_function_documentation (const struct Lisp_Module_Function *function) | ||
| 930 | { | ||
| 931 | return function->documentation; | ||
| 932 | } | ||
| 933 | |||
| 934 | void * | ||
| 935 | module_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); | |||
| 4151 | extern void unexec_free (void *); | 4151 | extern 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. */ | ||
| 4158 | typedef 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 | |||
| 4168 | struct 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 | ||
| 4181 | INLINE bool | 4157 | INLINE bool |
| 4182 | MODULE_FUNCTIONP (Lisp_Object o) | 4158 | MODULE_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. */ |
| 4199 | extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *); | 4175 | extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *); |
| 4200 | extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *); | 4176 | extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *); |
| 4177 | extern Lisp_Object module_function_documentation (const struct Lisp_Module_Function *); | ||
| 4178 | extern void *module_function_address (const struct Lisp_Module_Function *); | ||
| 4201 | extern void mark_modules (void); | 4179 | extern void mark_modules (void); |
| 4202 | extern void init_module_assertions (bool); | 4180 | extern void init_module_assertions (bool); |
| 4203 | extern void syms_of_module (void); | 4181 | 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, | |||
| 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 | ||