Skip to content

Commit

Permalink
Support for nodejs v22.x
Browse files Browse the repository at this point in the history
Fixes #468
  • Loading branch information
laverdet committed May 20, 2024
1 parent d00be92 commit 1254a30
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/isolate/class_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "generic/extract_params.h"
#include "generic/handle_cast.h"
#include "generic/read_option.h"
#include "v8-object.h"

#include <cassert>
#include <cstddef>
Expand Down Expand Up @@ -91,7 +92,7 @@ class ClassHandle {
template <typename... Args>
void Add(const char* name, detail::MemberAccessorHolder impl, Args... args) {
v8::Local<v8::String> name_handle = v8_symbol(name);
proto->SetAccessor(name_handle, impl.getter.callback, impl.setter.callback, name_handle, v8::AccessControl::DEFAULT, v8::PropertyAttribute::None);
proto->SetNativeDataProperty(name_handle, impl.getter.callback, impl.setter.callback, name_handle, v8::PropertyAttribute::None, v8::AccessControl::DEFAULT);
Add(args...);
}

Expand Down
12 changes: 11 additions & 1 deletion src/isolate/generic/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdexcept>
#include <string>
#include <v8.h>
#include "isolate/v8_version.h"

namespace ivm {

Expand Down Expand Up @@ -35,7 +36,11 @@ class RuntimeErrorConstructible : public RuntimeErrorWithMessage {
};

// `RuntimeErrorWithConstructor` can be used to construct any of the `v8::Exception` errors
#if V8_AT_LEAST(11, 9, 154)
template <v8::Local<v8::Value> (*Error)(v8::Local<v8::String>, v8::Local<v8::Value>)>
#else
template <v8::Local<v8::Value> (*Error)(v8::Local<v8::String>)>
#endif
class RuntimeErrorWithConstructor : public RuntimeErrorConstructible {
using RuntimeErrorConstructible::RuntimeErrorConstructible;
public:
Expand All @@ -47,7 +52,12 @@ class RuntimeErrorWithConstructor : public RuntimeErrorConstructible {
v8::MaybeLocal<v8::String> maybe_message = v8::String::NewFromUtf8(isolate, GetMessage().c_str(), v8::NewStringType::kNormal);
v8::Local<v8::String> message_handle;
if (maybe_message.ToLocal(&message_handle)) {
v8::Local<v8::Object> error = Error(message_handle).As<v8::Object>();
v8::Local<v8::Object> error =
#if V8_AT_LEAST(11, 9, 154)
Error(message_handle, {}).As<v8::Object>();
#else
Error(message_handle).As<v8::Object>();
#endif
if (!stack_trace.empty() && isolate->InContext()) {
std::string stack_str = std::string(GetMessage()) + stack_trace;
v8::MaybeLocal<v8::String> maybe_stack = v8::String::NewFromUtf8(isolate, stack_str.c_str(), v8::NewStringType::kNormal);
Expand Down
1 change: 0 additions & 1 deletion tests/shared-array-buffer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
// node-args: --harmony_sharedarraybuffer
let ivm = require('isolated-vm');

let buffer = new SharedArrayBuffer(1024 * 1024);
Expand Down

0 comments on commit 1254a30

Please sign in to comment.