Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-02-06 04:18:38 +0300
committerJulian Eisel <julian@blender.org>2021-02-06 21:27:55 +0300
commitef29ebb31bd4bad47f55f45d6b4a2ab40fe09caf (patch)
tree67736e49c577a9fdfd5f88501bb5b130bd25d2fc /source/blender/editors/asset
parent4cca64f4ad32f3c5509e40f931afdab550ff32d2 (diff)
Code quality: Port recently added asset files to C++
It seems generally preferred to have new files be created with C++. The only reason I didn't do that when I initially created the files is that I was unsure about some C-API aspect. Also includes some minor C++ related cleanup (nullptr instead of NULL, remove redundant `struct` keyword).
Diffstat (limited to 'source/blender/editors/asset')
-rw-r--r--source/blender/editors/asset/CMakeLists.txt4
-rw-r--r--source/blender/editors/asset/asset_edit.cc (renamed from source/blender/editors/asset/asset_edit.c)4
-rw-r--r--source/blender/editors/asset/asset_ops.cc (renamed from source/blender/editors/asset/asset_ops.c)22
3 files changed, 15 insertions, 15 deletions
diff --git a/source/blender/editors/asset/CMakeLists.txt b/source/blender/editors/asset/CMakeLists.txt
index 6cd94783251..8c5f91561b7 100644
--- a/source/blender/editors/asset/CMakeLists.txt
+++ b/source/blender/editors/asset/CMakeLists.txt
@@ -29,8 +29,8 @@ set(INC_SYS
)
set(SRC
- asset_edit.c
- asset_ops.c
+ asset_edit.cc
+ asset_ops.cc
)
set(LIB
diff --git a/source/blender/editors/asset/asset_edit.c b/source/blender/editors/asset/asset_edit.cc
index 3dca87d3a03..7aee467286f 100644
--- a/source/blender/editors/asset/asset_edit.c
+++ b/source/blender/editors/asset/asset_edit.cc
@@ -45,7 +45,7 @@ bool ED_asset_mark_id(const bContext *C, ID *id)
id->asset_data = BKE_asset_metadata_create();
- UI_icon_render_id(C, NULL, id, ICON_SIZE_PREVIEW, true);
+ UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
return true;
}
@@ -65,5 +65,5 @@ bool ED_asset_clear_id(ID *id)
bool ED_asset_can_make_single_from_context(const bContext *C)
{
/* Context needs a "id" pointer to be set for #ASSET_OT_mark()/#ASSET_OT_clear() to use. */
- return CTX_data_pointer_get_type_silent(C, "id", &RNA_ID).data != NULL;
+ return CTX_data_pointer_get_type_silent(C, "id", &RNA_ID).data != nullptr;
}
diff --git a/source/blender/editors/asset/asset_ops.c b/source/blender/editors/asset/asset_ops.cc
index 29c3174f051..6c4ef8923a2 100644
--- a/source/blender/editors/asset/asset_ops.c
+++ b/source/blender/editors/asset/asset_ops.cc
@@ -64,7 +64,8 @@ static ListBase /* CollectionPointerLink */ asset_operation_get_ids_from_context
PointerRNA idptr = CTX_data_pointer_get_type(C, "id", &RNA_ID);
if (idptr.data) {
- CollectionPointerLink *ctx_link = MEM_callocN(sizeof(*ctx_link), __func__);
+ CollectionPointerLink *ctx_link = (CollectionPointerLink *)MEM_callocN(sizeof(*ctx_link),
+ __func__);
ctx_link->ptr = idptr;
BLI_addtail(&list, ctx_link);
}
@@ -84,7 +85,7 @@ static void asset_mark_for_idptr_list(const bContext *C,
LISTBASE_FOREACH (CollectionPointerLink *, ctx_id, ids) {
BLI_assert(RNA_struct_is_ID(ctx_id->ptr.type));
- ID *id = ctx_id->ptr.data;
+ ID *id = (ID *)ctx_id->ptr.data;
if (id->asset_data) {
r_stats->tot_already_asset++;
continue;
@@ -138,8 +139,8 @@ static int asset_mark_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- WM_main_add_notifier(NC_ID | NA_EDITED, NULL);
- WM_main_add_notifier(NC_ASSET | NA_ADDED, NULL);
+ WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
+ WM_main_add_notifier(NC_ASSET | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@@ -166,14 +167,14 @@ struct AssetClearResultStats {
};
static void asset_clear_from_idptr_list(const ListBase /* CollectionPointerLink */ *ids,
- struct AssetClearResultStats *r_stats)
+ AssetClearResultStats *r_stats)
{
memset(r_stats, 0, sizeof(*r_stats));
LISTBASE_FOREACH (CollectionPointerLink *, ctx_id, ids) {
BLI_assert(RNA_struct_is_ID(ctx_id->ptr.type));
- ID *id = ctx_id->ptr.data;
+ ID *id = (ID *)ctx_id->ptr.data;
if (!id->asset_data) {
continue;
}
@@ -185,8 +186,7 @@ static void asset_clear_from_idptr_list(const ListBase /* CollectionPointerLink
}
}
-static bool asset_clear_result_report(const struct AssetClearResultStats *stats,
- ReportList *reports)
+static bool asset_clear_result_report(const AssetClearResultStats *stats, ReportList *reports)
{
if (stats->tot_removed < 1) {
@@ -210,7 +210,7 @@ static int asset_clear_exec(bContext *C, wmOperator *op)
{
ListBase ids = asset_operation_get_ids_from_context(C);
- struct AssetClearResultStats stats;
+ AssetClearResultStats stats;
asset_clear_from_idptr_list(&ids, &stats);
BLI_freelistN(&ids);
@@ -218,8 +218,8 @@ static int asset_clear_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- WM_main_add_notifier(NC_ID | NA_EDITED, NULL);
- WM_main_add_notifier(NC_ASSET | NA_REMOVED, NULL);
+ WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
+ WM_main_add_notifier(NC_ASSET | NA_REMOVED, nullptr);
return OPERATOR_FINISHED;
}