ui scripting related fixes

This commit is contained in:
MihailRis
2024-02-13 14:36:10 +03:00
parent 7f17face73
commit 302b649634
8 changed files with 21 additions and 9 deletions
+12 -1
View File
@@ -74,7 +74,6 @@ wstringconsumer scripting::create_wstring_consumer(
const std::string& src,
const std::string& file
) {
auto funcName = state->storeAnonymous();
return [=](const std::wstring& x){
try {
if (state->eval(env, src, file) == 0)
@@ -119,6 +118,18 @@ std::unique_ptr<Environment> scripting::create_pack_environment(const ContentPac
state->setfield("PACK_ENV");
state->pushstring(pack.id);
state->setfield("PACK_ID");
state->pop();
return std::make_unique<Environment>(id);
}
std::unique_ptr<Environment> scripting::create_doc_environment(int parent, const std::string& name) {
int id = state->createEnvironment(parent);
state->pushenv(id);
state->pushvalue(-1);
state->setfield("DOC_ENV");
state->pushstring(name.c_str());
state->setfield("DOC_NAME");
state->pop();
return std::make_unique<Environment>(id);
}