Created
January 19, 2016 23:07
-
-
Save dherman/cb922331d62e4838315d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var addon = require('../native'); | |
console.log(addon.test({ foo: ["bar"] })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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