This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch efl
in repository laugh.
View the commit online.
commit cf705876907228ac2cb9cde3f270b89e5ef7592c
Author: melerva <[email protected]>
AuthorDate: Sat Sep 20 21:51:18 2025 -0400
Now for the hard part
---
meson.build | 7 +++++++
src/modules/laugh_ui.c | 39 ++++-----------------------------------
src/modules/laugh_ui.lua | 29 +++++++++++++++++++++++++++++
src/packages.c | 12 ++++++++++++
4 files changed, 52 insertions(+), 35 deletions(-)
diff --git a/meson.build b/meson.build
index 5141e31..5cd1c32 100644
--- a/meson.build
+++ b/meson.build
@@ -27,12 +27,19 @@ conf.set('LAUGH_USE_EFL_CORE', efl_core_dep.found())
conf.set('LAUGH_USE_EFL_NET', efl_net_dep.found())
conf.set('LAUGH_USE_EFL_UI', efl_ui_dep.found())
+prog_xxd = find_program('xxd')
+
laugh_sources = [
'src/main.c',
'src/modules/laugh.c',
'src/modules/laugh_ui.c',
'src/packages.c',
'src/require.c',
+ custom_target('laugh_luaui.h',
+ output: 'laugh_luaui.h',
+ input: 'src/modules/laugh_ui.lua',
+ command: [prog_xxd, '-i', '-n', 'luaui_source', '@INPUT@', '@OUTPUT@'],
+ ),
]
if get_option('mod_packagegc')
diff --git a/src/modules/laugh_ui.c b/src/modules/laugh_ui.c
index 884ff7c..929b1e0 100644
--- a/src/modules/laugh_ui.c
+++ b/src/modules/laugh_ui.c
@@ -1,42 +1,11 @@
#include "config.h"
-#include <lauxlib.h>
#include <lua.h>
-#include <lualib.h>
-
-/* Wrap in ifdefs to avoid compiling in code that'll never be used. */
-
-#ifdef LAUGH_USE_EFL_UI
-# include <Efl_Ui.h>
-
-static int laugh_ui_new(lua_State *const L) {
- aux_lines(L, 0);
- return 1;
-}
-
-static const luaL_Reg laugh_ui_efl_lib[] = {
- {"new", laugh_ui_new},
- {NULL, NULL},
-};
-#endif // LAUGH_USE_EFL_UI
+#include <lauxlib.h>
int luaopen_laugh_ui(lua_State *const L) {
- /* TODO: detect which backend(s) will work, pick one.
- * For example, check for graphics and use Qt/EFL,
- * use ncurses if no graphics.
- * Check an environment variable or lua global variable
- * for chosen backend before autodetecting. */
-
- /* bonus TODO: laugh.ui is generic and abstracted.
- * expose laugh.ui.$backend for advanced usage later.
- * Actually, laugh.ui should be written directly in lua
- * and have those functions call the more advanced things. */
-#ifdef LAUGH_USE_EFL_UI
- luaL_newlib(L, laugh_ui_efl_lib);
- lua_pushstring(L, "efl");
- lua_setfield(L, -2, backend);
-#else
- lua_pushnil();
-#endif
+#include "laugh_luaui.h"
+ luaL_loadstring(L, luaui_source);
+ lua_call(L, 0, 1);
return 1;
}
diff --git a/src/modules/laugh_ui.lua b/src/modules/laugh_ui.lua
new file mode 100644
index 0000000..6a5419f
--- /dev/null
+++ b/src/modules/laugh_ui.lua
@@ -0,0 +1,29 @@
+local laugh_ui
+
+do
+ local envbackend = require('os').getenv("LAUGH_UI")
+
+ if envbackend then
+ -- TODO: restrict to allowed values
+ laugh_ui = {
+ backend = envbackend,
+ }
+ laugh_ui[envbackend] = require('laugh.ui.' .. envbackend)
+
+ if not laugh_ui[envbackend] then
+ error('Requested "' .. envbackend .. '" UI backend not available.')
+ end
+ else
+ laugh_ui = {
+ efl = require('laugh.ui.efl'),
+ backend = 'none',
+ }
+ end
+end
+
+if (laugh_ui.efl) then -- Enlightenment Foundation Library UI backend
+ -- TODO: check if graphics, discard backend otherwise
+ laugh_ui.backend = 'efl'
+end
+
+return laugh_ui
diff --git a/src/packages.c b/src/packages.c
index 06e9dbd..3e1f467 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -12,6 +12,12 @@
lua_setfield(L, -2, module_name); \
}
+/* TODO: this is unused code many times; preprocess it out? */
+static int null_loader(lua_State *const L) {
+ lua_pushnil(L);
+ return 1;
+}
+
void init_preloaders(lua_State *const L) {
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");
@@ -19,6 +25,12 @@ void init_preloaders(lua_State *const L) {
REGISTER_LOADER("laugh", luaopen_laugh);
REGISTER_LOADER("laugh.ui", luaopen_laugh_ui);
+#ifdef LAUGH_USE_EFL_UI
+ REGISTER_LOADER("laugh.ui.efl", luaopen_laugh_ui_efl);
+#else // LAUGH_MOD_PACKAGEGC
+ REGISTER_LOADER("laugh.ui.efl", null_loader);
+#endif // LAUGH_MOD_PACKAGEGC
+
#ifdef LAUGH_MOD_PACKAGEGC
REGISTER_LOADER("mod_packagegc", luaopen_mod_packagegc);
#endif // LAUGH_MOD_PACKAGEGC
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.