harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r474176 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
Date Mon, 13 Nov 2006 07:12:13 GMT
Author: varlax
Date: Sun Nov 12 23:12:12 2006
New Revision: 474176

URL: http://svn.apache.org/viewvc?view=rev&rev=474176
Log:
Fixed JNI NIO impl:
- corrected signatures and parameters sizing;
- added prototype declarations as required by the stdcall calling convention;
- fixed PlatformAddressFactory class name.
Tested WinXP, SUSE9

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c?view=diff&rev=474176&r1=474175&r2=474176
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
Sun Nov 12 23:12:12 2006
@@ -16,13 +16,16 @@
 
 #include <jni.h>
 
+JNIEXPORT jobject JNICALL NewDirectByteBuffer(JNIEnv * , void*, jlong );
+JNIEXPORT void* JNICALL GetDirectBufferAddress(JNIEnv * , jobject );
+JNIEXPORT jlong JNICALL GetDirectBufferCapacity(JNIEnv * , jobject );
+
 /*
- * For JNI
- * Method:    NewDirectByteBuffer
- * Signature: (JJ)Ljava/nio/ByteBuffer;
+ * Reference implementation of NewDirectByteBuffer() functionality (JNI 1.4 NIO support).
+ * To be included to JNI function table either directly or wrapped.
  */
-jobject NewDirectByteBuffer
-  (JNIEnv * env, jlong address, jlong capacity){
+JNIEXPORT jobject JNICALL NewDirectByteBuffer
+  (JNIEnv * env, void* address, jlong capacity){
 	  jmethodID newBufferMethod;
 	  jclass directBufferClass;
 	  jclass platformaddressClass;
@@ -37,7 +40,7 @@
 	  if (!newBufferMethod){
 	      	  return NULL;
 	  }
-	  platformaddressClass = (*env)->FindClass (env, "org/apache/harmony/luni/platform/PlatformAddress");
+	  platformaddressClass = (*env)->FindClass (env, "org/apache/harmony/luni/platform/PlatformAddressFactory");
 	  if (!platformaddressClass){
 	      	  return NULL;
 	  }
@@ -46,16 +49,17 @@
 	  if (!onMethod){
 	      	  return NULL;
 	  }
-	  platformaddress = (*env)->CallStaticObjectMethod(env, platformaddressClass, onMethod,
address);
-	  return (*env)->NewObject(env, directBufferClass, newBufferMethod, platformaddress,
capacity, 0);
+	  platformaddress = (*env)->CallStaticObjectMethod(env, platformaddressClass, onMethod,
(jlong)address);
+	  return (*env)->NewObject(env, directBufferClass, newBufferMethod, 
+                                platformaddress, (jint)capacity, (jint)0);
   }
 
 /*
- * For JNI
- * Method:    GetDirectBufferAddress
- * Signature: (Ljava/nio/Buffer;)J
+ * Reference implementation of GetDirectBufferAddress() functionality 
+ * (JNI 1.4 NIO support).
+ * To be included to JNI function table either directly or wrapped.
  */
-jlong GetDirectBufferAddress
+JNIEXPORT void* JNICALL GetDirectBufferAddress
   (JNIEnv * env, jobject buf){
 	  jmethodID tempMethod;
 	  jclass tempClass;
@@ -85,15 +89,15 @@
 	  if (!toLongMethod){
 	      	  return 0;
 	  }
-	  return  (*env)->CallLongMethod(env, platformAddr, toLongMethod);	  
+	  return (void*)(*env)->CallLongMethod(env, platformAddr, toLongMethod);	  
   }
 
 /*
- * For JNI
- * Method:    GetDirectBufferCapacity
- * Signature: (Ljava/nio/Buffer;)J
+ * Reference implementation of GetDirectBufferCapacity() functionality 
+ * (JNI 1.4 NIO support).
+ * To be included to JNI function table either directly or wrapped.
  */
-jlong GetDirectBufferCapacity
+JNIEXPORT jlong JNICALL GetDirectBufferCapacity
   (JNIEnv * env, jobject buf){
 	  jfieldID fieldCapacity;
 	  jclass directBufferClass;
@@ -116,5 +120,3 @@
 	  }
 	  return (*env)->GetIntField(env, buf, fieldCapacity);
   }
-
-



Mime
View raw message