add FastCheck version classes in ClassLibrary
authorjzhou <jzhou>
Thu, 12 Mar 2009 22:59:28 +0000 (22:59 +0000)
committerjzhou <jzhou>
Thu, 12 Mar 2009 22:59:28 +0000 (22:59 +0000)
Robust/src/ClassLibrary/FastCheck/Object.java [new file with mode: 0644]
Robust/src/ClassLibrary/FastCheck/ServerSocket.java [new file with mode: 0644]
Robust/src/ClassLibrary/FastCheck/Socket.java [new file with mode: 0644]
Robust/src/ClassLibrary/FastCheck/StartupObject.java [new file with mode: 0644]
Robust/src/ClassLibrary/FastCheck/TagDescriptor.java [new file with mode: 0644]
Robust/src/buildscript

diff --git a/Robust/src/ClassLibrary/FastCheck/Object.java b/Robust/src/ClassLibrary/FastCheck/Object.java
new file mode 100644 (file)
index 0000000..351f032
--- /dev/null
@@ -0,0 +1,34 @@
+public class Object {
+  public int cachedCode;   //first field has to be a primitive
+  public boolean cachedHash;
+  public Object nextobject;   /* Oid */
+  public Object localcopy;
+
+  public native int nativehashCode();
+
+  /* DO NOT USE ANY OF THESE - THEY ARE FOR IMPLEMENTING TAGS */
+  private Object tags;
+
+
+  public int hashCode() {
+    if (!cachedHash) {
+      cachedCode=nativehashCode();
+      cachedHash=true;
+    }
+    return cachedCode;
+  }
+
+  /* DON'T USE THIS METHOD UNLESS NECESSARY */
+  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
+  public native int getType();
+
+  public String toString() {
+    return "Object"+hashCode();
+  }
+
+  public boolean equals(Object o) {
+    if (o==this)
+      return true;
+    return false;
+  }
+}
diff --git a/Robust/src/ClassLibrary/FastCheck/ServerSocket.java b/Robust/src/ClassLibrary/FastCheck/ServerSocket.java
new file mode 100644 (file)
index 0000000..723e886
--- /dev/null
@@ -0,0 +1,38 @@
+public class ServerSocket {
+  /* Socket pending flag */
+  external flag SocketPending;
+  /* File Descriptor */
+  int fd;
+
+  private native int createSocket(int port);
+
+  public ServerSocket(int port) {
+    this.fd=createSocket(port);
+  }
+
+  public Socket accept() {
+    Socket s=new Socket();
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+    return s;
+  }
+
+  public Socket accept(tag td) {
+    Socket s=new Socket() {
+    } {td};
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+    return s;
+  }
+
+  /* Lets caller pass in their own Socket object. */
+  public void accept(Socket s) {
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+  }
+
+  private native int nativeaccept(Socket s);
+
+  public void close();
+
+}
diff --git a/Robust/src/ClassLibrary/FastCheck/Socket.java b/Robust/src/ClassLibrary/FastCheck/Socket.java
new file mode 100644 (file)
index 0000000..506c327
--- /dev/null
@@ -0,0 +1,71 @@
+public class Socket {
+  /* Data pending flag */
+  external flag IOPending;
+  /* File Descriptor */
+  int fd;
+  private SocketInputStream sin;
+  private SocketOutputStream sout;
+
+  public Socket() {
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+  public InputStream getInputStream() {
+    return sin;
+  }
+
+  public OutputStream getOutputStream() {
+    return sout;
+  }
+
+  public Socket(String host, int port) {
+    InetAddress address=InetAddress.getByName(host);
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public Socket(InetAddress address, int port) {
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public void connect(String host, int port) {
+    InetAddress address=InetAddress.getByName(host);
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public void connect(InetAddress address, int port) {
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public static native int nativeBind(byte[] address, int port);
+
+  public native int nativeConnect(int fd, byte[] address, int port);
+
+  int setFD(int filed) {
+    fd=filed;
+  }
+
+  public int read(byte[] b) {
+    return nativeRead(b);
+  }
+  public void write(byte[] b) {
+    nativeWrite(b, 0, b.length);
+  }
+
+  public void write(byte[] b, int offset, int len) {
+    nativeWrite(b, offset, len);
+  }
+
+  private native void nativeBindFD(int fd);
+  private native int nativeRead(byte[] b);
+  private native void nativeWrite(byte[] b, int offset, int len);
+  private native void nativeClose();
+
+  public void close() {
+    nativeClose();
+  }
+}
diff --git a/Robust/src/ClassLibrary/FastCheck/StartupObject.java b/Robust/src/ClassLibrary/FastCheck/StartupObject.java
new file mode 100644 (file)
index 0000000..541c26f
--- /dev/null
@@ -0,0 +1,5 @@
+public class StartupObject {
+  flag initialstate;
+
+  String [] parameters;
+}
diff --git a/Robust/src/ClassLibrary/FastCheck/TagDescriptor.java b/Robust/src/ClassLibrary/FastCheck/TagDescriptor.java
new file mode 100644 (file)
index 0000000..be067fa
--- /dev/null
@@ -0,0 +1,5 @@
+/** This class is not to be used by the end user.  It's intended for
+ * internal use to keep track of tags. */
+
+private class TagDescriptor {
+}
index 50f305fdd73490a8fef17e7db2836c6c064a92a5..9e0c9b07ef639f5100e7c7d217512c62bed06b8c 100755 (executable)
@@ -286,9 +286,10 @@ if $FASTCHECK
 then
 #fast transactions
 JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/FastCheck"
-fi
+else
 #base bristlecone files
 JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/Bristlecone"
+fi
 else
 if $DSMFLAG
 then