> GetPort() needs a HandleScope and you need to pass the return value through scope.Close(...).
This is false. v8 builds a HandleScope for you automatically when a function or accessor is called through JS. You only need to use HandleScope at the very very top level (node.cc, or stuff like fibers and threads-a-gogo). You may also want to use HandleScope if you want to manage your handle lifetimes manually when doing lots of work in v8 c++ land. On Wed, Jun 27, 2012 at 8:11 AM, Ben Noordhuis <[email protected]> wrote: > On Wed, Jun 27, 2012 at 7:19 AM, Dave Horton <[email protected]> wrote: > > Any suggestions along these lines welcome. I'm writing my first C++ > add-in > > and struggling with a couple of things: > > > > 1) I can use gdb to set breakpoints in my code, but node-gyp by default > > doesn't include symbols and I haven't been able to figure out how to get > it > > to generate debug code (non optimized, no symbols). I tried "defines": > > ['DEBUG'] but that didn't work.... > > > > 2) I tried putting simple printf's in my code to stdout or stderr but > they > > don't appear so I assume they are being gobbled up by node some how. > > > > For a first exercise, I am simply trying to create a module that returns > a > > wrapped C++ object, with a property which when accessed in JS triggers a > C++ > > getter. I can compile the module ok, and my test script can create an > > instance, but it appears my getter is never called for some reason (it > > should return an integer value of 5060 but it returns undefined). For > > anyone willing to point out what I assume is an obvious flaw, I have > posted > > a gist here: git://gist.github.com/3001626.git > > > > I've read the docs on nodejs.org on the basics of creating modules, but > if > > anyone knows of useful sample code for a newbie to node (knowledgeable of > > javascript and C++) I'd appreciate the pointer. Thanks > > I just tried your example and it works for me, i.e. ua.port == 5060. > That it works may be accidental, though - there is at least one bug. > :-) > > GetPort() needs a HandleScope and you need to pass the return value > through scope.Close(...). > > -- > 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 > -- 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
