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:
@@ -29,13 +29,11 @@
|
||||
* Note that the function does not return otherwise.
|
||||
*/
|
||||
jerry_value_t
|
||||
jerryx_handler_assert_fatal (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_p, /**< this arg */
|
||||
jerryx_handler_assert_fatal (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
(void) func_obj_val; /* unused */
|
||||
(void) this_p; /* unused */
|
||||
(void) call_info_p; /* unused */
|
||||
|
||||
if (args_cnt == 1
|
||||
&& jerry_value_is_boolean (args_p[0])
|
||||
@@ -100,13 +98,11 @@ jerryx_handler_assert_fatal (const jerry_value_t func_obj_val, /**< function obj
|
||||
* error - otherwise.
|
||||
*/
|
||||
jerry_value_t
|
||||
jerryx_handler_assert_throw (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_p, /**< this arg */
|
||||
jerryx_handler_assert_throw (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
(void) func_obj_val; /* unused */
|
||||
(void) this_p; /* unused */
|
||||
(void) call_info_p; /* unused */
|
||||
|
||||
if (args_cnt == 1
|
||||
&& jerry_value_is_boolean (args_p[0])
|
||||
@@ -125,10 +121,9 @@ jerryx_handler_assert_throw (const jerry_value_t func_obj_val, /**< function obj
|
||||
* Note that the function does not return otherwise.
|
||||
*/
|
||||
jerry_value_t
|
||||
jerryx_handler_assert (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_p, /**< this arg */
|
||||
jerryx_handler_assert (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
return jerryx_handler_assert_fatal (func_obj_val, this_p, args_p, args_cnt);
|
||||
return jerryx_handler_assert_fatal (call_info_p, args_p, args_cnt);
|
||||
} /* jerryx_handler_assert */
|
||||
|
||||
@@ -21,13 +21,11 @@
|
||||
* @return undefined.
|
||||
*/
|
||||
jerry_value_t
|
||||
jerryx_handler_gc (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_p, /**< this arg */
|
||||
jerryx_handler_gc (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
(void) func_obj_val; /* unused */
|
||||
(void) this_p; /* unused */
|
||||
(void) call_info_p; /* unused */
|
||||
|
||||
jerry_gc_mode_t mode = ((args_cnt > 0 && jerry_value_to_boolean (args_p[0])) ? JERRY_GC_PRESSURE_HIGH
|
||||
: JERRY_GC_PRESSURE_LOW);
|
||||
|
||||
@@ -37,13 +37,11 @@
|
||||
* error - otherwise.
|
||||
*/
|
||||
jerry_value_t
|
||||
jerryx_handler_print (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_p, /**< this arg */
|
||||
jerryx_handler_print (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
(void) func_obj_val; /* unused */
|
||||
(void) this_p; /* unused */
|
||||
(void) call_info_p; /* unused */
|
||||
|
||||
const char * const null_str = "\\u0000";
|
||||
|
||||
|
||||
@@ -26,13 +26,11 @@
|
||||
* - "<anonymous>", otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerryx_handler_resource_name (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_p, /**< this arg */
|
||||
jerryx_handler_resource_name (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
(void) func_obj_val; /* unused */
|
||||
(void) this_p; /* unused */
|
||||
(void) call_info_p; /* unused */
|
||||
|
||||
jerry_value_t undefined_value = jerry_create_undefined ();
|
||||
jerry_value_t resource_name = jerry_get_resource_name (args_cnt > 0 ? args_p[0] : undefined_value);
|
||||
|
||||
@@ -34,17 +34,17 @@ jerry_value_t jerryx_handler_register_global (const jerry_char_t *name_p,
|
||||
* Common external function handlers
|
||||
*/
|
||||
|
||||
jerry_value_t jerryx_handler_assert_fatal (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
jerry_value_t jerryx_handler_assert_fatal (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerry_value_t jerryx_handler_assert_throw (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
jerry_value_t jerryx_handler_assert_throw (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerry_value_t jerryx_handler_assert (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
jerry_value_t jerryx_handler_assert (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerry_value_t jerryx_handler_gc (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
jerry_value_t jerryx_handler_gc (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerry_value_t jerryx_handler_print (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
jerry_value_t jerryx_handler_print (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerry_value_t jerryx_handler_resource_name (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
jerry_value_t jerryx_handler_resource_name (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user