(i am seething, i am malding)
(force push: #234234)
This commit is contained in:
Reece Wilson 2023-03-21 01:06:10 +00:00
parent 6894c75262
commit c20c7072e3
2 changed files with 77 additions and 1 deletions

View File

@ -8,4 +8,5 @@
#pragma once
#include "ClassHelpers.hpp"
#include "ModuleApi.hpp"
#include "ModuleApi.hpp"
#include "SOO.hpp"

View File

@ -0,0 +1,75 @@
/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: SOO.hpp
Date: 2023-1-18
Author: Reece
Note: ~~removed~~
Recovered and fixed up: 2023-3-21
***/
#pragma once
#if defined(_AUROXTL_INTERFACE_SOO_FORCE_NO_STRING)
#define _AUROXTL_INTERFACE_SOO_TYPE2NAME(Type) ""
#else
#define _AUROXTL_INTERFACE_SOO_TYPE2NAME(Type) #Type
#endif
#define _AUROXTL_INTERRFACE_SOO_THIS(FullType) (reinterpret_cast<FullType *>(this))
#define AUROXTL_INTERFACE_SOO_HDR_(type, maxSize) \
protected: \
char padding[maxSize] {}; \
inline type(std::nullptr_t) \
{} \
public: \
static const AuUInt kSSOPaddedSize = maxSize; \
static const AuUInt kSSORealSize; \
type(); \
~type();
#define AUROXTL_INTERFACE_SOO_HDR(Type, extends, targetSize) \
struct Type ## SOO \
{ \
AUROXTL_INTERFACE_SOO_HDR_(Type ## SOO, targetSize) \
inline extends *operator ->() \
{ \
return (extends *)this->padding; \
} \
inline operator extends&() \
{ \
return *(extends *)this->padding; \
} \
inline operator extends*() \
{ \
return (extends *)this->padding; \
} \
}; \
using Type ## SOO_t = Type ## SOO;
#define AUROXTL_INTERFACE_SOO_SRC(Type, FullType) \
Type ## SOO::Type ## SOO() \
{ \
if (kSSORealSize > kSSOPaddedSize) \
{ \
AuMemoryPanic("SOO out of overhead: " \
_AUROXTL_INTERFACE_SOO_TYPE2NAME(Type)); \
} \
\
{ \
new (_AUROXTL_INTERRFACE_SOO_THIS(FullType)) FullType(); \
} \
} \
\
Type ## SOO::~ Type ## SOO() \
{ \
_AUROXTL_INTERRFACE_SOO_THIS(FullType)->~FullType(); \
} \
const AuUInt Type ## SOO::kSSORealSize = sizeof(FullType);
#if !defined(AU_SHARED_API_SOO)
#define AU_SHARED_API_SOO(name, size, type, ...) \
AU_SHARED_API_EX(, name, type, #__VA_ARGS__) \
AUROXTL_INTERFACE_SOO_HDR(name, type, size)
#endif