diff options
| author | Philipp Stephani | 2015-12-20 21:10:03 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-12-20 21:10:03 +0200 |
| commit | 4851616b4d2e14cdf970b9029f0d4b00083a08f5 (patch) | |
| tree | eaadb154c9e7517cb1bd9af15c362eb628cc53be /src | |
| parent | f55c0f0c501bb343b68dd41b4fd30a2534bf78db (diff) | |
| download | emacs-4851616b4d2e14cdf970b9029f0d4b00083a08f5.tar.gz emacs-4851616b4d2e14cdf970b9029f0d4b00083a08f5.zip | |
Improve commentary for emacs-module.c
* src/lisp.h: Document emacs-module.c assumptions about EQ and NILP.
* src/emacs-module.c (module_non_local_exit_get): Document that we
cannot use the current implementation.
(module_is_not_nil, module_eq): Document assumptions about EQ and
NILP.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs-module.c | 8 | ||||
| -rw-r--r-- | src/lisp.h | 13 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index ee976440985..5d1b4dc8d6a 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -325,6 +325,8 @@ module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data) | |||
| 325 | struct emacs_env_private *p = env->private_members; | 325 | struct emacs_env_private *p = env->private_members; |
| 326 | if (p->pending_non_local_exit != emacs_funcall_exit_return) | 326 | if (p->pending_non_local_exit != emacs_funcall_exit_return) |
| 327 | { | 327 | { |
| 328 | /* FIXME: We cannot call lisp_to_value here because that can | ||
| 329 | exit non-locally. */ | ||
| 328 | *sym = lisp_to_value (p->non_local_exit_symbol); | 330 | *sym = lisp_to_value (p->non_local_exit_symbol); |
| 329 | *data = lisp_to_value (p->non_local_exit_data); | 331 | *data = lisp_to_value (p->non_local_exit_data); |
| 330 | } | 332 | } |
| @@ -434,6 +436,7 @@ module_is_not_nil (emacs_env *env, emacs_value value) | |||
| 434 | check_main_thread (); | 436 | check_main_thread (); |
| 435 | if (module_non_local_exit_check (env) != emacs_funcall_exit_return) | 437 | if (module_non_local_exit_check (env) != emacs_funcall_exit_return) |
| 436 | return false; | 438 | return false; |
| 439 | /* Assume that NILP never exits non-locally. */ | ||
| 437 | return ! NILP (value_to_lisp (value)); | 440 | return ! NILP (value_to_lisp (value)); |
| 438 | } | 441 | } |
| 439 | 442 | ||
| @@ -443,6 +446,7 @@ module_eq (emacs_env *env, emacs_value a, emacs_value b) | |||
| 443 | check_main_thread (); | 446 | check_main_thread (); |
| 444 | if (module_non_local_exit_check (env) != emacs_funcall_exit_return) | 447 | if (module_non_local_exit_check (env) != emacs_funcall_exit_return) |
| 445 | return false; | 448 | return false; |
| 449 | /* Assume that EQ never exits non-locally. */ | ||
| 446 | return EQ (value_to_lisp (a), value_to_lisp (b)); | 450 | return EQ (value_to_lisp (a), value_to_lisp (b)); |
| 447 | } | 451 | } |
| 448 | 452 | ||
| @@ -889,7 +893,7 @@ value_to_lisp_bits (emacs_value v) | |||
| 889 | } | 893 | } |
| 890 | 894 | ||
| 891 | /* If V was computed from lisp_to_value (O), then return O. | 895 | /* If V was computed from lisp_to_value (O), then return O. |
| 892 | Never fails. */ | 896 | Must never fail or exit non-locally. */ |
| 893 | static Lisp_Object | 897 | static Lisp_Object |
| 894 | value_to_lisp (emacs_value v) | 898 | value_to_lisp (emacs_value v) |
| 895 | { | 899 | { |
| @@ -919,7 +923,7 @@ enum { HAVE_STRUCT_ATTRIBUTE_ALIGNED = 0 }; | |||
| 919 | #endif | 923 | #endif |
| 920 | 924 | ||
| 921 | /* Convert O to an emacs_value. Allocate storage if needed; this can | 925 | /* Convert O to an emacs_value. Allocate storage if needed; this can |
| 922 | signal if memory is exhausted. */ | 926 | signal if memory is exhausted. Must be injective. */ |
| 923 | static emacs_value | 927 | static emacs_value |
| 924 | lisp_to_value (Lisp_Object o) | 928 | lisp_to_value (Lisp_Object o) |
| 925 | { | 929 | { |
diff --git a/src/lisp.h b/src/lisp.h index 995760a5019..bcac4b694b7 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -329,11 +329,15 @@ error !; | |||
| 329 | #define lisp_h_CHECK_TYPE(ok, predicate, x) \ | 329 | #define lisp_h_CHECK_TYPE(ok, predicate, x) \ |
| 330 | ((ok) ? (void) 0 : (void) wrong_type_argument (predicate, x)) | 330 | ((ok) ? (void) 0 : (void) wrong_type_argument (predicate, x)) |
| 331 | #define lisp_h_CONSP(x) (XTYPE (x) == Lisp_Cons) | 331 | #define lisp_h_CONSP(x) (XTYPE (x) == Lisp_Cons) |
| 332 | /* lisp_h_EQ must never exit non-locally; emacs-module.c relies on | ||
| 333 | that. */ | ||
| 332 | #define lisp_h_EQ(x, y) (XLI (x) == XLI (y)) | 334 | #define lisp_h_EQ(x, y) (XLI (x) == XLI (y)) |
| 333 | #define lisp_h_FLOATP(x) (XTYPE (x) == Lisp_Float) | 335 | #define lisp_h_FLOATP(x) (XTYPE (x) == Lisp_Float) |
| 334 | #define lisp_h_INTEGERP(x) ((XTYPE (x) & (Lisp_Int0 | ~Lisp_Int1)) == Lisp_Int0) | 336 | #define lisp_h_INTEGERP(x) ((XTYPE (x) & (Lisp_Int0 | ~Lisp_Int1)) == Lisp_Int0) |
| 335 | #define lisp_h_MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) | 337 | #define lisp_h_MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) |
| 336 | #define lisp_h_MISCP(x) (XTYPE (x) == Lisp_Misc) | 338 | #define lisp_h_MISCP(x) (XTYPE (x) == Lisp_Misc) |
| 339 | /* lisp_h_NILP must never exit non-locally; emacs-module.c relies on | ||
| 340 | that. */ | ||
| 337 | #define lisp_h_NILP(x) EQ (x, Qnil) | 341 | #define lisp_h_NILP(x) EQ (x, Qnil) |
| 338 | #define lisp_h_SET_SYMBOL_VAL(sym, v) \ | 342 | #define lisp_h_SET_SYMBOL_VAL(sym, v) \ |
| 339 | (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v)) | 343 | (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v)) |
| @@ -382,11 +386,14 @@ error !; | |||
| 382 | # define CHECK_SYMBOL(x) lisp_h_CHECK_SYMBOL (x) | 386 | # define CHECK_SYMBOL(x) lisp_h_CHECK_SYMBOL (x) |
| 383 | # define CHECK_TYPE(ok, predicate, x) lisp_h_CHECK_TYPE (ok, predicate, x) | 387 | # define CHECK_TYPE(ok, predicate, x) lisp_h_CHECK_TYPE (ok, predicate, x) |
| 384 | # define CONSP(x) lisp_h_CONSP (x) | 388 | # define CONSP(x) lisp_h_CONSP (x) |
| 389 | /* EQ must never exit non-locally; emacs-module.c relies on that. */ | ||
| 385 | # define EQ(x, y) lisp_h_EQ (x, y) | 390 | # define EQ(x, y) lisp_h_EQ (x, y) |
| 386 | # define FLOATP(x) lisp_h_FLOATP (x) | 391 | # define FLOATP(x) lisp_h_FLOATP (x) |
| 387 | # define INTEGERP(x) lisp_h_INTEGERP (x) | 392 | # define INTEGERP(x) lisp_h_INTEGERP (x) |
| 388 | # define MARKERP(x) lisp_h_MARKERP (x) | 393 | # define MARKERP(x) lisp_h_MARKERP (x) |
| 389 | # define MISCP(x) lisp_h_MISCP (x) | 394 | # define MISCP(x) lisp_h_MISCP (x) |
| 395 | /* NILP must never exit non-locally; emacs-module.c relies on | ||
| 396 | that. */ | ||
| 390 | # define NILP(x) lisp_h_NILP (x) | 397 | # define NILP(x) lisp_h_NILP (x) |
| 391 | # define SET_SYMBOL_VAL(sym, v) lisp_h_SET_SYMBOL_VAL (sym, v) | 398 | # define SET_SYMBOL_VAL(sym, v) lisp_h_SET_SYMBOL_VAL (sym, v) |
| 392 | # define SYMBOL_CONSTANT_P(sym) lisp_h_SYMBOL_CONSTANT_P (sym) | 399 | # define SYMBOL_CONSTANT_P(sym) lisp_h_SYMBOL_CONSTANT_P (sym) |
| @@ -988,7 +995,8 @@ make_natnum (EMACS_INT n) | |||
| 988 | return USE_LSB_TAG ? make_number (n) : XIL (n + (int0 << VALBITS)); | 995 | return USE_LSB_TAG ? make_number (n) : XIL (n + (int0 << VALBITS)); |
| 989 | } | 996 | } |
| 990 | 997 | ||
| 991 | /* Return true if X and Y are the same object. */ | 998 | /* Return true if X and Y are the same object. Must never exit |
| 999 | non-locally; emacs-module.c relies on that. */ | ||
| 992 | 1000 | ||
| 993 | INLINE bool | 1001 | INLINE bool |
| 994 | (EQ) (Lisp_Object x, Lisp_Object y) | 1002 | (EQ) (Lisp_Object x, Lisp_Object y) |
| @@ -2565,6 +2573,9 @@ enum char_bits | |||
| 2565 | 2573 | ||
| 2566 | /* Data type checking. */ | 2574 | /* Data type checking. */ |
| 2567 | 2575 | ||
| 2576 | /* Checks whether X is null. Must never exit non-locally; | ||
| 2577 | emacs-module.c relies on that. */ | ||
| 2578 | |||
| 2568 | INLINE bool | 2579 | INLINE bool |
| 2569 | (NILP) (Lisp_Object x) | 2580 | (NILP) (Lisp_Object x) |
| 2570 | { | 2581 | { |