Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created January 18, 2011 20:47
Show Gist options
  • Save springmeyer/785112 to your computer and use it in GitHub Desktop.
Save springmeyer/785112 to your computer and use it in GitHub Desktop.
It appears that node REPL is calling the functions on a c++ addon as part of inspection, of of course this fails if the functions need arguments. Is this intended?
$ node -e "require('srs')"
util.js:91
return value.inspect(recurseTimes);
^
TypeError: first argument must be srs string in any form readable by OGR, like WKT (.prj file) or a proj4 string
at format (util.js:91:20)
at Object.inspect (util.js:254:10)
at Object.format (console.js:11:25)
at Object.<anonymous> (console.js:40:31)
at node.js:607:13
My addon code looks like:
extern "C" {
static void init (Handle<Object> target)
{
NODE_SET_METHOD(target, "inspect", inspect);
// node-srs version
target->Set(String::NewSymbol("version"), String::New("0.1.0"));
// versions of deps
Local<Object> versions = Object::New();
versions->Set(String::NewSymbol("node"), String::New(NODE_VERSION+1));
versions->Set(String::NewSymbol("v8"), String::New(V8::GetVersion()));
// ogr/osr ?
target->Set(String::NewSymbol("versions"), versions);
}
NODE_MODULE(_srs, init);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment