gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r2900 - in freeway/src/org/gnu/freeway/cwrappers: . util


From: mdonoughe
Subject: [GNUnet-SVN] r2900 - in freeway/src/org/gnu/freeway/cwrappers: . util
Date: Fri, 26 May 2006 08:30:32 -0700 (PDT)

Author: mdonoughe
Date: 2006-05-26 08:30:24 -0700 (Fri, 26 May 2006)
New Revision: 2900

Modified:
   freeway/src/org/gnu/freeway/cwrappers/CInt.java
   freeway/src/org/gnu/freeway/cwrappers/util/CWrapper.java
Log:
Changed wrappers so they no longer are required to have have get and set
Object methods. CInt now stores its value in an int because it doesn't
need Integers anymore.



Modified: freeway/src/org/gnu/freeway/cwrappers/CInt.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/CInt.java     2006-05-26 02:03:01 UTC 
(rev 2899)
+++ freeway/src/org/gnu/freeway/cwrappers/CInt.java     2006-05-26 15:30:24 UTC 
(rev 2900)
@@ -1,49 +1,58 @@
-/**
- * @PROJECT_INFO@
+ /*
+      This file is part of Freeway
+
+      Freeway is free software; you can redistribute it and/or modify
+      it under the terms of the GNU General Public License as published
+      by the Free Software Foundation; either version 2, or (at your
+      option) any later version.
+
+      Freeway is distributed in the hope that it will be useful, but
+      WITHOUT ANY WARRANTY; without even the implied warranty of
+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+      General Public License for more details.
+
+      You should have received a copy of the GNU General Public License
+      along with Freeway; see the file COPYING.  If not, write to the
+      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+      Boston, MA 02111-1307, USA.
  */
+
 package org.gnu.freeway.cwrappers;
 
 import org.gnu.freeway.cwrappers.util.CWrapper;
 
 /**
- * 
+ * @file freeway/src/org/gnu/freeway/cwrappers/CInt.java
+ * @brief A wrapper for using integers with JNI
+ * @author mdonoughe
  */
 public class CInt implements CWrapper {
 
-       private Integer value;
+       private int value;
        
-       public CInt(Integer value) {
+       public CInt(int value) {
                this.value = value;
        }
        
-       public CInt(int value) {
-               this.value = new Integer(value);
-       }
-       
        /**
         * Returns a byte array containing the integer in big endian format
         */
        public byte[] serializeToByteArray() {
-               byte[] retValue = {0, 0, 0, 0};
-               int intValue = value.intValue();
-               retValue[0] = (byte) (intValue >> 24);
-               retValue[1] = (byte) (intValue >> 16);
-               retValue[2] = (byte) (intValue >> 8);
-               retValue[3] = (byte) intValue;
+               byte[] retValue = {(byte) (value >> 24), (byte) (value >> 16), 
(byte) (value >> 8), (byte) value};
                return retValue;
        }
 
        public void deserializeFromByteArray(byte[] serializedData) {
                // those bitmasks seem to keep the sign bit from moving around
-               value = new Integer(((serializedData[0] & 0xff) << 24) | 
((serializedData[1] & 0xff) << 16) | ((serializedData[2] & 0xff) << 8) | 
((serializedData[3] & 0xff)));
+               value = ((serializedData[0] & 0xff) << 24) | 
((serializedData[1] & 0xff) << 16) | ((serializedData[2] & 0xff) << 8) | 
((serializedData[3] & 0xff));
        }
 
-       public Object getObject() {
+       public int getValue() {
                return value;
        }
-
-       public void setObject(Object data) {
-               value = (Integer) data;
+       
+       public void setValue(int value) {
+               this.value = value;
        }
 
        public int getSerializedSize() {

Modified: freeway/src/org/gnu/freeway/cwrappers/util/CWrapper.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/util/CWrapper.java    2006-05-26 
02:03:01 UTC (rev 2899)
+++ freeway/src/org/gnu/freeway/cwrappers/util/CWrapper.java    2006-05-26 
15:30:24 UTC (rev 2900)
@@ -1,14 +1,32 @@
-/**
- * @PROJECT_INFO@
+ /*
+      This file is part of Freeway
+
+      Freeway is free software; you can redistribute it and/or modify
+      it under the terms of the GNU General Public License as published
+      by the Free Software Foundation; either version 2, or (at your
+      option) any later version.
+
+      Freeway is distributed in the hope that it will be useful, but
+      WITHOUT ANY WARRANTY; without even the implied warranty of
+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+      General Public License for more details.
+
+      You should have received a copy of the GNU General Public License
+      along with Freeway; see the file COPYING.  If not, write to the
+      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+      Boston, MA 02111-1307, USA.
  */
 
 package org.gnu.freeway.cwrappers.util;
 
+
 /**
+ * @file freeway/src/org/gnu/freeway/cwrappers/util/CWrapper.java
+ * @brief A wrapper for use with JNI
+ * @author mdonoughe
  * Implementations of this interface are used to pass arguments between
  * Freeway and plugins that may be written in C.
  */
-
 public interface CWrapper {
        /**
         * Returns a byte array representation of the contained object.
@@ -20,14 +38,6 @@
         */
        public void deserializeFromByteArray(byte[] serializedData);
        /**
-        * Returns the contained object.
-        */
-       public Object getObject();
-       /**
-        * Update the contained object. May be ignored by nonmutable types.
-        */
-       public void setObject(Object data);
-       /**
         * Returns the size of the byte array created when serialized.
         */
        public int getSerializedSize();





reply via email to

[Prev in Thread] Current Thread [Next in Thread]