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

Can now export regs + define repo reg

parent b4656680
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!102Modules
Ce commit fait partie de la requête de fusion !102. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
#pragma once #if ! defined(__REG_H__)
struct lkt_state; struct lkt_state;
...@@ -9,18 +9,28 @@ struct module_reg { ...@@ -9,18 +9,28 @@ struct module_reg {
void (*func)(void); void (*func)(void);
}; };
extern struct module_reg *reg;
#define REG_BEGIN(reg) struct module_reg reg[] = { #define REG_BEGIN(reg) struct module_reg reg[] = {
#define REG_ADD(__f) { .name = #__f, .func = (void(*)(void)) __f }, #define REG_ADD(__f) { .name = #__f, .func = (void(*)(void)) __f },
#define REG_ADD_NAMED(__n, __f) { .name = __n, .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 ! defined(_STATIC_MODULES)
#define REG_EXPORT(__reg) struct module_reg *__reg__ = __reg;
#else
#define REG_EXPORT(__reg)
#endif
/* 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,
we use dlfcn to search for the symbol which is returned. If *handle we use dlfcn to search for the symbol which is returned. If *handle
is NULL, it will be created by opening the file. */ is NULL, it will be created by opening the file. */
void *reg_pick(const char *file, void **handle, const char *symbol); void *reg_pick(const char *file, void **handle, const char *symbol);
/* Get the reg from a .so file. This reg must be exported by the
shared library with REG_EXPORT. Note that this reg is named `__reg__`,
thus no symbol must be named `__reg__` in the .so file.
Returns 0 on success, something else on error. */
int reg_from_file(const char *file, struct module_reg *ret);
/* Set the ref for this .a / .so file */ /* Set the ref for this .a / .so file */
void reg_set(struct module_reg *); void reg_set(struct module_reg *);
...@@ -28,3 +38,5 @@ void reg_set(struct module_reg *); ...@@ -28,3 +38,5 @@ void reg_set(struct module_reg *);
type is done, it is up to the user to check if the structure passed as a type is done, it is up to the user to check if the structure passed as a
`void*` is the right structure. */ `void*` is the right structure. */
int load_module_by_name(struct lkt_state *srv, const char *name, void *mod); int load_module_by_name(struct lkt_state *srv, const char *name, void *mod);
#endif
...@@ -423,3 +423,4 @@ REG_ADD(module_sdl2_set_volume) ...@@ -423,3 +423,4 @@ REG_ADD(module_sdl2_set_volume)
REG_ADD(module_sdl2_get_duration) REG_ADD(module_sdl2_get_duration)
REG_ADD(module_sdl2_get_elapsed) REG_ADD(module_sdl2_get_elapsed)
REG_END() REG_END()
REG_EXPORT(sdl2_reg)
...@@ -275,3 +275,4 @@ REG_ADD(module_x11_set_volume) ...@@ -275,3 +275,4 @@ REG_ADD(module_x11_set_volume)
REG_ADD(module_x11_get_duration) REG_ADD(module_x11_get_duration)
REG_ADD(module_x11_get_elapsed) REG_ADD(module_x11_get_elapsed)
REG_END() REG_END()
REG_EXPORT(x11_reg)
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <mthread/mthread.h> #include <mthread/mthread.h>
#include <lektor/database.h> #include <lektor/database.h>
#include <lektor/net.h> #include <lektor/net.h>
#include <lektor/reg.h>
static volatile unsigned int curl_init = false; static volatile unsigned int curl_init = false;
...@@ -491,3 +492,8 @@ repo_update(struct lkt_repo *const repo) ...@@ -491,3 +492,8 @@ repo_update(struct lkt_repo *const repo)
{ {
return mthread_create(NULL, ATTR_DETACHED, __repo_get_all_id_async, repo); return mthread_create(NULL, ATTR_DETACHED, __repo_get_all_id_async, repo);
} }
REG_BEGIN(repo_reg)
REG_ADD_NAMED("new", load_repo_https)
REG_END()
REG_EXPORT(repo_reg)
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