commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r765964 - in /commons/sandbox/runtime/trunk/src: main/native/include/ main/native/shared/ main/native/test/ test/org/apache/commons/runtime/
Date Fri, 17 Apr 2009 12:09:42 GMT
Author: mturk
Date: Fri Apr 17 12:09:42 2009
New Revision: 765964

URL: http://svn.apache.org/viewvc?rev=765964&view=rev
Log:
Add Pointer and Descriptor array API

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h
    commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h
    commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
    commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h?rev=765964&r1=765963&r2=765964&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h Fri Apr 17 12:09:42
2009
@@ -54,6 +54,13 @@
                                           acr_descriptor_callback_fn_t *cb);
 
 /**
+ * Create new Descriptor array
+ * @param env Current JNI environment
+ * @param len Size of the new Descriptor array
+ */
+ACR_DECLARE(jobjectArray) ACR_NewDescriptorArray(JNIEnv *env, jsize len);
+
+/**
  * Call descriptor cleanup and clear Java object.
  * @param env Current JNI environment
  * @param obj Java Descriptor object to clean. The function will

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h?rev=765964&r1=765963&r2=765964&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h Fri Apr 17 12:09:42
2009
@@ -48,6 +48,13 @@
                                        acr_pointer_cleanup_fn_t *cb);
 
 /**
+ * Create new Pointer array
+ * @param env Current JNI environment
+ * @param len Size of the new Pointer array
+ */
+ACR_DECLARE(jobjectArray) ACR_NewPointerArray(JNIEnv *env, jsize len);
+
+/**
  * Call pointer cleanup and clear Java object.
  * @param env Current JNI environment
  * @param ptr Java Pointer object to clean. The function will

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c?rev=765964&r1=765963&r2=765964&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c Fri Apr 17 12:09:42
2009
@@ -113,6 +113,13 @@
     ACR_UnloadClass(_E, &_clazzn);
 }
 
+ACR_DECLARE(jobjectArray) ACR_NewDescriptorArray(JNIEnv *_E, jsize len)
+{
+    if (_clazzn.a)
+        return (*_E)->NewObjectArray(_E, len, _clazzn.a, NULL);
+    else
+        return NULL;
+}
 
 ACR_JNI_EXPORT_DECLARE(void, Descriptor, close0)(ACR_JNISTDARGS)
 {

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c?rev=765964&r1=765963&r2=765964&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Fri Apr 17 12:09:42 2009
@@ -100,6 +100,13 @@
     ACR_UnloadClass(_E, &_clazzn);
 }
 
+ACR_DECLARE(jobjectArray) ACR_NewPointerArray(JNIEnv *_E, jsize len)
+{
+    if (_clazzn.a)
+        return (*_E)->NewObjectArray(_E, len, _clazzn.a, NULL);
+    else
+        return NULL;
+}
 
 ACR_JNI_EXPORT_DECLARE(void, Pointer, cleanup0)(ACR_JNISTDARGS)
 {

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=765964&r1=765963&r2=765964&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Fri Apr 17 12:09:42 2009
@@ -283,3 +283,14 @@
 {
     return ACR_DescriptorSetInt(_E, d, v);
 }
+
+ACR_JNI_EXPORT_DECLARE(jobjectArray, TestPrivate, test027)(ACR_JNISTDARGS, int l)
+{
+    int i;
+    jobjectArray a =  ACR_NewDescriptorArray(_E, (jsize)l);
+    for (i = 0; i < l; i++) {
+        jobject d = ACR_DescriptorCreate(_E, i, NULL, dcallback);
+        (*_E)->SetObjectArrayElement(_E, a, (jsize)i, d);
+    }
+    return a;
+}

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=765964&r1=765963&r2=765964&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Fri
Apr 17 12:09:42 2009
@@ -70,6 +70,7 @@
     private static native int   test024(Descriptor p);
     private static native int   test025(Descriptor p, int i);
     private static native int   test026(Descriptor p, int i);
+    private static native Descriptor[] test027(int size);
 
 
     protected void setUp()
@@ -479,5 +480,23 @@
         Thread.sleep(200);
     }
 
+    public void testDescriptorArray()
+        throws Throwable
+    {
+        Descriptor [] d = test027(8);
+        assertNotNull("Descriptor", d);
+        assertEquals("Size ", 8, d.length);
+        for (int i = 0; i < 8; i++) {
+            assertFalse("Closed", d[i].isClosed());
+            int r = test024(d[i]);
+            assertEquals("Result ", i, r);
+        }
+        d = null;
+        System.gc();
+        // This should be enough for a gc
+        // from Pointer.finalize()
+        Thread.sleep(200);
+    }
+
 
 }



Mime
View raw message