Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wotb-rs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
typescript
wotb-rs
Commits
6503d2fe
Commit
6503d2fe
authored
7 years ago
by
nanocryk
Browse files
Options
Downloads
Patches
Plain Diff
feature : class export with method
parent
fed24c36
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
native/src/lib.rs
+24
-11
24 additions, 11 deletions
native/src/lib.rs
with
24 additions
and
11 deletions
native/src/lib.rs
+
24
−
11
View file @
6503d2fe
//! `duniter-rs-wotb-js` is a crate providing Javascript bindings of `duniter-rs-wotb`.
#![deny(missing_docs,
/*missing_debug_implementations, */
missing_copy_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features,
unused_import_braces,
unused_qualifications)]
#[macro_use]
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! {
Err
(
Throw
)
}
}
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
|
{
wot
.to_file
(
path
.as_str
())
});
Ok
(
JsBoolean
::
new
(
scope
,
result
)
.upcast
())
}
}
}
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
));
Ok
(())
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment