-
Notifications
You must be signed in to change notification settings - Fork 684
Allow the JS objects to have more than one native pointer data #2814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the JS objects to have more than one native pointer data #2814
Conversation
Note: The patch contains API breaking changes so if the reviewers support this idea this should be land before the 2.0 release. I highly recommend to check this example to understand the motivation of the PR. |
200b35c
to
cbd7747
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a nice change.
{ | ||
void *data_p; /**< points to the data of the object */ | ||
ecma_object_native_info_t *info_p; /**< native info */ | ||
struct ecma_native_pointer_t *next_p; /**< points to the next ecma_native_pointer_t element */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be changed later but adding a pointer effectively doubles the size of this structure. (Jerry allocates memory in 8 byte blocks)
I like this proposal. I have two comments on this:
|
There might be cases that the native pointer might be NULL yet the JS objects been bound with gc-callbacks. |
@legendecas Is this a frequently used structure? Could you show me an example for it? |
@rerobika @legendecas I don't mind to keep the NULL value as a valid native pointer. |
I don't see the frequent usage of this behavior nor any example for it, sorry for that. Yet if the API doesn't force the native pointer to be non-NULL, then that is a valid usage anyway. |
dc065fe
to
a3cdc7b
Compare
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 [email protected]
a3cdc7b
to
43b44a7
Compare
@LaszloLango Thanks for the review, I updated the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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 [email protected]