зеркало из https://github.com/microsoft/v8-jsi.git
Bring in updated headers from microsoft/node-api-jsi (#185)
This commit is contained in:
Родитель
199d287af2
Коммит
e95059ae31
|
@ -13,7 +13,7 @@
|
|||
<files>
|
||||
<file src="$nugetroot$\lib\win32\**\*.*" target="lib\win32" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
|
||||
<file src="$nugetroot$\build\**\*.*" target="build" exclude="**\*.targets" />
|
||||
<file src="$nugetroot$\build\native\ReactNative.V8Jsi.Windows.targets" target="build\nativeReactNative.V8Jsi.Windows.targets" />
|
||||
<file src="$nugetroot$\build\native\ReactNative.V8Jsi.Windows.targets" target="build\native\ReactNative.V8Jsi.Windows.targets" />
|
||||
<file src="$nugetroot$\license\*.*" target="license"/>
|
||||
</files>
|
||||
</package>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.71.10",
|
||||
"version": "0.71.11",
|
||||
"v8ref": "refs/branch-heads/11.8",
|
||||
"buildNumber": "172"
|
||||
}
|
||||
|
|
|
@ -20,10 +20,14 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
|
|||
# Turn on Error Handling in MSVC, otherwise objects are not destructed
|
||||
# when they go out of scope due to exceptions.
|
||||
list(APPEND jsi_compile_flags "/EHsc")
|
||||
list(APPEND jsi_compile_flags "/Zi")
|
||||
list(APPEND jsi_compile_flags "/Qspectre")
|
||||
list(APPEND jsi_compile_flags "/sdl")
|
||||
endif()
|
||||
if (HERMES_ENABLE_BITCODE)
|
||||
list(APPEND jsi_compile_flags "-fembed-bitcode")
|
||||
endif ()
|
||||
|
||||
target_compile_options(jsi PRIVATE ${jsi_compile_flags})
|
||||
|
||||
install(DIRECTORY "${PROJECT_SOURCE_DIR}/API/jsi/" DESTINATION include
|
||||
|
|
|
@ -1556,9 +1556,9 @@ class JSI_EXPORT JSError : public JSIException {
|
|||
return *value_;
|
||||
}
|
||||
|
||||
/// In V8's case, creating an Error object in JS doesn't record the callstack.
|
||||
/// To preserve it, we need a way to manually add the stack here and on the JS
|
||||
/// side.
|
||||
// In V8's case, creating an Error object in JS doesn't record the callstack.
|
||||
// To preserve it, we need a way to manually add the stack here and on the JS
|
||||
// side.
|
||||
void setStack(std::string stack) {
|
||||
stack_ = std::move(stack);
|
||||
what_ = message_ + "\n\n" + stack_;
|
||||
|
|
|
@ -37,7 +37,7 @@ struct JSRuntimeApiNames {
|
|||
#include "JSRuntimeApi.inc"
|
||||
};
|
||||
|
||||
// Prepared script function either should be all loaded or we use all default functions.
|
||||
// Prepared script functions either should be all loaded or we use all default functions.
|
||||
void loadPreparedScriptFuncs() {
|
||||
JSRuntimeApi *current = JSRuntimeApi::current();
|
||||
bool useDefault = false;
|
||||
|
|
|
@ -7,13 +7,36 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
// JSI version defines set of features available in the API.
|
||||
// Each significant API change must be under a new version.
|
||||
// These macros must be defined in jsi.h, but define them here too
|
||||
// in case if this code is used with unmodified jsi.h.
|
||||
#ifndef JSI_VERSION
|
||||
#define JSI_VERSION 10
|
||||
#endif
|
||||
|
||||
#ifndef JSI_NO_CONST_3
|
||||
#if JSI_VERSION >= 3
|
||||
#define JSI_NO_CONST_3
|
||||
#else
|
||||
#define JSI_NO_CONST_3 const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef JSI_CONST_10
|
||||
#if JSI_VERSION >= 10
|
||||
#define JSI_CONST_10 const
|
||||
#else
|
||||
#define JSI_CONST_10
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace facebook;
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
|
@ -64,7 +87,7 @@ using namespace std::string_view_literals;
|
|||
} \
|
||||
} while (false)
|
||||
|
||||
#if 0
|
||||
#ifdef __cpp_lib_span
|
||||
#include <span>
|
||||
#endif // __cpp_lib_span
|
||||
|
||||
|
@ -72,19 +95,21 @@ namespace Microsoft::NodeApiJsi {
|
|||
|
||||
namespace {
|
||||
|
||||
#if 0 // TODO: additional changes required to switch to std::span
|
||||
#ifdef __cpp_lib_span
|
||||
using std::span;
|
||||
#else
|
||||
/**
|
||||
* @brief A span of values that can be used to pass arguments to a function.
|
||||
*
|
||||
* This should be replaced with std::span once C++ 2020 is supported.
|
||||
* This should be replaced with std::span once C++20 is supported.
|
||||
*/
|
||||
template <typename T>
|
||||
class span {
|
||||
public:
|
||||
constexpr span(std::initializer_list<T> il) noexcept : data_{const_cast<T *>(il.begin())}, size_{il.size()} {}
|
||||
constexpr span() noexcept : data_{nullptr}, size_{0} {}
|
||||
constexpr span(T *data, size_t size) noexcept : data_{data}, size_{size} {}
|
||||
template <std::size_t N>
|
||||
constexpr span(T (&arr)[N]) noexcept : data_{arr}, size_{N} {}
|
||||
|
||||
[[nodiscard]] constexpr T *data() const noexcept {
|
||||
return data_;
|
||||
|
@ -1249,8 +1274,8 @@ jsi::Object NodeApiJsiRuntime::createObject(std::shared_ptr<jsi::HostObject> hos
|
|||
getProperty(getNodeApiValue(cachedValue_.Global), getNodeApiValue(propertyId_.Proxy)),
|
||||
NodeApiPointerValueKind::Object);
|
||||
}
|
||||
napi_value proxy =
|
||||
constructObject(getNodeApiValue(cachedValue_.ProxyConstructor), {obj, getHostObjectProxyHandler()});
|
||||
napi_value args[] = {obj, getHostObjectProxyHandler()};
|
||||
napi_value proxy = constructObject(getNodeApiValue(cachedValue_.ProxyConstructor), args);
|
||||
return makeJsiPointer<jsi::Object>(proxy);
|
||||
}
|
||||
|
||||
|
@ -1859,7 +1884,7 @@ size_t NodeApiJsiRuntime::JsiValueViewArgs::size() const noexcept {
|
|||
|
||||
// TODO: account for symbol
|
||||
NodeApiJsiRuntime::PropNameIDView::PropNameIDView(NodeApiJsiRuntime * /*runtime*/, napi_value propertyId) noexcept
|
||||
: propertyId_{make<jsi::PropNameID>(new (std::addressof(
|
||||
: propertyId_{make<jsi::PropNameID>(new(std::addressof(
|
||||
pointerStore_)) NodeApiStackOnlyPointerValue(propertyId, NodeApiPointerValueKind::StringPropNameID))} {}
|
||||
|
||||
NodeApiJsiRuntime::PropNameIDView::operator jsi::PropNameID const &() const noexcept {
|
||||
|
@ -2166,14 +2191,14 @@ std::string NodeApiJsiRuntime::symbolToStdString(napi_value symbolValue) {
|
|||
// Calls a JavaScript function.
|
||||
napi_value NodeApiJsiRuntime::callFunction(napi_value thisArg, napi_value function, span<napi_value> args) const {
|
||||
napi_value result{};
|
||||
CHECK_NAPI(jsrApi_->napi_call_function(env_, thisArg, function, args.size(), args.begin(), &result));
|
||||
CHECK_NAPI(jsrApi_->napi_call_function(env_, thisArg, function, args.size(), args.data(), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
// Constructs a new JavaScript Object using a constructor function.
|
||||
napi_value NodeApiJsiRuntime::constructObject(napi_value constructor, span<napi_value> args) const {
|
||||
napi_value result{};
|
||||
CHECK_NAPI(jsrApi_->napi_new_instance(env_, constructor, args.size(), args.begin(), &result));
|
||||
CHECK_NAPI(jsrApi_->napi_new_instance(env_, constructor, args.size(), args.data(), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@ makeNodeApiJsiRuntime(napi_env env, JSRuntimeApi *jsrApi, std::function<void()>
|
|||
|
||||
struct NodeApiEnvScope {
|
||||
NodeApiEnvScope(napi_env env) : env_(env) {
|
||||
jsr_open_napi_env_scope(env, &scope_);
|
||||
JSRuntimeApi::current()->jsr_open_napi_env_scope(env, &scope_);
|
||||
}
|
||||
|
||||
NodeApiEnvScope(const NodeApiEnvScope &) = delete;
|
||||
NodeApiEnvScope &operator=(const NodeApiEnvScope &) = delete;
|
||||
|
||||
~NodeApiEnvScope() {
|
||||
jsr_close_napi_env_scope(env_, scope_);
|
||||
JSRuntimeApi::current()->jsr_close_napi_env_scope(env_, scope_);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -149,7 +149,7 @@ JSR_API jsr_run_script(napi_env env,
|
|||
|
||||
// Prepare the script for running.
|
||||
JSR_API jsr_create_prepared_script(napi_env env,
|
||||
const uint8_t* script_utf8,
|
||||
const uint8_t* script_data,
|
||||
size_t script_length,
|
||||
jsr_data_delete_cb script_delete_cb,
|
||||
void* deleter_data,
|
||||
|
|
Загрузка…
Ссылка в новой задаче