libGimbal 0.0.0 (PRERELEASE)
Ultimate C17/C++20 Core Utility Library and Cross-Language Runtime Framework
gimbal_ext.h
Go to the documentation of this file.
1
6#ifndef GIMBAL_EXT_H
7#define GIMBAL_EXT_H
8
9#include "../core/gimbal_typedefs.h"
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#define GBL_META_LOG_LEVEL_TABLE ( \
16 ( GBL_LOG_LEVEL, LogLevel, "Log Message Severity Level", gblLogLevelString), \
17 ( \
18 (GBL_LOG_LEVEL_DEBUG, 0x1, Debug, "Debug"), \
19 (GBL_LOG_LEVEL_VERBOSE, 0x2, Verbose, "Verbose"), \
20 (GBL_LOG_LEVEL_INFO, 0x4, Info, "Info"), \
21 (GBL_LOG_LEVEL_WARNING, 0x8, Warning, "Warning"), \
22 (GBL_LOG_LEVEL_ERROR, 0x10, Error, "Error"), \
23 (GBL_LOG_LEVEL_COUNT, 0x5, Count, "# of Levels") \
24 ) \
25 )
26
27GBL_ENUM_TABLE_DECLARE(GBL_META_LOG_LEVEL_TABLE);
28
29
30
31GBL_FORWARD_DECLARE_STRUCT(GblStackFrame);
32
33typedef GBL_RESULT (*GblExtLogWriteFn) (const GblStackFrame*, GBL_LOG_LEVEL, const char*, va_list);
34typedef GBL_RESULT (*GblExtLogPushFn) (const GblStackFrame*);
35typedef GBL_RESULT (*GblExtLogPopFn) (const GblStackFrame*, uint32_t);
36
37//Custom allocators
38typedef GBL_RESULT (*GblExtMemAllocFn) (const GblStackFrame*, GblSize, GblSize, const char*, void**);
39typedef GBL_RESULT (*GblExtMemReallocFn) (const GblStackFrame*, void*, GblSize, GblSize, void**);
40typedef GBL_RESULT (*GblExtMemFreeFn) (const GblStackFrame*, void*);
41
42//define all extension points and shit in one centralized location
43
44
45
46/*Call everything through these top-level macros so that user
47 is able to override them at compile-time + use inline functions
48
49
50
51GBL_EXT_EVENT_HANDLER
52 a. user-defined macro (compile-time polymorphic)
53 b. gblExtEventHandler
54 1. user-defined implementation (link-time polymorphic)
55 2. dynamic implementation (run-time polymorphic)gimbal_types.h"
56 a. calls context function pointer
57 b. calls event handler
58 c. falls back to default */
59
60#ifndef GBL_EXT_EVENT_HANDLER
61# define GBL_EXT_EVENT_HANDLER gblExtEventHandler
62#endif
63
64/* ==== SERIOUSLY CONSIDER MAKING THIS SHIT TAKE SOURCE CONTEXT INFO
65 actually give context a pointer to latest
66*/
67#ifndef GBL_EXT_MALLOC
68# define GBL_EXT_MALLOC gblExtMemAlloc
69#endif
70
71#ifndef GBL_EXT_REALLOC
72# define GBL_EXT_REALLOC gblExtMemRealloc
73#endif
74
75#ifndef GBL_EXT_FREE
76# define GBL_EXT_FREE gblExtMemFree
77#endif
78
79#ifndef GBL_EXT_LOG_WRITE
80# define GBL_EXT_LOG_WRITE gblExtLogWrite
81#endif
82
83#ifndef GBL_EXT_LOG_PUSH
84# define GBL_EXT_LOG_PUSH gblExtLogPush
85#endif
86
87#ifndef GBL_EXT_LOG_POP
88# define GBL_EXT_LOG_POP gblExtLogPop
89#endif
90
91#ifndef GBL_EXT_RESULT_STRING
92# define GBL_EXT_RESULT_STRING gblExtResultString
93#endif
94
95
96GBL_EXPORT GBL_RESULT gblExtLogWrite (const GblStackFrame* pFrame, GBL_LOG_LEVEL level, const char* pFmt, va_list varArgs);
97GBL_EXPORT GBL_RESULT gblExtLogPush (const GblStackFrame* pFrame);
98GBL_EXPORT GBL_RESULT gblExtLogPop (const GblStackFrame* pFrame, uint32_t count);
99
100GBL_EXPORT GBL_RESULT gblExtMemAlloc (const GblStackFrame* pFrame, GblSize size, GblSize alignment, const char* pDebugInfoString, void** ppData);
101GBL_EXPORT GBL_RESULT gblExtMemRealloc (const GblStackFrame* pFrame, void* pData, GblSize newSize, GblSize newAlign, void** ppNewData);
102GBL_EXPORT GBL_RESULT gblExtMemFree (const GblStackFrame* pFrame, void* pData);
103
104GBL_EXPORT GBL_RESULT gblExtCallRecordSet (const GblStackFrame* pFrame, const GblCallRecord* pRecord) GBL_NOEXCEPT;
105
106
107#ifdef __cplusplus
108}
109#endif
110
111#endif // GIMBAL_EXT_H