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_esc[(sizeof(id->lib->filepath) * 2) + 4]; | ||||
| if (id->lib != NULL) { | |||||
| int ofs = 0; | |||||
| memcpy(lib_filepath_esc, ", \"", 3); | |||||
| ofs += 3; | |||||
| ofs += BLI_str_escape(lib_filepath_esc + ofs, id->lib->filepath, sizeof(lib_filepath_esc)); | |||||
| memcpy(lib_filepath_esc + ofs, "\"", 2); | |||||
| } | |||||
| else { | |||||
| lib_filepath_esc[0] = '\0'; | |||||
| } | |||||
| 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", | return 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_esc, | |||||
| path[0] ? "." : "", | path[0] ? "." : "", | ||||
| path); | path); | ||||
| } | } | ||||
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) | ||||
| { | { | ||||
| char *id_path; | char *id_path; | ||||
| ▲ Show 20 Lines • Show All 2,087 Lines • Show Last 20 Lines | |||||
Memory allocation can be avoided here.