Core: lib_query: Replace raw function pointer by FunctionRef for callback.
Besides using modern code, this also allows to use 'capturing' lambdas as callbacks here.
This commit is contained in:
@@ -143,7 +143,7 @@ struct LibraryIDLinkCallbackData {
|
||||
*
|
||||
* \return a set of flags to control further iteration (0 to keep going).
|
||||
*/
|
||||
using LibraryIDLinkCallback = int (*)(LibraryIDLinkCallbackData *cb_data);
|
||||
using LibraryIDLinkCallback = int(LibraryIDLinkCallbackData *cb_data);
|
||||
|
||||
/* Flags for the foreach function itself. */
|
||||
enum {
|
||||
@@ -271,8 +271,11 @@ void BKE_lib_query_idpropertiesForeachIDLink_callback(IDProperty *id_prop, void
|
||||
/**
|
||||
* Loop over all of the ID's this data-block links to.
|
||||
*/
|
||||
void BKE_library_foreach_ID_link(
|
||||
Main *bmain, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag);
|
||||
void BKE_library_foreach_ID_link(Main *bmain,
|
||||
ID *id,
|
||||
blender::FunctionRef<LibraryIDLinkCallback> callback,
|
||||
void *user_data,
|
||||
int flag);
|
||||
/**
|
||||
* Re-usable function, use when replacing ID's.
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,7 @@ struct LibraryForeachIDData {
|
||||
|
||||
/* Function to call for every ID pointers of current processed data, and its opaque user data
|
||||
* pointer. */
|
||||
LibraryIDLinkCallback callback;
|
||||
blender::FunctionRef<LibraryIDLinkCallback> callback;
|
||||
void *user_data;
|
||||
/** Store the returned value from the callback, to decide how to continue the processing of ID
|
||||
* pointers for current data. */
|
||||
@@ -132,7 +132,7 @@ int BKE_lib_query_foreachid_process_callback_flag_override(LibraryForeachIDData
|
||||
static bool library_foreach_ID_link(Main *bmain,
|
||||
ID *owner_id,
|
||||
ID *id,
|
||||
LibraryIDLinkCallback callback,
|
||||
blender::FunctionRef<LibraryIDLinkCallback> callback,
|
||||
void *user_data,
|
||||
int flag,
|
||||
LibraryForeachIDData *inherit_data);
|
||||
@@ -198,7 +198,7 @@ static void library_foreach_ID_data_cleanup(LibraryForeachIDData *data)
|
||||
static bool library_foreach_ID_link(Main *bmain,
|
||||
ID *owner_id,
|
||||
ID *id,
|
||||
LibraryIDLinkCallback callback,
|
||||
blender::FunctionRef<LibraryIDLinkCallback> callback,
|
||||
void *user_data,
|
||||
int flag,
|
||||
LibraryForeachIDData *inherit_data)
|
||||
@@ -379,8 +379,11 @@ static bool library_foreach_ID_link(Main *bmain,
|
||||
#undef CALLBACK_INVOKE
|
||||
}
|
||||
|
||||
void BKE_library_foreach_ID_link(
|
||||
Main *bmain, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
|
||||
void BKE_library_foreach_ID_link(Main *bmain,
|
||||
ID *id,
|
||||
blender::FunctionRef<LibraryIDLinkCallback> callback,
|
||||
void *user_data,
|
||||
int flag)
|
||||
{
|
||||
library_foreach_ID_link(bmain, nullptr, id, callback, user_data, flag, nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user