diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2024-11-10 02:18:28 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-10 05:18:28 -0500 |
| commit | aec7c1df12ab40607e02bf67363fe59d3c1643a6 (patch) | |
| tree | 0c21399679a25226fb483fc63286e6e317ac0af2 /include/JSystem | |
| parent | d9201174e34d7a26199482546705b9ca16765dfd (diff) | |
d_demo mostly matched (#2242)
Diffstat (limited to 'include/JSystem')
| -rw-r--r-- | include/JSystem/JGadget/binary.h | 34 | ||||
| -rw-r--r-- | include/JSystem/JStudio/JStudio/stb.h | 25 |
2 files changed, 54 insertions, 5 deletions
diff --git a/include/JSystem/JGadget/binary.h b/include/JSystem/JGadget/binary.h index 89df9d4745..95ee063576 100644 --- a/include/JSystem/JGadget/binary.h +++ b/include/JSystem/JGadget/binary.h @@ -90,8 +90,26 @@ struct TValueIterator { mBegin = begin; } + const void* get() const { return mBegin; } + typename Parser::ParseType operator*() { - return *(typename Parser::ParseType*)mBegin; + return *(typename Parser::ParseType*)get(); + } + + TValueIterator& operator++() { + const_cast<u32*>(mBegin)++; + return *this; + } + + const TValueIterator operator++(int) { + TValueIterator old(*this); + ++(*this); + return old; + } + + TValueIterator& operator+=(s32 v) { + const_cast<u32*>(mBegin) += v; + return *this; } const void* mBegin; @@ -102,6 +120,20 @@ struct TValueIterator_raw : public TValueIterator<TParseValue_raw_<u8>, 1> { TValueIterator_raw(const void* begin) : TValueIterator<TParseValue_raw_<u8>, 1>(begin) {} }; +template <typename T> +struct TParseValue_misaligned : TParseValue_raw_<T> { + static T parse(const void* data) { return TParseValue_raw_::parse(data); } +}; + +template<typename T> +struct TValueIterator_misaligned : public TValueIterator<TParseValue_misaligned<T>, sizeof(T)> { + TValueIterator_misaligned(const TValueIterator_misaligned<T>& other) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(other) {} + TValueIterator_misaligned(const void* begin) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(begin) {} +}; + + +inline bool operator==(TValueIterator<TParseValue_misaligned<u32>, 4> a, TValueIterator<TParseValue_misaligned<u32>, 4> b) { return a.mBegin == b.mBegin; } + } // namespace binary } // namespace JGadget diff --git a/include/JSystem/JStudio/JStudio/stb.h b/include/JSystem/JStudio/JStudio/stb.h index a4ee1a7e76..4315abd82f 100644 --- a/include/JSystem/JStudio/JStudio/stb.h +++ b/include/JSystem/JStudio/JStudio/stb.h @@ -172,16 +172,20 @@ struct TParseData : public data::TParse_TParagraph_data::TData { } bool isEnd() const { - return _0 == 0; + return status == 0; } bool empty() const { - return _c == NULL; + return fileCount == NULL; } bool isValid() const { - return !empty() && _0 == 50; + return !empty() && status == 50; } + + const void* getContent() const { return fileCount; } + + u32 size() const { return dataSize; } }; template <int T, class Iterator=JGadget::binary::TValueIterator_raw<u8> > @@ -190,7 +194,7 @@ struct TParseData_fixed : public TParseData<T> { TParseData_fixed() : TParseData<T>() {} const void* getNext() const { - return fileCount; + return _10; } bool isValid() const { @@ -200,6 +204,19 @@ struct TParseData_fixed : public TParseData<T> { Iterator begin() { return Iterator(fileCount); } + + Iterator end() { + Iterator i(fileCount); + i += size(); + return i; + } +}; + +struct TParseData_string : public TParseData<0x60> { + TParseData_string(const void* pContent) : TParseData<0x60>(pContent) {} + TParseData_string() : TParseData<0x60>() {} + + const char* getData() const { return (const char*)getContent(); } }; } // namespace stb |
