aboutsummaryrefslogtreecommitdiff
path: root/src/LuaRuntime.cpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-22 17:17:15 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-22 18:26:37 +0530
commit0d728071e3287a71ce7928640e63c19f4d0ab00f (patch)
treed6e9fc90331e690dbc439e7ab8b9983df2d796a6 /src/LuaRuntime.cpp
parentf09f1aa704f06472ec134b40e2f69bf3279c3f06 (diff)
downloadnull-browser-0d728071e3287a71ce7928640e63c19f4d0ab00f.tar.gz
null-browser-0d728071e3287a71ce7928640e63c19f4d0ab00f.zip
Build fixes + formatting
Diffstat (limited to 'src/LuaRuntime.cpp')
-rw-r--r--src/LuaRuntime.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/LuaRuntime.cpp b/src/LuaRuntime.cpp
index f83ee48..cdf95b0 100644
--- a/src/LuaRuntime.cpp
+++ b/src/LuaRuntime.cpp
@@ -18,7 +18,7 @@ LuaRuntime::LuaRuntime() {
luaL_Reg weblib[] = {
{"open", &LuaRuntime::lua_onUrlOpen},
{"tabopen", &LuaRuntime::lua_onUrlTabOpen},
- {NULL, NULL},
+ {nullptr, nullptr},
};
luaL_newlib(state, weblib);
lua_setglobal(state, web_global_name);
@@ -60,13 +60,13 @@ void LuaRuntime::stopEventLoop() {
void LuaRuntime::evaluate(QString code) {
eventLoop->queueTask([this, code]() {
if (luaL_dostring(state, code.toStdString().c_str()) != LUA_OK) {
- auto value = lua_tostring(state, -1);
+ const char *value = lua_tostring(state, -1);
lua_pop(state, 1);
qDebug() << "Lua Error: " << value;
emit evaluationFailed(value);
} else {
- auto value = getValue(-1);
+ QVariant value = getValue(-1);
lua_pop(state, 1);
qDebug() << "result: " << value;
@@ -76,7 +76,7 @@ void LuaRuntime::evaluate(QString code) {
}
QVariant LuaRuntime::evaluateSync(QString code) {
- auto result = luaL_dostring(state, code.toStdString().c_str());
+ luaL_dostring(state, code.toStdString().c_str());
return getValue(-1); // TODO: error handling
}
@@ -113,25 +113,21 @@ int LuaRuntime::lua_onUrlTabOpen(lua_State *state) {
int LuaRuntime::lua_addKeymap(lua_State *state) {
const char *mode = lua_tostring(state, 1);
const char *keyseq = lua_tostring(state, 2);
- qDebug() << "Adduing" << mode << keyseq;
-
- qDebug() << "---" << lua_isfunction(state, 3);
lua_pushvalue(state, 3);
int functionRef = luaL_ref(state, LUA_REGISTRYINDEX);
auto action = [state, functionRef]() {
- qDebug() << "Hello";
+ qDebug() << "key action";
lua_rawgeti(state, LUA_REGISTRYINDEX, functionRef);
if (lua_pcall(state, 0, 0, 0) != LUA_OK) {
const char *error = lua_tostring(state, -1);
qDebug() << "Error calling Lua function:" << error;
lua_pop(state, 1);
- } else {
- qDebug() << "Done";
}
lua_pop(state, 1);
};
+ // TODO: Cleanup function ref on after keymap clear
auto runtime = LuaRuntime::instance();
emit runtime->keymapAddRequested(mode, keyseq, action);