You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/06/22 11:19:00 UTC
svn commit: r787178 - in /commons/sandbox/runtime/trunk/src:
main/java/org/apache/commons/runtime/ test/org/apache/commons/runtime/
Author: mturk
Date: Mon Jun 22 09:18:59 2009
New Revision: 787178
URL: http://svn.apache.org/viewvc?rev=787178&view=rev
Log:
Use primitive type for Pointer size
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestDirectByteBuffer.java
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java?rev=787178&r1=787177&r2=787178&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java Mon Jun 22 09:18:59 2009
@@ -111,14 +111,13 @@
/**
* Size of the memory area this pointer consumes.
* <p>
- * Depending on the operating system the {@code Number} can be
- * either {@code Integer} for 32 bit systems of {@code Long} for
- * a 64 bit system.
+ * If the {@code this} Pointer does not have a length
+ * the returned size if Pointer {@code SIZEOF}.
*</p>
*
- * @return Internal pointer size casted to the {@code Number}.
+ * @return Internal pointer size.
*/
- public abstract Number size();
+ public abstract long sizeof();
/** Chack if the pointer is valid
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java?rev=787178&r1=787177&r2=787178&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java Mon Jun 22 09:18:59 2009
@@ -68,9 +68,12 @@
return new Integer(POINTER);
}
- public Number size()
+ public long sizeof()
{
- return new Integer(PLENGTH);
+ if (PLENGTH > 0)
+ return PLENGTH;
+ else
+ return 4;
}
private static native int peek0(int addr);
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java?rev=787178&r1=787177&r2=787178&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java Mon Jun 22 09:18:59 2009
@@ -67,9 +67,12 @@
return new Long(POINTER);
}
- public Number size()
+ public long sizeof()
{
- return new Long(PLENGTH);
+ if (PLENGTH > 0)
+ return PLENGTH;
+ else
+ return 4;
}
private static native int peek0(long addr);
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestDirectByteBuffer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestDirectByteBuffer.java?rev=787178&r1=787177&r2=787178&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestDirectByteBuffer.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestDirectByteBuffer.java Mon Jun 22 09:18:59 2009
@@ -220,7 +220,7 @@
}
// Aligned size
// 104 + 1000 = 1104
- assertEquals("Size", 1104, mem.size().intValue());
+ assertEquals("Size", 1104L, mem.sizeof());
/* WARNING: Do not free any Buffer.
* Use Pointer.free()
*/