Cleanup/refactor: remove BKE_idcode, in favour of BKE_idtype.
Mpving utils from idcode to idtype proved to be somewhat painful for some reasons, but now all looks good. Had to add a fake/empty shell for the special snowflake too, `ID_LINK_PLACEHOLDER/INDEX_ID_NULL`...
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __BKE_IDCODE_H__
|
||||
#define __BKE_IDCODE_H__
|
||||
|
||||
/** \file
|
||||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char *BKE_idcode_to_name(short idcode);
|
||||
const char *BKE_idcode_to_name_plural(short idcode);
|
||||
const char *BKE_idcode_to_translation_context(short idcode);
|
||||
short BKE_idcode_from_name(const char *name);
|
||||
bool BKE_idcode_is_linkable(short idcode);
|
||||
bool BKE_idcode_is_valid(short idcode);
|
||||
|
||||
uint64_t BKE_idcode_to_idfilter(const short idcode);
|
||||
short BKE_idcode_from_idfilter(const uint64_t idfilter);
|
||||
|
||||
int BKE_idcode_to_index(const short idcode);
|
||||
short BKE_idcode_from_index(const int index);
|
||||
|
||||
short BKE_idcode_iter_step(int *index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -166,6 +166,8 @@ extern IDTypeInfo IDType_ID_HA;
|
||||
extern IDTypeInfo IDType_ID_PT;
|
||||
extern IDTypeInfo IDType_ID_VO;
|
||||
|
||||
extern IDTypeInfo IDType_ID_LINK_PLACEHOLDER;
|
||||
|
||||
/* ********** Helpers/Utils API. ********** */
|
||||
|
||||
/* Module initialization. */
|
||||
@@ -175,6 +177,22 @@ void BKE_idtype_init(void);
|
||||
const struct IDTypeInfo *BKE_idtype_get_info_from_idcode(const short id_code);
|
||||
const struct IDTypeInfo *BKE_idtype_get_info_from_id(const struct ID *id);
|
||||
|
||||
const char *BKE_idtype_idcode_to_name(const short idcode);
|
||||
const char *BKE_idtype_idcode_to_name_plural(const short idcode);
|
||||
const char *BKE_idtype_idcode_to_translation_context(const short idcode);
|
||||
bool BKE_idtype_idcode_is_linkable(const short idcode);
|
||||
bool BKE_idtype_idcode_is_valid(const short idcode);
|
||||
|
||||
short BKE_idtype_idcode_from_name(const char *name);
|
||||
|
||||
uint64_t BKE_idtype_idcode_to_idfilter(const short idcode);
|
||||
short BKE_idtype_idcode_from_idfilter(const uint64_t idfilter);
|
||||
|
||||
int BKE_idtype_idcode_to_index(const short idcode);
|
||||
short BKE_idtype_idcode_from_index(const int index);
|
||||
|
||||
short BKE_idtype_idcode_iter_step(int *index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -124,7 +124,6 @@ set(SRC
|
||||
intern/hair.c
|
||||
intern/icons.c
|
||||
intern/icons_rasterize.c
|
||||
intern/idcode.c
|
||||
intern/idprop.c
|
||||
intern/idprop_utils.c
|
||||
intern/idtype.c
|
||||
@@ -304,7 +303,6 @@ set(SRC
|
||||
BKE_gpencil_modifier.h
|
||||
BKE_hair.h
|
||||
BKE_icons.h
|
||||
BKE_idcode.h
|
||||
BKE_idprop.h
|
||||
BKE_idtype.h
|
||||
BKE_image.h
|
||||
|
||||
@@ -1,432 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
* return info about ID types
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned short code;
|
||||
const char *name, *plural;
|
||||
|
||||
const char *i18n_context;
|
||||
|
||||
int flags;
|
||||
#define IDTYPE_FLAGS_ISLINKABLE (1 << 0)
|
||||
} IDType;
|
||||
|
||||
/* Keep alignment for readability. */
|
||||
/* clang-format off */
|
||||
/**
|
||||
* When editing ensure that:
|
||||
* - Plural needs to match rna_main.c's #MainCollectionDef.
|
||||
* - Keep it in sync with i18n contexts in BLT_translation.h
|
||||
*/
|
||||
static IDType idtypes[] = {
|
||||
/** ID's directly below must all be in #Main, and be kept in sync with #MAX_LIBARRAY (membership, not order) */
|
||||
{ID_AC, "Action", "actions", BLT_I18NCONTEXT_ID_ACTION, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_AR, "Armature", "armatures", BLT_I18NCONTEXT_ID_ARMATURE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_BR, "Brush", "brushes", BLT_I18NCONTEXT_ID_BRUSH, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_CA, "Camera", "cameras", BLT_I18NCONTEXT_ID_CAMERA, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_CF, "CacheFile", "cache_files", BLT_I18NCONTEXT_ID_CACHEFILE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_GR, "Collection", "collections", BLT_I18NCONTEXT_ID_COLLECTION, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_CU, "Curve", "curves", BLT_I18NCONTEXT_ID_CURVE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_GD, "GPencil", "grease_pencils", BLT_I18NCONTEXT_ID_GPENCIL, IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */
|
||||
{ID_HA, "Hair", "hair", BLT_I18NCONTEXT_ID_HAIR, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_IM, "Image", "images", BLT_I18NCONTEXT_ID_IMAGE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_IP, "Ipo", "ipos", "", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */
|
||||
{ID_KE, "Key", "shape_keys", BLT_I18NCONTEXT_ID_SHAPEKEY, 0 },
|
||||
{ID_LA, "Light", "lights", BLT_I18NCONTEXT_ID_LIGHT, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_LI, "Library", "libraries", BLT_I18NCONTEXT_ID_LIBRARY, 0 },
|
||||
{ID_LS, "FreestyleLineStyle", "linestyles", BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_LT, "Lattice", "lattices", BLT_I18NCONTEXT_ID_LATTICE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_MA, "Material", "materials", BLT_I18NCONTEXT_ID_MATERIAL, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_MB, "Metaball", "metaballs", BLT_I18NCONTEXT_ID_METABALL, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_MC, "MovieClip", "movieclips", BLT_I18NCONTEXT_ID_MOVIECLIP, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_ME, "Mesh", "meshes", BLT_I18NCONTEXT_ID_MESH, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_MSK, "Mask", "masks", BLT_I18NCONTEXT_ID_MASK, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_NT, "NodeTree", "node_groups", BLT_I18NCONTEXT_ID_NODETREE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_OB, "Object", "objects", BLT_I18NCONTEXT_ID_OBJECT, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_PA, "ParticleSettings", "particles", BLT_I18NCONTEXT_ID_PARTICLESETTINGS, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_PAL, "Palettes", "palettes", BLT_I18NCONTEXT_ID_PALETTE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_PC, "PaintCurve", "paint_curves", BLT_I18NCONTEXT_ID_PAINTCURVE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_LP, "LightProbe", "lightprobes", BLT_I18NCONTEXT_ID_LIGHTPROBE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_PT, "PointCloud", "pointclouds", BLT_I18NCONTEXT_ID_POINTCLOUD, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_SCE, "Scene", "scenes", BLT_I18NCONTEXT_ID_SCENE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_SCR, "Screen", "screens", BLT_I18NCONTEXT_ID_SCREEN, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_SEQ, "Sequence", "sequences", BLT_I18NCONTEXT_ID_SEQUENCE, 0 }, /* not actually ID data */
|
||||
{ID_SPK, "Speaker", "speakers", BLT_I18NCONTEXT_ID_SPEAKER, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_SO, "Sound", "sounds", BLT_I18NCONTEXT_ID_SOUND, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_TE, "Texture", "textures", BLT_I18NCONTEXT_ID_TEXTURE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_TXT, "Text", "texts", BLT_I18NCONTEXT_ID_TEXT, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_VF, "VFont", "fonts", BLT_I18NCONTEXT_ID_VFONT, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_VO, "Volume", "volumes", BLT_I18NCONTEXT_ID_VOLUME, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_WO, "World", "worlds", BLT_I18NCONTEXT_ID_WORLD, IDTYPE_FLAGS_ISLINKABLE},
|
||||
{ID_WM, "WindowManager", "window_managers", BLT_I18NCONTEXT_ID_WINDOWMANAGER, 0 },
|
||||
{ID_WS, "WorkSpace", "workspaces", BLT_I18NCONTEXT_ID_WORKSPACE, IDTYPE_FLAGS_ISLINKABLE},
|
||||
|
||||
/** Keep last, not an ID exactly, only include for completeness */
|
||||
{ID_LINK_PLACEHOLDER, "Link Placeholder", "link_placeholders", BLT_I18NCONTEXT_ID_ID, 0}, /* plural is fake */
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
/* -1 for ID_LINK_PLACEHOLDER */
|
||||
BLI_STATIC_ASSERT((ARRAY_SIZE(idtypes) - 1 == MAX_LIBARRAY), "Missing IDType");
|
||||
|
||||
static IDType *idtype_from_name(const char *str)
|
||||
{
|
||||
int i = ARRAY_SIZE(idtypes);
|
||||
|
||||
while (i--) {
|
||||
if (STREQ(str, idtypes[i].name)) {
|
||||
return &idtypes[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
static IDType *idtype_from_code(short idcode)
|
||||
{
|
||||
int i = ARRAY_SIZE(idtypes);
|
||||
|
||||
while (i--) {
|
||||
if (idcode == idtypes[i].code) {
|
||||
return &idtypes[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if the ID code is a valid ID code.
|
||||
*
|
||||
* \param idcode: The code to check.
|
||||
* \return Boolean, 0 when invalid.
|
||||
*/
|
||||
bool BKE_idcode_is_valid(short idcode)
|
||||
{
|
||||
return idtype_from_code(idcode) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return non-zero when an ID type is linkable.
|
||||
*
|
||||
* \param idcode: The code to check.
|
||||
* \return Boolean, 0 when non linkable.
|
||||
*/
|
||||
bool BKE_idcode_is_linkable(short idcode)
|
||||
{
|
||||
IDType *idt = idtype_from_code(idcode);
|
||||
BLI_assert(idt);
|
||||
return idt ? ((idt->flags & IDTYPE_FLAGS_ISLINKABLE) != 0) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into a name.
|
||||
*
|
||||
* \param idcode: The code to convert.
|
||||
* \return A static string representing the name of
|
||||
* the code.
|
||||
*/
|
||||
const char *BKE_idcode_to_name(short idcode)
|
||||
{
|
||||
IDType *idt = idtype_from_code(idcode);
|
||||
BLI_assert(idt);
|
||||
return idt ? idt->name : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a name into an idcode (ie. ID_SCE)
|
||||
*
|
||||
* \param name: The name to convert.
|
||||
* \return The code for the name, or 0 if invalid.
|
||||
*/
|
||||
short BKE_idcode_from_name(const char *name)
|
||||
{
|
||||
IDType *idt = idtype_from_name(name);
|
||||
BLI_assert(idt);
|
||||
return idt ? idt->code : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into an idfilter (e.g. ID_OB -> FILTER_ID_OB).
|
||||
*/
|
||||
uint64_t BKE_idcode_to_idfilter(const short idcode)
|
||||
{
|
||||
#define CASE_IDFILTER(_id) \
|
||||
case ID_##_id: \
|
||||
return FILTER_ID_##_id
|
||||
|
||||
switch (idcode) {
|
||||
CASE_IDFILTER(AC);
|
||||
CASE_IDFILTER(AR);
|
||||
CASE_IDFILTER(BR);
|
||||
CASE_IDFILTER(CA);
|
||||
CASE_IDFILTER(CF);
|
||||
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(PA);
|
||||
CASE_IDFILTER(PAL);
|
||||
CASE_IDFILTER(PC);
|
||||
CASE_IDFILTER(LP);
|
||||
CASE_IDFILTER(SCE);
|
||||
CASE_IDFILTER(SPK);
|
||||
CASE_IDFILTER(SO);
|
||||
CASE_IDFILTER(TE);
|
||||
CASE_IDFILTER(TXT);
|
||||
CASE_IDFILTER(VF);
|
||||
CASE_IDFILTER(HA);
|
||||
CASE_IDFILTER(PT);
|
||||
CASE_IDFILTER(VO);
|
||||
CASE_IDFILTER(WO);
|
||||
CASE_IDFILTER(WS);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef CASE_IDFILTER
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idfilter into an idcode (e.g. FILTER_ID_OB -> ID_OB).
|
||||
*/
|
||||
short BKE_idcode_from_idfilter(const uint64_t 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(CF);
|
||||
CASE_IDFILTER(CU);
|
||||
CASE_IDFILTER(GD);
|
||||
CASE_IDFILTER(GR);
|
||||
CASE_IDFILTER(HA);
|
||||
CASE_IDFILTER(IM);
|
||||
CASE_IDFILTER(LA);
|
||||
CASE_IDFILTER(LP);
|
||||
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(PA);
|
||||
CASE_IDFILTER(PAL);
|
||||
CASE_IDFILTER(PC);
|
||||
CASE_IDFILTER(PT);
|
||||
CASE_IDFILTER(SCE);
|
||||
CASE_IDFILTER(SPK);
|
||||
CASE_IDFILTER(SO);
|
||||
CASE_IDFILTER(TE);
|
||||
CASE_IDFILTER(TXT);
|
||||
CASE_IDFILTER(VF);
|
||||
CASE_IDFILTER(VO);
|
||||
CASE_IDFILTER(WO);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef CASE_IDFILTER
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into an index (e.g. ID_OB -> INDEX_ID_OB).
|
||||
*/
|
||||
int BKE_idcode_to_index(const short idcode)
|
||||
{
|
||||
#define CASE_IDINDEX(_id) \
|
||||
case ID_##_id: \
|
||||
return INDEX_ID_##_id
|
||||
|
||||
switch ((ID_Type)idcode) {
|
||||
CASE_IDINDEX(AC);
|
||||
CASE_IDINDEX(AR);
|
||||
CASE_IDINDEX(BR);
|
||||
CASE_IDINDEX(CA);
|
||||
CASE_IDINDEX(CF);
|
||||
CASE_IDINDEX(CU);
|
||||
CASE_IDINDEX(GD);
|
||||
CASE_IDINDEX(GR);
|
||||
CASE_IDINDEX(HA);
|
||||
CASE_IDINDEX(IM);
|
||||
CASE_IDINDEX(KE);
|
||||
CASE_IDINDEX(IP);
|
||||
CASE_IDINDEX(LA);
|
||||
CASE_IDINDEX(LI);
|
||||
CASE_IDINDEX(LP);
|
||||
CASE_IDINDEX(LS);
|
||||
CASE_IDINDEX(LT);
|
||||
CASE_IDINDEX(MA);
|
||||
CASE_IDINDEX(MB);
|
||||
CASE_IDINDEX(MC);
|
||||
CASE_IDINDEX(ME);
|
||||
CASE_IDINDEX(MSK);
|
||||
CASE_IDINDEX(NT);
|
||||
CASE_IDINDEX(OB);
|
||||
CASE_IDINDEX(PA);
|
||||
CASE_IDINDEX(PAL);
|
||||
CASE_IDINDEX(PC);
|
||||
CASE_IDINDEX(PT);
|
||||
CASE_IDINDEX(SCE);
|
||||
CASE_IDINDEX(SCR);
|
||||
CASE_IDINDEX(SPK);
|
||||
CASE_IDINDEX(SO);
|
||||
CASE_IDINDEX(TE);
|
||||
CASE_IDINDEX(TXT);
|
||||
CASE_IDINDEX(VF);
|
||||
CASE_IDINDEX(VO);
|
||||
CASE_IDINDEX(WM);
|
||||
CASE_IDINDEX(WO);
|
||||
CASE_IDINDEX(WS);
|
||||
}
|
||||
|
||||
BLI_assert(0);
|
||||
return -1;
|
||||
|
||||
#undef CASE_IDINDEX
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an idcode from an index (e.g. INDEX_ID_OB -> ID_OB).
|
||||
*/
|
||||
short BKE_idcode_from_index(const int index)
|
||||
{
|
||||
#define CASE_IDCODE(_id) \
|
||||
case INDEX_ID_##_id: \
|
||||
return ID_##_id
|
||||
|
||||
switch (index) {
|
||||
CASE_IDCODE(AC);
|
||||
CASE_IDCODE(AR);
|
||||
CASE_IDCODE(BR);
|
||||
CASE_IDCODE(CA);
|
||||
CASE_IDCODE(CF);
|
||||
CASE_IDCODE(CU);
|
||||
CASE_IDCODE(GD);
|
||||
CASE_IDCODE(GR);
|
||||
CASE_IDCODE(HA);
|
||||
CASE_IDCODE(IM);
|
||||
CASE_IDCODE(KE);
|
||||
CASE_IDCODE(IP);
|
||||
CASE_IDCODE(LA);
|
||||
CASE_IDCODE(LI);
|
||||
CASE_IDCODE(LP);
|
||||
CASE_IDCODE(LS);
|
||||
CASE_IDCODE(LT);
|
||||
CASE_IDCODE(MA);
|
||||
CASE_IDCODE(MB);
|
||||
CASE_IDCODE(MC);
|
||||
CASE_IDCODE(ME);
|
||||
CASE_IDCODE(MSK);
|
||||
CASE_IDCODE(NT);
|
||||
CASE_IDCODE(OB);
|
||||
CASE_IDCODE(PA);
|
||||
CASE_IDCODE(PAL);
|
||||
CASE_IDCODE(PC);
|
||||
CASE_IDCODE(PT);
|
||||
CASE_IDCODE(SCE);
|
||||
CASE_IDCODE(SCR);
|
||||
CASE_IDCODE(SPK);
|
||||
CASE_IDCODE(SO);
|
||||
CASE_IDCODE(TE);
|
||||
CASE_IDCODE(TXT);
|
||||
CASE_IDCODE(VF);
|
||||
CASE_IDCODE(VO);
|
||||
CASE_IDCODE(WM);
|
||||
CASE_IDCODE(WO);
|
||||
CASE_IDCODE(WS);
|
||||
}
|
||||
|
||||
BLI_assert(0);
|
||||
return -1;
|
||||
|
||||
#undef CASE_IDCODE
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into a name (plural).
|
||||
*
|
||||
* \param idcode: The code to convert.
|
||||
* \return A static string representing the name of
|
||||
* the code.
|
||||
*/
|
||||
const char *BKE_idcode_to_name_plural(short idcode)
|
||||
{
|
||||
IDType *idt = idtype_from_code(idcode);
|
||||
BLI_assert(idt);
|
||||
return idt ? idt->plural : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into its translations' context.
|
||||
*
|
||||
* \param idcode: The code to convert.
|
||||
* \return A static string representing the i18n context of the code.
|
||||
*/
|
||||
const char *BKE_idcode_to_translation_context(short idcode)
|
||||
{
|
||||
IDType *idt = idtype_from_code(idcode);
|
||||
BLI_assert(idt);
|
||||
return idt ? idt->i18n_context : BLT_I18NCONTEXT_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an ID code and steps the index forward 1.
|
||||
*
|
||||
* \param index: start as 0.
|
||||
* \return the code, 0 when all codes have been returned.
|
||||
*/
|
||||
short BKE_idcode_iter_step(int *index)
|
||||
{
|
||||
return (*index < ARRAY_SIZE(idtypes)) ? idtypes[(*index)++].code : 0;
|
||||
}
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_idtype.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -181,7 +181,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
|
||||
const ID *id = prop->data.pointer;
|
||||
if (id != NULL) {
|
||||
STR_APPEND_STR("bpy.data.");
|
||||
STR_APPEND_STR(BKE_idcode_to_name_plural(GS(id->name)));
|
||||
STR_APPEND_STR(BKE_idtype_idcode_to_name_plural(GS(id->name)));
|
||||
STR_APPEND_STR("[");
|
||||
STR_APPEND_STR_QUOTE(id->name + 2);
|
||||
STR_APPEND_STR("]");
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
@@ -34,13 +36,13 @@
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "BKE_idtype.h"
|
||||
|
||||
// static CLG_LogRef LOG = {"bke.idtype"};
|
||||
|
||||
static IDTypeInfo *id_types[INDEX_ID_MAX] = {NULL};
|
||||
static IDTypeInfo *id_types[MAX_LIBARRAY] = {NULL};
|
||||
|
||||
static void id_type_init(void)
|
||||
{
|
||||
@@ -91,6 +93,10 @@ static void id_type_init(void)
|
||||
INIT_TYPE(ID_PT);
|
||||
INIT_TYPE(ID_VO);
|
||||
|
||||
/* Special naughty boy... */
|
||||
BLI_assert(IDType_ID_LINK_PLACEHOLDER.main_listbase_index == INDEX_ID_NULL);
|
||||
id_types[INDEX_ID_NULL] = &IDType_ID_LINK_PLACEHOLDER;
|
||||
|
||||
#undef INIT_TYPE
|
||||
}
|
||||
|
||||
@@ -102,9 +108,9 @@ void BKE_idtype_init(void)
|
||||
|
||||
const IDTypeInfo *BKE_idtype_get_info_from_idcode(const short id_code)
|
||||
{
|
||||
int id_index = BKE_idcode_to_index(id_code);
|
||||
int id_index = BKE_idtype_idcode_to_index(id_code);
|
||||
|
||||
if (id_index >= 0 && id_index < INDEX_ID_MAX && id_types[id_index] != NULL &&
|
||||
if (id_index >= 0 && id_index < ARRAY_SIZE(id_types) && id_types[id_index] != NULL &&
|
||||
id_types[id_index]->name[0] != '\0') {
|
||||
return id_types[id_index];
|
||||
}
|
||||
@@ -117,3 +123,329 @@ const IDTypeInfo *BKE_idtype_get_info_from_id(const ID *id)
|
||||
{
|
||||
return BKE_idtype_get_info_from_idcode(GS(id->name));
|
||||
}
|
||||
|
||||
static const IDTypeInfo *idtype_get_info_from_name(const char *str)
|
||||
{
|
||||
for (int i = ARRAY_SIZE(id_types); i--;) {
|
||||
if (id_types[i] != NULL && STREQ(str, id_types[i]->name)) {
|
||||
return id_types[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Various helpers/wrappers around IDTypeInfo structure. */
|
||||
|
||||
/**
|
||||
* Convert an idcode into a name.
|
||||
*
|
||||
* \param idcode: The code to convert.
|
||||
* \return A static string representing the name of
|
||||
* the code.
|
||||
*/
|
||||
const char *BKE_idtype_idcode_to_name(const short idcode)
|
||||
{
|
||||
const IDTypeInfo *id_type = BKE_idtype_get_info_from_idcode(idcode);
|
||||
BLI_assert(id_type != NULL);
|
||||
return id_type != NULL ? id_type->name : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into a name (plural).
|
||||
*
|
||||
* \param idcode: The code to convert.
|
||||
* \return A static string representing the name of
|
||||
* the code.
|
||||
*/
|
||||
const char *BKE_idtype_idcode_to_name_plural(const short idcode)
|
||||
{
|
||||
const IDTypeInfo *id_type = BKE_idtype_get_info_from_idcode(idcode);
|
||||
BLI_assert(id_type != NULL);
|
||||
return id_type != NULL ? id_type->name_plural : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into its translations' context.
|
||||
*
|
||||
* \param idcode: The code to convert.
|
||||
* \return A static string representing the i18n context of the code.
|
||||
*/
|
||||
const char *BKE_idtype_idcode_to_translation_context(const short idcode)
|
||||
{
|
||||
const IDTypeInfo *id_type = BKE_idtype_get_info_from_idcode(idcode);
|
||||
BLI_assert(id_type != NULL);
|
||||
return id_type != NULL ? id_type->translation_context : BLT_I18NCONTEXT_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a name into an idcode (ie. ID_SCE)
|
||||
*
|
||||
* \param name: The name to convert.
|
||||
* \return The code for the name, or 0 if invalid.
|
||||
*/
|
||||
short BKE_idtype_idcode_from_name(const char *name)
|
||||
{
|
||||
const IDTypeInfo *id_type = idtype_get_info_from_name(name);
|
||||
BLI_assert(id_type);
|
||||
return id_type != NULL ? id_type->id_code : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if the ID code is a valid ID code.
|
||||
*
|
||||
* \param idcode: The code to check.
|
||||
* \return Boolean, 0 when invalid.
|
||||
*/
|
||||
bool BKE_idtype_idcode_is_valid(const short idcode)
|
||||
{
|
||||
return BKE_idtype_get_info_from_idcode(idcode) != NULL ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return non-zero when an ID type is linkable.
|
||||
*
|
||||
* \param idcode: The code to check.
|
||||
* \return Boolean, 0 when non linkable.
|
||||
*/
|
||||
bool BKE_idtype_idcode_is_linkable(const short idcode)
|
||||
{
|
||||
const IDTypeInfo *id_type = BKE_idtype_get_info_from_idcode(idcode);
|
||||
BLI_assert(id_type != NULL);
|
||||
return id_type != NULL ? (id_type->flags & IDTYPE_FLAGS_NO_LIBLINKING) == 0 : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into an idfilter (e.g. ID_OB -> FILTER_ID_OB).
|
||||
*/
|
||||
uint64_t BKE_idtype_idcode_to_idfilter(const short idcode)
|
||||
{
|
||||
#define CASE_IDFILTER(_id) \
|
||||
case ID_##_id: \
|
||||
return FILTER_ID_##_id
|
||||
|
||||
switch (idcode) {
|
||||
CASE_IDFILTER(AC);
|
||||
CASE_IDFILTER(AR);
|
||||
CASE_IDFILTER(BR);
|
||||
CASE_IDFILTER(CA);
|
||||
CASE_IDFILTER(CF);
|
||||
CASE_IDFILTER(CU);
|
||||
CASE_IDFILTER(GD);
|
||||
CASE_IDFILTER(GR);
|
||||
CASE_IDFILTER(HA);
|
||||
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(PA);
|
||||
CASE_IDFILTER(PAL);
|
||||
CASE_IDFILTER(PC);
|
||||
CASE_IDFILTER(PT);
|
||||
CASE_IDFILTER(LP);
|
||||
CASE_IDFILTER(SCE);
|
||||
CASE_IDFILTER(SPK);
|
||||
CASE_IDFILTER(SO);
|
||||
CASE_IDFILTER(TE);
|
||||
CASE_IDFILTER(TXT);
|
||||
CASE_IDFILTER(VF);
|
||||
CASE_IDFILTER(VO);
|
||||
CASE_IDFILTER(WO);
|
||||
CASE_IDFILTER(WS);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef CASE_IDFILTER
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idfilter into an idcode (e.g. FILTER_ID_OB -> ID_OB).
|
||||
*/
|
||||
short BKE_idtype_idcode_from_idfilter(const uint64_t 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(CF);
|
||||
CASE_IDFILTER(CU);
|
||||
CASE_IDFILTER(GD);
|
||||
CASE_IDFILTER(GR);
|
||||
CASE_IDFILTER(HA);
|
||||
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(PA);
|
||||
CASE_IDFILTER(PAL);
|
||||
CASE_IDFILTER(PC);
|
||||
CASE_IDFILTER(PT);
|
||||
CASE_IDFILTER(LP);
|
||||
CASE_IDFILTER(SCE);
|
||||
CASE_IDFILTER(SPK);
|
||||
CASE_IDFILTER(SO);
|
||||
CASE_IDFILTER(TE);
|
||||
CASE_IDFILTER(TXT);
|
||||
CASE_IDFILTER(VF);
|
||||
CASE_IDFILTER(VO);
|
||||
CASE_IDFILTER(WO);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef CASE_IDFILTER
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an idcode into an index (e.g. ID_OB -> INDEX_ID_OB).
|
||||
*/
|
||||
int BKE_idtype_idcode_to_index(const short idcode)
|
||||
{
|
||||
#define CASE_IDINDEX(_id) \
|
||||
case ID_##_id: \
|
||||
return INDEX_ID_##_id
|
||||
|
||||
switch ((ID_Type)idcode) {
|
||||
CASE_IDINDEX(AC);
|
||||
CASE_IDINDEX(AR);
|
||||
CASE_IDINDEX(BR);
|
||||
CASE_IDINDEX(CA);
|
||||
CASE_IDINDEX(CF);
|
||||
CASE_IDINDEX(CU);
|
||||
CASE_IDINDEX(GD);
|
||||
CASE_IDINDEX(GR);
|
||||
CASE_IDINDEX(HA);
|
||||
CASE_IDINDEX(IM);
|
||||
CASE_IDINDEX(IP);
|
||||
CASE_IDINDEX(KE);
|
||||
CASE_IDINDEX(LA);
|
||||
CASE_IDINDEX(LI);
|
||||
CASE_IDINDEX(LS);
|
||||
CASE_IDINDEX(LT);
|
||||
CASE_IDINDEX(MA);
|
||||
CASE_IDINDEX(MB);
|
||||
CASE_IDINDEX(MC);
|
||||
CASE_IDINDEX(ME);
|
||||
CASE_IDINDEX(MSK);
|
||||
CASE_IDINDEX(NT);
|
||||
CASE_IDINDEX(OB);
|
||||
CASE_IDINDEX(PA);
|
||||
CASE_IDINDEX(PAL);
|
||||
CASE_IDINDEX(PC);
|
||||
CASE_IDINDEX(PT);
|
||||
CASE_IDINDEX(LP);
|
||||
CASE_IDINDEX(SCE);
|
||||
CASE_IDINDEX(SCR);
|
||||
CASE_IDINDEX(SPK);
|
||||
CASE_IDINDEX(SO);
|
||||
CASE_IDINDEX(TE);
|
||||
CASE_IDINDEX(TXT);
|
||||
CASE_IDINDEX(VF);
|
||||
CASE_IDINDEX(VO);
|
||||
CASE_IDINDEX(WM);
|
||||
CASE_IDINDEX(WO);
|
||||
CASE_IDINDEX(WS);
|
||||
}
|
||||
|
||||
/* Special naughty boy... */
|
||||
if (idcode == ID_LINK_PLACEHOLDER) {
|
||||
return INDEX_ID_NULL;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
#undef CASE_IDINDEX
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an idcode from an index (e.g. INDEX_ID_OB -> ID_OB).
|
||||
*/
|
||||
short BKE_idtype_idcode_from_index(const int index)
|
||||
{
|
||||
#define CASE_IDCODE(_id) \
|
||||
case INDEX_ID_##_id: \
|
||||
return ID_##_id
|
||||
|
||||
switch (index) {
|
||||
CASE_IDCODE(AC);
|
||||
CASE_IDCODE(AR);
|
||||
CASE_IDCODE(BR);
|
||||
CASE_IDCODE(CA);
|
||||
CASE_IDCODE(CF);
|
||||
CASE_IDCODE(CU);
|
||||
CASE_IDCODE(GD);
|
||||
CASE_IDCODE(GR);
|
||||
CASE_IDCODE(HA);
|
||||
CASE_IDCODE(IM);
|
||||
CASE_IDCODE(IP);
|
||||
CASE_IDCODE(KE);
|
||||
CASE_IDCODE(LA);
|
||||
CASE_IDCODE(LI);
|
||||
CASE_IDCODE(LS);
|
||||
CASE_IDCODE(LT);
|
||||
CASE_IDCODE(MA);
|
||||
CASE_IDCODE(MB);
|
||||
CASE_IDCODE(MC);
|
||||
CASE_IDCODE(ME);
|
||||
CASE_IDCODE(MSK);
|
||||
CASE_IDCODE(NT);
|
||||
CASE_IDCODE(OB);
|
||||
CASE_IDCODE(PA);
|
||||
CASE_IDCODE(PAL);
|
||||
CASE_IDCODE(PC);
|
||||
CASE_IDCODE(PT);
|
||||
CASE_IDCODE(LP);
|
||||
CASE_IDCODE(SCE);
|
||||
CASE_IDCODE(SCR);
|
||||
CASE_IDCODE(SPK);
|
||||
CASE_IDCODE(SO);
|
||||
CASE_IDCODE(TE);
|
||||
CASE_IDCODE(TXT);
|
||||
CASE_IDCODE(VF);
|
||||
CASE_IDCODE(VO);
|
||||
CASE_IDCODE(WM);
|
||||
CASE_IDCODE(WO);
|
||||
CASE_IDCODE(WS);
|
||||
}
|
||||
|
||||
/* Special naughty boy... */
|
||||
if (index == INDEX_ID_NULL) {
|
||||
return ID_LINK_PLACEHOLDER;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
#undef CASE_IDCODE
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an ID code and steps the index forward 1.
|
||||
*
|
||||
* \param index: start as 0.
|
||||
* \return the code, 0 when all codes have been returned.
|
||||
*/
|
||||
short BKE_idtype_idcode_iter_step(int *index)
|
||||
{
|
||||
printf("%d: %d\n", *index, BKE_idtype_idcode_from_index((*index)));
|
||||
return (*index < ARRAY_SIZE(id_types)) ? BKE_idtype_idcode_from_index((*index)++) : 0;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,6 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_hair.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_image.h"
|
||||
@@ -139,6 +138,23 @@
|
||||
|
||||
static CLG_LogRef LOG = {.identifier = "bke.lib_id"};
|
||||
|
||||
/* Empty shell mostly, but needed for read code. */
|
||||
IDTypeInfo IDType_ID_LINK_PLACEHOLDER = {
|
||||
.id_code = ID_LINK_PLACEHOLDER,
|
||||
.id_filter = 0,
|
||||
.main_listbase_index = INDEX_ID_NULL,
|
||||
.struct_size = sizeof(ID),
|
||||
.name = "LinkPlaceholder",
|
||||
.name_plural = "link_placeholders",
|
||||
.translation_context = BLT_I18NCONTEXT_ID_ID,
|
||||
.flags = IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_LIBLINKING | IDTYPE_FLAGS_NO_MAKELOCAL,
|
||||
|
||||
.init_data = NULL,
|
||||
.copy_data = NULL,
|
||||
.free_data = NULL,
|
||||
.make_local = NULL,
|
||||
};
|
||||
|
||||
/* GS reads the memory pointed at in a specific ordering.
|
||||
* only use this definition, makes little and big endian systems
|
||||
* work fine, in conjunction with MAKE_ID */
|
||||
@@ -204,7 +220,7 @@ void BKE_lib_id_clear_library_data(Main *bmain, ID *id)
|
||||
void id_lib_extern(ID *id)
|
||||
{
|
||||
if (id && ID_IS_LINKED(id)) {
|
||||
BLI_assert(BKE_idcode_is_linkable(GS(id->name)));
|
||||
BLI_assert(BKE_idtype_idcode_is_linkable(GS(id->name)));
|
||||
if (id->tag & LIB_TAG_INDIRECT) {
|
||||
id->tag &= ~LIB_TAG_INDIRECT;
|
||||
id->flag &= ~LIB_INDIRECT_WEAK_LINK;
|
||||
@@ -217,7 +233,7 @@ void id_lib_extern(ID *id)
|
||||
void id_lib_indirect_weak_link(ID *id)
|
||||
{
|
||||
if (id && ID_IS_LINKED(id)) {
|
||||
BLI_assert(BKE_idcode_is_linkable(GS(id->name)));
|
||||
BLI_assert(BKE_idtype_idcode_is_linkable(GS(id->name)));
|
||||
if (id->tag & LIB_TAG_INDIRECT) {
|
||||
id->flag |= LIB_INDIRECT_WEAK_LINK;
|
||||
}
|
||||
@@ -355,7 +371,8 @@ static int lib_id_expand_local_cb(LibraryIDLinkCallbackData *cb_data)
|
||||
* (through drivers)...
|
||||
* Just skip it, shape key can only be either indirectly linked, or fully local, period.
|
||||
* And let's curse one more time that stupid useless shapekey ID type! */
|
||||
if (*id_pointer && *id_pointer != id_self && BKE_idcode_is_linkable(GS((*id_pointer)->name))) {
|
||||
if (*id_pointer && *id_pointer != id_self &&
|
||||
BKE_idtype_idcode_is_linkable(GS((*id_pointer)->name))) {
|
||||
id_lib_extern(*id_pointer);
|
||||
}
|
||||
|
||||
@@ -1154,7 +1171,7 @@ void *BKE_id_new(Main *bmain, const short type, const char *name)
|
||||
BLI_assert(bmain != NULL);
|
||||
|
||||
if (name == NULL) {
|
||||
name = DATA_(BKE_idcode_to_name(type));
|
||||
name = DATA_(BKE_idtype_idcode_to_name(type));
|
||||
}
|
||||
|
||||
ID *id = BKE_libblock_alloc(bmain, type, name, 0);
|
||||
@@ -1171,7 +1188,7 @@ void *BKE_id_new(Main *bmain, const short type, const char *name)
|
||||
void *BKE_id_new_nomain(const short type, const char *name)
|
||||
{
|
||||
if (name == NULL) {
|
||||
name = DATA_(BKE_idcode_to_name(type));
|
||||
name = DATA_(BKE_idtype_idcode_to_name(type));
|
||||
}
|
||||
|
||||
ID *id = BKE_libblock_alloc(NULL,
|
||||
@@ -1670,7 +1687,7 @@ bool BKE_id_new_name_validate(ListBase *lb, ID *id, const char *tname)
|
||||
|
||||
if (name[0] == '\0') {
|
||||
/* Disallow empty names. */
|
||||
BLI_strncpy(name, DATA_(BKE_idcode_to_name(GS(id->name))), sizeof(name));
|
||||
BLI_strncpy(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))), sizeof(name));
|
||||
}
|
||||
else {
|
||||
/* disallow non utf8 chars,
|
||||
@@ -1875,7 +1892,7 @@ void BKE_library_make_local(Main *bmain,
|
||||
|
||||
/* Do not explicitly make local non-linkable IDs (shapekeys, in fact),
|
||||
* they are assumed to be handled by real data-blocks responsible of them. */
|
||||
const bool do_skip = (id && !BKE_idcode_is_linkable(GS(id->name)));
|
||||
const bool do_skip = (id && !BKE_idtype_idcode_is_linkable(GS(id->name)));
|
||||
|
||||
for (; id; id = id->next) {
|
||||
ID *ntree = (ID *)ntreeFromID(id);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_main_idmap.h" /* own include */
|
||||
@@ -110,7 +110,7 @@ struct IDNameLib_Map *BKE_main_idmap_create(struct Main *bmain,
|
||||
while (index < MAX_LIBARRAY) {
|
||||
struct IDNameLib_TypeMap *type_map = &id_map->type_maps[index];
|
||||
type_map->map = NULL;
|
||||
type_map->id_type = BKE_idcode_iter_step(&index);
|
||||
type_map->id_type = BKE_idtype_idcode_iter_step(&index);
|
||||
BLI_assert(type_map->id_type != 0);
|
||||
}
|
||||
BLI_assert(index == MAX_LIBARRAY);
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_lib_id.h"
|
||||
@@ -672,7 +671,8 @@ static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
|
||||
Mesh *BKE_mesh_new_nomain(
|
||||
int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
|
||||
{
|
||||
Mesh *mesh = BKE_libblock_alloc(NULL, ID_ME, BKE_idcode_to_name(ID_ME), LIB_ID_COPY_LOCALIZE);
|
||||
Mesh *mesh = BKE_libblock_alloc(
|
||||
NULL, ID_ME, BKE_idtype_idcode_to_name(ID_ME), LIB_ID_COPY_LOCALIZE);
|
||||
BKE_libblock_init_empty(&mesh->id);
|
||||
|
||||
/* don't use CustomData_reset(...); because we dont want to touch customdata */
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "BKE_appdir.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_lib_query.h"
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "DNA_genfile.h"
|
||||
#include "DNA_sdna_types.h"
|
||||
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "BLO_blend_defs.h"
|
||||
@@ -268,9 +268,9 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
|
||||
if (bhead->code == ENDB) {
|
||||
break;
|
||||
}
|
||||
else if (BKE_idcode_is_valid(bhead->code)) {
|
||||
if (BKE_idcode_is_linkable(bhead->code)) {
|
||||
const char *str = BKE_idcode_to_name(bhead->code);
|
||||
else if (BKE_idtype_idcode_is_valid(bhead->code)) {
|
||||
if (BKE_idtype_idcode_is_linkable(bhead->code)) {
|
||||
const char *str = BKE_idtype_idcode_to_name(bhead->code);
|
||||
|
||||
if (BLI_gset_add(gathered, (void *)str)) {
|
||||
BLI_linklist_prepend(&names, strdup(str));
|
||||
|
||||
@@ -122,8 +122,8 @@
|
||||
#include "BKE_global.h" // for G
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_hair.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_lib_override.h"
|
||||
@@ -629,7 +629,8 @@ static void read_file_bhead_idname_map_create(FileData *fd)
|
||||
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
|
||||
if (code_prev != bhead->code) {
|
||||
code_prev = bhead->code;
|
||||
is_link = BKE_idcode_is_valid(code_prev) ? BKE_idcode_is_linkable(code_prev) : false;
|
||||
is_link = BKE_idtype_idcode_is_valid(code_prev) ? BKE_idtype_idcode_is_linkable(code_prev) :
|
||||
false;
|
||||
}
|
||||
|
||||
if (is_link) {
|
||||
@@ -644,7 +645,8 @@ static void read_file_bhead_idname_map_create(FileData *fd)
|
||||
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
|
||||
if (code_prev != bhead->code) {
|
||||
code_prev = bhead->code;
|
||||
is_link = BKE_idcode_is_valid(code_prev) ? BKE_idcode_is_linkable(code_prev) : false;
|
||||
is_link = BKE_idtype_idcode_is_valid(code_prev) ? BKE_idtype_idcode_is_linkable(code_prev) :
|
||||
false;
|
||||
}
|
||||
|
||||
if (is_link) {
|
||||
@@ -11781,7 +11783,7 @@ static ID *link_named_part(
|
||||
const bool use_placeholders = (flag & BLO_LIBLINK_USE_PLACEHOLDERS) != 0;
|
||||
const bool force_indirect = (flag & BLO_LIBLINK_FORCE_INDIRECT) != 0;
|
||||
|
||||
BLI_assert(BKE_idcode_is_linkable(idcode) && BKE_idcode_is_valid(idcode));
|
||||
BLI_assert(BKE_idtype_idcode_is_linkable(idcode) && BKE_idtype_idcode_is_valid(idcode));
|
||||
|
||||
if (bhead) {
|
||||
id = is_yet_read(fd, mainl, bhead);
|
||||
@@ -11840,9 +11842,9 @@ int BLO_library_link_copypaste(Main *mainl, BlendHandle *bh, const uint64_t id_t
|
||||
break;
|
||||
}
|
||||
|
||||
if (BKE_idcode_is_valid(bhead->code) && BKE_idcode_is_linkable(bhead->code) &&
|
||||
if (BKE_idtype_idcode_is_valid(bhead->code) && BKE_idtype_idcode_is_linkable(bhead->code) &&
|
||||
(id_types_mask == 0 ||
|
||||
(BKE_idcode_to_idfilter((short)bhead->code) & id_types_mask) != 0)) {
|
||||
(BKE_idtype_idcode_to_idfilter((short)bhead->code) & id_types_mask) != 0)) {
|
||||
read_libblock(fd, mainl, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, false, &id);
|
||||
num_directly_linked++;
|
||||
}
|
||||
@@ -12154,7 +12156,8 @@ static void read_library_linked_id(
|
||||
ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id)
|
||||
{
|
||||
BHead *bhead = NULL;
|
||||
const bool is_valid = BKE_idcode_is_linkable(GS(id->name)) || ((id->tag & LIB_TAG_EXTERN) == 0);
|
||||
const bool is_valid = BKE_idtype_idcode_is_linkable(GS(id->name)) ||
|
||||
((id->tag & LIB_TAG_EXTERN) == 0);
|
||||
|
||||
if (fd) {
|
||||
bhead = find_bhead_from_idname(fd, id->name);
|
||||
@@ -12165,7 +12168,7 @@ static void read_library_linked_id(
|
||||
RPT_ERROR,
|
||||
TIP_("LIB: %s: '%s' is directly linked from '%s' (parent '%s'), but is a "
|
||||
"non-linkable data type"),
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2,
|
||||
mainvar->curlib->filepath,
|
||||
library_parent_filepath(mainvar->curlib));
|
||||
@@ -12183,7 +12186,7 @@ static void read_library_linked_id(
|
||||
blo_reportf_wrap(reports,
|
||||
RPT_WARNING,
|
||||
TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"),
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2,
|
||||
mainvar->curlib->filepath,
|
||||
library_parent_filepath(mainvar->curlib));
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h" // for G
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_override.h"
|
||||
#include "BKE_main.h"
|
||||
@@ -3861,7 +3861,7 @@ static void write_libraries(WriteData *wd, Main *main)
|
||||
if (id->us > 0 &&
|
||||
((id->tag & LIB_TAG_EXTERN) ||
|
||||
((id->tag & LIB_TAG_INDIRECT) && (id->flag & LIB_INDIRECT_WEAK_LINK)))) {
|
||||
if (!BKE_idcode_is_linkable(GS(id->name))) {
|
||||
if (!BKE_idtype_idcode_is_linkable(GS(id->name))) {
|
||||
printf(
|
||||
"ERROR: write file: data-block '%s' from lib '%s' is not linkable "
|
||||
"but is flagged as directly linked",
|
||||
|
||||
@@ -76,7 +76,7 @@ extern "C" {
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_lattice.h"
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_scene.h"
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ IDNode *Depsgraph::add_id_node(ID *id, ID *id_cow_hint)
|
||||
BLI_ghash_insert(id_hash, id, id_node);
|
||||
id_nodes.push_back(id_node);
|
||||
|
||||
id_type_exist[BKE_idcode_to_index(GS(id->name))] = 1;
|
||||
id_type_exist[BKE_idtype_idcode_to_index(GS(id->name))] = 1;
|
||||
}
|
||||
return id_node;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ extern "C" {
|
||||
|
||||
#include "BKE_action.h" // XXX: BKE_pose_channel_find_name
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
} /* extern "C" */
|
||||
@@ -78,7 +78,7 @@ float DEG_get_ctime(const Depsgraph *graph)
|
||||
bool DEG_id_type_updated(const Depsgraph *graph, short id_type)
|
||||
{
|
||||
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
|
||||
return deg_graph->id_type_updated[BKE_idcode_to_index(id_type)] != 0;
|
||||
return deg_graph->id_type_updated[BKE_idtype_idcode_to_index(id_type)] != 0;
|
||||
}
|
||||
|
||||
bool DEG_id_type_any_updated(const Depsgraph *graph)
|
||||
@@ -98,7 +98,7 @@ bool DEG_id_type_any_updated(const Depsgraph *graph)
|
||||
bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type)
|
||||
{
|
||||
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph);
|
||||
return deg_graph->id_type_exist[BKE_idcode_to_index(id_type)] != 0;
|
||||
return deg_graph->id_type_exist[BKE_idtype_idcode_to_index(id_type)] != 0;
|
||||
}
|
||||
|
||||
uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
|
||||
|
||||
@@ -46,7 +46,7 @@ extern "C" {
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_workspace.h"
|
||||
@@ -777,7 +777,7 @@ void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type)
|
||||
DEG_graph_id_type_tag(depsgraph, ID_WO);
|
||||
DEG_graph_id_type_tag(depsgraph, ID_SCE);
|
||||
}
|
||||
const int id_type_index = BKE_idcode_to_index(id_type);
|
||||
const int id_type_index = BKE_idtype_idcode_to_index(id_type);
|
||||
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
|
||||
deg_graph->id_type_updated[id_type_index] = 1;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_material.h"
|
||||
@@ -1657,7 +1657,7 @@ int delete_keyframe(Main *bmain,
|
||||
RPT_WARNING,
|
||||
"Not deleting keyframe for locked F-Curve '%s' for %s '%s'",
|
||||
fcu->rna_path,
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2);
|
||||
continue;
|
||||
}
|
||||
@@ -1761,7 +1761,7 @@ static int clear_keyframe(Main *bmain,
|
||||
RPT_WARNING,
|
||||
"Not clearing all keyframes from locked F-Curve '%s' for %s '%s'",
|
||||
fcu->rna_path,
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2);
|
||||
continue;
|
||||
}
|
||||
@@ -2567,7 +2567,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
|
||||
RPT_WARNING,
|
||||
"Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
|
||||
strip->name,
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
@@ -115,7 +115,7 @@ static int datadropper_init(bContext *C, wmOperator *op)
|
||||
BLI_assert(ddr->idcode != 0);
|
||||
/* Note we can translate here (instead of on draw time),
|
||||
* because this struct has very short lifetime. */
|
||||
ddr->idcode_name = TIP_(BKE_idcode_to_name(ddr->idcode));
|
||||
ddr->idcode_name = TIP_(BKE_idtype_idcode_to_name(ddr->idcode));
|
||||
|
||||
PointerRNA ptr = RNA_property_pointer_get(&ddr->ptr, ddr->prop);
|
||||
ddr->init_id = ptr.owner_id;
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#include "BKE_curveprofile.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_id.h"
|
||||
@@ -687,7 +687,7 @@ static const char *template_id_browse_tip(const StructRNA *type)
|
||||
static const char *template_id_context(StructRNA *type)
|
||||
{
|
||||
if (type) {
|
||||
return BKE_idcode_to_translation_context(RNA_type_to_ID_code(type));
|
||||
return BKE_idtype_idcode_to_translation_context(RNA_type_to_ID_code(type));
|
||||
}
|
||||
return BLT_I18NCONTEXT_DEFAULT;
|
||||
}
|
||||
@@ -2779,7 +2779,7 @@ void uiTemplatePreview(uiLayout *layout,
|
||||
|
||||
if (!preview_id || (preview_id[0] == '\0')) {
|
||||
/* If no identifier given, generate one from ID type. */
|
||||
BLI_snprintf(_preview_id, UI_MAX_NAME_STR, "uiPreview_%s", BKE_idcode_to_name(GS(id->name)));
|
||||
BLI_snprintf(_preview_id, UI_MAX_NAME_STR, "uiPreview_%s", BKE_idtype_idcode_to_name(GS(id->name)));
|
||||
preview_id = _preview_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_lattice.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_id.h"
|
||||
@@ -639,7 +639,7 @@ static int apply_objects_internal(bContext *C,
|
||||
RPT_ERROR,
|
||||
"Cannot apply to a multi user: Object \"%s\", %s \"%s\", aborting",
|
||||
ob->id.name + 2,
|
||||
BKE_idcode_to_name(GS(obdata->name)),
|
||||
BKE_idtype_idcode_to_name(GS(obdata->name)),
|
||||
obdata->name + 2);
|
||||
changed = false;
|
||||
}
|
||||
@@ -649,7 +649,7 @@ static int apply_objects_internal(bContext *C,
|
||||
RPT_ERROR,
|
||||
"Cannot apply to library data: Object \"%s\", %s \"%s\", aborting",
|
||||
ob->id.name + 2,
|
||||
BKE_idcode_to_name(GS(obdata->name)),
|
||||
BKE_idtype_idcode_to_name(GS(obdata->name)),
|
||||
obdata->name + 2);
|
||||
changed = false;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ static int apply_objects_internal(bContext *C,
|
||||
RPT_ERROR,
|
||||
"Rotation/Location can't apply to a 2D curve: Object \"%s\", %s \"%s\", aborting",
|
||||
ob->id.name + 2,
|
||||
BKE_idcode_to_name(GS(obdata->name)),
|
||||
BKE_idtype_idcode_to_name(GS(obdata->name)),
|
||||
obdata->name + 2);
|
||||
changed = false;
|
||||
}
|
||||
@@ -676,7 +676,7 @@ static int apply_objects_internal(bContext *C,
|
||||
RPT_ERROR,
|
||||
"Can't apply to a curve with shape-keys: Object \"%s\", %s \"%s\", aborting",
|
||||
ob->id.name + 2,
|
||||
BKE_idcode_to_name(GS(obdata->name)),
|
||||
BKE_idtype_idcode_to_name(GS(obdata->name)),
|
||||
obdata->name + 2);
|
||||
changed = false;
|
||||
}
|
||||
@@ -712,7 +712,7 @@ static int apply_objects_internal(bContext *C,
|
||||
"Can't apply to a GP datablock where all layers are parented: Object "
|
||||
"\"%s\", %s \"%s\", aborting",
|
||||
ob->id.name + 2,
|
||||
BKE_idcode_to_name(ID_GD),
|
||||
BKE_idtype_idcode_to_name(ID_GD),
|
||||
gpd->id.name + 2);
|
||||
changed = false;
|
||||
}
|
||||
@@ -724,7 +724,7 @@ static int apply_objects_internal(bContext *C,
|
||||
RPT_ERROR,
|
||||
"Can't apply to GP datablock with no layers: Object \"%s\", %s \"%s\", aborting",
|
||||
ob->id.name + 2,
|
||||
BKE_idcode_to_name(ID_GD),
|
||||
BKE_idtype_idcode_to_name(ID_GD),
|
||||
gpd->id.name + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_icons.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BLO_readfile.h"
|
||||
|
||||
@@ -2454,14 +2454,14 @@ static int groupname_to_code(const char *group)
|
||||
lslash[0] = '\0';
|
||||
}
|
||||
|
||||
return buf[0] ? BKE_idcode_from_name(buf) : 0;
|
||||
return buf[0] ? BKE_idtype_idcode_from_name(buf) : 0;
|
||||
}
|
||||
|
||||
static uint64_t groupname_to_filter_id(const char *group)
|
||||
{
|
||||
int id_code = groupname_to_code(group);
|
||||
|
||||
return BKE_idcode_to_idfilter(id_code);
|
||||
return BKE_idtype_idcode_to_idfilter(id_code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_library.h"
|
||||
@@ -2827,7 +2827,7 @@ int tree_element_id_type_to_index(TreeElement *te)
|
||||
{
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
const int id_index = tselem->type == 0 ? BKE_idcode_to_index(te->idcode) : INDEX_ID_GR;
|
||||
const int id_index = tselem->type == 0 ? BKE_idtype_idcode_to_index(te->idcode) : INDEX_ID_GR;
|
||||
if (id_index < INDEX_ID_OB) {
|
||||
return id_index;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "BKE_blender_copybuffer.h"
|
||||
#include "BKE_collection.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_lib_query.h"
|
||||
@@ -2194,7 +2194,7 @@ static void outliner_orphans_purge_tag(ID *id, int *num_tagged)
|
||||
if (id->us == 0) {
|
||||
id->tag |= LIB_TAG_DOIT;
|
||||
num_tagged[INDEX_ID_NULL]++;
|
||||
num_tagged[BKE_idcode_to_index(GS(id->name))]++;
|
||||
num_tagged[BKE_idtype_idcode_to_index(GS(id->name))]++;
|
||||
}
|
||||
else {
|
||||
id->tag &= ~LIB_TAG_DOIT;
|
||||
@@ -2233,7 +2233,7 @@ static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEv
|
||||
BLI_dynstr_appendf(dyn_str,
|
||||
"%d %s",
|
||||
num_tagged[i],
|
||||
TIP_(BKE_idcode_to_name_plural(BKE_idcode_from_index(i))));
|
||||
TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))));
|
||||
}
|
||||
}
|
||||
BLI_dynstr_append(dyn_str, TIP_("). Click here to proceed..."));
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
@@ -1237,7 +1237,7 @@ static void outliner_add_seq_dup(SpaceOutliner *soops, Sequence *seq, TreeElemen
|
||||
|
||||
static const char *outliner_idcode_to_plural(short idcode)
|
||||
{
|
||||
const char *propname = BKE_idcode_to_name_plural(idcode);
|
||||
const char *propname = BKE_idtype_idcode_to_name_plural(idcode);
|
||||
PropertyRNA *prop = RNA_struct_type_find_property(&RNA_BlendData, propname);
|
||||
return (prop) ? RNA_property_ui_name(prop) : "UNKNOWN";
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "BLO_readfile.h"
|
||||
|
||||
#include "BKE_icons.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "DNA_ID.h" /* For preview images... */
|
||||
@@ -47,7 +47,7 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const
|
||||
if (blen_group && blen_id) {
|
||||
LinkNode *ln, *names, *lp, *previews = NULL;
|
||||
struct BlendHandle *libfiledata = BLO_blendhandle_from_file(blen_path, NULL);
|
||||
int idcode = BKE_idcode_from_name(blen_group);
|
||||
int idcode = BKE_idtype_idcode_from_name(blen_group);
|
||||
int i, nprevs, nnames;
|
||||
|
||||
if (libfiledata == NULL) {
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
#include "BKE_collection.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_report.h"
|
||||
@@ -6116,7 +6116,7 @@ char *RNA_path_full_ID_py(Main *bmain, ID *id)
|
||||
BLI_strescape(id_esc, id->name + 2, sizeof(id_esc));
|
||||
|
||||
return BLI_sprintfN("bpy.data.%s[\"%s\"]%s%s",
|
||||
BKE_idcode_to_name_plural(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name_plural(GS(id->name)),
|
||||
id_esc,
|
||||
path[0] ? "." : "",
|
||||
path);
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
# include "BKE_gpencil.h"
|
||||
# include "BKE_hair.h"
|
||||
# include "BKE_icons.h"
|
||||
# include "BKE_idcode.h"
|
||||
# include "BKE_idtype.h"
|
||||
# include "BKE_image.h"
|
||||
# include "BKE_lattice.h"
|
||||
# include "BKE_lib_remap.h"
|
||||
@@ -135,7 +135,7 @@ static void rna_Main_ID_remove(Main *bmain,
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
"%s '%s' is outside of main database and can not be removed from it",
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2);
|
||||
return;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ static void rna_Main_ID_remove(Main *bmain,
|
||||
reports,
|
||||
RPT_ERROR,
|
||||
"%s '%s' must have zero users to be removed, found %d (try with do_unlink=True parameter)",
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2,
|
||||
ID_REAL_USERS(id));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_report.h"
|
||||
@@ -246,9 +246,9 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
|
||||
}
|
||||
else {
|
||||
int i = 0, code;
|
||||
while ((code = BKE_idcode_iter_step(&i))) {
|
||||
if (BKE_idcode_is_linkable(code)) {
|
||||
const char *name_plural = BKE_idcode_to_name_plural(code);
|
||||
while ((code = BKE_idtype_idcode_iter_step(&i))) {
|
||||
if (BKE_idtype_idcode_is_linkable(code)) {
|
||||
const char *name_plural = BKE_idtype_idcode_to_name_plural(code);
|
||||
PyObject *str = PyUnicode_FromString(name_plural);
|
||||
PyObject *item;
|
||||
|
||||
@@ -332,9 +332,9 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
|
||||
{
|
||||
int idcode_step = 0, idcode;
|
||||
while ((idcode = BKE_idcode_iter_step(&idcode_step))) {
|
||||
if (BKE_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
|
||||
const char *name_plural = BKE_idcode_to_name_plural(idcode);
|
||||
while ((idcode = BKE_idtype_idcode_iter_step(&idcode_step))) {
|
||||
if (BKE_idtype_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
|
||||
const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode);
|
||||
PyObject *ls = PyDict_GetItemString(self->dict, name_plural);
|
||||
// printf("lib: %s\n", name_plural);
|
||||
if (ls && PyList_Check(ls)) {
|
||||
@@ -419,9 +419,9 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
#ifdef USE_RNA_DATABLOCKS
|
||||
{
|
||||
int idcode_step = 0, idcode;
|
||||
while ((idcode = BKE_idcode_iter_step(&idcode_step))) {
|
||||
if (BKE_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
|
||||
const char *name_plural = BKE_idcode_to_name_plural(idcode);
|
||||
while ((idcode = BKE_idtype_idcode_iter_step(&idcode_step))) {
|
||||
if (BKE_idtype_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
|
||||
const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode);
|
||||
PyObject *ls = PyDict_GetItemString(self->dict, name_plural);
|
||||
if (ls && PyList_Check(ls)) {
|
||||
Py_ssize_t size = PyList_GET_SIZE(ls);
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h" /* evil G.* */
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
@@ -315,7 +315,7 @@ static bool rna_id_write_error(PointerRNA *ptr, PyObject *key)
|
||||
const short idcode = GS(id->name);
|
||||
/* May need more ID types added here. */
|
||||
if (!ELEM(idcode, ID_WM, ID_SCR, ID_WS)) {
|
||||
const char *idtype = BKE_idcode_to_name(idcode);
|
||||
const char *idtype = BKE_idtype_idcode_to_name(idcode);
|
||||
const char *pyname;
|
||||
if (key && PyUnicode_Check(key)) {
|
||||
pyname = _PyUnicode_AsString(key);
|
||||
@@ -921,11 +921,12 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
|
||||
tmp_str = PyUnicode_FromString(id->name + 2);
|
||||
|
||||
if (DEG_get_original_id(id) != id) {
|
||||
ret = PyUnicode_FromFormat("Evaluated %s %R", BKE_idcode_to_name(GS(id->name)), tmp_str);
|
||||
ret = PyUnicode_FromFormat(
|
||||
"Evaluated %s %R", BKE_idtype_idcode_to_name(GS(id->name)), tmp_str);
|
||||
}
|
||||
else if (RNA_struct_is_ID(self->ptr.type) && (id->flag & LIB_EMBEDDED_DATA) == 0) {
|
||||
ret = PyUnicode_FromFormat(
|
||||
"bpy.data.%s[%R]", BKE_idcode_to_name_plural(GS(id->name)), tmp_str);
|
||||
"bpy.data.%s[%R]", BKE_idtype_idcode_to_name_plural(GS(id->name)), tmp_str);
|
||||
}
|
||||
else {
|
||||
const char *path;
|
||||
@@ -940,13 +941,15 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
|
||||
if (real_id != NULL) {
|
||||
Py_DECREF(tmp_str);
|
||||
tmp_str = PyUnicode_FromString(real_id->name + 2);
|
||||
ret = PyUnicode_FromFormat(
|
||||
"bpy.data.%s[%R].%s", BKE_idcode_to_name_plural(GS(real_id->name)), tmp_str, path);
|
||||
ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
|
||||
BKE_idtype_idcode_to_name_plural(GS(real_id->name)),
|
||||
tmp_str,
|
||||
path);
|
||||
}
|
||||
else {
|
||||
/* Can't find the path, print something useful as a fallback. */
|
||||
ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
|
||||
BKE_idcode_to_name_plural(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name_plural(GS(id->name)),
|
||||
tmp_str,
|
||||
RNA_struct_identifier(self->ptr.type));
|
||||
}
|
||||
@@ -955,7 +958,7 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
|
||||
else {
|
||||
/* Can't find the path, print something useful as a fallback. */
|
||||
ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
|
||||
BKE_idcode_to_name_plural(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name_plural(GS(id->name)),
|
||||
tmp_str,
|
||||
RNA_struct_identifier(self->ptr.type));
|
||||
}
|
||||
@@ -1062,7 +1065,7 @@ static PyObject *pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim,
|
||||
}
|
||||
const char *data_delim = (path[0] == '[') ? "" : ".";
|
||||
ret = PyUnicode_FromFormat("bpy.data.%s[%R]%s%s",
|
||||
BKE_idcode_to_name_plural(GS(real_id->name)),
|
||||
BKE_idtype_idcode_to_name_plural(GS(real_id->name)),
|
||||
tmp_str,
|
||||
data_delim,
|
||||
path);
|
||||
@@ -1072,7 +1075,7 @@ static PyObject *pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim,
|
||||
else {
|
||||
/* Can't find the path, print something useful as a fallback. */
|
||||
ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
|
||||
BKE_idcode_to_name_plural(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name_plural(GS(id->name)),
|
||||
tmp_str,
|
||||
RNA_property_identifier(self->prop));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
@@ -473,7 +473,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
RPT_WARNING,
|
||||
"Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
|
||||
strip->name,
|
||||
BKE_idcode_to_name(GS(id->name)),
|
||||
BKE_idtype_idcode_to_name(GS(id->name)),
|
||||
id->name + 2);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
|
||||
#include "GPU_glew.h"
|
||||
#include "GPU_shader.h"
|
||||
@@ -357,7 +357,7 @@ static const char *wm_drag_name(wmDrag *drag)
|
||||
return id->name + 2;
|
||||
}
|
||||
else if (id) {
|
||||
return BKE_idcode_to_name_plural(GS(id->name));
|
||||
return BKE_idtype_idcode_to_name_plural(GS(id->name));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_build.h"
|
||||
@@ -304,11 +304,11 @@ static bool wm_link_append_item_poll(ReportList *reports,
|
||||
return false;
|
||||
}
|
||||
|
||||
idcode = BKE_idcode_from_name(group);
|
||||
idcode = BKE_idtype_idcode_from_name(group);
|
||||
|
||||
/* XXX For now, we do a nasty exception for workspace, forbid linking them.
|
||||
* Not nice, ultimately should be solved! */
|
||||
if (!BKE_idcode_is_linkable(idcode) && (do_append || idcode != ID_WS)) {
|
||||
if (!BKE_idtype_idcode_is_linkable(idcode) && (do_append || idcode != ID_WS)) {
|
||||
if (reports) {
|
||||
if (do_append) {
|
||||
BKE_reportf(reports,
|
||||
@@ -444,7 +444,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
|
||||
lib_idx = POINTER_AS_INT(BLI_ghash_lookup(libraries, libname));
|
||||
|
||||
item = wm_link_append_data_item_add(lapp_data, name, BKE_idcode_from_name(group), NULL);
|
||||
item = wm_link_append_data_item_add(
|
||||
lapp_data, name, BKE_idtype_idcode_from_name(group), NULL);
|
||||
BLI_BITMAP_ENABLE(item->libraries, lib_idx);
|
||||
}
|
||||
}
|
||||
@@ -456,7 +457,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
WMLinkAppendDataItem *item;
|
||||
|
||||
wm_link_append_data_library_add(lapp_data, libname);
|
||||
item = wm_link_append_data_item_add(lapp_data, name, BKE_idcode_from_name(group), NULL);
|
||||
item = wm_link_append_data_item_add(lapp_data, name, BKE_idtype_idcode_from_name(group), NULL);
|
||||
BLI_BITMAP_ENABLE(item->libraries, 0);
|
||||
}
|
||||
|
||||
@@ -703,7 +704,7 @@ static void lib_relocate_do(Main *bmain,
|
||||
ID *id = lbarray[lba_idx]->first;
|
||||
const short idcode = id ? GS(id->name) : 0;
|
||||
|
||||
if (!id || !BKE_idcode_is_linkable(idcode)) {
|
||||
if (!id || !BKE_idtype_idcode_is_linkable(idcode)) {
|
||||
/* No need to reload non-linkable datatypes,
|
||||
* those will get relinked with their 'users ID'. */
|
||||
continue;
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
#include "BKE_screen.h" /* BKE_ST_MAXNAME */
|
||||
#include "BKE_unit.h"
|
||||
|
||||
#include "BKE_idcode.h"
|
||||
#include "BKE_idtype.h"
|
||||
|
||||
#include "BLF_api.h"
|
||||
|
||||
@@ -1256,7 +1256,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
|
||||
BKE_reportf(op->reports,
|
||||
RPT_ERROR,
|
||||
"Cannot read %s '%s': %s",
|
||||
BKE_idcode_to_name(idcode),
|
||||
BKE_idtype_idcode_to_name(idcode),
|
||||
path,
|
||||
errno ? strerror(errno) : TIP_("unsupported format"));
|
||||
return NULL;
|
||||
@@ -1278,7 +1278,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
id = BKE_libblock_find_name(bmain, idcode, name);
|
||||
if (!id) {
|
||||
BKE_reportf(op->reports, RPT_ERROR, "%s '%s' not found", BKE_idcode_to_name(idcode), name);
|
||||
BKE_reportf(op->reports, RPT_ERROR, "%s '%s' not found", BKE_idtype_idcode_to_name(idcode), name);
|
||||
return NULL;
|
||||
}
|
||||
id_us_plus(id);
|
||||
@@ -3511,12 +3511,12 @@ static int previews_clear_exec(bContext *C, wmOperator *op)
|
||||
printf("%s: %d, %d, %d -> %d\n",
|
||||
id->name,
|
||||
GS(id->name),
|
||||
BKE_idcode_to_idfilter(GS(id->name)),
|
||||
BKE_idtype_idcode_to_idfilter(GS(id->name)),
|
||||
id_filters,
|
||||
BKE_idcode_to_idfilter(GS(id->name)) & id_filters);
|
||||
BKE_idtype_idcode_to_idfilter(GS(id->name)) & id_filters);
|
||||
#endif
|
||||
|
||||
if (!(BKE_idcode_to_idfilter(GS(id->name)) & id_filters)) {
|
||||
if (!(BKE_idtype_idcode_to_idfilter(GS(id->name)) & id_filters)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user