summaryrefslogtreecommitdiffstats
path: root/Primitives/interface
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-27 20:34:52 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-27 20:34:52 +0000
commit2a0f9a6b4c4e71a21711f794b864ecb0f27f300d (patch)
tree8bb08842a4972f9dcbcf98d82ba85962435033a8 /Primitives/interface
parentGuarded interface definitions by define-undef macro helper include pairs to a... (diff)
downloadDiligentCore-2a0f9a6b4c4e71a21711f794b864ecb0f27f300d.tar.gz
DiligentCore-2a0f9a6b4c4e71a21711f794b864ecb0f27f300d.zip
Fixed class vs struct issues. Implemented HLSL2GLSL Convertor C interfaces
Diffstat (limited to 'Primitives/interface')
-rw-r--r--Primitives/interface/MemoryAllocator.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/Primitives/interface/MemoryAllocator.h b/Primitives/interface/MemoryAllocator.h
index 734f507c..5fdf3b32 100644
--- a/Primitives/interface/MemoryAllocator.h
+++ b/Primitives/interface/MemoryAllocator.h
@@ -38,9 +38,8 @@ DILIGENT_BEGIN_NAMESPACE(Diligent)
#if DILIGENT_CPP_INTERFACE
/// Base interface for a raw memory allocator
-class IMemoryAllocator
+struct IMemoryAllocator
{
-public:
/// Allocates block of memory
virtual void* Allocate(size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber) = 0;
@@ -50,6 +49,33 @@ public:
#else
+struct IMemoryAllocator;
+
+// clang-format off
+
+struct IMemoryAllocatorMethods
+{
+ void* (*Allocate) (struct IMemoryAllocator*, size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber);
+ void (*Free) (struct IMemoryAllocator*, void* Ptr);
+};
+
+struct IMemoryAllocatorVtbl
+{
+ struct IMemoryAllocatorMethods MemoryAllocator;
+};
+
+// clang-format on
+
+typedef struct IMemoryAllocator
+{
+ struct IMemoryAllocatorVtbl* pVtbl;
+} IMemoryAllocator;
+
+// clang-format off
+
+# define IMemoryAllocator_Allocate(This, ...) (This)->pVtbl->MemoryAllocator.Allocate((IMemoryAllocator*)(This), __VA_ARGS__)
+# define IMemoryAllocator_Free(This, ...) (This)->pVtbl->MemoryAllocator.Free ((IMemoryAllocator*)(This), __VA_ARGS__)
+
#endif
DILIGENT_END_NAMESPACE // namespace Diligent