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:
@@ -19,13 +19,11 @@
|
||||
#include "test-common.h"
|
||||
|
||||
static jerry_value_t
|
||||
callback_func (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
callback_func (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count)
|
||||
{
|
||||
JERRY_UNUSED (function_obj);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_count);
|
||||
|
||||
|
||||
@@ -28,13 +28,11 @@ typedef struct
|
||||
} test_entry_t;
|
||||
|
||||
static jerry_value_t
|
||||
my_constructor (const jerry_value_t func_val, /**< function */
|
||||
const jerry_value_t this_val, /**< this */
|
||||
my_constructor (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t argv[], /**< arguments */
|
||||
const jerry_length_t argc) /**< number of arguments */
|
||||
{
|
||||
(void) func_val;
|
||||
(void) this_val;
|
||||
(void) call_info_p;
|
||||
(void) argv;
|
||||
(void) argc;
|
||||
return jerry_create_undefined ();
|
||||
|
||||
@@ -30,13 +30,11 @@ typedef struct
|
||||
#define ENTRY_IF(TYPE, VALUE, FEATURE, ASYNC) { TYPE, VALUE, jerry_is_feature_enabled (FEATURE), ASYNC }
|
||||
#define EVALUATE(BUFF) (jerry_eval ((BUFF), sizeof ((BUFF)) - 1, JERRY_PARSE_NO_OPTS))
|
||||
static jerry_value_t
|
||||
test_ext_function (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< function this value */
|
||||
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< array of arguments */
|
||||
const jerry_length_t args_cnt) /**< number of arguments */
|
||||
{
|
||||
(void) function_obj;
|
||||
(void) this_val;
|
||||
(void) call_info_p;
|
||||
(void) args_p;
|
||||
(void) args_cnt;
|
||||
return jerry_create_boolean (true);
|
||||
|
||||
@@ -29,13 +29,11 @@ typedef struct
|
||||
#define ENTRY_IF(TYPE, VALUE, FEATURE) { TYPE, VALUE, jerry_is_feature_enabled (FEATURE) }
|
||||
#define EVALUATE(BUFF) (jerry_eval ((BUFF), sizeof ((BUFF)) - 1, JERRY_PARSE_NO_OPTS))
|
||||
static jerry_value_t
|
||||
test_ext_function (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< function this value */
|
||||
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< array of arguments */
|
||||
const jerry_length_t args_cnt) /**< number of arguments */
|
||||
{
|
||||
(void) function_obj;
|
||||
(void) this_val;
|
||||
(void) call_info_p;
|
||||
(void) args_p;
|
||||
(void) args_cnt;
|
||||
return jerry_create_boolean (true);
|
||||
|
||||
@@ -27,13 +27,11 @@ typedef struct
|
||||
#define ENTRY(TYPE, VALUE) { TYPE, VALUE }
|
||||
|
||||
static jerry_value_t
|
||||
test_ext_function (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< function this value */
|
||||
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< array of arguments */
|
||||
const jerry_length_t args_cnt) /**< number of arguments */
|
||||
{
|
||||
(void) function_obj;
|
||||
(void) this_val;
|
||||
(void) call_info_p;
|
||||
(void) args_p;
|
||||
(void) args_cnt;
|
||||
return jerry_create_boolean (true);
|
||||
|
||||
+23
-16
@@ -62,8 +62,7 @@ const jerry_char_t test_source[] = TEST_STRING_LITERAL (
|
||||
bool test_api_is_free_callback_was_called = false;
|
||||
|
||||
static jerry_value_t
|
||||
handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
@@ -71,7 +70,10 @@ handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
jerry_size_t sz;
|
||||
|
||||
printf ("ok %u %u %p %u\n",
|
||||
(unsigned int) func_obj_val, (unsigned int) this_val, (void *) args_p, (unsigned int) args_cnt);
|
||||
(unsigned int) call_info_p->function,
|
||||
(unsigned int) call_info_p->this_value,
|
||||
(void *) args_p,
|
||||
(unsigned int) args_cnt);
|
||||
|
||||
TEST_ASSERT (args_cnt == 2);
|
||||
|
||||
@@ -90,13 +92,15 @@ handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
} /* handler */
|
||||
|
||||
static jerry_value_t
|
||||
handler_throw_test (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
handler_throw_test (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
printf ("ok %u %u %p %u\n",
|
||||
(unsigned int) func_obj_val, (unsigned int) this_val, (void *) args_p, (unsigned int) args_cnt);
|
||||
(unsigned int) call_info_p->function,
|
||||
(unsigned int) call_info_p->this_value,
|
||||
(void *) args_p,
|
||||
(unsigned int) args_cnt);
|
||||
|
||||
return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "error");
|
||||
} /* handler_throw_test */
|
||||
@@ -138,50 +142,53 @@ JERRY_DEFINE_NATIVE_HANDLE_INFO (bind2, handler_construct_2_freecb);
|
||||
JERRY_DEFINE_NATIVE_HANDLE_INFO (bind3, NULL);
|
||||
|
||||
static jerry_value_t
|
||||
handler_construct (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
handler_construct (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
printf ("ok construct %u %u %p %u\n",
|
||||
(unsigned int) func_obj_val, (unsigned int) this_val, (void *) args_p, (unsigned int) args_cnt);
|
||||
(unsigned int) call_info_p->function,
|
||||
(unsigned int) call_info_p->this_value,
|
||||
(void *) args_p,
|
||||
(unsigned int) args_cnt);
|
||||
|
||||
TEST_ASSERT (jerry_value_is_object (this_val));
|
||||
TEST_ASSERT (jerry_value_is_object (call_info_p->this_value));
|
||||
|
||||
TEST_ASSERT (args_cnt == 1);
|
||||
TEST_ASSERT (jerry_value_is_boolean (args_p[0]));
|
||||
TEST_ASSERT (jerry_get_boolean_value (args_p[0]) == true);
|
||||
|
||||
jerry_value_t this_value = call_info_p->this_value;
|
||||
jerry_value_t field_name = jerry_create_string ((jerry_char_t *) "value_field");
|
||||
jerry_value_t res = jerry_set_property (this_val, field_name, args_p[0]);
|
||||
jerry_value_t res = jerry_set_property (this_value, field_name, args_p[0]);
|
||||
TEST_ASSERT (!jerry_value_is_error (res));
|
||||
TEST_ASSERT (jerry_value_is_boolean (res) && jerry_get_boolean_value (res));
|
||||
jerry_release_value (res);
|
||||
jerry_release_value (field_name);
|
||||
|
||||
/* Set a native pointer. */
|
||||
jerry_set_object_native_pointer (this_val,
|
||||
jerry_set_object_native_pointer (this_value,
|
||||
(void *) 0x0000000000000000ull,
|
||||
&JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind1));
|
||||
|
||||
/* Check that the native pointer was set. */
|
||||
void *ptr = NULL;
|
||||
bool is_ok = jerry_get_object_native_pointer (this_val, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind1));
|
||||
bool is_ok = jerry_get_object_native_pointer (this_value, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind1));
|
||||
TEST_ASSERT (is_ok
|
||||
&& (uintptr_t) ptr == (uintptr_t) 0x0000000000000000ull);
|
||||
|
||||
/* Set a second native pointer. */
|
||||
jerry_set_object_native_pointer (this_val,
|
||||
jerry_set_object_native_pointer (this_value,
|
||||
(void *) 0x0012345678abcdefull,
|
||||
&JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind2));
|
||||
|
||||
/* Check that a second native pointer was set. */
|
||||
is_ok = jerry_get_object_native_pointer (this_val, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind2));
|
||||
is_ok = jerry_get_object_native_pointer (this_value, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind2));
|
||||
TEST_ASSERT (is_ok
|
||||
&& (uintptr_t) ptr == (uintptr_t) 0x0012345678abcdefull);
|
||||
|
||||
/* Check that the first native pointer is still set. */
|
||||
is_ok = jerry_get_object_native_pointer (this_val, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind1));
|
||||
is_ok = jerry_get_object_native_pointer (this_value, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind1));
|
||||
TEST_ASSERT (is_ok
|
||||
&& (uintptr_t) ptr == (uintptr_t) 0x0000000000000000ull);
|
||||
return jerry_create_boolean (true);
|
||||
|
||||
@@ -38,13 +38,11 @@ register_js_value (const char *name_p, /**< name of the function */
|
||||
} /* register_js_value */
|
||||
|
||||
static jerry_value_t
|
||||
assert_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
assert_handler (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 */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
if (args_cnt > 0
|
||||
&& jerry_value_is_boolean (args_p[0])
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
#include "test-common.h"
|
||||
|
||||
static jerry_value_t
|
||||
backtrace_handler (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
backtrace_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< argument list */
|
||||
const jerry_length_t args_count) /**< argument count */
|
||||
{
|
||||
JERRY_UNUSED (function_obj);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
uint32_t max_depth = 0;
|
||||
|
||||
@@ -98,13 +96,11 @@ backtrace_callback (jerry_backtrace_frame_t *frame_p, /* frame information */
|
||||
} /* backtrace_callback */
|
||||
|
||||
static jerry_value_t
|
||||
capture_handler (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
capture_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< argument list */
|
||||
const jerry_length_t args_count) /**< argument count */
|
||||
{
|
||||
JERRY_UNUSED (function_obj);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_count);
|
||||
|
||||
|
||||
@@ -19,13 +19,11 @@
|
||||
#include "test-common.h"
|
||||
|
||||
static jerry_value_t
|
||||
custom_to_json (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
custom_to_json (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
|
||||
@@ -19,13 +19,11 @@
|
||||
static const char instanceof_source[] = "var x = function(o, c) {return (o instanceof c);}; x";
|
||||
|
||||
static jerry_value_t
|
||||
external_function (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_arg,
|
||||
external_function (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_size_t args_count)
|
||||
{
|
||||
(void) function_obj;
|
||||
(void) this_arg;
|
||||
(void) call_info_p;
|
||||
(void) args_p;
|
||||
(void) args_count;
|
||||
|
||||
|
||||
@@ -47,13 +47,10 @@ enum
|
||||
};
|
||||
|
||||
static jerry_value_t
|
||||
construct_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
construct_handler (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 */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (args_p);
|
||||
|
||||
if (args_cnt != 1 || !jerry_value_is_number (args_p[0]))
|
||||
@@ -68,32 +65,31 @@ construct_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
case TEST_ID_SIMPLE_CONSTRUCT:
|
||||
{
|
||||
/* Method was called with "new": new.target should be equal to the function object. */
|
||||
jerry_value_t target = jerry_get_new_target ();
|
||||
jerry_value_t target = call_info_p->new_target;
|
||||
TEST_ASSERT (!jerry_value_is_undefined (target));
|
||||
TEST_ASSERT (target == func_obj_val);
|
||||
jerry_release_value (target);
|
||||
TEST_ASSERT (target == call_info_p->function);
|
||||
break;
|
||||
}
|
||||
case TEST_ID_SIMPLE_CALL:
|
||||
{
|
||||
/* Method was called directly without "new": new.target should be equal undefined. */
|
||||
jerry_value_t target = jerry_get_new_target ();
|
||||
jerry_value_t target = call_info_p->new_target;
|
||||
TEST_ASSERT (jerry_value_is_undefined (target));
|
||||
TEST_ASSERT (target != func_obj_val);
|
||||
jerry_release_value (target);
|
||||
TEST_ASSERT (target != call_info_p->function);
|
||||
break;
|
||||
}
|
||||
case TEST_ID_CONSTRUCT_AND_CALL_SUB:
|
||||
{
|
||||
/* Method was called with "new": new.target should be equal to the function object. */
|
||||
jerry_value_t target = jerry_get_new_target ();
|
||||
jerry_value_t target = call_info_p->new_target;
|
||||
TEST_ASSERT (!jerry_value_is_undefined (target));
|
||||
TEST_ASSERT (target == func_obj_val);
|
||||
jerry_release_value (target);
|
||||
TEST_ASSERT (target == call_info_p->function);
|
||||
|
||||
/* Calling a function should hide the old "new.target". */
|
||||
jerry_value_t sub_arg = jerry_create_number (TEST_ID_SIMPLE_CALL);
|
||||
jerry_value_t func_call_result = jerry_call_function (func_obj_val, this_val, &sub_arg, 1);
|
||||
jerry_value_t func_call_result;
|
||||
|
||||
func_call_result = jerry_call_function (call_info_p->function, call_info_p->this_value, &sub_arg, 1);
|
||||
TEST_ASSERT (!jerry_value_is_error (func_call_result));
|
||||
TEST_ASSERT (jerry_value_is_undefined (func_call_result));
|
||||
break;
|
||||
|
||||
@@ -36,13 +36,11 @@ static const jerry_char_t s1[] = "resolved";
|
||||
static const jerry_char_t s2[] = "rejected";
|
||||
|
||||
static jerry_value_t
|
||||
create_promise1_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
create_promise1_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
@@ -53,13 +51,11 @@ create_promise1_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
} /* create_promise1_handler */
|
||||
|
||||
static jerry_value_t
|
||||
create_promise2_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
create_promise2_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
@@ -70,13 +66,11 @@ create_promise2_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
} /* create_promise2_handler */
|
||||
|
||||
static jerry_value_t
|
||||
assert_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
assert_handler (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 */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
count_in_assert++;
|
||||
|
||||
|
||||
@@ -58,13 +58,11 @@ assert (pdemo.value === 13);
|
||||
static int demo_value = 0;
|
||||
|
||||
static jerry_value_t
|
||||
handler_get (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_count) /**< number of function arguments */
|
||||
handler_get (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_count) /**< number of function arguments */
|
||||
{
|
||||
JERRY_UNUSED (function_obj);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
TEST_ASSERT (args_count == 3);
|
||||
TEST_ASSERT (jerry_value_is_object (args_p[0])); /* target */
|
||||
@@ -84,13 +82,11 @@ handler_get (const jerry_value_t function_obj, /**< function object */
|
||||
} /* handler_get */
|
||||
|
||||
static jerry_value_t
|
||||
handler_set (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_count) /**< number of function arguments */
|
||||
handler_set (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_count) /**< number of function arguments */
|
||||
{
|
||||
JERRY_UNUSED (function_obj);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_count);
|
||||
|
||||
@@ -167,13 +163,11 @@ static const jerry_object_native_info_t proxy_native_info =
|
||||
};
|
||||
|
||||
static jerry_value_t
|
||||
proxy_native_handler_get (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
proxy_native_handler_get (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_count) /**< number of function arguments */
|
||||
{
|
||||
JERRY_UNUSED (function_obj);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
TEST_ASSERT (args_count == 3);
|
||||
|
||||
/* 3rd argument (Receiver) should be the Proxy here. */
|
||||
|
||||
@@ -22,13 +22,11 @@
|
||||
* Empty constructor
|
||||
*/
|
||||
static jerry_value_t
|
||||
construct_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
construct_handler (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 */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
TEST_ASSERT (args_cnt == 1);
|
||||
TEST_ASSERT (jerry_get_number_value (args_p[0]) == 1.0);
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
#include "test-common.h"
|
||||
|
||||
static jerry_value_t
|
||||
resource_name_handler (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
resource_name_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< argument list */
|
||||
const jerry_length_t args_count) /**< argument count */
|
||||
{
|
||||
(void) function_obj;
|
||||
(void) this_val;
|
||||
(void) call_info_p;
|
||||
|
||||
jerry_value_t undefined_value = jerry_create_undefined ();
|
||||
jerry_value_t resource_name = jerry_get_resource_name (args_count > 0 ? args_p[0] : undefined_value);
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
#include "test-common.h"
|
||||
|
||||
static jerry_value_t
|
||||
create_special_proxy_handler (const jerry_value_t function_obj, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
create_special_proxy_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< argument list */
|
||||
const jerry_length_t args_count) /**< argument count */
|
||||
{
|
||||
JERRY_UNUSED (function_obj);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
if (args_count < 2)
|
||||
{
|
||||
|
||||
@@ -50,13 +50,11 @@ register_js_value (const char *name_p, /**< name of the function */
|
||||
} /* register_js_value */
|
||||
|
||||
static jerry_value_t
|
||||
assert_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
assert_handler (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 */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
if (jerry_value_is_boolean (args_p[0])
|
||||
&& jerry_get_boolean_value (args_p[0]))
|
||||
|
||||
@@ -138,13 +138,11 @@ static const jerryx_module_resolver_t *resolvers[3] =
|
||||
};
|
||||
|
||||
static jerry_value_t
|
||||
handle_clear_require_cache (const jerry_value_t js_function,
|
||||
const jerry_value_t this_val,
|
||||
handle_clear_require_cache (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count)
|
||||
{
|
||||
(void) js_function;
|
||||
(void) this_val;
|
||||
(void) call_info_p;
|
||||
(void) args_count;
|
||||
|
||||
TEST_ASSERT (args_count == 1);
|
||||
@@ -154,13 +152,11 @@ handle_clear_require_cache (const jerry_value_t js_function,
|
||||
} /* handle_clear_require_cache */
|
||||
|
||||
static jerry_value_t
|
||||
handle_require (const jerry_value_t js_function,
|
||||
const jerry_value_t this_val,
|
||||
handle_require (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count)
|
||||
{
|
||||
(void) js_function;
|
||||
(void) this_val;
|
||||
(void) call_info_p;
|
||||
(void) args_count;
|
||||
|
||||
jerry_value_t return_value = 0;
|
||||
|
||||
@@ -106,13 +106,10 @@ static int validator_restore_count = 0;
|
||||
*
|
||||
*/
|
||||
static jerry_value_t
|
||||
test_validator1_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator1_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
|
||||
bool arg1;
|
||||
double arg2 = 0.0;
|
||||
char arg3[5] = "1234";
|
||||
@@ -132,7 +129,7 @@ test_validator1_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
jerryx_arg_function (&arg4, JERRYX_ARG_OPTIONAL)
|
||||
};
|
||||
|
||||
jerry_value_t is_ok = jerryx_arg_transform_this_and_args (this_val,
|
||||
jerry_value_t is_ok = jerryx_arg_transform_this_and_args (call_info_p->this_value,
|
||||
args_p,
|
||||
args_cnt,
|
||||
mapping,
|
||||
@@ -210,13 +207,10 @@ my_custom_transform (jerryx_arg_js_iterator_t *js_arg_iter_p, /**< available JS
|
||||
* arg1: should pass the custom tranform function.
|
||||
*/
|
||||
static jerry_value_t
|
||||
test_validator2_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator2_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
|
||||
my_type_a_t *thing_p;
|
||||
|
||||
jerryx_arg_t mapping[] =
|
||||
@@ -227,7 +221,7 @@ test_validator2_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
jerryx_arg_custom (NULL, 5, my_custom_transform)
|
||||
};
|
||||
|
||||
jerry_value_t is_ok = jerryx_arg_transform_this_and_args (this_val,
|
||||
jerry_value_t is_ok = jerryx_arg_transform_this_and_args (call_info_p->this_value,
|
||||
args_p,
|
||||
args_cnt,
|
||||
mapping,
|
||||
@@ -256,14 +250,10 @@ test_validator2_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
*
|
||||
*/
|
||||
static jerry_value_t
|
||||
test_validator3_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator3_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
|
||||
bool arg1 = false;
|
||||
bool arg2 = false;
|
||||
|
||||
@@ -277,7 +267,7 @@ test_validator3_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
jerryx_arg_boolean (&arg2, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL),
|
||||
};
|
||||
|
||||
jerry_value_t is_ok = jerryx_arg_transform_this_and_args (this_val,
|
||||
jerry_value_t is_ok = jerryx_arg_transform_this_and_args (call_info_p->this_value,
|
||||
args_p,
|
||||
args_cnt,
|
||||
mapping,
|
||||
@@ -323,13 +313,11 @@ test_validator3_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
* Calling jerryx_arg_transform_object_properties directly.
|
||||
*/
|
||||
static jerry_value_t
|
||||
test_validator_prop1_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_prop1_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
bool native1 = false;
|
||||
@@ -366,13 +354,11 @@ test_validator_prop1_handler (const jerry_value_t func_obj_val, /**< function ob
|
||||
* using jerryx_arg_object_properties.
|
||||
*/
|
||||
static jerry_value_t
|
||||
test_validator_prop2_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_prop2_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
bool native1 = false;
|
||||
double native2 = 0;
|
||||
@@ -416,13 +402,11 @@ test_validator_prop2_handler (const jerry_value_t func_obj_val, /**< function ob
|
||||
} /* test_validator_prop2_handler */
|
||||
|
||||
static jerry_value_t
|
||||
test_validator_prop3_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_prop3_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
bool native1 = false;
|
||||
@@ -456,13 +440,11 @@ test_validator_prop3_handler (const jerry_value_t func_obj_val, /**< function ob
|
||||
* args_p[0-2] are uint8, args_p[3-5] are int8, args_p[6-8] are uint32, args_p[9-11] are int32.
|
||||
*/
|
||||
static jerry_value_t
|
||||
test_validator_int1_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_int1_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
uint8_t num0, num1, num2;
|
||||
int8_t num3, num4, num5;
|
||||
@@ -511,13 +493,11 @@ test_validator_int1_handler (const jerry_value_t func_obj_val, /**< function obj
|
||||
} /* test_validator_int1_handler */
|
||||
|
||||
static jerry_value_t
|
||||
test_validator_int2_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_int2_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
int8_t num0, num1, num2, num3, num4, num5, num6, num7, num8, num9;
|
||||
num8 = 123;
|
||||
@@ -561,13 +541,11 @@ test_validator_int2_handler (const jerry_value_t func_obj_val, /**< function obj
|
||||
} /* test_validator_int2_handler */
|
||||
|
||||
static jerry_value_t
|
||||
test_validator_int3_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_int3_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
int8_t num0;
|
||||
|
||||
@@ -590,13 +568,11 @@ test_validator_int3_handler (const jerry_value_t func_obj_val, /**< function obj
|
||||
} /* test_validator_int3_handler */
|
||||
|
||||
static jerry_value_t
|
||||
test_validator_array1_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_array1_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
double native1 = 0;
|
||||
double native2 = 0;
|
||||
@@ -636,13 +612,11 @@ test_validator_array1_handler (const jerry_value_t func_obj_val, /**< function o
|
||||
} /* test_validator_array1_handler */
|
||||
|
||||
static jerry_value_t
|
||||
test_validator_array2_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_array2_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
double native1 = 0;
|
||||
@@ -794,13 +768,11 @@ jerry_arg_to_double_or_bool_t (jerryx_arg_js_iterator_t *js_arg_iter_p,
|
||||
* order doesn't matter (so we'll call it twice with the orders reversed).
|
||||
*/
|
||||
static jerry_value_t
|
||||
test_validator_restore_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
test_validator_restore_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (call_info_p);
|
||||
|
||||
double_or_bool_t arg1;
|
||||
double_or_bool_t arg2;
|
||||
@@ -853,19 +825,17 @@ test_utf8_string (void)
|
||||
} /* test_utf8_string */
|
||||
|
||||
static jerry_value_t
|
||||
create_object_a_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
create_object_a_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
TEST_ASSERT (jerry_value_is_object (this_val));
|
||||
TEST_ASSERT (jerry_value_is_object (call_info_p->this_value));
|
||||
|
||||
my_thing_a.x = 1;
|
||||
jerry_set_object_native_pointer (this_val,
|
||||
jerry_set_object_native_pointer (call_info_p->this_value,
|
||||
&my_thing_a,
|
||||
&thing_a_info);
|
||||
|
||||
@@ -873,19 +843,17 @@ create_object_a_handler (const jerry_value_t func_obj_val, /**< function object
|
||||
} /* create_object_a_handler */
|
||||
|
||||
static jerry_value_t
|
||||
create_object_b_handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
const jerry_value_t this_val, /**< this value */
|
||||
create_object_b_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< arguments list */
|
||||
const jerry_length_t args_cnt) /**< arguments length */
|
||||
{
|
||||
JERRY_UNUSED (func_obj_val);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_cnt);
|
||||
|
||||
TEST_ASSERT (jerry_value_is_object (this_val));
|
||||
TEST_ASSERT (jerry_value_is_object (call_info_p->this_value));
|
||||
|
||||
my_thing_b.x = false;
|
||||
jerry_set_object_native_pointer (this_val,
|
||||
jerry_set_object_native_pointer (call_info_p->this_value,
|
||||
&my_thing_b,
|
||||
&thing_b_info);
|
||||
|
||||
|
||||
@@ -24,13 +24,11 @@
|
||||
#include <string.h>
|
||||
|
||||
static jerry_value_t
|
||||
method_hello (const jerry_value_t jfunc, /**< function object */
|
||||
const jerry_value_t jthis, /**< function this */
|
||||
method_hello (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t jargv[], /**< arguments */
|
||||
const jerry_length_t jargc) /**< number of arguments */
|
||||
{
|
||||
(void) jfunc;
|
||||
(void) jthis;
|
||||
(void) call_info_p;
|
||||
(void) jargv;
|
||||
return jerry_create_number (jargc);
|
||||
} /* method_hello */
|
||||
|
||||
Reference in New Issue
Block a user