static jerry_value_t handler_construct (const jerry_value_t func_obj_val, /**< function object */ const jerry_value_t this_val, /**< this value */ const jerry_value_t args_p[], /**< arguments list */ const jerry_length_t args_cnt) /**< arguments length */ { printf ("ok construct %d %d %p %d\n", func_obj_val, this_val, args_p, args_cnt); JERRY_ASSERT (jerry_value_is_object (this_val)); JERRY_ASSERT (args_cnt == 1); JERRY_ASSERT (jerry_value_is_boolean (args_p[0])); JERRY_ASSERT (jerry_get_boolean_value (args_p[0]) == true); jerry_value_t field_name = jerry_create_string ((jerry_char_t *) "value_field"); jerry_set_property (this_val, field_name, args_p[0]); jerry_release_value (field_name); jerry_set_object_native_handle (this_val, (uintptr_t) 0x0000000000000000ull, handler_construct_freecb); uintptr_t ptr; bool is_ok = jerry_get_object_native_handle (this_val, &ptr); JERRY_ASSERT (is_ok && ptr == (uintptr_t) 0x0000000000000000ull); /* check if setting handle for second time is handled correctly */ jerry_set_object_native_handle (this_val, (uintptr_t) 0x0012345678abcdefull, handler_construct_freecb); return jerry_create_boolean (true); } /* handler_construct */
void iotjs_jval_set_object_native_handle(const iotjs_jval_t* jobj, uintptr_t ptr, JFreeHandlerType free_handler) { const IOTJS_VALIDATED_STRUCT_METHOD(iotjs_jval_t, jobj); IOTJS_ASSERT(iotjs_jval_is_object(jobj)); jerry_set_object_native_handle(_this->value, ptr, free_handler); }