aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlavo <zjx001202@126.com>2019-11-29 07:56:29 +0800
committerGlavo <zjx001202@126.com>2019-11-29 07:56:29 +0800
commit6fd5804e3f2c337839efcf5c10426faed1d8b1af (patch)
tree4ffeac2c918aafdd302a23c754e055da1480efd2
parente8c30ce4df4fa9e9b8f559153b54dfc2616d4ebc (diff)
downloadgjavah-6fd5804e3f2c337839efcf5c10426faed1d8b1af.zip
gjavah-6fd5804e3f2c337839efcf5c10426faed1d8b1af.tar.gz
gjavah-6fd5804e3f2c337839efcf5c10426faed1d8b1af.tar.bz2
fix bugs
-rw-r--r--src/main/java/org/glavo/javah/JNIGenerator.java4
-rw-r--r--src/main/java/org/glavo/javah/JavahTask.java11
-rw-r--r--src/main/java/org/glavo/javah/Main.java10
-rw-r--r--src/main/java/org/glavo/javah/Utils.java6
4 files changed, 15 insertions, 16 deletions
diff --git a/src/main/java/org/glavo/javah/JNIGenerator.java b/src/main/java/org/glavo/javah/JNIGenerator.java
index a00bc6c..c1a9d40 100644
--- a/src/main/java/org/glavo/javah/JNIGenerator.java
+++ b/src/main/java/org/glavo/javah/JNIGenerator.java
@@ -61,8 +61,10 @@ public class JNIGenerator extends ClassVisitor {
value = constant.value.toString() + "f";
} else if (constant.value instanceof Long) {
value = constant.value.toString() + "i64";
- } else {
+ } else if (constant.value instanceof Double) {
value = constant.value.toString();
+ } else {
+ value = constant.value.toString() + "L";
}
output.println("#undef " + cm);
output.println("#define " + cm + " " + value);
diff --git a/src/main/java/org/glavo/javah/JavahTask.java b/src/main/java/org/glavo/javah/JavahTask.java
index 5614854..2da9400 100644
--- a/src/main/java/org/glavo/javah/JavahTask.java
+++ b/src/main/java/org/glavo/javah/JavahTask.java
@@ -11,7 +11,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
-import java.util.function.Predicate;
import java.util.stream.Stream;
public class JavahTask {
@@ -24,8 +23,8 @@ public class JavahTask {
public void run() throws IOException {
if (outputPath == null) {
- errorHandle.println("output path is not set");
- return;
+ outputPath = Paths.get(".").toAbsolutePath();
+ outputToSignalFile = false;
}
if (outputToSignalFile) {
@@ -138,18 +137,16 @@ public class JavahTask {
return outputToSignalFile;
}
- public JavahTask setOutputToSignalFile(boolean outputToSignalFile) {
+ public void setOutputToSignalFile(boolean outputToSignalFile) {
this.outputToSignalFile = outputToSignalFile;
- return this;
}
public Path getOutputPath() {
return outputPath;
}
- public JavahTask setOutputPath(Path outputPath) {
+ public void setOutputPath(Path outputPath) {
this.outputPath = outputPath;
- return this;
}
public void addClass(String name) {
diff --git a/src/main/java/org/glavo/javah/Main.java b/src/main/java/org/glavo/javah/Main.java
index 60bc0b1..6df9539 100644
--- a/src/main/java/org/glavo/javah/Main.java
+++ b/src/main/java/org/glavo/javah/Main.java
@@ -61,15 +61,11 @@ public class Main {
task.addClasspaths(args[++i]);
break;
default:
- for (int j = i; j < args.length; j++) {
- task.addClass(args[i]);
+ while (i < args.length) {
+ task.addClass(args[i++]);
}
- break loop;
}
- if (task.getClassList().isEmpty()) {
- System.err.println("error: no classes specified");
- }
- task.run();
}
+ task.run();
}
}
diff --git a/src/main/java/org/glavo/javah/Utils.java b/src/main/java/org/glavo/javah/Utils.java
index b3554ff..e9043ea 100644
--- a/src/main/java/org/glavo/javah/Utils.java
+++ b/src/main/java/org/glavo/javah/Utils.java
@@ -24,7 +24,11 @@ class Utils {
buffer.append("_2");
} else if (ch == '[') {
buffer.append("_3");
- } else if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
+ } else if ((ch >= '0' && ch <= '9')
+ || (ch >= 'a' && ch <= 'z')
+ || (ch >= 'A' && ch <= 'Z')
+ || ch == '/'
+ || ch == '.') {
buffer.append(ch);
} else {
buffer.append(String.format("_0%04x", (int) ch));