even more boilerplate code

This commit is contained in:
MihailRis
2024-02-19 23:56:39 +03:00
parent 7792c1a6f4
commit 5c23b4125d
11 changed files with 220 additions and 72 deletions
@@ -51,6 +51,49 @@ wstringconsumer scripting::create_wstring_consumer(
};
}
wstringsupplier scripting::create_wstring_supplier(
int env,
const std::string& src,
const std::string& file
) {
return [=](){
if (processCallback(env, src, file)) {
state->callNoThrow(0);
auto str = state->tostring(-1); state->pop();
return util::str2wstr_utf8(str);
}
return std::wstring(L"");
};
}
boolconsumer scripting::create_bool_consumer(
int env,
const std::string& src,
const std::string& file
) {
return [=](bool x){
if (processCallback(env, src, file)) {
state->pushboolean(x);
state->callNoThrow(1);
}
};
}
boolsupplier scripting::create_bool_supplier(
int env,
const std::string& src,
const std::string& file
) {
return [=](){
if (processCallback(env, src, file)) {
state->callNoThrow(0);
bool x = state->toboolean(-1); state->pop();
return x;
}
return false;
};
}
doubleconsumer scripting::create_number_consumer(
int env,
const std::string& src,