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; }
|
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);
|
handle = dlopen(extension_path, RTLD_LAZY);
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
std::cerr << "Cannot open extension: " << dlerror() << std::endl;
|
std::cerr << "Cannot open extension: " << dlerror() << std::endl;
|
||||||
@@ -30,7 +30,7 @@ void yaze_load_c_extension(const char* extension_path) {
|
|||||||
|
|
||||||
extension = get_extension();
|
extension = get_extension();
|
||||||
if (extension && extension->initialize) {
|
if (extension && extension->initialize) {
|
||||||
extension->initialize();
|
extension->initialize(context);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Failed to initialize the extension." << std::endl;
|
std::cerr << "Failed to initialize the extension." << std::endl;
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ yaze_extension* get_yaze_extension();
|
|||||||
/**
|
/**
|
||||||
* @brief Load a C 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.
|
* @brief Load a Python extension.
|
||||||
|
|||||||
@@ -1,27 +1,48 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "ext/extension.h"
|
#include "ext/extension.h"
|
||||||
#include "yaze.h"
|
#include "yaze.h"
|
||||||
|
|
||||||
void my_extension_initialize() {
|
void my_extension_initialize(yaze_editor_context* context) {
|
||||||
// Custom initialization code
|
printf("My Extension Initialized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_extension_cleanup() {
|
void my_extension_cleanup(void) { printf("My Extension Cleaned Up\n"); }
|
||||||
// Custom cleanup code
|
|
||||||
|
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) {
|
void my_extension_manipulate_rom(z3_rom* rom) {
|
||||||
// Modify ROM data
|
// Modify ROM data
|
||||||
}
|
}
|
||||||
|
|
||||||
yaze_extension* get_yaze_extension() {
|
void my_extension_register_commands(void) {
|
||||||
static yaze_extension ext = {
|
// Register custom commands
|
||||||
"My Extension",
|
}
|
||||||
"1.0",
|
|
||||||
my_extension_initialize, // Initialization function
|
void my_extension_handle_file_format(void) {
|
||||||
my_extension_cleanup, // Cleanup function
|
// Handle custom file formats
|
||||||
NULL, // extend_functionality
|
}
|
||||||
NULL, // render_ui
|
|
||||||
my_extension_manipulate_rom // manipulate_rom
|
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;
|
return &ext;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user