-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
module: add support for abi stable module API #11975
Commits on Mar 21, 2017
-
module: add support for abi stable module API
Add support for abi stable module API (N-API) as "Experimental feature". The goal of this API is to provide a stable Node API for native module developers. N-API aims to provide ABI compatibility guarantees across different Node versions and also across different Node VMs - allowing N-API enabled native modules to just work across different versions and flavors of Node.js without recompilation. A more detailed introduction is provided in: https:/nodejs/node-eps/blob/master/005-ABI-Stable-Module-API.md and https:/nodejs/abi-stable-node/blob/doc/VM%20Summit.pdf. The feature, during its experimental state, will be guarded by a runtime flag "--napi-modules". Only when this flag is added to the command line will N-API modules along with regular non N-API modules be supported. The API is defined by the methods in "src/node_api.h", "src/node_api_types.h" and "src/node_api_async.h". This is the best starting point to review the API surface. More documentation will follow. In addition to the implementation of the API using V8, which is included in this PR, the API has also been validated against chakracore and that port is available in https:/nodejs/abi-stable-node/tree/api-prototype-chakracore-8.x. The current plan is to provide N-API support in versions 8.X and 6.X directly. For older versions, such as 4.X or pre N-API versions of 6.X, we plan to create an external npm module to provide a migration path that will allow modules targeting older Node.js versions to use the API, albeit without getting the advantage of not having to recompile. In addition, we also plan an external npm package with C++ sugar to simplify the use of the API. The sugar will be in-line only and will only use the exported N-API methods but is not part of the N-API itself. The current version is in: https:/nodejs/node-api. This PR is a result of work in the abi-stable-node repo: https:/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the api-prototype-8.x branch with the following contributors in alphabetical order: Arunesh Chandra (@aruneshchandra) Gabriel Schulhof (@gabrielschulhof) Hitesh Kanwathirtha (@digitalinfinity) Ian Halliday (@ianwjhalliday) Jason Ginchereau (@jasongin) Michael Dawson (@mhdawson) Sampson Gao (@sampsongao) Taylor Woll (@boingoing)
Configuration menu - View commit details
-
Copy full SHA for 43ab5a8 - Browse repository at this point
Copy the full SHA 43ab5a8View commit details
Commits on Mar 22, 2017
-
Fix undefined snprintf use for older compiler
The snprintf API is not available with older versions of MSVC. Found by a CI run.
Configuration menu - View commit details
-
Copy full SHA for a5d43d1 - Browse repository at this point
Copy the full SHA a5d43d1View commit details
Commits on Mar 23, 2017
-
all: update --napi-modules flag to not have a yes/no
This updates the documentation, the error message upon module load failure, the command line option parsing of the flag, and the way the N-API addon tests pass the flag to node. Re nodejs#11975 (comment) Re nodejs#11975 (comment) Fixes nodejs/abi-stable-node#184 Closes nodejs/abi-stable-node#186
Configuration menu - View commit details
-
Copy full SHA for 87c42e7 - Browse repository at this point
Copy the full SHA 87c42e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 876e6c8 - Browse repository at this point
Copy the full SHA 876e6c8View commit details -
Configuration menu - View commit details
-
Copy full SHA for b129624 - Browse repository at this point
Copy the full SHA b129624View commit details -
test: convert most addons-napi tests to C
Some tests need to stay C++ because they define classes. Fixes nodejs/abi-stable-node#183 Closes nodejs/abi-stable-node#190
Configuration menu - View commit details
-
Copy full SHA for 66944b8 - Browse repository at this point
Copy the full SHA 66944b8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9e3ab83 - Browse repository at this point
Copy the full SHA 9e3ab83View commit details -
Convert all locals and parameter names to snake_case (nodejs#193)
* Convert all locals and parameter names to snake_case Standardize some parameter names across the N-API surface such as ```napi_env env``` and ```size_t length```. Make all the parameter names in the header match the cc file and expand some parameter names from single characters into meaningful words. Also addresses a couple of minor PR feedback items: - Rename ```napi_reference_addref``` and ```napi_reference_release``` to ```napi_reference_ref``` and ```napi_reference_unref``` (respectively) - Rename ```Reference::AddRef``` and ```Reference::Release``` to ```Reference::Ref``` and ```Reference::Unref``` (respectively) - Remove ```napi_create_boolean```, ```napi_get_true```, and ```napi_get_false``` and replace them with ```napi_get_boolean``` - Rename ```napi_get_type_of_value``` to ```napi_typeof``` - Add a ```result_data``` out parameter to ```napi_create_buffer_copy``` which returns the data pointer of the new buffer - Change ```napi_get_value_string_utf8``` and ```napi_get_value_string_utf16``` to accept a null output buffer and return the length of the source string in that case via the ```result``` parameter - Remove ```napi_get_value_string_utf8_length``` and ```napi_get_value_string_utf16_length``` due to the above - Change ```Reference``` ctor and dtor to be protected and added public ```static Reference* Reference::New``` and ```static void Reference::Delete``` methods to make it more clear how the ```Reference``` objects are allocated and cleaned-up - Add a type check to ``napi_get_array_length``` which returns an error if the argument is not an array object - Change ```napi_create_symbol``` to take a ```napi_value``` instead of a ```const char*``` for the symbol description string. The API now throws if description is not a string but NULL is allowed. * Remove UTF-8 BOM characters and other non-ANSI whitespace * Change parameter names for create string APIs and address other feedback * Fixes for unit tests * Fix lint errors found via CI
Configuration menu - View commit details
-
Copy full SHA for fb8ced4 - Browse repository at this point
Copy the full SHA fb8ced4View commit details -
Address some minor PR feedback (nodejs#187)
- Simplify conversion to/from napi_value - Better names for CallbackWrapper template params - Fatal error when trying to set setter return value - Use node::arraysize - Replace v8::Handle with v8::Local - Align the star after v8::Isolate
Configuration menu - View commit details
-
Copy full SHA for 116bd19 - Browse repository at this point
Copy the full SHA 116bd19View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1b2f2db - Browse repository at this point
Copy the full SHA 1b2f2dbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1427b33 - Browse repository at this point
Copy the full SHA 1427b33View commit details -
Add some type checking (nodejs#195)
- Check the type before casting to string when creating error objects. - Return an error when napi_typeof does not find any valid type.
Configuration menu - View commit details
-
Copy full SHA for 6b4ce53 - Browse repository at this point
Copy the full SHA 6b4ce53View commit details
Commits on Mar 25, 2017
-
Updates for review feedback (nodejs#199)
- Delete the node_api_*internal.h headers - Don't crash when casting numbers when V8_ENABLE_CHECKS is defined - Return 0 when getting NaN value as an integer - Always set callback data internal field to prevent crashing when V8_ENABLE_CHECKS is defined - Style: replace `if (ptr)` with `if (ptr != nullptr)` - Fix extern "C" in node_api_async.h - Minor doc changes
Configuration menu - View commit details
-
Copy full SHA for f21ab80 - Browse repository at this point
Copy the full SHA f21ab80View commit details
Commits on Mar 28, 2017
-
Address PR feedback (nodejs#201)
- Consistent documentation for --napi-modules - Add underscore to napi_get_property_names - Avoid using V8 APIs marked as pending deprecation - Avoid unnecessary copying of args arrays - Other miscellaneous cleanup
Configuration menu - View commit details
-
Copy full SHA for e1ca374 - Browse repository at this point
Copy the full SHA e1ca374View commit details -
Updates for review feedback (nodejs#203)
- Add an env parameter to napi_finalize - Remove unnecessary reinterpret_cast<> calls - Remove redundant Maybe.IsNothing() checks - Make function call result parameters optional - Wrap internal field pointer values in External - Fix broken callback tests and add error-checking - Other misc test cleanup
Configuration menu - View commit details
-
Copy full SHA for 9c0b151 - Browse repository at this point
Copy the full SHA 9c0b151View commit details
Commits on Mar 29, 2017
-
Refcount for v8impl::Reference should be unsigned (nodejs#207)
* Refcount for v8impl::Reference should be unsigned Add ```Reference::RefCount()``` and check the refcount value before trying to call ```Reference::Unref()``` to avoid underflowing the refcount. This allows us to continue returning an error from ```napi_reference_unref``` if it is called with a reference that already has refcount set to zero. * Add check for _refcount == 0 in Reference::Unref to avoid an underflow
Configuration menu - View commit details
-
Copy full SHA for 375af79 - Browse repository at this point
Copy the full SHA 375af79View commit details -
Check value is external in napi_unwrap (nodejs#210)
- Check that an internal field value is actually an External before casting. This prevents a crash if the wrong object is passed to napi_unwrap. - Wrap some macro parameters in parentheses.
Configuration menu - View commit details
-
Copy full SHA for 20b6cf2 - Browse repository at this point
Copy the full SHA 20b6cf2View commit details -
Remove the async API sources (nodejs#212)
These APIs will be redesigned and added into the master branch after our main PR lands there. See nodejs/abi-stable-node#204 to see progress on the redesigned APIs.
Configuration menu - View commit details
-
Copy full SHA for 7a339c0 - Browse repository at this point
Copy the full SHA 7a339c0View commit details -
napi: add napi_env to napi_get_last_error_info() (nodejs#211)
This makes it necessary to pass napi_env to napi_get_last_error_info() thereby ensuring that errors can be tied to the napi_env in the future. Re nodejs/abi-stable-node#198
Configuration menu - View commit details
-
Copy full SHA for 232f004 - Browse repository at this point
Copy the full SHA 232f004View commit details
Commits on Mar 30, 2017
-
Add the _array suffix to the TypedArray type enum (nodejs#213)
* Add the _array suffix to the TypedArray type enum Also remove a stale comment
Configuration menu - View commit details
-
Copy full SHA for aa22a2a - Browse repository at this point
Copy the full SHA aa22a2aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e61d00 - Browse repository at this point
Copy the full SHA 0e61d00View commit details
Commits on Mar 31, 2017
-
Configuration menu - View commit details
-
Copy full SHA for c87eade - Browse repository at this point
Copy the full SHA c87eadeView commit details