Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_access.c
| Show First 20 Lines • Show All 6,109 Lines • ▼ Show 20 Lines | char *RNA_path_full_ID_py(Main *bmain, ID *id) | ||||
| if (id_real) { | if (id_real) { | ||||
| id = id_real; | id = id_real; | ||||
| } | } | ||||
| else { | else { | ||||
| path = ""; | path = ""; | ||||
| } | } | ||||
| char id_esc[(sizeof(id->name) - 2) * 2]; | char *lib_filepath = NULL; | ||||
| if (id->lib != NULL) { | |||||
| char lib_filepath_esc[sizeof(id->lib->filepath) * 2]; | |||||
| BLI_str_escape(lib_filepath_esc, id->lib->filepath, sizeof(lib_filepath_esc)); | |||||
| lib_filepath = BLI_sprintfN(", \"%s\"", lib_filepath_esc); | |||||
| } | |||||
| char id_esc[(sizeof(id->name) - 2) * 2]; | |||||
| BLI_str_escape(id_esc, id->name + 2, sizeof(id_esc)); | BLI_str_escape(id_esc, id->name + 2, sizeof(id_esc)); | ||||
| return BLI_sprintfN("bpy.data.%s[\"%s\"]%s%s", | char *path_full = BLI_sprintfN("bpy.data.%s[\"%s\"%s]%s%s", | ||||
| BKE_idtype_idcode_to_name_plural(GS(id->name)), | BKE_idtype_idcode_to_name_plural(GS(id->name)), | ||||
| id_esc, | id_esc, | ||||
| lib_filepath ? lib_filepath : "", | |||||
| path[0] ? "." : "", | path[0] ? "." : "", | ||||
| path); | path); | ||||
| if (lib_filepath) { | |||||
| MEM_freeN(lib_filepath); | |||||
| } | |||||
| return path_full; | |||||
campbellbarton: Memory allocation can be avoided here. | |||||
| } | } | ||||
| /** | /** | ||||
| * Get the ID.struct as a python representation, eg: | * Get the ID.struct as a python representation, eg: | ||||
| * bpy.data.foo["bar"].some_struct | * bpy.data.foo["bar"].some_struct | ||||
| */ | */ | ||||
| char *RNA_path_full_struct_py(Main *bmain, struct PointerRNA *ptr) | char *RNA_path_full_struct_py(Main *bmain, struct PointerRNA *ptr) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 2,088 Lines • Show Last 20 Lines | |||||
Memory allocation can be avoided here.