commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r790933 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/Pointer.java main/java/org/apache/commons/runtime/Sizeof.java test/org/apache/commons/runtime/TestPrivate.java
Date Fri, 03 Jul 2009 14:44:32 GMT
Author: mturk
Date: Fri Jul  3 14:44:32 2009
New Revision: 790933

URL: http://svn.apache.org/viewvc?rev=790933&view=rev
Log:
Add Sizeof public class

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java   (with
props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.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=790933&r1=790932&r2=790933&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 Fri
Jul  3 14:44:32 2009
@@ -25,6 +25,7 @@
 public interface Pointer extends Comparable<Pointer>
 {
 
+
     /**
      * Represents a C/C++ NULL {@code pointer}.
      */
@@ -46,7 +47,7 @@
      * Size of the memory area this pointer consumes.
      * <p>
      * If the {@code this} Pointer does not have a length
-     * the returned size if Pointer {@code SIZEOF}.
+     * the returned size if Pointer {@link #SIZEOF}.
      *</p>
      *
      * @return Internal pointer size.
@@ -129,8 +130,7 @@
      * @throws NullPointerException if {@code this} or {@code dst} is
      *          {@code null}.
      */
-    public void copy(long srcPos, Pointer dst,
-                              long dstPos, long length)
+    public void copy(long srcPos, Pointer dst, long dstPos, long length)
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException;
 
@@ -154,8 +154,7 @@
      * @throws NullPointerException if {@code this} or {@code dst} is
      *          {@code null}.
      */
-    public void move(Pointer src, long srcPos,
-                              long dstPos, long length)
+    public void move(Pointer src, long srcPos, long dstPos, long length)
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException;
 

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java?rev=790933&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java Fri
Jul  3 14:44:32 2009
@@ -0,0 +1,70 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime;
+import java.nio.charset.Charset;
+
+/**
+ * Primitive native types size info.
+ *
+ * @since Runtime 1.0
+ *
+ */
+public final class Sizeof
+{
+
+    private Sizeof()
+    {
+        // No class instance
+    }
+
+
+    static {
+
+        INT     = Platform.SIZEOF_INT;
+        LONG     = Platform.SIZEOF_LONG;
+        SIZE_T  = Platform.SIZEOF_SIZE_T;
+        POINTER = Platform.SIZEOF_POINTER;
+        WCHAR   = Platform.SIZEOF_WCHAR;
+    }
+
+    /**
+     * Size of the native platform {@code int} type in bytes.
+     */
+    public static final int INT;
+
+    /**
+     * Size of the native platform {@code long} type in bytes.
+     */
+    public static final int LONG;
+
+    /**
+     * Size of the native platform {@code size_t} type in bytes.
+     */
+    public static final int SIZE_T;
+
+    /**
+     * Size of the native platform {@code pointer} type in bytes.
+     */
+    public static final int POINTER;
+
+    /**
+     * Size of the native platform {@code size_t} type in bytes.
+     */
+    public static final int WCHAR;
+
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=790933&r1=790932&r2=790933&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
Jul  3 14:44:32 2009
@@ -315,7 +315,7 @@
     {
         Pointer p = test017(0xdeadbeef);
         assertNotNull("Pointer", p);
-        String ph = Platform.SIZEOF_POINTER == 4 ? "0xdeadbeef" : "0x00000000deadbeef";
+        String ph = Sizeof.POINTER == 4 ? "0xdeadbeef" : "0x00000000deadbeef";
         assertEquals("Pointer string ", ph, p.toString());
         p = null;
         System.gc();



Mime
View raw message