[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:39:38 UTC 2013
or, with a little less arcane stuff:
| myObject rs |
myObject := MethodReference asClassDefinition.
rs _ ReferenceStream on: (RWBinaryOrTextStream on: ByteArray new).
rs nextPut: myObject.
(ReferenceStream on: (ReadStream on: rs contents)) next
Cheers,
Bob
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/5feebe8d/attachment.htm
More information about the Squeak-dev
mailing list
|