From d973cc7992eaef2a342d2a845382f720a6ee7330 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 19 Sep 2023 15:10:47 +0200 Subject: [PATCH] Assets/BPY: Remove unnecessary asset handle related RNA members The asset handle type is supposed to be replaced by the asset representation type. It is designed for the asset system as opposed to the file browser backend. With d421ebac5e, d04cd3f3e6 and f6a6b27ac1, it can now do everything that is needed in Python to be a replacement. 591a1ae323 removed all usages of these members in the asset handle and the file entry wrapped by the asset handle. All this should now be accessed via the `bpy.types.AssetRepresentation` type instead, which is available everywhere the `AssetHandle` type was available before. Part of #102877 and #108806. --- source/blender/makesrna/intern/rna_asset.cc | 44 ------------------ source/blender/makesrna/intern/rna_space.cc | 49 --------------------- 2 files changed, 93 deletions(-) diff --git a/source/blender/makesrna/intern/rna_asset.cc b/source/blender/makesrna/intern/rna_asset.cc index a44bfd85f1d..0e5c18fd208 100644 --- a/source/blender/makesrna/intern/rna_asset.cc +++ b/source/blender/makesrna/intern/rna_asset.cc @@ -367,23 +367,6 @@ static void rna_AssetHandle_file_data_set(PointerRNA *ptr, asset_handle->file_data = static_cast(value.data); } -static void rna_AssetHandle_get_full_library_path( - // AssetHandle *asset, - FileDirEntry *asset_file, - char r_result[/*FILE_MAX_LIBEXTRA*/]) -{ - AssetHandle asset{}; - asset.file_data = asset_file; - ED_asset_handle_get_full_library_path(&asset, r_result); -} - -static PointerRNA rna_AssetHandle_local_id_get(PointerRNA *ptr) -{ - const AssetHandle *asset = static_cast(ptr->data); - ID *id = ED_asset_handle_get_representation(asset)->local_id(); - return rna_pointer_inherit_refine(ptr, &RNA_ID, id); -} - static void rna_AssetRepresentation_name_get(PointerRNA *ptr, char *value) { const AssetRepresentation *asset = static_cast(ptr->data); @@ -597,22 +580,6 @@ static void rna_def_asset_data(BlenderRNA *brna) "data recovery purposes"); } -static void rna_def_asset_handle_api(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *parm; - - func = RNA_def_function(srna, "get_full_library_path", "rna_AssetHandle_get_full_library_path"); - /* TODO temporarily static function, for until .py can receive the asset handle from context - * properly. `asset_file_handle` should go away too then. */ - RNA_def_function_flag(func, FUNC_NO_SELF); - parm = RNA_def_pointer(func, "asset_file_handle", "FileSelectEntry", "", ""); - RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED); - parm = RNA_def_string(func, "result", nullptr, FILE_MAX_LIBEXTRA, "result", ""); - RNA_def_parameter_flags(parm, PROP_THICK_WRAP, ParameterFlag(0)); - RNA_def_function_output(func, parm); -} - static void rna_def_asset_handle(BlenderRNA *brna) { StructRNA *srna; @@ -631,17 +598,6 @@ static void rna_def_asset_handle(BlenderRNA *brna) prop, "rna_AssetHandle_file_data_get", "rna_AssetHandle_file_data_set", nullptr, nullptr); RNA_def_property_ui_text( prop, "File Entry", "TEMPORARY, DO NOT USE - File data used to refer to the asset"); - - prop = RNA_def_property(srna, "local_id", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "ID"); - RNA_def_property_pointer_funcs(prop, "rna_AssetHandle_local_id_get", nullptr, nullptr, nullptr); - RNA_def_property_ui_text(prop, - "", - "The local data-block this asset represents; only valid if that is a " - "data-block in this file"); - RNA_def_property_flag(prop, PROP_HIDDEN); - - rna_def_asset_handle_api(srna); } static void rna_def_asset_representation(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_space.cc b/source/blender/makesrna/intern/rna_space.cc index 1b4a07c6d5b..d95590bc393 100644 --- a/source/blender/makesrna/intern/rna_space.cc +++ b/source/blender/makesrna/intern/rna_space.cc @@ -2838,32 +2838,6 @@ static int rna_FileBrowser_FileSelectEntry_relative_path_length(PointerRNA *ptr) return int(strlen(entry->relpath)); } -static const EnumPropertyItem *rna_FileBrowser_FileSelectEntry_id_type_itemf( - bContext * /*C*/, PointerRNA *ptr, PropertyRNA * /*prop*/, bool * /*r_free*/) -{ - const FileDirEntry *entry = static_cast(ptr->data); - if (entry->blentype == 0) { - static const EnumPropertyItem none_items[] = { - {0, "NONE", 0, "None", ""}, - }; - return none_items; - } - - return rna_enum_id_type_items; -} - -static int rna_FileBrowser_FileSelectEntry_id_type_get(PointerRNA *ptr) -{ - const FileDirEntry *entry = static_cast(ptr->data); - return entry->blentype; -} - -static PointerRNA rna_FileBrowser_FileSelectEntry_local_id_get(PointerRNA *ptr) -{ - const FileDirEntry *entry = static_cast(ptr->data); - return rna_pointer_inherit_refine(ptr, &RNA_ID, entry->id); -} - static int rna_FileBrowser_FileSelectEntry_preview_icon_id_get(PointerRNA *ptr) { const FileDirEntry *entry = static_cast(ptr->data); @@ -6674,29 +6648,6 @@ static void rna_def_fileselect_entry(BlenderRNA *brna) "Browser (includes the file name)"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_enum_id_type_items); - RNA_def_property_enum_funcs(prop, - "rna_FileBrowser_FileSelectEntry_id_type_get", - nullptr, - "rna_FileBrowser_FileSelectEntry_id_type_itemf"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text( - prop, - "Data-block Type", - "The type of the data-block, if the file represents one ('NONE' otherwise)"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); - - prop = RNA_def_property(srna, "local_id", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "ID"); - RNA_def_property_pointer_funcs( - prop, "rna_FileBrowser_FileSelectEntry_local_id_get", nullptr, nullptr, nullptr); - RNA_def_property_ui_text(prop, - "", - "The local data-block this file represents; only valid if that is a " - "data-block in this file"); - RNA_def_property_flag(prop, PROP_HIDDEN); - prop = RNA_def_int( srna, "preview_icon_id",