Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/idcode.c
| Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
| const char *BKE_idcode_to_name_plural(int code) | const char *BKE_idcode_to_name_plural(int code) | ||||
| { | { | ||||
| IDType *idt = idtype_from_code(code); | IDType *idt = idtype_from_code(code); | ||||
| BLI_assert(idt); | BLI_assert(idt); | ||||
| return idt ? idt->plural : NULL; | return idt ? idt->plural : NULL; | ||||
| } | } | ||||
| /** | /** | ||||
| * Convert an idcode into an idfilter (e.g. ID_OB -> FILTER_ID_OB). | |||||
| */ | |||||
| int BKE_idcode_to_idfilter(const int idcode) | |||||
sergey: Do we really need separate filter thing? It seems rather 1:1 mapping to ID codes here. | |||||
Not Done Inline ActionsYes we need them, FILTER_ID_XX is bitflag... Mandatory to combine several ID types in a same filter (integer). And we cannot do 1:1 mapping, because we have more than 32 IDs (see comment in DNA_ID.h). :/ mont29: Yes we need them, FILTER_ID_XX is bitflag... Mandatory to combine several ID types in a same… | |||||
| { | |||||
| #define CASE_IDFILTER(_id) case ID_##_id: return FILTER_ID_##_id | |||||
Done Inline Actionssuggest to use macro which expands suffix... one line per case, no chance of typos. eg: CASE_IDFILTER(AC); campbellbarton: suggest to use macro which expands suffix... one line per case, no chance of typos. eg… | |||||
| switch (idcode) { | |||||
| CASE_IDFILTER(AC); | |||||
| CASE_IDFILTER(AR); | |||||
| CASE_IDFILTER(BR); | |||||
| CASE_IDFILTER(CA); | |||||
| CASE_IDFILTER(CU); | |||||
| CASE_IDFILTER(GD); | |||||
| CASE_IDFILTER(GR); | |||||
| CASE_IDFILTER(IM); | |||||
| CASE_IDFILTER(LA); | |||||
| CASE_IDFILTER(LS); | |||||
| CASE_IDFILTER(LT); | |||||
| CASE_IDFILTER(MA); | |||||
| CASE_IDFILTER(MB); | |||||
| CASE_IDFILTER(MC); | |||||
| CASE_IDFILTER(ME); | |||||
| CASE_IDFILTER(MSK); | |||||
| CASE_IDFILTER(NT); | |||||
| CASE_IDFILTER(OB); | |||||
| CASE_IDFILTER(PAL); | |||||
| CASE_IDFILTER(PC); | |||||
| CASE_IDFILTER(SCE); | |||||
| CASE_IDFILTER(SPK); | |||||
| CASE_IDFILTER(SO); | |||||
| CASE_IDFILTER(TE); | |||||
| CASE_IDFILTER(TXT); | |||||
| CASE_IDFILTER(VF); | |||||
| CASE_IDFILTER(WO); | |||||
| default: | |||||
| return 0; | |||||
| } | |||||
| #undef CASE_IDFILTER | |||||
| } | |||||
| /** | |||||
| * Convert an idfilter into an idcode (e.g. FILTER_ID_OB -> ID_OB). | |||||
| */ | |||||
| int BKE_idcode_from_idfilter(const int idfilter) | |||||
| { | |||||
| #define CASE_IDFILTER(_id) case FILTER_ID_##_id: return ID_##_id | |||||
| switch (idfilter) { | |||||
| CASE_IDFILTER(AC); | |||||
| CASE_IDFILTER(AR); | |||||
| CASE_IDFILTER(BR); | |||||
| CASE_IDFILTER(CA); | |||||
| CASE_IDFILTER(CU); | |||||
| CASE_IDFILTER(GD); | |||||
| CASE_IDFILTER(GR); | |||||
| CASE_IDFILTER(IM); | |||||
| CASE_IDFILTER(LA); | |||||
| CASE_IDFILTER(LS); | |||||
| CASE_IDFILTER(LT); | |||||
| CASE_IDFILTER(MA); | |||||
| CASE_IDFILTER(MB); | |||||
| CASE_IDFILTER(MC); | |||||
| CASE_IDFILTER(ME); | |||||
| CASE_IDFILTER(MSK); | |||||
| CASE_IDFILTER(NT); | |||||
| CASE_IDFILTER(OB); | |||||
| CASE_IDFILTER(PAL); | |||||
| CASE_IDFILTER(PC); | |||||
| CASE_IDFILTER(SCE); | |||||
| CASE_IDFILTER(SPK); | |||||
| CASE_IDFILTER(SO); | |||||
| CASE_IDFILTER(TE); | |||||
| CASE_IDFILTER(TXT); | |||||
| CASE_IDFILTER(VF); | |||||
| CASE_IDFILTER(WO); | |||||
| default: | |||||
| return 0; | |||||
| } | |||||
| #undef CASE_IDFILTER | |||||
| } | |||||
| /** | |||||
| * Convert an idcode into its translations' context. | * Convert an idcode into its translations' context. | ||||
| * | * | ||||
| * \param code The code to convert. | * \param code The code to convert. | ||||
| * \return A static string representing the i18n context of the code. | * \return A static string representing the i18n context of the code. | ||||
| */ | */ | ||||
| const char *BKE_idcode_to_translation_context(int code) | const char *BKE_idcode_to_translation_context(int code) | ||||
| { | { | ||||
| IDType *idt = idtype_from_code(code); | IDType *idt = idtype_from_code(code); | ||||
| Show All 14 Lines | |||||
Do we really need separate filter thing? It seems rather 1:1 mapping to ID codes here.