void showprop(const char * name){v8::Local<v8::Name> val = v8::String::NewFromUtf8(m_Isolate, name);Local<Object> obj = val->ToObject(m_Context).ToLocalChecked();
Why do you say its global?
At the sample code, I read the K object from a specific context.
--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/c5187f07-6220-471b-958e-ab12f74bb614o%40googlegroups.com.
You can access your K object via the context's global object, and then iterate it's properties from there.
On Thu, Jul 2, 2020 at 1:47 PM <oreng...@gmail.com> wrote:
--i"m trying to get the variable from context / global without success.Any idea how to do it correctly?
On Wednesday, July 1, 2020 at 7:36:48 PM UTC+3, oreng...@gmail.com wrote:Thanks, I got you.
Do you know how I retrieve objects from context?
On Wednesday, July 1, 2020 at 1:31:54 PM UTC+3, Jakob Kummerow wrote:On Wed, Jul 1, 2020 at 12:13 PM <oreng...@gmail.com> wrote:Why do you say its global?After evaluating the string "const K = {...}", K is a global variable in the provided context.At the sample code, I read the K object from a specific context.No, that's not what you're doing. You're creating an object wrapper around a string "K". That object creation needs a context, but that's not the same as reading a variable from that context.
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-...@googlegroups.com.
// Get global object (effectively globalThis)v8::Local<v8::Object> global_obj = context->Global();// Get K from global object (effectively globalThis["K"])v8::Local<v8::Object> K_obj = global_obj->Get(context, v8::String::NewFromUtf8(isolate, "K"))// Get the properties from K (effectively Object.keys(globalThis["K"]))v8::Local<Array> arr = K_obj->GetPropertyNames(context);
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/01ac6bc4-a9fe-493c-8bdc-9cb28998379co%40googlegroups.com.
I compile & run this string "const K = {a: 1, b: 2}; "But when I try to get properties of object K , I got undefined at val_k , Any idea why ?v8::Local<v8::Object> global_obj = m_Context->Global();Local<Value> val_k = global_obj->Get(m_Context, v8::String::NewFromUtf8(m_Isolate, "K")).ToLocalChecked();Attached sample that reproduce itThanksOren
--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/5610ff0d-acc1-4d95-9b91-272301386307o%40googlegroups.com.
"const" doesn't define a property in the global object. Does it work if you use "var K" instead of "const K"?
On Fri, Jul 3, 2020, 12:02 <oreng...@gmail.com> wrote:
--I compile & run this string "const K = {a: 1, b: 2}; "But when I try to get properties of object K , I got undefined at val_k , Any idea why ?v8::Local<v8::Object> global_obj = m_Context->Global();Local<Value> val_k = global_obj->Get(m_Context, v8::String::NewFromUtf8(m_Isolate, "K")).ToLocalChecked();Attached sample that reproduce itThanksOren
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/abcefcd3-41a0-4690-9c8f-577d8a7bf525o%40googlegroups.com.