Re: [v8-users] How to retrieve a class defined in a module?

2020-11-27 Thread Ben Ernst
Thanks for that thought Alex! Drafting a reply to you led me to the answer, which is obvious in hindsight. Yes, I could just get "lamingtons" in this case, but that wouldn't help me if it was a non-trivial accessor. In javascript I would be able to call "instance.numberOfLamingtons". In this cas

Re: [v8-users] How to retrieve a class defined in a module?

2020-11-27 Thread Alex Kodat
You wouldn't call it any more than you "call" it in JavaScript. You just get the value via the Object Get function: Local pastries = object->Get(context, String::NewFromUtf8( isolate, "lamingtons").ToLocalChecked()); On Friday, November 27, 2020 at 4:59:00 AM UTC-5 boi...@gmail.com wrote: > Th

Re: [v8-users] How to retrieve a class defined in a module?

2020-11-27 Thread Ben Ernst
There's one thing I'm struggling with here. Given the simple class definition below, using the V8 C++ API I can call the ordinary function "lamingtonsIsUndefined", but how would I call the accessor "get numberOfLamingtons()"? Many thanks in advance, Ben export class DemonstrationClass { constr

Re: [v8-users] How to retrieve a class defined in a module?

2020-11-22 Thread Ben Ernst
Thanks for the advice, that got me back on track. The failure mentioned in my original post only occurs when there's nothing at all exported from the module. I speculate the namespace object gets garbage collected in that situation. When I tested with actual valid modules, everything works fine.

Re: [v8-users] How to retrieve a class defined in a module?

2020-11-17 Thread Ben Ernst
Thank you for the advice Camillo, the test you referred me to is very helpful. I will prepare a good code sample and come back to this conversation. Regards, Ben On Tue, 17 Nov 2020 at 19:54, Camillo Bruni wrote: > Hi, > > The ModuleNamespace >

Re: [v8-users] How to retrieve a class defined in a module?

2020-11-17 Thread Camillo Bruni
Hi, The ModuleNamespace object is the proper choice, you can have a look at the existing tests

[v8-users] How to retrieve a class defined in a module?

2020-11-16 Thread Ben Ernst
I am migrating my V8 code from using "plain scripts" to using "ES6 Modules". There are a few concepts that I am struggling with. First, how might I retrieve a class definition defined in a module? Previously I would have used the "global" object on the "context" (i.e. context->Global()), and f