Allow the JS objects to have more than one native pointer data (#2814)

Currently JS objects can only have one native pointer data which could be a limitation in special cases.
This patch allows to register multiple native infos, which can be accessed/associated with the corresponding `jerry_object_native_info_t`.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-04-16 07:50:49 +02:00
committed by László Langó
parent c818930cdc
commit b3f4aa6816
14 changed files with 436 additions and 180 deletions
@@ -47,10 +47,9 @@ DECLARE_CLASS_FUNCTION(AnalogIn, read) {
// Extract native AnalogIn pointer
void* void_ptr;
const jerry_object_native_info_t* type_ptr;
bool has_ptr = jerry_get_object_native_pointer(this_obj, &void_ptr, &type_ptr);
bool has_ptr = jerry_get_object_native_pointer(this_obj, &void_ptr, &native_obj_type_info);
if (!has_ptr || type_ptr != &native_obj_type_info) {
if (!has_ptr) {
return jerry_create_error(JERRY_ERROR_TYPE,
(const jerry_char_t *) "Failed to get native AnalogIn pointer");
}
@@ -73,10 +72,9 @@ DECLARE_CLASS_FUNCTION(AnalogIn, read_u16) {
// Extract native AnalogIn pointer
void* void_ptr;
const jerry_object_native_info_t* type_ptr;
bool has_ptr = jerry_get_object_native_pointer(this_obj, &void_ptr, &type_ptr);
bool has_ptr = jerry_get_object_native_pointer(this_obj, &void_ptr, &native_obj_type_info);
if (!has_ptr || type_ptr != &native_obj_type_info) {
if (!has_ptr) {
return jerry_create_error(JERRY_ERROR_TYPE,
(const jerry_char_t *) "Failed to get native AnalogIn pointer");
}