Deserializer

class Deserializer(input: InputStream, runtime: AvailRuntime, lookupPumpedObject: (Int) -> A_BasicObject = { throw Exception("Deserializer has no pumped objects.") }) : AbstractDeserializer

A Deserializer takes a stream of bytes and reconstructs objects that had been previously serialized with a Serializer.

Author

Mark van Gulik

Parameters

input

An InputStream from which to reconstruct objects.

runtime

The AvailRuntime from which to locate well-known objects during deserialization.

lookupPumpedObject

A function that maps from negative integers to objects that this deserializer has been primed with. This is the inverse function of Serializer.lookupPumpedObject.

Constructors

Link copied to clipboard
constructor(input: InputStream, runtime: AvailRuntime, lookupPumpedObject: (Int) -> A_BasicObject = { throw Exception("Deserializer has no pumped objects.") })

Construct a new Deserializer.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The current module.

Link copied to clipboard

The A_Modules that were already loaded in the runtime during instance creation.

Functions

Link copied to clipboard

Deserialize an object from the input and return it. If there are no more objects in the input then answer null. If the stream is malformed throw a MalformedSerialStreamException.

Link copied to clipboard
fun readByte(): Int

Consume an unsigned byte from the input. Return it as an Int to ensure it's unsigned, i.e., 0 ≤ b ≤ 255.

Link copied to clipboard
fun readInt(): Int

Consume an int from the input in big endian order.

Link copied to clipboard
fun readShort(): Int

Consume an unsigned short from the input in big endian order. Return it as an Int to ensure it's unsigned, i.e., 0 ≤ b ≤ 65535.

Link copied to clipboard

Answer a tuple containing the sequence of objects that have been deserialized by this Deserializer. This is the same sequence of objects that the Serializer generated.