[jffi-next] 39/49: First pass at fast-path for numeric invoker with up to two array arguments.

Tim Potter tpot-guest at moszumanska.debian.org
Wed Mar 4 04:51:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

tpot-guest pushed a commit to annotated tag upstream/1.0.10
in repository jffi-next.

commit a03809fcf71c6a5f28234c5c8f05a4125c215dfb
Author: Wayne Meissner <wmeissner at gmail.com>
Date:   Tue Apr 26 19:35:49 2011 +1000

    First pass at fast-path for numeric invoker with up to two array arguments.
---
 src/com/kenai/jffi/HeapObjectParameterInvoker.java | 220 +++++++++++++++++++++
 src/com/kenai/jffi/Invoker.java                    |  85 +++++++-
 .../kenai/jffi/NativeObjectParameterInvoker.java   | 219 ++++++++++++++++++++
 src/com/kenai/jffi/ObjectParameterInfo.java        |  75 +++++++
 src/com/kenai/jffi/ObjectParameterInvoker.java     |  70 +++++++
 version.xml                                        |   2 +-
 6 files changed, 669 insertions(+), 2 deletions(-)

diff --git a/src/com/kenai/jffi/HeapObjectParameterInvoker.java b/src/com/kenai/jffi/HeapObjectParameterInvoker.java
new file mode 100644
index 0000000..be37604
--- /dev/null
+++ b/src/com/kenai/jffi/HeapObjectParameterInvoker.java
@@ -0,0 +1,220 @@
+package com.kenai.jffi;
+
+/**
+ *
+ */
+public class HeapObjectParameterInvoker extends ObjectParameterInvoker {
+    private final Foreign foreign = Foreign.getInstance();
+
+    private static int encode(byte[] paramBuffer, int off, Type type, long n) {
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        if (type.size() <= 4) {
+            return encoder.putInt(paramBuffer, off, (int) n);
+        } else {
+            return encoder.putLong(paramBuffer, off, n);
+        }
+    }
+    
+    public long invokeN1O1rN(Function function, 
+            long n1,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        
+        return foreign.invokeArrayO1Int64(function.getContextAddress(), 
+                new byte[HeapInvocationBuffer.encoder.getBufferSize(function)],
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+    
+    public long invokeN2O1rN(Function function, 
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        
+        return foreign.invokeArrayO1Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    public long invokeN2O2rN(Function function,
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags, 
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+        
+        return foreign.invokeArrayO2Int64(function.getContextAddress(), 
+                new byte[HeapInvocationBuffer.encoder.getBufferSize(function)],
+                o1, o1flags.asObjectInfo(), o1off, o1len, 
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+
+    public long invokeN3O1rN(Function function, 
+        long n1, long n2, long n3,
+        Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        
+        
+        return foreign.invokeArrayO1Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+    
+    public long invokeN3O2rN(Function function, 
+        long n1, long n2, long n3, 
+        Object o1, int o1off, int o1len, ObjectParameterInfo o1flags, 
+        Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        
+        return foreign.invokeArrayO2Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+
+    public long invokeN4O1rN(Function function, 
+        long n1, long n2, long n3, long n4,
+        Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        poff = encode(paramBuffer, poff, function.getParameterType(3), n4);
+        
+        
+        return foreign.invokeArrayO1Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+    
+    public long invokeN4O2rN(Function function, 
+        long n1, long n2, long n3, long n4,
+        Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+        Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        poff = encode(paramBuffer, poff, function.getParameterType(3), n4);
+        
+        
+        return foreign.invokeArrayO2Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+
+    @Override
+    public long invokeN5O1rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        poff = encode(paramBuffer, poff, function.getParameterType(3), n4);
+        poff = encode(paramBuffer, poff, function.getParameterType(4), n5);
+        
+        return foreign.invokeArrayO1Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    @Override
+    public long invokeN5O2rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags, 
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        poff = encode(paramBuffer, poff, function.getParameterType(3), n4);
+        poff = encode(paramBuffer, poff, function.getParameterType(4), n5);
+        
+        
+        return foreign.invokeArrayO2Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+
+    @Override
+    public long invokeN6O1rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, long n6, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        poff = encode(paramBuffer, poff, function.getParameterType(3), n4);
+        poff = encode(paramBuffer, poff, function.getParameterType(4), n5);
+        poff = encode(paramBuffer, poff, function.getParameterType(5), n6);
+        
+        return foreign.invokeArrayO1Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    @Override
+    public long invokeN6O2rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, long n6, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags, 
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+        
+        HeapInvocationBuffer.Encoder encoder = HeapInvocationBuffer.encoder;
+        byte[] paramBuffer = new byte[encoder.getBufferSize(function)];
+        
+        int poff = 0;
+        poff = encode(paramBuffer, poff, function.getParameterType(0), n1);
+        poff = encode(paramBuffer, poff, function.getParameterType(1), n2);
+        poff = encode(paramBuffer, poff, function.getParameterType(2), n3);
+        poff = encode(paramBuffer, poff, function.getParameterType(3), n4);
+        poff = encode(paramBuffer, poff, function.getParameterType(4), n5);
+        poff = encode(paramBuffer, poff, function.getParameterType(5), n6);
+        
+        return foreign.invokeArrayO2Int64(function.getContextAddress(), 
+                paramBuffer, 
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+    
+    
+
+}
diff --git a/src/com/kenai/jffi/Invoker.java b/src/com/kenai/jffi/Invoker.java
index 093339a..2740c05 100644
--- a/src/com/kenai/jffi/Invoker.java
+++ b/src/com/kenai/jffi/Invoker.java
@@ -44,6 +44,8 @@ public abstract class Invoker {
     private static final long ADDRESS_MASK = Platform.getPlatform().addressMask();
     
     private final Foreign foreign = Foreign.getInstance();
+    
+    private final ObjectParameterInvoker objectParameterInvoker = ObjectParameterInvoker.getInstance();
 
     /** Lazy initialization singleton holder */
     private static final class SingletonHolder {
@@ -229,7 +231,7 @@ public abstract class Invoker {
     public final long invokeLrL(Function function, long arg1) {
         return foreign.invokeLrL(function.getContextAddress(), arg1);
     }
-
+    
     /**
      * Invokes a function with two 64 bit integer arguments, and returns a 64 bit integer.
      *
@@ -390,6 +392,87 @@ public abstract class Invoker {
     public final long invokeNNNNNNrN(Function function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) {
         return foreign.invokeNNNNNNrN(function.getContextAddress(), arg1, arg2, arg3, arg4, arg5, arg6);
     }
+    
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param n1 first numeric argument.
+     * @param idx1 parameter index of the first numeric argument.
+     * @param o1 array or buffer, to be passed as a pointer for the first numeric parameter.
+     * @param o1off offset from the start of the array pr buffer.
+     * @param o1len length of the array to use.
+     * @param o1flags object flags (type, direction, parameter index).
+     */
+    public final long invokeNNO1rN(Function function, 
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+
+        return objectParameterInvoker.invokeN2O1rN(function, 
+                n1, n2,
+                o1, o1off, o1len, o1flags);
+    }
+    
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param arg1 An array, to be passed as a pointer for the first numeric parameter.
+     * @param off1 The offset from the start of the array.
+     * @param len1 The length of the array to use.
+     * @param flags1 Array flags (direction, type).
+     * @param arg2 The second numeric argument.
+     */
+    public final long invokeNNO2rN(Function function,
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+
+        return objectParameterInvoker.invokeN2O2rN(function,
+                n1, n2,
+                o1, o1off, o1len, o1flags,
+                o2, o2off, o2len, o2flags);
+    }
+    
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param arg1 An array, to be passed as a pointer for the first numeric parameter.
+     * @param off1 The offset from the start of the array.
+     * @param len1 The length of the array to use.
+     * @param flags1 Array flags (direction, type).
+     * @param arg2 The second numeric argument.
+     */
+    public final long invokeNNNO1rN(Function function, 
+            long n1, long n2, long n3,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+
+        return objectParameterInvoker.invokeN3O1rN(function, 
+                n1, n2, n3,
+                o1, o1off, o1len, o1flags);
+    }
+
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param arg1 An array, to be passed as a pointer for the first numeric parameter.
+     * @param off1 The offset from the start of the array.
+     * @param len1 The length of the array to use.
+     * @param flags1 Array flags (direction, type).
+     * @param arg2 The second numeric argument.
+     */
+    public final long invokeNNNO2rN(Function function, 
+            long n1, long n2, long n3,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+
+        return objectParameterInvoker.invokeN3O2rN(function, 
+                n1, n2, n3,
+                o1, o1off, o1len, o1flags,
+                o2, o2off, o2len, o2flags);
+    }
 
     /**
      * Invokes a function and returns a native memory address.
diff --git a/src/com/kenai/jffi/NativeObjectParameterInvoker.java b/src/com/kenai/jffi/NativeObjectParameterInvoker.java
new file mode 100644
index 0000000..fe2fa3b
--- /dev/null
+++ b/src/com/kenai/jffi/NativeObjectParameterInvoker.java
@@ -0,0 +1,219 @@
+
+package com.kenai.jffi;
+
+/**
+ *
+ */
+public final class NativeObjectParameterInvoker extends ObjectParameterInvoker {
+    private final Foreign foreign = Foreign.getInstance();
+
+    public final boolean isNative() {
+        return true;
+    }
+    
+    public final long invokeN1O1rN(Function function, 
+            long n1, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        return foreign.invokeN1O1rN(function.getContextAddress(), function.getFunctionAddress(),
+                n1, 
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param n1 first numeric argument.
+     * @param idx1 parameter index of the first numeric argument.
+     * @param o1 array or buffer, to be passed as a pointer for the first numeric parameter.
+     * @param o1off offset from the start of the array or buffer.
+     * @param o1len length of the array to use.
+     * @param o1flags object flags (type, direction, parameter index).
+     */
+    public final long invokeN2O1rN(Function function, 
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+
+        return foreign.invokeN2O1rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2,
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+    
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param arg1 An array, to be passed as a pointer for the first numeric parameter.
+     * @param off1 The offset from the start of the array.
+     * @param len1 The length of the array to use.
+     * @param flags1 Array flags (direction, type).
+     * @param arg2 The second numeric argument.
+     */
+    public final long invokeN2O2rN(Function function,
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+
+        return foreign.invokeN2O2rN(function.getContextAddress(), function.getFunctionAddress(),
+                n1, n2,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+    
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param arg1 An array, to be passed as a pointer for the first numeric parameter.
+     * @param off1 The offset from the start of the array.
+     * @param len1 The length of the array to use.
+     * @param flags1 Array flags (direction, type).
+     * @param arg2 The second numeric argument.
+     */
+    public final long invokeN3O1rN(Function function, 
+            long n1, long n2, long n3,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+
+        return foreign.invokeN3O1rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3, 
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    /**
+     * Invokes a function with two numeric arguments, and returns a numeric value.
+     *
+     * @param function The <tt>Function</tt> to invoke.
+     * @param arg1 An array, to be passed as a pointer for the first numeric parameter.
+     * @param off1 The offset from the start of the array.
+     * @param len1 The length of the array to use.
+     * @param flags1 Array flags (direction, type).
+     * @param arg2 The second numeric argument.
+     */
+    public final long invokeN3O2rN(Function function, 
+            long n1, long n2, long n3,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+
+        return foreign.invokeN3O2rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+    
+    public final long invokeN3O3rN(Function function, 
+            long n1, long n2, long n3,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags,
+            Object o3, int o3off, int o3len, ObjectParameterInfo o3flags) {
+
+        return foreign.invokeN3O3rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len,
+                o3, o3flags.asObjectInfo(), o3off, o3len);
+    }
+
+    public final long invokeN4O1rN(Function function, 
+            long n1, long n2, long n3, long n4,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+
+        return foreign.invokeN4O1rN(function.getContextAddress(), function.getFunctionAddress(),
+                n1, n2, n3, n4,
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    public final long invokeN4O2rN(Function function, 
+            long n1, long n2, long n3, long n4,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+
+        return foreign.invokeN4O2rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3, n4,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+    
+    public final long invokeN4O3rN(Function function, 
+            long n1, long n2, long n3, long n4,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags,
+            Object o3, int o3off, int o3len, ObjectParameterInfo o3flags) {
+
+        return foreign.invokeN4O3rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3, n4,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len,
+                o3, o3flags.asObjectInfo(), o3off, o3len);
+    }
+
+    @Override
+    public long invokeN5O1rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        
+        return foreign.invokeN5O1rN(function.getContextAddress(), function.getFunctionAddress(),
+                n1, n2, n3, n4, n5,
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    @Override
+    public long invokeN5O2rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags, 
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+        
+        return foreign.invokeN5O2rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3, n4, n5,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+    
+    public final long invokeN5O3rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags,
+            Object o3, int o3off, int o3len, ObjectParameterInfo o3flags) {
+
+        return foreign.invokeN5O3rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3, n4, n5,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len,
+                o3, o3flags.asObjectInfo(), o3off, o3len);
+    }
+
+    @Override
+    public long invokeN6O1rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, long n6, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags) {
+        
+        return foreign.invokeN6O1rN(function.getContextAddress(), function.getFunctionAddress(),
+                n1, n2, n3, n4, n5, n6,
+                o1, o1flags.asObjectInfo(), o1off, o1len);
+    }
+
+    @Override
+    public long invokeN6O2rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, long n6, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags, 
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags) {
+        
+        return foreign.invokeN6O2rN(function.getContextAddress(), function.getFunctionAddress(),
+                n1, n2, n3, n4, n5, n6,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len);
+    }
+    
+    public final long invokeN6O3rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, long n6,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags,
+            Object o3, int o3off, int o3len, ObjectParameterInfo o3flags) {
+
+        return foreign.invokeN6O3rN(function.getContextAddress(), function.getFunctionAddress(), 
+                n1, n2, n3, n4, n5, n6,
+                o1, o1flags.asObjectInfo(), o1off, o1len,
+                o2, o2flags.asObjectInfo(), o2off, o2len,
+                o3, o3flags.asObjectInfo(), o3off, o3len);
+    }
+}
diff --git a/src/com/kenai/jffi/ObjectParameterInfo.java b/src/com/kenai/jffi/ObjectParameterInfo.java
new file mode 100644
index 0000000..95bcf20
--- /dev/null
+++ b/src/com/kenai/jffi/ObjectParameterInfo.java
@@ -0,0 +1,75 @@
+package com.kenai.jffi;
+
+public final class ObjectParameterInfo {
+    private final int parameterIndex;
+    private final ComponentType componentType;
+    private final int objectInfo;
+
+    
+    public static ObjectParameterInfo create(int parameterIndex, ObjectType objectType, 
+            ComponentType componentType, int ioflags) {
+
+        return new ObjectParameterInfo(parameterIndex, objectType, componentType, ioflags);
+    }
+
+    /* Stop ArrayFlags from being intantiated */
+    private ObjectParameterInfo(int parameterIndex, ObjectType objectType, 
+            ComponentType componentType, int ioflags) {
+        
+        this.parameterIndex = parameterIndex;
+        this.componentType = componentType;
+        this.objectInfo = ObjectBuffer.makeObjectFlags(ioflags, 
+                objectType.value | componentType.value, parameterIndex);
+    }
+
+    /** Copy the array contents to native memory before calling the function */
+    public static final int IN = ObjectBuffer.IN;
+
+    /** After calling the function, reload the array contents from native memory */
+    public static final int OUT = ObjectBuffer.OUT;
+
+    /** Pin the array memory and pass the JVM memory pointer directly to the function */
+    public static final int PINNED = ObjectBuffer.PINNED;
+
+    /** Append a NUL byte to the array contents after copying to native memory */
+    public static final int NULTERMINATE = ObjectBuffer.ZERO_TERMINATE;
+
+    /** For OUT arrays, clear the native memory area before passing to the native function */
+    public static final int CLEAR = ObjectBuffer.CLEAR;
+
+    public static final class ObjectType {
+        final int value;
+
+        ObjectType(int type) {
+            this.value = type;
+        }
+    }
+    
+    public static final ObjectType ARRAY = new ObjectType(ObjectBuffer.ARRAY);
+    public static final ObjectType BUFFER = new ObjectType(ObjectBuffer.BUFFER);
+    
+    public static final class ComponentType {
+        final int value;
+
+        ComponentType(int type) {
+            this.value = type;
+        }
+    }
+    
+    public static final ComponentType BYTE = new ComponentType(ObjectBuffer.BYTE);
+    public static final ComponentType SHORT = new ComponentType(ObjectBuffer.SHORT);
+    public static final ComponentType INT = new ComponentType(ObjectBuffer.INT);
+    public static final ComponentType LONG = new ComponentType(ObjectBuffer.LONG);
+    public static final ComponentType FLOAT = new ComponentType(ObjectBuffer.FLOAT);
+    public static final ComponentType DOUBLE = new ComponentType(ObjectBuffer.DOUBLE);
+    public static final ComponentType BOOLEAN = new ComponentType(ObjectBuffer.BOOLEAN);
+    public static final ComponentType CHAR = new ComponentType(ObjectBuffer.CHAR);
+    
+    final int asObjectInfo() {
+        return objectInfo;
+    }
+
+    public final int getParameterIndex() {
+        return parameterIndex;
+    }
+}
diff --git a/src/com/kenai/jffi/ObjectParameterInvoker.java b/src/com/kenai/jffi/ObjectParameterInvoker.java
new file mode 100644
index 0000000..51db3c0
--- /dev/null
+++ b/src/com/kenai/jffi/ObjectParameterInvoker.java
@@ -0,0 +1,70 @@
+package com.kenai.jffi;
+
+abstract public class ObjectParameterInvoker {
+    private static final class SingletonHolder {
+        static final ObjectParameterInvoker INSTANCE 
+                = Foreign.getInstance().getVersion() >= 0x01000A /* version 1.0.10 */
+                ? newNativeInvoker() : newHeapInvoker();
+    }
+    
+    public static ObjectParameterInvoker getInstance() {
+        return SingletonHolder.INSTANCE;
+    }
+    
+    static ObjectParameterInvoker newNativeInvoker() {
+        return new NativeObjectParameterInvoker();
+    }
+    
+    static ObjectParameterInvoker newHeapInvoker() {
+        return new HeapObjectParameterInvoker();
+    }
+    
+    abstract public long invokeN1O1rN(Function function, 
+            long n1, 
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags);
+    
+    abstract public long invokeN2O1rN(Function function, 
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags);
+    
+    abstract public long invokeN2O2rN(Function function,
+            long n1, long n2,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags);
+    
+    abstract public long invokeN3O1rN(Function function, 
+            long n1, long n2, long n3,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags);
+    
+    abstract public long invokeN3O2rN(Function function, 
+            long n1, long n2, long n3,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags);
+    
+    abstract public long invokeN4O1rN(Function function, 
+            long n1, long n2, long n3, long n4,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags);
+    
+    abstract public long invokeN4O2rN(Function function, 
+            long n1, long n2, long n3, long n4,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags);
+    
+    abstract public long invokeN5O1rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags);
+    
+    abstract public long invokeN5O2rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags);
+    
+    abstract public long invokeN6O1rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, long n6,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags);
+    
+    abstract public long invokeN6O2rN(Function function, 
+            long n1, long n2, long n3, long n4, long n5, long n6,
+            Object o1, int o1off, int o1len, ObjectParameterInfo o1flags,
+            Object o2, int o2off, int o2len, ObjectParameterInfo o2flags);
+}
diff --git a/version.xml b/version.xml
index b81bf0c..46fa596 100644
--- a/version.xml
+++ b/version.xml
@@ -1,7 +1,7 @@
 <project name="version" default="default" basedir=".">
     <property name="jffi.version.major" value="1"/>
     <property name="jffi.version.minor" value="0"/>
-    <property name="jffi.version.micro" value="7"/>
+    <property name="jffi.version.micro" value="10"/>
     <target name="-generate-version-source" depends="">
         <echo message="Generating Version.java"/>
         <mkdir dir="${build.classes.dir}"/>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git



More information about the pkg-java-commits mailing list