allow debugger to be created before the instance and attached to it

later
This commit is contained in:
Greg Wells
2025-05-25 07:32:05 -04:00
parent 5b6360f26f
commit 6c4bd6a572
7 changed files with 55 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
#include "gryphn_instance.h"
#include "init/gryphn_init.h"
#include <core/gryphn_platform_functions.h>
#include "core/debugger/gryphn_debugger.h"
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) {
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
@@ -11,6 +12,31 @@ gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info
gnLoadFunctions(instance->dynamicLib, instance->functions);
return instance->functions->_gnCreateInstance(instance, info);
}
void gnInstanceAttachDebugger(gnInstance *instance, struct gnDebugger_t *debugger) {
if (instance->debugger != NULL) {
gnDebuggerSetErrorMessage(debugger, (gnMessageData){
.message = gnCreateString("Debugger already attached to instance")
});
}
instance->debugger = debugger;
debugger->instance = instance;
gnReturnCode debuggerInfo = instance->functions->_gnCreateDebugger(debugger, instance, debugger->info);
if (debuggerInfo != GN_SUCCESS) {
gnDebuggerSetErrorMessage(debugger, (gnMessageData){
.message = gnCreateString("Failed to attach debugger to instance")
});
}
}
#include "stdio.h"
void gnDestroyInstance(gnInstance* instance) {
if (instance->debugger) {
instance->functions->_gnDestroyDebugger(instance->debugger);
}
instance->functions->_gnDestroyInstance(instance);
}
void gnInstanceReleaseDebugger(gnInstance* instance) {
instance->debugger = NULL;
}

View File

@@ -28,4 +28,6 @@ typedef struct gnInstance_t {
} gnInstance;
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
void gnInstanceAttachDebugger(gnInstance* istance, struct gnDebugger_t* debugger);
void gnInstanceReleaseDebugger(gnInstance* instance);
void gnDestroyInstance(gnInstance* instance);