Skip to content
Permalink
Branch: master
Commits on Apr 5, 2019
  1. test: cover napi_get/set/has_named_property()

    gabrielschulhof committed Mar 27, 2019
    Add test coverage for these N-APIs.
    
    PR-URL: #26947
    Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Feb 11, 2019
  1. n-api: finalize during second-pass callback

    gabrielschulhof committed Feb 7, 2019
    Calling into the engine from a weak callback is unsafe, however, the
    engine offers a way to attach a second-pass weak callback which gets
    called when it is safe to call into JavaScript. This moves the point
    at which the N-API finalize callback gets called to this latter point.
    
    Fixes: #25927
    PR-URL: #25992
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Jan 22, 2019
  1. n-api: mark thread-safe function as stable

    gabrielschulhof committed Jan 18, 2019
    Fixes: #24249
    PR-URL: #25556
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Dec 20, 2018
  1. src: unload addons when environment quits

    gabrielschulhof committed Dec 6, 2018
    This is an alternative to #23319
    which attaches the loaded addons to the environment and closes them
    when the environment is destroyed.
    
    PR-URL: #24861
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Commits on Dec 4, 2018
  1. test: partition N-API tests

    gabrielschulhof committed Nov 17, 2018
    Partition test/addons-napi into test/js-native-api and test/node-api to
    isolate the Node.js-agnostic portion of the N-API tests from the
    Node.js-specific portion.
    
    PR-URL: #24557
    Reviewed-By: Refael Ackermann <refack@gmail.com>
    Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Commits on Nov 17, 2018
  1. src: factor out Node.js-agnostic N-APIs

    gabrielschulhof committed Oct 19, 2018
    Split the Node.js ECMAScript API (N-EAPI?) into its own header and
    implementation files. The motivation is that the ECMAScript API stand
    on its own so it might be embedded separately, implementation and all.
    
    Portions of the implementation used by both files are stored in
    `node_api_impl.h`.
    
    The checked boxes below indicate that the given API remains in
    `node_api.h`, whereas the lack of a checkbox indicates that the API was
    moved to `node_ecma_api.h`.
    
    * [x] NAPI_MODULE
    * [x] NAPI_MODULE_INIT
    * [x] napi_acquire_threadsafe_function
    * [x] napi_add_env_cleanup_hook
    * [x] napi_async_destroy
    * [x] napi_async_init
    * [x] napi_call_threadsafe_function
    * [x] napi_cancel_async_work
    * [x] napi_close_callback_scope
    * [x] napi_create_async_work
    * [x] napi_create_buffer
    * [x] napi_create_buffer_copy
    * [x] napi_create_external_buffer
    * [x] napi_create_threadsafe_function
    * [x] napi_delete_async_work
    * [x] napi_fatal_error
    * [x] napi_fatal_exception
    * [x] napi_get_buffer_info
    * [x] napi_get_node_version
    * [x] napi_get_threadsafe_function_context
    * [x] napi_get_uv_event_loop
    * [x] napi_is_buffer
    * [x] napi_make_callback
    * [x] napi_module_register
    * [x] napi_open_callback_scope
    * [x] napi_queue_async_work
    * [x] napi_ref_threadsafe_function
    * [x] napi_release_threadsafe_function
    * [x] napi_remove_env_cleanup_hook
    * [x] napi_unref_threadsafe_function
    * [ ] napi_add_finalizer
    * [ ] napi_adjust_external_memory
    * [ ] napi_call_function
    * [ ] napi_close_escapable_handle_scope
    * [ ] napi_close_handle_scope
    * [ ] napi_coerce_to_bool
    * [ ] napi_coerce_to_number
    * [ ] napi_coerce_to_object
    * [ ] napi_coerce_to_string
    * [ ] napi_create_array
    * [ ] napi_create_arraybuffer
    * [ ] napi_create_array_with_length
    * [ ] napi_create_bigint_int64
    * [ ] napi_create_bigint_uint64
    * [ ] napi_create_bigint_words
    * [ ] napi_create_dataview
    * [ ] napi_create_double
    * [ ] napi_create_error
    * [ ] napi_create_external
    * [ ] napi_create_external_arraybuffer
    * [ ] napi_create_function
    * [ ] napi_create_int32
    * [ ] napi_create_int64
    * [ ] napi_create_object
    * [ ] napi_create_promise
    * [ ] napi_create_range_error
    * [ ] napi_create_reference
    * [ ] napi_create_string_latin1
    * [ ] napi_create_string_utf16
    * [ ] napi_create_string_utf8
    * [ ] napi_create_symbol
    * [ ] napi_create_typedarray
    * [ ] napi_create_type_error
    * [ ] napi_create_uint32
    * [ ] napi_define_class
    * [ ] napi_define_properties
    * [ ] napi_delete_element
    * [ ] napi_delete_property
    * [ ] napi_delete_reference
    * [ ] napi_escape_handle
    * [ ] napi_get_and_clear_last_exception
    * [ ] napi_get_arraybuffer_info
    * [ ] napi_get_array_length
    * [ ] napi_get_boolean
    * [ ] napi_get_cb_info
    * [ ] napi_get_dataview_info
    * [ ] napi_get_element
    * [ ] napi_get_global
    * [ ] napi_get_last_error_info
    * [ ] napi_get_named_property
    * [ ] napi_get_new_target
    * [ ] napi_get_null
    * [ ] napi_get_property
    * [ ] napi_get_property_names
    * [ ] napi_get_prototype
    * [ ] napi_get_reference_value
    * [ ] napi_get_typedarray_info
    * [ ] napi_get_undefined
    * [ ] napi_get_value_bigint_int64
    * [ ] napi_get_value_bigint_uint64
    * [ ] napi_get_value_bigint_words
    * [ ] napi_get_value_bool
    * [ ] napi_get_value_double
    * [ ] napi_get_value_external
    * [ ] napi_get_value_int32
    * [ ] napi_get_value_int64
    * [ ] napi_get_value_string_latin1
    * [ ] napi_get_value_string_utf16
    * [ ] napi_get_value_string_utf8
    * [ ] napi_get_value_uint32
    * [ ] napi_get_version
    * [ ] napi_has_element
    * [ ] napi_has_named_property
    * [ ] napi_has_own_property
    * [ ] napi_has_property
    * [ ] napi_instanceof
    * [ ] napi_is_array
    * [ ] napi_is_arraybuffer
    * [ ] napi_is_dataview
    * [ ] napi_is_error
    * [ ] napi_is_exception_pending
    * [ ] napi_is_promise
    * [ ] napi_is_typedarray
    * [ ] napi_new_instance
    * [ ] napi_open_escapable_handle_scope
    * [ ] napi_open_handle_scope
    * [ ] napi_reference_ref
    * [ ] napi_reference_unref
    * [ ] napi_reject_deferred
    * [ ] napi_remove_wrap
    * [ ] napi_resolve_deferred
    * [ ] napi_run_script
    * [ ] napi_set_element
    * [ ] napi_set_named_property
    * [ ] napi_set_property
    * [ ] napi_strict_equals
    * [ ] napi_throw
    * [ ] napi_throw_error
    * [ ] napi_throw_range_error
    * [ ] napi_throw_type_error
    * [ ] napi_typeof
    * [ ] napi_unwrap
    * [ ] napi_wrap
    
    PR-URL: #23786
    Reviewed-By: Yazhong Liu <yorkiefixer@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Nov 13, 2018
  1. src: bundle persistent-to-local methods as class

    gabrielschulhof authored and danbev committed Nov 7, 2018
    Create a class `PersistentToLocal` which contains three methods,
    `Strong`, `Weak`, and `Default`:
    
    * `Strong` returns a `Local` from a strong persistent reference,
    * `Weak` returns a `Local` from a weak persistent reference, and
    * `Default` decides based on `IsWeak()` which of the above two to call.
    
    These replace `node::StrongPersistentToLocal()`,
    `node::WeakPersistentToLocal()`, and `node::PersistentToLocal()`,
    respectively.
    
    PR-URL: #24276
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Refael Ackermann <refack@gmail.com>
Commits on Oct 9, 2018
  1. doc: add link to ABI guide

    gabrielschulhof committed Oct 6, 2018
    Provides a link from the N-API reference to the guide discussing ABI
    stability in greater depth.
    
    Re: nodejs/abi-stable-node#332
    PR-URL: #23287
    Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Richard Lau <riclau@uk.ibm.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Commits on Oct 7, 2018
  1. doc: remove ABI guide

    gabrielschulhof committed Oct 7, 2018
    Move it to the nodejs.org repo.
    
    PR-URL: #23303
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Commits on Oct 6, 2018
  1. doc: add guide about abi stability

    gabrielschulhof committed Oct 2, 2018
    Re: nodejs/abi-stable-node#332 (comment)
    PR-URL: #23229
    Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Sep 13, 2018
  1. n-api: add generic finalizer callback

    gabrielschulhof committed Aug 10, 2018
    Add `napi_add_finalizer()`, which provides the ability to attach data
    to an arbitrary object and be notified when that object is garbage-
    collected so as to have an opportunity to delete the data previously
    attached.
    
    This differs from `napi_wrap()` in that it does not use up the private
    slot on the object, and is therefore neither removable, nor retrievable
    after the call to `napi_add_finalizer()`. It is assumed that the data
    is accessible by other means, yet it must be tied to the lifetime of
    the object. This is the case for data passed to a dynamically created
    function which is itself heap-allocated and must therefore be freed
    along with the function.
    
    Fixes: nodejs/abi-stable-node#313
    PR-URL: #22244
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Sep 3, 2018
  1. doc: add blurb about implications of ABI stability

    gabrielschulhof committed Aug 24, 2018
    Mention that ABI stability can be achieved only by linking to ABI-
    stable parts of Node.js and to other libraries which are ABI-stable.
    
    PR-URL: #22508
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Aug 31, 2018
  1. n-api: clean up thread-safe function

    gabrielschulhof committed Aug 11, 2018
    * Move class `TsFn` to name space `v8impl` and rename it to
      `ThreadSafeFunction`
    * Remove `NAPI_EXTERN` from API declarations, because it's only needed
      in the header file.
    
    PR-URL: #22259
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Aug 21, 2018
  1. doc: update wrapping-related documentation

    gabrielschulhof committed Aug 21, 2018
    Update the N-API documentation to reflect that wrapping no longer
    affects the object's prototype chain.
    
    PR-URL: #22363
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
    Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
    Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Commits on Jul 24, 2018
  1. doc: link n-api module init to multi-load addons

    gabrielschulhof committed Jul 19, 2018
    Add a blurb to the documentation of `NAPI_MODULE_INIT()` pointing to
    the discussion of the consequences of providing an addon that can be
    loaded multiple times from multiple contexts.
    
    PR-URL: #21891
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  2. n-api: guard against cond null dereference

    gabrielschulhof committed Jul 18, 2018
    A condition variable is only created by the thread-safe function if the
    queue size is set to something larger than zero. This adds null-checks
    around the condition variable and tests for the case where the queue
    size is zero.
    
    Fixes: nodejs/help#1387
    PR-URL: #21871
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Jul 12, 2018
  1. n-api: test uint32 truncation

    gabrielschulhof committed Jul 9, 2018
    Re: nodejs/abi-stable-node#55 (comment)
    PR-URL: #21722
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Jul 9, 2018
  1. n-api: remove experimental gate from status codes

    gabrielschulhof committed Jul 6, 2018
    Re: #21226 (comment)
    PR-URL: #21680
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Gus Caplan <me@gus.host>
  2. n-api: create functions directly

    gabrielschulhof committed Jul 6, 2018
    Avoid using `v8::FunctionTemplate::New()` when using
    `v8::Function::New()` suffices. This ensures that individual functions
    can be gc-ed and that functions can be created dynamically without
    running out of memory.
    
    PR-URL: #21688
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
    Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
    Reviewed-By: Yang Guo <yangguo@chromium.org>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Gus Caplan <me@gus.host>
Commits on Jul 6, 2018
  1. doc: fix doc for napi_create_function

    gabrielschulhof committed Jul 2, 2018
    Merge the two duplicate entries for `napi_create_function()`.
    
    Fixes: #21606
    PR-URL: #21627
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
    Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Commits on Jul 3, 2018
  1. src: add context-aware init macro and doc

    gabrielschulhof committed Jun 13, 2018
    Introduces macros `NODE_MODULE_INITIALIZER` which expands to the name
    of the special symbol that process.dlopen() will look for to initialize
    an addon, and `NODE_MODULE_INIT()` which creates the boilerplate for
    a context-aware module which can be loaded multiple times via the
    special symbol mechanism.
    
    Additionally, provides an example of using the new macro to construct
    an addon which stores per-addon-instance data in a heap-allocated
    structure that gets passed to each binding, rather than in a collection
    of global static variables.
    
    Re: #21291 (comment)
    PR-URL: #21318
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Commits on Jun 29, 2018
  1. n-api: add API for asynchronous functions

    gabrielschulhof committed Jun 17, 2018
    Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`,
    and a `v8::Persistent<v8::Function>` to make it possible to call into JS
    from another thread. The API accepts a void data pointer and a callback
    which will be invoked on the loop thread and which will receive the
    `napi_value` representing the JavaScript function to call so as to
    perform the call into JS. The callback is run inside a
    `node::CallbackScope`.
    
    A `std::queue<void*>` is used to store calls from the secondary
    threads, and an idle loop is started by the `uv_async_t` callback on the
    loop thread to drain the queue, calling into JS with each item.
    
    Items can be added to the queue blockingly or non-blockingly.
    
    The thread-safe function can be referenced or unreferenced, with the
    same semantics as libuv handles.
    
    Re: nodejs/help#1035
    Re: #20964
    Fixes: #13512
    PR-URL: #17887
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on Jun 6, 2018
  1. n-api: remove unused napi_env member

    gabrielschulhof committed Jun 4, 2018
    `wrap_template` is no longer used since we've switched to v8::Private.
    
    PR-URL: #21127
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  2. n-api: back up env before async work finalize

    gabrielschulhof committed Jun 4, 2018
    We must back up the value of `_env` before calling the async work
    complete callback, because the complete callback may delete the
    instance in which `_env` is stored by calling `napi_delete_async_work`,
    and because we need to use it after the complete callback has
    completed.
    
    Fixes: #20966
    PR-URL: #21129
    Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
    Reviewed-By: Refael Ackermann <refack@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on May 24, 2018
  1. n-api: throw when entry point is null

    gabrielschulhof committed May 16, 2018
    PR-URL: #20779
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Commits on May 9, 2018
  1. doc: fix missing napi_get_typedarray_info() param

    gabrielschulhof committed May 9, 2018
    Also, make the type name notation more consistent.
    
    PR-URL: #20631
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Commits on May 6, 2018
  1. doc: fix N-API property descriptor documentation

    gabrielschulhof committed Apr 30, 2018
    PR-URL: #20433
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Commits on May 5, 2018
  1. test: fix up N-API error test

    gabrielschulhof authored and addaleax committed May 3, 2018
    Replace assert.throws() with an explicit try/catch in order to catch
    the thrown value and be able to compare it strictly to an expected
    value.
    
    Re: #20428 (comment)
    
    PR-URL: #20487
    Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Commits on May 4, 2018
  1. n-api: make test_error functions static

    gabrielschulhof committed Apr 27, 2018
    PR-URL: #20373
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Commits on May 2, 2018
  1. n-api: test and doc napi_throw() of a primitive

    gabrielschulhof committed Apr 29, 2018
    Ensure that napi_throw() is able to throw a primitive value, and
    document that it is able to throw any JavaScript value.
    
    Fixes: nodejs/abi-stable-node#309
    PR-URL: #20428
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Commits on Apr 30, 2018
  1. n-api: document the look of napi_external values

    gabrielschulhof committed Apr 28, 2018
    Describe what JavaScript values of type `napi_external` look like in
    JavaScript.
    
    Fixes: nodejs/abi-stable-node#306
    PR-URL: #20426
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
  2. n-api: document that native strings are copied

    gabrielschulhof committed Apr 28, 2018
    Mention that a copy is made of the native string by the
    napi_create_string_* APIs.
    
    Fixes: nodejs/abi-stable-node#304
    PR-URL: #20425
    Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
  3. doc: refine napi_get_property_names() doc

    gabrielschulhof committed Apr 29, 2018
    Document that only enumerable, string-keyed properties are returned.
    
    Fixes: nodejs/abi-stable-node#307
    PR-URL: #20427
    Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Commits on Apr 26, 2018
  1. n-api,test: remove superfluous persistent

    gabrielschulhof committed Apr 25, 2018
    Remove a superfluos persistent from test_constructor_name.c.
    
    PR-URL: #20299
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  2. n-api: update cli documentation

    gabrielschulhof committed Apr 25, 2018
    Fixes: #20082
    PR-URL: #20301
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Richard Lau <riclau@uk.ibm.com>
    Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
    Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Older
You can’t perform that action at this time.