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. |
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 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. |
Yes, I think there was recent discussion about inconsistent stream behavior with regard to #contents. This also works: myObject := MethodReference asClassDefinition. ba := ((ReferenceStream on: ByteArray new writeStream asBinaryOrTextStream) nextPut: myObject ; yourself) contents. (ReferenceStream on: ba readStream) next So the serializer is ok, the issue relates only to stream positioning. Dave On Sat, Sep 07, 2013 at 02:07:41PM -0400, Bob Arning wrote: > 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 > > 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. > > > > > > |
In reply to this post by Chris Muller-3
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. |
Free forum by Nabble | Edit this page |