Support serializing item use scripts.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
27dd8a8202
commit
7216d9d71b
|
@ -292,7 +292,7 @@ void AngelScriptResolver::WriteByteCodeToFile(const char* file, bool stripDebugI
|
||||||
// We grab the current position of the written file. This is the position the types will be written on. So we need
|
// We grab the current position of the written file. This is the position the types will be written on. So we need
|
||||||
// to know this.
|
// to know this.
|
||||||
uint64_t bytecodeSize = (uint64_t)ftell(wFile);
|
uint64_t bytecodeSize = (uint64_t)ftell(wFile);
|
||||||
stream->WriteTypes(_typeDatabase);
|
stream->WriteTypes(_typeDatabase, _itemUseTypes);
|
||||||
|
|
||||||
// Go back to the start of the file
|
// Go back to the start of the file
|
||||||
fsetpos(wFile, &startPos);
|
fsetpos(wFile, &startPos);
|
||||||
|
@ -334,7 +334,7 @@ uint8_t* AngelScriptResolver::WriteByteCodeToMemory(size_t& size, bool stripDebu
|
||||||
auto result = _mainModule->SaveByteCode(stream, stripDebugInfo);
|
auto result = _mainModule->SaveByteCode(stream, stripDebugInfo);
|
||||||
Ensure(result == asSUCCESS);
|
Ensure(result == asSUCCESS);
|
||||||
byteCodeSize[0] = (uint64_t)stream->GetWrittenSize();
|
byteCodeSize[0] = (uint64_t)stream->GetWrittenSize();
|
||||||
stream->WriteTypes(_typeDatabase);
|
stream->WriteTypes(_typeDatabase, _itemUseTypes);
|
||||||
stream->WriteToPosition(byteCodeSize, sizeof(uint64_t), 0);
|
stream->WriteToPosition(byteCodeSize, sizeof(uint64_t), 0);
|
||||||
auto arr = stream->GetOut();
|
auto arr = stream->GetOut();
|
||||||
size = stream->GetWrittenSize();
|
size = stream->GetWrittenSize();
|
||||||
|
@ -369,6 +369,7 @@ void AngelScriptResolver::InitializeByteCode(
|
||||||
}
|
}
|
||||||
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> typeDatabase;
|
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> typeDatabase;
|
||||||
for (const auto& innerDb : types) {
|
for (const auto& innerDb : types) {
|
||||||
|
if (innerDb.first != (ScriptCategory)-1) {
|
||||||
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*> newInnerDb;
|
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*> newInnerDb;
|
||||||
for (const auto& val : innerDb.second) {
|
for (const auto& val : innerDb.second) {
|
||||||
auto decl = val.second;
|
auto decl = val.second;
|
||||||
|
@ -376,6 +377,13 @@ void AngelScriptResolver::InitializeByteCode(
|
||||||
newInnerDb.Set(val.first, new AngelScriptTypeInfo(val.first, type));
|
newInnerDb.Set(val.first, new AngelScriptTypeInfo(val.first, type));
|
||||||
}
|
}
|
||||||
typeDatabase.Set(innerDb.first, newInnerDb);
|
typeDatabase.Set(innerDb.first, newInnerDb);
|
||||||
|
} else {
|
||||||
|
for (const auto& val : innerDb.second) {
|
||||||
|
auto decl = val.second;
|
||||||
|
auto type = objectTypes[decl];
|
||||||
|
_itemUseTypes[val.first] = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_typeDatabase = typeDatabase;
|
_typeDatabase = typeDatabase;
|
||||||
}
|
}
|
|
@ -14,7 +14,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void WriteTypes(
|
virtual void WriteTypes(
|
||||||
const ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>>& types) {
|
const ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>>& types,
|
||||||
|
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> itemUseTypes) {
|
||||||
// We serialize our types in the format
|
// We serialize our types in the format
|
||||||
// "[category(byte)][name(str)]\2[decl(str)]\2[name(str)]\2[decl(str)]\1[category(byte)]...."
|
// "[category(byte)][name(str)]\2[decl(str)]\2[name(str)]\2[decl(str)]\1[category(byte)]...."
|
||||||
|
|
||||||
|
@ -37,6 +38,22 @@ public:
|
||||||
// Write the divider between categories.
|
// Write the divider between categories.
|
||||||
Write("\1", sizeof(char));
|
Write("\1", sizeof(char));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
categoryArr[0] = (ScriptCategory)-1;
|
||||||
|
Write(categoryArr, sizeof(ScriptCategory));
|
||||||
|
for (const auto& inner : itemUseTypes) {
|
||||||
|
// Write the script name
|
||||||
|
Write(inner.first.c_str(), sizeof(char) * inner.first.Length());
|
||||||
|
// Write the divider
|
||||||
|
Write("\2", sizeof(char));
|
||||||
|
// Write the declaration of the script
|
||||||
|
auto decl = inner.second->GetName();
|
||||||
|
Write(decl, sizeof(char) * strlen(decl));
|
||||||
|
// Write another divider.
|
||||||
|
Write("\2", sizeof(char));
|
||||||
|
}
|
||||||
|
// Write the divider between categories.
|
||||||
|
Write("\1", sizeof(char));
|
||||||
}
|
}
|
||||||
virtual ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, uint32_t>> ReadTypes() {
|
virtual ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, uint32_t>> ReadTypes() {
|
||||||
_angelScriptBound = SIZE_MAX;
|
_angelScriptBound = SIZE_MAX;
|
||||||
|
|
Loading…
Reference in New Issue