Magma object serializer

Chris Muller asqueaker at gmail.com
Thu Jun 9 20:43:51 UTC 2011


> Ok. So if aStream is a fileStream for example, then the following two
> methods are correct:
>
>>> serialize: anObject on: aStream
> ....
> and
>
>>> materializeFrom: aStream
>
>     | size classDefinitionsByteArray graphBufferByteArray |
> ...
>
> is correct?

Hmm, well, that might work, but you should just use the helper methods
that are already provided for this, and which essentially do exactly
the same thing.

To serialize an object to a file, you may use
MaObjectSerializer>>#fileOut:toFileNamed:in:, which calls
MaObjectSerializer>>#object:toStream: (operates on any binary
WriteStream).

For materialization, use MaObjectSerializer class>>#fileIn:, which
calls MaObjectSerializer class>>#objectFromStream: (operates on any
binary ReadStream).  BTW, I just noticed these two methods are
incorrectly categorized under 'debugging', they should be under their
own category called 'file' or something..

These are just convenience methods for saving / loading users work to
a single file.  If you would need to load multiple files where
performance is concerned, you would want to try to instantiate only
one serializer and use it for all of them.

 - Chris


More information about the Magma mailing list