forked from amonakov/primus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gendef.rb
34 lines (29 loc) · 1021 Bytes
/
gendef.rb
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
data = File.open("/usr/include/EGL/egl.h").to_a.join.gsub(/[\n\t]/, ' ').split(/(;|\*\/)/)
#data = File.open("/usr/include/GLES3/gl3.h").to_a.join.gsub(/[\n\t]/, ' ').split(/(;|\*\/)/)
data.each{ |statement|
# puts statement
next if (!statement.match(/^ *EGLAPI.*/))
# next if (!statement.match(/^ *GL_APICALL.*/))
statement.gsub!(/ +/, ' ')
statement.gsub!(/^ /, '')
#fields = statement.split(' ')
#retval = fields[1]
#puts fields[3..fields.length-1].join(' ').match(/.*(.*)/).inspect
match = statement.match(/[^ ]* +([^ ]*) +[^ ]* +([^ ]*) *\((.*)\)/)
#puts match.inspect
retval = match[1]
func = match[2]
params = match[3]
extra = ''
if (params != "void") then
p = params.split(/, */).map{|k| k.split(/ /)}
if (p[0][0] == "EGLDisplay") then
p = p[1..(p.length-1)]
end
if (p.length > 0) then
extra = "," + p.map{|x| x[x.length-1].gsub(/\*/, '')}.join(',')
end
end
puts "DEF_EGL_PROTO(#{retval}, #{func}, (#{params})#{extra})"
#puts "P(#{func})"
};