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
+13 -5
View File
@@ -34,12 +34,12 @@ extern "C"
/**
* Major version of JerryScript API.
*/
#define JERRY_API_MAJOR_VERSION 2
#define JERRY_API_MAJOR_VERSION 3
/**
* Minor version of JerryScript API.
*/
#define JERRY_API_MINOR_VERSION 4
#define JERRY_API_MINOR_VERSION 0
/**
* Patch version of JerryScript API.
@@ -247,11 +247,20 @@ typedef struct
size_t reserved[4]; /**< padding for future extensions */
} jerry_heap_stats_t;
/**
* Call related information passed to jerry_external_handler_t.
*/
typedef struct jerry_call_info_t
{
jerry_value_t function; /**< invoked function object */
jerry_value_t this_value; /**< this value passed to the function */
jerry_value_t new_target; /**< current new target value, undefined for non-constructor calls */
} jerry_call_info_t;
/**
* Type of an external function handler.
*/
typedef jerry_value_t (*jerry_external_handler_t) (const jerry_value_t function_obj,
const jerry_value_t this_val,
typedef jerry_value_t (*jerry_external_handler_t) (const jerry_call_info_t *call_info_p,
const jerry_value_t args_p[],
const jerry_length_t args_count);
@@ -814,7 +823,6 @@ bool jerry_backtrace_is_strict (jerry_backtrace_frame_t *frame_p);
*/
void jerry_set_vm_exec_stop_callback (jerry_vm_exec_stop_callback_t stop_cb, void *user_p, uint32_t frequency);
jerry_value_t jerry_get_resource_name (const jerry_value_t value);
jerry_value_t jerry_get_new_target (void);
/**
* Array buffer components.