mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Yaml: Finish ByamlWriterHash (#829)
This commit is contained in:
parent
f0219686df
commit
fa8af06a5c
|
|
@ -287385,7 +287385,7 @@ Library/Yaml/ByamlWriter.o:
|
|||
- offset: 0xa319ac
|
||||
size: 120
|
||||
label: _ZN2al15ByamlWriterHash10deleteDataEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0xa31a24
|
||||
size: 16
|
||||
label: _ZNK2al15ByamlWriterHash12calcPackSizeEv
|
||||
|
|
@ -287393,7 +287393,7 @@ Library/Yaml/ByamlWriter.o:
|
|||
- offset: 0xa31a34
|
||||
size: 188
|
||||
label: _ZN2al15ByamlWriterHash7addDataEPKcPNS_15ByamlWriterDataE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0xa31af0
|
||||
size: 92
|
||||
label: _ZN2al15ByamlWriterHash7addBoolEPKcb
|
||||
|
|
@ -287445,7 +287445,7 @@ Library/Yaml/ByamlWriter.o:
|
|||
- offset: 0xa31ea0
|
||||
size: 172
|
||||
label: _ZNK2al15ByamlWriterHash14writeContainerEPN4sead11WriteStreamE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0xa31f4c
|
||||
size: 16
|
||||
label: _ZNK2al15ByamlWriterHash5writeEPN4sead11WriteStreamE
|
||||
|
|
@ -287453,7 +287453,7 @@ Library/Yaml/ByamlWriter.o:
|
|||
- offset: 0xa31f5c
|
||||
size: 88
|
||||
label: _ZNK2al15ByamlWriterHash5printEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0xa31fb4
|
||||
size: 40
|
||||
label:
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ u8 ByamlWriterArray::getTypeCode() const {
|
|||
}
|
||||
|
||||
void ByamlWriterArray::writeContainer(sead::WriteStream* stream) const {
|
||||
stream->writeU8(0xC0);
|
||||
stream->writeU8(ByamlWriterArray::getTypeCode());
|
||||
alByamlLocalUtil::writeU24(stream, mList.size());
|
||||
|
||||
for (auto& node : mList)
|
||||
|
|
@ -233,7 +233,7 @@ void ByamlWriterArray::print(s32 recursionDepth) const {
|
|||
}
|
||||
|
||||
ByamlWriterHashPair::ByamlWriterHashPair(const char* key, ByamlWriterData* value)
|
||||
: mKey(key), mValue(value) {}
|
||||
: sead::TListNode<ByamlWriterHashPair*>(this), mKey(key), mValue(value) {}
|
||||
|
||||
ByamlWriterHash::ByamlWriterHash(ByamlWriterStringTable* stringTable1,
|
||||
ByamlWriterStringTable* stringTable2)
|
||||
|
|
@ -244,10 +244,32 @@ ByamlWriterHash::~ByamlWriterHash() {
|
|||
delete node;
|
||||
}
|
||||
|
||||
void ByamlWriterHash::deleteData() {
|
||||
for (auto it = mList.robustBegin(); it != mList.robustEnd(); ++it)
|
||||
if (!it->mData->getValue()->isContainer())
|
||||
delete it->mData->getValue();
|
||||
}
|
||||
|
||||
u32 ByamlWriterHash::calcPackSize() const {
|
||||
return mList.size() * 8 + 4;
|
||||
}
|
||||
|
||||
void ByamlWriterHash::addData(const char* key, ByamlWriterData* data) {
|
||||
const char* str = mStringTable1->tryAdd(key);
|
||||
ByamlWriterHashPair* pair = new ByamlWriterHashPair(str, data);
|
||||
|
||||
for (auto it = mList.robustBegin(); it != mList.robustEnd(); ++it) {
|
||||
s32 cmp = strcmp(str, it->mData->getKey());
|
||||
if (cmp == 0)
|
||||
return;
|
||||
if (cmp < 0) {
|
||||
mList.insertBefore(&(*it), pair);
|
||||
return;
|
||||
}
|
||||
}
|
||||
mList.pushBack(pair);
|
||||
}
|
||||
|
||||
void ByamlWriterHash::addBool(const char* key, bool value) {
|
||||
addData(key, new ByamlWriterBool(value));
|
||||
}
|
||||
|
|
@ -293,11 +315,27 @@ void ByamlWriterHash::addNull(const char* key) {
|
|||
}
|
||||
|
||||
u8 ByamlWriterHash::getTypeCode() const {
|
||||
return 0xC1;
|
||||
return 0xc1;
|
||||
}
|
||||
|
||||
void ByamlWriterHash::writeContainer(sead::WriteStream* stream) const {
|
||||
stream->writeU8(ByamlWriterHash::getTypeCode());
|
||||
alByamlLocalUtil::writeU24(stream, mList.size());
|
||||
|
||||
for (auto it = mList.begin(); it != mList.end(); ++it) {
|
||||
alByamlLocalUtil::writeU24(stream, mStringTable1->calcIndex((*it)->getKey()));
|
||||
stream->writeU8((*it)->getValue()->getTypeCode());
|
||||
(*it)->getValue()->write(stream);
|
||||
}
|
||||
}
|
||||
|
||||
void ByamlWriterHash::write(sead::WriteStream* stream) const {
|
||||
stream->writeU32(getOffset());
|
||||
}
|
||||
|
||||
void ByamlWriterHash::print(s32 recursionDepth) const {
|
||||
for (auto it = mList.begin(); it != mList.end(); ++it)
|
||||
(*it)->getValue()->print(recursionDepth + 1);
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ private:
|
|||
|
||||
static_assert(sizeof(ByamlWriterArray) == 0x30);
|
||||
|
||||
class ByamlWriterHashPair : public sead::ListNode {
|
||||
class ByamlWriterHashPair : public sead::TListNode<ByamlWriterHashPair*> {
|
||||
public:
|
||||
ByamlWriterHashPair(const char* key, ByamlWriterData* value);
|
||||
|
||||
|
|
@ -261,8 +261,6 @@ public:
|
|||
ByamlWriterData* getValue() { return mValue; }
|
||||
|
||||
private:
|
||||
void* mSelfReference = this;
|
||||
void* unk = nullptr;
|
||||
const char* mKey;
|
||||
ByamlWriterData* mValue;
|
||||
};
|
||||
|
|
@ -274,10 +272,10 @@ public:
|
|||
ByamlWriterHash(ByamlWriterStringTable* stringTable1, ByamlWriterStringTable* stringTable2);
|
||||
~ByamlWriterHash();
|
||||
|
||||
void deleteData() override; // TODO implementation missing
|
||||
void deleteData() override;
|
||||
u32 calcPackSize() const override;
|
||||
|
||||
void addData(const char*, ByamlWriterData*); // TODO implementation missing
|
||||
void addData(const char* key, ByamlWriterData* data);
|
||||
void addBool(const char* key, bool value) override;
|
||||
void addInt(const char* key, s32 value) override;
|
||||
void addUInt(const char* key, u32 value) override;
|
||||
|
|
@ -291,14 +289,15 @@ public:
|
|||
void addNull(const char* key) override;
|
||||
|
||||
u8 getTypeCode() const override;
|
||||
void writeContainer(sead::WriteStream* stream) const override; // TODO implementation missing
|
||||
void writeContainer(sead::WriteStream* stream) const override;
|
||||
void write(sead::WriteStream* stream) const override;
|
||||
void print(s32 recursionDepth) const override; // TODO implementation missing
|
||||
void print(s32 recursionDepth) const override;
|
||||
|
||||
bool isHash() const override { return true; }
|
||||
|
||||
private:
|
||||
sead::TList<ByamlWriterHashPair> mList; // TODO not really... it's something different here.
|
||||
sead::TList<ByamlWriterHashPair*> mList;
|
||||
// TODO: find better names for these two tables
|
||||
ByamlWriterStringTable* mStringTable1;
|
||||
ByamlWriterStringTable* mStringTable2;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue