Reformat
This commit is contained in:
parent
e24055f5b8
commit
0b81199965
@ -4,20 +4,20 @@
|
|||||||
|
|
||||||
static pumpkin_plugin_t g_plugin = {0};
|
static pumpkin_plugin_t g_plugin = {0};
|
||||||
|
|
||||||
void pumpkin_register_plugin(pumpkin_plugin_t plugin) {
|
void pumpkin_register_plugin(pumpkin_plugin_t plugin) { g_plugin = plugin; }
|
||||||
g_plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
// WIT exports
|
// WIT exports
|
||||||
|
|
||||||
void exports_pumpkin_plugin_metadata_get_metadata(exports_pumpkin_plugin_metadata_plugin_metadata_t *ret) {
|
void exports_pumpkin_plugin_metadata_get_metadata(
|
||||||
|
exports_pumpkin_plugin_metadata_plugin_metadata_t *ret) {
|
||||||
if (g_plugin.get_metadata) {
|
if (g_plugin.get_metadata) {
|
||||||
pumpkin_metadata_t meta = g_plugin.get_metadata();
|
pumpkin_metadata_t meta = g_plugin.get_metadata();
|
||||||
plugin_string_dup(&(ret->name), meta.name);
|
plugin_string_dup(&(ret->name), meta.name);
|
||||||
plugin_string_dup(&(ret->version), meta.version);
|
plugin_string_dup(&(ret->version), meta.version);
|
||||||
|
|
||||||
ret->authors.len = meta.authors_count;
|
ret->authors.len = meta.authors_count;
|
||||||
ret->authors.ptr = (plugin_string_t*)malloc(ret->authors.len * sizeof(plugin_string_t));
|
ret->authors.ptr =
|
||||||
|
(plugin_string_t *)malloc(ret->authors.len * sizeof(plugin_string_t));
|
||||||
for (size_t i = 0; i < ret->authors.len; ++i) {
|
for (size_t i = 0; i < ret->authors.len; ++i) {
|
||||||
plugin_string_dup(&(ret->authors.ptr[i]), meta.authors[i]);
|
plugin_string_dup(&(ret->authors.ptr[i]), meta.authors[i]);
|
||||||
}
|
}
|
||||||
@ -25,49 +25,60 @@ void exports_pumpkin_plugin_metadata_get_metadata(exports_pumpkin_plugin_metadat
|
|||||||
plugin_string_dup(&(ret->description), meta.description);
|
plugin_string_dup(&(ret->description), meta.description);
|
||||||
|
|
||||||
ret->dependencies.len = meta.dependencies_count;
|
ret->dependencies.len = meta.dependencies_count;
|
||||||
ret->dependencies.ptr = (plugin_string_t*)malloc(ret->dependencies.len * sizeof(plugin_string_t));
|
ret->dependencies.ptr = (plugin_string_t *)malloc(ret->dependencies.len *
|
||||||
|
sizeof(plugin_string_t));
|
||||||
for (size_t i = 0; i < ret->dependencies.len; ++i) {
|
for (size_t i = 0; i < ret->dependencies.len; ++i) {
|
||||||
plugin_string_dup(&(ret->dependencies.ptr[i]), meta.dependencies[i]);
|
plugin_string_dup(&(ret->dependencies.ptr[i]), meta.dependencies[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret->permissions.len = meta.permissions_count;
|
ret->permissions.len = meta.permissions_count;
|
||||||
ret->permissions.ptr = (plugin_string_t*)malloc(ret->permissions.len * sizeof(plugin_string_t));
|
ret->permissions.ptr = (plugin_string_t *)malloc(ret->permissions.len *
|
||||||
|
sizeof(plugin_string_t));
|
||||||
for (size_t i = 0; i < ret->permissions.len; ++i) {
|
for (size_t i = 0; i < ret->permissions.len; ++i) {
|
||||||
plugin_string_dup(&(ret->permissions.ptr[i]), meta.permissions[i]);
|
plugin_string_dup(&(ret->permissions.ptr[i]), meta.permissions[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exports_plugin_on_load(plugin_own_context_t context_handle, plugin_string_t *err) {
|
bool exports_plugin_on_load(plugin_own_context_t context_handle,
|
||||||
|
plugin_string_t *err) {
|
||||||
if (g_plugin.on_load) {
|
if (g_plugin.on_load) {
|
||||||
g_plugin.on_load(context_handle);
|
g_plugin.on_load(context_handle);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exports_plugin_on_unload(plugin_own_context_t context_handle, plugin_string_t *err) {
|
bool exports_plugin_on_unload(plugin_own_context_t context_handle,
|
||||||
|
plugin_string_t *err) {
|
||||||
if (g_plugin.on_unload) {
|
if (g_plugin.on_unload) {
|
||||||
g_plugin.on_unload(context_handle);
|
g_plugin.on_unload(context_handle);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exports_plugin_handle_event(uint32_t event_id, plugin_own_server_instance_t server, plugin_event_t *event, plugin_event_t *ret) {
|
void exports_plugin_handle_event(uint32_t event_id,
|
||||||
|
plugin_own_server_instance_t server,
|
||||||
|
plugin_event_t *event, plugin_event_t *ret) {
|
||||||
// Basic event pass-through
|
// Basic event pass-through
|
||||||
*ret = *event;
|
*ret = *event;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exports_plugin_handle_command(uint32_t command_id, plugin_own_command_sender_t sender, plugin_own_server_instance_t server, plugin_own_consumed_args_t args, int32_t *ret, plugin_command_error_t *err) {
|
bool exports_plugin_handle_command(uint32_t command_id,
|
||||||
|
plugin_own_command_sender_t sender,
|
||||||
|
plugin_own_server_instance_t server,
|
||||||
|
plugin_own_consumed_args_t args,
|
||||||
|
int32_t *ret, plugin_command_error_t *err) {
|
||||||
err->tag = PUMPKIN_PLUGIN_COMMAND_COMMAND_ERROR_COMMAND_FAILED;
|
err->tag = PUMPKIN_PLUGIN_COMMAND_COMMAND_ERROR_COMMAND_FAILED;
|
||||||
|
|
||||||
plugin_string_t str;
|
plugin_string_t str;
|
||||||
plugin_string_set(&str, "Command not implemented");
|
plugin_string_set(&str, "Command not implemented");
|
||||||
|
|
||||||
pumpkin_plugin_text_own_text_component_t text = pumpkin_plugin_text_static_text_component_text(&str);
|
pumpkin_plugin_text_own_text_component_t text =
|
||||||
|
pumpkin_plugin_text_static_text_component_text(&str);
|
||||||
err->val.command_failed = text;
|
err->val.command_failed = text;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exports_plugin_handle_task(uint32_t handler_id, plugin_own_server_instance_t server) {
|
void exports_plugin_handle_task(uint32_t handler_id,
|
||||||
}
|
plugin_own_server_instance_t server) {}
|
||||||
|
|||||||
@ -8,18 +8,18 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* name;
|
const char *name;
|
||||||
const char* version;
|
const char *version;
|
||||||
|
|
||||||
const char** authors;
|
const char **authors;
|
||||||
size_t authors_count;
|
size_t authors_count;
|
||||||
|
|
||||||
const char* description;
|
const char *description;
|
||||||
|
|
||||||
const char** dependencies;
|
const char **dependencies;
|
||||||
size_t dependencies_count;
|
size_t dependencies_count;
|
||||||
|
|
||||||
const char** permissions;
|
const char **permissions;
|
||||||
size_t permissions_count;
|
size_t permissions_count;
|
||||||
} pumpkin_metadata_t;
|
} pumpkin_metadata_t;
|
||||||
|
|
||||||
@ -36,9 +36,7 @@ typedef struct {
|
|||||||
void pumpkin_register_plugin(pumpkin_plugin_t plugin);
|
void pumpkin_register_plugin(pumpkin_plugin_t plugin);
|
||||||
|
|
||||||
#define REGISTER_PUMPKIN_PLUGIN(plugin) \
|
#define REGISTER_PUMPKIN_PLUGIN(plugin) \
|
||||||
void exports_plugin_init_plugin(void) { \
|
void exports_plugin_init_plugin(void) { pumpkin_register_plugin(plugin); }
|
||||||
pumpkin_register_plugin(plugin); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user