Slight tweaks to writing byte code to file.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -196,20 +196,23 @@ void AngelScripResolver::CreateScript(const char* name, const char* script) {
|
||||
_builder.AddSectionFromMemory(name, script);
|
||||
}
|
||||
void AngelScripResolver::WriteByteCodeToFile(const char* file, bool stripDebugInfo) {
|
||||
FILE* wFile = fopen(file, "w");
|
||||
FILE* wFile = nullptr;
|
||||
wFile = fopen(file, "wb");
|
||||
AssertNotNull(wFile);
|
||||
auto stream = new FileByteCodeStream(wFile);
|
||||
_mainModule->SaveByteCode(stream, stripDebugInfo);
|
||||
fclose(wFile);
|
||||
Assert(fclose(wFile) == 0);
|
||||
delete stream;
|
||||
}
|
||||
void AngelScripResolver::LoadByteCodeFromFile(
|
||||
const char* file, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
|
||||
FILE* rFile = fopen(file, "r");
|
||||
FILE* rFile = nullptr;
|
||||
rFile = fopen(file, "rb");
|
||||
AssertNotNull(rFile);
|
||||
auto stream = new FileByteCodeStream(rFile);
|
||||
LoadByteCode(stream, types);
|
||||
fclose(rFile);
|
||||
InitializeByteCode(stream, types);
|
||||
Assert(fclose(rFile) == 0);
|
||||
delete stream;
|
||||
//_typeDatabase = types;
|
||||
}
|
||||
uint8_t* AngelScripResolver::WriteByteCodeToMemory(size_t& size, bool stripDebugInfo) {
|
||||
auto stream = new MemoryByteCodeStream();
|
||||
@@ -223,12 +226,14 @@ uint8_t* AngelScripResolver::WriteByteCodeToMemory(size_t& size, bool stripDebug
|
||||
}
|
||||
void AngelScripResolver::LoadByteCodeFromMemory(
|
||||
uint8_t* byte, size_t size, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
|
||||
std::cout << "Loading from RAM" << std::endl;
|
||||
auto stream = new MemoryByteCodeStream(byte, size);
|
||||
LoadByteCode(stream, types);
|
||||
InitializeByteCode(stream, types);
|
||||
delete stream;
|
||||
}
|
||||
void AngelScripResolver::LoadByteCode(asIBinaryStream* stream,
|
||||
void AngelScripResolver::InitializeByteCode(asIBinaryStream* stream,
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
|
||||
std::cout << "Loading byte code" << std::endl;
|
||||
int result = _mainModule->LoadByteCode(stream);
|
||||
Assert(result == asSUCCESS);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
Dictionary<ScriptCategory, Dictionary<ConstString, AngelScriptTypeInfo*>> _typeDatabase;
|
||||
|
||||
void RegisterTypes();
|
||||
void LoadByteCode(asIBinaryStream* stream,
|
||||
void InitializeByteCode(asIBinaryStream* stream,
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types);
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user