2467b7139b
* napi procedural macro for basic rust/JavaScript types * introduce the `compat-mode` for `napi` and `napi-derive` crates for backward compatible * remove #[inline] and let compiler to decide the inline behavior * cli now can produce the `.d.ts` file for native binding * many tests and example for the new procedural macro Co-authored-by: LongYinan <lynweklm@gmail.com>
75 lines
1.8 KiB
Rust
75 lines
1.8 KiB
Rust
#![allow(unused_variables)]
|
|
|
|
#[macro_use]
|
|
extern crate napi_derive;
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
|
|
use napi::{Env, JsObject, Result};
|
|
|
|
mod cleanup_env;
|
|
#[cfg(feature = "latest")]
|
|
mod napi4;
|
|
#[cfg(feature = "latest")]
|
|
mod napi5;
|
|
#[cfg(feature = "latest")]
|
|
mod napi6;
|
|
#[cfg(feature = "latest")]
|
|
mod napi7;
|
|
#[cfg(feature = "latest")]
|
|
mod napi8;
|
|
#[cfg(feature = "latest")]
|
|
mod tokio_rt;
|
|
|
|
mod array;
|
|
mod arraybuffer;
|
|
mod buffer;
|
|
mod class;
|
|
mod either;
|
|
mod env;
|
|
mod error;
|
|
mod external;
|
|
mod function;
|
|
mod global;
|
|
mod napi_version;
|
|
mod object;
|
|
mod serde;
|
|
mod string;
|
|
mod symbol;
|
|
mod task;
|
|
|
|
use napi_version::get_napi_version;
|
|
|
|
#[module_exports]
|
|
fn init(mut exports: JsObject, env: Env) -> Result<()> {
|
|
exports.create_named_method("getNapiVersion", get_napi_version)?;
|
|
array::register_js(&mut exports)?;
|
|
error::register_js(&mut exports)?;
|
|
string::register_js(&mut exports)?;
|
|
serde::register_js(&mut exports)?;
|
|
task::register_js(&mut exports)?;
|
|
external::register_js(&mut exports)?;
|
|
arraybuffer::register_js(&mut exports)?;
|
|
buffer::register_js(&mut exports)?;
|
|
either::register_js(&mut exports)?;
|
|
symbol::register_js(&mut exports)?;
|
|
function::register_js(&mut exports)?;
|
|
class::register_js(&mut exports)?;
|
|
env::register_js(&mut exports)?;
|
|
object::register_js(&mut exports)?;
|
|
global::register_js(&mut exports)?;
|
|
cleanup_env::register_js(&mut exports)?;
|
|
#[cfg(feature = "latest")]
|
|
napi4::register_js(&mut exports, &env)?;
|
|
#[cfg(feature = "latest")]
|
|
tokio_rt::register_js(&mut exports)?;
|
|
#[cfg(feature = "latest")]
|
|
napi5::register_js(&mut exports)?;
|
|
#[cfg(feature = "latest")]
|
|
napi6::register_js(&mut exports)?;
|
|
#[cfg(feature = "latest")]
|
|
napi7::register_js(&mut exports)?;
|
|
#[cfg(feature = "latest")]
|
|
napi8::register_js(&mut exports)?;
|
|
Ok(())
|
|
}
|