napi-rs / napi

High-level Node.js N-API bindings for Rust ✨🦀🚀✨— ⚠️Deprecated in favor of https://github.com/napi-rs/napi-rs ⚠️
MIT License
99 stars 4 forks source link

Is this project still active #3

Open phillipCouto opened 5 years ago

phillipCouto commented 5 years ago

Is this project still active?

anurbol commented 4 years ago

It seems it's not. @aqrln Alexey could you please comment on this: is this project abandoned or it just works fine despite the WIP warnings on the README.md 😃

I've seen that you do conduct some activity in this area, and I've read this PDF where you wrote that you're going to make a new release soon. In the end of that PDF though, you're writing that you're looking for a new maintainer for this crate.

So it seems that one shoudn't use this crate in commercial production, or could they?

anurbol commented 4 years ago

I tried to run cargo build --release with Cargo 1.41 and it didn't produce example.node, only napi_example.lib and napi_derive.dll etc.

aqrln commented 4 years ago

@anurbol

So it seems that one shoudn't use this crate in commercial production, or could they?

I'd recommend against that, right.

I tried to run cargo build --release with Cargo 1.41 and it didn't produce example.node, only napi_example.lib and napi_derive.dll etc.

Yeah, you need to run npm run build inside the example directory to build the actual Node.js addon.

Brooooooklyn commented 4 years ago

@aqrln I'm working on a new napi & rust project: https://github.com/Brooooooklyn/napi-rs And it seems napi-derive crate name was taken by you.. Could you please transfer this crate name(napi-derive) to me if you don't want maintain this project anymore?

aqrln commented 4 years ago

@Brooooooklyn yeah sure, your project looks awesome, and I don't even need that name anymore because if I were to continue working on this project, it would be called napi-codegen like in this demo.

Brooooooklyn commented 4 years ago

My napi-derive implementation is similar with napi-codegen 😄

#[macro_use]
extern crate napi_rs_derive;

use napi_rs::{Result, Value, CallContext, Number};
use std::convert::TryInto;

#[js_function(1)]
fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, Number>> {
  let n = ctx.get::<Number>(0)?.try_into()?;
  ctx.env.create_int64(fibonacci_native(n))
}

#[inline]
fn fibonacci_native(n: i64) -> i64 {
  match n {
    1 | 2 => 1,
    _ => fibonacci_native(n - 1) + fibonacci_native(n - 2)
  }
}
aqrln commented 4 years ago

Cool! In my implementation the boilerplate for retrieving arguments from context is generated automatically too:

#[napi::callback(fibonacci_js)]
fn fibonacci(env: Env, n: Number) -> Result<Number> {
    Number::from_i64(env, fibonacci_native(n.to_i64()?))
}

Would you want to add something similar or there are some drawbacks I didn't account for?

Brooooooklyn commented 4 years ago

Would you want to add something similar or there are some drawbacks I didn't account for?

How do you get this object from call object in your implementation?

My version is not simpler enough for now, I will make them easier to use in next version. Now I'm focusing developing ecosystem around my napi-rs: https://github.com/Brooooooklyn/node-rs

aqrln commented 4 years ago

@Brooooooklyn

How do you get this object from call object in your implementation?

I guess it could be a parameter of special type?

Now I'm focusing developing ecosystem around my napi-rs

That looks very cool!