Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
aaf32f8
comments, simplification of Matcher.RegExp
Dec 8, 2020
2ce69ee
slider
Dec 9, 2020
4f2b3d4
missing @ in j2sNative JSJarURLConnection
Dec 10, 2020
5ff407f
Toolkit.getScreenSize() should use window.innerWidth/innerHeight
Dec 10, 2020
0507f97
SwingJS-site.zip
Dec 10, 2020
585c888
interface extends interface with duplicate default method
Dec 12, 2020
5487bab
JSUtilI importModule(), DomnNode.Promise adds $then,$finally,$catch
Dec 12, 2020
a37f38b
paste operation, importModule, WASM and ES6 directories.
Dec 14, 2020
ad1552b
paste operation, importModule, WASM and ES6 directories.
Dec 14, 2020
68647cf
Boolean boxing fix
Dec 15, 2020
194152c
_applet._j2sFullPath and JSUtil.getJ2SPath()
Dec 15, 2020
471297e
SwingJS-site and transpiler fixes
Dec 15, 2020
5ee0a5f
JSSplitPaneUI correction for setDividerSize(0)
Dec 15, 2020
2f8e706
fix for applet ready overriding applet._appletPanel
Dec 15, 2020
7f622b4
applet._j2sFullPath; readyCallback overwrites _appletPanel
Dec 15, 2020
be7d075
Removing JSInterface.startHoverWatcher
Dec 15, 2020
ba5a61e
Removing JSInterface.startHoverWatcher
Dec 15, 2020
a05b714
java.time.Instant
Dec 16, 2020
639f5f4
FrameViewer restored legacy method
Dec 19, 2020
590f4a9
java.util.Timer with SwingJS Timer and Executor implementation
Dec 19, 2020
10624de
java.util.Timer with SwingJS Timer and Executor implementation
Dec 19, 2020
9cb37cc
Merge pull request #196 from BobHanson/long
BobHanson Dec 19, 2020
a1ad74b
implements java.util.Timer using Swing Timer and Executors
Dec 19, 2020
8085808
PriorToLong tag
Dec 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20201206115202
20201219080050
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20201206115202
20201219080050
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class CorePlugin extends Plugin {
// if you change the x.x.x number, be sure to also indicate that in
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat

// BH 2020.12.14 -- 3.2.9-v1s fix for Boolean |= boolean and related boxing
// BH 2020.12.06 -- 3.2.9-v1r fix for (long) double using |0
// BH 2020.11.20 -- 3.2.9-v1q fix for new ImmutableCollections.ListN<>(E...) should use Object[]
// BH 2020.08.03 -- 3.2.9-v1p fix for boxing boolean should be Boolean.valueOf$, not new Boolean
Expand Down
65 changes: 51 additions & 14 deletions sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@

// TODO: superclass inheritance for JAXB XmlAccessorType

//BH 2020.12.14 -- 3.2.9-v1s fix for Boolean |= boolean and related boxing
//BH 2020.12.06 -- 3.2.9-v1r fix for (long) double using |0
//BH 2020.11.20 -- 3.2.9-v1q fix for new ImmutableCollections.ListN<>(E...) should use Object[]
//BH 2020.08.03 -- 3.2.9-v1p fix for boxing boolean should be Boolean.valueOf$, not new Boolean
Expand Down Expand Up @@ -3189,6 +3190,7 @@ public boolean visit(Assignment node) {
IVariableBinding toBinding = getLeftVariableBinding(left, leftTypeBinding);
String op = node.getOperator().toString();
String opType = (op.length() == 1 ? null : op.substring(0, op.length() - 1));

boolean needNewStaticParenthesis = false;
boolean isParenthesized = (right instanceof ParenthesizedExpression);
// boolean haveDocRight = (getJ2sJavadoc(right, DOC_CHECK_ONLY) != null);
Expand All @@ -3206,12 +3208,14 @@ public boolean visit(Assignment node) {
if ("boolean".equals(leftName) && "boolean".equals(rightName)) {
if (("^=".equals(op))) {
opType = "!=";
} else {
} else if (opType == null) {
// all boolean should be OK -- no automatic here
left.accept(this);
buffer.append((opType == null ? "=" : op));
buffer.append("=");
right.accept(this);
leftName = null;
} else {
// a&=b -> !!(a&(b)) because both must execute
}
} else if (opType == null) {
// = operator is no problem
Expand All @@ -3234,11 +3238,13 @@ public boolean visit(Assignment node) {
else
left.accept(this);
int ptArray2 = (temp_processingArrayIndex ? buffer.length() : -1);
boolean leftIsString = leftName.equals("String");
boolean mustBoxAll = !(leftIsString || leftTypeBinding != null && leftTypeBinding.isPrimitive());
if (!"char".equals(leftName)) {
if (isIntegerType(leftName) || "boolean".equals(leftName)) {
if (isIntegerType(leftName) || "boolean".equals(leftName) || mustBoxAll) {
// can't just use a |= b because that ends up as 1 or 0, not true or false.
// byte|short|int|long += ...
if (!addPrimitiveTypedExpression(left, toBinding, leftName, opType, right, rightName, null, true))
if (!addPrimitiveTypedExpression(left, toBinding, leftName, opType, right, rightName, null, true, mustBoxAll ? leftTypeBinding : null))
ptArray = -1;
} else {
ptArray = -1;
Expand All @@ -3249,7 +3255,6 @@ public boolean visit(Assignment node) {
buffer.append(' ');
buffer.append(op);
buffer.append(' ');
boolean leftIsString = leftName.equals("String");
if ("char".equals(rightName)) {
if (right instanceof CharacterLiteral) {
// ... = 'c'
Expand Down Expand Up @@ -3443,7 +3448,7 @@ public boolean visit(CastExpression node) {
String nameFROM = expBinding.getName();
String nameTO = ((PrimitiveType) typeTO).getPrimitiveTypeCode().toString();
if (!nameTO.equals(nameFROM)) {
addPrimitiveTypedExpression(null, null, nameTO, null, expression, nameFROM, null, false);
addPrimitiveTypedExpression(null, null, nameTO, null, expression, nameFROM, null, false, null);
return false;
}
}
Expand Down Expand Up @@ -3600,7 +3605,7 @@ public boolean visit(InfixExpression node) {
if ("/".equals(operator) && leftIsInt && rightIsInt) {
// left and right are one of byte, short, int, or long
// division must take care of this.
addPrimitiveTypedExpression(left, null, leftName, operator, right, rightName, extendedOperands, false);
addPrimitiveTypedExpression(left, null, leftName, operator, right, rightName, extendedOperands, false, null);
return false;
}

Expand Down Expand Up @@ -4329,7 +4334,7 @@ private void addExpressionAsTargetType(Expression exp, Object targetType, String
if ((isNumeric || paramName.equals("char")) && !isBoxTyped(exp)) {
// using operator "m" to limit int application of $i$

addPrimitiveTypedExpression(null, null, paramName, op, exp, rightName, extendedOperands, false);
addPrimitiveTypedExpression(null, null, paramName, op, exp, rightName, extendedOperands, false, null);
} else {
// char f() { return Character }
// Character f() { return char }
Expand Down Expand Up @@ -4575,11 +4580,11 @@ private void addOperand(Expression exp, boolean isToString) {
* @param rightName
* @param extendedOperands
* @param isAssignment (+=, &=, etc)
* @param return true if is an assignment and a = (a op b) was
* used
* @param mustBoxAll Integer != b
* @return true if is an assignment and a = (a op b) was used
*/
private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding assignmentBinding, String leftName,
String op, Expression right, String rightName, List<?> extendedOperands, boolean isAssignment) {
String op, Expression right, String rightName, List<?> extendedOperands, boolean isAssignment, ITypeBinding allBinding) {
// byte|short|int|long /= ...
// convert to proper number of bits

Expand All @@ -4589,6 +4594,9 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as

// a = ($b$[0] = a | right, $b$[0])



// also boolean |= boolean op will be !!|
String classIntArray = null;
String more = null, less = null;

Expand All @@ -4598,7 +4606,16 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
boolean addParens = (op != "r" || fromChar || right instanceof ParenthesizedExpression);
boolean isDiv = "/".equals(op);
boolean toChar = false;
boolean isBoolean = false;
switch (leftName) {
case "Boolean":
isBoolean = true;
break;
case "boolean":
less = "!!(";
more = ")";
addParens = true;
break;
case "char":
if (!fromChar) {
prefix += "String.fromCharCode(";
Expand All @@ -4608,7 +4625,7 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
toChar = true;
break;
default:
// double, float
// double, float, boxed
break;
case "long":
if (isDiv || !fromIntType) {
Expand Down Expand Up @@ -4655,6 +4672,8 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
}
boolean wasArray = temp_processingArrayIndex;



if (isAssignment && left == null) {
buffer.append(op);
}
Expand All @@ -4670,11 +4689,23 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
buffer.append("(");
}
if (left != null) {

// a += b


if (allBinding != null) {
// Boolean.from(!!(a | (b))
buffer.append(leftName + ".valueOf$" + getJSTypeCode(leftName.toLowerCase()))
.append(isBoolean ? "(!!(" : "(");
}

addFieldName(left, assignmentBinding);
buffer.append(op);
if (isAssignment)

if (isAssignment) {
buffer.append("(");
}

}
if (!appendBoxingNode(right, fromChar) && fromChar && !toChar) {
buffer.append(CHARCODEAT0);
Expand All @@ -4685,6 +4716,10 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
if (left != null && isAssignment) {
buffer.append(")");
}

if (allBinding != null)
buffer.append(isBoolean ? "))" : ")");

if (classIntArray != null) {
// this is necessary because in JavaScript,
// a = new Int8Array(1)
Expand Down Expand Up @@ -5719,13 +5754,15 @@ private String getJSTypeCode(String className) {
return "Z";
case "byte":
return "B";
case "character":
case "char":
return "C";
case "double":
return "D";
case "float":
return "F";
case "int":
case "integer":
case "int":
return "I";
case "long":
return "J";
Expand Down
29 changes: 28 additions & 1 deletion sources/net.sf.j2s.java.core/build-core-applet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
<echo>Deleting the site directory.</echo>
<delete quiet="true" dir="site" />
-->



<!-- non-Java resources to copy to site/swingjs/j2s -->
<property name="resource.dir" value="resources" />

<!-- non-Java resources to copy to site/ -->
<property name="site-resource.dir" value="site-resources" />

<echo>creating swingjs2.js</echo>
<concat destfile="srcjs/swingjs2.js">
<filelist dir="srcjs/js" files="jquery.js,j2sJQueryExt.js,j2sApplet.js,j2sClazz.js,SwingJSApplet.js" />
Expand All @@ -20,6 +27,26 @@
<fileset dir="srcjs"/>
</copy>


<property name="site.dir" value="site" />
<property name="j2s.dir" value="${site.dir}/swingjs/j2s" />

<!-- transfer resources -->

<echo> Copying ${resource.dir} files into ${j2s.dir} </echo>
<copy todir="${j2s.dir}">
<fileset dir="${resource.dir}" erroronmissingdir="false" >
<include name="**/*"/>
</fileset>
</copy>

<echo> Copying ${site-resource.dir} files into ${site.dir} </echo>
<copy todir="${site.dir}">
<fileset dir="${site-resource.dir}" erroronmissingdir="false" >
<include name="**/*"/>
</fileset>
</copy>

<!-- make core files -->

<echo>creating and compressing core files - warnings are OK; "does not exist" is trouble</echo>
Expand Down
93 changes: 0 additions & 93 deletions sources/net.sf.j2s.java.core/build-site.xml

This file was deleted.

Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
3 changes: 3 additions & 0 deletions sources/net.sf.j2s.java.core/resources/_ES6/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The /_ES6 directory can contain JavaScript ES6 module code that is not to be compressed using GCC.

For example, molfile_to_inchi.wasm and wasi.esm.js
18 changes: 18 additions & 0 deletions sources/net.sf.j2s.java.core/resources/_ES6/jsutil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// JavaScript methods that use ES6 methods

J2S._ES6 || (J2S._ES6 = {});

J2S._ES6.jsutil = {

// resolve and reject are Function<Object,Object>, taking in a value and returning
// a value or a Promise.
importModule : function(resource, resolve, reject) {
return import(resource).then(
function(value) { return resolve ? resolve.apply$O(value) : value },
function(reason) { return reject ? reject.apply$O(reason) : reason }
)
},

test : function(s){alert(s)}

}
1 change: 1 addition & 0 deletions sources/net.sf.j2s.java.core/resources/_WASM/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The /_WASM directory can contain Web Assembly code.
Loading