407 print >>self.output, " if (typeof %s == 'undefined')" % (default_name) |
407 print >>self.output, " if (typeof %s == 'undefined')" % (default_name) |
408 print >>self.output, " %s=__kwargs.%s;" % (default_name, default_name) |
408 print >>self.output, " %s=__kwargs.%s;" % (default_name, default_name) |
409 default_pos += 1 |
409 default_pos += 1 |
410 |
410 |
411 #self._default_args_handler(node, arg_names, current_klass) |
411 #self._default_args_handler(node, arg_names, current_klass) |
412 if node.kwargs: arg_names += ["pyjslib.Dict(__kwargs)"] |
412 if node.kwargs: |
|
413 arg_names += ["pyjslib.Dict(__kwargs)"] |
413 print >>self.output, " var __r = "+"".join(["[", ", ".join(arg_names), "]"])+";" |
414 print >>self.output, " var __r = "+"".join(["[", ", ".join(arg_names), "]"])+";" |
414 if node.varargs: |
415 if node.varargs: |
415 self._varargs_handler(node, "__args", arg_names, current_klass) |
416 self._varargs_handler(node, "__args", arg_names, current_klass) |
416 print >>self.output, " __r.push.apply(__r, __args.getArray())" |
417 print >>self.output, " __r.push.apply(__r, __args.getArray())" |
417 print >>self.output, " return __r;" |
418 print >>self.output, " return __r;" |
424 else: |
425 else: |
425 function_name = UU + self.modpfx() + node.name |
426 function_name = UU + self.modpfx() + node.name |
426 |
427 |
427 arg_names = list(node.argnames) |
428 arg_names = list(node.argnames) |
428 normal_arg_names = list(arg_names) |
429 normal_arg_names = list(arg_names) |
429 if node.kwargs: kwargname = normal_arg_names.pop() |
430 if node.kwargs: |
430 if node.varargs: varargname = normal_arg_names.pop() |
431 kwargname = normal_arg_names.pop() |
|
432 if node.varargs: |
|
433 varargname = normal_arg_names.pop() |
431 declared_arg_names = list(normal_arg_names) |
434 declared_arg_names = list(normal_arg_names) |
432 if node.kwargs: declared_arg_names.append(kwargname) |
435 if node.kwargs: |
|
436 declared_arg_names.append(kwargname) |
433 |
437 |
434 function_args = "(" + ", ".join(declared_arg_names) + ")" |
438 function_args = "(" + ", ".join(declared_arg_names) + ")" |
435 print >>self.output, "%s = function%s {" % (function_name, function_args) |
439 print >>self.output, "%s = function%s {" % (function_name, function_args) |
436 self._default_args_handler(node, normal_arg_names, None) |
440 self._default_args_handler(node, normal_arg_names, None) |
437 |
441 |
536 fn_args = ", ".join(call_args) |
540 fn_args = ", ".join(call_args) |
537 |
541 |
538 if kwargs or star_arg_name: |
542 if kwargs or star_arg_name: |
539 if not star_arg_name: |
543 if not star_arg_name: |
540 star_arg_name = 'null' |
544 star_arg_name = 'null' |
541 try: call_this, method_name = call_name.rsplit(".", 1) |
545 try: |
|
546 call_this, method_name = call_name.rsplit(".", 1) |
542 except ValueError: |
547 except ValueError: |
543 # Must be a function call ... |
548 # Must be a function call ... |
544 return ("pyjs_kwargs_function_call("+call_name+", " |
549 return ("pyjs_kwargs_function_call("+call_name+", " |
545 + star_arg_name |
550 + star_arg_name |
546 + ", ["+fn_args+"]" |
551 + ", ["+fn_args+"]" |
884 |
889 |
885 #if not classmethod and arg_names[0] != "self": |
890 #if not classmethod and arg_names[0] != "self": |
886 # raise TranslationError("first arg not 'self' (in _method)", node) |
891 # raise TranslationError("first arg not 'self' (in _method)", node) |
887 |
892 |
888 normal_arg_names = arg_names[1:] |
893 normal_arg_names = arg_names[1:] |
889 if node.kwargs: kwargname = normal_arg_names.pop() |
894 if node.kwargs: |
890 if node.varargs: varargname = normal_arg_names.pop() |
895 kwargname = normal_arg_names.pop() |
|
896 if node.varargs: |
|
897 varargname = normal_arg_names.pop() |
891 declared_arg_names = list(normal_arg_names) |
898 declared_arg_names = list(normal_arg_names) |
892 if node.kwargs: declared_arg_names.append(kwargname) |
899 if node.kwargs: |
|
900 declared_arg_names.append(kwargname) |
893 |
901 |
894 function_args = "(" + ", ".join(declared_arg_names) + ")" |
902 function_args = "(" + ", ".join(declared_arg_names) + ")" |
895 |
903 |
896 if classmethod: |
904 if classmethod: |
897 fexpr = UU + class_name_ + ".prototype.__class__." + node.name |
905 fexpr = UU + class_name_ + ".prototype.__class__." + node.name |