Ah... Yes, you're right, that's got to be it.  My string parameter was 
getting converted to char* on assignment to the baton.  When I switched 
from a string parameter to an object, I ripped out that string conversion 
and ended up putting a JS value directly in the baton and tried to use it 
in another thread.  I'll move that helper function call (with the 
obj->Get()) so it happens prior to the work function and that will likely 
give me the results I'm looking for.

Thanks!!

- Paul

On Sunday, February 10, 2013 9:07:00 AM UTC-5, Ben Noordhuis wrote:
>
> On Sun, Feb 10, 2013 at 2:28 PM, Paul <[email protected]<javascript:>> 
> wrote: 
> > Thanks for the reply!  I was using Local<Object>::Cast(args[0]) instead 
> of 
> > ->ToObject() so I switched that out to match your code below.  In my 
> module 
> > I take the Local<Object> from args[], assign it to a baton, pass the 
> baton 
> > to my work function and then reference it there to pass to a helper 
> function 
> > to read the values from the object.  However even with the below code 
> I'm 
> > still dumping core on obj->Get() in this helper function -- where I've 
> been 
> > getting stopped thus far.  This overall pattern has worked for me with a 
> > String parameter, but not with an Object parameter.  I guess I'll have 
> to 
> > delve into gdb to investigate further -- something I've tried my best to 
> > avoid up 'til now... :-) 
> > 
> > I must say, though, that working on this native module has given me a 
> > tremendous appreciation for the "heavy lifting" many of you do so the 
> rest 
> > of us can happily play in JavaScript land!  :-) 
> > 
> > Thanks again, 
> > Paul 
>
> If the object outlives the function it's used in, you have to make it 
> persistent. That is: 
>
>   Persistent<Object> persistent = Persistent<Object>::New(obj); 
>
> And once you're done with it: 
>
>   persistent.Dispose(); 
>   persistent.Clear();  // Optional but catches use-after-free bugs. 
>
> You mention a work function.  If that runs in another thread, forget 
> what I said - it's unsafe to access JS values from other threads. 
> You'll have to make copies of the properties you are interested in (as 
> C style primitives, not JS values.) 
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to