Repository navigation
Expand file tree
/
Copy pathtype.lua
More file actions
97 lines (84 loc) · 1.89 KB
/
Copy pathtype.lua
File metadata and controls
97 lines (84 loc) · 1.89 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
94
95
96
97
local POINTER_SIZE = 4
local function createSystemType(name, size, cType)
return {
primitiveType = "system",
name = name,
size = size,
cType = cType or name,
cTypePtr = (cType or name) .. "*",
resolved = true
}
end
local function createTemplateType(t, mod)
mod = mod or {}
local template = {
primitiveType = "template",
name = mod.name or t.name,
templateType = mod.templateType or t.templateType,
value = mod.value or t.value,
default = mod.default or t.default,
type = mod.type or t.type
}
template.resolved = template.value ~= nil
if template.templateType == nil then
if template.type ~= nil then
template.templateType = "value"
else
template.templateType = "type"
end
end
return template
end
local function createClassType(data)
data.templates = data.templates or {}
for i, v in ipairs(data.templates) do
data.templates[i] = createTemplateType(v)
end
return {
primitiveType = "class",
name = data.name,
cType = data.cType,
cTypePtr = data.cType .. "*",
parent = data.super or object,
templates = data.templates,
members = {},
methods = {},
properties = {},
templateDefaults = 0,
size = 0,
resolved = #data.templates == 0
}
end
local function createPointerType(origin, indirection)
local resolved = true
local name = origin
local cType
if type(origin) == "table" then
name = origin.name
cType = origin.cType
resolved = origin.resolved
end
indirection = indirection or 1
for i = 1, indirection do
name = name .. "*"
if cType ~= nil then
cType = cType .. "*"
end
end
return {
primitiveType = "pointer",
name = name,
cType = cType,
cTypePtr = cType and cType .. "*" or nil,
origin = origin,
indirection = indirection,
size = POINTER_SIZE,
resolved = resolved
}
end
return {
SystemType = createSystemType,
ClassType = createClassType,
PointerType = createPointerType,
TemplateType = createTemplateType
}