napi-rs/examples/napi-compat-mode/src/lib.rs

76 lines
1.8 KiB
Rust
Raw Normal View History

2021-05-28 19:50:16 +09:00
#![allow(unused_variables)]
2018-04-28 17:26:38 +09:00
#[macro_use]
extern crate napi_derive;
2020-08-26 01:07:27 +09:00
#[macro_use]
extern crate serde_derive;
2018-04-28 17:26:38 +09:00
use napi::{Env, JsObject, Result};
2020-10-04 17:02:04 +09:00
mod cleanup_env;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
2020-07-08 01:59:09 +09:00
mod napi4;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
mod napi5;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
2020-07-10 20:14:32 +09:00
mod napi6;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
2021-04-21 18:19:45 +09:00
mod napi7;
#[cfg(feature = "latest")]
mod napi8;
#[cfg(feature = "latest")]
2020-08-26 01:07:27 +09:00
mod tokio_rt;
2018-04-28 17:26:38 +09:00
2020-10-21 16:45:45 +09:00
mod array;
mod arraybuffer;
mod buffer;
2020-08-03 00:31:22 +09:00
mod class;
2020-07-18 03:00:48 +09:00
mod either;
mod env;
mod error;
mod external;
2020-07-08 01:59:09 +09:00
mod function;
2020-10-03 01:05:43 +09:00
mod global;
2020-07-08 01:59:09 +09:00
mod napi_version;
mod object;
2020-08-26 01:07:27 +09:00
mod serde;
2020-08-03 15:34:58 +09:00
mod string;
mod symbol;
mod task;
2018-04-28 17:26:38 +09:00
2020-07-08 01:59:09 +09:00
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)?;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
napi4::register_js(&mut exports, &env)?;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
tokio_rt::register_js(&mut exports)?;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
napi5::register_js(&mut exports)?;
2020-11-10 12:09:25 +09:00
#[cfg(feature = "latest")]
napi6::register_js(&mut exports)?;
2021-04-21 18:19:45 +09:00
#[cfg(feature = "latest")]
napi7::register_js(&mut exports)?;
#[cfg(feature = "latest")]
napi8::register_js(&mut exports)?;
Ok(())
2018-04-28 17:26:38 +09:00
}