Copy RTTI Info
This commit is contained in:
parent
225eb259fe
commit
842f05a288
@ -2,6 +2,7 @@ import * as fs from 'node:fs';
|
||||
|
||||
export const INDENT = ' ';
|
||||
export const POINTER_SIZE = 4;
|
||||
export const RTTI_SIZE = POINTER_SIZE;
|
||||
export const EXTENSION = '.def';
|
||||
export const STRUCTURE_FILES: {[id: string]: string} = {};
|
||||
export function readDefinition(name: string) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { INDENT, POINTER_SIZE, Size, assertSize, getSelfArg, toHex } from './common';
|
||||
import { INDENT, POINTER_SIZE, RTTI_SIZE, Size, assertSize, getSelfArg, toHex } from './common';
|
||||
import { Method } from './method';
|
||||
import { Property } from './property';
|
||||
|
||||
@ -170,12 +170,16 @@ export class VTable implements Property {
|
||||
// Duplication Method
|
||||
if (this.#size.isExact()) {
|
||||
declarations += `${this.#getName()} *dup_${this.#getName()}(${this.#getName()} *vtable) {\n`;
|
||||
declarations += `${INDENT}${this.#getName()} *obj = new ${this.#getName()};\n`;
|
||||
declarations += `${INDENT}if (obj == NULL) {\n`;
|
||||
declarations += `${INDENT}uchar *real_vtable = (uchar *) vtable;\n`;
|
||||
declarations += `${INDENT}real_vtable -= ${RTTI_SIZE};\n`;
|
||||
declarations += `${INDENT}size_t real_vtable_size = sizeof(${this.#getName()}) + ${RTTI_SIZE};\n`;
|
||||
declarations += `${INDENT}uchar *new_vtable = (uchar *) ::operator new(real_vtable_size);\n`;
|
||||
declarations += `${INDENT}if (new_vtable == NULL) {\n`;
|
||||
declarations += `${INDENT}${INDENT}return NULL;\n`;
|
||||
declarations += `${INDENT}}\n`;
|
||||
declarations += `${INDENT}memcpy((void *) obj, (void *) vtable, sizeof(${this.#getName()}));\n`;
|
||||
declarations += `${INDENT}return obj;\n`;
|
||||
declarations += `${INDENT}memcpy((void *) new_vtable, (void *) real_vtable, real_vtable_size);\n`;
|
||||
declarations += `${INDENT}new_vtable += ${RTTI_SIZE};\n`;
|
||||
declarations += `${INDENT}return (${this.#getName()} *) new_vtable;\n`;
|
||||
declarations += '}\n';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user