Native callback in embedding jerry when object is to be freed.
JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
This commit is contained in:
@@ -40,6 +40,8 @@ const char *test_source = (
|
||||
"}"
|
||||
);
|
||||
|
||||
bool test_api_is_free_callback_was_called = false;
|
||||
|
||||
/**
|
||||
* Initialize Jerry API value with specified boolean value
|
||||
*/
|
||||
@@ -115,6 +117,15 @@ handler (const jerry_api_object_t *function_obj_p,
|
||||
return true;
|
||||
} /* handler */
|
||||
|
||||
static void
|
||||
handler_construct_freecb (uintptr_t native_p)
|
||||
{
|
||||
assert (native_p == (uintptr_t) 0x0012345678abcdefull);
|
||||
printf ("ok object free callback\n");
|
||||
|
||||
test_api_is_free_callback_was_called = true;
|
||||
} /* handler_construct_freecb */
|
||||
|
||||
static bool
|
||||
handler_construct (const jerry_api_object_t *function_obj_p,
|
||||
const jerry_api_value_t *this_p,
|
||||
@@ -135,6 +146,9 @@ handler_construct (const jerry_api_object_t *function_obj_p,
|
||||
|
||||
jerry_api_set_object_native_handle (this_p->v_object, (uintptr_t) 0x0012345678abcdefull);
|
||||
|
||||
bool is_set = jerry_api_set_object_free_callback (this_p->v_object, handler_construct_freecb);
|
||||
assert (is_set);
|
||||
|
||||
return true;
|
||||
} /* handler_construct */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user