summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorSilenio Quarti2013-02-21 14:31:04 (EST)
committer Carolyn MacLeod2013-04-09 10:53:15 (EDT)
commit87186b02e66770160dfc3566be4551b5fda59f58 (patch)
tree821b7477da29dba52b15c71571811d440642ff3c
parentda88fe82a56079ffe9f54c3b8ab6d1ded9e9efa7 (diff)
downloadeclipse.platform.swt-87186b02e66770160dfc3566be4551b5fda59f58.zip
eclipse.platform.swt-87186b02e66770160dfc3566be4551b5fda59f58.tar.gz
eclipse.platform.swt-87186b02e66770160dfc3566be4551b5fda59f58.tar.bz2
fix tools parse of parameters of comma. add convention attriibute for call natives
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTItem.java53
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java73
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java2
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java4
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectItem.java54
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties3
6 files changed, 77 insertions, 112 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTItem.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTItem.java
index 9edfd7a..b60d707 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTItem.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTItem.java
@@ -10,59 +10,6 @@
*******************************************************************************/
package org.eclipse.swt.tools.internal;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Set;
-
public abstract class ASTItem extends AbstractItem {
-public String flatten() {
- checkParams();
- StringBuffer buffer = new StringBuffer();
- Set set = params.keySet();
- String[] keys = (String[])set.toArray(new String[set.size()]);
- Arrays.sort(keys);
- for (int j = 0; j < keys.length; j++) {
- String key = keys[j];
- Object value = params.get(key);
- String valueStr = "";
- if (value instanceof String) {
- valueStr = (String)value;
- } else if (value instanceof String[]) {
- String[] values = (String[])value;
- StringBuffer valueBuffer = new StringBuffer();
- for (int i = 0; i < values.length; i++) {
- if (i != 0) valueBuffer.append(" ");
- valueBuffer.append(values[i]);
- }
- valueStr = valueBuffer.toString();
- } else {
- valueStr = value.toString();
- }
- if (valueStr.length() > 0) {
- if (buffer.length() != 0) buffer.append(",");
- buffer.append(key);
- buffer.append("=");
- buffer.append(valueStr);
- }
- }
- return buffer.toString();
-}
-
-public void parse(String str) {
- this.params = new HashMap();
- if (str.length() == 0) return;
- String[] params = split(str, ",");
- for (int i = 0; i < params.length; i++) {
- String param = params[i];
- int equals = param.indexOf('=');
- if (equals == -1) {
- System.out.println("Error: " + str + " param " + param);
- }
- String key = param.substring(0, equals).trim();
- String value = param.substring(equals + 1).trim();
- setParam(key, value);
- }
-}
-
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java
index 8e566a2..ae03297 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java
@@ -13,6 +13,7 @@ package org.eclipse.swt.tools.internal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Set;
public abstract class AbstractItem implements JNIItem {
@@ -27,7 +28,44 @@ void checkParams() {
parse(getMetaData());
}
-public abstract String flatten();
+public String flatten() {
+ checkParams();
+ StringBuffer buffer = new StringBuffer();
+ Set set = params.keySet();
+ String[] keys = (String[])set.toArray(new String[set.size()]);
+ Arrays.sort(keys);
+ for (int j = 0; j < keys.length; j++) {
+ String key = keys[j];
+ Object value = params.get(key);
+ String valueStr = "";
+ if (value instanceof String) {
+ valueStr = (String)value;
+ } else if (value instanceof String[]) {
+ String[] values = (String[])value;
+ StringBuffer valueBuffer = new StringBuffer();
+ for (int i = 0; i < values.length; i++) {
+ if (i != 0) valueBuffer.append(" ");
+ valueBuffer.append(values[i]);
+ }
+ valueStr = valueBuffer.toString();
+ } else {
+ valueStr = value.toString();
+ }
+ if (valueStr.length() > 0) {
+ if (buffer.length() != 0) buffer.append(",");
+ buffer.append(key);
+ buffer.append("=");
+ String quote = "";
+ if (valueStr.indexOf(',') != -1) {
+ quote = valueStr.indexOf('"') != -1 ? "'" : "\"";
+ }
+ buffer.append(quote);
+ buffer.append(valueStr);
+ buffer.append(quote);
+ }
+ }
+ return buffer.toString();
+}
public String[] getFlags() {
Object flags = getParam("flags");
@@ -62,7 +100,38 @@ public void setFlags(String[] flags) {
setParam("flags", flags);
}
-public abstract void parse(String str);
+public void parse(String str) {
+ this.params = new HashMap();
+ int length = str.length();
+ if (length == 0) return;
+ int index = 0;
+ while (index < length) {
+ int equals = str.indexOf('=', index);
+ if (equals == -1) {
+ System.out.println("Error: " + str + " index=" + index + " length=" + length);
+ break;
+ }
+ String key = str.substring(index, equals).trim();
+ equals++;
+ while (equals < length && Character.isWhitespace(str.charAt(equals))) equals++;
+ char c = str.charAt(equals), ending = ',';
+ switch (c) {
+ case '"':
+ case '\'':
+ equals++;
+ ending = c;
+ break;
+ }
+ int end = equals;
+ while (end < length && str.charAt(end) != ending) end++;
+ String value = str.substring(equals, end).trim();
+ setParam(key, value);
+ if (ending != ',') {
+ while (end < length && str.charAt(end) != ',') end++;
+ }
+ index = end + 1;
+ }
+}
public void setFlag(String flag, boolean value) {
String[] flags = getFlags();
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 e09dba3..23da3a2 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
@@ -73,7 +73,6 @@ public void generateAll() {
continue;
}
}
- System.out.println("Generating \"" + className + "\"");
setMainClassName(className);
generate();
}
@@ -216,6 +215,7 @@ void generateEmbededMetaData(JNIClass[] classes) {
}
public void generate() {
+ System.out.println("Generating \"" + getMainClassName() + "\"");
generate(null);
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java
index c61dad7..5994f9d 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java
@@ -694,7 +694,9 @@ void generateFunctionCall(JNIMethod method, JNIParameter[] params, JNIType retur
} else {
output("(");
output(returnType.getTypeSignature2(!returnType.equals(returnType64)));
- output(" (*)())");
+ output(" (");
+ output((String)method.getParam("convention"));
+ output("*)())");
}
output("arg0)");
paramStart = 1;
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectItem.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectItem.java
index acd9e67..9a32a26 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectItem.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectItem.java
@@ -10,10 +10,6 @@
*******************************************************************************/
package org.eclipse.swt.tools.internal;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Set;
-
public abstract class ReflectItem extends AbstractItem {
static boolean convertTo32Bit(JNIType[] paramTypes, boolean floatingPointTypes) {
@@ -53,54 +49,4 @@ boolean canChange64(Class clazz) {
clazz == float[].class ||
clazz == double[].class;
}
-
-public String flatten() {
- checkParams();
- StringBuffer buffer = new StringBuffer();
- Set set = params.keySet();
- String[] keys = (String[])set.toArray(new String[set.size()]);
- Arrays.sort(keys);
- for (int j = 0; j < keys.length; j++) {
- String key = keys[j];
- Object value = params.get(key);
- String valueStr = "";
- if (value instanceof String) {
- valueStr = (String)value;
- } else if (value instanceof String[]) {
- String[] values = (String[])value;
- StringBuffer valueBuffer = new StringBuffer();
- for (int i = 0; i < values.length; i++) {
- if (i != 0) valueBuffer.append(" ");
- valueBuffer.append(values[i]);
- }
- valueStr = valueBuffer.toString();
- } else {
- valueStr = value.toString();
- }
- if (valueStr.length() > 0) {
- if (buffer.length() != 0) buffer.append(",");
- buffer.append(key);
- buffer.append("=");
- buffer.append(valueStr);
- }
- }
- return buffer.toString();
-}
-
-public void parse(String str) {
- this.params = new HashMap();
- if (str.length() == 0) return;
- String[] params = split(str, ",");
- for (int i = 0; i < params.length; i++) {
- String param = params[i];
- int equals = param.indexOf('=');
- if (equals == -1) {
- System.out.println("Error: " + str + " param " + param);
- }
- String key = param.substring(0, equals).trim();
- String value = param.substring(equals + 1).trim();
- setParam(key, value);
- }
-}
-
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties
index c43588f..3106bf2 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties
@@ -52,4 +52,5 @@ org.eclipse.swt.internal.win32.Win32,../org.eclipse.swt/Eclipse SWT PI/wpf_win32
org.eclipse.swt.internal.cocoa.Cocoa,../org.eclipse.swt/Eclipse SWT PI/carbon/library/,\
org.eclipse.swt.internal.cocoa.OS,../org.eclipse.swt/Eclipse SWT PI/cocoa/library/,\
org.eclipse.swt.internal.webkit.WebKitGTK,../org.eclipse.swt/Eclipse SWT WebKit/gtk/library/,\
-org.eclipse.swt.internal.webkit.WebKit_win32,../org.eclipse.swt/Eclipse SWT WebKit/win32/library/
+org.eclipse.swt.internal.webkit.WebKit_win32,../org.eclipse.swt/Eclipse SWT WebKit/win32/library/,\
+org.eclipse.swt.internal.cef3.CEF3,../org.eclipse.swt/Eclipse SWT CEF/win32/library/