Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 0cd8ff51 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Register functions in modules, using .def files (gitlab things that

there is some php files in the project...)
parent 377e3253
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!95Process queue
Fichier déplacé
...@@ -12,7 +12,7 @@ struct lkt_state; ...@@ -12,7 +12,7 @@ struct lkt_state;
#define value(key, val) key " = " val "\n" #define value(key, val) key " = " val "\n"
#define value_opt(key, val) value(key, val) #define value_opt(key, val) value(key, val)
static const char *const lkt_default_config_file = static const char *const lkt_default_config_file =
#include <lektor/config.inc> #include <lektor/config.def>
; ;
#undef value #undef value
#undef value_opt #undef value_opt
......
...@@ -17,7 +17,6 @@ int load_sdl2(void *mod, struct lkt_state *srv, void *handle); ...@@ -17,7 +17,6 @@ int load_sdl2(void *mod, struct lkt_state *srv, void *handle);
bool module_sdl2_new(struct lkt_win *const win); bool module_sdl2_new(struct lkt_win *const win);
void module_sdl2_close(struct lkt_win *const win); void module_sdl2_close(struct lkt_win *const win);
void module_sdl2_free(struct lkt_win *const win); void module_sdl2_free(struct lkt_win *const win);
void module_sdl2_attach(struct lkt_win *const win, void *server);
bool module_sdl2_toggle_pause(struct lkt_win *const win); bool module_sdl2_toggle_pause(struct lkt_win *const win);
bool module_sdl2_load_file(struct lkt_win *const win, const char *filepath); bool module_sdl2_load_file(struct lkt_win *const win, const char *filepath);
......
...@@ -6,13 +6,14 @@ struct lkt_state; ...@@ -6,13 +6,14 @@ struct lkt_state;
with a name that can be generated or red from a config file. */ with a name that can be generated or red from a config file. */
struct module_reg { struct module_reg {
const char *name; const char *name;
int (*func)(void *, struct lkt_state *, void *); void (*func)(void);
}; };
extern struct module_reg *reg; extern struct module_reg *reg;
#define REG_BEGIN(reg) struct module_reg reg[] = { #define REG_BEGIN(reg) struct module_reg reg[] = {
#define REG_ADD(__func) { .name = #__func, .func = __func }, #define REG_ADD(__f) { .name = #__f, .func = (void(*)(void)) __f },
#define REG_ADD_NAMED(__n, __f) { .name = __n, .func = (void(*)(void)) __f },
#define REG_END() { .name = NULL, .func = NULL } }; #define REG_END() { .name = NULL, .func = NULL } };
/* If handle is NULL, file is unused and the reg is red. Otherwise, /* If handle is NULL, file is unused and the reg is red. Otherwise,
......
...@@ -171,7 +171,7 @@ database_validate_conf(volatile sqlite3 *db) ...@@ -171,7 +171,7 @@ database_validate_conf(volatile sqlite3 *db)
section); \ section); \
return false; \ return false; \
} }
#include <lektor/config.inc> #include <lektor/config.def>
#undef section #undef section
#undef value #undef value
#undef value_opt #undef value_opt
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <lektor/module/mpv.h> #include <lektor/module/mpv.h>
#include <mthread/mthread.h> #include <mthread/mthread.h>
#include <lektor/thread.h> #include <lektor/thread.h>
#include <lektor/reg.h>
#include <sched.h> #include <sched.h>
#include <assert.h> #include <assert.h>
...@@ -405,3 +406,15 @@ module_sdl2_handle_events(struct lkt_win *const win, volatile sqlite3 *db, ...@@ -405,3 +406,15 @@ module_sdl2_handle_events(struct lkt_win *const win, volatile sqlite3 *db,
UNUSED(win, db, mpd_idle_events); UNUSED(win, db, mpd_idle_events);
return true; return true;
} }
REG_BEGIN(sdl2_reg)
REG_ADD_NAMED("new", module_sdl2_new)
REG_ADD_NAMED("free", module_sdl2_free)
REG_ADD_NAMED("handle", module_sdl2_handle_events)
REG_ADD(module_sdl2_close)
REG_ADD(module_sdl2_toggle_pause)
REG_ADD(module_sdl2_load_file)
REG_ADD(module_sdl2_set_volume)
REG_ADD(module_sdl2_get_duration)
REG_ADD(module_sdl2_get_elapsed)
REG_END()
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <lektor/module/mpv.h> #include <lektor/module/mpv.h>
#include <lektor/database.h> #include <lektor/database.h>
#include <lektor/commands.h> #include <lektor/commands.h>
#include <lektor/reg.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
...@@ -276,3 +277,15 @@ module_x11_handle_events(struct lkt_win *const win, volatile sqlite3 *db, ...@@ -276,3 +277,15 @@ module_x11_handle_events(struct lkt_win *const win, volatile sqlite3 *db,
! lmpv_handle(win, xwin->mpv, db, mpd_idle_events, ! lmpv_handle(win, xwin->mpv, db, mpd_idle_events,
&xwin->mpv_time_pos, &xwin->mpv_duration); &xwin->mpv_time_pos, &xwin->mpv_duration);
} }
REG_BEGIN(x11_reg)
REG_ADD_NAMED("new", module_x11_new)
REG_ADD_NAMED("free", module_x11_free)
REG_ADD_NAMED("handle", module_x11_handle_events)
REG_ADD(module_x11_close)
REG_ADD(module_x11_toggle_pause)
REG_ADD(module_x11_load_file)
REG_ADD(module_x11_set_volume)
REG_ADD(module_x11_get_duration)
REG_ADD(module_x11_get_elapsed)
REG_END()
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter