aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2015-11-28 13:53:32 +0200
committerEli Zaretskii2015-11-28 13:53:32 +0200
commitb527d609d9da61497ba10e0c5fe7c6a3eb7ba7d0 (patch)
tree73672bb2d861ff791880a635dea859e5aff28ff9 /src
parent40b794bf004032e6f9a01047562c6504bcf7cf4e (diff)
downloademacs-b527d609d9da61497ba10e0c5fe7c6a3eb7ba7d0.tar.gz
emacs-b527d609d9da61497ba10e0c5fe7c6a3eb7ba7d0.zip
Make module-call be visible from Lisp
* src/emacs-module.c (module_make_function): Use internal--module-call. (Finternal_module_call): Renamed from Fmodule_call. Add safety checks. (syms_of_module): DEFSYM save-value-p and save-pointer-p. Do defsubr internal--module-call.
Diffstat (limited to 'src')
-rw-r--r--src/emacs-module.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 36864705b82..76c9098bab3 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -214,8 +214,8 @@ static void module_wrong_type (emacs_env *, Lisp_Object, Lisp_Object);
214/* A function environment is an auxiliary structure used by 214/* A function environment is an auxiliary structure used by
215 `module_make_function' to store information about a module 215 `module_make_function' to store information about a module
216 function. It is stored in a save pointer and retrieved by 216 function. It is stored in a save pointer and retrieved by
217 `module-call'. Its members correspond to the arguments given to 217 `internal--module-call'. Its members correspond to the arguments
218 `module_make_function'. */ 218 given to `module_make_function'. */
219 219
220struct module_fun_env 220struct module_fun_env
221{ 221{
@@ -224,11 +224,6 @@ struct module_fun_env
224 void *data; 224 void *data;
225}; 225};
226 226
227/* The function definition of `module-call'. `module-call' is
228 uninterned because user code couldn't meaningfully use it, so keep
229 its definition around somewhere else. */
230static Lisp_Object module_call_func;
231
232 227
233/* Implementation of runtime and environment functions. 228/* Implementation of runtime and environment functions.
234 229
@@ -384,12 +379,12 @@ module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value)
384 value_to_lisp (value)); 379 value_to_lisp (value));
385} 380}
386 381
387/* A module function is lambda function that calls `module-call', 382/* A module function is lambda function that calls
388 passing the function pointer of the module function along with the 383 `internal--module-call', passing the function pointer of the module
389 module emacs_env pointer as arguments. 384 function along with the module emacs_env pointer as arguments.
390 385
391 (function (lambda (&rest arglist) 386 (function (lambda (&rest arglist)
392 (module-call envobj arglist))) */ 387 (internal--module-call envobj arglist))) */
393 388
394static emacs_value 389static emacs_value
395module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, 390module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity,
@@ -423,7 +418,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity,
423 Lisp_Object ret = list4 (Qlambda, 418 Lisp_Object ret = list4 (Qlambda,
424 list2 (Qand_rest, Qargs), 419 list2 (Qand_rest, Qargs),
425 doc, 420 doc,
426 list3 (module_call_func, 421 list3 (Qinternal_module_call,
427 envobj, 422 envobj,
428 Qargs)); 423 Qargs));
429 424
@@ -779,12 +774,16 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
779 return Qt; 774 return Qt;
780} 775}
781 776
782DEFUN ("module-call", Fmodule_call, Smodule_call, 2, 2, 0, 777DEFUN ("internal--module-call", Finternal_module_call, Sinternal_module_call, 2, 2, 0,
783 doc: /* Internal function to call a module function. 778 doc: /* Internal function to call a module function.
784ENVOBJ is a save pointer to a module_fun_env structure. 779ENVOBJ is a save pointer to a module_fun_env structure.
785ARGLIST is a list of arguments passed to SUBRPTR. */) 780ARGLIST is a list of arguments passed to SUBRPTR. */)
786 (Lisp_Object envobj, Lisp_Object arglist) 781 (Lisp_Object envobj, Lisp_Object arglist)
787{ 782{
783 CHECK_TYPE (SAVE_VALUEP (envobj), Qsave_value_p, envobj);
784 struct Lisp_Save_Value *save_value = XSAVE_VALUE (envobj);
785 CHECK_TYPE (save_type (save_value, 0) == SAVE_POINTER, Qsave_pointer_p, envobj);
786 CHECK_CONS (arglist);
788 struct module_fun_env *envptr = XSAVE_POINTER (envobj, 0); 787 struct module_fun_env *envptr = XSAVE_POINTER (envobj, 0);
789 EMACS_INT len = XFASTINT (Flength (arglist)); 788 EMACS_INT len = XFASTINT (Flength (arglist));
790 eassume (0 <= envptr->min_arity); 789 eassume (0 <= envptr->min_arity);
@@ -1155,14 +1154,13 @@ syms_of_module (void)
1155 code or modules should not access it. */ 1154 code or modules should not access it. */
1156 Funintern (Qmodule_refs_hash, Qnil); 1155 Funintern (Qmodule_refs_hash, Qnil);
1157 1156
1157 DEFSYM (Qsave_value_p, "save-value-p");
1158 DEFSYM (Qsave_pointer_p, "save-pointer-p");
1159
1158 defsubr (&Smodule_load); 1160 defsubr (&Smodule_load);
1159 1161
1160 /* Don't call defsubr on `module-call' because that would intern it, 1162 DEFSYM (Qinternal_module_call, "internal--module-call");
1161 but `module-call' is an internal function that users cannot 1163 defsubr (&Sinternal_module_call);
1162 meaningfully use. Instead, assign its definition to a private
1163 variable. */
1164 XSETPVECTYPE (&Smodule_call, PVEC_SUBR);
1165 XSETSUBR (module_call_func, &Smodule_call);
1166} 1164}
1167 1165
1168/* Unlike syms_of_module, this initializer is called even from an 1166/* Unlike syms_of_module, this initializer is called even from an