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 zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-02-17 17:52:19 +01:00
committed by GitHub
parent 488a0bf7e8
commit 112ad83aaa
51 changed files with 322 additions and 586 deletions
@@ -1227,9 +1227,19 @@ ecma_op_function_call_native (ecma_object_t *func_obj_p, /**< Function object */
native_function_p->realm_value);
#endif /* JERRY_BUILTIN_REALMS */
jerry_call_info_t call_info;
call_info.function = ecma_make_object_value (func_obj_p);
call_info.this_value = this_arg_value;
#if JERRY_ESNEXT
ecma_object_t *new_target_p = JERRY_CONTEXT (current_new_target_p);
call_info.new_target = (new_target_p == NULL) ? ECMA_VALUE_UNDEFINED : ecma_make_object_value (new_target_p);
#else /* JERRY_ESNEXT */
call_info.new_target = ECMA_VALUE_UNDEFINED;
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (native_function_p->native_handler_cb != NULL);
ecma_value_t ret_value = native_function_p->native_handler_cb (ecma_make_object_value (func_obj_p),
this_arg_value,
ecma_value_t ret_value = native_function_p->native_handler_cb (&call_info,
arguments_list_p,
arguments_list_len);
#if JERRY_BUILTIN_REALMS