#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct WjApp WjApp;
typedef enum {
WJ_OK = 0,
WJ_INVALID_PARAMETER = 1,
WJ_PLUGIN_NOT_FOUND = 2,
WJ_DEPENDENCY_ERROR = 3,
WJ_ALREADY_LOADED = 4,
WJ_LOAD_FAILED = 5,
WJ_UNLOAD_FAILED = 6,
WJ_VERSION_MISMATCH = 7,
WJ_CIRCULAR_DEPENDENCY = 8,
} WjPluginErrorCode;
typedef enum {
WJ_CATEGORY_RENDERING = 0,
WJ_CATEGORY_PHYSICS = 1,
WJ_CATEGORY_AUDIO = 2,
WJ_CATEGORY_AI = 3,
WJ_CATEGORY_EDITOR = 4,
WJ_CATEGORY_ASSETS = 5,
WJ_CATEGORY_NETWORKING = 6,
WJ_CATEGORY_PLATFORM = 7,
WJ_CATEGORY_OTHER = 8,
} WjPluginCategory;
typedef struct {
const char* name;
const char* version;
const char* description;
const char* author;
const char* license;
WjPluginCategory category;
bool supports_hot_reload;
} WjPluginInfo;
typedef struct {
const char* name;
const char* version;
} WjPluginDependency;
#ifdef _WIN32
__declspec(dllexport)
#endif
WjPluginInfo wj_plugin_info(void) {
WjPluginInfo info = {
.name = "example_plugin",
.version = "1.0.0",
.description = "Example plugin demonstrating C FFI",
.author = "Windjammer Team",
.license = "MIT",
.category = WJ_CATEGORY_OTHER,
.supports_hot_reload = true,
};
return info;
}
#ifdef _WIN32
__declspec(dllexport)
#endif
const WjPluginDependency* wj_plugin_dependencies(size_t* out_count) {
*out_count = 0;
return NULL;
}
#ifdef _WIN32
__declspec(dllexport)
#endif
WjPluginErrorCode wj_plugin_init(WjApp* app) {
printf("[ExamplePlugin] Initializing...\n");
printf("[ExamplePlugin] App handle: %p\n", (void*)app);
printf("[ExamplePlugin] Initialized successfully!\n");
return WJ_OK;
}
#ifdef _WIN32
__declspec(dllexport)
#endif
WjPluginErrorCode wj_plugin_cleanup(WjApp* app) {
printf("[ExamplePlugin] Cleaning up...\n");
printf("[ExamplePlugin] App handle: %p\n", (void*)app);
printf("[ExamplePlugin] Cleaned up successfully!\n");
return WJ_OK;
}