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

[6.x] n-api: backport to v6.x #19447

Closed

Commits on Apr 10, 2018

  1. n-api: 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://github.com/nodejs/node-eps/blob/master/005-ABI-Stable-Module-API.md
    and https://github.com/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" and
    "src/node_api_types.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://github.com/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://github.com/nodejs/node-api.
    
    This PR is a result of work in the abi-stable-node repo:
    https://github.com/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:
    
    Author: Arunesh Chandra <[email protected]>
    Author: Gabriel Schulhof <[email protected]>
    Author: Hitesh Kanwathirtha <[email protected]>
    Author: Ian Halliday <[email protected]>
    Author: Jason Ginchereau <[email protected]>
    Author: Michael Dawson <[email protected]>
    Author: Sampson Gao <[email protected]>
    Author: Taylor Woll <[email protected]>
    PR-URL: nodejs#11975
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    146f554 View commit details
    Browse the repository at this point in the history
  2. n-api: break dep between v8 and napi attributes

    The v8 n-api implementation had been depending on a one-to-one
    relationship between v8 and n-api v8 property attributes.
    Remove this dependency and fix coverity scan issue
    165845.
    
    PR-URL: nodejs#12191
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    7a43dd2 View commit details
    Browse the repository at this point in the history
  3. napi: supress invalid coverity leak message

    Coverity was complaining that finalizer was being
    leaked in this method, however it should be
    freed when the buffer is finalized so I believe
    the message is invalid.
    
    Add the required comments to suppress the warning.
    
    PR-URL: nodejs#12192
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    6244224 View commit details
    Browse the repository at this point in the history
  4. n-api: create napi_env as a real structure

    1. We define struct napi_env__ to include the isolate, the last
    exception, and the info about the last error.
    
    2. We instantiate one struct napi_env__ during module registration and
    we pass it into the FunctionCallbackInfo for all subsequent entries into
    N-API when we create functions/accessors/finalizers.
    
    Once module unloading will be supported we shall have to delete the
    napi_env we create during module init.
    
    There is a clear separation between public and private API wrt. env:
    
    1. Public APIs assert that env is not nullptr as their first action.
    
    2. Private APIs need not validate env. They assume it's not nullptr.
    
    PR-URL: nodejs#12195
    Fixes: nodejs/abi-stable-node#198
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    69fe5ae View commit details
    Browse the repository at this point in the history
  5. n-api: Update property attrs enum to match JS spec

    The napi_property_attributes enum used names and values from
    v8::PropertyAttribute, but those negative flag names were outdated
    along with the default behavior of a property being writable,
    enumerable, and configurable unless otherwise specified. To match the
    ES5 standard property descriptor those attributes should be positive
    flags and should default to false unless otherwise specified.
    
    PR-URL: nodejs#12240
    Fixes: nodejs/abi-stable-node#221
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    8047b41 View commit details
    Browse the repository at this point in the history
  6. n-api: cache Symbol.hasInstance

    This improves the performance of napi_instanceof() by retrieving
    Symbol.hasInstance from the global object once and then storing a
    persistent reference to it in the env.
    
    PR-URL: nodejs#12246
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    7afb3bc View commit details
    Browse the repository at this point in the history
  7. napi: initialize and check status properly

    Initialize status to napi_generic_failure and only check it after
    having made an actual N-API call.
    
    This fixes up 8fbace1.
    
    PR-URL: nodejs#12283
    Ref: nodejs#12279
    Reviewed-By: Refael Ackermann <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    1459aea View commit details
    Browse the repository at this point in the history
  8. n-api: change napi_callback to return napi_value

    Change `napi_callback` to return `napi_value` directly instead of
    requiring `napi_set_return_value`.
    
    When we invoke the callback, we will check the return value and
    call `SetReturnValue` ourselves. If the callback returns `NULL`,
    we don't set the return value in v8 which would have the same
    effect as previously if the callback didn't call
    `napi_set_return_value`. Seems to be a more natural way
    to handle return values from callbacks. As a consequence,
    remove `napi_set_return_value`.
    
    Add a `napi_value` to `napi_property_descriptor` to support string
    values which couldn't be passed in the `utf8name` parameter or
    symbols as property names. Class names, however, cannot be symbols
    so this `napi_value` must be a string type in that case.
    
    Remove all of the `napi_callback_info` helpers except for
    `napi_get_cb_info` and make all the parameters to
    `napi_get_cb_info` optional except for argc.
    
    Update all the test collateral according to these changes.
    Also add `test/addons-napi/common.h` to house some common macros
    for wrapping N-API calls and error handling.
    
    PR-URL: nodejs#12248
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    boingoing authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    630b4bf View commit details
    Browse the repository at this point in the history
  9. n-api: implement async helper methods

    Based on the async methods we had in abi-stable-node before the napi
    feature landed in node/master. Changed this set of APIs to handle
    error cases and removed a lot of the extra methods we had for setting
    all the pieces of napi_work opting instead to pass all of those as
    arguments to napi_create_async_work as none of those parameters are
    optional except for the complete callback, anyway.
    
    Renamed the napi_work struct to napi_async_work and replace the
    struct itself with a class which can better encapsulate the object
    lifetime and uv_work_t that we're trying to wrap anyway.
    
    Added a napi_async_callback type for the async helper callbacks
    instead of taking raw function pointers and make this callback take a
    napi_env parameter as well as the void* data it was already taking.
    
    Call the complete handler for the async work item with a napi_status
    code translated from the uvlib error code.
    
    The execute callback is required for napi_create_async_work, though
    complete callback is still optional.
    
    Also added some async unit tests for addons-napi based on the
    addons/async_hello_world test.
    
    PR-URL: nodejs#12250
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    boingoing authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    257b28c View commit details
    Browse the repository at this point in the history
  10. n-api: fix -Wmismatched-tags compiler warning

    `napi_env__` was declared as a struct in one place and a class in
    another.
    
    PR-URL: nodejs#12333
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    bnoordhuis authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    e6055bb View commit details
    Browse the repository at this point in the history
  11. test: improve test coverage for n-api

    Add basic tests for handle scopes as code coverage
    reports that we are not covering these with the existing
    tests.
    
    PR-URL: nodejs#12327
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    3e6db1f View commit details
    Browse the repository at this point in the history
  12. test: add second argument to assert.throws

    This adds RegExp or error constructor arguments to the remaining places
    where it is missing in preparation for the commit that will enforce the
    presence of at least two arguments.
    
    PR-URL: nodejs#12270
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    targos authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    a5d892d View commit details
    Browse the repository at this point in the history
  13. test: fix compiler warning in n-api test

    Missed in ca786c3. This does
    not actually affect the outcome because returning `nullptr` or
    `this` from a constructor has the same effect.
    
    PR-URL: nodejs#12318
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    addaleax authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    d26cbed View commit details
    Browse the repository at this point in the history
  14. n-api: add string api for latin1 encoding

    PR-URL: nodejs#12368
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Sampson Gao authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    13261d9 View commit details
    Browse the repository at this point in the history
  15. n-api: fix coverity scan report

    Coverity was reporting _request.work_req as not being initialized.
    Add memset to ensure all of _request is initialized.
    
    PR-URL: nodejs#12365
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    89e816b View commit details
    Browse the repository at this point in the history
  16. test: port test for make_callback to n-api

    Improved test coverage for napi_make_callback by porting the
    existing addons/make_callback test to n-api
    
    PR-URL: nodejs#12409
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    digitalinfinity authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    476b4ff View commit details
    Browse the repository at this point in the history
  17. Revert "test: port test for make_callback to n-api"

    This reverts commit 70b51c8.
    
    PR-URL: nodejs#12475
    Reviewed-By: Colin Ihrig <[email protected]>
    jasnell authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    4414e2b View commit details
    Browse the repository at this point in the history
  18. n-api: remove napi_get_value_string_length()

    This API doesn't serve much purpose, and is only likely to cause
    confusion and bugs. The intention was that this would return the
    number of characters in a string independent of encoding, but
    that's not generally useful. In almost all cases, one of the
    encoding-specific napi_get_value_string_* APIs is more correct.
    (Pass a null buffer if only the encoded length is desired.)
    
    Anyway the current implementation of napi_get_value_string_length()
    is technically wrong: it returns the number of 2-byte code units of
    the UTF-16 encoding, but there are actually some characters that
    are encoded as two UTF-16 code units.
    
    Note the JavaScript String.prototype.length property returns the
    number of UTF-16 code units, which may be different from the number
    of characters. So, getting the true character count is not common
    with JavaScript, and is probably best left to specialized
    internationalization libraries.
    
    PR-URL: nodejs#12496
    Fixes: nodejs/abi-stable-node#226
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Jeremiah Senkpiel <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    7a093c2 View commit details
    Browse the repository at this point in the history
  19. n-api: tighten null-checking and clean up last error

    We left out null-checks for many of the parameters passed to our APIs.
    In particular, arguments of type `napi_value` were often accepted
    without a null-check, even though they should never be null.
    
    Additionally, many APIs simply returned `napi_ok` on success. This
    leaves in place an error that may have occurred in a previous N-API
    call. Others (those which perform `NAPI_PREAMBLE(env)` at the top)
    OTOH explicitly clear the last error before proceeding. With this
    modification all APIs explicitly clear the last error on success.
    
    Fixes: nodejs/abi-stable-node#227
    PR-URL: nodejs#12539
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    89e85e7 View commit details
    Browse the repository at this point in the history
  20. n-api: Enable scope and ref APIs during exception

    N-API is somewhat strict about blocking calls to many APIs while there
    is a pending exception. The NAPI_PREAMBLE macro at the beginning of
    many API implementations checks for a pending exception. However, a
    subset of the APIs (which don't call back into JavaScript) still need
    to work while in a pending-exception state. This changes the reference
    APIs (equivalent to v8::Persistent) and handle scope APIs so that they
    can be used for cleanup up while an exception is pending.
    
    We may decide to similarly enable a few other APIs later, (which would
    be a non-breaking change) but we know at least these are needed now
    to unblock some specific scenarios.
    
    Fixes: nodejs/abi-stable-node#122
    Fixes: nodejs/abi-stable-node#228
    PR-URL: nodejs#12524
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Gabriel Schulhof <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    4653b67 View commit details
    Browse the repository at this point in the history
  21. test: test doc'd napi_get_value_int32 behaviour

    We chose to document this in the docs as there are
    different possible behaviours.  Adding this test to validate
    that all vm implementations do it the same way.
    
    PR-URL: nodejs#12633
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    f7488e7 View commit details
    Browse the repository at this point in the history
  22. test: add coverage for napi_cancel_async_work

    adding test coverage for napi_cancel_async_work based
    on coverage report
    
    PR-URL: nodejs#12575
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    1afabfc View commit details
    Browse the repository at this point in the history
  23. n-api: Reference and external tests

     - Add a test project to addons-napi that covers the
       N-API reference and external APIs
     - Fix a bug in napi_typeof that was found by the new tests
    
    PR-URL: nodejs#12551
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    624a448 View commit details
    Browse the repository at this point in the history
  24. n-api: Sync with back-compat changes

    Background: To enable N-API support for node versions back to v4, the
    N-API code can also be built as an external addon. To make maintenance
    easier, a single codebase needs to support both built-in and external
    scenarios, along with Node versions >= 4 (and corresponding V8
    versions).
    
    This change includes several minor fixes to avoid using node
    internal APIs and support older V8 versions:
      - Expand node::arraysize
      - In the CHECK_ENV() macro, return an error code instead of calling
        node::FatalError(). This is more consistent with how other invalid
        arguments to N-API functions are handled.
      - In v8impl::SetterCallbackWrapper::SetReturnValue(), do nothing
        instead of calling node::FatalError(). This is more consistent
        with JavaScript setter callbacks, where any returned value is
        silently ignored.
      - When queueing async work items, get the uv default loop instead of
        getting the loop from node::Environment::GetCurrent(). Currently
        that returns the same loop anyway. If/when node supports multiple
        environments, it should have a public API for getting the
        environment & event loop, and we can update this implementation
        then.
      - Use v8::Maybe::FromJust() instead of the newer alias ToChecked()
    
    PR-URL: nodejs#12674
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    406f4ce View commit details
    Browse the repository at this point in the history
  25. doc: Add initial documentation for N-API

    Add the initial documentation for the N-API
    
    This PR is a result of work in the abi-stable-node repo:
    https://github.com/nodejs/abi-stable-node/tree/doc,
    with this PR being the cumulative work on the documentation
    sections in that repo with the following contributors
    in alphabetical order:
    
    Author: Arunesh Chandra <[email protected]>
    Author: Gabriel Schulhof <[email protected]>
    Author: Hitesh Kanwathirtha <[email protected]>
    Author: Jason Ginchereau <[email protected]>
    Author: Michael Dawson <[email protected]>
    Author: Sampson Gao <[email protected]>
    Author: Taylor Woll <[email protected]>
    
    PR-URL: nodejs#12549
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jeremiah Senkpiel <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    9189c86 View commit details
    Browse the repository at this point in the history
  26. test: replace indexOf with includes

    Start the transition to Array.prototype.includes() and
    String.prototype.includes().  This commit refactors most of the
    comparisons of Array.prototype.indexOf() and String.prototype.indexOf()
    return values with -1 to the former methods in tests.
    
    PR-URL: nodejs#12604
    Refs: nodejs#12586
    Reviewed-By: Alexey Orlenko <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    gwer authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    3461bc1 View commit details
    Browse the repository at this point in the history
  27. test,lib,doc: use function declarations

    Replace function expressions with function declarations in preparation
    for a lint rule requiring function declarations.
    
    PR-URL: nodejs#12711
    Reviewed-By: Vse Mozhet Byt <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Trott authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    b91ac10 View commit details
    Browse the repository at this point in the history
  28. n-api: remove unnecessary try-catch bracket from certain APIs

    These APIs do not need a try-catch around their body, because no
    exceptions are thrown in their implementation:
    - `napi_is_array()`
    - `napi_get_value_string_latin1()`
    - `napi_get_value_string_utf8()`
    - `napi_get_value_string_utf16()`
    - `napi_get_value_external()`
    - `napi_is_buffer()`
    - `napi_is_arraybuffer()`
    - `napi_get_arraybuffer_info()`
    - `napi_is_typedarray()`
    - `napi_get_typedarray_info()`
    
    Fixes: nodejs/abi-stable-node#238
    PR-URL: nodejs#12705
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    e89a911 View commit details
    Browse the repository at this point in the history
  29. test: fix warning in n-api reference test

    Add cast to avoid warning during build of addon.
    
    PR-URL: nodejs#12730
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    f14a0bb View commit details
    Browse the repository at this point in the history
  30. test: add coverage for error apis

    Add coverage for N-API functions related to
    throwing and creating errors.  A number of these
    are currently showing as not having any
    coverage in the nightly code coverage reports.
    
    PR-URL: nodejs#12729
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    269e921 View commit details
    Browse the repository at this point in the history
  31. test: port test for make_callback to n-api

    Improved test coverage for napi_make_callback by porting the
    existing addons/make_callback test to n-api
    
    PR-URL: nodejs#12409
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    digitalinfinity authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    ed2ef69 View commit details
    Browse the repository at this point in the history
  32. test: fix napi test_reference for recent V8

    PR-URL: nodejs#12864
    Ref: nodejs#12551 (comment)
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    targos authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    7491cee View commit details
    Browse the repository at this point in the history
  33. n-api: napi_get_cb_info should fill array

    When the number of args requested is greater than the actual number of
    args supplied to the function call, the remainder of the args array
    should be filled in with `undefined` values. Because of this bug, the
    remainder of the array was left uninitialized, which could cause a
    crash.
    
    Refer to the documentation for the `argv` parameter at
    https://github.com/nodejs/node/blob/master/doc/api/n-api.md#napi_get_cb_info
    
    PR-URL: nodejs#12863
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    61992ff View commit details
    Browse the repository at this point in the history
  34. n-api: Handle fatal exception in async callback

     - Create a handle scope before invoking the async completion
       callback, because it is basically always needed, easy for user
       code to forget, and this makes it more consistent with ordinary
       N-API function callbacks.
    
     - Check for an unhandled JS exception after invoking an async
       completion callback, and report it via `node::FatalException()`.
    
     - Add a corresponding test case for an exception in async callback.
    
    Previously, any unhandled JS exception thrown from a
    `napi_async_complete_callback` would be silently ignored. Among other
    things this meant assertions in some test cases could be undetected.
    
    PR-URL: nodejs#12838
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    184ffb5 View commit details
    Browse the repository at this point in the history
  35. doc: fix broken links in n-api doc

    - fix 2 broken links
    - fix capitalization in description of
    napi_create_array-with-length
    
    PR-URL: nodejs#12889
    Reviewed-By: Sakthipriyan Vairamani <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: MichaëZasso <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    b69818d View commit details
    Browse the repository at this point in the history
  36. test: improve n-api array func coverage

    - add coverage for napi_has_element
    - add coverage for napi_create_array_with_length
    
    PR-URL: nodejs#12890
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    17d8b55 View commit details
    Browse the repository at this point in the history
  37. doc: clarify node.js addons are c++

    PR-URL: nodejs#12898
    Fixes: nodejs#7129
    Reviewed-By: Sam Roberts <[email protected]>
    Reviewed-By: Sakthipriyan Vairamani <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    BethGriggs authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    ce0e121 View commit details
    Browse the repository at this point in the history
  38. test: add common.mustCall() to NAPI exception test

    Use `common.mustCall()` to confirm that function is invoked.
    
    PR-URL: nodejs#12959
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Sakthipriyan Vairamani <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Trott authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    bdd1375 View commit details
    Browse the repository at this point in the history
  39. doc: clarify operation of napi_cancel_async_work

    PR-URL: nodejs#12974
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Sakthipriyan Vairamani <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    ba2594e View commit details
    Browse the repository at this point in the history
  40. test: improve N-API test coverage

    Add tests to cover functions that return globals
    
    PR-URL: nodejs#13006
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    67e0372 View commit details
    Browse the repository at this point in the history
  41. n-api: remove compiler warning

    `TryCatch` without an `Isolate*` argument is deprecated, so add one.
    
    PR-URL: nodejs#13014
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    addaleax authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    d572c9c View commit details
    Browse the repository at this point in the history
  42. test: Improve N-API test coverage

    - add coverage for napi_get_prototype
    - add coverage for napi_strict_equals
    
    PR-URL: nodejs#13044
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    b10fe3e View commit details
    Browse the repository at this point in the history
  43. n-api: Retain last code when getting error info

    Unlike most N-API functions, `napi_get_last_error_info()` should not
    clear the last error code when successful, because a pointer to (not
    a copy of) the error info structure is returned via an out parameter.
    
    PR-URL: nodejs#13087
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    726d584 View commit details
    Browse the repository at this point in the history
  44. doc: add reference to node_api.h in docs

    Realized that we don't actually point people to the file to
    include in order to access N-API functions.  Add that.
    
    PR-URL: nodejs#13084
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    f7232ad View commit details
    Browse the repository at this point in the history
  45. doc: fix title/function name mismatch

    Fix mismatch in title for napi_get_value_string_utf16
    
    Fixes: nodejs/abi-stable-node#243
    PR-URL: nodejs#13123
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    2e48f58 View commit details
    Browse the repository at this point in the history
  46. test: increase n-api constructor coverage

    Add tests to validate that properties marked as static
    are available through the class as opposed to instances
    
    PR-URL: nodejs#13124
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    4d730be View commit details
    Browse the repository at this point in the history
  47. src: correct endif comment SRC_NODE_API_H__

    Really minor but I could not find an open PR for anything n-api where
    this could be changed, so creating this so that it is not forgotten.
    
    PR-URL: nodejs#13190
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    danbev authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    278ba33 View commit details
    Browse the repository at this point in the history
  48. test: add coverage for napi_has_named_property

    Add test to cover napi_has_named_property
    
    PR-URL: nodejs#13178
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    54bd4b5 View commit details
    Browse the repository at this point in the history
  49. n-api: add napi_get_version

    Add napi_get_version function so that addons can
    query the level of N-API supported.
    
    PR-URL: nodejs#13207
    Fixes: nodejs/abi-stable-node#231
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    5c0c021 View commit details
    Browse the repository at this point in the history
  50. test: improve n-api coverage for typed arrays

    Add testing for all types of typed arrays.
    Add testing for napi_is_arraybuffer.
    
    PR-URL: nodejs#13244
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Kunal Pathak <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    5c19e28 View commit details
    Browse the repository at this point in the history
  51. test: Make N-API weak-ref GC tests asynchronous

    One of the N-API weak-reference test cases already had to be made
    asynchronous to handle different behavior in a newer V8 version:
    nodejs#12864
    When porting N-API to Node-ChakraCore, we found more of the test
    cases needed similar treatment:
    nodejs/node-chakracore#246 So to make
    thes tests more robust (and avoid having differences in the test code
    for Node-ChakraCore), I am refactoring the tests in this file to
    insert a `setImmedate()` callback before every call to `gc()` and
    assertions about the effects of the GC.
    
    PR-URL: nodejs#13121
    Reviewed-By: Michael Dawson <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    8653a1b View commit details
    Browse the repository at this point in the history
  52. doc: fix typo in n-api.md

    PR-URL: nodejs#13323
    Reviewed-By: Luigi Pinca <[email protected]>
    disjukr authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    897bac2 View commit details
    Browse the repository at this point in the history
  53. n-api: enable napi_wrap() to work with any object

    Previously, napi_wrap() would only work with objects created from a
    constructor returned by napi_define_class(). While the N-API team
    was aware of this limitation, it was not clearly documented and is
    likely to cause confusion anyway. It's much simpler if addons are
    allowed to use any JS object. Also, the specific behavior of the
    limitation is difficult to reimplement on other VMs that work
    differently from V8.
    
    V8 requires object internal fields to be declared on the object
    prototype (which napi_define_class() used to do). Since it's too
    late to modify the object prototype by the time napi_wrap() is
    called, napi_wrap() now inserts a new object (with the internal
    field) into the supplied object's prototype chain. Then it can be
    retrieved from there later by napi_unwrap().
    
    This change also includes improvements to the documentation for
    napi_create_external(), partly to explain how it is different from
    napi_wrap().
    
    PR-URL: nodejs#13250
    Reviewed-By: Michael Dawson <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    2249581 View commit details
    Browse the repository at this point in the history
  54. test: consolidate n-api test addons

    It takes time to build each of the addons used to test n-api.
    Consolidate a few of the smaller ones to save build time.
    
    PR-URL: nodejs#13317
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    2052c6a View commit details
    Browse the repository at this point in the history
  55. test: consolidate n-api test addons - part2

    It takes time to build each of the addons used to test n-api.
    Consolidate a few of the smaller ones to save build time.
    
    Get rid of one more small addon.
    
    PR-URL: nodejs#13380
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    d572b0f View commit details
    Browse the repository at this point in the history
  56. test: fix build warning in addons-napi/test_object

    PR-URL: nodejs#13412
    Reviewed-By: Anna Henningsen <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    28cf8f0 View commit details
    Browse the repository at this point in the history
  57. doc: add ref to option to enable n-api

    Since its guarded in by a command line option say
    that in the docs and provide the option that needs
    to be used to enable it.
    
    PR-URL: nodejs#13406
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Tobias Nießn <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    45be27f View commit details
    Browse the repository at this point in the history
  58. doc: fix typo "ndapi" in n-api.md

    PR-URL: nodejs#13484
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Jamen Marz authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    8a96551 View commit details
    Browse the repository at this point in the history
  59. doc: fix out of date sections in n-api doc

    PR-URL: nodejs#13508
    Fixes: nodejs#13469
    Fixes: nodejs#13458
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    01302b1 View commit details
    Browse the repository at this point in the history
  60. test: add coverage for napi_property_descriptor

    We did not have test coverage for using a napi_value
    pointing to a string or symbol for the name when
    creating a property.  Add that coverage.
    
    PR-URL: nodejs#13510
    Reviewed-By: Jason Ginchereau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    02e7b63 View commit details
    Browse the repository at this point in the history
  61. doc: fix napi_create_*_error signatures in n-api

    PR-URL: nodejs#13544
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna M. Kedzierska <[email protected]>
    Reviewed-By: Chris Dickinson <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    jamen authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    2ff7692 View commit details
    Browse the repository at this point in the history
  62. doc: fix out of date napi_callback doc

    The earlier version `napi_callback` returns `void` but now is
    `napi_value`. The document of this section hasn't been modified.
    
    PR-URL: nodejs#13570
    Fixes: nodejs#12248
    Fixes: nodejs#13562
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    XadillaX authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    2b94a31 View commit details
    Browse the repository at this point in the history
  63. doc: fix a few n-api doc issues

    - Add doc for napi_create_string_latin1().
    - Fix signatures where c string was specified instead of napi_value.
    - Fix return type of napi_callback.
    - Update to specify that napi_escape_handle() can only be called once
      for a given scope.
    
    PR-URL: nodejs#13650
    Fixes: nodejs#13555
    Fixes: nodejs#13556
    Fixes: nodejs#13562
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Ingvar Stepanyan <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    00ee027 View commit details
    Browse the repository at this point in the history
  64. n-api: avoid crash in napi_escape_scope()

    V8 will crash if escape is called twice on the same
    scope.
    
    Add checks to avoid crashing if napi_escape_scope() is
    called to try and do this.
    
    Add test that tries to call napi_create_scope() twice.
    
    PR-URL: nodejs#13651
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Ben Noordhuis <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    f680c08 View commit details
    Browse the repository at this point in the history
  65. doc: doc lifetime of n-api last error info

    Document the lifetime of the structure returned
    by napi_get_last_error_info
    
    PR-URL: nodejs#13939
    Fixes: nodejs/abi-stable-node#251
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Vse Mozhet Byt <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    512fc32 View commit details
    Browse the repository at this point in the history
  66. n-api: fix section title typo

    PR-URL: nodejs#13972
    Reviewed-By: Vse Mozhet Byt <[email protected]>
    Reviewed-By: Richard Lau <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    kfarnung authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    947b1cd View commit details
    Browse the repository at this point in the history
  67. test: verify napi_get_property() walks prototype

    Refs: nodejs#13925
    PR-URL: nodejs#13961
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Evan Lucas <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    cjihrig authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    922ea46 View commit details
    Browse the repository at this point in the history
  68. n-api: add napi_delete_element()

    Refs: nodejs#13924
    PR-URL: nodejs#13949
    Reviewed-By: Jason Ginchereau <[email protected]>
    cjihrig authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    ae0bdd5 View commit details
    Browse the repository at this point in the history
  69. n-api: add napi_delete_property()

    Fixes: nodejs#13924
    PR-URL: nodejs#13934
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    cjihrig authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    22b9a87 View commit details
    Browse the repository at this point in the history
  70. n-api: use Maybe version of Object::SetPrototype()

    Fixes the following deprecation warning:
    
        ../src/node_api.cc:2020:30: warning: 'bool
        v8::Object::SetPrototype(v8::Local<v8::Value>)' is deprecated: Use
        maybe version [-Wdeprecated-declarations]
           wrapper->SetPrototype(proto);
        ../src/node_api.cc:2021:28: warning: 'bool
        v8::Object::SetPrototype(v8::Local<v8::Value>)' is deprecated: Use
        maybe version [-Wdeprecated-declarations]
           obj->SetPrototype(wrapper);
    
    PR-URL: nodejs#14053
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    Reviewed-By: Michaël Zasso <[email protected]>
    bnoordhuis authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    c95b561 View commit details
    Browse the repository at this point in the history
  71. n-api: fix -Wmaybe-uninitialized compiler warning

    Not an actual bug, as far as I can tell, the compiler is simply not
    smart enough to figure out that the offending code path isn't reached
    with an uninitialized value.
    
    PR-URL: nodejs#14053
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    Reviewed-By: Michaël Zasso <[email protected]>
    bnoordhuis authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    c5c580c View commit details
    Browse the repository at this point in the history
  72. test: add coverage for napi_typeof

    We had some, but not complete coverage indirectly through
    other tests.  Add test to validate it specifically and
    covers cases that were not being covered.
    
    PR-URL: nodejs#13990
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    134d7a1 View commit details
    Browse the repository at this point in the history
  73. N-API: Reuse ObjectTemplate instances

    V8 caches and does not subsequently release `ObjectTemplate` instances.
    Thus, we need to store the `ObjectTemplate` from which we derive object
    instances we use for `napi_wrap()` and function/accessor context in a
    persistent in the `napi_env`.
    
    nodejs/node-addon-api#70 (comment)
    
    PR-URL: nodejs#13999
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    35b3c61 View commit details
    Browse the repository at this point in the history
  74. n-api: add napi_has_own_property()

    Refs: nodejs#13925
    PR-URL: nodejs#14063
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    cjihrig authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    bb5a56e View commit details
    Browse the repository at this point in the history
  75. n-api: fix warning in test_general

    Currently the following warning is issued when buildning:
    
    Building addon
    /work/nodejs/node/test/addons-napi/test_general/
      CC(target) Debug/obj.target/test_general/test_general.o
    ../test_general.c:116:14: warning: variable 'result' is used
    uninitialized whenever 'if' condition is false
    [-Wsometimes-uninitialized]
      } else if (argument_type == napi_null) {
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
    ../test_general.c:119:10: note: uninitialized use occurs here
      return result;
             ^~~~~~
    ../test_general.c:116:10: note: remove the 'if' if its condition is
    always true
      } else if (argument_type == napi_null) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../test_general.c:101:20: note: initialize the variable 'result' to
    silence this warning
      napi_value result;
                       ^
                        = NULL
    
    This commit simply initializes result to NULL to avoid this warning.
    
    PR-URL: nodejs#14104
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    danbev authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    c8ae23e View commit details
    Browse the repository at this point in the history
  76. n-api: Implement stricter wrapping

    Use a stronger criterion to identify objects in the prototype chain that store
    pointers to native data that were added by previous calls to `napi_wrap()`.
    
    Whereas the old criterion for identifying `napi_wrap()`-injected prototype
    chain objects was to consider an object with an internal field
    count of 1 to be such an object, the new criterion is to consider an object
    with an internal field count of 2 such that the second field holds a
    `v8::External` which itself contains a pointer to a global static string unique
    to N-API to be a `napi_wrap()`-injected prototype chain object.
    
    This greatly reduces the possibility of returning a pointer that was not
    previously added with `napi_wrap()`, and it allows us to recognize that an
    object has already undergone `napi_wrap()` and we can thus prevent a chain of
    wrappers only the first of which is accessible from appearing in the prototype
    chain, as would be the result of multiple calls to `napi_wrap()` using the same
    object.
    
    PR-URL: nodejs#13872
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    99fc87e View commit details
    Browse the repository at this point in the history
  77. n-api: wrap test macros in do/while

    PR-URL: nodejs#14095
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    kfarnung authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    1536f37 View commit details
    Browse the repository at this point in the history
  78. test: handle missing V8 tests in n-api test

    The N-API test testInstanceOf.js relies on several V8 test files
    which may not exist in downloadable archives. If the files are
    missing, this commit causes a warning to be emitted rather than
    failing the test.
    
    Refs: nodejs#14113
    Fixes: nodejs#13344
    PR-URL: nodejs#14123
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: Michaël Zasso <[email protected]>
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    cjihrig authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    fb572c4 View commit details
    Browse the repository at this point in the history
  79. n-api: add code parameter to error helpers

    In support of the effort to add error codes to all errors
    generated by Node.js, add an optional code parameter to the
    helper functions used to throw/create errors in N-API.
    
    PR-URL: nodejs#13988
    Fixes: nodejs#13933
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    5278223 View commit details
    Browse the repository at this point in the history
  80. n-api: add napi_fatal_error API

    PR-URL: nodejs#13971
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    kfarnung authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    25e46c5 View commit details
    Browse the repository at this point in the history
  81. test: replace string concat with template literal

    Replace the string concat at test/addons-napi/test_reference/test.js.
    
    PR-URL: nodejs#14269
    Reviewed-By: Joyee Cheung <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    4garfield authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    bc83e71 View commit details
    Browse the repository at this point in the history
  82. doc: fix some links

    PR-URL: nodejs#14400
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Yuta Hiroto <[email protected]>
    Reviewed-By: Khaidi Chu <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    vsemozhetbyt authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    e885661 View commit details
    Browse the repository at this point in the history
  83. n-api: add fast paths for integer getters

    Ref: nodejs#14379
    PR-URL: nodejs#14393
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    addaleax authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    55e3ca8 View commit details
    Browse the repository at this point in the history
  84. n-api: directly create Local from Persistent

    The `v8::PersistentBase<T>.Get` method didn't exist in node 4 and it's
    just a helper which creates a new `v8::Local` from the given object.
    
    PR-URL: nodejs#14211
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    kfarnung authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    39ce757 View commit details
    Browse the repository at this point in the history
  85. test: changed error message validator

    Replaced TypeError with RegEx to match the exact error message in file
    test/addons-napi/test_properties/test.js. The RegEx will check the
    validity of the error being thrown.
    
    PR-URL: nodejs#14443
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Yuta Hiroto <[email protected]>
    Reviewed-By: Vse Mozhet Byt <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    pratik0509 authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    8fab9bc View commit details
    Browse the repository at this point in the history
  86. n-api: re-use napi_env between modules

    Store the `napi_env` on the global object at a private key. This gives
    us one `napi_env` per context.
    
    Refs: nodejs#14367
    PR-URL: nodejs#14217
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    b5ef731 View commit details
    Browse the repository at this point in the history
  87. n-api: add support for DataView

    Basic support for Dataview is added in this commit. This is achieved
    by using three functions, napi_create_dataview(), napi_is_dataview()
    and napi_get_dataview_info().
    
    PR-URL: nodejs#14382
    Fixes: nodejs#13926
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    shivanth authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    1fe2004 View commit details
    Browse the repository at this point in the history
  88. doc: document napi_finalize() signature

    Refs: nodejs#14138
    PR-URL: nodejs#14230
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    cjihrig authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    fb41b01 View commit details
    Browse the repository at this point in the history
  89. src: replace assert with CHECK_LE in node_api.cc

    PR-URL: nodejs#14514
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Richard Lau <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Tobias Nie�en <[email protected]>
    bnoordhuis authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    3be9e95 View commit details
    Browse the repository at this point in the history
  90. n-api: optimize number API performance

     - Add separate APIs for creating different kinds of numbers,
       because creating a V8 number value from an integer is faster
       than creating one from a double.
     - When getting number values, avoid getting the current context
       because the context will not actually be used and is expensive
       to obtain.
     - When creating values, don't use v8::TryCatch (NAPI_PREAMBLE),
       because these functions have no possibility of executing JS code.
    
    Refs: nodejs#14379
    PR-URL: nodejs#14573
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    2ae281e View commit details
    Browse the repository at this point in the history
  91. n-api: add napi_get_node_version

    Add `napi_get_node_version`, to help with feature-detecting
    Node.js as an environment.
    
    PR-URL: nodejs#14696
    Reviewed-By: Kyle Farnung <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    addaleax authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    11427ca View commit details
    Browse the repository at this point in the history
  92. test: use regular expressions in throw assertions

    Test errors thrown in addons-napi/test_constructor more specifically.
    
    PR-URL: nodejs#14318
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    vincentcn authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    7ca8b1d View commit details
    Browse the repository at this point in the history
  93. doc: delint

    PR-URL: nodejs#14707
    Refs: nodejs#12756
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Daijiro Wachi <[email protected]>
    Reviewed-By: Sakthipriyan Vairamani <[email protected]>
    refack authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    ca8eaa2 View commit details
    Browse the repository at this point in the history
  94. doc: added napi_get_value_string_latin1

    * Reordered string functions alphabetically
    * Fixed a typo in napi_get_value_string_utf8
    
    PR-URL: nodejs#14678
    Fixes: nodejs#14397
    Refs: nodejs#14256
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    kfarnung authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    b0abcbf View commit details
    Browse the repository at this point in the history
  95. n-api: add ability to remove a wrapping

    Calling napi_wrap() twice on the same object has the result of returning
    napi_invalid_arg on the second call. However, sometimes it is necessary
    to replace the native pointer associated with a given object. This new
    API allows one to remove an existing pointer, returning the object to
    its pristine, non-wrapped state.
    
    PR-URL: nodejs#14658
    Reviewed-By: Michael Dawson <[email protected]>
    Fixes: nodejs/abi-stable-node#266
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    f3a8d0a View commit details
    Browse the repository at this point in the history
  96. doc: fix doc for napi_get_value_string_utf8

    The API for napi_get_value_string_utf8() appears to have been
    previously changed. This improves the doc reflect the current design.
    
    PR-URL: nodejs#14529
    Fixes: nodejs#14398
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Daniel Taveras authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    41b7f4c View commit details
    Browse the repository at this point in the history
  97. test: remove unused parameters

    PR-URL: nodejs#14968
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Kunal Pathak <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: David Cai <[email protected]>
    Reviewed-By: Yuta Hiroto <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    human33 authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    6ec485a View commit details
    Browse the repository at this point in the history
  98. n-api: implement promise

    Promise is implemented as a pair of objects. `napi_create_promise()`
    returns both a JavaScript promise and a newly allocated "deferred" in
    its out-params. The deferred is linked to the promise such that the
    deferred can be passed to `napi_resolve_deferred()` or
    `napi_reject_deferred()` to reject/resolve the promise.
    
    `napi_is_promise()` can be used to check if a `napi_value` is a native
    promise - that is, a promise created by the underlying engine, rather
    than a pure JS implementation of a promise.
    
    PR-URL: nodejs#14365
    Fixes: nodejs/abi-stable-node#242
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    2bab64e View commit details
    Browse the repository at this point in the history
  99. n-api: adds function to adjust external memory

    Added a wrapper around
    v8::Isolate::AdjustAmountOfExternalAllocatedMemory
    
    PR-URL: nodejs#14310
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Fixes: nodejs#13928
    Chris Young authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    28786e2 View commit details
    Browse the repository at this point in the history
  100. n-api: implement napi_run_script

    Fixes: nodejs/abi-stable-node#51
    PR-URL: nodejs#15216
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]
    Reviewed-By: James M Snell <jasnell.gmail.com>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    32504e1 View commit details
    Browse the repository at this point in the history
  101. n-api: stop creating references to primitives

    The binding testing napi_wrap() creates references to primitives passed
    into the binding in its second parameter. This is unnecessary and not
    at all the point of the test. Additionally, creating persistent
    references to primitive values may not be supported by all VMs, since
    primitives are best persisted in their native form.
    
    Instead, the point of the test is to make sure that the finalize
    callback gets called when it should get called, that it gets called
    with the correct pointer, and that it does not get called when it
    should not get called. Creating persistent references is not necessary
    for verifying this.
    
    PR-URL: nodejs#15289
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Re: nodejs/node-chakracore#380
    Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    63e8605 View commit details
    Browse the repository at this point in the history
  102. n-api: use AsyncResource for Work tracking

    Enable combining N-API async work with async-hooks.
    
    PR-URL: nodejs#14697
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    addaleax authored and Gabriel Schulhof committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    9c68371 View commit details
    Browse the repository at this point in the history

Commits on Apr 16, 2018

  1. n-api: change async resource name to napi_value

    PR-URL: nodejs#14697
    Reviewed-By: Anna Henningsen <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    14dc0f8 View commit details
    Browse the repository at this point in the history
  2. n-api: refactor napi_addon_register_func

    As per discussion in abi-stable-node:
    nodejs/abi-stable-node#256,
    take a refactor to napi_addon_register_func such that
    the result from the register function is assigned to
    the module exports property. By making this change,
    native module can be agnostic about which type of
    module the environment supports.
    
    PR-URL: nodejs#15088
    Reviewed-By: Gabriel Schulhof <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    boingoing authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    ab1870a View commit details
    Browse the repository at this point in the history
  3. n-api: Context for custom async operations

     - Add napi_async_context opaque pointer type.
       (If needed, we could later add APIs for getting the async IDs
       out of this context.)
     - Add napi_async_init() and napi_async_destroy() APIs.
     - Add async_context parameter to napi_make_callback().
     - Add code and checks to test_make_callback to validate async context
       APIs by checking async hooks are called with correct context.
     - Update API documentation.
    
    PR-URL: nodejs#15189
    Fixes: nodejs#13254
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    jasongin authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    edfbc5b View commit details
    Browse the repository at this point in the history
  4. n-api: napi_is_construct_call->napi_get_new_target

    Remove napi_is_construct_call and introduce napi_get_new_target.
    
    PR-URL: nodejs#14698
    Reviewed-By: Jason Ginchereau <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Kyle Farnung <[email protected]>
    Sampson Gao authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    574f09e View commit details
    Browse the repository at this point in the history
  5. n-api: add optional string length parameters

    PR-URL: nodejs#15343
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    Sampson Gao authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    7fb617b View commit details
    Browse the repository at this point in the history
  6. n-api: remove n-api module loading flag

    Remove the command line flag that was needed for N-API module loading.
    Re: nodejs/vm#9
    
    PR-URL: nodejs#14902
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Matteo Collina <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    a61dd4b View commit details
    Browse the repository at this point in the history
  7. doc: fix new nits in links

    PR-URL: nodejs#15449
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    vsemozhetbyt authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    ccc321d View commit details
    Browse the repository at this point in the history
  8. n-api: fix warning about size_t compare with int

    PR-URL: nodejs#15508
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Sampson Gao authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    3f8e900 View commit details
    Browse the repository at this point in the history
  9. doc: fix outdated code sample in n-api.md

    code samples of napi_create_object and napi_property_descriptor were
    not updated to latest API.
    
    PR-URL: nodejs#15581
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    rebornix authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    c683497 View commit details
    Browse the repository at this point in the history
  10. n-api: add check for large strings

    n-api uses size_t for the size of strings when specifying
    string lengths.  V8 only supports a size of int.  Add
    a check so that an error will be returned if the user
    passes in a string with a size larger than will fit into
    an int.
    
    PR-URL: nodejs#15611
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    7e6c9f1 View commit details
    Browse the repository at this point in the history
  11. test: remove template literal

    PR-URL: nodejs#15953
    Reviewed-By: Ruben Bridgewater <[email protected]>
    emilyford authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    1b2c2a9 View commit details
    Browse the repository at this point in the history
  12. test: fix race condition in addon test

    PR-URL: nodejs#16037
    Reviewed-By: Joyee Cheung <[email protected]>
    Reviewed-By: Evan Lucas <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    kkwoker authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    f589058 View commit details
    Browse the repository at this point in the history
  13. test: cleaned up assert messages

    PR-URL: nodejs#16032
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    mrgorbo authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    b225e66 View commit details
    Browse the repository at this point in the history
  14. n-api: make changes for source compatibility

    These changes are necessary in order to retain source compatibility
    with older versions of node.
    
    The removal of `module_version` from `napi_module_register()` is
    reverted from the flag removal PR, because it should not have been a
    part of it.
    
    `CallbackWrapper::NewTarget()` is renamed to
    `CallbackWrapper::GetNewTarget()` to distinguish it from V8's native
    method, thus allowing for a macro which reduces `NewTarget()` to
    `This()` on V8 versions where it was not yet available.
    
    `AsyncResource` is constructed with a C string rather than a V8 string
    because the former is available on all versions of node.
    
    PR-URL: nodejs#16102
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jason Ginchereau <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    2e2b48b View commit details
    Browse the repository at this point in the history
  15. n-api,test: use module name macro

    test_constructor_name.c should use NODE_GYP_MODULE_NAME.
    
    PR-URL: nodejs#16146
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Evan Lucas <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    45205f0 View commit details
    Browse the repository at this point in the history
  16. test: remove redundant error messages

    Remove redundant error messages for assert.strictEqual()
    
    PR-URL: nodejs#16043
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Christina Chan authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    ae88690 View commit details
    Browse the repository at this point in the history
  17. doc: fix some links

    PR-URL: nodejs#16202
    Reviewed-By: Daijiro Wachi <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    vsemozhetbyt authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    239859f View commit details
    Browse the repository at this point in the history
  18. doc: update to use NAPI_AUTO_LENGTH

    Update so that doc says to use NAPI_AUTO_LENGTH instead
    of -1 to indicate null terminate string.
    
    PR-URL: nodejs#16187
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    6456daf View commit details
    Browse the repository at this point in the history
  19. n-api: use module name macro

    Update tests to use module name macro
    
    PR-URL: nodejs#16185
    Reviewed-By: Gabriel Schulhof <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    a20e0d5 View commit details
    Browse the repository at this point in the history
  20. n-api: check against invalid handle scope usage

    Fixes: nodejs#16175
    PR-URL: nodejs#16201
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    addaleax authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    96d1334 View commit details
    Browse the repository at this point in the history
  21. n-api: unexpose symbols and remove EXTERNAL_NAPI

    * namespaced functions such as v8impl::JsHandleScopeFromV8HandleScope
      become part of Node's public symbols unless they are declared static.
    * the class uvimpl::Work needs to be enclosed in an anonymous namespace
      else it, too becomes part of Node's public symbols.
    * remove references to EXTERNAL_NAPI.
    
    PR-URL: nodejs#16234
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    dd2a60e View commit details
    Browse the repository at this point in the history
  22. test: improve message for assert.strictEqual()

    PR-URL: nodejs#16013
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Evan Lucas <[email protected]>
    Reviewed-By: Michaël Zasso <[email protected]>
    Reviewed-By: Joyee Cheung <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Deep-Six authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    e2b58ab View commit details
    Browse the repository at this point in the history
  23. test: include actual value in assertion message

    PR-URL: nodejs#15935
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Joyee Cheung <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    mattcan authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    6674c17 View commit details
    Browse the repository at this point in the history
  24. test: use default assertion messages

    The string literal messages in addons-napi/test_buffer/test.js are less
    helpful than the default messages, so use the default messages.
    
    PR-URL: nodejs#16808
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    trootski authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    ec2c784 View commit details
    Browse the repository at this point in the history
  25. test: add detailed message for assertion failure

    PR-URL: nodejs#16812
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Joyee Cheung <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    pcdevil authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    4c8826f View commit details
    Browse the repository at this point in the history
  26. test: improve assert messages in napi exception test

    Include unexpected value in assertion messages.
    
    PR-URL: nodejs#16820
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    PaulBlanche authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    cc202a5 View commit details
    Browse the repository at this point in the history
  27. doc: fix a typo in n-api documentation

    PR-URL: nodejs#16879
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    vipinmenon authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    bfeeeb3 View commit details
    Browse the repository at this point in the history
  28. test: improve error emssage reporting in testNapiRun.js

    PR-URL: nodejs#16821
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Paul Ashfield authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    ab95aa4 View commit details
    Browse the repository at this point in the history
  29. doc: fix typos in N-API

    PR-URL: nodejs#16911
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    SwathiKalahastri authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    f3cfc2f View commit details
    Browse the repository at this point in the history
  30. test: refactor addons-napi/test_promise/test.js

    * remove custom messages for assert that conceal values
    * add comment explaining test
    * add block scoping
    
    PR-URL: nodejs#16814
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    ka3e authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    c15b4ee View commit details
    Browse the repository at this point in the history
  31. doc: document common pattern for instanceof checks

    PR-URL: nodejs#16699
    Fixes: nodejs#13824
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    f450931 View commit details
    Browse the repository at this point in the history
  32. n-api: add helper for addons to get the event loop

    Add a utility functions for addons to use when they need
    a reference to the current event loop.
    
    While the libuv API is not directly part of N-API, it
    provides a quite stable C API as well, and is tightly
    integrated with Node itself.
    
    As a particular use case, without access to the event loop
    it is hard to do something interesting from inside a N-API
    finalizer function, since calls into JS and therefore virtually
    all other N-API functions are not allowed.
    
    PR-URL: nodejs#17109
    Reviewed-By: Ben Noordhuis <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    addaleax authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    d21b9a5 View commit details
    Browse the repository at this point in the history
  33. src: add napi_handle_scope_mismatch to msg list

    PR-URL: nodejs#17161
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Refael Ackermann <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Alexey Orlenko <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    neta authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    c04169d View commit details
    Browse the repository at this point in the history
  34. doc: use "JavaScript" instead of "Javascript"

    PR-URL: nodejs#17163
    Reviewed-By: Michaël Zasso <[email protected]>
    Reviewed-By: Vse Mozhet Byt <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Alexey Orlenko <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Trott authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    32dd8f1 View commit details
    Browse the repository at this point in the history
  35. n-api: use nullptr instead of NULL in node_api.cc

    This commit changes two checks which use NULL to use nullptr.
    
    I'm not very familiar with N-API but wanted to bring this up in case
    it was something that was overlooked.
    
    PR-URL: nodejs#17276
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Benjamin Gruenbaum <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: Ali Ijaz Sheikh <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Lance Ball <[email protected]>
    Reviewed-By: Alexey Orlenko <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: MichaëZasso <[email protected]>
    danbev authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    45a3e6b View commit details
    Browse the repository at this point in the history
  36. doc: update example in module registration

    Update return type of `Init` function in documentation to match
    `napi_addon_register_func` signature. Return type used to be
    `void`, now it is `napi_value`.
    
    PR-URL: nodejs#17424
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    fhinkel authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    d9dc130 View commit details
    Browse the repository at this point in the history
  37. test: replace assert.throws with common.expectsError

    PR-URL: nodejs#17445
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Leko authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    3f4ac09 View commit details
    Browse the repository at this point in the history
  38. test: add unhandled rejection guard

    Add an unhandled rejection function in
    addons-napi/test_promise/test.js. Also, add a
    rejection handler to catch the unhandled rejection
    after introducing the guard and test the reason
    code.
    
    PR-URL: nodejs#17275
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    babygoat authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    a005c30 View commit details
    Browse the repository at this point in the history
  39. test: remove literals that obscure assert messages

    Remove string literals as messages to `assert.strictEqual()`. They can
    be misleading here (where perhaps the reason an assertino failed isn't
    that the deleter wasn't called but rather was called too many times.
    
    PR-URL: nodejs#17642
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anatoli Papirovski <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Trott authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    2515f51 View commit details
    Browse the repository at this point in the history
  40. n-api: fix memory leak in napi_async_destroy()

    PR-URL: nodejs#17714
    Reviewed-By: Alexey Orlenko <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Timothy Gu <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    alnyan authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    825468f View commit details
    Browse the repository at this point in the history
  41. test: remove ambiguous error messages from test_error

    assert.strictEqual accepts 3 arguments, the last of which allows for
    user-specified error message to be thrown when the assertion fails.
    Unfortunately, this error message is less helpful than the default when
    it is vague. This commit removes vague, user-specified error messages,
    instead relying on clearer, default error messages.
    
    PR-URL: nodejs#17812
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    nadrane authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    6d5b622 View commit details
    Browse the repository at this point in the history
  42. doc: updates examples to use NULL

    Examples in the N-API doc used a mix of nullptr and NULL.
    We should be consistent and because N-API is a 'C' API I believe
    using NULL is better.  This will avoid any potential confusion
    as to whether N-API can be used with plain C.
    
    PR-URL: nodejs#18008
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    968d757 View commit details
    Browse the repository at this point in the history
  43. n-api: throw RangeError in napi_create_dataview() with invalid range

    The API is required that `byte_length + byte_offset` is less than or
    equal to the size in bytes of the array passed in. If not, a RangeError
    exception is raised[1].
    
    [1] https://nodejs.org/api/n-api.html#n_api_napi_create_dataview
    
    PR-URL: nodejs#17869
    Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    romandev authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    2f92a07 View commit details
    Browse the repository at this point in the history
  44. n-api: expose n-api version in process.versions

    Expose n-api version in process.versions so that it is
    available for use in javascript by external modules
    like node-pre-gyp. It was previously accessible through
    a functon available in the N-API.
    
    PR-URL: nodejs#18067
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jeremiah Senkpiel <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Minwoo Jung <[email protected]>
    Reviewed-By: Gibson Fahnestock <[email protected]>
    Reviewed-By: Tobias Nießn <[email protected]>
    Reviewed-By: Richard Lau <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    9dc08ae View commit details
    Browse the repository at this point in the history
  45. doc: napi: fix unbalanced emphasis

    Some of the section headers had unbalanced emphasis.
    
    PR-URL: nodejs#18122
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Kyle Farnung <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    ofrobots authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    edb244f View commit details
    Browse the repository at this point in the history
  46. doc: napi: make header style consistent

    Some of the API section headers had emphasis, while others did not.
    Use a consistent style (no emphasis) for all of them, as that matches
    our other API docs.
    
    PR-URL: nodejs#18122
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Kyle Farnung <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    ofrobots authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    85b964b View commit details
    Browse the repository at this point in the history
  47. n-api: throw RangeError napi_create_typedarray()

    According to the ECMA spec, we should throw a RangeError in the
    following cases:
      - `(length * elementSize) + offset` > the size of the array passed in
      - `offset % elementSize` != `0`
    
    In the current implementation, this check was omitted. So, the following
    code will cause a crash.
      ```
      napi_create_typedarray(env, napi_uint16_array, 2 /* length */,
                             buffer, 1 /* byte_offset */, &output_array);
      ```
    
    This change fixes the problem and write some related tests.
    
    Refs:
    https://tc39.github.io/ecma262/#sec-typedarray-buffer-byteoffset-length
    
    PR-URL: nodejs#18037
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    romandev authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    5d06fab View commit details
    Browse the repository at this point in the history
  48. test: fixed typos in napi test

    PR-URL: nodejs#18148
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    furstenheim authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    e32cca2 View commit details
    Browse the repository at this point in the history
  49. doc: remove uannecessary Require

    This was the only instance were we said a parameter
    was required.  It is assumed parameters are required unless
    the doc says they are option.  Remove `Required` to make
    consistent with the rest of the doc
    
    PR-URL: nodejs#18184
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    91c9e19 View commit details
    Browse the repository at this point in the history
  50. test: refactor addons-napi/test_exception/test.js

    * provide block scoping to prevent unintended side effects
    * remove confusing and unnecessary assertion message
    * use consisitent `actual, expected` argument order for assertions
    
    PR-URL: nodejs#18340
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Trott authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    f103e21 View commit details
    Browse the repository at this point in the history
  51. n-api: change assert ok check to notStrictEqual.

    PR-URL: nodejs#18414
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    nbdaaron authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    0fd8ceb View commit details
    Browse the repository at this point in the history
  52. test: show pending exception error in napi tests

    Shows the result of the wasPending in the error message if the
    assertion fails.
    
    PR-URL: nodejs#18413
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    reccanti authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    e57f34c View commit details
    Browse the repository at this point in the history
  53. n-api: implement wrapping using private properties

    PR-URL: nodejs#18311
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Fixes: nodejs#14367
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    5c183d7 View commit details
    Browse the repository at this point in the history
  54. n-api: wrap control flow macro in do/while

    Make CHECK_ENV() safe to use in the following context:
    
        if (condition)
          CHECK_ENV(env);
        else
          something_else();
    
    PR-URL: nodejs#18532
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Ali Ijaz Sheikh <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    bnoordhuis authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    76dfefa View commit details
    Browse the repository at this point in the history
  55. doc: remove usage of you in n-api doc

    We avoid using 'you' in the documentation based on our
    guidelines. Remove usage in the n-api doc.
    
    PR-URL: nodejs#18528
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    b7093fa View commit details
    Browse the repository at this point in the history
  56. doc: small typo in n-api.md

    PR-URL: nodejs#18555
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Evan Lucas <[email protected]>
    iSkore authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    ed7e64b View commit details
    Browse the repository at this point in the history
  57. n-api: add methods to open/close callback scope

    Add support for the following methods;
      napi_open_callback_scope
      napi_close_callback_scope
    
    These are needed when running asynchronous methods directly
    using uv.
    
    PR-URL: nodejs#18089
    Fixes: nodejs#15604
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Ben Noordhuis <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    63d1f02 View commit details
    Browse the repository at this point in the history
  58. n-api: remove extra reference from test

    PR-URL: nodejs#18542
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    d75fbeb View commit details
    Browse the repository at this point in the history
  59. doc: fix typo in n-api.md

    PR-URL: nodejs#18590
    Reviewed-By: Jon Moss <[email protected]>
    Reviewed-By: Weijia Wang <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Rich Trott <[email protected]>
    Reviewed-By: Daniel Bevenius <[email protected]>
    Reviewed-By: Yuta Hiroto <[email protected]>
    vsemozhetbyt authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    4753369 View commit details
    Browse the repository at this point in the history
  60. test: improve error message output

    PR-URL: nodejs#18498
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Anatoli Papirovski <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    bshankar authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    c7f4a4f View commit details
    Browse the repository at this point in the history
  61. test: convert new tests to use error types

    PR-URL: nodejs#18581
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    jackhorton authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    85728d1 View commit details
    Browse the repository at this point in the history
  62. doc: fix exporting a function example

    Missing the length argument in napi_create_function.
    
    PR-URL: nodejs#18661
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Aonghus O Nia authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    4950772 View commit details
    Browse the repository at this point in the history
  63. doc: mark NAPI_AUTO_LENGTH as code

    PR-URL: nodejs#18697
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Jeremiah Senkpiel <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    tniessen authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    7996463 View commit details
    Browse the repository at this point in the history
  64. test: remove unnecessary timer

    The timer in NAPI's test_callback_scope/test-resolve-async.js
    can be removed. If the test fails, it will timeout on its own.
    The extra timer increases the chances of the test being
    flaky.
    
    PR-URL: nodejs#18719
    Fixes: nodejs#18702
    Reviewed-By: Ruben Bridgewater <[email protected]>
    Reviewed-By: Santiago Gimeno <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    cjihrig authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    a12f442 View commit details
    Browse the repository at this point in the history
  65. n-api: fix object test

    Passing a pointer to a static integer is sufficient for the test.
    
    PR-URL: nodejs#19039
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: Hitesh Kanwathirtha <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    8786335 View commit details
    Browse the repository at this point in the history
  66. doc: fix n-api asynchronous threading docs

    Documentation for N-API Custom Asynchronous Operations incorrectly
    stated that async execution happens on the main event loop.
    Added details to napi_create_async_work about which threads are
    used to invoke the execute and complete callbacks.
    
    Changed 'async' to 'asynchronous' in the documentation for Custom
    Asynchronous Operations. Changed "executes in parallel" to "can
    execute in parallel" for the documentation of napi_create_async_work
    execute parameter.
    
    PR-URL: nodejs#19073
    Fixes: nodejs#19071
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    ebickle authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    0efd826 View commit details
    Browse the repository at this point in the history
  67. n-api: update reference test

    Remove the necessity for allocating on the heap, and assert that the
    correct pointer gets passed to the finalizer.
    
    PR-URL: nodejs#19086
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    cab6ce9 View commit details
    Browse the repository at this point in the history
  68. n-api: update documentation

    Document which APIs work while an exception is pending. This is the
    list of all APIs which do not start with `NAPI_PREAMBLE(env)`.
    
    Fixes: nodejs/abi-stable-node#257
    PR-URL: nodejs#19078
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    ab4763d View commit details
    Browse the repository at this point in the history
  69. n-api: resolve promise in test

    The last promise created by the test for the purposes of making sure
    that its type is indeed a promise needs to be resolved so as to avoid
    having it left in the pending state at the end of the test.
    
    PR-URL: nodejs#19245
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    a5ec82f View commit details
    Browse the repository at this point in the history
  70. n-api,test: add a new.target test to addons-napi

    Added a N-API test to verify new.target behavior.
    
    PR-URL: nodejs#19236
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    boingoing authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    b0e458a View commit details
    Browse the repository at this point in the history
  71. n-api: take n-api out of experimental

    Take n-api out of experimental as per:
    nodejs/TSC#501
    
    PR-URL: nodejs#19262
    Reviewed-By: Matteo Collina <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Michaël Zasso <[email protected]>
    Reviewed-By: Gus Caplan <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    f07b614 View commit details
    Browse the repository at this point in the history
  72. n-api,test: add int64 bounds tests

    Added some simple tests to verify that the int64 API is correctly
    handling numbers greater than 32-bits. This is a basic test, but
    verifies that an implementer hasn't truncated back to 32-bits.
    
    Refs: nodejs/node-chakracore#496
    
    PR-URL: nodejs#19309
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Gabriel Schulhof <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    kfarnung authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    fdd3f57 View commit details
    Browse the repository at this point in the history
  73. doc: fix typos on n-api

    PR-URL: nodejs#19385
    Reviewed-By: Gireesh Punathil <[email protected]>
    Reviewed-By: Franziska Hinkelmann <[email protected]>
    Reviewed-By: Michaël Zasso <[email protected]>
    Reviewed-By: Richard Lau <[email protected]>
    Reviewed-By: Vse Mozhet Byt <[email protected]>
    Reviewed-By: Tobias Nießen <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    shama authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    7c784de View commit details
    Browse the repository at this point in the history
  74. n-api: add missing exception checking

    Add checks for a pending exception in napi_make_callback
    after the callback has been invoked.  If there is a pending
    exception then we need to avoid checking the result as that
    will not be able to complete properly.
    
    Add additional checks to the unit test for napi_make_callback
    to catch this case.
    
    PR-URL: nodejs#19362
    Fixes: nodejs/node-addon-api#235
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    dd61f8e View commit details
    Browse the repository at this point in the history
  75. n-api: add napi_fatal_exception

    Add function to trigger and uncaught exception.
    Useful if an async callback throws an exception with
    no way to recover.
    
    PR-URL: nodejs#19337
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    mafintosh authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    78ccedf View commit details
    Browse the repository at this point in the history
  76. n-api: re-write test_make_callback

    This re-writes the test in C by dropping std::vector<napi_value> in
    favour of a C99 variable length array, and by dropping the anonymous
    namespace in favour of static function declarations.
    
    PR-URL: nodejs#19448
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Luigi Pinca <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    6b12016 View commit details
    Browse the repository at this point in the history
  77. doc: Add a missing comma

    PR-URL: nodejs#19555
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Trivikram Kamat <[email protected]>
    leaves4j authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    041c9a0 View commit details
    Browse the repository at this point in the history
  78. n-api: bump version of n-api supported

    Bump the version due to additions to the api.
    
    PR-URL: nodejs#19497
    Reviewed-By: Colin Ihrig <[email protected]>
    Reviewed-By: Trivikram Kamat <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Ruben Bridgewater <[email protected]>
    mhdawson authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    96fe46b View commit details
    Browse the repository at this point in the history
  79. n-api: ensure in-module exceptions are propagated

    Whenever we call into an addon, whether it is for a callback, for
    module init, or for async work-related reasons, we should make sure
    that
    
    * the last error is cleared,
    * the scopes before the call are the same as after, and
    * if an exception was thrown and captured inside the module, then it is
      re-thrown after the call.
    
    Therefore we should call into the module in a unified fashion. This
    change introduces the macro NAPI_CALL_INTO_MODULE() which should be
    used whenever invoking a callback provided by the module.
    
    Fixes: nodejs#19437
    PR-URL: nodejs#19537
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Michael Dawson <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    f4b0f7a View commit details
    Browse the repository at this point in the history
  80. n-api: back up env before finalize

    Heed the comment to not use fields of a Reference after calling its
    finalize callback, because such a call may destroy the Reference.
    
    Fixes: nodejs#19673
    PR-URL: nodejs#19718
    Reviewed-By: James M Snell <[email protected]>
    Reviewed-By: Colin Ihrig <[email protected]>
    Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    dc4c825 View commit details
    Browse the repository at this point in the history
  81. n-api: add more int64_t tests

    * Updated tests for `Number` and `int32_t`
    * Added new tests for `int64_t`
    * Updated N-API `int64_t` behavior to return zero for all non-finite
      numbers
    * Clarified the documentation for these calls.
    
    PR-URL: nodejs#19402
    Refs: nodejs/node-chakracore#500
    Reviewed-By: Michael Dawson <[email protected]>
    Reviewed-By: James M Snell <[email protected]>
    kfarnung authored and Gabriel Schulhof committed Apr 16, 2018
    Configuration menu
    Copy the full SHA
    f498a62 View commit details
    Browse the repository at this point in the history