[dali_2.1.22] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / adaptors / scripts / parse.rb
1 #!/usr/bin/env ruby
2 # To use type parse.rb in the same folder as gl-abstraction.h
3 # and pipe the output to a file
4 #
5 # Assemble the gl function call
6 #
7 # turns this: GLBoolean BlendEquation(GLEnum mode);
8 #
9 # into an inline function like this:
10 #
11 # GLBoolean BlendEquation(GLEnum mode)
12 # {
13 #    return glBlendEquation(mode);
14 # }
15
16 f = File.new("x11-gles.h")
17 #scan each line in the file
18 f.each do |x|
19
20   # x is original line, y is the new gl function call
21   y = String.new(x)
22
23   y.lstrip!                  # strip leading white spaces
24   returns = y.index("void"); # see if the function returns void
25   y.gsub!'void',' '          # delete the return types ...
26   y.gsub!(/GL[a-z]*/, '')    # remove GL types such as GLenum
27   y.gsub!('const','')        # remove const, *
28   y.gsub!('char','')         # remove char
29   y.gsub!('*','')            # remove pointer *
30   y.gsub!(/\s+/,"")          # remove all spaces
31   y.insert(0,'  gl')         # add gl to function name
32
33   if (returns != 0)          # insert a return if the function returns
34    y.lstrip!
35    y.insert(0,'  return ')
36   end
37
38   # print the function out
39   y << "\n"
40   x.lstrip!
41   x.gsub!(';','')
42   print x
43   print "{\n"
44   print y
45   print "}\n\n"
46 end
47
48
49