3 # Reads in the output from gengtk.dlt and fills in the filling values for the enums
5 import pygtk
; pygtk
.require('2.0')
21 out
= file(sys
.argv
[2], 'w')
23 print >>out
, "# Auto-generated by doenums.py"
25 for line
in file(sys
.argv
[1]):
26 if line
.startswith('\tenum '):
27 values
= line
.strip().split(' ')
34 dname
, icname
= i
.split(':')
35 mod
, pyname
= icname
.split('_', 1)
37 if pyname
[0].isdigit():
41 en
= getattr(gtk
, pyname
, None)
43 en
= getattr(pango
, pyname
, None)
45 en
= getattr(gtk
.atk
, pyname
, None)
47 en
= getattr(gtk
.gdk
, pyname
, None)
48 elif mod
== 'PRIVATE':
52 print "Skipping unknown enum value %s" % icname
55 dname
= string
.capwords(dname
.replace('_', ' ')).replace(' ', '')
56 if dname
[0].isdigit():
59 values
.append((dname
, format_hex(en
)))
60 print >>out
, "\tenum %s:" % cname
63 print >>out
, "\t\t%s = %s" % v
65 print >>out
, "\t\tUNKNOWN"
69 print >>out
, "\ninterface Gtk:"
71 ext
= iter(file('../_externals/dlt/gtk.dlt'))
73 if line
.startswith('class HostGtk '):
79 if not line
.strip(): continue
80 if not line
.startswith('\t'): break
81 if line
.startswith('\tpublic '):
82 print >>out
, '\t' + line
.split(' ', 1)[1].strip(':\n')