mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-12 21:56:54 +00:00
Flattener: Pull up children of children
This commit is contained in:
parent
17633983b5
commit
43303ae6d3
@ -205,6 +205,13 @@ void Flattener::visit(Class& c) {
|
||||
for (const auto& child : c.children) {
|
||||
accept(child);
|
||||
}
|
||||
|
||||
// Pull in children from flattened children
|
||||
// This may result in duplicates, but that shouldn't be a big deal
|
||||
for (const Class& child : c.children) {
|
||||
c.children.insert(c.children.end(), child.children.begin(),
|
||||
child.children.end());
|
||||
}
|
||||
}
|
||||
|
||||
void Flattener::visit(Container& c) {
|
||||
|
@ -204,7 +204,7 @@ void Printer::print_function(const Function& function) {
|
||||
void Printer::print_child(const Type& child) {
|
||||
depth_++;
|
||||
prefix();
|
||||
out_ << "Child:" << std::endl;
|
||||
out_ << "Child" << std::endl;
|
||||
print(child);
|
||||
depth_--;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ class Class : public Type {
|
||||
std::vector<Parent> parents; // Sorted by offset
|
||||
std::vector<Member> members; // Sorted by offset
|
||||
std::vector<Function> functions;
|
||||
std::vector<std::reference_wrapper<Type>>
|
||||
std::vector<std::reference_wrapper<Class>>
|
||||
children; // Only for dynamic classes
|
||||
|
||||
private:
|
||||
|
@ -625,7 +625,7 @@ TEST(FlattenerTest, Children) {
|
||||
[0] Class: ClassB (size: 4)
|
||||
Member: b (offset: 0)
|
||||
Primitive: int32_t
|
||||
Child:
|
||||
Child
|
||||
[1] Class: ClassA (size: 8)
|
||||
Member: b (offset: 0)
|
||||
Primitive: int32_t
|
||||
@ -665,13 +665,13 @@ TEST(FlattenerTest, ChildrenTwoDeep) {
|
||||
[0] Class: ClassD (size: 4)
|
||||
Member: d (offset: 0)
|
||||
Primitive: int32_t
|
||||
Child:
|
||||
Child
|
||||
[1] Class: ClassB (size: 8)
|
||||
Member: d (offset: 0)
|
||||
Primitive: int32_t
|
||||
Member: b (offset: 4)
|
||||
Primitive: int32_t
|
||||
Child:
|
||||
Child
|
||||
[2] Class: ClassA (size: 16)
|
||||
Member: d (offset: 0)
|
||||
Primitive: int32_t
|
||||
@ -681,6 +681,8 @@ TEST(FlattenerTest, ChildrenTwoDeep) {
|
||||
Primitive: int32_t
|
||||
Member: a (offset: 12)
|
||||
Primitive: int32_t
|
||||
Child
|
||||
[2]
|
||||
)");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user