debugger handles

This commit is contained in:
Greg Wells
2025-06-03 13:42:55 -04:00
parent ed781c1d63
commit ee03b87600
7 changed files with 33 additions and 20 deletions

View File

@@ -2,10 +2,11 @@
#include <core/gryphn_platform_functions.h>
#include "stdio.h"
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info) {
debugger->info = info;
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const struct gnDebuggerInfo_t info) {
*debugger = malloc(sizeof(struct gnDebugger_t));
(*debugger)->info = info;
return GN_SUCCESS;
}
void gnDestroyDebugger(gnDebugger* debugger) {
// debugger->instance->functions->_gnDestroyDebugger(debugger);
void gnDestroyDebugger(gnDebuggerHandle debugger) {
free(debugger);
}

View File

@@ -44,16 +44,23 @@ typedef struct gnDebuggerInfo_t {
void* userData;
} gnDebuggerInfo;
typedef struct gnDebugger_t {
#ifdef GN_REVEAL_IMPL
struct gnDebugger_t {
struct gnPlatformDebugger_t* debugger;
struct gnDebuggerInfo_t info;
gnInstanceHandle instance;
} gnDebugger;
};
#endif
typedef struct gnDebugger_t* gnDebuggerHandle;
typedef gnDebuggerHandle gnDebugger;
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info);
void gnDestroyDebugger(gnDebugger* debugger);
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const struct gnDebuggerInfo_t info);
void gnDestroyDebugger(gnDebuggerHandle debugger);
#ifdef GN_REVEAL_IMPL
static void gnDebuggerSetErrorMessage(gnDebuggerHandle debugger, gnMessageData data) {
if (debugger == NULL) return;
static void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) {
debugger->info.callback(
GN_MESSAGE_ERROR,
GN_DEBUG_MESSAGE_VALIDATION,
@@ -61,3 +68,4 @@ static void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data)
debugger->info.userData
);
}
#endif

View File

@@ -23,8 +23,8 @@ typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, struct gnInstanceInfo_t info);
void (*_gnDestroyInstance)(gnInstanceHandle instance);
gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info);
void (*_gnDestroyDebugger)(gnDebugger* debugger);
gnReturnCode (*_gnCreateDebugger)(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info);
void (*_gnDestroyDebugger)(gnDebuggerHandle debugger);
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
gnBool (*_gnQueueCanPresentToSurface)(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface);

View File

@@ -2,6 +2,7 @@
#include "init/gryphn_init.h"
#include <core/gryphn_platform_functions.h>
#include "core/debugger/gryphn_debugger.h"
#include "core/instance/gryphn_instance.h"
gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInstanceInfo_t info) {
*instanceHandlePtr = malloc(sizeof(struct gnInstance_t));
@@ -42,4 +43,5 @@ void gnDestroyInstance(gnInstanceHandle instance) {
void gnInstanceReleaseDebugger(gnInstanceHandle instance) {
instance->debugger = NULL;
free(instance);
}

View File

@@ -5,7 +5,7 @@
struct gnPlatformInstance_t;
struct gnFunctions_t;
struct gnDynamicLibrary_t;
struct gnDebugger_t;
typedef struct gnDebugger_t* gnDebuggerHandle;
typedef struct gnInstanceInfo_t {
gnString applicationName;
@@ -17,6 +17,7 @@ typedef struct gnInstanceInfo_t {
gnRenderingAPI renderingAPI;
} gnInstanceInfo;
#ifdef GN_REVEAL_IMPL
struct gnInstance_t {
struct gnPlatformInstance_t* instance;
gnBool valid,
@@ -29,12 +30,13 @@ struct gnInstance_t {
struct gnDeviceFunctions_t* deviceFunctions;
struct gnCommandFunctions_t* commandFunctions;
struct gnDebugger_t* debugger;
} gnInstance_t;
gnDebuggerHandle debugger;
};
#endif
typedef struct gnInstance_t* gnInstanceHandle;
typedef struct gnInstance_t* gnInstance;
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, struct gnInstanceInfo_t info);
void gnInstanceAttachDebugger(gnInstanceHandle istance, struct gnDebugger_t* debugger);
void gnInstanceAttachDebugger(gnInstanceHandle istance, gnDebuggerHandle debugger);
void gnInstanceReleaseDebugger(gnInstanceHandle instance);
void gnDestroyInstance(gnInstanceHandle instance);