Unify asserts in jerry-ext (#4488)

Some components of the jerry-ext library re-declared their own
assert and/or static assert macros. No need to re-invent the wheel
all the time. This patch makes all components use the assert macros
defined in jext-common.h. This also makes maintenance easier.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2021-01-17 15:21:46 +01:00
committed by GitHub
parent 11894a6032
commit 9bc0f2fd3f
5 changed files with 8 additions and 29 deletions
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include "handle-scope-internal.h"
#include "jext-common.h"
static jerryx_handle_scope_t jerryx_handle_scope_root =
{
@@ -157,7 +158,7 @@ jerryx_handle_scope_alloc (void)
else
{
jerryx_handle_scope_dynamic_t *dy_scope = malloc (sizeof (jerryx_handle_scope_dynamic_t));
JERRYX_HANDLE_SCOPE_ASSERT (dy_scope != NULL);
JERRYX_ASSERT (dy_scope != NULL);
dy_scope->child = NULL;
if (jerryx_handle_scope_pool.count != JERRYX_SCOPE_PRELIST_SIZE)
@@ -25,21 +25,6 @@ extern "C"
{
#endif /* __cplusplus */
#define JERRYX_HANDLE_SCOPE_ASSERT(x) \
do \
{ \
if (!(x)) \
{ \
jerry_port_log (JERRY_LOG_LEVEL_ERROR, \
"JerryXHandleScope: Assertion '%s' failed at %s(%s):%lu.\n", \
#x, \
__FILE__, \
__func__, \
(unsigned long) __LINE__); \
jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \
} \
} while (0)
/** MARK: - handle-scope-allocator.c */
typedef struct jerryx_handle_scope_pool_s jerryx_handle_scope_pool_t;
/**
+4 -1
View File
@@ -15,6 +15,9 @@
#include <stdlib.h>
#include "handle-scope-internal.h"
#include "jext-common.h"
JERRYX_STATIC_ASSERT (JERRYX_SCOPE_PRELIST_SIZE < 32, JERRYX_SCOPE_PRELIST_SIZE_MUST_BE_LESS_THAN_SIZE_OF_UINT8_T);
/**
* Opens a new handle scope and attach it to current global scope as a child scope.
@@ -339,7 +342,7 @@ jerryx_create_handle_in_scope (jerry_value_t jval, jerryx_handle_scope scope)
return jval;
}
jerryx_handle_t *handle = malloc (sizeof (jerryx_handle_t));
JERRYX_HANDLE_SCOPE_ASSERT (handle != NULL);
JERRYX_ASSERT (handle != NULL);
handle->jval = jval;
handle->sibling = scope->handle_ptr;