diff options
| author | Philipp Stephani | 2017-04-22 18:04:29 +0200 |
|---|---|---|
| committer | Philipp | 2017-05-06 21:29:08 +0200 |
| commit | a3e9694078e24d19db860aa4ff8dec8bc34b59b7 (patch) | |
| tree | 235bf0857ebe0011ffd0b9cbef5f8daa242efbc1 /src/lisp.h | |
| parent | 5e47c2e52b9b7616668c5586084e0128b231272a (diff) | |
| download | emacs-a3e9694078e24d19db860aa4ff8dec8bc34b59b7.tar.gz emacs-a3e9694078e24d19db860aa4ff8dec8bc34b59b7.zip | |
Introduce new misc type for module function
This resolves a couple of FIXMEs in emacs-module.c.
* src/lisp.h (MODULE_FUNCTIONP, XMODULE_FUNCTION): New functions.
* src/alloc.c (make_module_function): New function.
(mark_object): GC support.
* src/data.c (Ftype_of, syms_of_data): Handle module function type.
* src/print.c (print_object): Print support for new type.
* src/emacs-module.c (module_make_function, Finternal_module_call):
Use new module function type, remove FIXMEs.
(module_format_fun_env): Adapt and give it external linkage.
* test/src/emacs-module-tests.el (module-function-object): Add unit
test.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h index daf57ed906f..5d4c64a2e50 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -464,6 +464,7 @@ enum Lisp_Misc_Type | |||
| 464 | Lisp_Misc_Save_Value, | 464 | Lisp_Misc_Save_Value, |
| 465 | Lisp_Misc_Finalizer, | 465 | Lisp_Misc_Finalizer, |
| 466 | #ifdef HAVE_MODULES | 466 | #ifdef HAVE_MODULES |
| 467 | Lisp_Misc_Module_Function, | ||
| 467 | Lisp_Misc_User_Ptr, | 468 | Lisp_Misc_User_Ptr, |
| 468 | #endif | 469 | #endif |
| 469 | /* Currently floats are not a misc type, | 470 | /* Currently floats are not a misc type, |
| @@ -2385,6 +2386,28 @@ struct Lisp_User_Ptr | |||
| 2385 | void (*finalizer) (void *); | 2386 | void (*finalizer) (void *); |
| 2386 | void *p; | 2387 | void *p; |
| 2387 | }; | 2388 | }; |
| 2389 | |||
| 2390 | #include "emacs-module.h" | ||
| 2391 | |||
| 2392 | /* Function prototype for the module Lisp functions. */ | ||
| 2393 | typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t, | ||
| 2394 | emacs_value [], void *); | ||
| 2395 | |||
| 2396 | /* Function environments. */ | ||
| 2397 | |||
| 2398 | /* A function environment is an auxiliary structure used by | ||
| 2399 | `module_make_function' to store information about a module | ||
| 2400 | function. It is stored in a save pointer and retrieved by | ||
| 2401 | `internal--module-call'. Its members correspond to the arguments | ||
| 2402 | given to `module_make_function'. */ | ||
| 2403 | |||
| 2404 | struct Lisp_Module_Function | ||
| 2405 | { | ||
| 2406 | struct Lisp_Misc_Any base; | ||
| 2407 | ptrdiff_t min_arity, max_arity; | ||
| 2408 | emacs_subr subr; | ||
| 2409 | void *data; | ||
| 2410 | }; | ||
| 2388 | #endif | 2411 | #endif |
| 2389 | 2412 | ||
| 2390 | /* A finalizer sentinel. */ | 2413 | /* A finalizer sentinel. */ |
| @@ -2437,6 +2460,7 @@ union Lisp_Misc | |||
| 2437 | struct Lisp_Finalizer u_finalizer; | 2460 | struct Lisp_Finalizer u_finalizer; |
| 2438 | #ifdef HAVE_MODULES | 2461 | #ifdef HAVE_MODULES |
| 2439 | struct Lisp_User_Ptr u_user_ptr; | 2462 | struct Lisp_User_Ptr u_user_ptr; |
| 2463 | struct Lisp_Module_Function u_module_function; | ||
| 2440 | #endif | 2464 | #endif |
| 2441 | }; | 2465 | }; |
| 2442 | 2466 | ||
| @@ -2485,6 +2509,19 @@ XUSER_PTR (Lisp_Object a) | |||
| 2485 | eassert (USER_PTRP (a)); | 2509 | eassert (USER_PTRP (a)); |
| 2486 | return XUNTAG (a, Lisp_Misc); | 2510 | return XUNTAG (a, Lisp_Misc); |
| 2487 | } | 2511 | } |
| 2512 | |||
| 2513 | INLINE bool | ||
| 2514 | MODULE_FUNCTIONP (Lisp_Object o) | ||
| 2515 | { | ||
| 2516 | return MISCP (o) && XMISCTYPE (o) == Lisp_Misc_Module_Function; | ||
| 2517 | } | ||
| 2518 | |||
| 2519 | INLINE struct Lisp_Module_Function * | ||
| 2520 | XMODULE_FUNCTION (Lisp_Object o) | ||
| 2521 | { | ||
| 2522 | eassert (MODULE_FUNCTIONP (o)); | ||
| 2523 | return XUNTAG (o, Lisp_Misc); | ||
| 2524 | } | ||
| 2488 | #endif | 2525 | #endif |
| 2489 | 2526 | ||
| 2490 | 2527 | ||
| @@ -3889,8 +3926,10 @@ extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); | |||
| 3889 | #ifdef HAVE_MODULES | 3926 | #ifdef HAVE_MODULES |
| 3890 | /* Defined in alloc.c. */ | 3927 | /* Defined in alloc.c. */ |
| 3891 | extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p); | 3928 | extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p); |
| 3929 | extern Lisp_Object make_module_function (void); | ||
| 3892 | 3930 | ||
| 3893 | /* Defined in emacs-module.c. */ | 3931 | /* Defined in emacs-module.c. */ |
| 3932 | extern Lisp_Object module_format_fun_env (const struct Lisp_Module_Function *); | ||
| 3894 | extern void syms_of_module (void); | 3933 | extern void syms_of_module (void); |
| 3895 | #endif | 3934 | #endif |
| 3896 | 3935 | ||