refactor: 'lua' namespace expansion
This commit is contained in:
@@ -8,11 +8,10 @@
|
||||
namespace scripting {
|
||||
extern lua::LuaState* state;
|
||||
}
|
||||
using namespace scripting;
|
||||
|
||||
static debug::Logger logger("scripting_func");
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
runnable scripting::create_runnable(
|
||||
const scriptenv& env,
|
||||
const std::string& src,
|
||||
@@ -20,8 +19,8 @@ runnable scripting::create_runnable(
|
||||
) {
|
||||
auto L = state->getMainThread();
|
||||
try {
|
||||
state->loadbuffer(L, *env, src, file);
|
||||
return state->createRunnable(L);
|
||||
lua::loadbuffer(L, *env, src, file);
|
||||
return lua::create_runnable(L);
|
||||
} catch (const lua::luaerror& err) {
|
||||
logger.error() << err.what();
|
||||
return [](){};
|
||||
@@ -35,7 +34,7 @@ static lua_State* processCallback(
|
||||
) {
|
||||
auto L = state->getMainThread();
|
||||
try {
|
||||
if (state->eval(L, *env, src, file) != 0) {
|
||||
if (lua::eval(L, *env, src, file) != 0) {
|
||||
return L;
|
||||
}
|
||||
} catch (lua::luaerror& err) {
|
||||
@@ -52,7 +51,7 @@ wstringconsumer scripting::create_wstring_consumer(
|
||||
return [=](const std::wstring& x){
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
lua::pushwstring(L, x);
|
||||
lua::callNoThrow(L, 1);
|
||||
lua::call_nothrow(L, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -65,7 +64,7 @@ wstringsupplier scripting::create_wstring_supplier(
|
||||
return [=](){
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
if (lua_isfunction(L, -1)) {
|
||||
lua::callNoThrow(L, 0);
|
||||
lua::call_nothrow(L, 0);
|
||||
}
|
||||
auto str = lua::require_wstring(L, -1); lua_pop(L, 1);
|
||||
return str;
|
||||
@@ -82,7 +81,7 @@ wstringchecker scripting::create_wstring_validator(
|
||||
return [=](const std::wstring& x){
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
lua::pushwstring(L, x);
|
||||
if (lua::callNoThrow(L, 1))
|
||||
if (lua::call_nothrow(L, 1))
|
||||
return lua::toboolean(L, -1);
|
||||
}
|
||||
return false;
|
||||
@@ -97,7 +96,7 @@ boolconsumer scripting::create_bool_consumer(
|
||||
return [=](bool x){
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
lua::pushboolean(L, x);
|
||||
lua::callNoThrow(L, 1);
|
||||
lua::call_nothrow(L, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -110,7 +109,7 @@ boolsupplier scripting::create_bool_supplier(
|
||||
return [=](){
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
if (lua_isfunction(L, -1)) {
|
||||
lua::callNoThrow(L, 0);
|
||||
lua::call_nothrow(L, 0);
|
||||
}
|
||||
bool x = lua::toboolean(L,-1); lua_pop(L, 1);
|
||||
return x;
|
||||
@@ -127,7 +126,7 @@ doubleconsumer scripting::create_number_consumer(
|
||||
return [=](double x){
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
lua::pushnumber(L, x);
|
||||
lua::callNoThrow(L, 1);
|
||||
lua::call_nothrow(L, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -140,7 +139,7 @@ doublesupplier scripting::create_number_supplier(
|
||||
return [=](){
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
if (lua_isfunction(L, -1)) {
|
||||
lua::callNoThrow(L, 0);
|
||||
lua::call_nothrow(L, 0);
|
||||
}
|
||||
auto x = lua_tonumber(L, -1);
|
||||
lua::pop(L);
|
||||
@@ -160,7 +159,7 @@ int_array_consumer scripting::create_int_array_consumer(
|
||||
for (uint i = 0; i < len; i++) {
|
||||
lua::pushinteger(L, arr[i]);
|
||||
}
|
||||
lua::callNoThrow(L, len);
|
||||
lua::call_nothrow(L, len);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -173,7 +172,7 @@ vec2supplier scripting::create_vec2_supplier(
|
||||
return [=]() {
|
||||
if (auto L = processCallback(env, src, file)) {
|
||||
if (lua_isfunction(L, -1)) {
|
||||
lua::callNoThrow(L, 0);
|
||||
lua::call_nothrow(L, 0);
|
||||
}
|
||||
auto y = lua_tonumber(L, -1); lua::pop(L);
|
||||
auto x = lua_tonumber(L, -1); lua::pop(L);
|
||||
|
||||
Reference in New Issue
Block a user