Blender  V3.3
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_NONE(_id)
 
#define CASE_IDFILTER(_id)
 
#define CASE_IDFILTER_NONE(_id)   (void)0
 
#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)
 
bool BKE_idtype_idcode_is_only_appendable (const short idcode)
 
bool BKE_idtype_idcode_append_is_reusable (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_IDFILTER_NONE [1/2]

#define CASE_IDFILTER_NONE (   _id)
Value:
case ID_##_id: \
return 0

◆ CASE_IDFILTER_NONE [2/2]

#define CASE_IDFILTER_NONE (   _id)    (void)0

◆ 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
SyclQueue void void size_t num_bytes void

Function Documentation

◆ BKE_idtype_cache_key_cmp()

bool BKE_idtype_cache_key_cmp ( const void key_a_v,
const void key_b_v 
)

Definition at line 39 of file idtype.c.

References IDCacheKey::id_session_uuid, and IDCacheKey::offset_in_ID.

Referenced by blo_cache_storage_init().

◆ 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 124 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_append_is_reusable()

bool BKE_idtype_idcode_append_is_reusable ( short  idcode)

Check if an ID type can try to reuse and existing matching local one when being appended again.

Parameters
idcodeThe IDType code to check.
Returns
Boolean, false when it cannot be re-used, true otherwise.

Definition at line 194 of file idtype.c.

References BKE_idtype_get_info_from_idcode(), BLI_assert, IDTypeInfo::flags, IDTYPE_FLAGS_APPEND_IS_REUSABLE, IDTYPE_FLAGS_NO_LIBLINKING, and NULL.

Referenced by BKE_blendfile_append(), BKE_main_library_weak_reference_add_item(), and BKE_main_library_weak_reference_create().

◆ BKE_idtype_idcode_from_idfilter()

short BKE_idtype_idcode_from_idfilter ( uint64_t  idfilter)

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

Definition at line 266 of file idtype.c.

References BLI_assert_unreachable, BR, CASE_IDFILTER, CASE_IDFILTER_NONE, CV, and LT.

◆ BKE_idtype_idcode_from_index()

short BKE_idtype_idcode_from_index ( int  index)

Get an idcode from an index (e.g. INDEX_ID_OB -> ID_OB).

Definition at line 383 of file idtype.c.

References BR, CASE_IDCODE, CV, ID_LINK_PLACEHOLDER, INDEX_ID_NULL, and LT.

Referenced by BKE_idtype_idcode_iter_step(), and outliner_orphans_purge_invoke().

◆ 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 163 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_from_blend_id(), wm_link_append_exec(), and wm_link_append_item_poll().

◆ BKE_idtype_idcode_is_linkable()

bool BKE_idtype_idcode_is_linkable ( short  idcode)

◆ BKE_idtype_idcode_is_only_appendable()

bool BKE_idtype_idcode_is_only_appendable ( short  idcode)

Check if an ID type is only appendable.

Parameters
idcodeThe IDType code to check.
Returns
Boolean, false when also linkable, true when only appendable.

Definition at line 182 of file idtype.c.

References BKE_idtype_get_info_from_idcode(), BLI_assert, IDTypeInfo::flags, IDTYPE_FLAGS_NO_LIBLINKING, IDTYPE_FLAGS_ONLY_APPEND, and NULL.

Referenced by wm_link_append_item_poll().

◆ BKE_idtype_idcode_is_valid()

bool BKE_idtype_idcode_is_valid ( 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 170 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 442 of file idtype.c.

References ARRAY_SIZE, BKE_idtype_idcode_from_index(), and id_types.

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

◆ BKE_idtype_idcode_to_idfilter()

uint64_t BKE_idtype_idcode_to_idfilter ( short  idcode)

◆ BKE_idtype_idcode_to_index()

int BKE_idtype_idcode_to_index ( short  idcode)

◆ BKE_idtype_idcode_to_name()

const char* BKE_idtype_idcode_to_name ( short  idcode)

◆ BKE_idtype_idcode_to_name_plural()

const char* BKE_idtype_idcode_to_name_plural ( 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 149 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(), bpy_lib_exit_lapp_context_items_cb(), 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_get_item_name().

◆ BKE_idtype_idcode_to_translation_context()

const char* BKE_idtype_idcode_to_translation_context ( 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 156 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  )

◆ 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 129 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