diff options
author | Philipp Stephani <phst@google.com> | 2019-04-18 22:38:29 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2019-04-24 12:53:54 +0200 |
commit | e290a7d1730c99010272bbff7f497c3041cef46d (patch) | |
tree | d17ccf1313e8b408c6e8cbef64e71a4f1311da4e /doc/lispref/internals.texi | |
parent | bffceab6339fb4042588b893ef754c6264379e75 (diff) | |
download | emacs-e290a7d1730c99010272bbff7f497c3041cef46d.tar.gz |
Add module functions to convert from and to big integers.
* 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.
Diffstat (limited to 'doc/lispref/internals.texi')
-rw-r--r-- | doc/lispref/internals.texi | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 0e7a1339e76..10f49c569fa 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -1508,6 +1508,41 @@ function raises the @code{overflow-error} error condition if string. @end deftypefn +If you define the preprocessor macro @code{EMACS_MODULE_GMP} before +including the header @file{emacs-module.h}, you can also convert +between Emacs integers and GMP @code{mpz_t} values. @xref{GMP +Basics,,,gmp}. If @code{EMACS_MODULE_GMP} is defined, +@file{emacs-module.h} wraps @code{mpz_t} in the following structure: + +@deftp struct emacs_mpz value +struct emacs_mpz @{ mpz_t value; @}; +@end deftp + +@noindent +Then you can use the following additional functions: + +@deftypefn Function bool extract_big_integer (emacs_env *@var{env}, emacs_value @var{arg}, struct emacs_mpz *@var{result}) +This function, which is available since Emacs 27, extracts the +integral value of @var{arg} into @var{result}. @var{result} must not +be @code{NULL}. @code{@var{result}->value} must be an initialized +@code{mpz_t} object. @xref{Initializing Integers,,,gmp}. If +@var{arg} is an integer, Emacs will store its value into +@code{@var{result}->value}. After you have finished using +@code{@var{result}->value}, you should free it using @code{mpz_clear} +or similar. +@end deftypefn + +@deftypefn Function emacs_value make_big_integer (emacs_env *@var{env}, const struct emacs_mpz *@var{value}) +This function, which is available since Emacs 27, takes an +arbitrary-sized integer argument and returns a corresponding +@code{emacs_value} object. @var{value} must not be @code{NULL}. +@code{@var{value}->value} must be an initialized @code{mpz_t} object. +@xref{Initializing Integers,,,gmp}. Emacs will return a corresponding +integral object. After you have finished using +@code{@var{value}->value}, you should free it using @code{mpz_clear} +or similar. +@end deftypefn + The @acronym{API} does not provide functions to manipulate Lisp data structures, for example, create lists with @code{cons} and @code{list} (@pxref{Building Lists}), extract list members with @code{car} and |