This commit is contained in:
TheBrokenRail 2024-07-16 13:46:20 -04:00
parent 46c486e56a
commit 6f792dfb16
4 changed files with 8 additions and 8 deletions

View File

@ -3,9 +3,9 @@
// Thunks // Thunks
template <typename Ret, typename... Args> template <typename Ret, typename... Args>
struct __Thunk<Ret(Args...)> { struct __Thunk<Ret(Args...)> {
template <__Function<Ret(Args...)> *func> template <__Function<Ret(Args...)> *const *func>
static Ret call(Args... args) { static Ret call(Args... args) {
return func->get_thunk_target()(std::forward<Args>(args)...); return (*func)->get_thunk_target()(std::forward<Args>(args)...);
} }
}; };

View File

@ -27,8 +27,7 @@ class __VirtualFunctionInfo {
} }
T *const addr; T *const addr;
void *const parent; void *const parent;
template <typename U> friend class __Function<std::remove_pointer_t<T>>;
friend class __Function;
}; };
// Thunks // Thunks
@ -171,6 +170,7 @@ T *dup_vtable(T *vtable) {
new_vtable += RTTI_SIZE; new_vtable += RTTI_SIZE;
return (T *) new_vtable; return (T *) new_vtable;
} }
#undef RTTI_SIZE
// Forward Declarations // Forward Declarations
{{ forwardDeclarations }} {{ forwardDeclarations }}

View File

@ -31,7 +31,7 @@ export class Method {
return `${INDENT}${this.getWrapperType()}::ptr_type ${this.shortName};\n`; return `${INDENT}${this.getWrapperType()}::ptr_type ${this.shortName};\n`;
} }
getWrapperType() { getWrapperType() {
return `decltype(${this.getName()})`; return `std::remove_pointer_t<decltype(${this.getName()})>`;
} }
// Overwrite Helper // Overwrite Helper
@ -45,9 +45,9 @@ export class Method {
} }
const signature = this.returnType.trim() + this.args.trim(); const signature = this.returnType.trim() + this.args.trim();
const type = `${INTERNAL}Function<${signature}>`; const type = `${INTERNAL}Function<${signature}>`;
out += `${type} ${this.getName()}`; out += `${type} *const ${this.getName()}`;
if (code) { if (code) {
out += `(${JSON.stringify(this.getName('::'))}, `; out += ` = new ${type}(${JSON.stringify(this.getName('::'))}, `;
if (isVirtual) { if (isVirtual) {
const parentMethod = parentSelf ? `(void *) ${this.#getVirtualCall(parentSelf)}` : 'nullptr'; const parentMethod = parentSelf ? `(void *) ${this.#getVirtualCall(parentSelf)}` : 'nullptr';
out += `&${this.#getVirtualCall()}, ${parentMethod}`; out += `&${this.#getVirtualCall()}, ${parentMethod}`;

View File

@ -144,7 +144,7 @@ export class Struct {
if (isVirtual) { if (isVirtual) {
call += `this->vtable->${method.shortName}`; call += `this->vtable->${method.shortName}`;
} else { } else {
call += `${method.getName()}.get()`; call += `${method.getName()}->get()`;
} }
call += '('; call += '(';
if (!method.isStatic) { if (!method.isStatic) {