diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-07-23 20:36:35 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-07-23 20:36:35 -0700 |
commit | cbd2894946f87264bfc604e62eb05f7ebe1d1a92 (patch) | |
tree | 27384f6f9b24cb4517c88017b20ec8fe7e5e7480 | |
parent | 18acbda893af41307a2304c18eaa5fa72a0fa5a6 (diff) |
fixes for binding constructors with default arguments
-rwxr-xr-x | tools/bindings_generator.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/bindings_generator.py b/tools/bindings_generator.py index 09d5b3f0..4104f002 100755 --- a/tools/bindings_generator.py +++ b/tools/bindings_generator.py @@ -199,7 +199,7 @@ def generate_class(generating_classname, classname, clazz): if constructor: generating_classname_suffixed += suffix - argfixes = map(lambda arg: ''' %s = (%s && %s.ptr) ? %s.ptr : %s;''' % (arg['name'], arg['name'], arg['name'], arg['name'], arg['name']), args) + argfixes = '\n'.join(map(lambda arg: ''' %s = (%s && %s.ptr) ? %s.ptr : %s;''' % (arg['name'], arg['name'], arg['name'], arg['name'], arg['name']), args)) for i in range(method['first_default_param'], len(args)+1): # C @@ -208,7 +208,7 @@ def generate_class(generating_classname, classname, clazz): %s %s_p%d(%s) { %s%s%s(%s); } -''' % (ret, fullname, i, ', '.join(typedargs[:i+1]), 'return ' if ret.replace(' ', '') != 'void' else '', callprefix, actualmname, ', '.join(justargs[:i]))) +''' % (ret, fullname, i, ', '.join(typedargs[:i + (0 if constructor else 1)]), 'return ' if ret.replace(' ', '') != 'void' else '', callprefix, actualmname, ', '.join(justargs[:i]))) c_funcs.append(fullname + '_p' + str(i)) @@ -241,7 +241,7 @@ function %s(%s) { %s %s } -''' % (mname_suffixed, ', '.join(justargs), ', '.join(argfixes), calls) +''' % (mname_suffixed, ', '.join(justargs), argfixes, calls) else: js_text = ''' function %s(%s) { @@ -249,14 +249,14 @@ function %s(%s) { %s } %s.prototype = %s.prototype; -''' % (mname_suffixed, ', '.join(justargs), ', '.join(argfixes), calls, mname_suffixed, classname) +''' % (mname_suffixed, ', '.join(justargs), argfixes, calls, mname_suffixed, classname) else: js_text = ''' %s.prototype.%s = function(%s) { %s %s } -''' % (generating_classname, mname_suffixed, ', '.join(justargs), ', '.join(argfixes), calls) +''' % (generating_classname, mname_suffixed, ', '.join(justargs), argfixes, calls) js_text = js_text.replace('\n\n', '\n').replace('\n\n', '\n') gen_js.write(js_text) |