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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#pragma once
#include <string>
#include <vector>
struct DeclNamespace {
DeclNamespace* container = nullptr;
std::string name;
std::string_view fullname; // View into storage map key
};
// Structs or classes
struct DeclStruct {
DeclNamespace* container = nullptr;
std::string name;
};
enum EnumUnderlyingType {
EUT_Int8,
EUT_Int16,
EUT_Int32,
EUT_Int64,
EUT_Uint8,
EUT_Uint16,
EUT_Uint32,
EUT_Uint64,
EUT_COUNT,
};
enum EnumValuePattern {
// The numbers cover n..m with no gaps
EVP_Continuous,
// The numbers cover for i in n..m, 1 << i
// e.g. [0] = 1 << 0,
// [1] = 1 << 1.
// [2] = 1 << 2. etc.
EVP_Bits,
// The numbesr don't have a particular pattern
EVP_Random,
EVP_COUNT,
};
struct DeclEnumElement {
std::string name;
// TODO support int64_t, etc. enum underlying types
uint64_t value;
};
struct DeclEnum {
DeclNamespace* container = nullptr;
std::string name;
std::vector<DeclEnumElement> elements;
EnumUnderlyingType underlyingType;
// Start with invalid value, calculate on demand
mutable EnumValuePattern pattern = EVP_COUNT;
EnumValuePattern CalcPattern() const;
EnumValuePattern GetPattern() const;
};
struct DeclFunctionArgument {
std::string type;
std::string name;
};
struct DeclFunction {
DeclNamespace* container = nullptr;
// Things like extern, static, etc. that gets written before the function return type
std::string prefix;
std::string name;
std::string returnType;
std::vector<DeclFunctionArgument> arguments;
std::string body;
};
|