summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/runtime
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-02-12 02:22:24 +0100
committerMichael Bien <[email protected]>2010-02-12 02:22:24 +0100
commit0fa706b4eef533ead671310a9a7e063a910198cb (patch)
treeb02b31aa6215c7b2f627ae785d4bdaf9242e0e70 /src/java/com/sun/gluegen/runtime
parentdd7facc1dd5f6a34d2c4542b7435995c4d2d25b1 (diff)
added support for arrays in generated StructAccessors.
Specifying JavaClass or JavaImplClass is no longer a requirement. It is now possible to generate StructAccessors from c headers without emitting any other binding code (force with EmitStruct <name>).
Diffstat (limited to 'src/java/com/sun/gluegen/runtime')
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp39
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/StructAccessor.java.javase65
2 files changed, 104 insertions, 0 deletions
diff --git a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp b/src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp
index d670bcc..d97d2a0 100755
--- a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp
+++ b/src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp
@@ -98,6 +98,45 @@ public class StructAccessor {
intBuffer().put(slot, v);
}
+ public void setBytesAt(int slot, byte[] v) {
+ for (int i = 0; i < v.length; i++) {
+ bb.put(slot++, v[i]);
+ }
+ }
+
+ public byte[] getBytesAt(int slot, byte[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = bb.get(slot++);
+ }
+ return v;
+ }
+
+ public void setIntsAt(int slot, int[] v) {
+ for (int i = 0; i < v.length; i++) {
+ intBuffer().put(slot++, v[i]);
+ }
+ }
+
+ public int[] getIntsAt(int slot, int[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = intBuffer().get(slot++);
+ }
+ return v;
+ }
+
+ public void setFloatsAt(int slot, float[] v) {
+ for (int i = 0; i < v.length; i++) {
+ floatBuffer().put(slot++, v[i]);
+ }
+ }
+
+ public float[] getFloatsAt(int slot, float[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = floatBuffer().get(slot++);
+ }
+ return v;
+ }
+
/** Retrieves the long at the specified slot (8-byte offset). */
public long getLongAt(int slot) {
slot = slot << 1 ; // 8-byte to 4-byte offset
diff --git a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javase b/src/java/com/sun/gluegen/runtime/StructAccessor.java.javase
index 5a0fa5d..9113859 100755
--- a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javase
+++ b/src/java/com/sun/gluegen/runtime/StructAccessor.java.javase
@@ -143,6 +143,71 @@ public class StructAccessor {
shortBuffer().put(slot, v);
}
+ public void setBytesAt(int slot, byte[] v) {
+ for (int i = 0; i < v.length; i++) {
+ bb.put(slot++, v[i]);
+ }
+ }
+
+ public byte[] getBytesAt(int slot, byte[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = bb.get(slot++);
+ }
+ return v;
+ }
+
+ public void setCharsAt(int slot, char[] v) {
+ for (int i = 0; i < v.length; i++) {
+ charBuffer().put(slot++, v[i]);
+ }
+ }
+
+ public char[] getCharsAt(int slot, char[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = charBuffer().get(slot++);
+ }
+ return v;
+ }
+
+ public void setIntsAt(int slot, int[] v) {
+ for (int i = 0; i < v.length; i++) {
+ intBuffer().put(slot++, v[i]);
+ }
+ }
+
+ public int[] getIntsAt(int slot, int[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = intBuffer().get(slot++);
+ }
+ return v;
+ }
+
+ public void setFloatsAt(int slot, float[] v) {
+ for (int i = 0; i < v.length; i++) {
+ floatBuffer().put(slot++, v[i]);
+ }
+ }
+
+ public float[] getFloatsAt(int slot, float[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = floatBuffer().get(slot++);
+ }
+ return v;
+ }
+
+ public void setDoublesAt(int slot, double[] v) {
+ for (int i = 0; i < v.length; i++) {
+ doubleBuffer().put(slot++, v[i]);
+ }
+ }
+
+ public double[] getDoublesAt(int slot, double[] v) {
+ for (int i = 0; i < v.length; i++) {
+ v[i] = doubleBuffer().get(slot++);
+ }
+ return v;
+ }
+
//----------------------------------------------------------------------
// Internals only below this point
//