fix compiler errors in MSVC
This commit is contained in:
parent
f0b34de867
commit
c53600c04c
@ -58,8 +58,9 @@ class Future final {
|
||||
// Factory side have this to tell finish or abort.
|
||||
class Promise final {
|
||||
public:
|
||||
template <typename U> friend class nf7::Future;
|
||||
template <typename U> friend class nf7::Future<U>::Coro;
|
||||
// Use data_() instead, MSVC doesn't allow this:
|
||||
// template <typename U> friend class nf7::Future<U>;
|
||||
// template <typename U> friend class nf7::Future<U>::Coro;
|
||||
|
||||
static constexpr bool kThisIsNf7FuturePromise = true;
|
||||
|
||||
@ -136,16 +137,21 @@ class Future final {
|
||||
Return(std::move(v));
|
||||
return std::suspend_never();
|
||||
}
|
||||
auto return_value(const T& v) {
|
||||
Return(T(v));
|
||||
}
|
||||
auto return_value(T&& v) {
|
||||
Return(std::move(v));
|
||||
auto return_void() {
|
||||
if (data_->state == kYet) {
|
||||
if constexpr (std::is_same<T, std::monostate>::value) {
|
||||
Return({});
|
||||
} else {
|
||||
assert(false && "coroutine returned without value");
|
||||
}
|
||||
}
|
||||
}
|
||||
auto unhandled_exception() noexcept {
|
||||
Throw(std::current_exception());
|
||||
}
|
||||
|
||||
const std::shared_ptr<Data>& data__() noexcept { return data_; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<Data> data_;
|
||||
|
||||
@ -274,7 +280,7 @@ class Future final {
|
||||
auto callee_ctx = data.ctx.lock();
|
||||
assert(callee_ctx);
|
||||
|
||||
auto caller_data = caller.promise().data_;
|
||||
auto caller_data = caller.promise().data__();
|
||||
auto caller_ctx = caller_data->ctx.lock();
|
||||
assert(caller_ctx);
|
||||
|
||||
|
@ -90,7 +90,7 @@ struct FileCreatePopup final {
|
||||
ImGui::Bullet(); ImGui::Text("invalid name: %s", e.msg().c_str());
|
||||
err = true;
|
||||
}
|
||||
if constexpr (kFlags & FileCreatePopupFlag::kNameDupCheck) {
|
||||
if constexpr ((kFlags & FileCreatePopupFlag::kNameDupCheck) != 0) {
|
||||
if (owner.Find(name_)) {
|
||||
ImGui::Bullet(); ImGui::Text("name duplicated");
|
||||
err = true;
|
||||
|
@ -36,7 +36,7 @@ class Task : public nf7::Context,
|
||||
auto fu() noexcept { return *fu_; }
|
||||
|
||||
protected:
|
||||
virtual nf7::Future<T>::Coro Proc() noexcept = 0;
|
||||
virtual typename nf7::Future<T>::Coro Proc() noexcept = 0;
|
||||
|
||||
private:
|
||||
std::optional<typename nf7::Future<T>::Coro> coro_;
|
||||
|
@ -238,7 +238,7 @@ class IO::Ring final {
|
||||
std::unique_lock<std::mutex> k(mtx_);
|
||||
for (size_t i = 0; i < n; ++i, ++cursor_) {
|
||||
if (cursor_ >= buf_.size()) cursor_ = 0;
|
||||
dst[i] = std::exchange(buf_[cursor_], 0);
|
||||
dst[i] = std::exchange(buf_[cursor_], 0.f);
|
||||
}
|
||||
time_ += n;
|
||||
}
|
||||
|
@ -24,12 +24,13 @@ class LuaContext final : public nf7::File,
|
||||
|
||||
class Queue;
|
||||
|
||||
LuaContext(Env& env) noexcept
|
||||
try :
|
||||
File(kType, env), DirItem(DirItem::kTooltip),
|
||||
q_(std::make_shared<Queue>(env)) {
|
||||
} catch (nf7::Exception&) {
|
||||
// Thread construction failure (ignore it)
|
||||
LuaContext(Env& env) noexcept :
|
||||
File(kType, env), DirItem(DirItem::kTooltip) {
|
||||
try {
|
||||
q_ = std::make_shared<Queue>(env);
|
||||
} catch (nf7::Exception&) {
|
||||
// Thread construction failure (ignore it)
|
||||
}
|
||||
}
|
||||
|
||||
LuaContext(Env& env, Deserializer&) noexcept : LuaContext(env) {
|
||||
|
@ -144,32 +144,33 @@ class Node::FetchTask final : public nf7::Task<std::shared_ptr<nf7::luajit::Ref>
|
||||
std::shared_ptr<nf7::LoggerRef> log_;
|
||||
|
||||
|
||||
nf7::Future<std::shared_ptr<nf7::luajit::Ref>>::Coro Proc() noexcept
|
||||
try {
|
||||
auto& objf = *target_->obj_;
|
||||
auto& obj = objf.interfaceOrThrow<nf7::luajit::Obj>();
|
||||
auto handler = co_await obj.Build();
|
||||
co_yield handler;
|
||||
|
||||
nf7::Future<std::shared_ptr<nf7::luajit::Ref>>::Coro Proc() noexcept {
|
||||
try {
|
||||
*target_->obj_; // checks if objf is alive
|
||||
auto& objf = *target_->obj_;
|
||||
auto& obj = objf.interfaceOrThrow<nf7::luajit::Obj>();
|
||||
auto handler = co_await obj.Build();
|
||||
co_yield handler;
|
||||
|
||||
target_->handler_ = handler;
|
||||
try {
|
||||
*target_->obj_; // checks if objf is alive
|
||||
|
||||
auto& w = target_->watcher_;
|
||||
w.emplace(env());
|
||||
w->Watch(objf.id());
|
||||
w->AddHandler(Event::kUpdate, [t = target_](auto&) {
|
||||
if (t->handler_) {
|
||||
t->log_->Info("detected update of handler object, drops cache");
|
||||
t->handler_ = nullptr;
|
||||
}
|
||||
});
|
||||
target_->handler_ = handler;
|
||||
|
||||
auto& w = target_->watcher_;
|
||||
w.emplace(env());
|
||||
w->Watch(objf.id());
|
||||
w->AddHandler(Event::kUpdate, [t = target_](auto&) {
|
||||
if (t->handler_) {
|
||||
t->log_->Info("detected update of handler object, drops cache");
|
||||
t->handler_ = nullptr;
|
||||
}
|
||||
});
|
||||
} catch (Exception& e) {
|
||||
log_->Error("watcher setup failure: "+e.msg());
|
||||
}
|
||||
} catch (Exception& e) {
|
||||
log_->Error("watcher setup failure: "+e.msg());
|
||||
log_->Error("fetch failure: "+e.msg());
|
||||
}
|
||||
} catch (Exception& e) {
|
||||
log_->Error("fetch failure: "+e.msg());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -205,7 +205,7 @@ class Obj::ExecTask final : public nf7::Task<std::shared_ptr<nf7::luajit::Ref>>
|
||||
|
||||
// return the object and cache it
|
||||
target_->cache_ = std::make_shared<nf7::luajit::Ref>(ctx, ljq, idx);
|
||||
co_return target_->cache_;
|
||||
co_yield target_->cache_;
|
||||
|
||||
} catch (Exception& e) {
|
||||
log_->Error(e.msg());
|
||||
|
7
thirdparty/luajit.cmake
vendored
7
thirdparty/luajit.cmake
vendored
@ -24,12 +24,15 @@ elseif (MINGW)
|
||||
|
||||
elseif (MSVC)
|
||||
set(lib "${src}/lua51.lib")
|
||||
add_custom_target(luajit-build
|
||||
add_custom_command(
|
||||
OUTPUT "${lib}"
|
||||
COMMAND msvcbuild.bat static
|
||||
DEPENDS "${luajit_BINARY_DIR}/skip_build"
|
||||
|
||||
WORKING_DIRECTORY "${luajit_SOURCE_DIR}/src"
|
||||
WORKING_DIRECTORY "${src}"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(luajit-build SOURCES "${lib}")
|
||||
|
||||
else()
|
||||
message(ERROR "unknown environment")
|
||||
|
Loading…
x
Reference in New Issue
Block a user