-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreflect.h
More file actions
93 lines (83 loc) · 2.21 KB
/
Copy pathreflect.h
File metadata and controls
93 lines (83 loc) · 2.21 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include <stddef.h>
#include <stdint.h>
typedef struct _ReflectType _ReflectType;
typedef struct _ReflectTypeMember _ReflectTypeMember;
typedef struct _ReflectTypeEnumerant _ReflectTypeEnumerant;
#define _REFLECT_KIND_VOID 0
#define _REFLECT_KIND_BOOL 1
#define _REFLECT_KIND_CHAR 2
#define _REFLECT_KIND_SHORT 3
#define _REFLECT_KIND_INT 4
#define _REFLECT_KIND_LONG 5
#define _REFLECT_KIND_FLOAT 6
#define _REFLECT_KIND_DOUBLE 7
// TODO: LDOUBLE
#define _REFLECT_KIND_ENUM 9
#define _REFLECT_KIND_PTR 10
#define _REFLECT_KIND_FUNC 11
#define _REFLECT_KIND_ARRAY 12
#define _REFLECT_KIND_VLA 13
#define _REFLECT_KIND_STRUCT 14
#define _REFLECT_KIND_UNION 15
#define _REFLECT_TYPEFLAG_UNSIGNED 0x0001 // Integer types only
#define _REFLECT_TYPEFLAG_ATOMIC 0x0002 // Integer types only
#define _REFLECT_TYPEFLAG_FLEXIBLE 0x0004 // Arrays at end of structs only
#define _REFLECT_TYPEFLAG_PACKED 0x0008 // Structs and unions only
#define _REFLECT_TYPEFLAG_VARIADIC 0x0010 // Functions only
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4200) // Zero-sized array.
#pragma warning(disable : 4201) // Unnamed union.
#endif
struct _ReflectTypeMember {
_ReflectType* type;
char* name;
int32_t align;
int32_t offset;
int32_t bit_width; // -1 if not bitfield
int32_t bit_offset; // -1 if not bitfield
};
struct _ReflectTypeEnumerant {
_ReflectTypeEnumerant* next;
char* name;
int32_t value;
};
struct _ReflectType {
char* name; // Either the built-in typename, or the user declared one.
int32_t size;
int32_t align;
int32_t kind; // One of _REFLECT_KIND_*.
int32_t flags; // Combination of _REFLECT_TYPEFLAG_*.
union {
struct {
_ReflectType* base;
int32_t len;
} arr;
struct {
_ReflectType* base;
} ptr;
struct {
size_t num_members;
_ReflectTypeMember members[];
} su;
struct {
_ReflectType* return_ty;
size_t num_params;
_ReflectType* params[];
} func;
struct {
_ReflectTypeEnumerant* enums;
} enumer;
struct {
_ReflectType* vla_size;
// len?
} vla;
};
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#if __dyibicc__
extern _ReflectType* _ReflectTypeOf(...);
#endif