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

Add JSRT support for native callbacks with new.target #4529

Merged

Commits on Jan 11, 2018

  1. Add JSRT support for native callbacks with new.target

    Existing `JsNativeFunction` callbacks have no concept of `new.target` and, as a consequence, native functions cannot be used as the base class for a derived class constructor in Javascript. An API like `JsGetNewTarget` doesen't make a lot of sense so we propose here a new type of callback which will be called with `new.target` directly.
    
    `JsCreateEnhancedFunction` acts similarly to the way `JsCreateFunction` did but takes a `JsEnhancedNativeFunction` callback instead. This callback is called passing a struct (`JsNativeFunctionInfo` containing `new.target`, `this`, and `isConstructCall`) as well as ordinary `callee`, `arguments`, and `argumentsCount`.
    
    To simplify `JavascriptExternalFunction` and handling of native callback functions in ChakraCore, I refactored `JsCreateFunction` to use a `JsEnhancedNativeFunction` wrapper function which forwards to the `JsNativeFunction` callback.
    
    Add native unit tests where an enhanced function (`JavascriptExternalFunction`) is used as the base class for a Javascript derived class.
    
    Fixes:
    chakra-core#3762
    boingoing committed Jan 11, 2018
    Configuration menu
    Copy the full SHA
    bfbfbaa View commit details
    Browse the repository at this point in the history
  2. Respond to review feedback

    boingoing committed Jan 11, 2018
    Configuration menu
    Copy the full SHA
    ac00296 View commit details
    Browse the repository at this point in the history