This is an automated email from the git hooks/post-receive script. tpot-guest pushed a commit to tag 0.6.5 in repository jffi-next.
commit 66eaa01685f2325c6dd1549f904d647142486918 Author: Wayne Meissner <[email protected]> Date: Fri Aug 21 19:14:32 2009 +1000 Type that describes an array (cherry picked from commit 2150fce31ccc5b1da3367a8c9b553999cd0d20ee) --- src/com/kenai/jffi/Array.java | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/com/kenai/jffi/Array.java b/src/com/kenai/jffi/Array.java new file mode 100644 index 0000000..de4280d --- /dev/null +++ b/src/com/kenai/jffi/Array.java @@ -0,0 +1,65 @@ + +package com.kenai.jffi; + +/** + * Describes the layout of a C array + */ +public final class Array extends Type { + /* Keep a strong reference to the element types so it is not GCed */ + private final Type elementType; + + private final int length; + + /** + * Creates a new C array layout description. + * + * @param fields The fields contained in the struct. + */ + public Array(Type elementType, int length) { + super(newArray(elementType, length)); + this.elementType = elementType; + this.length = length; + } + + /** + * Creates a libffi ffi_type* handle for the array. + * + * Since libffi doesn't know about arrays, we fake them by defining an + * aggregate (struct) with <tt>length</tt> fields of type <tt>elementType</tt> + */ + private static final long newArray(Type elementType, int length) { + long[] handles = new long[length]; + for (int i = 0; i < handles.length; i++) { + handles[i] = elementType.handle(); + } + + return Foreign.getInstance().newStruct(handles, false); + } + + /** + * Returns the type of elements in the array + * + * @return The <tt>Type</tt> of the elements in the array + */ + public final Type getElementType() { + return elementType; + } + + /** + * Returns the number of elements in the array + * + * @return The number of elements in the array + */ + public final int length() { + return length; + } + + @Override + protected void finalize() throws Throwable { + try { + Foreign.getInstance().freeStruct(handle); + } finally { + super.finalize(); + } + } +} -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

