Skip to content

Commit 54babfd

Browse files
hansonrhansonr
authored andcommitted
Long constructor fix for new Long([r,m,s])
1 parent cadde2a commit 54babfd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ Clazz.newMeth = function (clazzThis, funName, funBody, modifiers) {
11071107
else
11081108
clazzThis.prototype[funName] = funBody;
11091109
return funBody; // allow static calls as though they were not static
1110-
};
1110+
};
11111111

11121112
Clazz.newPackage = function (pkgName) {
11131113
Clazz._Loader && Clazz._Loader.doTODO();
@@ -4071,10 +4071,11 @@ m$(Integer,"decode$S", function(n){
40714071
// Note that Long is problematic in JavaScript
40724072

40734073
Clazz._setDeclared("java.lang.Long", java.lang.Long=Long=function(){
4074-
if (arguments[0] === null || typeof arguments[0] != "object")this.c$(arguments[0]);
4074+
this.c$(arguments[0]);
40754075
});
40764076

40774077
decorateAsNumber(Long, "Long", "long", "J", lHCOffset);
4078+
40784079
Long.toString=Long.toString$J=Long.toString$J$I = Long.prototype.toString=function(i, radix){
40794080
switch(arguments.length) {
40804081
case 2:
@@ -4085,7 +4086,7 @@ Long.toString=Long.toString$J=Long.toString$J$I = Long.prototype.toString=functi
40854086
i = this.valueOf();
40864087
break;
40874088
}
4088-
return (i.length ? Long.$s(i) : i);
4089+
return (i.length ? Long.$s(i) : "" + i);
40894090
};
40904091

40914092

@@ -4884,8 +4885,8 @@ m$(Long,["longValue","longValue$"],function(){return this.valueOf();});
48844885

48854886
m$(Long,"c$",
48864887
function(v) {
4887-
if (typeof v != "number")
4888-
v = Long.parseLong$S$I(v, 10);
4888+
if (typeof v != "number" && typeof v != "object")
4889+
v = Long.parseLong$S$I(v, 10);
48894890
this.valueOf=function(){return v;};
48904891
}, 1);
48914892

@@ -4916,7 +4917,7 @@ function(s, radix){
49164917
m$(Long,"valueOf$J",
49174918
function(i){
49184919
i = Clazz.toLong(i);
4919-
var v = (i.length ? 0 : getCachedNumber(i, longs, Long, "c$$J"));
4920+
var v = (!i.length || (v = Long.$ival(i)) == Long.$lval(i) && (i = v) == i ? getCachedNumber(i, longs, Long, "c$$J") : 0);
49204921
return (v ? v : Clazz.new_(Long.c$$J, [i]));
49214922
}, 1);
49224923

0 commit comments

Comments
 (0)