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 On Sunday, February 10, 2013 3:47:02 AM UTC-5, mscdex wrote: > > On Feb 9, 10:47 pm, Paul <[email protected]> wrote: > > So far I've been able to take strings and functions as parameters, and > even > > emit events with objects. However, for the life of me, I can't figure > out > > how to access an object passed in as a function parameter. I need to > pull > > out individual values by key name and pass these values as C strings to > the > > API I'm wrapping. > > Something like this: > > // { strarg: 'hello world' } > Local<Object> obj = args[0]->ToObject(); > String::Utf8Value utf8str(obj->Get(String::New("strarg"))); > char *str = *utf8str; > > You may need to make a copy of the C string if the library you're > interfacing with doesn't already do it and you need to keep it around > after the string is destructed when it goes out of scope. > > v8 api docs: http://izs.me/v8-docs/annotated.html > -- -- 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.
