Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminary refactoring from Babylon Native #569

Closed

Conversation

syntheticmagus
Copy link

Pursuant to issue #399, this is a minimal set of changes that allows Babylon Native to use napi.h and napi_inl.h without modification. This may just be a first step as we're still trying to understand what the right integration strategy would be, and it's possible there might be a better way to achieve the result we're looking for (for instance, factoring out the node-specific APIs instead of guarding them inside a compiler define), but this PR may be a good place to start the relevant conversation.

@devsnek
Copy link
Member

devsnek commented Oct 22, 2019

If you want N-API without buffers, N-API is probably not what you want.

@@ -2045,7 +2050,7 @@ inline Error Error::New(napi_env env, const std::string& message) {
}

inline NAPI_NO_RETURN void Error::Fatal(const char* location, const char* message) {
napi_fatal_error(location, NAPI_AUTO_LENGTH, message, NAPI_AUTO_LENGTH);
napi_fatal_error(location, NAPI_AUTO_LENGTH, message, NAPI_AUTO_LENGTH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated

Comment on lines -790 to +800
void* Data(); ///< Gets a pointer to the data buffer.
size_t ByteLength(); ///< Gets the length of the array buffer in bytes.
void* Data() const; ///< Gets a pointer to the data buffer.
size_t ByteLength() const; ///< Gets the length of the array buffer in bytes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are unrelated, though relevant. Can you please submit them in a separate PR?

@gabrielschulhof
Copy link
Contributor

The same separation needs to be made for the tests as well. The non-Node.js-specific tests need to be able to run entirely on their own.

The non-Node.js-specific native portions must not contain any addon initialization code, but they may include a common file which contains such code. Please have a look at

https://github.com/nodejs/node/blob/master/test/js-native-api/entry_point.c

and

https://github.com/nodejs/node/blob/master/test/js-native-api/test_array/binding.gyp#L6

for an example of a common file and its use in an otherwise non-Node.js-specific test.

@legendecas
Copy link
Member

Would it be possible and simpler to separate these declarations into two files like what's done in node_api.h and js_native_api.h? It could be achieved without introducing any new macro.

@mhdawson
Copy link
Member

Discussed in the N-API team meeting together. There is consensus that is should be refactored into 2 files

napi.h - the existing one that should include the new file
jsapi.h - the new file with the non-node specific API

  • The import of the core headers will have some extra work to allow importing separated or not

instead of using macros.

@mhdawson
Copy link
Member

@syntheticmagus is this something you'd still like to pursue?

@syntheticmagus
Copy link
Author

@mhdawson Sorry for the delayed reply. This is still something we want to pursue, and I think the edits suggested here will work great for us. However, to make those edits and update this PR, we'll need to upgrade all our integrations to merge with the latest changes from this repo. That's also something we want to do, but unfortunately it's not our top priority at the moment. So, in short, we're not working on this actively at the moment, but we do hope to be able to take action on it in the coming months.

@bghgary
Copy link

bghgary commented May 1, 2020

@syntheticmagus I think we should probably close this PR until we are ready to work on it again. What do you think?

@syntheticmagus
Copy link
Author

@bghgary Makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants