napi-rs/test_module/src/lib.rs
LongYinan 1a3621b727
feat(napi): major upgrades for napi@1
1. inline everything
2. change `check_status` and `type_of` to macro
3. provide #[module_exports] macro
4. remove debug and repr[transparent] for ffi struct
2020-11-26 11:31:49 +08:00

65 lines
1.5 KiB
Rust

#[macro_use]
extern crate napi_derive;
#[macro_use]
extern crate serde_derive;
use napi::{JsObject, Result};
mod cleanup_env;
#[cfg(feature = "latest")]
mod napi4;
#[cfg(feature = "latest")]
mod napi5;
#[cfg(feature = "latest")]
mod napi6;
#[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) -> 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)?;
#[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)?;
Ok(())
}