Giter Site home page Giter Site logo

lunchclass / bacardi Goto Github PK

View Code? Open in Web Editor NEW
113.0 12.0 17.0 9.12 MB

Bacardi project is an effort to provide multi-language binding for Node.js native layer.

Home Page: https://lunchclass.github.io/bacardi

License: Apache License 2.0

Shell 18.19% Batchfile 0.63% Python 2.19% TypeScript 50.38% HTML 9.42% C++ 19.18%
nodejs node native cpp napi n-api abi v8 nan addon

bacardi's Introduction

Bacardi

Linux/Mac Build Status Windows Build Status License Apache 2.0 Slack Status

Bacardi project is an effort to provide multi-language binding for Node.js native layer.

System requirements

  • This project is multi-platform oriented, so we support Linux, Mac and Windows platforms.

Linux

  • You MUST have git, python, wget and g++ compilers.
    • sudo apt-get install g++ git make python wget

Mac

  • You MUST have Xcode with command line tools. You can install them as follows:
    • xcode-select --install

Windows

Build

  • You can just run the following command to build.
    • ./bacardi build

Test

  • You can just run the following command to test.
    • ./bacardi test

Electron with Bacardi

  • If you want to run Electron with Bacardi, you can run the following commands.
    • ./bacardi build_electron
    • ./bacardi electron

Coding style

  • We are following Chromium coding style. You can see the details in the following link.
  • If you want, you can just run the following command to format source codes you modified automatically.
    • ./bacardi format

bacardi's People

Contributors

corona10 avatar daehyunjimmy avatar gogag2 avatar hwanseung avatar nadongguri avatar newklus avatar romandev avatar taxookim avatar usefulhyun avatar yjaeseok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bacardi's Issues

Add byte and octet types

need to support byte and octet basic types

Byte - the byte type is a signed integer type that has values in the range [-128, 127].
Octet - the octet type is an unsigned integer type that has values in the range [0, 255].

Auto execute format and test If needed

Our test command now exits with a "You should run |bacardi format| command first." message if format is required.

This means that the user must explicitly type the bacardi format and type the bacardi test again, which is very annoying.

And some test case failed in AppVeyor if need format.
please refer to link
https://ci.appveyor.com/project/romandev/bacardi/build/1.0.257/job/e32eve5hgrivpnkj

So I would like to suggest is that if we need bacardi format when you type bacardi test, we execute format and test automatically?

As a result, user cannot see "You should run |bacardi format| command first" message and user can test by typing bacardi test only.

[Meta] RoadMap for feature implementation.

Interface Members

Feature Name Priority Status Owner Issues or PRs
Constants P3
Attributes P1 Done @byeolbit
Operations P1 Done @romandev
Stringifiers P2
Indexed properties P3
Named properties P3
Static attributes and operations P1 Done @romandev, @byeolbit
Overloading P1 In Progress @yjaeseok, @romandev
Iterable declarations P3
Maplike declarations P3
Setlike declarations P3

Basic Types

Feature Name Priority Status Owner Issues or PRs
any P1 In Progress @daehyunjimmy #163
boolean P1 Done @gogag2
byte P2 Done @daehyunjimmy
octet P2 Done @daehyunjimmy
short P2 Done @gogag2
unsigned short P2 Done @nadongguri #156
long P1 Done @gogag2
unsigned long P1 In Progress @usefulhyun #158
long long P2 Done @corona10
unsigned long long P2 In Progress @usefulhyun #158
float P1 Done @gogag2
unrestricted float P1
double P1 Done @gogag2
unrestricted double P1
string P1 Done @romandev
object P1
symbol P3
Interface types P1
Dictionary types P1
Enumerations types P1 In Progress @hwanseung
Callback function types P3
Nullable types P1
Sequence types P1
Record types P3
Promise types P1
Union types P2
Annotated types P3
Buffer source types P2
Frozen array types P2

Special things

Feature Name Priority Status Owner Issues or PRs
Namespaces P3
Dictionaries P1 In Progress @hwanseung
Enumerations P1 In Progress @hwanseung
Callback functions P3
Typedefs P1

Extended attributes

Introduce TypeScript for developer performance.

The TypeScript is a language for application-scale JavaScript. It provides many things for developer convenience such as TypeSystem and access modifiers and so on. So, we can consider to introduce TypeScript for developer performance and convenience.

Need a test framework for C++ codes.

We already write some C++ codes but there are no tests for them.
(Currently, only have JS side tests using Mocha.)
So, we should introduce a test framework (e.g. gtest) for C++ codes.

Refactor codes main.ts and idls.ts.

The complexity of the two files has increased, on the other hand, readability has decreased. We should split into smaller files and clear their purpose.

Add support basic type conversion.

Currently, we are only supporting |double| type in calculator examples.
But we should support for basic type such as integer, boolean and so on.

Need more example

I think it would be good to think of an example that better explains the effect of bacardi project.
We have only calculator.

Should implement JSTypeTraits.

We should implement JSTypeTraits similar to NativeTypeTraits.
It should provide converted JS value from Native value.
For example, if the Native value is a double type, should return Napi::Number.

Can not use IDL long type as return type.

In the current implementation, we can not use IDL long type as return type. If we add some test method returning long type, the following build error occurs.

.././core/js_type_traits.h:25:10: error: no viable conversion from returned value of type 'long' to function return type 'Napi::Value'
  return T();
         ^~~
Release/obj/gen/test/test_interface_bridge.cc:286:10: note: in instantiation of function template specialization 'JSTypeTraits<long>' requested here
  return JSTypeTraits(info.Env(), return_value);
         ^
/Users/zino/bacardi/node_modules/node-addon-api/napi.h:118:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'long' to 'const Napi::Value &' for 1st argument
  class Value {
        ^
/Users/zino/bacardi/node_modules/node-addon-api/napi.h:118:9: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'long' to 'Napi::Value &&' for 1st argument
1 error generated.

The above error is because there is no template-specialization for long type in JSTypeTraits.
So, if we add the specialization, it works. But it's not a right way I think.
The long type's range might be changed in C++ side depending on each platform. So, we should find a better way to map explicit range type such as int32_t.

I got some warning message, in first build

When I first got the bacardi source download from github and tried it, the following warning occurred.
This warning is likely to be removed.

/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h: In instantiation of ‘static Napi::ClassPropertyDescriptor Napi::ObjectWrap::InstanceMethod(const char*, Napi::ObjectWrap::InstanceMethodCallback, napi_property_attributes, void*) [with T = CalculatorBridge; Napi::ObjectWrap::InstanceMethodCallback = Napi::Value (CalculatorBridge::*)(const Napi::CallbackInfo&)]’:
../examples/calculator_bridge.cc:25:67: required from here
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::utf8name’ [-Wmissing-field-initializers]
napi_property_descriptor desc = {};
^
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::name’ [-Wmissing-field-initializers]
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::method’ [-Wmissing-field-initializers]
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::getter’ [-Wmissing-field-initializers]
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::setter’ [-Wmissing-field-initializers]
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::value’ [-Wmissing-field-initializers]
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::attributes’ [-Wmissing-field-initializers]
/home/jake_ubuntu/Workspace/lunchclass/bacardi/node_modules/node-addon-api/napi-inl.h:2419:36: warning: missing initializer for member ‘napi_property_descriptor::data’ [-Wmissing-field-initializers]

Should add support for static function.

Currently, we are supporting instance method but not support static function.
So, we should support it as follows:

interface Test {
    static double hello();
};

Then, we can use it as follows:

bacardi.Test.hello();  // Call the static function without instantiation.

Update nodejs from v8.2.1 to v8.4.0

We are using napi_create_number() to get double value from C++ code.
But the function was deleted on v8.4.0 and it also didn't work well.
So we need to change it as napi_create_double() that is new api for getting double value.

Migrate the calculator example to C++ code.

The calculator example is written in C++ language but it's also using built-in N-API based on C language.
We introduced node-addon-api in #36, so, we can just replace it with C++ wrapper code fully.

Bridge files should be generated by code generator.

In the current implementation, calculator_bridge.h, calculator_bridge.cc files have been written by our authors. But they should be generated by code generator from now. So, we should implement code generator to fit the example.

Split example test into feature unit tests.

To implement POC ASAP, we didn't consider project structure much, especially, testing part. As the number of contributors grows, we need to write more tests and make the structure robust.

CalculatorExample: Add() should take arguments and process them.

In the current implementation, Add() method takes arguments in C++ level but exposed JS layer doesn't take arguments and process them. So, we are just passing hard-coded value and it always returns the same value (3).

napi_status status = napi_create_number(env, Calculator::Add(1, 2), &sum);

We should make the function process the arguments and convert types between JS level and C++ level.

Attributes need getter and setter

In user implementation code, attributes need getter and setter.

e.g.

// Attribute
double double_number;

// Getter and setter for attribute
double GetDoubleNumber();
void SetDoubleNumber(double number);

Implement a simple code generator.

We should implement a simple code generator.
It should take IDL files as an input and print C++ classes that maps with IDL files on the screen.

The bacardi.cc should be generated by code generator.

The bacardi.cc and bacardi.h files are in examples directory currently. The file is used to initialize bridge classes but we are not sure what is added newly in the future. Therefore, we should make it be generated automatically.

We can not use camelCase method name.

In the current implementation, we can not use camelCase naming.
For example, if the camelCase() method is defined in interface as follows:

interface ExampleInterface {
    void camelCase();
};

Our generator generates codes as follows:

class ExampleInterface {
    void Camelcase();    // This is a bug.
};

Stop using C based N-API.

We already migrated example codes to C++ based N-API but the core/ directory is still using C based N-API.

Should implement constructor in WebIDL.

In the current implementation, we allow to create object in JS side although there is no constructor definition in WebIDL. It's seems a bug. We should allow to create object with constructor in JS side only if there is an explicit constructor in WebIDL level. To resolve the issue, we should implement constructor feature.

Do we really need to use GYP build system?

Do we really need to use GYP build system?
The Chromium projects (including V8) are already moved to GN build system.
If possible, we can consider GN build system or another thing.

Tests are not working in CI tools.

Tests are not working in CI tools.
after meged #135 CL, tests were passed in CI tools.
because SimRank codes did not formatting like us coding style.
so when run ./bacardi test command, it just show message for formatting and skip the tests.

Multi platform build

Since Bacardi provides multi-language bindings for the Node.js native layer.
Building binding layer for multi-platform is the essential feature.

  • Windows -> Linux
  • Windows -> MacOS
  • Linux -> Windows
  • Linux -> MacOS
  • MacOS -> Windows
  • MacOS -> Linux

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.