gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r2934 - in freeway/src/org/gnu/freeway: cwrappers server


From: mdonoughe
Subject: [GNUnet-SVN] r2934 - in freeway/src/org/gnu/freeway: cwrappers server
Date: Sun, 28 May 2006 18:59:49 -0700 (PDT)

Author: mdonoughe
Date: 2006-05-28 18:59:44 -0700 (Sun, 28 May 2006)
New Revision: 2934

Added:
   freeway/src/org/gnu/freeway/cwrappers/CIntPtr.java
   freeway/src/org/gnu/freeway/cwrappers/CLongPtr.java
   freeway/src/org/gnu/freeway/cwrappers/CUnsignedIntPtr.java
   freeway/src/org/gnu/freeway/cwrappers/ConstCIntPtr.java
   freeway/src/org/gnu/freeway/cwrappers/ConstCLongPtr.java
   freeway/src/org/gnu/freeway/cwrappers/ConstCUnsignedIntPtr.java
Modified:
   freeway/src/org/gnu/freeway/server/CoreAPI.java
Log:
added pointer varients of cwrapper classes
put fake code into CoreAPI.java


Added: freeway/src/org/gnu/freeway/cwrappers/CIntPtr.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/CIntPtr.java  2006-05-28 21:54:15 UTC 
(rev 2933)
+++ freeway/src/org/gnu/freeway/cwrappers/CIntPtr.java  2006-05-29 01:59:44 UTC 
(rev 2934)
@@ -0,0 +1,46 @@
+ /*
+      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 CIntPtr extends ConstCInt implements CWrapper {
+
+       @SuppressWarnings("unused")
+       private static final int KIND = CWrapper.PTR_KIND;
+       
+       public CIntPtr(int value) {
+               super(value);
+       }
+
+       public void deserializeFromByteArray(byte[] serializedData) {
+               // those bitmasks seem to keep the sign bit from moving around
+               value = ((serializedData[0] & 0xff) << 24) | 
((serializedData[1] & 0xff) << 16) | ((serializedData[2] & 0xff) << 8) | 
((serializedData[3] & 0xff));
+       }
+       
+       public void setValue(int value) {
+               this.value = value;
+       }
+}

Added: freeway/src/org/gnu/freeway/cwrappers/CLongPtr.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/CLongPtr.java 2006-05-28 21:54:15 UTC 
(rev 2933)
+++ freeway/src/org/gnu/freeway/cwrappers/CLongPtr.java 2006-05-29 01:59:44 UTC 
(rev 2934)
@@ -0,0 +1,46 @@
+ /*
+      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/CLong.java
+ * @brief A wrapper for using long long values with JNI
+ * @author mdonoughe
+ */
+public class CLongPtr extends ConstCLong implements CWrapper {
+
+       @SuppressWarnings("unused")
+       private static final int KIND = CWrapper.PTR_KIND;
+
+       public CLongPtr(long value) {
+               super(value);
+       }
+
+       public void deserializeFromByteArray(byte[] serializedData) {
+               // those bitmasks seem to keep the sign bit from moving around
+               value = ((serializedData[0] & 0xffl) << 56) | 
((serializedData[1] & 0xffl) << 48) | ((serializedData[2] & 0xffl) << 40) | 
((serializedData[3] & 0xffl) << 32) | ((serializedData[4] & 0xffl) << 24) | 
((serializedData[5] & 0xffl) << 16) | ((serializedData[6] & 0xffl) << 8) | 
((serializedData[7] & 0xffl));
+       }
+       
+       public void setValue(long value) {
+               this.value = value;
+       }
+}

Added: freeway/src/org/gnu/freeway/cwrappers/CUnsignedIntPtr.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/CUnsignedIntPtr.java  2006-05-28 
21:54:15 UTC (rev 2933)
+++ freeway/src/org/gnu/freeway/cwrappers/CUnsignedIntPtr.java  2006-05-29 
01:59:44 UTC (rev 2934)
@@ -0,0 +1,47 @@
+ /*
+      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/CUnsignedInt.java
+ * @brief A wrapper for using unsigned integers with JNI
+ * @author mdonoughe
+ */
+public class CUnsignedIntPtr extends ConstCUnsignedInt implements CWrapper {
+
+       @SuppressWarnings("unused")
+       private static final int KIND = CWrapper.PTR_KIND;
+
+       public CUnsignedIntPtr(long value) {
+               super(value);
+       }
+
+       public void deserializeFromByteArray(byte[] serializedData) {
+               // those bitmasks seem to keep the sign bit from moving around
+               value = ((serializedData[0] & 0xffl) << 24) | 
((serializedData[1] & 0xffl) << 16) | ((serializedData[2] & 0xffl) << 8) | 
((serializedData[3] & 0xffl));
+       }
+       
+       public void setValue(long value) {
+               validate(value);
+               this.value = value;
+       }
+}

Added: freeway/src/org/gnu/freeway/cwrappers/ConstCIntPtr.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/ConstCIntPtr.java     2006-05-28 
21:54:15 UTC (rev 2933)
+++ freeway/src/org/gnu/freeway/cwrappers/ConstCIntPtr.java     2006-05-29 
01:59:44 UTC (rev 2934)
@@ -0,0 +1,55 @@
+ /*
+      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;
+import org.gnu.freeway.cwrappers.util.ConstCWrapper;
+
+/**
+ * @file freeway/src/org/gnu/freeway/cwrappers/ConstCInt.java
+ * @brief A wrapper for using constant integers with JNI
+ * @author mdonoughe
+ */
+public class ConstCIntPtr implements ConstCWrapper {
+       
+       @SuppressWarnings("unused")
+       private static final int KIND = CWrapper.PTR_KIND;
+
+       protected int value;
+       
+       public ConstCIntPtr(int value) {
+               this.value = value;
+       }
+       
+       /**
+        * Returns a byte array containing the integer in big endian format
+        */
+       public byte[] serializeToByteArray() {
+               return new byte[] {(byte) (value >> 24), (byte) (value >> 16), 
(byte) (value >> 8), (byte) value};
+       }
+
+       public int getValue() {
+               return value;
+       }
+
+       public int getSerializedSize() {
+               return 4;
+       }
+}

Added: freeway/src/org/gnu/freeway/cwrappers/ConstCLongPtr.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/ConstCLongPtr.java    2006-05-28 
21:54:15 UTC (rev 2933)
+++ freeway/src/org/gnu/freeway/cwrappers/ConstCLongPtr.java    2006-05-29 
01:59:44 UTC (rev 2934)
@@ -0,0 +1,55 @@
+ /*
+      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;
+import org.gnu.freeway.cwrappers.util.ConstCWrapper;
+
+/**
+ * @file freeway/src/org/gnu/freeway/cwrappers/ConstCLong.java
+ * @brief A wrapper for using constant long long values with JNI
+ * @author mdonoughe
+ */
+public class ConstCLongPtr implements ConstCWrapper {
+
+       @SuppressWarnings("unused")
+       private static final int KIND = CWrapper.PTR_KIND;
+
+       protected long value;
+       
+       public ConstCLongPtr(long value) {
+               this.value = value;
+       }
+       
+       /**
+        * Returns a byte array containing the long in big endian format
+        */
+       public byte[] serializeToByteArray() {
+               return new byte[] {(byte) (value >> 56), (byte) (value >> 48), 
(byte) (value >> 40), (byte) (value >> 32), (byte) (value >> 24), (byte) (value 
>> 16), (byte) (value >> 8), (byte) value};
+       }
+
+       public long getValue() {
+               return value;
+       }
+
+       public int getSerializedSize() {
+               return 8;
+       }
+}

Added: freeway/src/org/gnu/freeway/cwrappers/ConstCUnsignedIntPtr.java
===================================================================
--- freeway/src/org/gnu/freeway/cwrappers/ConstCUnsignedIntPtr.java     
2006-05-28 21:54:15 UTC (rev 2933)
+++ freeway/src/org/gnu/freeway/cwrappers/ConstCUnsignedIntPtr.java     
2006-05-29 01:59:44 UTC (rev 2934)
@@ -0,0 +1,69 @@
+ /*
+      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;
+import org.gnu.freeway.cwrappers.util.ConstCWrapper;
+
+/**
+ * @file freeway/src/org/gnu/freeway/cwrappers/ConstCUnsignedInt.java
+ * @brief A wrapper for using constant unsigned integers with JNI
+ * @author mdonoughe
+ */
+public class ConstCUnsignedIntPtr implements ConstCWrapper {
+
+       @SuppressWarnings("unused")
+       private static final int KIND = CWrapper.PTR_KIND;
+
+       protected long value;
+       
+       public ConstCUnsignedIntPtr(long value) {
+               validate(value);
+               this.value = value;
+       }
+       
+       protected static void validate(long value) {
+               if(value < 0 || value > 4294967295l)
+                       throw new IllegalArgumentException("Unsigned integers 
cannot be less than 0 or more than 4,294,967,295.");
+       }
+       
+       /**
+        * Returns a byte array containing the integer in big endian format
+        */
+       public byte[] serializeToByteArray() {
+               return new byte[] {(byte) (value >> 24), (byte) (value >> 16), 
(byte) (value >> 8), (byte) value};
+       }
+
+       public long getValue() {
+               return value;
+       }
+
+       public int getSerializedSize() {
+               return 4;
+       }
+       
+       public static CUnsignedInt boxSignedInt(int value) {
+               return new CUnsignedInt(unsignedIntToLong(value));
+       }
+       
+       public static long unsignedIntToLong(int value) {
+               return value & 0xFFFFFFFFl;
+       }
+}

Modified: freeway/src/org/gnu/freeway/server/CoreAPI.java
===================================================================
--- freeway/src/org/gnu/freeway/server/CoreAPI.java     2006-05-28 21:54:15 UTC 
(rev 2933)
+++ freeway/src/org/gnu/freeway/server/CoreAPI.java     2006-05-29 01:59:44 UTC 
(rev 2934)
@@ -19,14 +19,269 @@
 
 package org.gnu.freeway.server;
 
+import org.gnu.freeway.cwrappers.*;
+
 /**
  * @file CoreAPI.java
  * @brief 
  * @author mdonoughe
  */
 public class CoreAPI {
+       public final static CInt OK = new CInt(1);
+       public final static CInt SYSERR = new CInt(-1);
+       public final static CInt YES = new CInt(1);
+       public final static CInt NO = new CInt(0);
+       
+       public CUnsignedInt version;
+       public CPeerIdentity myIdentity;
+       
+       public CInt loadApplicationModule(CString name) {
+               return SYSERR;
+       }
+       
+       public CInt unloadApplicationModule(CString name) {
+               return SYSERR;
+       }
+       
+       public CPointer requestService(CString name) {
+               return new CPointer();
+       }
+       
+       public CInt releaseService(CPointer service) {
+               return SYSERR;
+       }
+       
+       public CInt sendPlaintext(CTSession session, CString msg, CUnsignedInt 
size) {
+               return SYSERR;
+       }
+       
+       public void unicast(ConstCPeerIdentity receiver, ConstCP2PMessageHeader 
msg, CUnsignedInt importance, CUnsignedInt maxdelay) {
+               
+       }
+       
+       public void unicastCallback(ConstCPeerIdentity receiver, 
CBuildMessageCallback callback, CPointer closure) {
+               
+       }
+       
+       public CInt forAllConnectedNodes(CPerNodeCallback method, CPointer arg) 
{
+               return SYSERR;
+       }
+       
+       public CInt registerSendCallback(ConstCUnsignedInt minimumPadding, 
CBufferFillCallback callback) {
+               return SYSERR;
+       }
+       
+       public CInt unregisterSendCallback(ConstCUnsignedInt minimumPadding, 
CBufferFillCallback callback) {
+               return SYSERR;
+       }
+       
+       public CInt registerSendNotify(CMessagePartHandler callback) {
+               return SYSERR;
+       }
+       
+       public CInt unregisterSendNotify(CMessagePartHandler callback) {
+               return SYSERR;
+       }
+       
+       public CInt registerHandler(CUnsignedShort type, CMessagePartHandler 
callback) {
+               return SYSERR;
+       }
+       
+       public CInt unregisterHandler(CUnsignedShort type, CMessagePartHandler 
callback) {
+               return SYSERR;
+       }
+       
+       public CInt isHandlerRegistered(CUnsignedShort type, CUnsignedShort 
handlerType) {
+               return SYSERR;
+       }
+       
+       public CInt registerPlainTextHandler(CUnsignedShort type, 
CPlaintextMessagePartHandler callback) {
+               return SYSERR;
+       }
+       
+       public CInt unregisterPlaintextHandler(CUnsignedShort type, 
CPlaintextMessagePartHandler callback) {
+               return SYSERR;
+       }
+       
+       public void offerTSessionFor(ConstCPeerIdentity peer, CTSession 
session) {
+               
+       }
+       
+       public void assignSessionKey(ConstCSessionKey key, ConstCPeerIdentity 
peer, CTime_T age, CInt forSending) {
+               
+       }
+       
+       public CInt getCurrentSessionKey(ConstCPeerIdentity peer, CSessionKey 
key, CTime_TPtr age, CInt forSending) {
+               return SYSERR;
+       }
+       
+       public void confirmSessionUp(ConstCPeerIdentity peer) {
+               
+       }
+       
+       public void preferTrafficFrom(ConstCPeerIdentity node, CDouble 
preference) {
+               
+       }
+       
+       public CUnsignedInt queryBPMfromPeer(ConstCPeerIdentity node) {
+               return new CUnsignedInt(SYSERR.getValue());
+       }
+       
+       public void disconnectFromPeer(ConstCPeerIdentity peer) {
+               
+       }
+       
+       public CInt sendValueToClient(CClientHandle handle, CInt value) {
+               return SYSERR;
+       }
+       
+       public CSendToClientCallback sendToClient;
+       
+       public CInt registerClientHandler(CUnsignedShort type, CCSHandler 
callback) {
+               return SYSERR;
+       }
+       
+       public CInt unregisterClientHandler(CUnsignedShort type, CCSHandler 
callback) {
+               return SYSERR;
+       }
+       
+       public CInt registerClientExitHandler(CClientExitHandler callback) {
+               return SYSERR;
+       }
+       
+       public CInt unregisterClientExitHandler(CClientExitHandler callback) {
+               return SYSERR;
+       }
+       
+       public void terminateClientConnection(CClientHandle handle) {
+               
+       }
+       
+       public void injectMessage(ConstCPeerIdentity sender, ConstCString msg, 
CUnsignedInt size, CInt wasEncrypted, CTSession session) {
+               
+       }
+       
+       public CUnsignedInt computeIndex(ConstCPeerIdentity hostId) {
+               return new CUnsignedInt(0);
+       }
+       
+       public CMutexPtr getConnectionModuleLock() {
+               return new CMutexPtr();
+       }
+       
+       public CInt getSlotCount() {
+               return new CInt(0);
+       }
+       
+       public CInt isSlotUsed(CInt slot) {
+               return new CInt(0);
+       }
+       
+       public CInt getLastActivityOf(ConstCPeerIdentity peer, CCron_TPtr time) 
{
+               return SYSERR;
+       }
+       
+       
        public static final CoreAPI _ = new CoreAPI();
        private CoreAPI() {
                
        }
+       
+       private class CPeerIdentity {
+               //TODO: write CPeerIdentity
+       }
+       
+       private class ConstCPeerIdentity {
+               //TODO: write CConstPeerIdentity
+       }
+       
+       private class CTSession {
+               //TODO: write CTSession
+       }
+       
+       private class CP2PMessageHeader {
+               //TODO: write CP2PMessageHeader
+       }
+       
+       private class ConstCP2PMessageHeader {
+               //TODO: write CP2PMessageHeader
+       }
+       
+       private class CBuildMessageCallback {
+               //TODO: write CBuildMessageCallback
+       }
+       
+       private class CPointer {
+               //TODO: write CPointer class for void *
+               public CPointer() {
+                       
+               }
+       }
+       
+       private class CPerNodeCallback {
+               //TODO: write CPerNodeCallback
+       }
+       
+       private class CBufferFillCallback {
+               //TODO: write CPerNodeCallback
+       }
+       
+       private class CMessagePartHandler {
+               //TODO: write this
+       }
+       
+       private class CUnsignedShort {
+               //TODO: write this
+       }
+       
+       private class CMutexPtr {
+               //TODO: write this
+               public CMutexPtr() {
+                       
+               }
+       }
+       
+       private class CCron_TPtr {
+               //TODO: write this
+       }
+       
+       private class CClientHandle {
+               //TODO: write this
+       }
+       
+       private class CClientExitHandler {
+               //TODO: write this
+       }
+       
+       private class CCSHandler {
+               //TODO: write this
+       }
+       
+       private class CSendToClientCallback {
+               //TODO: write this
+       }
+       
+       private class CDouble {
+               //TODO: write this
+       }
+       
+       private class CTime_TPtr {
+               //TODO: write this
+       }
+       
+       private class CSessionKey {
+               //TODO: write this
+       }
+       
+       private class ConstCSessionKey {
+               //TODO: write this
+       }
+       
+       private class CTime_T {
+               //TODO: write this
+       }
+       
+       private class CPlaintextMessagePartHandler {
+               //TODO: write this
+       }
 }





reply via email to

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