Re: [v8-users] Re: running a script...

2014-01-29 Thread Jochen Eisinger
Yes, you'd usually either store a Persistent in the C++ class itself or maintain a map. The Persistent would usually be weak, so you get notified if the object is no longer needed by V8, and you can create new Local handles to the js object when needed. A common pattern to get from the js object

Re: [v8-users] Re: running a script...

2014-01-28 Thread Kevin Ingwersen
What exactly do you want to store; just one class instance - or do you have an existing C++ class that you are extending to be v8 compatible? There is a giant difference between these cases. The first case is what I am doing for nodejs currently; I am taking an existing c++ class (Fl_Window) an

Re: [v8-users] Re: running a script...

2014-01-28 Thread Jochen Eisinger
On Tue, Jan 28, 2014 at 9:20 AM, Pierre Saunier < pierre.saun...@ppmodeler.com> wrote: > Thanks a lot, I figure it also... But, I have still 3 (related) questions: > Why Persistent are not a subclass of handle? so that it is possible to use > Handle (Local) and persistent in the same way, without

Re: [v8-users] Re: running a script...

2014-01-26 Thread Jochen Eisinger
Right, Handle<> (and Local<>) can only be stack allocated and have to live within a HandleScope. If you want to store a reference to a V8 object, you need a Persistent<>, see esp. https://developers.google.com/v8/embed#handles best -jochen On Sat, Jan 25, 2014 at 8:52 PM, Kevin Ingwersen wrote:

Re: [v8-users] Re: running a script...

2014-01-25 Thread Kevin Ingwersen
To really store something: Persistent MyVal = Persistent::New( Value::New() ); Replace Value with something like Array, for example. That will give you an ever-existing value, not devoured by the GC. That, at least, works in my case o.o; Am Sa. Jan. 25 2014 19:07:14 schrieb mh: > Hi. >

Re: [v8-users] Re: running a script...

2014-01-25 Thread Kevin Ingwersen
>From what I know, you have to first create a Context…then create a new >v8::Script, which you can later ->Run();. See shell.cc, it has a function to >run a script. Am Sa. Jan. 25 2014 11:31:21 schrieb Niklas Voss: > I am myself fairly new to V8, but your handles are dependent on your > HandleS