Make ID types typed enum, to easily spot missing ones in core switches of library.c
Note that all deprecated/non-real ID types are kept as defines.
This commit is contained in:
@@ -335,13 +335,11 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
|
||||
if (id->tag & LIB_TAG_INDIRECT)
|
||||
return false;
|
||||
|
||||
switch (GS(id->name)) {
|
||||
switch ((ID_Type)GS(id->name)) {
|
||||
case ID_SCE:
|
||||
/* Partially implemented (has no copy...). */
|
||||
if (!test) BKE_scene_make_local(bmain, (Scene *)id, lib_local);
|
||||
return true;
|
||||
case ID_LI:
|
||||
return false; /* can't be linked */
|
||||
case ID_OB:
|
||||
if (!test) BKE_object_make_local(bmain, (Object *)id, lib_local);
|
||||
return true;
|
||||
@@ -375,15 +373,9 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
|
||||
case ID_SPK:
|
||||
if (!test) BKE_speaker_make_local(bmain, (Speaker *)id, lib_local);
|
||||
return true;
|
||||
case ID_IP:
|
||||
return false; /* deprecated */
|
||||
case ID_KE:
|
||||
return false; /* can't be linked */
|
||||
case ID_WO:
|
||||
if (!test) BKE_world_make_local(bmain, (World *)id, lib_local);
|
||||
return true;
|
||||
case ID_SCR:
|
||||
return false; /* can't be linked */
|
||||
case ID_VF:
|
||||
/* Partially implemented (has no copy...). */
|
||||
if (!test) BKE_vfont_make_local(bmain, (VFont *)id, lib_local);
|
||||
@@ -413,8 +405,6 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
|
||||
case ID_PA:
|
||||
if (!test) BKE_particlesettings_make_local(bmain, (ParticleSettings *)id, lib_local);
|
||||
return true;
|
||||
case ID_WM:
|
||||
return false; /* can't be linked */
|
||||
case ID_GD:
|
||||
if (!test) BKE_gpencil_make_local(bmain, (bGPdata *)id, lib_local);
|
||||
return true;
|
||||
@@ -430,6 +420,15 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
|
||||
case ID_PC:
|
||||
if (!test) BKE_paint_curve_make_local(bmain, (PaintCurve *)id, lib_local);
|
||||
return true;
|
||||
case ID_MC:
|
||||
return false; /* TODO missing implementation */
|
||||
case ID_SCR:
|
||||
case ID_LI:
|
||||
case ID_KE:
|
||||
case ID_WM:
|
||||
return false; /* can't be linked */
|
||||
case ID_IP:
|
||||
return false; /* deprecated */
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -448,11 +447,7 @@ bool id_copy(Main *bmain, ID *id, ID **newid, bool test)
|
||||
/* conventions:
|
||||
* - make shallow copy, only this ID block
|
||||
* - id.us of the new ID is set to 1 */
|
||||
switch (GS(id->name)) {
|
||||
case ID_SCE:
|
||||
return false; /* can't be copied from here */
|
||||
case ID_LI:
|
||||
return false; /* can't be copied from here */
|
||||
switch ((ID_Type)GS(id->name)) {
|
||||
case ID_OB:
|
||||
if (!test) *newid = (ID *)BKE_object_copy(bmain, (Object *)id);
|
||||
return true;
|
||||
@@ -486,23 +481,15 @@ bool id_copy(Main *bmain, ID *id, ID **newid, bool test)
|
||||
case ID_CA:
|
||||
if (!test) *newid = (ID *)BKE_camera_copy(bmain, (Camera *)id);
|
||||
return true;
|
||||
case ID_IP:
|
||||
return false; /* deprecated */
|
||||
case ID_KE:
|
||||
if (!test) *newid = (ID *)BKE_key_copy(bmain, (Key *)id);
|
||||
return true;
|
||||
case ID_WO:
|
||||
if (!test) *newid = (ID *)BKE_world_copy(bmain, (World *)id);
|
||||
return true;
|
||||
case ID_SCR:
|
||||
return false; /* can't be copied from here */
|
||||
case ID_VF:
|
||||
return false; /* not implemented */
|
||||
case ID_TXT:
|
||||
if (!test) *newid = (ID *)BKE_text_copy(bmain, (Text *)id);
|
||||
return true;
|
||||
case ID_SO:
|
||||
return false; /* not implemented */
|
||||
case ID_GR:
|
||||
if (!test) *newid = (ID *)BKE_group_copy(bmain, (Group *)id);
|
||||
return true;
|
||||
@@ -521,8 +508,6 @@ bool id_copy(Main *bmain, ID *id, ID **newid, bool test)
|
||||
case ID_PA:
|
||||
if (!test) *newid = (ID *)BKE_particlesettings_copy(bmain, (ParticleSettings *)id);
|
||||
return true;
|
||||
case ID_WM:
|
||||
return false; /* can't be copied from here */
|
||||
case ID_GD:
|
||||
if (!test) *newid = (ID *)gpencil_data_duplicate(bmain, (bGPdata *)id, false);
|
||||
return true;
|
||||
@@ -538,6 +523,17 @@ bool id_copy(Main *bmain, ID *id, ID **newid, bool test)
|
||||
case ID_PC:
|
||||
if (!test) *newid = (ID *)BKE_paint_curve_copy(bmain, (PaintCurve *)id);
|
||||
return true;
|
||||
case ID_SCE:
|
||||
case ID_LI:
|
||||
case ID_SCR:
|
||||
case ID_WM:
|
||||
return false; /* can't be copied from here */
|
||||
case ID_VF:
|
||||
case ID_SO:
|
||||
case ID_MC:
|
||||
return false; /* not implemented */
|
||||
case ID_IP:
|
||||
return false; /* deprecated */
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -573,7 +569,7 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
|
||||
|
||||
ListBase *which_libbase(Main *mainlib, short type)
|
||||
{
|
||||
switch (type) {
|
||||
switch ((ID_Type)type) {
|
||||
case ID_SCE:
|
||||
return &(mainlib->scene);
|
||||
case ID_LI:
|
||||
@@ -814,7 +810,7 @@ void *BKE_libblock_alloc_notest(short type)
|
||||
{
|
||||
ID *id = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch ((ID_Type)type) {
|
||||
case ID_SCE:
|
||||
id = MEM_callocN(sizeof(Scene), "scene");
|
||||
break;
|
||||
@@ -951,7 +947,7 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name)
|
||||
void BKE_libblock_init_empty(ID *id)
|
||||
{
|
||||
/* Note that only ID types that are not valid when filled of zero should have a callback here. */
|
||||
switch (GS(id->name)) {
|
||||
switch ((ID_Type)GS(id->name)) {
|
||||
case ID_SCE:
|
||||
BKE_scene_init((Scene *)id);
|
||||
break;
|
||||
@@ -995,15 +991,6 @@ void BKE_libblock_init_empty(ID *id)
|
||||
case ID_CA:
|
||||
BKE_camera_init((Camera *)id);
|
||||
break;
|
||||
case ID_IP:
|
||||
/* Should not be needed - animation from lib pre-2.5 is broken anyway. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_KE:
|
||||
/* Shapekeys are a complex topic too - they depend on their 'user' data type...
|
||||
* They are not linkable, though, so it should never reach here anyway. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_WO:
|
||||
BKE_world_init((World *)id);
|
||||
break;
|
||||
@@ -1040,10 +1027,6 @@ void BKE_libblock_init_empty(ID *id)
|
||||
case ID_PC:
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
case ID_WM:
|
||||
/* We should never reach this. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_GD:
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
@@ -1053,6 +1036,21 @@ void BKE_libblock_init_empty(ID *id)
|
||||
case ID_LS:
|
||||
BKE_linestyle_init((FreestyleLineStyle *)id);
|
||||
break;
|
||||
case ID_KE:
|
||||
/* Shapekeys are a complex topic too - they depend on their 'user' data type...
|
||||
* They are not linkable, though, so it should never reach here anyway. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_WM:
|
||||
/* We should never reach this. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_IP:
|
||||
/* Should not be needed - animation from lib pre-2.5 is broken anyway. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
default:
|
||||
BLI_assert(0); /* Should never reach this point... */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -213,43 +213,49 @@ typedef struct PreviewImage {
|
||||
* Written to #BHead.code (for file IO)
|
||||
* and the first 2 bytes of #ID.name (for runtime checks, see #GS macro).
|
||||
*/
|
||||
#define ID_SCE MAKE_ID2('S', 'C') /* Scene */
|
||||
#define ID_LI MAKE_ID2('L', 'I') /* Library */
|
||||
#define ID_OB MAKE_ID2('O', 'B') /* Object */
|
||||
#define ID_ME MAKE_ID2('M', 'E') /* Mesh */
|
||||
#define ID_CU MAKE_ID2('C', 'U') /* Curve */
|
||||
#define ID_MB MAKE_ID2('M', 'B') /* MetaBall */
|
||||
#define ID_MA MAKE_ID2('M', 'A') /* Material */
|
||||
#define ID_TE MAKE_ID2('T', 'E') /* Tex (Texture) */
|
||||
#define ID_IM MAKE_ID2('I', 'M') /* Image */
|
||||
#define ID_LT MAKE_ID2('L', 'T') /* Lattice */
|
||||
#define ID_LA MAKE_ID2('L', 'A') /* Lamp */
|
||||
#define ID_CA MAKE_ID2('C', 'A') /* Camera */
|
||||
#define ID_IP MAKE_ID2('I', 'P') /* Ipo (depreciated, replaced by FCurves) */
|
||||
#define ID_KE MAKE_ID2('K', 'E') /* Key (shape key) */
|
||||
#define ID_WO MAKE_ID2('W', 'O') /* World */
|
||||
#define ID_SCR MAKE_ID2('S', 'R') /* Screen */
|
||||
#define ID_SCRN MAKE_ID2('S', 'N') /* (depreciated?) */
|
||||
#define ID_VF MAKE_ID2('V', 'F') /* VFont (Vector Font) */
|
||||
#define ID_TXT MAKE_ID2('T', 'X') /* Text */
|
||||
#define ID_SPK MAKE_ID2('S', 'K') /* Speaker */
|
||||
#define ID_SO MAKE_ID2('S', 'O') /* Sound */
|
||||
#define ID_GR MAKE_ID2('G', 'R') /* Group */
|
||||
#define ID_ID MAKE_ID2('I', 'D') /* (internal use only) */
|
||||
#define ID_AR MAKE_ID2('A', 'R') /* bArmature */
|
||||
#define ID_AC MAKE_ID2('A', 'C') /* bAction */
|
||||
#define ID_NT MAKE_ID2('N', 'T') /* bNodeTree */
|
||||
#define ID_BR MAKE_ID2('B', 'R') /* Brush */
|
||||
#define ID_PA MAKE_ID2('P', 'A') /* ParticleSettings */
|
||||
#define ID_GD MAKE_ID2('G', 'D') /* bGPdata, (Grease Pencil) */
|
||||
#define ID_WM MAKE_ID2('W', 'M') /* WindowManager */
|
||||
#define ID_MC MAKE_ID2('M', 'C') /* MovieClip */
|
||||
#define ID_MSK MAKE_ID2('M', 'S') /* Mask */
|
||||
#define ID_LS MAKE_ID2('L', 'S') /* FreestyleLineStyle */
|
||||
#define ID_PAL MAKE_ID2('P', 'L') /* Palette */
|
||||
#define ID_PC MAKE_ID2('P', 'C') /* PaintCurve */
|
||||
typedef enum ID_Type {
|
||||
ID_SCE = MAKE_ID2('S', 'C'), /* Scene */
|
||||
ID_LI = MAKE_ID2('L', 'I'), /* Library */
|
||||
ID_OB = MAKE_ID2('O', 'B'), /* Object */
|
||||
ID_ME = MAKE_ID2('M', 'E'), /* Mesh */
|
||||
ID_CU = MAKE_ID2('C', 'U'), /* Curve */
|
||||
ID_MB = MAKE_ID2('M', 'B'), /* MetaBall */
|
||||
ID_MA = MAKE_ID2('M', 'A'), /* Material */
|
||||
ID_TE = MAKE_ID2('T', 'E'), /* Tex (Texture) */
|
||||
ID_IM = MAKE_ID2('I', 'M'), /* Image */
|
||||
ID_LT = MAKE_ID2('L', 'T'), /* Lattice */
|
||||
ID_LA = MAKE_ID2('L', 'A'), /* Lamp */
|
||||
ID_CA = MAKE_ID2('C', 'A'), /* Camera */
|
||||
ID_IP = MAKE_ID2('I', 'P'), /* Ipo (depreciated, replaced by FCurves) */
|
||||
ID_KE = MAKE_ID2('K', 'E'), /* Key (shape key) */
|
||||
ID_WO = MAKE_ID2('W', 'O'), /* World */
|
||||
ID_SCR = MAKE_ID2('S', 'R'), /* Screen */
|
||||
ID_VF = MAKE_ID2('V', 'F'), /* VFont (Vector Font) */
|
||||
ID_TXT = MAKE_ID2('T', 'X'), /* Text */
|
||||
ID_SPK = MAKE_ID2('S', 'K'), /* Speaker */
|
||||
ID_SO = MAKE_ID2('S', 'O'), /* Sound */
|
||||
ID_GR = MAKE_ID2('G', 'R'), /* Group */
|
||||
ID_AR = MAKE_ID2('A', 'R'), /* bArmature */
|
||||
ID_AC = MAKE_ID2('A', 'C'), /* bAction */
|
||||
ID_NT = MAKE_ID2('N', 'T'), /* bNodeTree */
|
||||
ID_BR = MAKE_ID2('B', 'R'), /* Brush */
|
||||
ID_PA = MAKE_ID2('P', 'A'), /* ParticleSettings */
|
||||
ID_GD = MAKE_ID2('G', 'D'), /* bGPdata, (Grease Pencil) */
|
||||
ID_WM = MAKE_ID2('W', 'M'), /* WindowManager */
|
||||
ID_MC = MAKE_ID2('M', 'C'), /* MovieClip */
|
||||
ID_MSK = MAKE_ID2('M', 'S'), /* Mask */
|
||||
ID_LS = MAKE_ID2('L', 'S'), /* FreestyleLineStyle */
|
||||
ID_PAL = MAKE_ID2('P', 'L'), /* Palette */
|
||||
ID_PC = MAKE_ID2('P', 'C'), /* PaintCurve */
|
||||
} ID_Type;
|
||||
|
||||
/* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
|
||||
/* Only used as 'placeholder' in .blend files for directly linked datablocks. */
|
||||
#define ID_ID MAKE_ID2('I', 'D') /* (internal use only) */
|
||||
|
||||
/* Deprecated. */
|
||||
#define ID_SCRN MAKE_ID2('S', 'N')
|
||||
|
||||
/* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
|
||||
#define ID_SEQ MAKE_ID2('S', 'Q')
|
||||
/* constraint */
|
||||
#define ID_CO MAKE_ID2('C', 'O')
|
||||
|
||||
Reference in New Issue
Block a user