Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions

BKE_idprop.h File Reference

#include "DNA_ID.h"

Go to the source code of this file.

Classes

union  IDPropertyTemplate

Defines

#define IDP_Int(prop)   ((prop)->data.val)
#define IDP_Float(prop)   (*(float*)&(prop)->data.val)
#define IDP_String(prop)   ((char*)(prop)->data.pointer)
#define IDP_Array(prop)   ((prop)->data.pointer)
#define IDP_IDPArray(prop)   ((IDProperty*)(prop)->data.pointer)
#define IDP_Double(prop)   (*(double*)&(prop)->data.val)

Typedefs

typedef union IDPropertyTemplate IDPropertyTemplate

Functions

IDPropertyIDP_NewIDPArray (const char *name)
IDPropertyIDP_CopyIDPArray (IDProperty *array)
void IDP_FreeIDPArray (IDProperty *prop)
void IDP_SetIndexArray (struct IDProperty *prop, int index, struct IDProperty *item)
struct IDPropertyIDP_GetIndexArray (struct IDProperty *prop, int index)
struct IDPropertyIDP_AppendArray (struct IDProperty *prop, struct IDProperty *item)
void IDP_ResizeIDPArray (struct IDProperty *prop, int len)
void IDP_ResizeArray (struct IDProperty *prop, int newlen)
void IDP_FreeArray (struct IDProperty *prop)
void IDP_UnlinkArray (struct IDProperty *prop)
IDPropertyIDP_NewString (const char *st, const char *name, int maxlen)
void IDP_AssignString (struct IDProperty *prop, const char *st, int maxlen)
void IDP_ConcatStringC (struct IDProperty *prop, const char *st)
void IDP_ConcatString (struct IDProperty *str1, struct IDProperty *append)
void IDP_FreeString (struct IDProperty *prop)
void IDP_LinkID (struct IDProperty *prop, ID *id)
void IDP_UnlinkID (struct IDProperty *prop)
void IDP_SyncGroupValues (struct IDProperty *dest, struct IDProperty *src)
void IDP_ReplaceGroupInGroup (struct IDProperty *dest, struct IDProperty *src)
void IDP_ReplaceInGroup (struct IDProperty *group, struct IDProperty *prop)
int IDP_AddToGroup (struct IDProperty *group, struct IDProperty *prop)
int IDP_InsertToGroup (struct IDProperty *group, struct IDProperty *previous, struct IDProperty *pnew)
void IDP_RemFromGroup (struct IDProperty *group, struct IDProperty *prop)
IDPropertyIDP_GetPropertyFromGroup (struct IDProperty *prop, const char *name)
IDPropertyIDP_GetPropertyTypeFromGroup (struct IDProperty *prop, const char *name, const char type)
void * IDP_GetGroupIterator (struct IDProperty *prop)
IDPropertyIDP_GroupIterNext (void *vself)
void IDP_FreeIterBeforeEnd (void *vself)
struct IDPropertyIDP_GetProperties (struct ID *id, int create_if_needed)
struct IDPropertyIDP_CopyProperty (struct IDProperty *prop)
int IDP_EqualsProperties (struct IDProperty *prop1, struct IDProperty *prop2)
struct IDPropertyIDP_New (const int type, const IDPropertyTemplate *val, const char *name)
void IDP_FreeProperty (struct IDProperty *prop)
void IDP_UnlinkProperty (struct IDProperty *prop)

Detailed Description

Author:
Joseph Eagar

Definition in file BKE_idprop.h.


Define Documentation

#define IDP_Array (   prop)    ((prop)->data.pointer)
#define IDP_Double (   prop)    (*(double*)&(prop)->data.val)
#define IDP_Float (   prop)    (*(float*)&(prop)->data.val)
#define IDP_IDPArray (   prop)    ((IDProperty*)(prop)->data.pointer)
#define IDP_Int (   prop)    ((prop)->data.val)
#define IDP_String (   prop)    ((char*)(prop)->data.pointer)

Typedef Documentation


Function Documentation

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 507 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(), texture_paint_image_from_view_exec(), and ui_menu_block_set_keymaps().

struct IDProperty* IDP_AppendArray ( struct IDProperty prop,
struct IDProperty item 
) [read]
void IDP_AssignString ( struct IDProperty prop,
const char *  st,
int  maxlen 
)
void IDP_ConcatString ( struct IDProperty str1,
struct IDProperty append 
)
void IDP_ConcatStringC ( struct IDProperty prop,
const char *  st 
)
IDProperty* IDP_CopyIDPArray ( IDProperty array)
struct IDProperty* IDP_CopyProperty ( struct IDProperty prop) [read]
int IDP_EqualsProperties ( struct IDProperty prop1,
struct IDProperty prop2 
)
void IDP_FreeArray ( struct IDProperty prop)

Definition at line 251 of file idprop.c.

References IDProperty::data, idp_resize_group_array(), MEM_freeN(), NULL, and IDPropertyData::pointer.

Referenced by IDP_FreeProperty().

void IDP_FreeIDPArray ( IDProperty prop)
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 572 of file idprop.c.

References MEM_freeN().

void IDP_FreeProperty ( struct IDProperty prop)
void IDP_FreeString ( struct IDProperty prop)

Definition at line 388 of file idprop.c.

References IDProperty::data, MEM_freeN(), and IDPropertyData::pointer.

Referenced by IDP_FreeProperty().

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 551 of file idprop.c.

References IDProperty::data, ListBase::first, IDPropertyData::group, MEM_callocN(), IDPIter::next, and IDPIter::parent.

struct IDProperty* IDP_GetIndexArray ( struct IDProperty prop,
int  index 
) [read]

Definition at line 120 of file idprop.c.

References GETPROP.

Referenced by RNA_property_collection_add().

struct 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 604 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 ( struct IDProperty prop,
const char *  name 
)
IDProperty* IDP_GetPropertyTypeFromGroup ( struct IDProperty prop,
const char *  name,
const char  type 
)
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 559 of file idprop.c.

References if(), MEM_freeN(), next, Link::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 518 of file idprop.c.

References BLI_insertlink(), IDProperty::data, IDPropertyData::group, IDP_GetPropertyFromGroup(), IDProperty::len, IDProperty::name, and NULL.

void IDP_LinkID ( struct IDProperty prop,
ID id 
)

Definition at line 397 of file idprop.c.

References IDProperty::data, id_us_plus(), and IDPropertyData::pointer.

struct IDProperty* IDP_New ( const int  type,
const 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, IDP_STRING_SUB_BYTE, IDP_STRING_SUB_UTF8, if(), IDProperty::len, IDPropertyTemplate::len, MEM_callocN(), MEM_mallocN(), NULL, IDPropertyData::pointer, IDPropertyTemplate::str, IDPropertyTemplate::string, strlen(), IDPropertyTemplate::subtype, 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(), ui_menu_block_set_keymaps(), uiItemFullO(), uiLayoutOperatorButs(), wm_operator_create(), and WM_operator_properties_alloc().

IDProperty* IDP_NewIDPArray ( const char *  name)
IDProperty* IDP_NewString ( const char *  st,
const char *  name,
int  maxlen 
)
void IDP_RemFromGroup ( struct IDProperty group,
struct IDProperty prop 
)
Note:
this does not free the property!!

To free the property, you have to do: IDP_FreeProperty(prop); //free all subdata MEM_freeN(prop); //free property struct itself

Definition at line 529 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 460 of file idprop.c.

References BLI_addtail(), BLI_insertlink(), BLI_remlink(), 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 489 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(), and wm_operator_init_from_last().

void IDP_ResizeArray ( struct IDProperty prop,
int  newlen 
)
void IDP_ResizeIDPArray ( struct IDProperty prop,
int  len 
)
void IDP_SetIndexArray ( struct IDProperty prop,
int  index,
struct IDProperty item 
)

Definition at line 111 of file idprop.c.

References GETPROP, IDP_FreeProperty(), and IDProperty::len.

Referenced by IDP_AppendArray().

void IDP_SyncGroupValues ( struct IDProperty dest,
struct IDProperty src 
)
void IDP_UnlinkArray ( struct IDProperty prop)
void IDP_UnlinkID ( struct IDProperty prop)

Definition at line 404 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 787 of file idprop.c.

References IDP_ID, IDP_UnlinkID(), and IDProperty::type.