update extension c example
This commit is contained in:
@@ -9,7 +9,7 @@ static yaze_extension* extension = nullptr;
|
||||
|
||||
yaze_extension* get_yaze_extension() { return extension; }
|
||||
|
||||
void yaze_load_c_extension(const char* extension_path) {
|
||||
void yaze_load_c_extension(const char* extension_path, yaze_editor_context* context) {
|
||||
handle = dlopen(extension_path, RTLD_LAZY);
|
||||
if (!handle) {
|
||||
std::cerr << "Cannot open extension: " << dlerror() << std::endl;
|
||||
@@ -30,7 +30,7 @@ void yaze_load_c_extension(const char* extension_path) {
|
||||
|
||||
extension = get_extension();
|
||||
if (extension && extension->initialize) {
|
||||
extension->initialize();
|
||||
extension->initialize(context);
|
||||
} else {
|
||||
std::cerr << "Failed to initialize the extension." << std::endl;
|
||||
dlclose(handle);
|
||||
|
||||
@@ -92,7 +92,7 @@ yaze_extension* get_yaze_extension();
|
||||
/**
|
||||
* @brief Load a C extension.
|
||||
*/
|
||||
void yaze_load_c_extension(const char* extension_path);
|
||||
void yaze_load_c_extension(const char* extension_path, yaze_editor_context* context);
|
||||
|
||||
/**
|
||||
* @brief Load a Python extension.
|
||||
|
||||
@@ -1,27 +1,48 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ext/extension.h"
|
||||
#include "yaze.h"
|
||||
|
||||
void my_extension_initialize() {
|
||||
// Custom initialization code
|
||||
void my_extension_initialize(yaze_editor_context* context) {
|
||||
printf("My Extension Initialized\n");
|
||||
}
|
||||
|
||||
void my_extension_cleanup() {
|
||||
// Custom cleanup code
|
||||
void my_extension_cleanup(void) { printf("My Extension Cleaned Up\n"); }
|
||||
|
||||
void my_extension_extend_ui(yaze_editor_context* context) {
|
||||
// Add a custom tab or panel to the editor
|
||||
}
|
||||
|
||||
void my_extension_manipulate_rom(z3_rom* rom) {
|
||||
// Modify ROM data
|
||||
}
|
||||
|
||||
yaze_extension* get_yaze_extension() {
|
||||
static yaze_extension ext = {
|
||||
"My Extension",
|
||||
"1.0",
|
||||
my_extension_initialize, // Initialization function
|
||||
my_extension_cleanup, // Cleanup function
|
||||
NULL, // extend_functionality
|
||||
NULL, // render_ui
|
||||
my_extension_manipulate_rom // manipulate_rom
|
||||
};
|
||||
void my_extension_register_commands(void) {
|
||||
// Register custom commands
|
||||
}
|
||||
|
||||
void my_extension_handle_file_format(void) {
|
||||
// Handle custom file formats
|
||||
}
|
||||
|
||||
void my_extension_register_event_hooks(yaze_event_type event,
|
||||
yaze_event_hook_func hook) {
|
||||
// Register event hooks for specific events
|
||||
}
|
||||
|
||||
void my_extension_register_custom_tools(void) {
|
||||
// Register custom tools or editors
|
||||
}
|
||||
|
||||
yaze_extension* get_yaze_extension(void) {
|
||||
static yaze_extension ext = {"My Extension",
|
||||
"1.0",
|
||||
my_extension_initialize,
|
||||
my_extension_cleanup,
|
||||
my_extension_manipulate_rom,
|
||||
my_extension_extend_ui,
|
||||
my_extension_register_commands,
|
||||
my_extension_register_custom_tools,
|
||||
my_extension_register_event_hooks};
|
||||
return &ext;
|
||||
}
|
||||
Reference in New Issue
Block a user