Skip to content

Instantly share code, notes, and snippets.

@dherman
Created January 19, 2016 23:07
Show Gist options
  • Save dherman/cb922331d62e4838315d to your computer and use it in GitHub Desktop.
Save dherman/cb922331d62e4838315d to your computer and use it in GitHub Desktop.
var addon = require('../native');
console.log(addon.test({ foo: ["bar"] }));
#[macro_use]
extern crate neon;
use neon::vm::{Call, JsResult};
use neon::js::{JsObject, JsValue, Object};
fn test(call: Call) -> JsResult<JsValue> {
let scope = call.scope;
let arg = try!(call.arguments.require(scope, 0));
let obj = try!(arg.check::<JsObject>());
let foo = try!(obj.get(scope, "foo"));
let obj = try!(foo.check::<JsObject>());
obj.get(scope, 0)
}
register_module!(m, {
m.export("test", test)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment