Blender  V2.93
Macros | Functions | Variables
idtype.c File Reference
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
#include "BLI_utildefines.h"
#include "CLG_log.h"
#include "BLT_translation.h"
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_idtype.h"

Go to the source code of this file.

Macros

#define INIT_TYPE(_id_code)
 
#define CASE_IDFILTER(_id)
 
#define CASE_IDFILTER(_id)
 
#define CASE_IDINDEX(_id)
 
#define CASE_IDCODE(_id)
 

Functions

uint BKE_idtype_cache_key_hash (const void *key_v)
 
bool BKE_idtype_cache_key_cmp (const void *key_a_v, const void *key_b_v)
 
static void id_type_init (void)
 
void BKE_idtype_init (void)
 
const IDTypeInfoBKE_idtype_get_info_from_idcode (const short id_code)
 
const IDTypeInfoBKE_idtype_get_info_from_id (const ID *id)
 
static const IDTypeInfoidtype_get_info_from_name (const char *idtype_name)
 
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)
 
short BKE_idtype_idcode_from_name (const char *idtype_name)
 
bool BKE_idtype_idcode_is_valid (const short idcode)
 
bool BKE_idtype_idcode_is_linkable (const short idcode)
 
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)
 
void BKE_idtype_id_foreach_cache (struct ID *id, IDTypeForeachCacheFunctionCallback function_callback, void *user_data)
 

Variables

static IDTypeInfoid_types [INDEX_ID_MAX] = {NULL}
 

Macro Definition Documentation

◆ CASE_IDCODE

#define CASE_IDCODE (   _id)
Value:
case INDEX_ID_##_id: \
return ID_##_id

◆ CASE_IDFILTER [1/2]

#define CASE_IDFILTER (   _id)
Value:
case ID_##_id: \
return FILTER_ID_##_id

◆ CASE_IDFILTER [2/2]

#define CASE_IDFILTER (   _id)
Value:
case FILTER_ID_##_id: \
return ID_##_id

◆ CASE_IDINDEX

#define CASE_IDINDEX (   _id)
Value:
case ID_##_id: \
return INDEX_ID_##_id

◆ INIT_TYPE

#define INIT_TYPE (   _id_code)
Value:
{ \
BLI_assert(IDType_##_id_code.main_listbase_index == INDEX_##_id_code); \
id_types[INDEX_##_id_code] = &IDType_##_id_code; \
} \
(void)0

Function Documentation

◆ BKE_idtype_cache_key_cmp()

bool BKE_idtype_cache_key_cmp ( const void *  key_a_v,
const void *  key_b_v 
)

◆ BKE_idtype_cache_key_hash()

uint BKE_idtype_cache_key_hash ( const void *  key_v)

◆ BKE_idtype_get_info_from_id()

const IDTypeInfo* BKE_idtype_get_info_from_id ( const ID id)

Definition at line 143 of file idtype.c.

References BKE_idtype_get_info_from_idcode(), GS, id, and ID::name.

Referenced by BKE_idtype_id_foreach_cache().

◆ BKE_idtype_get_info_from_idcode()

const IDTypeInfo* BKE_idtype_get_info_from_idcode ( const short  id_code)

◆ BKE_idtype_id_foreach_cache()

void BKE_idtype_id_foreach_cache ( struct ID id,
IDTypeForeachCacheFunctionCallback  function_callback,
void *  user_data 
)

◆ BKE_idtype_idcode_from_idfilter()

short BKE_idtype_idcode_from_idfilter ( const uint64_t  idfilter)

Convert an idfilter into an idcode (e.g. FILTER_ID_OB -> ID_OB).

Definition at line 294 of file idtype.c.

References BR, CASE_IDFILTER, and LT.

◆ BKE_idtype_idcode_from_index()

short BKE_idtype_idcode_from_index ( const int  index)

◆ BKE_idtype_idcode_from_name()

short BKE_idtype_idcode_from_name ( const char *  idtype_name)

Convert an ID-type name into an idcode (ie. ID_SCE)

Parameters
idtype_nameThe ID-type's "user visible name" to convert.
Returns
The idcode for the name, or 0 if invalid.

Definition at line 208 of file idtype.c.

References BLI_assert, IDTypeInfo::id_code, idtype_get_info_from_name(), and NULL.

Referenced by groupname_to_code(), IMB_thumb_load_blend(), wm_link_append_exec(), and wm_link_append_item_poll().

◆ BKE_idtype_idcode_is_linkable()

bool BKE_idtype_idcode_is_linkable ( const short  idcode)

◆ BKE_idtype_idcode_is_valid()

bool BKE_idtype_idcode_is_valid ( const short  idcode)

Return if the ID code is a valid ID code.

Parameters
idcodeThe code to check.
Returns
Boolean, 0 when invalid.

Definition at line 221 of file idtype.c.

References BKE_idtype_get_info_from_idcode(), and NULL.

Referenced by blo_bhead_is_id_valid_type(), BLO_blendhandle_get_linkable_groups(), and link_named_part().

◆ BKE_idtype_idcode_iter_step()

short BKE_idtype_idcode_iter_step ( int *  index)

Return an ID code and steps the index forward 1.

Parameters
indexstart as 0.
Returns
the code, 0 when all codes have been returned.

Definition at line 472 of file idtype.c.

References ARRAY_SIZE, BKE_idtype_idcode_from_index(), and id_types.

Referenced by BKE_main_idmap_create(), bpy_lib_enter(), and bpy_lib_exit().

◆ BKE_idtype_idcode_to_idfilter()

uint64_t BKE_idtype_idcode_to_idfilter ( const short  idcode)

Convert an idcode into an idfilter (e.g. ID_OB -> FILTER_ID_OB).

Definition at line 242 of file idtype.c.

References BR, CASE_IDFILTER, and LT.

Referenced by BLO_library_link_copypaste(), groupname_to_filter_id(), and previews_clear_exec().

◆ BKE_idtype_idcode_to_index()

int BKE_idtype_idcode_to_index ( const short  idcode)

◆ BKE_idtype_idcode_to_name()

const char* BKE_idtype_idcode_to_name ( const short  idcode)

◆ BKE_idtype_idcode_to_name_plural()

const char* BKE_idtype_idcode_to_name_plural ( const short  idcode)

Convert an idcode into a name (plural).

Parameters
idcodeThe code to convert.
Returns
A static string representing the name of the code.

Definition at line 182 of file idtype.c.

References BKE_idtype_get_info_from_idcode(), BLI_assert, IDTypeInfo::name_plural, and NULL.

Referenced by bpy_lib_enter(), bpy_lib_exit(), idp_repr_fn_recursive(), outliner_idcode_to_plural(), outliner_orphans_purge_invoke(), pyrna_prop_repr_ex(), pyrna_struct_repr(), RNA_path_full_ID_py(), and wm_drag_name().

◆ BKE_idtype_idcode_to_translation_context()

const char* BKE_idtype_idcode_to_translation_context ( const short  idcode)

Convert an idcode into its translations' context.

Parameters
idcodeThe code to convert.
Returns
A static string representing the i18n context of the code.

Definition at line 195 of file idtype.c.

References BKE_idtype_get_info_from_idcode(), BLI_assert, BLT_I18NCONTEXT_DEFAULT, NULL, and IDTypeInfo::translation_context.

◆ BKE_idtype_init()

void BKE_idtype_init ( void  )

Definition at line 125 of file idtype.c.

References id_type_init().

Referenced by main(), BlendfileLoadingBaseTest::SetUpTestCase(), and blender::bke::tests::TEST().

◆ id_type_init()

static void id_type_init ( void  )
static

◆ idtype_get_info_from_name()

static const IDTypeInfo* idtype_get_info_from_name ( const char *  idtype_name)
static

Definition at line 148 of file idtype.c.

References ARRAY_SIZE, id_types, NULL, and STREQ.

Referenced by BKE_idtype_idcode_from_name().

Variable Documentation

◆ id_types

IDTypeInfo* id_types[INDEX_ID_MAX] = {NULL}
static