Re: [nodejs] Pass an int to a node.js addon

2012-10-29 Thread Ben Noordhuis
On Sun, Oct 28, 2012 at 4:52 AM, NodeNinja wrote: > Ben, Thanks for the code snippet is an array of pointers also created in the > same style? Depends on what you mean by 'pointer'. JS the language doesn't have a concept of pointers. V8 lets you store pointers with v8::Object::SetPointerInInter

Re: [nodejs] Pass an int to a node.js addon

2012-10-27 Thread NodeNinja
> If you want some crazy v8 type conversion library, there is v8-juice: > http://code.google.com/p/v8-juice/wiki/ConvertingTypes > > Thats wonderful info Dan!! Many thanks! > -- Ben, Thanks for the code snippet is an array of pointers also created in the same style?

Re: [nodejs] Pass an int to a node.js addon

2012-10-26 Thread Ben Noordhuis
On Fri, Oct 26, 2012 at 2:00 PM, NodeNinja wrote: > >> >> int length = args[0]->Int32Value(); >> if (length <= 0) { >> return ThrowException(Exception::Error(String::New("BAM"))); >> } >> unsigned char* buffer = new unsigned char[length]; > > > Thanks for that info Ben, > > Further to that is th

Re: [nodejs] Pass an int to a node.js addon

2012-10-26 Thread Dean Mao
If you want some crazy v8 type conversion library, there is v8-juice: http://code.google.com/p/v8-juice/wiki/ConvertingTypes I've not used it before, but it came highly recommended from others. It's not too useful for converting one type, but if you have composite types, it might make things easi

Re: [nodejs] Pass an int to a node.js addon

2012-10-26 Thread NodeNinja
> > int length = args[0]->Int32Value(); > if (length <= 0) { > return ThrowException(Exception::Error(String::New("BAM"))); > } > unsigned char* buffer = new unsigned char[length]; > Thanks for that info Ben, Further to that is there a way to pass and return array of pointers I have som

Re: [nodejs] Pass an int to a node.js addon

2012-10-26 Thread Ben Noordhuis
On Fri, Oct 26, 2012 at 8:43 AM, NodeNinja wrote: > My original c++ function had the following signature > > unsigned char* random(int length); > > To use this as an add-on I modified it to > > Handle random(const Arguments& args) { > > > if(args[0]->IsInt32()){ > > Local length = args[0]->ToInt3

[nodejs] Pass an int to a node.js addon

2012-10-25 Thread NodeNinja
My original c++ function had the following signature unsigned char* random(int length); To use this as an add-on I modified it to Handle random(const Arguments& args) { if(args[0]->IsInt32()){ Local length = args[0]->ToInt32(); // Now here I want to create an array like this "unsigned char