Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce #[napi] procedural macro to automation development boilerplate #696

Merged
merged 18 commits into from
Sep 22, 2021

Conversation

forehalo
Copy link
Member

@forehalo forehalo commented Aug 10, 2021

See the discussion: #684. This PR would include all the things listed below

  • implements the macro: #[napi]
    • function

    • js <=> rust value mapping

      • boolean/numbers
      • strings
      • T | undefined <=> Option
      • Class <=> Struct
      • literal object
      • Array <=> Vec<_>
      • enum
      • callback
      • buffer
    • auto-exports

      • functions
      • structs
      • impls
      • enum
  • runtime arguments validation
    • arguments length
    • arguments type(#[napi(strict)], would be slow)
  • typescript type generation
  • testing

What would come with releases later on:

  • typed array
  • async functions
  • auto serde serialization/deserialization

Greatly thank wasm_bindgen for where the idea originally coming from when exploring it's codebase, and node_bindgen for the idea of implicit exports registering at runtime.

@forehalo
Copy link
Member Author

good start

image

@forehalo forehalo force-pushed the napi_bindgen branch 6 times, most recently from f6d7e98 to 139c002 Compare August 18, 2021 15:47
@forehalo forehalo force-pushed the napi_bindgen branch 4 times, most recently from 7bde75a to 703a319 Compare August 22, 2021 13:49
@jaredpalmer
Copy link

Just want to say that this PR is awesome. This will dramatically lower the barrier to entry for JS devs just learning Rust while also removing boilerplate.

+1000000000000 for this

@forehalo forehalo force-pushed the napi_bindgen branch 3 times, most recently from 4d3fbb1 to e85a387 Compare August 26, 2021 01:49
@forehalo
Copy link
Member Author

@jaredpalmer It's truly happening and we almost get there. The things left are just cleaning up and covering cases.

@Brooooooklyn Brooooooklyn added this to In progress in 2.0 Sep 19, 2021
@forehalo forehalo changed the title [WIP] Introduce #[napi] procedural macro to automation development boilerplate Introduce #[napi] procedural macro to automation development boilerplate Sep 21, 2021
@Brooooooklyn
Copy link
Sponsor Member

napi-rs napi-rs-compat neon node-bindgen
Sum (a + b) 36 121 906 ops/s 100% 36 021 114 ops/s 99.72% 9 438 807 ops/s 26.13% 7 522 062 ops/s 20.82%
Concat(Hello + " world") 4 526 668 ops/s 100% 4 336 416 ops/s 95.95% 3 973 988 ops/s 85.09% 2 747 707 ops/s 60.93%

@Brooooooklyn Brooooooklyn merged commit 2467b71 into main Sep 22, 2021
@Brooooooklyn Brooooooklyn deleted the napi_bindgen branch September 22, 2021 17:29
@forehalo forehalo moved this from In progress to Done in 2.0 Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
2.0
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants