aboutsummaryrefslogtreecommitdiffstats
path: root/src/emacs-module.h.in (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Improve nonnull checking with GCC in emacs-modulePaul Eggert2020-05-091-6/+10
| | | | | | * src/emacs-module.h.in (EMACS_ATTRIBUTE_NONNULL): Also do the nonnull check with GCC. (The old code did the check with Clang but not with GCC.)
* Improve 'noexcept' support in C++17.Philipp Stephani2020-01-041-2/+8
| | | | | | | | | In C++17, 'noexcept' is part of a function type and may be used in typedef declarations, see https://en.cppreference.com/w/cpp/language/noexcept_spec. * src/emacs-module.h.in: Mark function pointer type aliases as 'noexcept' in C++17.
* emacs-module.h: Don't generate invalid C++11 code.Philipp Stephani2020-01-041-2/+2
| | | | | | * src/emacs-module.h.in: Remove 'noexcept' from function pointer type aliases. It is illegal there in C++11, see https://en.cppreference.com/w/cpp/language/noexcept_spec.
* Implement finalizers for module functions (Bug#30373)Philipp Stephani2020-01-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/module-env-28.h: Add new module environment functions to module environment for Emacs 28. * src/emacs-module.h.in: Document that 'emacs_finalizer' also works for function finalizers. * src/emacs-module.c (CHECK_MODULE_FUNCTION): New function. (struct Lisp_Module_Function): Add finalizer data member. (module_make_function): Initialize finalizer. (module_get_function_finalizer) (module_set_function_finalizer): New module environment functions. (module_finalize_function): New function. (initialize_environment): Initialize new environment functions. * src/alloc.c (cleanup_vector): Call potential module function finalizer during garbage collection. * test/data/emacs-module/mod-test.c (signal_error): New helper function. (memory_full): Use it. (finalizer): New example function finalizer. (Fmod_test_make_function_with_finalizer) (Fmod_test_function_finalizer_calls): New test module functions. (emacs_module_init): Define them. * test/src/emacs-module-tests.el (module/function-finalizer): New unit test. * doc/lispref/internals.texi (Module Functions): Document new functionality. (Module Misc): Move description of 'emacs_finalizer' type to 'Module Functions' node, and add a reference to it. * etc/NEWS: Mention new functionality.
* Merge from origin/emacs-27Paul Eggert2020-01-011-1/+1
|\ | | | | | | | | | | | | | | | | | | | | 186152ba40 Pacify gcc -Wunused-function on Ubuntu 18.04.3 4cd143aded Fix copyright years by hand 365e01cc9f Update copyright year to 2020 cd2c156163 ; * etc/NEWS: Make the description of XDG fallback more ac... # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex
| * Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | | | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* | Promote function type aliases to the public module API.Philipp Stephani2019-12-261-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously module authors had to define type aliases for module functions and finalizers themselves. This commit adds and documents aliases so that this is no longer necessary. * src/emacs-module.h.in: Add 'emacs_function' and 'emacs_finalizer' type aliases. * src/emacs-module.c: Remove old 'emacs_subr' and 'emacs_finalizer' type aliases. (struct Lisp_Module_Function, module_make_function): Switch from 'emacs_subr' to 'emacs_function'. * doc/lispref/internals.texi (Module Functions): Document and use 'emacs_function' type alias. (Module Values): Document 'emacs_finalizer' type alias. * etc/NEWS: Mention change.
* | Merge from origin/emacs-27Glenn Morris2019-12-251-0/+6
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | ca6a53d3bc Don't default to showing X-Faces externally in Gnus dbf4b5b2d0 Fix manual typo in Special Read Syntax a9fe6dfa90 Fix problem with emacs -nw / eww / svg 0de63092c8 Clarify base64 requirements and say what {en,de}code_codin... 6184aa003f ; * etc/NEWS: Fix boring oddities. 51ea32dd12 * src/emacs-module.h.in: Add reference to manual. 75d0cef20d Trivial docstring fixes ee12c421b6 imagemagick-types needs to initialize ImageMagick # Conflicts: # etc/NEWS
| * * src/emacs-module.h.in: Add reference to manual.Philipp Stephani2019-12-241-0/+6
| |
* | Prepare module header generation for Emacs 28.Philipp Stephani2019-12-241-0/+11
| | | | | | | | | | | | | | | | * configure.ac: Substitute environment function snippet for Emacs 28. * src/module-env-28.h: New file, with dummy contents for now. * src/emacs-module.h.in: Provide emacs_env_28 structure.
* | * src/emacs-module.h.in: Use @emacs_major_version@ for current env.Philipp Stephani2019-12-241-1/+1
| |
* | Make argument names in module interface more consistent.Philipp Stephani2019-12-231-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | Previously, the names of arguments and other details were needlessly inconsistent between the documentation, the declarations, and the definitions, as well as between each other. This commit makes them more consistent, in most cases by applying the names from the documentation everywhere. * src/module-env-27.h: * src/module-env-25.h: * src/emacs-module.h.in: * src/emacs-module.c (module_get_environment) (module_make_global_ref, module_free_global_ref) (module_non_local_exit_get, module_non_local_exit_signal) (module_make_function, module_funcall, module_type_of) (module_is_not_nil, module_extract_integer) (module_extract_float, module_copy_string_contents) (module_make_string, module_vec_set, module_vec_get) (module_vec_size, module_extract_time) (module_assert_runtime): * doc/lispref/internals.texi (Module Initialization) (Module Functions, Module Values): Make argument names and some other details consistent. No functional changes.
* ; * src/emacs-module.h.in: Sort includes alphabetically.Philipp Stephani2019-12-131-1/+1
|
* Just use size_t for emacs_limb_tPaul Eggert2019-12-101-17/+7
| | | | | * src/emacs-module.h.in: Do not include limits.h; no longer needed. (emacs_limb_t, EMACS_LIMB_MAX): Now size_t and SIZE_MAX.
* Change module interface to no longer use GMP objects directly.Philipp Stephani2019-12-041-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in the new comment added to emacs-module.c, using GMP directly in the module interface has significant downsides: it couples the module interface directly to the implementation and requires module authors to link their module against the same GMP library as Emacs itself, which is often difficult and an unnecessary burden. By picking a representation for the magnitude that often matches the one used by GMP, we can avoid overhead when converting from and to GMP in most cases. Loading the test module in test/data/emacs-module and evaluating (dotimes (_ 10000) (mod-test-double (* 2 most-negative-fixnum))) under Callgrind shows that on my (GNU/Linux) machine Emacs only spends 10% of the CPU time of mod-test-double in mpz_import and mpz_export combined, even though that function does little else. (By contrast, 30% is spent in allocate_pseudovector.) * src/emacs-module.h.in: Don't check EMACS_MODULE_GMP. Don't include gmp.h. Remove emacs_mpz structure. Instead, define type alias emacs_limb_t and macro EMACS_LIMB_MAX. * src/module-env-27.h: Change interface of extract_big_integer and make_big_integer to take a sign-magnitude representation instead of mpz_t. * src/emacs-module.c: Don't check EMACS_MODULE_GMP or EMACS_MODULE_HAVE_MPZ_T. Add a comment about the chosen implementation. (module_extract_big_integer, module_make_big_integer): Reimplement without using mpz_t in the interface. * doc/lispref/internals.texi (Module Values): Adapt function documentation and example. Stop mentioning GMP and EMACS_MODULE_GMP. * test/data/emacs-module/mod-test.c: Don't define EMACS_MODULE_GMP or EMACS_MODULE_HAVE_MPZ_T. (memory_full, extract_big_integer, make_big_integer): New helper functions, identical to example in the Info documentation. (Fmod_test_nanoseconds, Fmod_test_double): Adapt to new interface.
* Export major version of latest Emacs supported by emacs-module.h.Philipp Stephani2019-04-281-0/+2
| | | | | | | | | | | | | | | This is useful if module authors want to support multiple versions of emacs-module.h. * configure.ac (emacs_major_version): Define substitution. * src/emacs-module.h.in (EMACS_MAJOR_VERSION): Define macro. * doc/lispref/internals.texi (Module Initialization): Document EMACS_MAJOR_VERSION preprocessor macro. * test/data/emacs-module/mod-test.c (emacs_module_init): Verify behavior of EMACS_MAJOR_VERSION.
* Unbreak build when building without GMP support.Philipp Stephani2019-04-241-1/+1
| | | | | | | | | | | | | | | | | | | | | Add support for a new preprocessor macro EMACS_MODULE_HAVE_MPZ_T to emacs-module.h. If this macro is defined, assume that mpz_t is already defined and don’t include gmp.h. Don’t document the new macro for now, as it’s unclear whether we want to support this in modules outside the Emacs tree. * src/emacs-module.h.in: Allow user to prevent inclusion of gmp.h. * src/emacs-module.c: Use mini-gmp if GMP is unavailable. Don’t include gmp.h. * src/lisp.h: Don’t require gmp.h. It’s not needed for lisp.h. * test/Makefile.in (GMP_LIB, GMP_OBJ): New variables. ($(test_module)): Use them. * test/data/emacs-module/mod-test.c: Use mini-gmp if GMP is unavailable.
* Add module functions to convert from and to big integers.Philipp Stephani2019-04-241-0/+10
| | | | | | | | | | | | | | | | | | | * src/module-env-27.h: Add new module functions to convert big integers. * src/emacs-module.h.in (emacs_mpz): Define if GMP is available. * src/emacs-module.c (module_extract_big_integer) (module_make_big_integer): New functions. (initialize_environment): Use them. * test/data/emacs-module/mod-test.c (Fmod_test_double): New test function. (emacs_module_init): Define it. * test/src/emacs-module-tests.el (mod-test-double): New unit test. * doc/lispref/internals.texi (Module Values): Document new functions.
* Add conversions to and from struct timespec to module interface.Philipp Stephani2019-04-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Time values are a fundamental data type, and such conversions are hard to implement within modules because of the various forms of time values in Emacs Lisp. Adding dedicated conversion functions can significantly simplify module code dealing with times. This approach uses nanosecond precision. While Emacs in theory has support for higher-precision time values, in practice most languages and standards, such as POSIX, C, Java, and Go, have settled on nanosecond-precision integers to represent time. * src/emacs-module.h.in: Add header for struct timespec. * src/module-env-27.h: Add module functions for time conversion. * src/emacs-module.c (module_extract_time, module_make_time): New functions. (initialize_environment): Use them. * test/data/emacs-module/mod-test.c (Fmod_test_add_nanosecond): New test function. (emacs_module_init): Define it. * test/src/emacs-module-tests.el (mod-test-add-nanosecond/valid) (mod-test-add-nanosecond/nil, mod-test-add-nanosecond/invalid): New unit tests. * doc/lispref/internals.texi (Module Values): Document time conversion functions.
* Ignore pending_signals when checking for quits.Philipp Stephani2019-02-241-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pending_signals is often set if no quit is pending. This results in bugs in module code if the module returns but no quit is actually pending. As a better alternative, add a new process_input environment function for Emacs 27. That function processes signals (like maybe_quit). * configure.ac: Add module snippet for Emacs 27. * src/module-env-27.h: New file. * src/emacs-module.h.in: Add process_input function to environment interface. * src/emacs-module.c (module_should_quit): Use QUITP macro to check whether the caller should quit. (module_process_input): New function. (initialize_environment): Use it. * src/eval.c: Remove obsolete comment. * test/data/emacs-module/mod-test.c (signal_wrong_type_argument) (signal_errno): New helper functions. (Fmod_test_sleep_until): New test module function. * test/src/emacs-module-tests.el (mod-test-sleep-until): New unit test. * doc/lispref/internals.texi (Module Misc): Document process_input.
* Update copyright year to 2019Paul Eggert2019-01-011-1/+1
| | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
* Update copyright year to 2018Paul Eggert2018-01-011-1/+1
| | | | Run admin/update-copyright.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-1/+1
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Also mark module init function as noexcept if possiblePhilipp Stephani2017-07-011-0/+1
| | | | | * src/emacs-module.h.in (emacs_module_init): Mark as noexcept if possible.
* Improve C++98 compatibilityPhilipp Stephani2017-07-011-1/+1
| | | | | * src/emacs-module.h.in (emacs_funcall_exit): Lose trailing comma. C++98 doesn't allow trailing commas in enumerations.
* emacs-module.h: Create emacs_env_26Philipp Stephani2017-06-171-0/+106
This was part of the original design of the module API (https://lists.gnu.org/archive/html/emacs-devel/2015-02/msg00960.html), but I didn't take it into account when adding the should_quit function. Instead of duplicating the environment fields or using the C preprocessor, use configure to build emacs-module.h. * configure.ac: Expand emacs-module.h template.