summaryrefslogtreecommitdiff
path: root/util/generate-binding.lua
blob: 1c5359f9597891633ad13e97c673364b84a7649b (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
local b = {}
setmetatable(b, {__index=G})
setfenv(1, b)


--===== enums =====--
local Enum = {}
-- create a single enum element
function Enum.new(name, id)
	local self = {
		name = string.upper(name),
		id = id,
	}
	setmetatable(self, Enum)
	return self
end
-- create multiple enums
function Enum.new_multi(tbl)
	local enums = {}
	for id, name in ipairs(tbl) do
		table.insert(enums, Enum.new(name, id))
	end
	return enums
end
-- make enums read-only
function Enum.__newindex(self)
	error("Attempted to set index on Enum")
end
-- make enums print nicely
function Enum.__tostring(self)
	return self.name
end
-- allow comparinge enums
function Enum.__eq(self, other)
	return self.id == other.id
end


local function check_match(string, pattern, rule)
	local match = string.match(string, '^' .. pattern)
	if match then
		return match, rule(match)
	end
end

local function append_match(string, pattern, rule, 


local function lex(string)
	for _, typename in ipairs(c_int_types) do
		if (string.sub(string, 1, #typename) == typename) then
			return 
	end
end


function bind(signature)
	
end


return b