The following section provides information for these earlier sections:
The example method DdeTimeServer>>flatten: (in the DdeExamples application) converts a Smalltalk object into a ByteArray. The code to do this (using the IBM Smalltalk Swapper) is:
flatten: anObject "Flatten anObject into a ByteArray." | aByteArray size dumper | dumper := ObjectDumper new. size := dumper totalSizeBeforeUnload: anObject. aByteArray := Array with: (ByteArray new: size). dumper unload: anObject intoByteObjects: aByteArray offsetsIntoByteObjects: 0 maximumLimit: size errorStream: Transcript. ^aByteArray at: 1
The example method DdeTimeClient>>unflatten: (in the DdeExamples application) converts a ByteArray object into a Smalltalk object. The code to do this (using the Swapper) is:
unflatten: aByteArray "Answers an object from a ByteArray. Call the Swapper ObjectLoader to rebuild the object." | bytes | bytes := Array with: aByteArray. ^ObjectLoader new loadFromByteObjects: bytes offsetsIntoByteObjects: 0 errorStream: nil.