Skip to content

Commit 0ae0416

Browse files
committed
[[ LCB ]] Add constant formalism for binary module format versioning.
1 parent 56a40e9 commit 0ae0416

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

libscript/src/script-builder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ bool MCScriptEndModule(MCScriptModuleBuilderRef self, MCStreamRef p_stream)
148148
byte_t t_header[4];
149149
t_header[0] = 'L';
150150
t_header[1] = 'C';
151-
t_header[2] = 0;
152-
t_header[3] = 0;
151+
t_header[2] = ((kMCScriptCurrentModuleVersion & 0xFF) >> 0);
152+
t_header[3] = ((kMCScriptCurrentModuleVersion & 0xFF) >> 8);
153153

154154
t_success = MCStreamWrite(p_stream, t_header, 4) &&
155155
MCScriptWriteRawModule(p_stream, &self -> module);

libscript/src/script-module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ bool MCScriptCreateModuleFromStream(MCStreamRef stream, MCScriptModuleRef& r_mod
427427

428428
if (t_header[0] != 'L' ||
429429
t_header[1] != 'C' ||
430-
t_header[2] != 0x00 ||
431-
t_header[3] != 0x00)
430+
t_header[2] != (kMCScriptCurrentModuleVersion & 0xFF) ||
431+
t_header[3] != ((kMCScriptCurrentModuleVersion >> 8) & 0xFF))
432432
return false;
433433

434434
MCScriptModule *t_module;

libscript/src/script-private.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,18 @@ bool MCScriptBytecodeIterate(byte_t*& x_bytecode, byte_t *p_bytecode_limit, MCSc
565565
// byte version[1]
566566
// <pickle of module struct>
567567

568+
// The module version will be incremented for every public release of the libscript
569+
// which occurs in which the module binary format changes.
570+
//
571+
// We will only aim to support module formats which have been released as final and
572+
// stable.
573+
//
574+
// The following constants keep track of, and should be updated to reflect the meaning
575+
// of each module version.
576+
577+
#define kMCScriptModuleVersion_8_0_0_DP_1 0
578+
#define kMCScriptCurrentModuleVersion kMCScriptModuleVersion_8_0_0_DP_1
579+
568580
////////////////////////////////////////////////////////////////////////////////
569581

570582
#endif

0 commit comments

Comments
 (0)