summaryrefslogtreecommitdiffstats
path: root/bundles
diff options
context:
space:
mode:
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java37
-rw-r--r--bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java33
2 files changed, 57 insertions, 13 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
index ee4ecc2120..e09dba3eb4 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
@@ -24,7 +24,7 @@ public class JNIGeneratorApp {
JNIClass mainClass;
JNIClass[] classes;
ProgressMonitor progress;
- String mainClassName, outputDir, classpath;
+ String mainClassName, classesDir, outputDir, classpath;
MetaData metaData;
static boolean USE_AST = true;
@@ -36,6 +36,10 @@ public String getClasspath() {
return classpath;
}
+public String getClassesDir() {
+ return classesDir;
+}
+
public JNIClass getMainClass() {
return mainClass;
}
@@ -332,7 +336,8 @@ public JNIClass[] getClasses() {
if (qualifiedName.equals(mainClassName)) {
classes[i] = mainClass;
} else {
- String sourcePath = new File(outputDir).getParent() + "/" + qualifiedName.replace('.', '/') + ".java";
+ String root = classesDir != null ? classesDir : new File(outputDir).getParent() + "/";
+ String sourcePath = root + qualifiedName.replace('.', '/') + ".java";
classes[i] = new ReflectClass(Class.forName(qualifiedName, false, getClass().getClassLoader()), metaData, sourcePath);
}
} catch (Exception e) {
@@ -345,8 +350,8 @@ public JNIClass[] getClasses() {
JNIClass[] getASTClasses() {
if (classes != null) return classes;
if (mainClassName == null) return new JNIClass[0];
- String root = new File(outputDir).getParent();
- String mainPath = new File(root + "/" + mainClassName.replace('.', '/') + ".java").getAbsolutePath();
+ String root = classesDir != null ? classesDir : new File(outputDir).getParent() + "/";
+ String mainPath = new File(root + mainClassName.replace('.', '/') + ".java").getAbsolutePath();
ArrayList classes = new ArrayList();
String packageName = getPackageName(mainClassName);
File dir = new File(root + "/" + packageName.replace('.', '/'));
@@ -445,7 +450,8 @@ public void setMainClassName(String str) {
}
if (mainClassName != null) {
try {
- String sourcePath = new File(outputDir).getParent() + "/" + mainClassName.replace('.', '/') + ".java";
+ String root = classesDir != null ? classesDir : new File(outputDir).getParent() + "/";
+ String sourcePath = root + mainClassName.replace('.', '/') + ".java";
if (USE_AST) {
mainClass = new ASTClass(sourcePath, metaData);
} else {
@@ -457,11 +463,17 @@ public void setMainClassName(String str) {
}
}
public void setMainClassName(String str, String outputDir) {
+ setMainClassName(str, outputDir, null);
+}
+
+public void setMainClassName(String str, String outputDir, String classesDir) {
mainClassName = str;
+ setClassesDir(classesDir);
setOutputDir(outputDir);
metaData = new MetaData(mainClassName);
try {
- String sourcePath = new File(this.outputDir).getParent() + "/" + mainClassName.replace('.', '/') + ".java";
+ String root = classesDir != null ? classesDir : new File(outputDir).getParent() + "/";
+ String sourcePath = root + mainClassName.replace('.', '/') + ".java";
if (USE_AST) {
mainClass = new ASTClass(sourcePath, metaData);
} else {
@@ -472,13 +484,24 @@ public void setMainClassName(String str, String outputDir) {
}
}
+public void setClassesDir(String str) {
+ if (str != null) {
+ if (!str.endsWith("\\") && !str.endsWith("/") ) {
+ str += File.separator;
+ }
+ str = str.replace('\\', '/');
+ }
+ classesDir = str;
+}
+
public void setOutputDir(String str) {
if (str != null) {
if (!str.endsWith("\\") && !str.endsWith("/") ) {
str += File.separator;
}
+ str = str.replace('\\', '/');
}
- outputDir = str.replace('\\', '/');
+ outputDir = str;
}
public static String getDefaultMainClass() {
diff --git a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
index f670c8fe64..2f6c055eeb 100644
--- a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
+++ b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
@@ -20,7 +20,7 @@ import org.xml.sax.InputSource;
public class MacGenerator {
String[] xmls;
Document[] documents;
- String outputDir, mainClassName;
+ String outputDir, outputLibDir, extrasDir, mainClassName;
String delimiter = System.getProperty("line.separator");
PrintStream out;
@@ -137,7 +137,8 @@ public void generate(ProgressMonitor progress) {
void generateCSource() {
JNIGeneratorApp app = new JNIGeneratorApp();
- app.setMainClassName(mainClassName, outputDir + "/library");
+ String outputLibDir = this.outputLibDir != null ? this.outputLibDir : outputDir + "/library";
+ app.setMainClassName(mainClassName, outputLibDir, outputDir);
app.generate();
}
@@ -446,7 +447,7 @@ void copyClassMethodsDown(final Map classes) {
int getHierarchyLevel(Node node) {
String superclass = getSuperclassName(node);
int level = 0;
- while (!superclass.equals("id")) {
+ while (!superclass.equals("id") && !superclass.equals("NSObject")) {
level++;
superclass = getSuperclassName((Node)((Object[])classes.get(superclass))[0]);
}
@@ -561,7 +562,7 @@ void generateMainClass() {
int start = str.indexOf(section) + section.length();
int end = str.indexOf(section, start);
header = str.substring(0, start);
- footer = str.substring(end);
+ footer = end == -1 ? "\n}" : str.substring(end);
} catch (IOException e) {
} finally {
try {
@@ -633,7 +634,8 @@ public Document[] getDocuments() {
if (document == null) continue;
if (mainClassName != null && outputDir != null) {
String packageName = getPackageName(mainClassName);
- String extrasPath = outputDir + packageName.replace('.', '/') + "/" + getFileName(xmlPath) + ".extras";
+ String folder = extrasDir != null ? extrasDir : outputDir + packageName.replace('.', '/');
+ String extrasPath = folder + "/" + getFileName(xmlPath) + ".extras";
merge(document, getDocument(extrasPath));
}
}
@@ -660,7 +662,8 @@ public String[] getXmls() {
void saveExtraAttributes(String xmlPath, Document document) {
try {
String packageName = getPackageName(mainClassName);
- String fileName = outputDir + packageName.replace('.', '/') + "/" + getFileName(xmlPath) + ".extras";
+ String folder = extrasDir != null ? extrasDir : outputDir + packageName.replace('.', '/');
+ String fileName = folder + "/" + getFileName(xmlPath) + ".extras";
ByteArrayOutputStream out = new ByteArrayOutputStream();
DOMWriter writer = new DOMWriter(new PrintStream(out));
String[] names = getIDAttributeNames();
@@ -688,6 +691,24 @@ public void setOutputDir(String dir) {
this.outputDir = dir;
}
+public void setOutputLibDir(String dir) {
+ if (dir != null) {
+ if (!dir.endsWith("\\") && !dir.endsWith("/") ) {
+ dir += "/";
+ }
+ }
+ this.outputLibDir = dir;
+}
+
+public void setExtrasDir(String dir) {
+ if (dir != null) {
+ if (!dir.endsWith("\\") && !dir.endsWith("/") ) {
+ dir += "/";
+ }
+ }
+ this.extrasDir = dir;
+}
+
public void setXmls(String[] xmls) {
this.xmls = xmls;
this.documents = null;