summaryrefslogtreecommitdiff
path: root/meta/3rd/ffi-reflect/library/reflect.lua
blob: 8a9b759c24f236eeef73277a07bae236b122aa6c (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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---@meta

---@alias ffi.typeinfo.what "int"
---|"void"
---|"float"
---|"enum"
---|"constant"
---|"ptr"
---|"ref"
---|"array"
---|"struct"
---|"union"
---|"func"
---|"field"
---|"bitfield"
---|"typedef"

---@class ffi.typeinfo
---@field what ffi.typeinfo.what

---@class ffi.enuminfo : ffi.typeinfo
---@field name string?
---@field size number|string
---@field alignment number
---@field type ffi.typeinfo
local enuminfo = {}

---@return ffi.constantinfo[]
function enuminfo:values()
end

---@return ffi.constantinfo
function enuminfo:value(name_or_index)
end

---@class ffi.funcinfo : ffi.typeinfo
---@field name string?
---@field sym_name string?
---@field return_type ffi.funcinfo
---@field nargs integer
---@field vararg boolean
---@field sse_reg_params boolean
---@field convention "cdecl"|"thiscall"|"fastcall"|"stdcall"
local funcinfo = {}

---@return ffi.fieldinfo[]
function funcinfo:arguments()
end

---@return ffi.fieldinfo
function funcinfo:argument(name_or_index)
end

---@class ffi.unioninfo : ffi.typeinfo
---@field name string?
---@field size integer
---@field alignment number
---@field const boolean
---@field volatile boolean
---@field transparent boolean
local unioninfo = {}

---@return ffi.typeinfo[]
function unioninfo:members()
end

---@return ffi.typeinfo
function unioninfo:member(name_or_index)
end

---@class ffi.structinfo : ffi.unioninfo
---@field vla boolean

---@class ffi.floatinfo : ffi.typeinfo
---@field size integer
---@field alignment number
---@field const boolean
---@field volatile boolean

---@alias ffi.voidinfo ffi.floatinfo

---@class ffi.intinfo : ffi.floatinfo
---@field bool boolean
---@field unsigned boolean
---@field long boolean

---@class ffi.constantinfo : ffi.typeinfo
---@field name string?
---@field type ffi.typeinfo
---@field value integer

---@class ffi.ptrinfo : ffi.typeinfo
---@field size integer
---@field alignment number
---@field const boolean
---@field volatile boolean
---@field element_type ffi.typeinfo

---@alias ffi.refinfo ffi.ptrinfo

---@class ffi.arrayinfo : ffi.ptrinfo
---@field vla boolean
---@field vector boolean
---@field complex boolean

---@class ffi.fieldinfo : ffi.typeinfo
---@field name string?
---@field offset number
---@field type ffi.typeinfo

---@class ffi.bitfield : ffi.fieldinfo
---@field size integer|string

local reflect = {}

---reflection cdata c defined
---@param v ffi.cdata*
---@return ffi.typeinfo
function reflect.typeof(v)
end

---try get cdata metatable
---@param v ffi.cdata*
---@return table
function reflect.getmetatable(v)
end

return reflect