DVX_GUI/apps/dvxbasic/runtime/serialize.h

41 lines
1.5 KiB
C

// serialize.h -- DVX BASIC module serialization
//
// Serialize/deserialize a compiled BasModuleT to/from a byte buffer.
// Used by "Make Executable" (serialize) and the standalone stub
// (deserialize). The format is a flat binary with no alignment padding.
#ifndef DVXBASIC_SERIALIZE_H
#define DVXBASIC_SERIALIZE_H
#include "vm.h"
#include <stdint.h>
// ============================================================
// Module serialization
// ============================================================
// Serialize a compiled module to a malloc'd byte buffer.
// Returns the buffer (caller frees) and sets *outLen to the size.
// Returns NULL on failure.
uint8_t *basModuleSerialize(const BasModuleT *mod, int32_t *outLen);
// Deserialize a module from a byte buffer.
// Returns a malloc'd BasModuleT (caller frees with basModuleFree).
// Returns NULL on failure.
BasModuleT *basModuleDeserialize(const uint8_t *data, int32_t dataLen);
// Free a deserialized module and all its allocated members.
void basModuleFree(BasModuleT *mod);
// ============================================================
// Debug info serialization (separate resource)
// ============================================================
// Serialize debug info (debugVars + formVarInfo) to a malloc'd buffer.
uint8_t *basDebugSerialize(const BasModuleT *mod, int32_t *outLen);
// Deserialize debug info and attach to an existing module.
void basDebugDeserialize(BasModuleT *mod, const uint8_t *data, int32_t dataLen);
#endif // DVXBASIC_SERIALIZE_H