diff options
| author | Philipp Stephani | 2019-04-18 22:38:29 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2019-04-24 12:53:54 +0200 |
| commit | e290a7d1730c99010272bbff7f497c3041cef46d (patch) | |
| tree | d17ccf1313e8b408c6e8cbef64e71a4f1311da4e /doc | |
| parent | bffceab6339fb4042588b893ef754c6264379e75 (diff) | |
| download | emacs-e290a7d1730c99010272bbff7f497c3041cef46d.tar.gz emacs-e290a7d1730c99010272bbff7f497c3041cef46d.zip | |
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')
| -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 | |||
| 1508 | string. | 1508 | string. |
| 1509 | @end deftypefn | 1509 | @end deftypefn |
| 1510 | 1510 | ||
| 1511 | If you define the preprocessor macro @code{EMACS_MODULE_GMP} before | ||
| 1512 | including the header @file{emacs-module.h}, you can also convert | ||
| 1513 | between Emacs integers and GMP @code{mpz_t} values. @xref{GMP | ||
| 1514 | Basics,,,gmp}. If @code{EMACS_MODULE_GMP} is defined, | ||
| 1515 | @file{emacs-module.h} wraps @code{mpz_t} in the following structure: | ||
| 1516 | |||
| 1517 | @deftp struct emacs_mpz value | ||
| 1518 | struct emacs_mpz @{ mpz_t value; @}; | ||
| 1519 | @end deftp | ||
| 1520 | |||
| 1521 | @noindent | ||
| 1522 | Then you can use the following additional functions: | ||
| 1523 | |||
| 1524 | @deftypefn Function bool extract_big_integer (emacs_env *@var{env}, emacs_value @var{arg}, struct emacs_mpz *@var{result}) | ||
| 1525 | This function, which is available since Emacs 27, extracts the | ||
| 1526 | integral value of @var{arg} into @var{result}. @var{result} must not | ||
| 1527 | be @code{NULL}. @code{@var{result}->value} must be an initialized | ||
| 1528 | @code{mpz_t} object. @xref{Initializing Integers,,,gmp}. If | ||
| 1529 | @var{arg} is an integer, Emacs will store its value into | ||
| 1530 | @code{@var{result}->value}. After you have finished using | ||
| 1531 | @code{@var{result}->value}, you should free it using @code{mpz_clear} | ||
| 1532 | or similar. | ||
| 1533 | @end deftypefn | ||
| 1534 | |||
| 1535 | @deftypefn Function emacs_value make_big_integer (emacs_env *@var{env}, const struct emacs_mpz *@var{value}) | ||
| 1536 | This function, which is available since Emacs 27, takes an | ||
| 1537 | arbitrary-sized integer argument and returns a corresponding | ||
| 1538 | @code{emacs_value} object. @var{value} must not be @code{NULL}. | ||
| 1539 | @code{@var{value}->value} must be an initialized @code{mpz_t} object. | ||
| 1540 | @xref{Initializing Integers,,,gmp}. Emacs will return a corresponding | ||
| 1541 | integral object. After you have finished using | ||
| 1542 | @code{@var{value}->value}, you should free it using @code{mpz_clear} | ||
| 1543 | or similar. | ||
| 1544 | @end deftypefn | ||
| 1545 | |||
| 1511 | The @acronym{API} does not provide functions to manipulate Lisp data | 1546 | The @acronym{API} does not provide functions to manipulate Lisp data |
| 1512 | structures, for example, create lists with @code{cons} and @code{list} | 1547 | structures, for example, create lists with @code{cons} and @code{list} |
| 1513 | (@pxref{Building Lists}), extract list members with @code{car} and | 1548 | (@pxref{Building Lists}), extract list members with @code{car} and |