[armedbear-cvs] r12414 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Tue Feb 2 19:54:40 UTC 2010


Author: ehuelsmann
Date: Tue Feb  2 14:54:37 2010
New Revision: 12414

Log:
Add function to retrieve a lisp byte array from a byte array output stream.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Autoload.java
   trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java
   trunk/abcl/src/org/armedbear/lisp/ByteArrayOutputStream.java   (contents, props changed)

Modified: trunk/abcl/src/org/armedbear/lisp/Autoload.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Autoload.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Autoload.java	Tue Feb  2 14:54:37 2010
@@ -526,6 +526,7 @@
         autoload(PACKAGE_SYS, "%generic-function-lambda-list", "StandardGenericFunction", true);
         autoload(PACKAGE_SYS, "%generic-function-name", "StandardGenericFunction", true);
         autoload(PACKAGE_SYS, "%get-output-stream-bytes", "ByteArrayOutputStream"); //AS 20090325
+        autoload(PACKAGE_SYS, "%get-output-stream-array", "ByteArrayOutputStream");
         autoload(PACKAGE_SYS, "%make-array", "make_array");
         autoload(PACKAGE_SYS, "%make-byte-array-output-stream", "ByteArrayOutputStream"); //AS 20090325
         autoload(PACKAGE_SYS, "%make-condition", "make_condition", true);

Modified: trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java	Tue Feb  2 14:54:37 2010
@@ -48,8 +48,15 @@
     this.capacity = capacity;
   }
 
-  public BasicVector_UnsignedByte8(LispObject[] array)
+  public BasicVector_UnsignedByte8(byte[] array)
+  {
+    capacity = array.length;
+    elements = new byte[capacity];
+    System.arraycopy(array, 0, elements, 0, capacity);
+  }
+
 
+  public BasicVector_UnsignedByte8(LispObject[] array)
   {
     capacity = array.length;
     elements = new byte[capacity];

Modified: trunk/abcl/src/org/armedbear/lisp/ByteArrayOutputStream.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ByteArrayOutputStream.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ByteArrayOutputStream.java	Tue Feb  2 14:54:37 2010
@@ -2,7 +2,7 @@
  * ByteArrayOutputStream.java
  *
  * Copyright (C) 2009 Alessio Stalla
- * $Id: StringOutputStream.java 11434 2008-12-07 23:24:31Z ehuelsmann $
+ * $Id$
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -132,4 +132,19 @@
             return error(new TypeError(this, Symbol.STREAM)); //TODO
         }
     };
+
+    private static final Primitive GET_OUTPUT_STREAM_ARRAY =
+        new Primitive("%get-output-stream-array", PACKAGE_SYS, false,
+                      "byte-array-output-stream")
+    {
+        @Override
+        public LispObject execute(LispObject arg)
+        {
+            if (arg instanceof ByteArrayOutputStream)
+                return new BasicVector_UnsignedByte8(((ByteArrayOutputStream)arg).getByteArray());
+
+            return error(new TypeError(this, Symbol.STREAM)); // TODO
+        }
+    };
+
 }




More information about the armedbear-cvs mailing list