Rework external function handlers (#4599)

Instead of a fixed number of arguments, a call info structure is passed
to the handlers, which can be extended in the future without breaknig the
API. This structure holds new.target value, so its getter function is removed.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
This commit is contained in:
Zoltan Herczeg authored and GitHub committed 2021-02-17 17:52:19 +01:00
1 parent 488a0bf7e8
commit 112ad83aaa
51 files changed
+322 -586

No files matched your search

@@ -20,14 +20,14 @@
#include "ecma-builtin-handlers.h"
#include "ecma-promise-object.h"
static const ecma_native_handler_t ecma_native_handlers[] =
static const ecma_builtin_handler_t ecma_native_handlers[] =
{
#define ECMA_NATIVE_HANDLER(id, handler, length) handler,
#include "ecma-builtin-handlers.inc.h"
#undef ECMA_NATIVE_HANDLER
};
static const uint8_t ecma_native_handler_lengths[] =
static const uint8_t ecma_native_handler_lengths[] =
{
#define ECMA_NATIVE_HANDLER(id, handler, length) length,
#include "ecma-builtin-handlers.inc.h"
@@ -39,7 +39,7 @@ static const uint8_t ecma_native_handler_lengths[] =
*
* return Function pointer of the handler
*/
ecma_native_handler_t
ecma_builtin_handler_t
ecma_builtin_handler_get (ecma_native_handler_id_t id) /**< handler id */
{
JERRY_ASSERT (id != ECMA_NATIVE_HANDLER_START && id < ECMA_NATIVE_HANDLER__COUNT);
@@ -42,7 +42,7 @@ typedef enum
ECMA_NATIVE_HANDLER_FLAGS_PROMISE_ALREADY_RESOLVED = (1 << 2),
} ecma_native_handler_flags_t;
ecma_native_handler_t
ecma_builtin_handler_t
ecma_builtin_handler_get (ecma_native_handler_id_t id);
uint8_t
ecma_builtin_handler_get_length (ecma_native_handler_id_t id);
@@ -1481,8 +1481,8 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (ext_obj_p->u.built_in.id == ECMA_BUILTIN_ID_HANDLER))
{
ecma_native_handler_t handler = ecma_builtin_handler_get (ext_obj_p->u.built_in.routine_id);
return handler (ecma_make_object_value (obj_p), this_arg_value, arguments_list_p, arguments_list_len);
ecma_builtin_handler_t handler = ecma_builtin_handler_get (ext_obj_p->u.built_in.routine_id);
return handler (obj_p, arguments_list_p, arguments_list_len);
}
#endif /* !JERRY_ESNEXT */