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.