Code Cleanup: use const's and bools for idprops

This commit is contained in:
Campbell Barton 2013-12-12 21:57:37 +11:00
parent eb9d94f48b
commit 8a7f2b24c1
2 changed files with 24 additions and 24 deletions

View File

@ -58,7 +58,7 @@ typedef union IDPropertyTemplate {
/* ----------- Property Array Type ---------- */
IDProperty *IDP_NewIDPArray(const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
IDProperty *IDP_CopyIDPArray(IDProperty *array) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
IDProperty *IDP_CopyIDPArray(const IDProperty *array) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void IDP_FreeIDPArray(IDProperty *prop);
@ -87,12 +87,12 @@ void IDP_UnlinkID(struct IDProperty *prop);
/*-------- Group Functions -------*/
/** Sync values from one group to another, only where they match */
void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src) ATTR_NONNULL();
void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src) ATTR_NONNULL();
void IDP_SyncGroupValues(struct IDProperty *dest, const struct IDProperty *src) ATTR_NONNULL();
void IDP_ReplaceGroupInGroup(struct IDProperty *dest, const struct IDProperty *src) ATTR_NONNULL();
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite) ATTR_NONNULL();
int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite) ATTR_NONNULL();
bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
bool IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
struct IDProperty *pnew) ATTR_NONNULL(1 /* group */, 3 /* pnew */);
void IDP_RemoveFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
void IDP_FreeFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
@ -104,12 +104,12 @@ IDProperty *IDP_GroupIterNext(void *vself) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(
void IDP_FreeIterBeforeEnd(void *vself) ATTR_NONNULL();
/*-------- Main Functions --------*/
struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
struct IDProperty *IDP_CopyProperty(struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
struct IDProperty *IDP_GetProperties(struct ID *id, const bool create_if_needed) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
struct IDProperty *IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict) ATTR_WARN_UNUSED_RESULT;
bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is_strict) ATTR_WARN_UNUSED_RESULT;
int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2) ATTR_WARN_UNUSED_RESULT;
bool IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2) ATTR_WARN_UNUSED_RESULT;
struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();

View File

@ -81,7 +81,7 @@ IDProperty *IDP_NewIDPArray(const char *name)
return prop;
}
IDProperty *IDP_CopyIDPArray(IDProperty *array)
IDProperty *IDP_CopyIDPArray(const IDProperty *array)
{
/* don't use MEM_dupallocN because this may be part of an array */
IDProperty *narray, *tmp;
@ -273,7 +273,7 @@ void IDP_FreeArray(IDProperty *prop)
}
static IDProperty *idp_generic_copy(IDProperty *prop)
static IDProperty *idp_generic_copy(const IDProperty *prop)
{
IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup");
@ -286,7 +286,7 @@ static IDProperty *idp_generic_copy(IDProperty *prop)
return newp;
}
static IDProperty *IDP_CopyArray(IDProperty *prop)
static IDProperty *IDP_CopyArray(const IDProperty *prop)
{
IDProperty *newp = idp_generic_copy(prop);
@ -352,7 +352,7 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen)
return prop;
}
static IDProperty *IDP_CopyString(IDProperty *prop)
static IDProperty *IDP_CopyString(const IDProperty *prop)
{
IDProperty *newp;
@ -453,7 +453,7 @@ void IDP_UnlinkID(IDProperty *prop)
/**
* Checks if a property with the same name as prop exists, and if so replaces it.
*/
static IDProperty *IDP_CopyGroup(IDProperty *prop)
static IDProperty *IDP_CopyGroup(const IDProperty *prop)
{
IDProperty *newp, *link;
@ -470,7 +470,7 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
/* use for syncing proxies.
* When values name and types match, copy the values, else ignore */
void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
void IDP_SyncGroupValues(IDProperty *dest, const IDProperty *src)
{
IDProperty *other, *prop;
@ -509,7 +509,7 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
/**
* Replaces all properties with the same name in a destination group from a source group.
*/
void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
void IDP_ReplaceGroupInGroup(IDProperty *dest, const IDProperty *src)
{
IDProperty *loop, *prop;
@ -565,7 +565,7 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
/**
* If a property is missing in \a dest, add it.
*/
void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite)
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite)
{
IDProperty *prop;
@ -604,7 +604,7 @@ void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite)
* struct. In the future this will just be IDP_FreeProperty and the code will
* be reorganized to work properly.
*/
int IDP_AddToGroup(IDProperty *group, IDProperty *prop)
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop)
{
BLI_assert(group->type == IDP_GROUP);
@ -621,7 +621,7 @@ int IDP_AddToGroup(IDProperty *group, IDProperty *prop)
* This is the same as IDP_AddToGroup, only you pass an item
* in the group list to be inserted after.
*/
int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew)
bool IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew)
{
BLI_assert(group->type == IDP_GROUP);
@ -744,7 +744,7 @@ static void IDP_FreeGroup(IDProperty *prop)
/** \name IDProperty Main API
* \{ */
IDProperty *IDP_CopyProperty(IDProperty *prop)
IDProperty *IDP_CopyProperty(const IDProperty *prop)
{
switch (prop->type) {
case IDP_GROUP: return IDP_CopyGroup(prop);
@ -760,7 +760,7 @@ IDProperty *IDP_CopyProperty(IDProperty *prop)
* 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.
*/
IDProperty *IDP_GetProperties(ID *id, int create_if_needed)
IDProperty *IDP_GetProperties(ID *id, const bool create_if_needed)
{
if (id->properties) {
return id->properties;
@ -780,7 +780,7 @@ IDProperty *IDP_GetProperties(ID *id, int create_if_needed)
/**
* \param is_strict When FALSE treat missing items as a match */
int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict)
bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is_strict)
{
if (prop1 == NULL && prop2 == NULL)
return 1;
@ -842,7 +842,7 @@ int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_s
return 1;
}
int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
bool IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
{
return IDP_EqualsProperties_ex(prop1, prop2, TRUE);
}