The code you want is: int n = ( int )( args[ idx ]->Int32Value() );
On Thu, Oct 16, 2014 at 8:46 PM, Jeremy Darling <[email protected]> wrote: > I'm trying to wrap up some hardware libraries for use with Node.js and have > run into a casting issue. I did some searching around, but Google and the > cheat sheets failed me. Can anyone answer how I should properly convert an > argument to a unsigned int? > > Local<Integer> pin = Uint32::New(args[0]->NumberValue()); > Local<Integer> value = Uint32::New(args[1]->NumberValue()); > > if(set_pin(pin, value) < 0){ > ThrowException(Exception::TypeError(String::New("Could not set value on > port"))); > return scope.Close(Undefined()); > } > > Results in: > > CXX(target) Release/obj.target/gpio/src/gpio.o > ../src/gpio.cc: In function ‘v8::Handle<v8::Value> Method(const > v8::Arguments&)’: > ../src/gpio.cc:51:37: error: cannot convert ‘v8::Local<v8::Integer>’ to > ‘unsigned int’ for argument ‘1’ to ‘int set_pin(unsigned int, unsigned int)’ > > I'm no C expert, so any advice greatly appreciated. > > - Jeremy > > -- > Job board: http://jobs.nodejs.org/ > New group rules: > https://gist.github.com/othiym23/9886289#file-moderation-policy-md > Old group rules: > 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 unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nodejs/CAAhs7Eh77uyvBsuxhk6xw0QN6Vg-7bTFnNMzhAs7J9%2BphUZigQ%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAB9Rao-tO64kZH_bCrDiNqbMmZrj-rF4BtdjhqCjS3SH2Dbz-g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
