From fc92c2d8942cf466aa6dbc422f2e798801b18408 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sun, 5 Jan 2020 16:05:14 +0100 Subject: Also print function data when printing module functions. This is especially useful in cases where modules only use a single entry point and use the data to dispatch to the actual function. Such a design is common for languages such as Go and C++. * src/emacs-module.c (module_function_data): New function. * src/print.c (print_vectorlike): Use it to print module function data if not NULL. (print_object): Adapt size of buffer. * test/data/emacs-module/mod-test.c (emacs_module_init): Pass some non-NULL data to ‘mod-test-sum’. (Fmod_test_sum): Check that correct data is passed through. * test/src/emacs-module-tests.el (mod-test-sum-test) (module-function-object): Adapt unit tests. --- test/data/emacs-module/mod-test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/data') diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c index 1a0a879a1bc..ec6948921f2 100644 --- a/test/data/emacs-module/mod-test.c +++ b/test/data/emacs-module/mod-test.c @@ -24,6 +24,7 @@ along with GNU Emacs. If not, see . */ #include #include +#include #include #include #include @@ -86,6 +87,7 @@ static emacs_value Fmod_test_sum (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data) { assert (nargs == 2); + assert ((uintptr_t) data == 0x1234); intmax_t a = env->extract_integer (env, args[0]); intmax_t b = env->extract_integer (env, args[1]); @@ -587,7 +589,8 @@ emacs_module_init (struct emacs_runtime *ert) env->make_function (env, amin, amax, csym, doc, data)) DEFUN ("mod-test-return-t", Fmod_test_return_t, 1, 1, NULL, NULL); - DEFUN ("mod-test-sum", Fmod_test_sum, 2, 2, "Return A + B\n\n(fn a b)", NULL); + DEFUN ("mod-test-sum", Fmod_test_sum, 2, 2, "Return A + B\n\n(fn a b)", + (void *) (uintptr_t) 0x1234); DEFUN ("mod-test-signal", Fmod_test_signal, 0, 0, NULL, NULL); DEFUN ("mod-test-throw", Fmod_test_throw, 0, 0, NULL, NULL); DEFUN ("mod-test-non-local-exit-funcall", Fmod_test_non_local_exit_funcall, -- cgit v1.2.1