[squeak-dev] Beginner's question: How to serialize/materialize an object to/from a ByteArray?

Bob Arning arning315 at comcast.net
Sat Sep 7 18:07:41 UTC 2013

Well, this seems to work:

| ba myObject rs |
myObject := MethodReference asClassDefinition.
rs _ ReferenceStream on: (MultiByteBinaryOrTextStream on: ByteArray new).
rs nextPut: myObject.
ba :=  rs reset; contents.
(ReferenceStream on: (MultiByteBinaryOrTextStream with: ba) reset) next


On 9/7/13 1:33 PM, Chris Muller wrote:
> I just noticed 'browse class versions' is still not working with the
> new-and-improved SqueakSource prototype because maybe there's a bug
> with serializing an object to/from a ByteArray with Squeak?
> I had wanted to use MultiByteBinaryOrTextStream to serialize to a
> ByteArray, but when I try this:
> | ba myObject |
> myObject := MethodReference asClassDefinition.
> ba :=  ((ReferenceStream on: (MultiByteBinaryOrTextStream on: ByteArray new))
>       nextPut: myObject ;
>       yourself) contents.
> (ReferenceStream on: (MultiByteBinaryOrTextStream on: ba)) next
> Produces an error:  'The file did not exist in this directory'.   Huh?
>   What file?  What directory?
> I've only ever used my own serializer since about 2004, which I think
> is much better but obviously for in-image stuff I have to use
> ReferenceStream.
> Any help would be greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130907/0f85e8f7/attachment.htm

More information about the Squeak-dev mailing list