Skip to content

Commit 4e1f159

Browse files
authored
Merge pull request #56 from BobHanson/master
minor fixes
2 parents e88dcf9 + 8201d9b commit 4e1f159

File tree

10 files changed

+51
-14
lines changed

10 files changed

+51
-14
lines changed
30 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2018-07-19_0557 AM
1+
2018_07_22__14_28_50
30 Bytes
Binary file not shown.

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130

131131
import net.sf.j2s.core.CorePlugin;
132132

133+
// BH 7/22/2018 -- fixes improper use of charCodeAt() to replace charCode().$c() when not java.lang.String.charAt
133134
// BH 7/20/2018 -- removes qualifications for single-abstract method overrides
134135
// BH 7/19/2018 -- fixes Enum.Enum
135136
// BH 7/18/2018 -- addw Java 8 try without catch or finally
@@ -1661,14 +1662,12 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
16611662
// methods are not to be qualified
16621663

16631664
for (int i = unqualifiedMethods.size(); --i >= 0;) {
1664-
//buffer.append(">>" + method.getKey() + " " + unqualifiedMethods.get(i).getKey() + "<<\r\n");
16651665
if (method.overrides(unqualifiedMethods.get(i))) {
16661666
dontQualifyMethod = true;
16671667
break;
16681668
}
16691669
}
16701670
}
1671-
//buffer.append("<<" + dontQualifyMethod + "<<");
16721671
element.accept(this);
16731672
dontQualifyMethod = dontQualifyCurrent;
16741673
}
@@ -2346,7 +2345,7 @@ public boolean visit(Assignment node) {
23462345
left.accept(this);
23472346
int ptArray2 = (isArray ? buffer.length() : -1);
23482347
if (!"char".equals(leftName)) {
2349-
if (isIntegerType(leftName) || "booelean".equals(leftName)) {
2348+
if (isIntegerType(leftName) || "boolean".equals(leftName)) {
23502349
// can't just use a |= b because that ends up as 1 or 0, not true or false.
23512350
// byte|short|int|long += ...
23522351
if (!addPrimitiveTypedExpression(left, toBinding, leftName, opType, right, rightName, null, true))
@@ -2997,7 +2996,6 @@ private String getQualifiedSimpleName(SimpleName node) {
29972996
return simpleNameInMethodBinding(node, isQualified, (IMethodBinding) binding);
29982997

29992998
ITypeBinding typeBinding = node.resolveTypeBinding();
3000-
// >>Math<<.max
30012999
return NameMapper.get$QualifiedJ2SFieldName(typeBinding == null ? node.getFullyQualifiedName()
30023000
: assureQualifiedNameAllowP$(typeBinding.getQualifiedName()), true);
30033001
}
@@ -3476,9 +3474,9 @@ private void addCharCodeAt(Expression right, int pt) {
34763474
if (right instanceof MethodInvocation) {
34773475
// if possible, just replace "charAt" with "charCodeAt"
34783476
MethodInvocation m = (MethodInvocation) right;
3479-
if ("charAt".equals(m.getName().toString())) {
3477+
if (m.resolveMethodBinding().getKey().equals("Ljava/lang/String;.charAt(I)C")) {
34803478
if ((pt = buffer.indexOf(".charAt", pt)) >= 0) {
3481-
charCodeAt0 = "Code" + buffer.substring(pt + 5); // At....
3479+
charCodeAt0 = "Code" + buffer.substring(pt + 5);
34823480
buffer.setLength(pt + 5);
34833481
}
34843482
}

sources/net.sf.j2s.core/src/net/sf/j2s/core/compiler/Java2ScriptCompiler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class Java2ScriptCompiler {
4444
// BH: added "true".equals(getProperty(props,
4545
// "j2s.compiler.allow.compression")) to ensure compression only occurs when
4646
// desired
47-
private static final int JSL_LEVEL = AST.JLS8; // not handling lampda functions
48-
47+
private static final int JSL_LEVEL = AST.JLS8; // deprecation just because Java has moved on
4948
private boolean showJ2SSettings = true;
5049

5150
// We copy all non .java files from any directory from which we loaded a
307 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/dist/SwingJS-site0.zip

Whitespace-only changes.

sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,15 @@ public void fillRect(int x, int y, int width, int height) {
248248
ctx.fillRect(x, y, width, height);
249249
}
250250

251+
public void draw3DRect(int x, int y, int width, int height, boolean raised) {
252+
do3DRect(x, y, width, height, raised, false);
253+
}
254+
251255
public void fill3DRect(int x, int y, int width, int height, boolean raised) {
256+
do3DRect(x, y, width, height, raised, true);
257+
}
258+
259+
private void do3DRect(int x, int y, int width2, int height2, boolean raised, boolean isFill) {
252260
if (width <= 0 || height <= 0)
253261
return;
254262
Paint p = getPaint();
@@ -261,7 +269,9 @@ public void fill3DRect(int x, int y, int width, int height, boolean raised) {
261269
} else if (p != c) {
262270
setColor(c);
263271
}
264-
fillRect(x + 1, y + 1, width - 2, height - 2);
272+
if (isFill) {
273+
fillRect(x + 1, y + 1, width - 2, height - 2);
274+
}
265275
setColor(raised ? brighter : darker);
266276
// drawLine(x, y, x, y + height - 1);
267277
fillRect(x, y, 1, height);

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// TODO: CharacterSequence does not implement Java 8 default methods chars() or codePoints()
1111
// It is possible that these might be loaded dynamically.
1212

13+
// BH 7/22/2018 adds System.getProperty("java.vendor") == "SwingJS/OpenJDK"
14+
// BH 7/22/2018 adds Math.IEEEremainder
1315
// BH 7/20/2018 removes def of Closeable, DataInput, DataOutput, Iterable, Comparator
1416
// BH 7/19/2018 removes Constructor, Method, and Field code here -- now in their .js files
1517
// BH 7/18/2018 adds Java 8 default interface method support
@@ -2660,8 +2662,10 @@ java.lang.System = System = {
26602662
case "java.class.version":
26612663
v = "50";
26622664
break;
2665+
case "java.vendor":
2666+
v = "SwingJS/OpenJDK";
26632667
case "java.version":
2664-
v = "1.6";
2668+
v = "1.6-1.8";
26652669
break;
26662670
case "file.separator":
26672671
case "path.separator":
@@ -2808,7 +2812,18 @@ Math.nextAfter||(Math.nextAfter=function(start,direction){return 0});
28082812
Math.nextUp||(Math.nextUp=function(d){return 0});
28092813
Math.ulp||(Math.ulp=function(d){return 0});
28102814
Math.getExponent||(Math.getExponent=function(d){return 0});
2811-
Math.getIEEEremainder||(Math.getIEEEremainder=function(f1,f2){return 0});
2815+
Math.IEEEremainder||(Math.IEEEremainder=function (x, y) {
2816+
if (y == 0 || Double.isNaN(x) || Double.isInfinite(y) && !Double.isInfinite(x) ) return NaN;
2817+
var modxy = x % y;
2818+
if (modxy == 0 ) return modxy;
2819+
var rem = modxy - (Math.abs(y) * Math.signum(x));
2820+
if (Math.abs(rem) == Math.abs(modxy) ) {
2821+
var div = x / y;
2822+
return (Math.abs(Math.round(div)) > Math.abs(div) ? rem : modxy);
2823+
}
2824+
return (Math.abs(rem) < Math.abs(modxy) ? rem : modxy);
2825+
});
2826+
28122827
//end datatype reliant math declarations
28132828

28142829
Clazz._setDeclared("java.lang.Number", java.lang.Number=Number);

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13440,6 +13440,8 @@ if (!J2S._version)
1344013440
// TODO: CharacterSequence does not implement Java 8 default methods chars() or codePoints()
1344113441
// It is possible that these might be loaded dynamically.
1344213442

13443+
// BH 7/22/2018 adds System.getProperty("java.vendor") == "SwingJS/OpenJDK"
13444+
// BH 7/22/2018 adds Math.IEEEremainder
1344313445
// BH 7/20/2018 removes def of Closeable, DataInput, DataOutput, Iterable, Comparator
1344413446
// BH 7/19/2018 removes Constructor, Method, and Field code here -- now in their .js files
1344513447
// BH 7/18/2018 adds Java 8 default interface method support
@@ -16090,8 +16092,10 @@ java.lang.System = System = {
1609016092
case "java.class.version":
1609116093
v = "50";
1609216094
break;
16095+
case "java.vendor":
16096+
v = "SwingJS/OpenJDK";
1609316097
case "java.version":
16094-
v = "1.6";
16098+
v = "1.6-1.8";
1609516099
break;
1609616100
case "file.separator":
1609716101
case "path.separator":
@@ -16238,7 +16242,18 @@ Math.nextAfter||(Math.nextAfter=function(start,direction){return 0});
1623816242
Math.nextUp||(Math.nextUp=function(d){return 0});
1623916243
Math.ulp||(Math.ulp=function(d){return 0});
1624016244
Math.getExponent||(Math.getExponent=function(d){return 0});
16241-
Math.getIEEEremainder||(Math.getIEEEremainder=function(f1,f2){return 0});
16245+
Math.IEEEremainder||(Math.IEEEremainder=function (x, y) {
16246+
if (y == 0 || Double.isNaN(x) || Double.isInfinite(y) && !Double.isInfinite(x) ) return NaN;
16247+
var modxy = x % y;
16248+
if (modxy == 0 ) return modxy;
16249+
var rem = modxy - (Math.abs(y) * Math.signum(x));
16250+
if (Math.abs(rem) == Math.abs(modxy) ) {
16251+
var div = x / y;
16252+
return (Math.abs(Math.round(div)) > Math.abs(div) ? rem : modxy);
16253+
}
16254+
return (Math.abs(rem) < Math.abs(modxy) ? rem : modxy);
16255+
});
16256+
1624216257
//end datatype reliant math declarations
1624316258

1624416259
Clazz._setDeclared("java.lang.Number", java.lang.Number=Number);

0 commit comments

Comments
 (0)