From 63a210a5076270530989c8fbadfc0239813fd320 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 12 Feb 2010 09:48:24 +0000 Subject: Bindings python: remove default argument if there is parameters without default argument following --- bindings/python/lang.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'bindings/python/lang.py') 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: -- cgit