Remove/Rename Some Stuff
This commit is contained in:
parent
f72c4f0567
commit
308a36b4ba
42
data/out.h
42
data/out.h
@ -137,26 +137,6 @@ typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
|
||||
// Duplicate VTable
|
||||
#define RTTI_SIZE 4
|
||||
template <typename T>
|
||||
T *dup_vtable(T *vtable) {
|
||||
// Check
|
||||
static_assert(std::is_constructible_v<T>, "Unable To Construct VTable");
|
||||
// Get Size
|
||||
const uchar *real_vtable = (uchar *) vtable;
|
||||
real_vtable -= RTTI_SIZE;
|
||||
const size_t real_vtable_size = sizeof(T) + RTTI_SIZE;
|
||||
// Allocate
|
||||
uchar *new_vtable = (uchar *) ::operator new(real_vtable_size);
|
||||
// Copy
|
||||
memcpy(new_vtable, real_vtable, real_vtable_size);
|
||||
// Return
|
||||
new_vtable += RTTI_SIZE;
|
||||
return (T *) new_vtable;
|
||||
}
|
||||
#undef RTTI_SIZE
|
||||
|
||||
// Internal Macros
|
||||
#define __PREVENT_DESTRUCTION(self) \
|
||||
~self() = delete
|
||||
@ -167,28 +147,6 @@ T *dup_vtable(T *vtable) {
|
||||
self(const self &) = delete; \
|
||||
self &operator=(const self &) = delete
|
||||
|
||||
// Easily Extend Structures
|
||||
template<typename T, typename = void>
|
||||
struct __HasAllocate : std::false_type {};
|
||||
template<typename T>
|
||||
struct __HasAllocate<T, std::enable_if_t<std::is_same_v<T *, decltype(T::allocate())>>> : std::true_type {};
|
||||
template <typename Super, typename Self>
|
||||
class __ExtendedStruct final {
|
||||
static_assert(__HasAllocate<Super>::value, "Super Type Does Not Have A Defined Size");
|
||||
__PREVENT_DESTRUCTION(__ExtendedStruct);
|
||||
__PREVENT_COPY(__ExtendedStruct);
|
||||
alignas(Super) uchar _super[sizeof(Super)];
|
||||
public:
|
||||
__ExtendedStruct() {}
|
||||
Super *super() {
|
||||
return (Super *) &_super[0];
|
||||
}
|
||||
Self data;
|
||||
};
|
||||
#define EXTEND_STRUCT(name, base, ...) \
|
||||
typedef __VA_ARGS__ __##name##_data; \
|
||||
typedef __ExtendedStruct<base, __##name##_data> name
|
||||
|
||||
// Forward Declarations
|
||||
{{ forwardDeclarations }}
|
||||
|
||||
|
@ -47,7 +47,7 @@ export class Method {
|
||||
|
||||
// Overwrite Helper
|
||||
#getVirtualCall(self: string = this.self) {
|
||||
return `${self}_vtable_base->${this.shortName}`;
|
||||
return `${self}_vtable::base->${this.shortName}`;
|
||||
}
|
||||
generate(code: boolean, isVirtual: boolean, parentSelf?: string) {
|
||||
let out = '';
|
||||
|
@ -146,6 +146,10 @@ export class VTable {
|
||||
// Prevent Construction
|
||||
out += preventConstruction(this.#getName());
|
||||
}
|
||||
if (this.#address !== null) {
|
||||
// Base
|
||||
out += `${INDENT}static ${this.#getName()} *base;\n`;
|
||||
}
|
||||
out += `};\n`;
|
||||
|
||||
// Sanity Check Size
|
||||
@ -153,12 +157,6 @@ export class VTable {
|
||||
out += assertSize(this.#getName(), this.#size);
|
||||
}
|
||||
|
||||
// Pointers
|
||||
if (this.#address !== null) {
|
||||
// Base
|
||||
out += `extern ${this.#getName()} *${this.#getName()}_base;\n`;
|
||||
}
|
||||
|
||||
// Return
|
||||
return out;
|
||||
}
|
||||
@ -173,7 +171,7 @@ export class VTable {
|
||||
// Pointers
|
||||
if (this.#address !== null) {
|
||||
// Base
|
||||
out += `${this.#getName()} *${this.#getName()}_base = (${this.#getName()} *) ${toHex(this.#address)};\n`;
|
||||
out += `${this.#getName()} *${this.#getName()}::base = (${this.#getName()} *) ${toHex(this.#address)};\n`;
|
||||
}
|
||||
|
||||
// Method Wrappers
|
||||
|
Loading…
Reference in New Issue
Block a user