aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2017-05-21 22:33:50 +0200
committerPhilipp Stephani2017-05-21 22:33:50 +0200
commitb69f6a779a65f1f3e0963d6fd280ae95970f5325 (patch)
tree5400801f98ecda21d616191c454b23edece6a9a3 /src
parent6f1f88224c62dfb7b311dc1a57db267d118cae5c (diff)
downloademacs-b69f6a779a65f1f3e0963d6fd280ae95970f5325.tar.gz
emacs-b69f6a779a65f1f3e0963d6fd280ae95970f5325.zip
Improve module function terminology
Module functions were previously called "function environments" when the functions created by module_make_functions were lambdas. Now we can adapt the terminology and rename "function environments" to "module functions" everywhere. This also removes the name clash between "function environments" and "module environments." * src/emacs-module.c (module_make_function): Adapt comment to reality; stop using "function environment" terminology. (funcall_module): Stop using "function environment" terminology.
Diffstat (limited to 'src')
-rw-r--r--src/emacs-module.c40
-rw-r--r--src/lisp.h4
2 files changed, 20 insertions, 24 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 5ab69135952..33c5fbd484b 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -342,12 +342,8 @@ module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value)
342 value_to_lisp (value)); 342 value_to_lisp (value));
343} 343}
344 344
345/* A module function is lambda function that calls 345/* A module function is a pseudovector of subtype type
346 `internal--module-call', passing the function pointer of the module 346 PVEC_MODULE_FUNCTION; see lisp.h for the definition. */
347 function along with the module emacs_env pointer as arguments.
348
349 (function (lambda (&rest arglist)
350 (internal--module-call envobj arglist))) */
351 347
352static emacs_value 348static emacs_value
353module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, 349module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity,
@@ -363,24 +359,24 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity,
363 : min_arity <= max_arity && max_arity <= MOST_POSITIVE_FIXNUM))) 359 : min_arity <= max_arity && max_arity <= MOST_POSITIVE_FIXNUM)))
364 xsignal2 (Qinvalid_arity, make_number (min_arity), make_number (max_arity)); 360 xsignal2 (Qinvalid_arity, make_number (min_arity), make_number (max_arity));
365 361
366 struct Lisp_Module_Function *envptr = allocate_module_function (); 362 struct Lisp_Module_Function *function = allocate_module_function ();
367 envptr->min_arity = min_arity; 363 function->min_arity = min_arity;
368 envptr->max_arity = max_arity; 364 function->max_arity = max_arity;
369 envptr->subr = subr; 365 function->subr = subr;
370 envptr->data = data; 366 function->data = data;
371 367
372 if (documentation) 368 if (documentation)
373 { 369 {
374 AUTO_STRING (unibyte_doc, documentation); 370 AUTO_STRING (unibyte_doc, documentation);
375 envptr->documentation = 371 function->documentation =
376 code_convert_string_norecord (unibyte_doc, Qutf_8, false); 372 code_convert_string_norecord (unibyte_doc, Qutf_8, false);
377 } 373 }
378 374
379 Lisp_Object envobj; 375 Lisp_Object result;
380 XSET_MODULE_FUNCTION (envobj, envptr); 376 XSET_MODULE_FUNCTION (result, function);
381 eassert (MODULE_FUNCTIONP (envobj)); 377 eassert (MODULE_FUNCTIONP (result));
382 378
383 return lisp_to_value (envobj); 379 return lisp_to_value (result);
384} 380}
385 381
386static emacs_value 382static emacs_value
@@ -644,13 +640,13 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
644} 640}
645 641
646Lisp_Object 642Lisp_Object
647funcall_module (const struct Lisp_Module_Function *const envptr, 643funcall_module (const struct Lisp_Module_Function *const function,
648 ptrdiff_t nargs, Lisp_Object *arglist) 644 ptrdiff_t nargs, Lisp_Object *arglist)
649{ 645{
650 eassume (0 <= envptr->min_arity); 646 eassume (0 <= function->min_arity);
651 if (! (envptr->min_arity <= nargs 647 if (! (function->min_arity <= nargs
652 && (envptr->max_arity < 0 || nargs <= envptr->max_arity))) 648 && (function->max_arity < 0 || nargs <= function->max_arity)))
653 xsignal2 (Qwrong_number_of_arguments, module_format_fun_env (envptr), 649 xsignal2 (Qwrong_number_of_arguments, module_format_fun_env (function),
654 make_number (nargs)); 650 make_number (nargs));
655 651
656 emacs_env pub; 652 emacs_env pub;
@@ -668,7 +664,7 @@ funcall_module (const struct Lisp_Module_Function *const envptr,
668 args[i] = lisp_to_value (arglist[i]); 664 args[i] = lisp_to_value (arglist[i]);
669 } 665 }
670 666
671 emacs_value ret = envptr->subr (&pub, nargs, args, envptr->data); 667 emacs_value ret = function->subr (&pub, nargs, args, function->data);
672 SAFE_FREE (); 668 SAFE_FREE ();
673 669
674 eassert (&priv == pub.private_members); 670 eassert (&priv == pub.private_members);
diff --git a/src/lisp.h b/src/lisp.h
index f423a66d5a8..7290386b255 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3901,9 +3901,9 @@ extern void unexec_free (void *);
3901typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t, 3901typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
3902 emacs_value [], void *); 3902 emacs_value [], void *);
3903 3903
3904/* Function environments. */ 3904/* Module function. */
3905 3905
3906/* A function environment is an auxiliary structure used by 3906/* A function environment is an auxiliary structure returned by
3907 `module_make_function' to store information about a module 3907 `module_make_function' to store information about a module
3908 function. It is stored in a pseudovector. Its members correspond 3908 function. It is stored in a pseudovector. Its members correspond
3909 to the arguments given to `module_make_function'. */ 3909 to the arguments given to `module_make_function'. */