gui: more xml and lua support
This commit is contained in:
@@ -70,21 +70,42 @@ runnable scripting::create_runnable(
|
||||
};
|
||||
}
|
||||
|
||||
static bool processCallback(
|
||||
int env,
|
||||
const std::string& src,
|
||||
const std::string& file
|
||||
) {
|
||||
try {
|
||||
return state->eval(env, src, file) != 0;
|
||||
} catch (lua::luaerror err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
wstringconsumer scripting::create_wstring_consumer(
|
||||
int env,
|
||||
const std::string& src,
|
||||
const std::string& file
|
||||
) {
|
||||
return [=](const std::wstring& x){
|
||||
try {
|
||||
if (state->eval(env, src, file) == 0)
|
||||
return;
|
||||
} catch (lua::luaerror err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
return;
|
||||
if (processCallback(env, src, file)) {
|
||||
state->pushstring(util::wstr2str_utf8(x));
|
||||
state->callNoThrow(1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
doubleconsumer scripting::create_number_consumer(
|
||||
int env,
|
||||
const std::string& src,
|
||||
const std::string& file
|
||||
) {
|
||||
return [=](double x){
|
||||
if (processCallback(env, src, file)) {
|
||||
state->pushnumber(x);
|
||||
state->callNoThrow(1);
|
||||
}
|
||||
state->pushstring(util::wstr2str_utf8(x));
|
||||
state->callNoThrow(1);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -94,17 +115,12 @@ int_array_consumer scripting::create_int_array_consumer(
|
||||
const std::string& file
|
||||
) {
|
||||
return [=](const int arr[], size_t len){
|
||||
try {
|
||||
if (state->eval(env, src, file) == 0)
|
||||
return;
|
||||
} catch (lua::luaerror err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
return;
|
||||
if (processCallback(env, src, file)) {
|
||||
for (uint i = 0; i < len; i++) {
|
||||
state->pushinteger(arr[i]);
|
||||
}
|
||||
state->callNoThrow(len);
|
||||
}
|
||||
for (uint i = 0; i < len; i++) {
|
||||
state->pushinteger(arr[i]);
|
||||
}
|
||||
state->callNoThrow(len);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user