Commit 6503d2fe authored by nanocryk's avatar nanocryk
Browse files

feature : class export with method

parent fed24c36
//! `duniter-rs-wotb-js` is a crate providing Javascript bindings of `duniter-rs-wotb`.
/*missing_debug_implementations, */
trivial_casts, trivial_numeric_casts,
unused_import_braces, unused_qualifications)]
extern crate neon;
extern crate duniter_rs_wotb;
use neon::vm::Throw;
use neon::js::{JsInteger, JsString};
use neon::js::{Value, JsInteger, JsString, JsBoolean, JsFunction, Object};
use neon::js::class::{Class, JsClass};
use neon::mem::Handle;
use neon::vm::{Throw, Lock};
use duniter_rs_wotb::WebOfTrust;
......@@ -44,5 +39,23 @@ declare_types! {
method to_file(call) {
let scope = call.scope;
let path = try!(try!(call.arguments.require(scope, 0)).to_string(scope)).value();
let result = call.arguments.this(scope).grab(|wot| {
Ok(JsBoolean::new(scope, result).upcast())
\ No newline at end of file
register_module!(m, {
let class: Handle<JsClass<JsWebOfTrust>> = try!(JsWebOfTrust::class(m.scope));
let constructor: Handle<JsFunction<JsWebOfTrust>> = try!(class.constructor(m.scope));
try!(m.exports.set("WebOfTrust", constructor));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment