summaryrefslogtreecommitdiff
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2017-04-22 18:04:29 +0200
committerPhilipp <phst@google.com>2017-05-06 21:29:08 +0200
commita3e9694078e24d19db860aa4ff8dec8bc34b59b7 (patch)
tree235bf0857ebe0011ffd0b9cbef5f8daa242efbc1 /src/lisp.h
parent5e47c2e52b9b7616668c5586084e0128b231272a (diff)
downloademacs-a3e9694078e24d19db860aa4ff8dec8bc34b59b7.tar.gz
emacs-a3e9694078e24d19db860aa4ff8dec8bc34b59b7.tar.bz2
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.h39
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
Lisp_Misc_Save_Value,
Lisp_Misc_Finalizer,
#ifdef HAVE_MODULES
+ Lisp_Misc_Module_Function,
Lisp_Misc_User_Ptr,
#endif
/* Currently floats are not a misc type,
@@ -2385,6 +2386,28 @@ struct Lisp_User_Ptr
void (*finalizer) (void *);
void *p;
};
+
+#include "emacs-module.h"
+
+/* Function prototype for the module Lisp functions. */
+typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
+ emacs_value [], void *);
+
+/* Function environments. */
+
+/* A function environment is an auxiliary structure used by
+ `module_make_function' to store information about a module
+ function. It is stored in a save pointer and retrieved by
+ `internal--module-call'. Its members correspond to the arguments
+ given to `module_make_function'. */
+
+struct Lisp_Module_Function
+{
+ struct Lisp_Misc_Any base;
+ ptrdiff_t min_arity, max_arity;
+ emacs_subr subr;
+ void *data;
+};
#endif
/* A finalizer sentinel. */
@@ -2437,6 +2460,7 @@ union Lisp_Misc
struct Lisp_Finalizer u_finalizer;
#ifdef HAVE_MODULES
struct Lisp_User_Ptr u_user_ptr;
+ struct Lisp_Module_Function u_module_function;
#endif
};
@@ -2485,6 +2509,19 @@ XUSER_PTR (Lisp_Object a)
eassert (USER_PTRP (a));
return XUNTAG (a, Lisp_Misc);
}
+
+INLINE bool
+MODULE_FUNCTIONP (Lisp_Object o)
+{
+ return MISCP (o) && XMISCTYPE (o) == Lisp_Misc_Module_Function;
+}
+
+INLINE struct Lisp_Module_Function *
+XMODULE_FUNCTION (Lisp_Object o)
+{
+ eassert (MODULE_FUNCTIONP (o));
+ return XUNTAG (o, Lisp_Misc);
+}
#endif
@@ -3889,8 +3926,10 @@ extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol);
#ifdef HAVE_MODULES
/* Defined in alloc.c. */
extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p);
+extern Lisp_Object make_module_function (void);
/* Defined in emacs-module.c. */
+extern Lisp_Object module_format_fun_env (const struct Lisp_Module_Function *);
extern void syms_of_module (void);
#endif