Skip to content

Commit

Permalink
fix: compiler issues on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
ialex32x committed Oct 22, 2024
1 parent 36e7637 commit e2bbc76
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 57 deletions.
2 changes: 1 addition & 1 deletion SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ lws_prebuilt_libs = LibraryDescriptor("lws", \
quickjs_src_descs = ThirdPartyDescriptor("quickjs", \
[
# can't compile with VS2022
ThirdPartyDetails("quickjs-ng", ["cutils.c", "libbf.c", "libregexp.c", "libunicode.c", "quickjs.c"], lambda: env["MSVC_VERSION"] != "14.3"),
# ThirdPartyDetails("quickjs-ng", ["cutils.c", "libbf.c", "libregexp.c", "libunicode.c", "quickjs.c"], lambda: "MSVC_VERSION" not in env or env["MSVC_VERSION"] != "14.3"),
ThirdPartyDetails("quickjs", ["cutils.c", "libbf.c", "libregexp.c", "libunicode.c", "quickjs.c"]),
])

Expand Down
1 change: 1 addition & 0 deletions impl/quickjs/jsb_quickjs_class_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ namespace jsb::impl

static_assert(jsb::impl::FunctionStackBase::This == 1);
const uint16_t stack_this = isolate->push_copy(this_val);
jsb_unused(stack_this);

static_assert(jsb::impl::FunctionStackBase::Data == 2);
isolate->push_steal(JS_NewUint32(ctx, constructor_data.data));
Expand Down
57 changes: 57 additions & 0 deletions impl/quickjs/jsb_quickjs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,63 @@ namespace v8
static Local<Context> New(Isolate* isolate);
Local<Object> Global() const;
};

template <>
class Global<Context>
{
// clear all fields silently after moved
void _clear()
{
isolate_ = nullptr;
}

public:
Global() = default;
Global(Isolate* isolate, Local<Context> value) { Reset(isolate, value); }

Global(const Global&) = delete;
Global& operator=(const Global&) = delete;

~Global() { Reset(); }

Global(Global&& other) noexcept
{
isolate_ = other.isolate_;
other._clear();
}

void Reset()
{
if (!isolate_) return;
isolate_ = nullptr;
}

void Reset(Isolate* isolate, Local<Context> value)
{
Reset();

jsb_check(isolate);
isolate_ = isolate;
}

void Reset(Isolate* isolate, const Global& value)
{
Reset(isolate, value.Get(isolate));
}

// Return true if no value held by this handle
bool IsEmpty() const { return !isolate_; }

Local<Context> Get(Isolate* isolate) const
{
jsb_check(isolate_ == isolate && isolate_);
return Local<Context>(Data(isolate_, 0));
}

private:
Isolate* isolate_ = nullptr;

};
}

#endif
56 changes: 0 additions & 56 deletions impl/quickjs/jsb_quickjs_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,62 +291,6 @@ namespace v8
WeakType weak_type_ = WeakType::kStrong;
};

template <>
class Global<Context>
{
// clear all fields silently after moved
void _clear()
{
isolate_ = nullptr;
}

public:
Global() = default;
Global(Isolate* isolate, Local<Context> value) { Reset(isolate, value); }

Global(const Global&) = delete;
Global& operator=(const Global&) = delete;

~Global() { Reset(); }

Global(Global&& other) noexcept
{
isolate_ = other.isolate_;
other._clear();
}

void Reset()
{
if (!isolate_) return;
isolate_ = nullptr;
}

void Reset(Isolate* isolate, Local<Context> value)
{
Reset();

jsb_check(isolate);
isolate_ = isolate;
}

void Reset(Isolate* isolate, const Global& value)
{
Reset(isolate, value.Get(isolate));
}

// Return true if no value held by this handle
bool IsEmpty() const { return !isolate_; }

Local<Context> Get(Isolate* isolate) const
{
jsb_check(isolate_ == isolate && isolate_);
return Local<Context>(Data(isolate_, 0));
}

private:
Isolate* isolate_ = nullptr;

};
}

#endif

0 comments on commit e2bbc76

Please sign in to comment.