You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible right now to create an "External Object" which stores a C pointer to internal native data. However, what's not possible as far as I can see is being able to store arbitrary properties on an object which refer to JS values but aren't accessible from JS. For example in Duktape it's possible to:
duk_push_object(ctx);
/* populate new object with anything needed */duk_put_prop_string(ctx, -2, "\xff""hiddenObject");
That can be done with any object, whereas in Chakra you currently have to create an external object to store private data--and it's not possible to convert an existing standard JS object to an external one, either, which means that in native constructors for external objects, you can't use the automatic this and must instead return a fresh object from the constructor.
I propose an API that would either:
Add an API that converts an existing standard JS object to an External object, OR:
Add an API for storing "hidden" properties that could be accessed using Js[GS]etProperty() but not within JavaScript code. Perhaps something like JsCreateHiddenPropertyId().
The text was updated successfully, but these errors were encountered:
I'd like to add one more vote for such feature request.
The project I'm working on needs to map JS objects to C++ object and I'm experimenting moving our JS VM to ChakraCore. The external data support for all objects would be perfect. Right now I'm using code like this, setting an internal property (say, "__privdata"), which refers to an external object:
That appeared to be quite expensive (mostly due to the access to the property) when I ran a profile on some performance tests that exercised going back and forth from C++ to JS. Being able to simply set external data to any object would be much more convenient (and a lot faster I suppose).
@obastemur I saw that #3639 has the "experimental" disclaimer so I haven't tried it (and it's also referencing another issue - #3717). Is that something you're considering to add in the official versions soon?
It's possible right now to create an "External Object" which stores a C pointer to internal native data. However, what's not possible as far as I can see is being able to store arbitrary properties on an object which refer to JS values but aren't accessible from JS. For example in Duktape it's possible to:
That can be done with any object, whereas in Chakra you currently have to create an external object to store private data--and it's not possible to convert an existing standard JS object to an external one, either, which means that in native constructors for external objects, you can't use the automatic
this
and must instead return a fresh object from the constructor.I propose an API that would either:
Js[GS]etProperty()
but not within JavaScript code. Perhaps something likeJsCreateHiddenPropertyId()
.The text was updated successfully, but these errors were encountered: