diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-02-03 21:45:09 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-02-10 20:11:05 -0500 |
| commit | ece59d9114f566a0f364cf8c56d555b70952f70b (patch) | |
| tree | fa8703614af89adea1cfca26fe9a3cc13c4e1994 /type.cpp | |
| parent | babc57fefb70199ef388cab6d0feca95cc43307f (diff) | |
Move TypeView::getLinesForType into core as Type::GetLines
Diffstat (limited to 'type.cpp')
| -rw-r--r-- | type.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -419,6 +419,20 @@ NameSpace NameSpace::FromAPIObject(const BNNameSpace* name) } +TypeDefinitionLine TypeDefinitionLine::FromAPIObject(BNTypeDefinitionLine* line) +{ + TypeDefinitionLine result; + result.lineType = line->lineType; + result.tokens = InstructionTextToken::ConvertInstructionTextTokenList(line->tokens, line->count); + result.type = new Type(BNNewTypeReference(line->type)); + result.rootType = new Type(BNNewTypeReference(line->rootType)); + result.rootTypeName = line->rootTypeName; + result.offset = line->offset; + result.fieldIndex = line->fieldIndex; + return result; +} + + Type::Type(BNType* type) { m_object = type; @@ -989,6 +1003,32 @@ bool Type::AddTypeMemberTokens(BinaryView* data, vector<InstructionTextToken>& t } +std::vector<TypeDefinitionLine> Type::GetLines(Ref<BinaryView> data, const std::string& name, + int lineWidth, bool collapsed) +{ + size_t count; + BNTypeDefinitionLine* list = + BNGetTypeLines(m_object, data->m_object, name.c_str(), lineWidth, collapsed, &count); + + std::vector<TypeDefinitionLine> results; + for (size_t i = 0; i < count; i++) + { + TypeDefinitionLine line; + line.lineType = list[i].lineType; + line.tokens = InstructionTextToken::ConvertInstructionTextTokenList(list[i].tokens, list[i].count); + line.type = new Type(BNNewTypeReference(list[i].type)); + line.rootType = list[i].rootType ? new Type(BNNewTypeReference(list[i].rootType)) : nullptr; + line.rootTypeName = list[i].rootTypeName; + line.offset = list[i].offset; + line.fieldIndex = list[i].fieldIndex; + results.push_back(line); + } + + BNFreeTypeDefinitionLineList(list, count); + return results; +} + + string Type::GetSizeSuffix(size_t size) { char sizeStr[32]; |
