summaryrefslogtreecommitdiff
path: root/binaryview.cpp
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2025-06-16 17:20:26 -0400
committerBrian Potchik <brian@vector35.com>2025-06-16 17:20:26 -0400
commit5cab99afa06eb32265fee4798cbfc83bd6a8ae4d (patch)
treea641c9e2f86c29aa78dc50598477cc861e22df6e /binaryview.cpp
parent979515fb42365fbe6f000086ef13c125150f36c3 (diff)
Update SymbolQueue API to support types with confidence.
Diffstat (limited to 'binaryview.cpp')
-rw-r--r--binaryview.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/binaryview.cpp b/binaryview.cpp
index 310396c0..d8477826 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -29,12 +29,12 @@ using namespace std;
struct SymbolQueueResolveContext
{
- std::function<std::pair<Ref<Symbol>, Ref<Type>>()> resolve;
+ std::function<std::pair<Ref<Symbol>, Confidence<Ref<Type>>>()> resolve;
};
struct SymbolQueueAddContext
{
- std::function<void(Symbol*, Type*)> add;
+ std::function<void(Symbol*, const Confidence<Ref<Type>>&)> add;
};
@@ -3130,10 +3130,11 @@ void BinaryView::DefineAutoSymbol(Ref<Symbol> sym)
}
-Ref<Symbol> BinaryView::DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, Ref<Type> type)
+Ref<Symbol> BinaryView::DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, const Confidence<Ref<Type>>& type)
{
+ BNTypeWithConfidence apiType = {type.GetValue() ? type.GetValue()->GetObject() : nullptr, type.GetConfidence()};
BNSymbol* result = BNDefineAutoSymbolAndVariableOrFunction(
- m_object, platform ? platform->GetObject() : nullptr, sym->GetObject(), type ? type->GetObject() : nullptr);
+ m_object, platform ? platform->GetObject() : nullptr, sym->GetObject(), &apiType);
if (!result)
return nullptr;
return new Symbol(result);
@@ -5694,28 +5695,29 @@ SymbolQueue::~SymbolQueue()
}
-void SymbolQueue::ResolveCallback(void* ctxt, BNSymbol** symbol, BNType** type)
+void SymbolQueue::ResolveCallback(void* ctxt, BNSymbol** symbol, BNTypeWithConfidence* type)
{
SymbolQueueResolveContext* resolve = (SymbolQueueResolveContext*)ctxt;
auto result = resolve->resolve();
delete resolve;
*symbol = result.first ? BNNewSymbolReference(result.first->GetObject()) : nullptr;
- *type = result.second ? BNNewTypeReference(result.second->GetObject()) : nullptr;
+ type->type = result.second.GetValue() ? BNNewTypeReference(result.second.GetValue()->GetObject()) : nullptr;
+ type->confidence = result.second.GetConfidence();
}
-void SymbolQueue::AddCallback(void* ctxt, BNSymbol* symbol, BNType* type)
+void SymbolQueue::AddCallback(void* ctxt, BNSymbol* symbol, BNTypeWithConfidence* type)
{
SymbolQueueAddContext* add = (SymbolQueueAddContext*)ctxt;
Ref<Symbol> apiSymbol = new Symbol(symbol);
- Ref<Type> apiType = new Type(type);
+ Confidence<Ref<Type>> apiType(type->type ? new Type(type->type) : nullptr, type->confidence);
add->add(apiSymbol, apiType);
delete add;
}
void SymbolQueue::Append(
- const std::function<std::pair<Ref<Symbol>, Ref<Type>>()>& resolve, const std::function<void(Symbol*, Type*)>& add)
+ const std::function<std::pair<Ref<Symbol>, Confidence<Ref<Type>>>()>& resolve, const std::function<void(Symbol*, const Confidence<Ref<Type>>&)>& add)
{
SymbolQueueResolveContext* resolveCtxt = new SymbolQueueResolveContext {resolve};
SymbolQueueAddContext* addCtxt = new SymbolQueueAddContext {add};