mirror of
https://github.com/quinton-ashley/java2js
synced 2024-12-29 10:11:54 +01:00
1.2.2
This commit is contained in:
parent
2b9cc5bf44
commit
a03efa965d
23
jdk.js
23
jdk.js
@ -218,9 +218,6 @@
|
||||
return 'new Runnable("' + in0 + '")';
|
||||
});
|
||||
|
||||
// cast to int, truncates the number (just removes decimal value)
|
||||
// file = file.replace(/\(int\)\s*/gm, 'Math.floor');
|
||||
|
||||
let packageName = (file.match(/package\s+([^;]+)/gm) || [])[1] || 'default';
|
||||
|
||||
let trans = await java_to_javascript(file);
|
||||
@ -19187,22 +19184,24 @@
|
||||
let cast = expr.type.primitiveTypeCode;
|
||||
if (cast == 'int') {
|
||||
// if cast to int
|
||||
if (type == 'char') {
|
||||
exp += '.charCodeAt(0)';
|
||||
} else if (/(double|float|short|long)/.test(type)) {
|
||||
exp = 'Math.floor(' + exp + ')';
|
||||
} else {
|
||||
if (type == 'String') {
|
||||
castError = true;
|
||||
} else if (type == 'char') {
|
||||
exp += '.charCodeAt(0)';
|
||||
} else {
|
||||
exp = 'Math.floor(' + exp + ')';
|
||||
}
|
||||
} else if (cast == 'char') {
|
||||
if (/(double|float|short|long)/.test(type)) {
|
||||
exp = 'String.fromCharCode(' + exp + ')';
|
||||
} else {
|
||||
if (type == 'String') {
|
||||
castError = true;
|
||||
} else {
|
||||
exp = 'String.fromCharCode(' + exp + ')';
|
||||
}
|
||||
}
|
||||
if (castError) {
|
||||
System.err.println(`error: incompatible types: ${type} cannot be converted to ${cast}: ${exp}`);
|
||||
let msg = `error: incompatible types: ${type} cannot be converted to ${cast}: ${exp}`;
|
||||
console.log(msg);
|
||||
System.err.println(msg);
|
||||
return '';
|
||||
}
|
||||
return exp;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "java2js",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "Converts Java to JavaScript and runs it with a JS JDK",
|
||||
"main": "jdk.js",
|
||||
"scripts": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user