-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add unit tests for syntax checking remove special handling for Jscallback in the code generator use unified trait to handle cb argument extraction update version add support for optional argument
- Loading branch information
Showing
96 changed files
with
3,960 additions
and
1,973 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
|
||
DYLIB = ../target/debug/libnj_example_async_cb.dylib | ||
|
||
all: build | ||
|
||
|
||
build: | ||
nj-cli build | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
simple hello world callback | ||
callback inside async fn |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
fn main() { | ||
|
||
node_bindgen::build::configure(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
|
||
use std::time::Duration; | ||
|
||
use flv_future_aio::timer::sleep; | ||
use node_bindgen::derive::node_bindgen; | ||
|
||
|
||
#[node_bindgen] | ||
async fn basic<F: Fn(f64,f64)>( seconds: i32, cb: F) { | ||
|
||
sleep(Duration::from_secs(1)).await; | ||
cb(seconds as f64,(seconds*2) as f64); | ||
|
||
} | ||
|
||
|
||
#[node_bindgen] | ||
async fn hello<F: Fn(f64,String)>( seconds: i32, cb: F) { | ||
|
||
// println!("sleeping"); | ||
sleep(Duration::from_secs(seconds as u64)).await; | ||
// println!("woke from time"); | ||
|
||
cb(10.0,"hello world".to_string()); | ||
|
||
} | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
let addon = require('./dist'); | ||
const assert = require('assert'); | ||
|
||
|
||
addon.hello(1,function(val,msg){ | ||
assert.equal(val,10); | ||
assert.equal(msg,"hello world"); | ||
console.log("callback test succeed"); | ||
}); | ||
|
||
|
||
addon.basic(10,function(val,val2){ | ||
assert.equal(val,10); | ||
assert.equal(val2,20); | ||
console.log("callback test succeed"); | ||
}); | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
|
||
DYLIB = ../target/debug/libnj_example_cb.dylib | ||
|
||
all: build | ||
|
||
build: | ||
|
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Oops, something went wrong.