Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7104256

Browse files
authored
Merge pull request#232 from BobHanson/master
various updates
2 parentsb3db746 +61b4fc1 commit7104256

File tree

78 files changed

+5086
-1336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5086
-1336
lines changed
55.9 KB
Binary file not shown.
-36 KB
Binary file not shown.
-105 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240225103130
1+
20241217101652
55.9 KB
Binary file not shown.
-36 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240225103130
1+
20241217101652

‎sources/net.sf.j2s.core/src/j2s/CorePlugin.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ public class CorePlugin extends Plugin {
2626
* the actual "x.y.z" version is specified in plugin.xml.
2727
*
2828
*/
29-
publicstaticStringVERSION ="5.0.1-v2";
29+
publicstaticStringVERSION ="5.0.1-v4";
3030

3131
// if you change the x.x.x number, be sure to also indicate that in
3232
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat
3333

34+
// BH 2024.07.14 -- 5.0.1-v4 fixes numerical array initializer using characters ['a','b',...]
35+
// BH 2024.02.22 -- 5.0.1-v3 fixes long extension issue causing MutableBitInteger to miscalculate subtraction(no change in version #)
3436
// BH 2023.11.27 -- 5.0.1-v2 final refactoring and creatiton of J2SUtil
3537
// BH 2023.11.21 -- 5.0.1-v2 adds Java8 syntaxes for try and switch; removes dependency for instanceOf and exception checking
3638
// BH 2023.11.09 -- 5.0.1-v1 merges Jmol legacy (.j2sjmol) with Java8//11 (.j2s)

‎sources/net.sf.j2s.core/src/j2s/jmol/J2SLegacyVisitor.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ public boolean visit(ArrayCreation node) {
21002100
buffer.append(" Clazz.newBooleanArray(");
21012101
boxList(dim,", ");
21022102
buffer.append(", false)");
2103-
}else {
2103+
}else {
21042104
if (dim !=null &&dim.size() >1) {
21052105
buffer.append(" Clazz.newArray(");
21062106
boxList(dim,", ");
@@ -2140,6 +2140,8 @@ public boolean visit(ArrayInitializer node) {
21402140
buffer.append("]");
21412141
returnfalse;
21422142
}
2143+
// note that this does NOT allow for new byte[] {'a', 'b', 'c'}
2144+
// only implemented that for SwingJS
21432145
if (elementType.isPrimitive()) {
21442146
StringtypeCode =elementType.getName();
21452147
if ("int".equals(typeCode)

‎sources/net.sf.j2s.core/src/j2s/swingjs/Java2ScriptVisitor.java‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
// TODO: superclass inheritance for JAXB XmlAccessorType
3232
// TODO: Transpiler bug allows static String name, but JavaScript function().name is read-only and will be "clazz"
3333

34-
//BH 2024.02.22 -- 3.3.1-v7 fixes long extension issue causing MutableBitInteger to miscalculate subtraction(no change in version #)
34+
//BH 2024.07.14 -- 5.0.1-v4 fixes numerical array initializer using characters ['a','b',...], but not new int[] { "test".charAt(3) }
35+
//BH 2024.02.22 -- 5.0.1-v3 fixes long extension issue causing MutableBitInteger to miscalculate subtraction(no change in version #)
36+
//BH 2023.11.27 -- 5.0.1-v2 final refactoring and creatiton of J2SUtil
37+
//BH 2023.11.21 -- 5.0.1-v2 adds Java8 syntaxes for try and switch; removes dependency for instanceOf and exception checking
38+
//BH 2023.11.09 -- 5.0.1-v1 merges Jmol legacy (.j2sjmol) with Java8//11 (.j2s)
3539
//BH 2023.03.29 -- 3.3.1-v7 fixes outer static method call from within lambda expression.
3640
//BH 2023.02.09 -- 3.3.1.v6 fixes j2s.excluded.paths needing /src/xxxx
3741
//BH 2022.06.27 -- 3.3.1-v5 fixes missing method annotations
@@ -3015,15 +3019,63 @@ private void addArrayConstructor(ITypeBinding binding, List<ASTNode> dim) {
30153019

30163020
publicbooleanvisit(ArrayInitializernode) {
30173021
// as in: public String[] d = {"1", "2"};
3018-
buffer.append(clazzArray(node.resolveTypeBinding(),ARRAY_INITIALIZED));
3022+
ITypeBindingtype =node.resolveTypeBinding();
3023+
buffer.append(clazzArray(type,ARRAY_INITIALIZED));
30193024
buffer.append(", [");
3025+
inttoChar =toCharType(type);
30203026
@SuppressWarnings("unchecked")
3021-
List<ASTNode>expressions =node.expressions();
3022-
visitList(expressions,", ");
3027+
List<ASTNode>ex =node.expressions();
3028+
if (toChar ==0) {
3029+
visitList(ex,", ");
3030+
}else {
3031+
fixCharArrayInit(buffer,ex,toChar);
3032+
}
30233033
buffer.append("])");
30243034
returnfalse;
30253035
}
30263036

3037+
privatestaticinttoCharType(ITypeBindingtype) {
3038+
switch (type ==null ?"" :type.getName()) {
3039+
case"char[]":
3040+
return1;
3041+
case"byte[]":
3042+
case"short[]":
3043+
case"int[]":
3044+
case"long[]":
3045+
case"float[]":
3046+
case"double[]":
3047+
return -1;
3048+
default:
3049+
return0;
3050+
}
3051+
}
3052+
3053+
privatevoidfixCharArrayInit(StringBufferbuffer,List<ASTNode>list,inttoChar) {
3054+
for (Iterator<ASTNode>iter =list.iterator();iter.hasNext();) {
3055+
intpt =buffer.length();
3056+
appendBoxingNode(iter.next(),false,null,false,false);
3057+
if (toChar !=0) {
3058+
Strings =buffer.substring(pt);
3059+
// only fix "x" and number
3060+
// not fixed: int[] a = new int[] {"test".charAt(0)}
3061+
try {
3062+
if (pt >0 && (s.charAt(0) =='"') != (toChar ==1)) {
3063+
buffer.replace(pt,buffer.length(),
3064+
(toChar ==1 ?
3065+
"\"" + ((char)Integer.parseInt(s)) +"\""
3066+
:s.length() ==3 ?"" + (byte)s.charAt(1) :s)
3067+
);
3068+
}
3069+
}catch (@SuppressWarnings("unused")Exceptione) {
3070+
// ignore
3071+
}
3072+
}
3073+
if (!iter.hasNext())
3074+
return;
3075+
buffer.append(", ");
3076+
}
3077+
}
3078+
30273079
publicbooleanvisit(Assignmentnode) {
30283080
// note that this is not
30293081
// var x = ..... -- that is a visit(VariableDeclaration)
@@ -4431,8 +4483,6 @@ private void addNonCharacter(Expression exp) {
44314483
switch (name) {
44324484
case"char":
44334485
case"Character":
4434-
addOperand(exp,false);
4435-
break;
44364486
case"Byte":
44374487
case"Short":
44384488
case"Integer":

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp