From 308a36b4ba7f4b1b9917967f66df07860e7d0c56 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 8 Nov 2024 02:28:05 -0500 Subject: [PATCH] Remove/Rename Some Stuff --- data/out.h | 42 ------------------------------------------ src/method.ts | 2 +- src/vtable.ts | 12 +++++------- 3 files changed, 6 insertions(+), 50 deletions(-) diff --git a/data/out.h b/data/out.h index 609e5ca..d622b2c 100644 --- a/data/out.h +++ b/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 -T *dup_vtable(T *vtable) { - // Check - static_assert(std::is_constructible_v, "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 -struct __HasAllocate : std::false_type {}; -template -struct __HasAllocate>> : std::true_type {}; -template -class __ExtendedStruct final { - static_assert(__HasAllocate::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 name - // Forward Declarations {{ forwardDeclarations }} diff --git a/src/method.ts b/src/method.ts index b543ae6..d251def 100644 --- a/src/method.ts +++ b/src/method.ts @@ -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 = ''; diff --git a/src/vtable.ts b/src/vtable.ts index 0742a3e..026fcd5 100644 --- a/src/vtable.ts +++ b/src/vtable.ts @@ -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