Skip to content

Commit 4355930

Browse files
committed
Add typedef for ProgressFunction and add DefaultProgressFunction
1 parent 3432a4e commit 4355930

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

binaryninjaapi.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,21 @@ map<string, uint64_t> BinaryNinja::GetMemoryUsageInfo()
383383
}
384384

385385

386-
std::function<bool(size_t, size_t)> BinaryNinja::SplitProgress(
387-
std::function<bool(size_t, size_t)> originalFn, size_t subpart, size_t subpartCount)
386+
bool BinaryNinja::DefaultProgressFunction(size_t, size_t)
387+
{
388+
return true;
389+
}
390+
391+
392+
BinaryNinja::ProgressFunction BinaryNinja::SplitProgress(
393+
BinaryNinja::ProgressFunction originalFn, size_t subpart, size_t subpartCount)
388394
{
389395
return SplitProgress(originalFn, subpart, std::vector<double>(subpartCount, 1.0 / (double)subpartCount));
390396
}
391397

392398

393-
std::function<bool(size_t, size_t)> BinaryNinja::SplitProgress(
394-
std::function<bool(size_t, size_t)> originalFn, size_t subpart, std::vector<double> subpartWeights)
399+
BinaryNinja::ProgressFunction BinaryNinja::SplitProgress(
400+
BinaryNinja::ProgressFunction originalFn, size_t subpart, std::vector<double> subpartWeights)
395401
{
396402
if (!originalFn)
397403
return [](size_t, size_t) {

binaryninjaapi.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,9 @@ namespace BinaryNinja {
20002000
*/
20012001
bool OpenUrl(const std::string& url);
20022002

2003+
typedef std::function<bool(size_t, size_t)> ProgressFunction;
2004+
bool DefaultProgressFunction(size_t, size_t);
2005+
20032006
/*! Run a given task in a background thread, and show an updating progress bar which the user can cancel
20042007

20052008
@threadsafe
@@ -2011,7 +2014,7 @@ namespace BinaryNinja {
20112014
to cancel, and the task should handle this appropriately.
20122015
\return True if not cancelled
20132016
*/
2014-
bool RunProgressDialog(const std::string& title, bool canCancel, std::function<void(std::function<bool(size_t, size_t)> progress)> task);
2017+
bool RunProgressDialog(const std::string& title, bool canCancel, std::function<void(ProgressFunction progress)> task);
20152018

20162019
/*!
20172020
Split a single progress function into equally sized subparts.
@@ -2030,8 +2033,8 @@ namespace BinaryNinja {
20302033
\param subpartCount Total number of subparts
20312034
\return A function that will call originalFn() within a modified progress region
20322035
*/
2033-
std::function<bool(size_t, size_t)> SplitProgress(
2034-
std::function<bool(size_t, size_t)> originalFn, size_t subpart, size_t subpartCount);
2036+
ProgressFunction SplitProgress(
2037+
ProgressFunction originalFn, size_t subpart, size_t subpartCount);
20352038

20362039

20372040
/*!
@@ -2052,8 +2055,8 @@ namespace BinaryNinja {
20522055
\param subpartWeights Weights of subparts, described above
20532056
\return A function that will call originalFn() within a modified progress region
20542057
*/
2055-
std::function<bool(size_t, size_t)> SplitProgress(
2056-
std::function<bool(size_t, size_t)> originalFn, size_t subpart, std::vector<double> subpartWeights);
2058+
ProgressFunction SplitProgress(
2059+
ProgressFunction originalFn, size_t subpart, std::vector<double> subpartWeights);
20572060

20582061
struct ProgressContext
20592062
{

0 commit comments

Comments
 (0)