diff options
| author | kat <kat@vector35.com> | 2024-02-10 14:59:50 -0500 |
|---|---|---|
| committer | kat <kat@vector35.com> | 2024-02-10 15:20:37 -0500 |
| commit | ddce31c8d62c7ce0a385e5af65b0134c56e3b6c8 (patch) | |
| tree | 9dfa07ca14f62806bdb97d8c31866b023aa1a9a2 /function.cpp | |
| parent | 5454781534812279765047823519504338550434 (diff) | |
Use TypeID for serializing enum types, replace set_int_enum_display_typeid with set_int_display_type, add get_int_display_type_and_typeid, bump ABI
Diffstat (limited to 'function.cpp')
| -rw-r--r-- | function.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/function.cpp b/function.cpp index 601df3aa..27a91952 100644 --- a/function.cpp +++ b/function.cpp @@ -1865,26 +1865,37 @@ BNIntegerDisplayType Function::GetIntegerConstantDisplayType( void Function::SetIntegerConstantDisplayType( - Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type) + Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type, Ref<Type> enumType) { - BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type); + if (enumType) + BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type, enumType->GetRegisteredName()->GetTypeId().c_str()); + else + BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type, nullptr); } Ref<Type> Function::GetIntegerConstantDisplayTypeEnumType( Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand) { - BNType* apiType = BNGetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand); + char* apiType = BNGetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand); + std::string apiTypeStr = std::string(apiType); if (apiType) - return new Type(apiType); - return nullptr; + BNFreeString(apiType); + Ref<Type> type = GetView()->GetTypeById(apiTypeStr); + return type; } -void Function::SetIntegerConstantDisplayTypeEnumType( - Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, Ref<Type> type) +std::pair<BNIntegerDisplayType, Ref<Type>> Function::GetIntegerConstantDisplayTypeAndEnumType(Architecture* arch, + uint64_t instrAddr, uint64_t value, size_t operand) { - BNSetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand, type->m_object); + auto displayType = BNGetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand); + char* apiType = BNGetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand); + std::string apiTypeStr = std::string(apiType); + if (apiType) + BNFreeString(apiType); + Ref<Type> type = GetView()->GetTypeById(apiTypeStr); + return {displayType, type}; } |
