fix issues of LuaJIT/Node
This commit is contained in:
@@ -84,15 +84,18 @@ Thread::Handler Thread::CreateNodeLambdaHandler(
|
||||
case 0:
|
||||
th.ExecResume(L);
|
||||
return;
|
||||
case 2: {
|
||||
auto k = luaL_checkstring(L, 1);
|
||||
auto v = nf7::luajit::CheckValue(L, 2);
|
||||
caller->env().ExecSub(
|
||||
caller, [caller, callee, k = std::string {k}, v = std::move(v)]() {
|
||||
caller->Handle(k, v, callee);
|
||||
});
|
||||
th.ExecResume(L);
|
||||
} return;
|
||||
case 2:
|
||||
if (auto v = nf7::luajit::ToValue(L, 2)) {
|
||||
auto k = luaL_checkstring(L, 1);
|
||||
caller->env().ExecSub(
|
||||
caller, [caller, callee, k = std::string {k}, v = std::move(v)]() {
|
||||
caller->Handle(k, *v, callee);
|
||||
});
|
||||
th.ExecResume(L);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if (auto log = th.logger()) {
|
||||
log->Warn("invalid use of yield, nf7:yield() or nf7:yield(name, value)");
|
||||
|
@@ -24,19 +24,16 @@ class NodeRootLambda final : public nf7::Node::Lambda,
|
||||
NodeRootLambda(NodeRootLambda&&) = delete;
|
||||
NodeRootLambda& operator=(const NodeRootLambda&) = delete;
|
||||
NodeRootLambda& operator=(NodeRootLambda&&) = delete;
|
||||
|
||||
bool KeepAlive() noexcept {
|
||||
if (target_.expired() && pro_.size()) {
|
||||
for (auto& pro : pro_) {
|
||||
pro.second.Throw(std::make_exception_ptr(
|
||||
nf7::Exception {"output was never satisified"}));
|
||||
}
|
||||
~NodeRootLambda() noexcept {
|
||||
target_ = nullptr;
|
||||
for (auto& pro : pro_) {
|
||||
pro.second.Throw(std::make_exception_ptr(
|
||||
nf7::Exception {"output was never satisified"}));
|
||||
}
|
||||
return !target_.expired();
|
||||
}
|
||||
|
||||
private:
|
||||
std::weak_ptr<nf7::Node::Lambda> target_;
|
||||
std::shared_ptr<nf7::Node::Lambda> target_;
|
||||
|
||||
std::unordered_map<std::string, nf7::Future<nf7::Value>::Promise> pro_;
|
||||
std::unordered_map<std::string, std::function<void(const nf7::Value&)>> handler_;
|
||||
|
@@ -114,7 +114,6 @@ class Node final : public nf7::FileBase, public nf7::DirItem, public nf7::Node {
|
||||
return data().outputs;
|
||||
}
|
||||
|
||||
void Update() noexcept override;
|
||||
void UpdateTooltip() noexcept override;
|
||||
void UpdateWidget() noexcept override;
|
||||
|
||||
@@ -162,6 +161,8 @@ class Node::Lambda final : public nf7::Node::Lambda,
|
||||
|
||||
f_->factory_ = b.Build();
|
||||
b.Send("create", nf7::Value::Pulse {});
|
||||
|
||||
f_->fu_->ThenSub(self, [this](auto) { if (f_) f_->factory_ = nullptr; });
|
||||
}
|
||||
|
||||
assert(f_->fu_);
|
||||
@@ -242,12 +243,6 @@ std::shared_ptr<nf7::Node::Lambda> Node::CreateLambda(
|
||||
return std::make_shared<Lambda>(*this, parent);
|
||||
}
|
||||
|
||||
void Node::Update() noexcept {
|
||||
nf7::FileBase::Update();
|
||||
if (factory_) {
|
||||
factory_->KeepAlive();
|
||||
}
|
||||
}
|
||||
void Node::UpdateTooltip() noexcept {
|
||||
ImGui::Text("factory:");
|
||||
ImGui::Indent();
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#include "common/logger.hh"
|
||||
#include "common/logger_ref.hh"
|
||||
#include "common/node.hh"
|
||||
#include "common/node_root_lambda.hh"
|
||||
#include "common/ptr_selector.hh"
|
||||
#include "common/value.hh"
|
||||
|
||||
|
Reference in New Issue
Block a user