Commit 4f4a27f9 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

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
parent c2c0d142
Thu Jan 15 00:48:46 CET 2004 Daniel Veillard <daniel@veillard.com>
* python/generator.py python/tests/tstLastError.py: applied
patch from Stephane Bidoul to add enums to the Python bindings.
Tue Jan 13 21:50:05 CET 2004 Daniel Veillard <daniel@veillard.com> Tue Jan 13 21:50:05 CET 2004 Daniel Veillard <daniel@veillard.com>
   
* testHTML.c: another small patch from Mark Vadoc * testHTML.c: another small patch from Mark Vadoc
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# #
functions = {} functions = {}
enums = {} # { enumType: { enumConstant: enumValue } }
import sys import sys
import string import string
...@@ -137,7 +138,8 @@ class docParser: ...@@ -137,7 +138,8 @@ class docParser:
self.function_return_info = attrs['info'] self.function_return_info = attrs['info']
if attrs.has_key('field'): if attrs.has_key('field'):
self.function_return_field = attrs['field'] self.function_return_field = attrs['field']
elif tag == 'enum':
enum(attrs['type'],attrs['name'],attrs['value'])
def end(self, tag): def end(self, tag):
if debug: if debug:
...@@ -167,10 +169,13 @@ class docParser: ...@@ -167,10 +169,13 @@ class docParser:
def function(name, desc, ret, args, file): def function(name, desc, ret, args, file):
global functions
functions[name] = (desc, ret, args, file) 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 # Some filtering rukes to drop functions/types which should not
...@@ -1161,9 +1166,19 @@ def buildWrappers(): ...@@ -1161,9 +1166,19 @@ def buildWrappers():
classes.write(" return ret\n"); classes.write(" return ret\n");
classes.write("\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() txt.close()
classes.close() classes.close()
buildStubs() buildStubs()
buildWrappers() buildWrappers()
...@@ -48,10 +48,10 @@ class TestCase(unittest.TestCase): ...@@ -48,10 +48,10 @@ class TestCase(unittest.TestCase):
self.failUnlessXmlError(libxml2.readFile, self.failUnlessXmlError(libxml2.readFile,
("dummy.xml",None,0), ("dummy.xml",None,0),
libxml2.treeError, libxml2.treeError,
domain=8, # XML_FROM_IO domain=libxml2.XML_FROM_IO,
code=1549, # XML_IO_LOAD_ERROR code=libxml2.XML_IO_LOAD_ERROR,
message='failed to load external entity "dummy.xml"\n', message='failed to load external entity "dummy.xml"\n',
level=1, # XML_ERR_WARNING level=libxml2.XML_ERR_WARNING,
file=None, file=None,
line=0) line=0)
...@@ -61,10 +61,10 @@ class TestCase(unittest.TestCase): ...@@ -61,10 +61,10 @@ class TestCase(unittest.TestCase):
self.failUnlessXmlError(libxml2.readMemory, self.failUnlessXmlError(libxml2.readMemory,
(s,len(s),"dummy.xml",None,0), (s,len(s),"dummy.xml",None,0),
libxml2.treeError, libxml2.treeError,
domain=1, # XML_FROM_PARSER domain=libxml2.XML_FROM_PARSER,
code=77, # XML_ERR_TAG_NOT_FINISHED code=libxml2.XML_ERR_TAG_NOT_FINISHED,
message='Premature end of data in tag x line 1\n', message='Premature end of data in tag x line 1\n',
level=3, # XML_ERR_FATAL level=libxml2.XML_ERR_FATAL,
file='dummy.xml', file='dummy.xml',
line=3) line=3)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment