aboutsummaryrefslogtreecommitdiff
path: root/source/CodegenRuntime/MetadataBase.hpp
blob: c1ad89480bd12628ec1cd66f14a2114cfaa0df2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once

#include <cstddef>
#include <optional>
#include <span>
#include <string_view>

namespace Metadata {

struct TypeId {
	size_t id;
};

struct TypeInfo;

struct TypePropertyInfo {
	std::string_view name;
	const TypeInfo* type;
	std::string_view getterName;
	std::string_view setterName;

	bool IsDirectAccess() const;
};

struct TypeMethodInfo {
	std::string_view name;
	// TODO
};

struct TypeInfo {
	TypeId typeId;
	std::string_view name;
	std::span<const TypeInfo*> parents;
	std::span<const TypePropertyInfo> properties;
	std::span<const TypeMethodInfo> methods;

	/// Whether this object is registered at runtime or statically compiled
	bool dynamic = false;
};

// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase
template <typename T>
const TypeInfo* GetTypeInfo();

// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase
template <typename TEnum>
std::string_view EnumToString(TEnum value);

// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase
template <typename TEnum>
std::optional<TEnum> EnumFromString(std::string_view str);

} // namespace Metadata