|
16 | 16 |
|
17 | 17 | #include <assert.h> |
18 | 18 |
|
| 19 | +#include "JavaObject/type/object/types/AnnotationObject.h" |
19 | 20 | #include "JavaObject/type/object/types/EndBlockDataObject.h" |
| 21 | +#include "JavaObject/type/object/types/descriptor/NewClassDescriptorObject.h" |
20 | 22 | #include "JavaObject/type/primitive/PrimitiveTypeCodeParser.h" |
21 | | -#include "JavaObject/type/object/types/AnnotationObject.h" |
| 23 | + |
| 24 | +#include <stack> |
22 | 25 |
|
23 | 26 | namespace javaobject::type::object::parsers { |
24 | 27 | ClassDataParser::ClassDataParser(const std::shared_ptr<object::descriptor::ClassDescriptorInfoObject> &classDescInfo) : m_classDescInfo(classDescInfo) { |
@@ -52,17 +55,32 @@ namespace javaobject::type::object::parsers { |
52 | 55 |
|
53 | 56 | auto primitiveParser = parser.parserStorage().primitiveParser; |
54 | 57 |
|
55 | | - // BUG WORKAROUND, REMOVE AFTER WE FIND THE FIX |
56 | | - // parser.stream().seekRelative(-2); |
57 | | - for (auto &[name, value] : this->m_classDescInfo->fields) { |
58 | | - const auto typeCode = value->primitiveDescriptor->typeCode; |
| 58 | + std::deque<std::shared_ptr<descriptor::ClassDescriptorInfoObject>> tree; |
59 | 59 |
|
60 | | - //todo check this out since I can't easily see whats going on when using codewithme |
61 | | - std::shared_ptr<primitive::types::IPrimitiveObject> obj = primitiveParser->readUsingParser(*primitiveParser->getParser(typeCode)); |
| 60 | + std::shared_ptr<IObject> super = this->m_classDescInfo; |
| 61 | + while (typeid(*super) != typeid(NullObject)) { |
| 62 | + auto sp = std::static_pointer_cast<descriptor::ClassDescriptorInfoObject>(super); |
| 63 | + tree.push_front(sp); |
| 64 | + |
| 65 | + auto nsp = std::dynamic_pointer_cast<descriptor::NewClassDescriptorObject>(sp->superClassDescriptor); |
| 66 | + if (nsp == nullptr) { |
| 67 | + break; |
| 68 | + } |
62 | 69 |
|
63 | | - d->values.emplace(name, obj); |
| 70 | + super = nsp->info; |
64 | 71 | } |
65 | 72 |
|
| 73 | + std::ranges::for_each(tree, [primitiveParser, &d](const std::shared_ptr<descriptor::ClassDescriptorInfoObject> &c) { |
| 74 | + for (auto &[name, value] : c->fields) { |
| 75 | + const auto typeCode = value->primitiveDescriptor->typeCode; |
| 76 | + |
| 77 | + //todo check this out since I can't easily see whats going on when using codewithme |
| 78 | + std::shared_ptr<primitive::types::IPrimitiveObject> obj = primitiveParser->readUsingParser(*primitiveParser->getParser(typeCode)); |
| 79 | + |
| 80 | + d->values.emplace(name, obj); |
| 81 | + } |
| 82 | + }); |
| 83 | + |
66 | 84 | return d; |
67 | 85 | } |
68 | 86 |
|
|
0 commit comments