From 603010e3cce7a7cce90b87da43e4c918047d14a2 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 17 May 2024 00:36:06 -0400 Subject: [PATCH] Remove alloc_*() Functions --- src/struct.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/struct.ts b/src/struct.ts index 6a7081b..0d0f692 100644 --- a/src/struct.ts +++ b/src/struct.ts @@ -220,6 +220,12 @@ export class Struct { out += `struct ${this.#name} {\n`; out += this.#generateProperties(); out += this.#generateMethods(); + if (this.#size === null) { + // Prevent Manually Copying/Allocating Structure With Undefined + out += `${INDENT}${this.#name}() = delete;\n`; + out += `${INDENT}${this.#name}(const ${this.#name} &) = delete;\n`; + out += `${INDENT}${this.#name} &operator=(const ${this.#name} &) = delete;\n`; + } out += `};\n`; // Sanity Check Offsets @@ -235,11 +241,6 @@ export class Struct { out += assertSize(this.#name, this.#size); } - // Allocation Function - if (this.#size !== null) { - out += `${this.#name} *alloc_${this.#name}();\n`; - } - // Return return out; } @@ -272,13 +273,6 @@ export class Struct { init += vtable.init; } - // Allocation Function - if (this.#size !== null) { - declarations += `${this.#name} *alloc_${this.#name}() {\n`; - declarations += `${INDENT}return new ${this.#name};\n`; - declarations += '}\n'; - } - // Return return {functions: declarations, init}; }