X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fswingjs%2Fj2s%2FJU%2FBC.js;fp=site%2Fswingjs%2Fj2s%2FJU%2FBC.js;h=30eb0485c85cc5142501d1d4da8c2755f1968436;hp=6a368d884870d3f5f89dd186e49c5910ec6006d7;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/swingjs/j2s/JU/BC.js b/site/swingjs/j2s/JU/BC.js index 6a368d8..30eb048 100644 --- a/site/swingjs/j2s/JU/BC.js +++ b/site/swingjs/j2s/JU/BC.js @@ -1,65 +1,65 @@ -Clazz.declarePackage ("JU"); -c$ = Clazz.declareType (JU, "BC"); -Clazz.makeConstructor (c$, -function () { -}); -c$.bytesToFloat = Clazz.defineMethod (c$, "bytesToFloat", -function (bytes, j, isBigEndian) { -return JU.BC.intToFloat (JU.BC.bytesToInt (bytes, j, isBigEndian)); -}, "~A,~N,~B"); -c$.bytesToInt = Clazz.defineMethod (c$, "bytesToInt", -function (bytes, j, isBigEndian) { -var n = (isBigEndian ? (bytes[j + 3] & 0xff) | (bytes[j + 2] & 0xff) << 8 | (bytes[j + 1] & 0xff) << 16 | (bytes[j] & 0xff) << 24 : (bytes[j++] & 0xff) | (bytes[j++] & 0xff) << 8 | (bytes[j++] & 0xff) << 16 | (bytes[j++] & 0xff) << 24); -{ -return (n > 0x7FFFFFFF ? n - 0x100000000 : n); -}}, "~A,~N,~B"); -c$.intToFloat = Clazz.defineMethod (c$, "intToFloat", -function (x) { -{ -if (x == 0) return 0; -var o = JU.BC; -if (o.fracIEEE == null) -o.setFracIEEE(); -var m = ((x & 0x7F800000) >> 23); -return ((x & 0x80000000) == 0 ? 1 : -1) * o.shiftIEEE((x & 0x7FFFFF) | 0x800000, m - 149); -}}, "~N"); -c$.bytesToDoubleToFloat = Clazz.defineMethod (c$, "bytesToDoubleToFloat", -function (bytes, j, isBigEndian) { -{ -if (JU.BC.fracIEEE == null) JU.BC.setFracIEEE (); -{ -var o = JU.BC; -var b1, b2, b3, b4, b5; -if (isBigEndian) { -b1 = bytes[j] & 0xFF; -b2 = bytes[j + 1] & 0xFF; -b3 = bytes[j + 2] & 0xFF; -b4 = bytes[j + 3] & 0xFF; -b5 = bytes[j + 4] & 0xFF; -} else { -b1 = bytes[j + 7] & 0xFF; -b2 = bytes[j + 6] & 0xFF; -b3 = bytes[j + 5] & 0xFF; -b4 = bytes[j + 4] & 0xFF; -b5 = bytes[j + 3] & 0xFF; -} -var s = ((b1 & 0x80) == 0 ? 1 : -1); -var e = (((b1 & 0x7F) << 4) | (b2 >> 4)) - 1026; -b2 = (b2 & 0xF) | 0x10; -return s * (o.shiftIEEE(b2, e) + o.shiftIEEE(b3, e - 8) + o.shiftIEEE(b4, e - 16) -+ o.shiftIEEE(b5, e - 24)); -}}}, "~A,~N,~B"); -c$.setFracIEEE = Clazz.defineMethod (c$, "setFracIEEE", - function () { -JU.BC.fracIEEE = Clazz.newFloatArray (270, 0); -for (var i = 0; i < 270; i++) JU.BC.fracIEEE[i] = Math.pow (2, i - 141); - -}); -c$.shiftIEEE = Clazz.defineMethod (c$, "shiftIEEE", -function (f, i) { -if (f == 0 || i < -140) return 0; -if (i > 128) return 3.4028235E38; -return f * JU.BC.fracIEEE[i + 140]; -}, "~N,~N"); -Clazz.defineStatics (c$, -"fracIEEE", null); +Clazz.declarePackage ("JU"); +c$ = Clazz.declareType (JU, "BC"); +Clazz.makeConstructor (c$, +function () { +}); +c$.bytesToFloat = Clazz.defineMethod (c$, "bytesToFloat", +function (bytes, j, isBigEndian) { +return JU.BC.intToFloat (JU.BC.bytesToInt (bytes, j, isBigEndian)); +}, "~A,~N,~B"); +c$.bytesToInt = Clazz.defineMethod (c$, "bytesToInt", +function (bytes, j, isBigEndian) { +var n = (isBigEndian ? (bytes[j + 3] & 0xff) | (bytes[j + 2] & 0xff) << 8 | (bytes[j + 1] & 0xff) << 16 | (bytes[j] & 0xff) << 24 : (bytes[j++] & 0xff) | (bytes[j++] & 0xff) << 8 | (bytes[j++] & 0xff) << 16 | (bytes[j++] & 0xff) << 24); +{ +return (n > 0x7FFFFFFF ? n - 0x100000000 : n); +}}, "~A,~N,~B"); +c$.intToFloat = Clazz.defineMethod (c$, "intToFloat", +function (x) { +{ +if (x == 0) return 0; +var o = JU.BC; +if (o.fracIEEE == null) +o.setFracIEEE(); +var m = ((x & 0x7F800000) >> 23); +return ((x & 0x80000000) == 0 ? 1 : -1) * o.shiftIEEE((x & 0x7FFFFF) | 0x800000, m - 149); +}}, "~N"); +c$.bytesToDoubleToFloat = Clazz.defineMethod (c$, "bytesToDoubleToFloat", +function (bytes, j, isBigEndian) { +{ +if (JU.BC.fracIEEE == null) JU.BC.setFracIEEE (); +{ +var o = JU.BC; +var b1, b2, b3, b4, b5; +if (isBigEndian) { +b1 = bytes[j] & 0xFF; +b2 = bytes[j + 1] & 0xFF; +b3 = bytes[j + 2] & 0xFF; +b4 = bytes[j + 3] & 0xFF; +b5 = bytes[j + 4] & 0xFF; +} else { +b1 = bytes[j + 7] & 0xFF; +b2 = bytes[j + 6] & 0xFF; +b3 = bytes[j + 5] & 0xFF; +b4 = bytes[j + 4] & 0xFF; +b5 = bytes[j + 3] & 0xFF; +} +var s = ((b1 & 0x80) == 0 ? 1 : -1); +var e = (((b1 & 0x7F) << 4) | (b2 >> 4)) - 1026; +b2 = (b2 & 0xF) | 0x10; +return s * (o.shiftIEEE(b2, e) + o.shiftIEEE(b3, e - 8) + o.shiftIEEE(b4, e - 16) ++ o.shiftIEEE(b5, e - 24)); +}}}, "~A,~N,~B"); +c$.setFracIEEE = Clazz.defineMethod (c$, "setFracIEEE", + function () { +JU.BC.fracIEEE = Clazz.newFloatArray (270, 0); +for (var i = 0; i < 270; i++) JU.BC.fracIEEE[i] = Math.pow (2, i - 141); + +}); +c$.shiftIEEE = Clazz.defineMethod (c$, "shiftIEEE", +function (f, i) { +if (f == 0 || i < -140) return 0; +if (i > 128) return 3.4028235E38; +return f * JU.BC.fracIEEE[i + 140]; +}, "~N,~N"); +Clazz.defineStatics (c$, +"fracIEEE", null);