[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 1839699 02/14: Define helper macro to reduce code d
From: |
Philipp Stephani |
Subject: |
[Emacs-diffs] master 1839699 02/14: Define helper macro to reduce code duplication |
Date: |
Sun, 4 Jun 2017 13:54:05 -0400 (EDT) |
branch: master
commit 18396997b30c053a905c9a509777625ccc01c3d5
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Define helper macro to reduce code duplication
* src/emacs-module.c (MODULE_FUNCTION_BEGIN_NO_CATCH): New helper
macro.
(MODULE_FUNCTION_BEGIN, module_type_of, module_is_not_nil, module_eq):
Use it.
---
src/emacs-module.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/emacs-module.c b/src/emacs-module.c
index d3c4cac..f2eaa71 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -211,14 +211,25 @@ static emacs_value const module_nil = 0;
instead of reporting the error back to Lisp, and also because
'eassert' is compiled to nothing in the release version. */
+/* Use MODULE_FUNCTION_BEGIN_NO_CATCH to implement steps 2 and 3 for
+ environment functions that are known to never exit non-locally. On
+ error it will return its argument, which can be a sentinel
+ value. */
+
+#define MODULE_FUNCTION_BEGIN_NO_CATCH(error_retval) \
+ do { \
+ eassert (env != NULL); \
+ check_main_thread (); \
+ if (module_non_local_exit_check (env) != emacs_funcall_exit_return) \
+ return error_retval; \
+ } while (false)
+
/* Use MODULE_FUNCTION_BEGIN to implement steps 2 through 4 for most
environment functions. On error it will return its argument, which
should be a sentinel value. */
-#define MODULE_FUNCTION_BEGIN(error_retval) \
- check_main_thread (); \
- if (module_non_local_exit_check (env) != emacs_funcall_exit_return) \
- return error_retval; \
+#define MODULE_FUNCTION_BEGIN(error_retval) \
+ MODULE_FUNCTION_BEGIN_NO_CATCH (error_retval); \
MODULE_HANDLE_NONLOCAL_EXIT (error_retval)
static void
@@ -416,18 +427,14 @@ module_type_of (emacs_env *env, emacs_value value)
static bool
module_is_not_nil (emacs_env *env, emacs_value value)
{
- check_main_thread ();
- if (module_non_local_exit_check (env) != emacs_funcall_exit_return)
- return false;
+ MODULE_FUNCTION_BEGIN_NO_CATCH (false);
return ! NILP (value_to_lisp (value));
}
static bool
module_eq (emacs_env *env, emacs_value a, emacs_value b)
{
- check_main_thread ();
- if (module_non_local_exit_check (env) != emacs_funcall_exit_return)
- return false;
+ MODULE_FUNCTION_BEGIN_NO_CATCH (false);
return EQ (value_to_lisp (a), value_to_lisp (b));
}
- [Emacs-diffs] master updated (bd3c6ee -> 2aa8b15), Philipp Stephani, 2017/06/04
- [Emacs-diffs] master db74384 01/14: Remove two FIXMEs that can't be fixed, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 1839699 02/14: Define helper macro to reduce code duplication,
Philipp Stephani <=
- [Emacs-diffs] master 034275e 07/14: ; Small comment fix, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 3b0080d 03/14: Rework printing of module functions, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 366e25a 05/14: Simplify interface of dynlib_attr., Philipp Stephani, 2017/06/04
- [Emacs-diffs] master a8a93b1 10/14: Guard against signed integer overflows, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master fb3a9fd 08/14: ; Grammar fix, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 9be8b2b 06/14: Use ATTRIBUTE_MAY_ALIAS where alias violations are likely, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 5497062 09/14: Add a couple more assertions to the module code, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 27445a8 11/14: Remove an unneeded assertion, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 2aa8b15 14/14: Remove an unused error symbol, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master d372017 12/14: Use more specific errors for module load failure, Philipp Stephani, 2017/06/04