-
Notifications
You must be signed in to change notification settings - Fork 79
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
Don't expose JS_GetPropertyInternal in the public API #329
Conversation
bba0971
to
f651603
Compare
Good move! I have a few remarks:
|
Not exactly. My observation was that JS_SetProperty and friends consume / take ownership of the value but not the key, i.e., you have to JS_FreeValue the key but not the value (and that requirement isn't documented anywhere either, AFAICT.) Half-way APIs are the worst so my suggestion was to either consume both or neither, but not one or the other. That's definitely a backwards incompatible change, though, and a subtle one, too. I believe Charlie suggested versioning the API, to make it opt-in. |
quickjs.c
Outdated
static JSValue JS_GetPropertyInternal2(JSContext *ctx, JSValue obj, | ||
JSAtom prop, JSValue this_obj, | ||
JSInlineCache* ic, BOOL throw_ref_error) |
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.
Style nit: line up arguments
917df30
to
baff254
Compare
Pushed an update, PTAL!
Done.
I think any change there is to be done in another PR. That said, to Ben's point on half-way APIs: looks like there is some (weird) consistency going on: atoms are never consumed in JS APIs. Perhaps a way around it would be with some documentation macros so the caller would see if a reference would be consumed or not. I don't have good names at the tip of my tongue though.
Makes sense! I'll add that. |
After further thinking, I think we should just leave it as is for now.
Yes, the atoms are never consumed. This is especially true for
This was the very purpose of It would be nice to have tool to verify refcounting on |
Agreed. Can you please take a final look? Is this good to go? |
The prototype for |
f5923c7
to
3ee2bb7
Compare
Ops, I had missed that one. Fixed! |
No description provided.