minid.serialization

This module contains functions for serializing and deserializing compiled MiniD functions and modules.

License:
Copyright (c) 2008 Jarrett Billingsley


This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

void serializeModule (MDThread* t, int idx, IWriter s);
Serializes the function object at the given index into the provided writer as a module. Serializing a function as a module outputs the platform-dependent MiniD module header before outputting the function, so that upon subsequent loads of the module, the platform can be correctly detected.

Params:
int idx The stack index of the function object to serialize. The function must be a script function with no upvalues.
IWriter s The writer object to be used to serialize the function.

int deserializeModule (MDThread* t, IReader s);
Inverse of the above, which means it expects for there to be a module header at the beginning of the stream. If the module header of the stream does not match the module header for the platform that is loading the module, the load will fail. A closure of the deserialized function is created with the current environment as its environment and is pushed onto the given thread's stack.

Params:
IReader s The reader object that holds the data stream from which the function will be deserialized.

void serializeFunction (MDThread* t, int idx, IWriter s);
Same as serializeModule but does not output the module header.

int deserializeFunction (MDThread* t, IReader s);
Same as deserializeModule but does not expect for there to be a module header.

Page was generated with on Thu Jul 16 22:47:50 2009