summaryrefslogtreecommitdiffstats
path: root/bindings/lang_python.py
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/lang_python.py')
-rw-r--r--bindings/lang_python.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bindings/lang_python.py b/bindings/lang_python.py
index 8dba3eb2..5e4dc4ae 100644
--- a/bindings/lang_python.py
+++ b/bindings/lang_python.py
@@ -163,6 +163,9 @@ class %sError(%sError):
def generate_footer(self, fd):
print >> fd, '''
+
+WSF_SUPPORT = WSF_ENABLED # compatibility
+
import lasso
'''
@@ -170,6 +173,15 @@ import lasso
print >> fd, '### Constants (both enums and defines)'
for c in self.binding_data.constants:
print >> fd, '%s = _lasso.%s' % (c[1][6:], c[1][6:])
+ for c in self.binding_data.overrides.findall('constant'):
+ name = c.attrib.get('name')
+ if c.attrib.get('value'):
+ name = name[6:] # dropping LASSO_
+ value = c.attrib.get('value')
+ if value == 'True':
+ print >> fd, '%s = True' % name
+ else:
+ print >> sys.stderr, 'E: unknown value for constant: %r' % value
print >> fd, ''
def generate_class(self, clss, fd):
@@ -445,6 +457,15 @@ register_constants(PyObject *d)
print >> fd, ' obj = PyInt_FromLong(%s);' % c[1]
elif c[0] == 's':
print >> fd, ' obj = PyString_FromString(%s);' % c[1]
+ elif c[0] == 'b':
+ print >> fd, '''\
+#ifdef %s
+ obj = Py_True;
+#else
+ obj = Py_False;
+#endif''' % c[1]
+ else:
+ print >> sys.stderr, 'E: unknown constant type: %r' % c[0]
print >> fd, ' PyDict_SetItemString(d, "%s", obj);' % c[1][6:]
print >> fd, ' Py_DECREF(obj);'
print >> fd, '}'