Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/emacs-module.h
$ cat -n /usr/include/emacs-module.h 1 /* emacs-module.h - GNU Emacs module API. 2 3 Copyright (C) 2015-2024 Free Software Foundation, Inc. 4 5 This file is part of GNU Emacs. 6 7 GNU Emacs is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or (at 10 your option) any later version. 11 12 GNU Emacs is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GNU Emacs. If not, see
. */ 19 20 /* 21 This file defines the Emacs module API. Please see the chapter 22 `Dynamic Modules' in the GNU Emacs Lisp Reference Manual for 23 information how to write modules and use this header file. 24 */ 25 26 #ifndef EMACS_MODULE_H 27 #define EMACS_MODULE_H 28 29 #include
30 #include
31 #include
32 33 #if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \ 34 && !defined __bool_true_false_are_defined && !defined __cplusplus) 35 #include
36 #endif 37 38 #define EMACS_MAJOR_VERSION 29 39 40 #if defined __cplusplus && __cplusplus >= 201103L 41 # define EMACS_NOEXCEPT noexcept 42 #else 43 # define EMACS_NOEXCEPT 44 #endif 45 46 #if defined __cplusplus && __cplusplus >= 201703L 47 # define EMACS_NOEXCEPT_TYPEDEF noexcept 48 #else 49 # define EMACS_NOEXCEPT_TYPEDEF 50 #endif 51 52 #if 3 < __GNUC__ + (3 <= __GNUC_MINOR__) 53 # define EMACS_ATTRIBUTE_NONNULL(...) \ 54 __attribute__ ((__nonnull__ (__VA_ARGS__))) 55 #elif (defined __has_attribute \ 56 && (!defined __clang_minor__ \ 57 || 3 < __clang_major__ + (5 <= __clang_minor__))) 58 # if __has_attribute (__nonnull__) 59 # define EMACS_ATTRIBUTE_NONNULL(...) \ 60 __attribute__ ((__nonnull__ (__VA_ARGS__))) 61 # endif 62 #endif 63 #ifndef EMACS_ATTRIBUTE_NONNULL 64 # define EMACS_ATTRIBUTE_NONNULL(...) 65 #endif 66 67 #ifdef __cplusplus 68 extern "C" { 69 #endif 70 71 /* Current environment. */ 72 typedef struct emacs_env_29 emacs_env; 73 74 /* Opaque pointer representing an Emacs Lisp value. 75 BEWARE: Do not assume NULL is a valid value! */ 76 typedef struct emacs_value_tag *emacs_value; 77 78 enum { emacs_variadic_function = -2 }; 79 80 /* Struct passed to a module init function (emacs_module_init). */ 81 struct emacs_runtime 82 { 83 /* Structure size (for version checking). */ 84 ptrdiff_t size; 85 86 /* Private data; users should not touch this. */ 87 struct emacs_runtime_private *private_members; 88 89 /* Return an environment pointer. */ 90 emacs_env *(*get_environment) (struct emacs_runtime *runtime) 91 EMACS_ATTRIBUTE_NONNULL (1); 92 }; 93 94 /* Type aliases for function pointer types used in the module API. 95 Note that we don't use these aliases directly in the API to be able 96 to mark the function arguments as 'noexcept' before C++20. 97 However, users can use them if they want. */ 98 99 /* Function prototype for the module Lisp functions. These must not 100 throw C++ exceptions. */ 101 typedef emacs_value (*emacs_function) (emacs_env *env, ptrdiff_t nargs, 102 emacs_value *args, 103 void *data) 104 EMACS_NOEXCEPT_TYPEDEF EMACS_ATTRIBUTE_NONNULL (1); 105 106 /* Function prototype for module user-pointer and function finalizers. 107 These must not throw C++ exceptions. */ 108 typedef void (*emacs_finalizer) (void *data) EMACS_NOEXCEPT_TYPEDEF; 109 110 /* Possible Emacs function call outcomes. */ 111 enum emacs_funcall_exit 112 { 113 /* Function has returned normally. */ 114 emacs_funcall_exit_return = 0, 115 116 /* Function has signaled an error using `signal'. */ 117 emacs_funcall_exit_signal = 1, 118 119 /* Function has exited using `throw'. */ 120 emacs_funcall_exit_throw = 2 121 }; 122 123 /* Possible return values for emacs_env.process_input. */ 124 enum emacs_process_input_result 125 { 126 /* Module code may continue */ 127 emacs_process_input_continue = 0, 128 129 /* Module code should return control to Emacs as soon as possible. */ 130 emacs_process_input_quit = 1 131 }; 132 133 /* Define emacs_limb_t so that it is likely to match GMP's mp_limb_t. 134 This micro-optimization can help modules that use mpz_export and 135 mpz_import, which operate more efficiently on mp_limb_t. It's OK 136 (if perhaps a bit slower) if the two types do not match, and 137 modules shouldn't rely on the two types matching. */ 138 typedef size_t emacs_limb_t; 139 #define EMACS_LIMB_MAX SIZE_MAX 140 141 struct emacs_env_25 142 { 143 /* Structure size (for version checking). */ 144 ptrdiff_t size; 145 146 /* Private data; users should not touch this. */ 147 struct emacs_env_private *private_members; 148 149 /* Memory management. */ 150 151 emacs_value (*make_global_ref) (emacs_env *env, emacs_value value) 152 EMACS_ATTRIBUTE_NONNULL(1); 153 154 void (*free_global_ref) (emacs_env *env, emacs_value global_value) 155 EMACS_ATTRIBUTE_NONNULL(1); 156 157 /* Non-local exit handling. */ 158 159 enum emacs_funcall_exit (*non_local_exit_check) (emacs_env *env) 160 EMACS_ATTRIBUTE_NONNULL(1); 161 162 void (*non_local_exit_clear) (emacs_env *env) 163 EMACS_ATTRIBUTE_NONNULL(1); 164 165 enum emacs_funcall_exit (*non_local_exit_get) 166 (emacs_env *env, emacs_value *symbol, emacs_value *data) 167 EMACS_ATTRIBUTE_NONNULL(1, 2, 3); 168 169 void (*non_local_exit_signal) (emacs_env *env, 170 emacs_value symbol, emacs_value data) 171 EMACS_ATTRIBUTE_NONNULL(1); 172 173 void (*non_local_exit_throw) (emacs_env *env, 174 emacs_value tag, emacs_value value) 175 EMACS_ATTRIBUTE_NONNULL(1); 176 177 /* Function registration. */ 178 179 emacs_value (*make_function) (emacs_env *env, 180 ptrdiff_t min_arity, 181 ptrdiff_t max_arity, 182 emacs_value (*func) (emacs_env *env, 183 ptrdiff_t nargs, 184 emacs_value* args, 185 void *data) 186 EMACS_NOEXCEPT 187 EMACS_ATTRIBUTE_NONNULL(1), 188 const char *docstring, 189 void *data) 190 EMACS_ATTRIBUTE_NONNULL(1, 4); 191 192 emacs_value (*funcall) (emacs_env *env, 193 emacs_value func, 194 ptrdiff_t nargs, 195 emacs_value* args) 196 EMACS_ATTRIBUTE_NONNULL(1); 197 198 emacs_value (*intern) (emacs_env *env, const char *name) 199 EMACS_ATTRIBUTE_NONNULL(1, 2); 200 201 /* Type conversion. */ 202 203 emacs_value (*type_of) (emacs_env *env, emacs_value arg) 204 EMACS_ATTRIBUTE_NONNULL(1); 205 206 bool (*is_not_nil) (emacs_env *env, emacs_value arg) 207 EMACS_ATTRIBUTE_NONNULL(1); 208 209 bool (*eq) (emacs_env *env, emacs_value a, emacs_value b) 210 EMACS_ATTRIBUTE_NONNULL(1); 211 212 intmax_t (*extract_integer) (emacs_env *env, emacs_value arg) 213 EMACS_ATTRIBUTE_NONNULL(1); 214 215 emacs_value (*make_integer) (emacs_env *env, intmax_t n) 216 EMACS_ATTRIBUTE_NONNULL(1); 217 218 double (*extract_float) (emacs_env *env, emacs_value arg) 219 EMACS_ATTRIBUTE_NONNULL(1); 220 221 emacs_value (*make_float) (emacs_env *env, double d) 222 EMACS_ATTRIBUTE_NONNULL(1); 223 224 /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 225 null-terminated string. 226 227 SIZE must point to the total size of the buffer. If BUFFER is 228 NULL or if SIZE is not big enough, write the required buffer size 229 to SIZE and return true. 230 231 Note that SIZE must include the last null byte (e.g. "abc" needs 232 a buffer of size 4). 233 234 Return true if the string was successfully copied. */ 235 236 bool (*copy_string_contents) (emacs_env *env, 237 emacs_value value, 238 char *buf, 239 ptrdiff_t *len) 240 EMACS_ATTRIBUTE_NONNULL(1, 4); 241 242 /* Create a Lisp string from a utf8 encoded string. */ 243 emacs_value (*make_string) (emacs_env *env, 244 const char *str, ptrdiff_t len) 245 EMACS_ATTRIBUTE_NONNULL(1, 2); 246 247 /* Embedded pointer type. */ 248 emacs_value (*make_user_ptr) (emacs_env *env, 249 void (*fin) (void *) EMACS_NOEXCEPT, 250 void *ptr) 251 EMACS_ATTRIBUTE_NONNULL(1); 252 253 void *(*get_user_ptr) (emacs_env *env, emacs_value arg) 254 EMACS_ATTRIBUTE_NONNULL(1); 255 void (*set_user_ptr) (emacs_env *env, emacs_value arg, void *ptr) 256 EMACS_ATTRIBUTE_NONNULL(1); 257 258 void (*(*get_user_finalizer) (emacs_env *env, emacs_value uptr)) 259 (void *) EMACS_NOEXCEPT EMACS_ATTRIBUTE_NONNULL(1); 260 void (*set_user_finalizer) (emacs_env *env, emacs_value arg, 261 void (*fin) (void *) EMACS_NOEXCEPT) 262 EMACS_ATTRIBUTE_NONNULL(1); 263 264 /* Vector functions. */ 265 emacs_value (*vec_get) (emacs_env *env, emacs_value vector, ptrdiff_t index) 266 EMACS_ATTRIBUTE_NONNULL(1); 267 268 void (*vec_set) (emacs_env *env, emacs_value vector, ptrdiff_t index, 269 emacs_value value) 270 EMACS_ATTRIBUTE_NONNULL(1); 271 272 ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vector) 273 EMACS_ATTRIBUTE_NONNULL(1); 274 }; 275 276 struct emacs_env_26 277 { 278 /* Structure size (for version checking). */ 279 ptrdiff_t size; 280 281 /* Private data; users should not touch this. */ 282 struct emacs_env_private *private_members; 283 284 /* Memory management. */ 285 286 emacs_value (*make_global_ref) (emacs_env *env, emacs_value value) 287 EMACS_ATTRIBUTE_NONNULL(1); 288 289 void (*free_global_ref) (emacs_env *env, emacs_value global_value) 290 EMACS_ATTRIBUTE_NONNULL(1); 291 292 /* Non-local exit handling. */ 293 294 enum emacs_funcall_exit (*non_local_exit_check) (emacs_env *env) 295 EMACS_ATTRIBUTE_NONNULL(1); 296 297 void (*non_local_exit_clear) (emacs_env *env) 298 EMACS_ATTRIBUTE_NONNULL(1); 299 300 enum emacs_funcall_exit (*non_local_exit_get) 301 (emacs_env *env, emacs_value *symbol, emacs_value *data) 302 EMACS_ATTRIBUTE_NONNULL(1, 2, 3); 303 304 void (*non_local_exit_signal) (emacs_env *env, 305 emacs_value symbol, emacs_value data) 306 EMACS_ATTRIBUTE_NONNULL(1); 307 308 void (*non_local_exit_throw) (emacs_env *env, 309 emacs_value tag, emacs_value value) 310 EMACS_ATTRIBUTE_NONNULL(1); 311 312 /* Function registration. */ 313 314 emacs_value (*make_function) (emacs_env *env, 315 ptrdiff_t min_arity, 316 ptrdiff_t max_arity, 317 emacs_value (*func) (emacs_env *env, 318 ptrdiff_t nargs, 319 emacs_value* args, 320 void *data) 321 EMACS_NOEXCEPT 322 EMACS_ATTRIBUTE_NONNULL(1), 323 const char *docstring, 324 void *data) 325 EMACS_ATTRIBUTE_NONNULL(1, 4); 326 327 emacs_value (*funcall) (emacs_env *env, 328 emacs_value func, 329 ptrdiff_t nargs, 330 emacs_value* args) 331 EMACS_ATTRIBUTE_NONNULL(1); 332 333 emacs_value (*intern) (emacs_env *env, const char *name) 334 EMACS_ATTRIBUTE_NONNULL(1, 2); 335 336 /* Type conversion. */ 337 338 emacs_value (*type_of) (emacs_env *env, emacs_value arg) 339 EMACS_ATTRIBUTE_NONNULL(1); 340 341 bool (*is_not_nil) (emacs_env *env, emacs_value arg) 342 EMACS_ATTRIBUTE_NONNULL(1); 343 344 bool (*eq) (emacs_env *env, emacs_value a, emacs_value b) 345 EMACS_ATTRIBUTE_NONNULL(1); 346 347 intmax_t (*extract_integer) (emacs_env *env, emacs_value arg) 348 EMACS_ATTRIBUTE_NONNULL(1); 349 350 emacs_value (*make_integer) (emacs_env *env, intmax_t n) 351 EMACS_ATTRIBUTE_NONNULL(1); 352 353 double (*extract_float) (emacs_env *env, emacs_value arg) 354 EMACS_ATTRIBUTE_NONNULL(1); 355 356 emacs_value (*make_float) (emacs_env *env, double d) 357 EMACS_ATTRIBUTE_NONNULL(1); 358 359 /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 360 null-terminated string. 361 362 SIZE must point to the total size of the buffer. If BUFFER is 363 NULL or if SIZE is not big enough, write the required buffer size 364 to SIZE and return true. 365 366 Note that SIZE must include the last null byte (e.g. "abc" needs 367 a buffer of size 4). 368 369 Return true if the string was successfully copied. */ 370 371 bool (*copy_string_contents) (emacs_env *env, 372 emacs_value value, 373 char *buf, 374 ptrdiff_t *len) 375 EMACS_ATTRIBUTE_NONNULL(1, 4); 376 377 /* Create a Lisp string from a utf8 encoded string. */ 378 emacs_value (*make_string) (emacs_env *env, 379 const char *str, ptrdiff_t len) 380 EMACS_ATTRIBUTE_NONNULL(1, 2); 381 382 /* Embedded pointer type. */ 383 emacs_value (*make_user_ptr) (emacs_env *env, 384 void (*fin) (void *) EMACS_NOEXCEPT, 385 void *ptr) 386 EMACS_ATTRIBUTE_NONNULL(1); 387 388 void *(*get_user_ptr) (emacs_env *env, emacs_value arg) 389 EMACS_ATTRIBUTE_NONNULL(1); 390 void (*set_user_ptr) (emacs_env *env, emacs_value arg, void *ptr) 391 EMACS_ATTRIBUTE_NONNULL(1); 392 393 void (*(*get_user_finalizer) (emacs_env *env, emacs_value uptr)) 394 (void *) EMACS_NOEXCEPT EMACS_ATTRIBUTE_NONNULL(1); 395 void (*set_user_finalizer) (emacs_env *env, emacs_value arg, 396 void (*fin) (void *) EMACS_NOEXCEPT) 397 EMACS_ATTRIBUTE_NONNULL(1); 398 399 /* Vector functions. */ 400 emacs_value (*vec_get) (emacs_env *env, emacs_value vector, ptrdiff_t index) 401 EMACS_ATTRIBUTE_NONNULL(1); 402 403 void (*vec_set) (emacs_env *env, emacs_value vector, ptrdiff_t index, 404 emacs_value value) 405 EMACS_ATTRIBUTE_NONNULL(1); 406 407 ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vector) 408 EMACS_ATTRIBUTE_NONNULL(1); 409 410 /* Returns whether a quit is pending. */ 411 bool (*should_quit) (emacs_env *env) 412 EMACS_ATTRIBUTE_NONNULL(1); 413 }; 414 415 struct emacs_env_27 416 { 417 /* Structure size (for version checking). */ 418 ptrdiff_t size; 419 420 /* Private data; users should not touch this. */ 421 struct emacs_env_private *private_members; 422 423 /* Memory management. */ 424 425 emacs_value (*make_global_ref) (emacs_env *env, emacs_value value) 426 EMACS_ATTRIBUTE_NONNULL(1); 427 428 void (*free_global_ref) (emacs_env *env, emacs_value global_value) 429 EMACS_ATTRIBUTE_NONNULL(1); 430 431 /* Non-local exit handling. */ 432 433 enum emacs_funcall_exit (*non_local_exit_check) (emacs_env *env) 434 EMACS_ATTRIBUTE_NONNULL(1); 435 436 void (*non_local_exit_clear) (emacs_env *env) 437 EMACS_ATTRIBUTE_NONNULL(1); 438 439 enum emacs_funcall_exit (*non_local_exit_get) 440 (emacs_env *env, emacs_value *symbol, emacs_value *data) 441 EMACS_ATTRIBUTE_NONNULL(1, 2, 3); 442 443 void (*non_local_exit_signal) (emacs_env *env, 444 emacs_value symbol, emacs_value data) 445 EMACS_ATTRIBUTE_NONNULL(1); 446 447 void (*non_local_exit_throw) (emacs_env *env, 448 emacs_value tag, emacs_value value) 449 EMACS_ATTRIBUTE_NONNULL(1); 450 451 /* Function registration. */ 452 453 emacs_value (*make_function) (emacs_env *env, 454 ptrdiff_t min_arity, 455 ptrdiff_t max_arity, 456 emacs_value (*func) (emacs_env *env, 457 ptrdiff_t nargs, 458 emacs_value* args, 459 void *data) 460 EMACS_NOEXCEPT 461 EMACS_ATTRIBUTE_NONNULL(1), 462 const char *docstring, 463 void *data) 464 EMACS_ATTRIBUTE_NONNULL(1, 4); 465 466 emacs_value (*funcall) (emacs_env *env, 467 emacs_value func, 468 ptrdiff_t nargs, 469 emacs_value* args) 470 EMACS_ATTRIBUTE_NONNULL(1); 471 472 emacs_value (*intern) (emacs_env *env, const char *name) 473 EMACS_ATTRIBUTE_NONNULL(1, 2); 474 475 /* Type conversion. */ 476 477 emacs_value (*type_of) (emacs_env *env, emacs_value arg) 478 EMACS_ATTRIBUTE_NONNULL(1); 479 480 bool (*is_not_nil) (emacs_env *env, emacs_value arg) 481 EMACS_ATTRIBUTE_NONNULL(1); 482 483 bool (*eq) (emacs_env *env, emacs_value a, emacs_value b) 484 EMACS_ATTRIBUTE_NONNULL(1); 485 486 intmax_t (*extract_integer) (emacs_env *env, emacs_value arg) 487 EMACS_ATTRIBUTE_NONNULL(1); 488 489 emacs_value (*make_integer) (emacs_env *env, intmax_t n) 490 EMACS_ATTRIBUTE_NONNULL(1); 491 492 double (*extract_float) (emacs_env *env, emacs_value arg) 493 EMACS_ATTRIBUTE_NONNULL(1); 494 495 emacs_value (*make_float) (emacs_env *env, double d) 496 EMACS_ATTRIBUTE_NONNULL(1); 497 498 /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 499 null-terminated string. 500 501 SIZE must point to the total size of the buffer. If BUFFER is 502 NULL or if SIZE is not big enough, write the required buffer size 503 to SIZE and return true. 504 505 Note that SIZE must include the last null byte (e.g. "abc" needs 506 a buffer of size 4). 507 508 Return true if the string was successfully copied. */ 509 510 bool (*copy_string_contents) (emacs_env *env, 511 emacs_value value, 512 char *buf, 513 ptrdiff_t *len) 514 EMACS_ATTRIBUTE_NONNULL(1, 4); 515 516 /* Create a Lisp string from a utf8 encoded string. */ 517 emacs_value (*make_string) (emacs_env *env, 518 const char *str, ptrdiff_t len) 519 EMACS_ATTRIBUTE_NONNULL(1, 2); 520 521 /* Embedded pointer type. */ 522 emacs_value (*make_user_ptr) (emacs_env *env, 523 void (*fin) (void *) EMACS_NOEXCEPT, 524 void *ptr) 525 EMACS_ATTRIBUTE_NONNULL(1); 526 527 void *(*get_user_ptr) (emacs_env *env, emacs_value arg) 528 EMACS_ATTRIBUTE_NONNULL(1); 529 void (*set_user_ptr) (emacs_env *env, emacs_value arg, void *ptr) 530 EMACS_ATTRIBUTE_NONNULL(1); 531 532 void (*(*get_user_finalizer) (emacs_env *env, emacs_value uptr)) 533 (void *) EMACS_NOEXCEPT EMACS_ATTRIBUTE_NONNULL(1); 534 void (*set_user_finalizer) (emacs_env *env, emacs_value arg, 535 void (*fin) (void *) EMACS_NOEXCEPT) 536 EMACS_ATTRIBUTE_NONNULL(1); 537 538 /* Vector functions. */ 539 emacs_value (*vec_get) (emacs_env *env, emacs_value vector, ptrdiff_t index) 540 EMACS_ATTRIBUTE_NONNULL(1); 541 542 void (*vec_set) (emacs_env *env, emacs_value vector, ptrdiff_t index, 543 emacs_value value) 544 EMACS_ATTRIBUTE_NONNULL(1); 545 546 ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vector) 547 EMACS_ATTRIBUTE_NONNULL(1); 548 549 /* Returns whether a quit is pending. */ 550 bool (*should_quit) (emacs_env *env) 551 EMACS_ATTRIBUTE_NONNULL(1); 552 553 /* Processes pending input events and returns whether the module 554 function should quit. */ 555 enum emacs_process_input_result (*process_input) (emacs_env *env) 556 EMACS_ATTRIBUTE_NONNULL (1); 557 558 struct timespec (*extract_time) (emacs_env *env, emacs_value arg) 559 EMACS_ATTRIBUTE_NONNULL (1); 560 561 emacs_value (*make_time) (emacs_env *env, struct timespec time) 562 EMACS_ATTRIBUTE_NONNULL (1); 563 564 bool (*extract_big_integer) (emacs_env *env, emacs_value arg, int *sign, 565 ptrdiff_t *count, emacs_limb_t *magnitude) 566 EMACS_ATTRIBUTE_NONNULL (1); 567 568 emacs_value (*make_big_integer) (emacs_env *env, int sign, ptrdiff_t count, 569 const emacs_limb_t *magnitude) 570 EMACS_ATTRIBUTE_NONNULL (1); 571 }; 572 573 struct emacs_env_28 574 { 575 /* Structure size (for version checking). */ 576 ptrdiff_t size; 577 578 /* Private data; users should not touch this. */ 579 struct emacs_env_private *private_members; 580 581 /* Memory management. */ 582 583 emacs_value (*make_global_ref) (emacs_env *env, emacs_value value) 584 EMACS_ATTRIBUTE_NONNULL(1); 585 586 void (*free_global_ref) (emacs_env *env, emacs_value global_value) 587 EMACS_ATTRIBUTE_NONNULL(1); 588 589 /* Non-local exit handling. */ 590 591 enum emacs_funcall_exit (*non_local_exit_check) (emacs_env *env) 592 EMACS_ATTRIBUTE_NONNULL(1); 593 594 void (*non_local_exit_clear) (emacs_env *env) 595 EMACS_ATTRIBUTE_NONNULL(1); 596 597 enum emacs_funcall_exit (*non_local_exit_get) 598 (emacs_env *env, emacs_value *symbol, emacs_value *data) 599 EMACS_ATTRIBUTE_NONNULL(1, 2, 3); 600 601 void (*non_local_exit_signal) (emacs_env *env, 602 emacs_value symbol, emacs_value data) 603 EMACS_ATTRIBUTE_NONNULL(1); 604 605 void (*non_local_exit_throw) (emacs_env *env, 606 emacs_value tag, emacs_value value) 607 EMACS_ATTRIBUTE_NONNULL(1); 608 609 /* Function registration. */ 610 611 emacs_value (*make_function) (emacs_env *env, 612 ptrdiff_t min_arity, 613 ptrdiff_t max_arity, 614 emacs_value (*func) (emacs_env *env, 615 ptrdiff_t nargs, 616 emacs_value* args, 617 void *data) 618 EMACS_NOEXCEPT 619 EMACS_ATTRIBUTE_NONNULL(1), 620 const char *docstring, 621 void *data) 622 EMACS_ATTRIBUTE_NONNULL(1, 4); 623 624 emacs_value (*funcall) (emacs_env *env, 625 emacs_value func, 626 ptrdiff_t nargs, 627 emacs_value* args) 628 EMACS_ATTRIBUTE_NONNULL(1); 629 630 emacs_value (*intern) (emacs_env *env, const char *name) 631 EMACS_ATTRIBUTE_NONNULL(1, 2); 632 633 /* Type conversion. */ 634 635 emacs_value (*type_of) (emacs_env *env, emacs_value arg) 636 EMACS_ATTRIBUTE_NONNULL(1); 637 638 bool (*is_not_nil) (emacs_env *env, emacs_value arg) 639 EMACS_ATTRIBUTE_NONNULL(1); 640 641 bool (*eq) (emacs_env *env, emacs_value a, emacs_value b) 642 EMACS_ATTRIBUTE_NONNULL(1); 643 644 intmax_t (*extract_integer) (emacs_env *env, emacs_value arg) 645 EMACS_ATTRIBUTE_NONNULL(1); 646 647 emacs_value (*make_integer) (emacs_env *env, intmax_t n) 648 EMACS_ATTRIBUTE_NONNULL(1); 649 650 double (*extract_float) (emacs_env *env, emacs_value arg) 651 EMACS_ATTRIBUTE_NONNULL(1); 652 653 emacs_value (*make_float) (emacs_env *env, double d) 654 EMACS_ATTRIBUTE_NONNULL(1); 655 656 /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 657 null-terminated string. 658 659 SIZE must point to the total size of the buffer. If BUFFER is 660 NULL or if SIZE is not big enough, write the required buffer size 661 to SIZE and return true. 662 663 Note that SIZE must include the last null byte (e.g. "abc" needs 664 a buffer of size 4). 665 666 Return true if the string was successfully copied. */ 667 668 bool (*copy_string_contents) (emacs_env *env, 669 emacs_value value, 670 char *buf, 671 ptrdiff_t *len) 672 EMACS_ATTRIBUTE_NONNULL(1, 4); 673 674 /* Create a Lisp string from a utf8 encoded string. */ 675 emacs_value (*make_string) (emacs_env *env, 676 const char *str, ptrdiff_t len) 677 EMACS_ATTRIBUTE_NONNULL(1, 2); 678 679 /* Embedded pointer type. */ 680 emacs_value (*make_user_ptr) (emacs_env *env, 681 void (*fin) (void *) EMACS_NOEXCEPT, 682 void *ptr) 683 EMACS_ATTRIBUTE_NONNULL(1); 684 685 void *(*get_user_ptr) (emacs_env *env, emacs_value arg) 686 EMACS_ATTRIBUTE_NONNULL(1); 687 void (*set_user_ptr) (emacs_env *env, emacs_value arg, void *ptr) 688 EMACS_ATTRIBUTE_NONNULL(1); 689 690 void (*(*get_user_finalizer) (emacs_env *env, emacs_value uptr)) 691 (void *) EMACS_NOEXCEPT EMACS_ATTRIBUTE_NONNULL(1); 692 void (*set_user_finalizer) (emacs_env *env, emacs_value arg, 693 void (*fin) (void *) EMACS_NOEXCEPT) 694 EMACS_ATTRIBUTE_NONNULL(1); 695 696 /* Vector functions. */ 697 emacs_value (*vec_get) (emacs_env *env, emacs_value vector, ptrdiff_t index) 698 EMACS_ATTRIBUTE_NONNULL(1); 699 700 void (*vec_set) (emacs_env *env, emacs_value vector, ptrdiff_t index, 701 emacs_value value) 702 EMACS_ATTRIBUTE_NONNULL(1); 703 704 ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vector) 705 EMACS_ATTRIBUTE_NONNULL(1); 706 707 /* Returns whether a quit is pending. */ 708 bool (*should_quit) (emacs_env *env) 709 EMACS_ATTRIBUTE_NONNULL(1); 710 711 /* Processes pending input events and returns whether the module 712 function should quit. */ 713 enum emacs_process_input_result (*process_input) (emacs_env *env) 714 EMACS_ATTRIBUTE_NONNULL (1); 715 716 struct timespec (*extract_time) (emacs_env *env, emacs_value arg) 717 EMACS_ATTRIBUTE_NONNULL (1); 718 719 emacs_value (*make_time) (emacs_env *env, struct timespec time) 720 EMACS_ATTRIBUTE_NONNULL (1); 721 722 bool (*extract_big_integer) (emacs_env *env, emacs_value arg, int *sign, 723 ptrdiff_t *count, emacs_limb_t *magnitude) 724 EMACS_ATTRIBUTE_NONNULL (1); 725 726 emacs_value (*make_big_integer) (emacs_env *env, int sign, ptrdiff_t count, 727 const emacs_limb_t *magnitude) 728 EMACS_ATTRIBUTE_NONNULL (1); 729 730 void (*(*EMACS_ATTRIBUTE_NONNULL (1) 731 get_function_finalizer) (emacs_env *env, 732 emacs_value arg)) (void *) EMACS_NOEXCEPT; 733 734 void (*set_function_finalizer) (emacs_env *env, emacs_value arg, 735 void (*fin) (void *) EMACS_NOEXCEPT) 736 EMACS_ATTRIBUTE_NONNULL (1); 737 738 int (*open_channel) (emacs_env *env, emacs_value pipe_process) 739 EMACS_ATTRIBUTE_NONNULL (1); 740 741 void (*make_interactive) (emacs_env *env, emacs_value function, 742 emacs_value spec) 743 EMACS_ATTRIBUTE_NONNULL (1); 744 745 /* Create a unibyte Lisp string from a string. */ 746 emacs_value (*make_unibyte_string) (emacs_env *env, 747 const char *str, ptrdiff_t len) 748 EMACS_ATTRIBUTE_NONNULL(1, 2); 749 }; 750 751 struct emacs_env_29 752 { 753 /* Structure size (for version checking). */ 754 ptrdiff_t size; 755 756 /* Private data; users should not touch this. */ 757 struct emacs_env_private *private_members; 758 759 /* Memory management. */ 760 761 emacs_value (*make_global_ref) (emacs_env *env, emacs_value value) 762 EMACS_ATTRIBUTE_NONNULL(1); 763 764 void (*free_global_ref) (emacs_env *env, emacs_value global_value) 765 EMACS_ATTRIBUTE_NONNULL(1); 766 767 /* Non-local exit handling. */ 768 769 enum emacs_funcall_exit (*non_local_exit_check) (emacs_env *env) 770 EMACS_ATTRIBUTE_NONNULL(1); 771 772 void (*non_local_exit_clear) (emacs_env *env) 773 EMACS_ATTRIBUTE_NONNULL(1); 774 775 enum emacs_funcall_exit (*non_local_exit_get) 776 (emacs_env *env, emacs_value *symbol, emacs_value *data) 777 EMACS_ATTRIBUTE_NONNULL(1, 2, 3); 778 779 void (*non_local_exit_signal) (emacs_env *env, 780 emacs_value symbol, emacs_value data) 781 EMACS_ATTRIBUTE_NONNULL(1); 782 783 void (*non_local_exit_throw) (emacs_env *env, 784 emacs_value tag, emacs_value value) 785 EMACS_ATTRIBUTE_NONNULL(1); 786 787 /* Function registration. */ 788 789 emacs_value (*make_function) (emacs_env *env, 790 ptrdiff_t min_arity, 791 ptrdiff_t max_arity, 792 emacs_value (*func) (emacs_env *env, 793 ptrdiff_t nargs, 794 emacs_value* args, 795 void *data) 796 EMACS_NOEXCEPT 797 EMACS_ATTRIBUTE_NONNULL(1), 798 const char *docstring, 799 void *data) 800 EMACS_ATTRIBUTE_NONNULL(1, 4); 801 802 emacs_value (*funcall) (emacs_env *env, 803 emacs_value func, 804 ptrdiff_t nargs, 805 emacs_value* args) 806 EMACS_ATTRIBUTE_NONNULL(1); 807 808 emacs_value (*intern) (emacs_env *env, const char *name) 809 EMACS_ATTRIBUTE_NONNULL(1, 2); 810 811 /* Type conversion. */ 812 813 emacs_value (*type_of) (emacs_env *env, emacs_value arg) 814 EMACS_ATTRIBUTE_NONNULL(1); 815 816 bool (*is_not_nil) (emacs_env *env, emacs_value arg) 817 EMACS_ATTRIBUTE_NONNULL(1); 818 819 bool (*eq) (emacs_env *env, emacs_value a, emacs_value b) 820 EMACS_ATTRIBUTE_NONNULL(1); 821 822 intmax_t (*extract_integer) (emacs_env *env, emacs_value arg) 823 EMACS_ATTRIBUTE_NONNULL(1); 824 825 emacs_value (*make_integer) (emacs_env *env, intmax_t n) 826 EMACS_ATTRIBUTE_NONNULL(1); 827 828 double (*extract_float) (emacs_env *env, emacs_value arg) 829 EMACS_ATTRIBUTE_NONNULL(1); 830 831 emacs_value (*make_float) (emacs_env *env, double d) 832 EMACS_ATTRIBUTE_NONNULL(1); 833 834 /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 835 null-terminated string. 836 837 SIZE must point to the total size of the buffer. If BUFFER is 838 NULL or if SIZE is not big enough, write the required buffer size 839 to SIZE and return true. 840 841 Note that SIZE must include the last null byte (e.g. "abc" needs 842 a buffer of size 4). 843 844 Return true if the string was successfully copied. */ 845 846 bool (*copy_string_contents) (emacs_env *env, 847 emacs_value value, 848 char *buf, 849 ptrdiff_t *len) 850 EMACS_ATTRIBUTE_NONNULL(1, 4); 851 852 /* Create a Lisp string from a utf8 encoded string. */ 853 emacs_value (*make_string) (emacs_env *env, 854 const char *str, ptrdiff_t len) 855 EMACS_ATTRIBUTE_NONNULL(1, 2); 856 857 /* Embedded pointer type. */ 858 emacs_value (*make_user_ptr) (emacs_env *env, 859 void (*fin) (void *) EMACS_NOEXCEPT, 860 void *ptr) 861 EMACS_ATTRIBUTE_NONNULL(1); 862 863 void *(*get_user_ptr) (emacs_env *env, emacs_value arg) 864 EMACS_ATTRIBUTE_NONNULL(1); 865 void (*set_user_ptr) (emacs_env *env, emacs_value arg, void *ptr) 866 EMACS_ATTRIBUTE_NONNULL(1); 867 868 void (*(*get_user_finalizer) (emacs_env *env, emacs_value uptr)) 869 (void *) EMACS_NOEXCEPT EMACS_ATTRIBUTE_NONNULL(1); 870 void (*set_user_finalizer) (emacs_env *env, emacs_value arg, 871 void (*fin) (void *) EMACS_NOEXCEPT) 872 EMACS_ATTRIBUTE_NONNULL(1); 873 874 /* Vector functions. */ 875 emacs_value (*vec_get) (emacs_env *env, emacs_value vector, ptrdiff_t index) 876 EMACS_ATTRIBUTE_NONNULL(1); 877 878 void (*vec_set) (emacs_env *env, emacs_value vector, ptrdiff_t index, 879 emacs_value value) 880 EMACS_ATTRIBUTE_NONNULL(1); 881 882 ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vector) 883 EMACS_ATTRIBUTE_NONNULL(1); 884 885 /* Returns whether a quit is pending. */ 886 bool (*should_quit) (emacs_env *env) 887 EMACS_ATTRIBUTE_NONNULL(1); 888 889 /* Processes pending input events and returns whether the module 890 function should quit. */ 891 enum emacs_process_input_result (*process_input) (emacs_env *env) 892 EMACS_ATTRIBUTE_NONNULL (1); 893 894 struct timespec (*extract_time) (emacs_env *env, emacs_value arg) 895 EMACS_ATTRIBUTE_NONNULL (1); 896 897 emacs_value (*make_time) (emacs_env *env, struct timespec time) 898 EMACS_ATTRIBUTE_NONNULL (1); 899 900 bool (*extract_big_integer) (emacs_env *env, emacs_value arg, int *sign, 901 ptrdiff_t *count, emacs_limb_t *magnitude) 902 EMACS_ATTRIBUTE_NONNULL (1); 903 904 emacs_value (*make_big_integer) (emacs_env *env, int sign, ptrdiff_t count, 905 const emacs_limb_t *magnitude) 906 EMACS_ATTRIBUTE_NONNULL (1); 907 908 void (*(*EMACS_ATTRIBUTE_NONNULL (1) 909 get_function_finalizer) (emacs_env *env, 910 emacs_value arg)) (void *) EMACS_NOEXCEPT; 911 912 void (*set_function_finalizer) (emacs_env *env, emacs_value arg, 913 void (*fin) (void *) EMACS_NOEXCEPT) 914 EMACS_ATTRIBUTE_NONNULL (1); 915 916 int (*open_channel) (emacs_env *env, emacs_value pipe_process) 917 EMACS_ATTRIBUTE_NONNULL (1); 918 919 void (*make_interactive) (emacs_env *env, emacs_value function, 920 emacs_value spec) 921 EMACS_ATTRIBUTE_NONNULL (1); 922 923 /* Create a unibyte Lisp string from a string. */ 924 emacs_value (*make_unibyte_string) (emacs_env *env, 925 const char *str, ptrdiff_t len) 926 EMACS_ATTRIBUTE_NONNULL(1, 2); 927 928 /* Add module environment functions newly added in Emacs 29 here. 929 Before Emacs 29 is released, remove this comment and start 930 module-env-30.h on the master branch. */ 931 }; 932 933 /* Every module should define a function as follows. */ 934 extern int emacs_module_init (struct emacs_runtime *runtime) 935 EMACS_NOEXCEPT 936 EMACS_ATTRIBUTE_NONNULL (1); 937 938 #ifdef __cplusplus 939 } 940 #endif 941 942 #endif /* EMACS_MODULE_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2026 MyWebUniversity.com ™