Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Loading...
Searching...
No Matches
TypeDescriptorArray.hpp
1
#pragma once
2
3
#include <array>
4
#include "TypeDescriptor.hpp"
5
#include "TypeResolver.hpp"
6
7
namespace
Grindstone::Reflection {
8
struct
TypeDescriptor_FixedArray : TypeDescriptor {
9
std::string name;
10
TypeDescriptor* itemType;
11
size_t
size;
12
void
* (*getItem)(
const
void
*, size_t);
13
void (*emplaceBack)(
void
*);
14
15
template
<
typename
ItemType,
size_t
N>
16
TypeDescriptor_FixedArray(ItemType(*)[N])
17
: TypeDescriptor{
"FixedArray<>"
,
sizeof
(ItemType) * N, ReflectionTypeData::FixedArray },
18
itemType{ TypeResolver<ItemType>::Get() },
19
name{ (std::string(TypeResolver<ItemType>::Get()->GetFullName()) +
"["
+ std::to_string(N) +
"]"
).c_str()},
20
size(N)
21
{
22
getItem = [](
const
void
* arrayPtr,
size_t
index) ->
void
* {
23
ItemType* vec = (ItemType*)(arrayPtr);
24
return
(
void
*)&vec[index];
25
};
26
}
27
28
virtual
const
char
* GetFullName()
const override
{
29
return
name.c_str();
30
}
31
};
32
33
template
<
typename
T,
size_t
N>
34
class
TypeResolver
<T[N]> {
35
public
:
36
static
TypeDescriptor
* Get() {
37
static
TypeDescriptor_FixedArray
typeDesc( (T(*)[N])
nullptr
);
38
return
&typeDesc;
39
}
40
};
41
}
Grindstone::Reflection::TypeDescriptor_FixedArray
Definition
TypeDescriptorArray.hpp:8
Grindstone::Reflection::TypeDescriptor
Definition
TypeDescriptor.hpp:6
Grindstone::Reflection::TypeResolver
Definition
TypeResolver.hpp:9
sources
code
EngineCore
Reflection
TypeDescriptorArray.hpp
Generated by
1.17.0