-
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
* Consider undefined/null for optional rust types * Fix version of dependency (nj-core) * Add test
- Loading branch information
1 parent
7c87f99
commit 2b2ac97
Showing
15 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "node-bindgen" | ||
version = "6.0.1" | ||
version = "6.0.2" | ||
authors = ["Fluvio Contributors <[email protected]>"] | ||
edition = "2021" | ||
description = "easy way to write nodejs module using rust" | ||
|
@@ -17,7 +17,7 @@ uuid = ["nj-core/convert-uuid"] | |
|
||
[dependencies] | ||
nj-sys = { path = "nj-sys", version = "4.0.0", optional = true } | ||
nj-core = { path = "nj-core", version = "6.0.0", optional = true } | ||
nj-core = { path = "nj-core", version = "6.0.1", optional = true } | ||
nj-build = { path = "nj-build", version = "0.3.0", optional = true } | ||
nj-derive = { path = "nj-derive", version = "3.2.0", optional = true } | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ members = [ | |
"tuples", | ||
"uuid", | ||
"logging", | ||
"option", | ||
] | ||
|
||
|
||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
dylib |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "nj-example-option" | ||
version = "0.0.0" | ||
authors = ["fluvio.io"] | ||
edition = "2021" | ||
publish = false | ||
|
||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
|
||
[dependencies] | ||
node-bindgen = { workspace = true} | ||
fluvio-future = { workspace = true} | ||
|
||
[build-dependencies] | ||
node-bindgen = { path = "../../", default-features = false, features = ["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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
all: build | ||
|
||
build: | ||
nj-cli build | ||
|
||
test: build | ||
node test.js | ||
|
||
|
||
clean: | ||
rm -rf dist | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
simple hello world |
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 |
---|---|---|
@@ -0,0 +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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use node_bindgen::derive::node_bindgen; | ||
|
||
#[node_bindgen] | ||
fn test(a: Option<i32>, b: Option<i32>) -> i32 { | ||
if let (Some(a), Some(b)) = (a, b) { | ||
a + b | ||
} else { | ||
a.unwrap_or(b.unwrap_or(1)) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const assert = require('assert'); | ||
|
||
let addon = require('./dist'); | ||
|
||
assert.equal(addon.test(100, 200), 300); | ||
|
||
assert.equal(addon.test(100), 100); | ||
|
||
assert.equal(addon.test(undefined, 200), 200); | ||
|
||
assert.equal(addon.test(null, 200), 200); | ||
|
||
assert.equal(addon.test(100, undefined), 100); | ||
|
||
assert.equal(addon.test(100, null), 100); | ||
|
||
assert.equal(addon.test(undefined, undefined), 1); | ||
|
||
assert.equal(addon.test(null, null), 1); |
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