fix compiler errors on MSVC

This commit is contained in:
falsycat 2022-11-01 11:52:26 -07:00
parent b553f44f95
commit 5e8fa70805
7 changed files with 27 additions and 19 deletions

View File

@ -44,6 +44,7 @@ target_include_directories(nf7 PRIVATE . "${PROJECT_BINARY_DIR}/include")
target_compile_options(nf7 PRIVATE
${NF7_OPTIONS_WARNING}
${NF7_OPTIONS_SANITIZE}
$<$<CXX_COMPILER_ID:MSVC>:/bigobj>
)
target_link_options(nf7 PRIVATE
${NF7_OPTIONS_SANITIZE}

View File

@ -265,10 +265,12 @@ class Future final {
});
return pro.future();
}
ThisFuture& Then(const std::shared_ptr<nf7::Context>& ctx, auto&& f) noexcept {
template <typename F>
ThisFuture& Then(const std::shared_ptr<nf7::Context>& ctx, F&& f) noexcept {
return Then(nf7::Env::kSub, ctx, std::move(f));
}
ThisFuture& Then(auto&& f) noexcept {
template <typename F>
ThisFuture& Then(F&& f) noexcept {
return Then(nullptr, std::move(f));
}
@ -281,10 +283,11 @@ class Future final {
});
return *this;
}
ThisFuture& ThenIf(const std::shared_ptr<nf7::Context>& ctx, auto&& f) noexcept {
ThisFuture& ThenIf(const std::shared_ptr<nf7::Context>& ctx,
std::function<void(const T&)>&& f) noexcept {
return ThenIf(nf7::Env::kSub, ctx, std::move(f));
}
ThisFuture& ThenIf(auto&& f) noexcept {
ThisFuture& ThenIf(std::function<void(const T&)>&& f) noexcept {
return ThenIf(nullptr, std::move(f));
}
@ -299,18 +302,20 @@ class Future final {
return *this;
}
template <typename E>
ThisFuture& Catch(const std::shared_ptr<nf7::Context>& ctx, auto&& f) noexcept {
ThisFuture& Catch(const std::shared_ptr<nf7::Context>& ctx,
std::function<void(E&)>&& f) noexcept {
return Catch<E>(nf7::Env::kSub, ctx, std::move(f));
}
template <typename E>
ThisFuture& Catch(auto&& f) noexcept {
ThisFuture& Catch(std::function<void(E&)>&& f) noexcept {
return Catch<E>(nullptr, std::move(f));
}
// Finalizes the other promise on finalize of this future.
template <typename P, typename F>
ThisFuture& Chain(nf7::Env::Executor exec,
const std::shared_ptr<nf7::Context>& ctx,
auto& pro, auto&& func) noexcept {
P& pro, F&& func) noexcept {
return Then(exec, ctx, [pro, func = std::move(func)](auto& fu) mutable {
try {
if constexpr (std::is_void<decltype(func(fu.value()))>::value) {
@ -323,13 +328,16 @@ class Future final {
}
});
}
ThisFuture& Chain(const std::shared_ptr<nf7::Context>& ctx, auto& pro, auto&& func) noexcept {
template <typename P, typename F>
ThisFuture& Chain(const std::shared_ptr<nf7::Context>& ctx, P& pro, F&& func) noexcept {
return Chain(nf7::Env::kSub, ctx, pro, std::move(func));
}
ThisFuture& Chain(auto& pro, auto&& func) noexcept {
template <typename P, typename F>
ThisFuture& Chain(P& pro, F&& func) noexcept {
return Chain(nullptr, pro, std::move(func));
}
ThisFuture& Chain(auto& pro) noexcept {
template <typename P>
ThisFuture& Chain(P& pro) noexcept {
return Chain(pro, [](auto& v) { return v; });
}

View File

@ -398,7 +398,7 @@ void PushNodeRootLambda(
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, [](auto L) {
CheckNodeRootLambda(L, 1).~T();
CheckNodeRootLambda(L, 1).~shared_ptr();
return 0;
});
lua_setfield(L, -2, "__gc");

View File

@ -139,8 +139,7 @@ static void PushMeta(lua_State* L) noexcept {
auto fu = im->Import(*th, name);
fu.ThenIf([L, th](auto& obj) {
th->ExecResume(L, obj);
}).
template Catch<nf7::Exception>([L, th](auto&) {
}).template Catch<nf7::Exception>([L, th](auto&) {
if (auto log = th->logger()) {
log->Warn("import failed, returning nil");
}

View File

@ -178,8 +178,8 @@ void AudioContext::UpdateDeviceListMenu(ma_device_info* ptr, ma_uint32 n) noexce
ImGui::Text("default: %s", ptr[i].isDefault? "yes": "no");
ImGui::TextUnformatted("native formats:");
const auto n = std::min(ptr[i].nativeDataFormatCount, ma_uint32 {5});
for (ma_uint32 j = 0; j < n; ++j) {
const auto fmtn = std::min(ptr[i].nativeDataFormatCount, ma_uint32 {5});
for (ma_uint32 j = 0; j < fmtn; ++j) {
const auto& d = ptr[i].nativeDataFormats[j];
const char* fmt =
d.format == ma_format_u8? "u8":
@ -191,10 +191,10 @@ void AudioContext::UpdateDeviceListMenu(ma_device_info* ptr, ma_uint32 n) noexce
ImGui::Bullet();
ImGui::Text("%s / %" PRIu32 " ch / %" PRIu32 " Hz", fmt, d.channels, d.sampleRate);
}
if (ptr[i].nativeDataFormatCount > n) {
if (ptr[i].nativeDataFormatCount > fmtn) {
ImGui::Bullet(); ImGui::TextDisabled("etc...");
}
if (n == 0) {
if (fmtn == 0) {
ImGui::Bullet(); ImGui::TextDisabled("(nothing)");
}
ImGui::EndTooltip();

View File

@ -983,7 +983,7 @@ struct Program {
for (const auto& pa : *uni) {
try {
SetUniform(prog->id(), pa.first.c_str(), pa.second);
} catch (nf7::Exception& e) {
} catch (nf7::Exception&) {
p.log->Warn("uniform '"+pa.first+"' is ignored");
}
}

View File

@ -225,7 +225,7 @@ class Plot::Lambda final : public nf7::Node::Lambda {
throw nf7::Exception {"expected vector"};
}
} catch (nf7::ExpiredException&) {
} catch (nf7::Exception& e) {
} catch (nf7::Exception&) {
f_->log_.Warn("plotter error");
}