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:
committed by
László Langó
parent
c818930cdc
commit
b3f4aa6816
@@ -52,10 +52,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, write) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
@@ -86,10 +85,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, read) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
@@ -115,10 +113,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, period) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
@@ -142,10 +139,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, period_ms) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
@@ -169,10 +165,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, period_us) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
@@ -196,10 +191,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, pulsewidth) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
@@ -223,10 +217,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, pulsewidth_ms) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
@@ -250,10 +243,9 @@ DECLARE_CLASS_FUNCTION(PwmOut, pulsewidth_us) {
|
||||
|
||||
// Extract native PwmOut 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 PwmOut pointer");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user