summaryrefslogtreecommitdiffstats
path: root/bindings/python/lang.py
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-12 09:48:24 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-12 09:48:24 +0000
commit63a210a5076270530989c8fbadfc0239813fd320 (patch)
treea3b885ce1c45ff410b784e07cd3bc56ed798e2aa /bindings/python/lang.py
parent686951e381674852eeb825fa6b60ece37b850672 (diff)
downloadlasso-63a210a5076270530989c8fbadfc0239813fd320.tar.gz
lasso-63a210a5076270530989c8fbadfc0239813fd320.tar.xz
lasso-63a210a5076270530989c8fbadfc0239813fd320.zip
Bindings python: remove default argument if there is parameters without default argument following
Diffstat (limited to 'bindings/python/lang.py')
-rw-r--r--bindings/python/lang.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/bindings/python/lang.py b/bindings/python/lang.py
index c930ec92..e69248a9 100644
--- a/bindings/python/lang.py
+++ b/bindings/python/lang.py
@@ -25,6 +25,22 @@ import re
import textwrap
from utils import *
+
+def remove_bad_optional(args):
+ args.reverse()
+ non_opt = False
+ new_args = []
+ for x in args:
+ if not '=' in x:
+ non_opt = True
+ elif non_opt:
+ print >>sys.stderr, 'W: changed', x,
+ x = re.sub(' *=.*', '', x)
+ print >>sys.stderr, 'to', x
+ new_args.append(x)
+ new_args.reverse()
+ return new_args
+
def defval_to_python_value(defval):
if defval is None:
return 'None'
@@ -281,6 +297,7 @@ if WSF_SUPPORT:
c_args.append('%s and %s._cptr' % (aname, aname))
else:
c_args.append(aname)
+ py_args = remove_bad_optional(py_args)
c_args = ', '.join(c_args)
py_args = ', ' + ', '.join(py_args)
@@ -306,6 +323,13 @@ if WSF_SUPPORT:
c_args.append('%s and %s._cptr' % (aname, aname))
else:
c_args.append(aname)
+ opt = False
+ py_args = remove_bad_optional(py_args)
+ for x in py_args:
+ if '=' in x:
+ opt = True
+ elif opt:
+ print >>sys.stderr, 'W: non-optional follows optional,', m
c_args = ', '.join(c_args)
py_args = ', ' + ', '.join(py_args)
print >> fd, ' @classmethod'
@@ -415,6 +439,7 @@ if WSF_SUPPORT:
else:
c_args.append('%s and %s._cptr' % (aname, aname))
# check py_args
+ py_args = remove_bad_optional(py_args)
opt = False
for x in py_args:
if '=' in x: