Restore operability of Circle3D from JavaScript
There were two small problems. First, the type-checking in MacroRunner.run was too strict, so applications that worked manually were failing from JavaScript. The fix was to replace all of the type-checking code in that function with a single call to isAdmissible(), which also simplified the code and removed duplication. Second, when assembling return values in ExecuteMacro in JSFunctions.java the code would commit array bounds violations when there were no targets from the MacroRunner. This commit fixes both problems and avoids silently dropping the exceptions caught in Circle3D.
This commit is contained in:
parent
c312811084
commit
e2f0f34394
4 changed files with 29 additions and 46 deletions
|
@ -5758,7 +5758,9 @@ public class JSFunctions {
|
|||
getC().lastButN(i).setShowName(false);
|
||||
}
|
||||
|
||||
if(TargetsNamesArray.length<2) {
|
||||
if (TargetsNamesArray.length == 0) {
|
||||
return getC().lastButN(0).getName();
|
||||
} else if (TargetsNamesArray.length == 1) {
|
||||
return TargetsNamesArray[0];
|
||||
} else {
|
||||
return TargetsNamesArray;
|
||||
|
@ -5785,7 +5787,9 @@ public class JSFunctions {
|
|||
getC().lastButN(i).setShowName(false);
|
||||
}
|
||||
|
||||
if(TargetsNamesArray.length<2) {
|
||||
if (TargetsNamesArray.length == 0) {
|
||||
return getC().lastButN(0).getName();
|
||||
} else if (TargetsNamesArray.length == 1) {
|
||||
return TargetsNamesArray[0];
|
||||
} else {
|
||||
return TargetsNamesArray;
|
||||
|
@ -7650,14 +7654,21 @@ public class JSFunctions {
|
|||
try {
|
||||
ExecuteMacro("","@builtin@/3Dcircle1","O,X,Y,Z,"+a+","+b);
|
||||
}
|
||||
catch (final Exception f) {}
|
||||
catch (final Exception f) {
|
||||
Println("Potential problem executing macro @builtin@/3Dcircle1(O,X,Y,Z,"
|
||||
+ a + "," + b + "):" + f.getMessage());
|
||||
}
|
||||
getC().lastButN(0).setShowName(false);
|
||||
} else {
|
||||
name=parseVariables(name);
|
||||
try {
|
||||
ExecuteMacro("","@builtin@/3Dcircle1","O,X,Y,Z,"+a+","+b);
|
||||
}
|
||||
catch (final Exception f) {}
|
||||
catch (final Exception f) {
|
||||
Println("Potential problem executing macro assignment " +
|
||||
name + " = @builtin@/3Dcircle1(O,X,Y,Z," +
|
||||
a + "," + b + "):" + f.getMessage());
|
||||
}
|
||||
getC().lastButN(0).setName(name);
|
||||
}
|
||||
Normalize(0);
|
||||
|
@ -7679,14 +7690,21 @@ public class JSFunctions {
|
|||
try {
|
||||
ExecuteMacro("","@builtin@/3Dcircle1","O,X,Y,Z,"+a+","+b);
|
||||
}
|
||||
catch (final Exception f) {}
|
||||
catch (final Exception f) {
|
||||
Println("Il y a peut-etre une probleme avec macro @builtin@/3Dcircle1(O,X,Y,Z,"
|
||||
+ a + "," + b + "):" + f.getMessage());
|
||||
}
|
||||
getC().lastButN(0).setShowName(false);
|
||||
} else {
|
||||
name=parseVariables(name);
|
||||
try {
|
||||
ExecuteMacro("","@builtin@/3Dcircle1","O,X,Y,Z,"+a+","+b);
|
||||
}
|
||||
catch (final Exception f) {}
|
||||
catch (final Exception f) {
|
||||
Println("Il y a peut-etre une probleme avec macro assignment " +
|
||||
name + " = @builtin@/3Dcircle1(O,X,Y,Z," +
|
||||
a + "," + b + "):" + f.getMessage());
|
||||
}
|
||||
getC().lastButN(0).setName(name);
|
||||
}
|
||||
Normalize(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue