56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#pragma once
|
|
|
|
// Check Architecture
|
|
#ifndef __arm__
|
|
#error "Symbols Are ARM-Only"
|
|
#endif
|
|
|
|
// Headers
|
|
#include "{{ data }}/function.h"
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <type_traits>
|
|
#include <cstring>
|
|
|
|
// Shortcuts
|
|
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
|
|
|
|
// Forward Declarations
|
|
{{ forwardDeclarations }}
|
|
|
|
// Extra Headers
|
|
{{ extraHeaders }}
|
|
|
|
// Warnings
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
|
|
#pragma GCC diagnostic ignored "-Wshadow"
|
|
|
|
{{ main }}
|
|
|
|
// Cleanup Warnings
|
|
#pragma GCC diagnostic pop |