1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-07 12:21:17 +03:00

applied patch from Stephane Bidoul to add enums to the Python bindings.

* python/generator.py python/tests/tstLastError.py: applied
  patch from Stephane Bidoul to add enums to the Python bindings.
Daniel
This commit is contained in:
Daniel Veillard
2004-01-14 23:50:34 +00:00
parent c2c0d14217
commit 4f4a27f970
3 changed files with 30 additions and 10 deletions

View File

@ -4,6 +4,7 @@
#
functions = {}
enums = {} # { enumType: { enumConstant: enumValue } }
import sys
import string
@ -137,7 +138,8 @@ class docParser:
self.function_return_info = attrs['info']
if attrs.has_key('field'):
self.function_return_field = attrs['field']
elif tag == 'enum':
enum(attrs['type'],attrs['name'],attrs['value'])
def end(self, tag):
if debug:
@ -167,10 +169,13 @@ class docParser:
def function(name, desc, ret, args, file):
global functions
functions[name] = (desc, ret, args, file)
def enum(type, name, value):
if not enums.has_key(type):
enums[type] = {}
enums[type][name] = value
#######################################################################
#
# Some filtering rukes to drop functions/types which should not
@ -1161,9 +1166,19 @@ def buildWrappers():
classes.write(" return ret\n");
classes.write("\n");
#
# Generate enum constants
#
for type,enum in enums.items():
classes.write("# %s\n" % type)
items = enum.items()
items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
for name,value in items:
classes.write("%s = %s\n" % (name,value))
classes.write("\n");
txt.close()
classes.close()
buildStubs()
buildWrappers()