|
Blender
V2.59
|
#include <stdio.h>#include <stdlib.h>#include <stddef.h>#include <string.h>#include "BKE_idprop.h"#include "BKE_library.h"#include "BLI_blenlib.h"#include "MEM_guardedalloc.h"Go to the source code of this file.
Definition in file idprop.c.
| #define BSTR_EQ | ( | a, | |
| b | |||
| ) | (*(a) == *(b) && !strcmp(a, b)) |
Definition at line 45 of file idprop.c.
Referenced by IDP_EqualsProperties(), and IDP_ReplaceGroupInGroup().
| #define GETPROP | ( | prop, | |
| i | |||
| ) | (((IDProperty*)(prop)->data.pointer)+(i)) |
Definition at line 63 of file idprop.c.
Referenced by IDP_CopyIDPArray(), IDP_FreeIDPArray(), IDP_GetIndexArray(), IDP_ResizeIDPArray(), and IDP_SetIndexArray().
| #define SWITCH_LONGINT | ( | a | ) |
| int IDP_AddToGroup | ( | struct IDProperty * | group, |
| struct IDProperty * | prop | ||
| ) |
This function has a sanity check to make sure ID properties with the same name don't get added to the group.
The sanity check just means the property is not added to the group if another property exists with the same name; the client code using ID properties then needs to detect this (the function that adds new properties to groups, IDP_AddToGroup, returns 0 if a property can't be added to the group, and 1 if it can) and free the property.
Currently the code to free ID properties is designesd to leave the actual struct you pass it un-freed, this is needed for how the system works. This means to free an ID property, you first call IDP_FreeProperty then MEM_freeN the struct. In the future this will just be IDP_FreeProperty and the code will be reorganized to work properly.
Definition at line 508 of file idprop.c.
References BLI_addtail(), IDProperty::data, IDPropertyData::group, IDP_GetPropertyFromGroup(), IDProperty::len, IDProperty::name, and NULL.
Referenced by RNA_property_boolean_set(), RNA_property_boolean_set_array(), RNA_property_collection_add(), RNA_property_enum_set(), RNA_property_float_set(), RNA_property_float_set_array(), RNA_property_int_set(), RNA_property_int_set_array(), RNA_property_pointer_add(), RNA_property_string_set(), and texture_paint_image_from_view_exec().
| IDProperty* IDP_AppendArray | ( | IDProperty * | prop, |
| IDProperty * | item | ||
| ) | [read] |
Definition at line 129 of file idprop.c.
References IDP_ResizeIDPArray(), IDP_SetIndexArray(), and IDProperty::len.
Referenced by BPy_IDProperty_Map_ValidateAndCreate(), and RNA_property_collection_add().
| void IDP_AssignString | ( | IDProperty * | prop, |
| const char * | st, | ||
| int | maxlen | ||
| ) |
Definition at line 352 of file idprop.c.
References BLI_strncpy(), IDProperty::data, IDP_ResizeArray(), and IDPropertyData::pointer.
Referenced by RNA_property_string_set().
| void IDP_ConcatString | ( | IDProperty * | str1, |
| IDProperty * | append | ||
| ) |
Definition at line 378 of file idprop.c.
References IDProperty::data, IDP_ResizeArray(), IDProperty::len, and IDPropertyData::pointer.
| void IDP_ConcatStringC | ( | IDProperty * | prop, |
| const char * | st | ||
| ) |
Definition at line 367 of file idprop.c.
References IDProperty::data, IDP_ResizeArray(), IDProperty::len, and IDPropertyData::pointer.
| static IDProperty* IDP_CopyArray | ( | IDProperty * | prop | ) | [static] |
Definition at line 277 of file idprop.c.
References IDProperty::data, IDP_CopyProperty(), idp_generic_copy(), IDP_GROUP, IDProperty::len, MEM_dupallocN(), IDPropertyData::pointer, IDProperty::subtype, IDProperty::totallen, and IDProperty::type.
Referenced by IDP_CopyProperty().
| static IDProperty* IDP_CopyGroup | ( | IDProperty * | prop | ) | [static] |
Definition at line 413 of file idprop.c.
References BLI_addtail(), IDProperty::data, ListBase::first, IDPropertyData::group, IDP_CopyProperty(), idp_generic_copy(), IDProperty::len, and link().
Referenced by IDP_CopyProperty().
| IDProperty* IDP_CopyIDPArray | ( | IDProperty * | array | ) |
Definition at line 79 of file idprop.c.
References IDProperty::data, GETPROP, i, IDP_CopyProperty(), IDProperty::len, MEM_dupallocN(), MEM_freeN(), MEM_mallocN(), and IDPropertyData::pointer.
Referenced by IDP_CopyProperty().
| IDProperty* IDP_CopyProperty | ( | IDProperty * | prop | ) | [read] |
Definition at line 594 of file idprop.c.
References IDP_ARRAY, IDP_CopyArray(), IDP_CopyGroup(), IDP_CopyIDPArray(), IDP_CopyString(), idp_generic_copy(), IDP_GROUP, IDP_IDPARRAY, IDP_STRING, and IDProperty::type.
Referenced by copy_bonechildren(), copy_libblock_data(), copy_pose(), copy_scene(), duplicate_pose_channel_data(), duplicateEditBoneObjects(), ED_armature_from_edit(), fcm_python_copy(), fcurves_to_pchan_links_get(), IDP_CopyArray(), IDP_CopyGroup(), IDP_CopyIDPArray(), IDP_ReplaceGroupInGroup(), IDP_SyncGroupValues(), make_boneList(), menu_add_shortcut(), object_make_proxy(), pose_paste_exec(), pose_proxy_synchronize(), poselib_backup_posecopy(), pycon_copy(), uiItemsFullEnumO(), wm_keymap_item_copy(), WM_keymap_restore_item_to_default(), WM_operator_confirm_message(), and wm_operator_create().
| static IDProperty* IDP_CopyString | ( | IDProperty * | prop | ) | [static] |
Definition at line 339 of file idprop.c.
References IDProperty::data, idp_generic_copy(), IDProperty::len, MEM_dupallocN(), IDPropertyData::pointer, IDProperty::subtype, and IDProperty::totallen.
Referenced by IDP_CopyProperty().
| int IDP_EqualsProperties | ( | IDProperty * | prop1, |
| IDProperty * | prop2 | ||
| ) |
Definition at line 621 of file idprop.c.
References BLI_countlist(), BSTR_EQ, IDProperty::data, ListBase::first, IDPropertyData::group, i, IDP_ARRAY, IDP_Array, IDP_DOUBLE, IDP_Double, IDP_EqualsProperties(), IDP_FLOAT, IDP_Float, IDP_GetPropertyFromGroup(), IDP_GROUP, IDP_IDPARRAY, IDP_IDPArray, IDP_INT, IDP_Int, idp_size_table, IDP_STRING, IDP_String, IDProperty::len, IDProperty::name, IDProperty::next, NULL, IDProperty::subtype, and IDProperty::type.
Referenced by IDP_EqualsProperties(), wm_keymap_item_equals_result(), and wm_keymap_item_find_handlers().
| void IDP_FreeArray | ( | IDProperty * | prop | ) |
Definition at line 255 of file idprop.c.
References IDProperty::data, idp_resize_group_array(), MEM_freeN(), NULL, and IDPropertyData::pointer.
Referenced by IDP_FreeProperty().
| static void IDP_FreeGroup | ( | IDProperty * | prop | ) | [static] |
Definition at line 582 of file idprop.c.
References BLI_freelistN(), IDProperty::data, ListBase::first, IDPropertyData::group, IDP_FreeProperty(), and IDProperty::next.
Referenced by IDP_FreeProperty().
| void IDP_FreeIDPArray | ( | IDProperty * | prop | ) |
Definition at line 103 of file idprop.c.
References IDProperty::data, GETPROP, i, IDP_FreeProperty(), IDProperty::len, MEM_freeN(), and IDPropertyData::pointer.
Referenced by IDP_FreeProperty().
| void IDP_FreeIterBeforeEnd | ( | void * | vself | ) |
Frees the iterator pointed to at vself, only use this if iteration is stopped early; when the iterator hits the end of the list it'll automatially free itself.
Definition at line 573 of file idprop.c.
References MEM_freeN().
| void IDP_FreeProperty | ( | struct IDProperty * | prop | ) |
Definition at line 745 of file idprop.c.
References IDP_ARRAY, IDP_FreeArray(), IDP_FreeGroup(), IDP_FreeIDPArray(), IDP_FreeString(), IDP_GROUP, IDP_IDPARRAY, IDP_STRING, and IDProperty::type.
Referenced by bone_free(), BPy_IDProperty_Map_ValidateAndCreate(), BPy_Wrap_SetMapItem(), duplicate_pose_channel_data(), ED_armature_edit_free(), fcm_python_free(), free_bonelist(), free_libblock(), free_pose_channel(), free_posebuf(), free_scene(), IDP_FreeGroup(), IDP_FreeIDPArray(), IDP_ReplaceGroupInGroup(), IDP_ReplaceInGroup(), idp_resize_group_array(), IDP_ResizeIDPArray(), IDP_SetIndexArray(), IDP_SyncGroupValues(), keymap_item_free(), object_make_proxy(), pose_paste_exec(), pose_proxy_synchronize(), poseAnim_mapping_free(), poselib_backup_free_data(), pycon_free(), pyrna_struct_dealloc(), rna_idproperty_check(), RNA_property_pointer_remove(), RNA_struct_idprops_unset(), shader_preview_free(), uiItemsFullEnumO(), WM_keymap_restore_item_to_default(), WM_operator_free(), and WM_operator_properties_free().
| void IDP_FreeString | ( | IDProperty * | prop | ) |
Definition at line 389 of file idprop.c.
References IDProperty::data, MEM_freeN(), and IDPropertyData::pointer.
Referenced by IDP_FreeProperty().
| static IDProperty* idp_generic_copy | ( | IDProperty * | prop | ) | [static] |
Definition at line 264 of file idprop.c.
References BLI_strncpy(), IDProperty::data, IDProperty::flag, MAX_IDPROP_NAME, MEM_callocN(), IDProperty::name, IDProperty::type, IDPropertyData::val, and IDPropertyData::val2.
Referenced by IDP_CopyArray(), IDP_CopyGroup(), IDP_CopyProperty(), and IDP_CopyString().
| void* IDP_GetGroupIterator | ( | struct IDProperty * | prop | ) |
Get an iterator to iterate over the members of an id property group. Note that this will automatically free the iterator once iteration is complete; if you stop the iteration before hitting the end, make sure to call IDP_FreeIterBeforeEnd().
Definition at line 552 of file idprop.c.
References IDProperty::data, ListBase::first, IDPropertyData::group, MEM_callocN(), IDPIter::next, and IDPIter::parent.
| IDProperty* IDP_GetIndexArray | ( | IDProperty * | prop, |
| int | index | ||
| ) | [read] |
Definition at line 124 of file idprop.c.
References GETPROP.
Referenced by RNA_property_collection_add().
| IDProperty* IDP_GetProperties | ( | struct ID * | id, |
| int | create_if_needed | ||
| ) | [read] |
Get the Group property that contains the id properties for ID id. Set create_if_needed to create the Group property and attach it to id if it doesn't exist; otherwise the function will return NULL if there's no Group property attached to the ID.
Definition at line 605 of file idprop.c.
References IDP_GROUP, MEM_callocN(), and ID::properties.
Referenced by project_paint_begin(), shader_preview_free(), texture_paint_camera_project_exec(), and texture_paint_image_from_view_exec().
| IDProperty* IDP_GetPropertyFromGroup | ( | IDProperty * | prop, |
| const char * | name | ||
| ) |
Definition at line 536 of file idprop.c.
References BLI_findstring(), IDProperty::data, and IDPropertyData::group.
Referenced by BPy_IDGroup_Contains(), BPy_IDGroup_Get(), BPy_IDGroup_Map_GetItem(), BPy_IDGroup_Pop(), BPy_Wrap_SetMapItem(), IDP_AddToGroup(), IDP_EqualsProperties(), IDP_GetPropertyTypeFromGroup(), IDP_InsertToGroup(), IDP_ReplaceInGroup(), project_paint_begin(), pyrna_struct_contains(), pyrna_struct_get(), pyrna_struct_is_property_set(), pyrna_struct_subscript(), rna_idproperty_find(), RNA_path_resolve_full(), and RNA_struct_idprops_unset().
| IDProperty* IDP_GetPropertyTypeFromGroup | ( | struct IDProperty * | prop, |
| const char * | name, | ||
| const char | type | ||
| ) |
same as above but ensure type match
Definition at line 541 of file idprop.c.
References IDP_GetPropertyFromGroup(), NULL, and IDProperty::type.
Referenced by rna_ensure_property_description(), rna_idproperty_ui(), RNA_property_float_range(), RNA_property_float_ui_range(), RNA_property_int_range(), RNA_property_int_ui_range(), and texture_paint_camera_project_exec().
| IDProperty* IDP_GroupIterNext | ( | void * | vself | ) |
Returns the next item in the iteration. To use, simple for a loop like the following: while (IDP_GroupIterNext(iter) != NULL) { . . . }
Definition at line 560 of file idprop.c.
References if(), MEM_freeN(), Link::next, next, and NULL.
| int IDP_InsertToGroup | ( | struct IDProperty * | group, |
| struct IDProperty * | previous, | ||
| struct IDProperty * | pnew | ||
| ) |
this is the same as IDP_AddToGroup, only you pass an item in the group list to be inserted after.
Definition at line 519 of file idprop.c.
References BLI_insertlink(), IDProperty::data, IDPropertyData::group, IDP_GetPropertyFromGroup(), IDProperty::len, IDProperty::name, and NULL.
| void IDP_LinkID | ( | IDProperty * | prop, |
| ID * | id | ||
| ) |
Definition at line 398 of file idprop.c.
References IDProperty::data, id_us_plus(), and IDPropertyData::pointer.
| IDProperty* IDP_New | ( | int | type, |
| IDPropertyTemplate | val, | ||
| const char * | name | ||
| ) | [read] |
Allocate a new ID.
This function takes three arguments: the ID property type, a union which defines it's initial value, and a name.
The union is simple to use; see the top of this header file for its definition. An example of using this function:
IDPropertyTemplate val; IDProperty *group, *idgroup, *color; group = IDP_New(IDP_GROUP, val, "group1"); //groups don't need a template.
val.array.len = 4 val.array.type = IDP_FLOAT; color = IDP_New(IDP_ARRAY, val, "color1");
idgroup = IDP_GetProperties(some_id, 1); IDP_AddToGroup(idgroup, color); IDP_AddToGroup(idgroup, group);
Note that you MUST either attach the id property to an id property group with IDP_AddToGroup or MEM_freeN the property, doing anything else might result in a memory leak.
Definition at line 675 of file idprop.c.
References IDPropertyTemplate::array, IDPropertyTemplate::d, IDProperty::data, DEFAULT_ALLOC_FOR_NULL_STRINGS, IDPropertyTemplate::f, IDPropertyTemplate::i, IDP_ARRAY, IDP_DOUBLE, IDP_FLOAT, IDP_GROUP, IDP_INT, idp_size_table, IDP_STRING, if(), IDPropertyTemplate::len, IDProperty::len, MEM_callocN(), MEM_mallocN(), NULL, IDPropertyData::pointer, IDPropertyTemplate::str, IDProperty::subtype, IDProperty::totallen, IDPropertyTemplate::type, and IDPropertyData::val.
Referenced by BPy_IDProperty_Map_ValidateAndCreate(), idp_resize_group_array(), RNA_property_boolean_set(), RNA_property_boolean_set_array(), RNA_property_collection_add(), RNA_property_enum_set(), RNA_property_float_set(), RNA_property_float_set_array(), RNA_property_int_set(), RNA_property_int_set_array(), RNA_property_pointer_add(), texture_paint_image_from_view_exec(), uiItemFullO(), uiLayoutOperatorButs(), wm_operator_create(), and WM_operator_properties_alloc().
| IDProperty* IDP_NewIDPArray | ( | const char * | name | ) |
Definition at line 69 of file idprop.c.
References BLI_strncpy(), IDP_IDPARRAY, IDProperty::len, MAX_IDPROP_NAME, MEM_callocN(), IDProperty::name, and IDProperty::type.
Referenced by BPy_IDProperty_Map_ValidateAndCreate(), and RNA_property_collection_add().
| IDProperty* IDP_NewString | ( | const char * | st, |
| const char * | name, | ||
| int | maxlen | ||
| ) |
Definition at line 311 of file idprop.c.
References BLI_strncpy(), IDProperty::data, DEFAULT_ALLOC_FOR_NULL_STRINGS, IDP_STRING, IDProperty::len, MAX_IDPROP_NAME, MEM_callocN(), IDProperty::name, NULL, IDPropertyData::pointer, IDProperty::totallen, and IDProperty::type.
Referenced by RNA_property_string_set().
| void IDP_RemFromGroup | ( | struct IDProperty * | group, |
| struct IDProperty * | prop | ||
| ) |
To free the property, you have to do: IDP_FreeProperty(prop); //free all subdata MEM_freeN(prop); //free property struct itself
Definition at line 530 of file idprop.c.
References BLI_remlink(), IDProperty::data, IDPropertyData::group, and IDProperty::len.
Referenced by BPy_IDGroup_Pop(), BPy_Wrap_SetMapItem(), rna_idproperty_check(), RNA_property_pointer_remove(), and RNA_struct_idprops_unset().
| void IDP_ReplaceGroupInGroup | ( | struct IDProperty * | dest, |
| struct IDProperty * | src | ||
| ) |
replaces all properties with the same name in a destination group from a source group.
Definition at line 461 of file idprop.c.
References BLI_addtail(), BLI_insertlink(), BLI_remlink(), BSTR_EQ, copy(), IDProperty::data, ListBase::first, IDPropertyData::group, IDP_CopyProperty(), IDP_FreeProperty(), IDProperty::len, MEM_freeN(), IDProperty::name, IDProperty::next, and NULL.
Referenced by wm_operator_create().
| void IDP_ReplaceInGroup | ( | struct IDProperty * | group, |
| struct IDProperty * | prop | ||
| ) |
checks if a property with the same name as prop exists, and if so replaces it. Use this to preserve order!
Definition at line 490 of file idprop.c.
References BLI_addtail(), BLI_insertlink(), BLI_remlink(), IDProperty::data, IDPropertyData::group, IDP_FreeProperty(), IDP_GetPropertyFromGroup(), IDProperty::len, MEM_freeN(), and IDProperty::name.
Referenced by BPy_IDProperty_Map_ValidateAndCreate().
| static void idp_resize_group_array | ( | IDProperty * | prop, |
| int | newlen, | ||
| void * | newarr | ||
| ) | [static] |
Definition at line 185 of file idprop.c.
References IDProperty::data, IDPropertyTemplate::i, IDP_FreeProperty(), IDP_GROUP, IDP_New(), IDProperty::len, MEM_freeN(), IDPropertyData::pointer, IDProperty::subtype, and simple_enum_gen::val.
Referenced by IDP_FreeArray(), and IDP_ResizeArray().
| void IDP_ResizeArray | ( | IDProperty * | prop, |
| int | newlen | ||
| ) |
Definition at line 214 of file idprop.c.
References IDProperty::data, idp_resize_group_array(), idp_size_table, IDProperty::len, MEM_callocN(), MEM_freeN(), IDPropertyData::pointer, IDProperty::subtype, and IDProperty::totallen.
Referenced by IDP_AssignString(), IDP_ConcatString(), and IDP_ConcatStringC().
| void IDP_ResizeIDPArray | ( | IDProperty * | prop, |
| int | newlen | ||
| ) |
Definition at line 136 of file idprop.c.
References IDProperty::data, GETPROP, i, IDP_FreeProperty(), IDProperty::len, MEM_callocN(), MEM_freeN(), IDPropertyData::pointer, and IDProperty::totallen.
Referenced by IDP_AppendArray(), RNA_property_collection_clear(), and RNA_property_collection_remove().
| void IDP_SetIndexArray | ( | IDProperty * | prop, |
| int | index, | ||
| IDProperty * | item | ||
| ) |
Definition at line 115 of file idprop.c.
References GETPROP, IDP_FreeProperty(), and IDProperty::len.
Referenced by IDP_AppendArray().
| void IDP_SyncGroupValues | ( | struct IDProperty * | dest, |
| struct IDProperty * | src | ||
| ) |
Sync values from one group to another, only where they match
Definition at line 427 of file idprop.c.
References BLI_findstring(), BLI_insertlinkafter(), BLI_remlink(), copy(), IDProperty::data, ListBase::first, IDPropertyData::group, IDP_CopyProperty(), IDP_DOUBLE, IDP_FLOAT, IDP_FreeProperty(), IDP_GROUP, IDP_INT, IDP_SyncGroupValues(), MEM_freeN(), IDProperty::name, IDProperty::next, and IDProperty::type.
Referenced by IDP_SyncGroupValues(), pose_proxy_synchronize(), poseAnim_mapping_reset(), and poselib_backup_restore().
| void IDP_UnlinkID | ( | IDProperty * | prop | ) |
Definition at line 405 of file idprop.c.
References IDProperty::data, and IDPropertyData::pointer.
Referenced by IDP_UnlinkProperty().
| void IDP_UnlinkProperty | ( | struct IDProperty * | prop | ) |
Unlinks any struct IDProperty<->ID linkage that might be going on.
Definition at line 765 of file idprop.c.
References IDP_ID, IDP_UnlinkID(), and IDProperty::type.
char idp_size_table[] [static] |
{
1,
sizeof(int),
sizeof(float),
sizeof(float)*3,
sizeof(float)*16,
0,
sizeof(ListBase),
sizeof(void*),
sizeof(double)
}
Definition at line 50 of file idprop.c.
Referenced by IDP_EqualsProperties(), IDP_New(), and IDP_ResizeArray().