~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/BKE_idprop.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
/* note: as a start to move away from the stupid IDP_New function, this type
62
62
 * has it's own allocation function.*/
63
 
IDProperty *IDP_NewIDPArray(const char *name);
64
 
IDProperty *IDP_CopyIDPArray(IDProperty *array);
 
63
IDProperty *IDP_NewIDPArray(const char *name)
 
64
#ifdef __GNUC__
 
65
__attribute__((warn_unused_result))
 
66
__attribute__((nonnull))
 
67
#endif
 
68
;
 
69
IDProperty *IDP_CopyIDPArray(IDProperty *array)
 
70
#ifdef __GNUC__
 
71
__attribute__((warn_unused_result))
 
72
__attribute__((nonnull))
 
73
#endif
 
74
;
65
75
 
66
76
void IDP_FreeIDPArray(IDProperty *prop);
67
77
 
68
78
/* shallow copies item */
69
79
void IDP_SetIndexArray(struct IDProperty *prop, int index, struct IDProperty *item);
70
 
struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index);
71
 
struct IDProperty *IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
 
80
#ifdef __GNUC__
 
81
__attribute__((nonnull))
 
82
#endif
 
83
struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index)
 
84
#ifdef __GNUC__
 
85
__attribute__((warn_unused_result))
 
86
__attribute__((nonnull))
 
87
#endif
 
88
;
 
89
void IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
72
90
void IDP_ResizeIDPArray(struct IDProperty *prop, int len);
73
91
 
74
92
/* ----------- Numeric Array Type ----------- */
77
95
void IDP_FreeArray(struct IDProperty *prop);
78
96
 
79
97
/* ---------- String Type ------------ */
80
 
IDProperty *IDP_NewString(const char *st, const char *name, int maxlen);/* maxlen excludes '\0' */
81
 
void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen);     /* maxlen excludes '\0' */
82
 
void IDP_ConcatStringC(struct IDProperty *prop, const char *st);
83
 
void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append);
84
 
void IDP_FreeString(struct IDProperty *prop);
 
98
IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) /* maxlen excludes '\0' */
 
99
#ifdef __GNUC__
 
100
__attribute__((warn_unused_result))
 
101
__attribute__((nonnull (2))) /* 'name' arg */
 
102
#endif
 
103
;
 
104
 
 
105
void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen) /* maxlen excludes '\0' */
 
106
#ifdef __GNUC__
 
107
__attribute__((nonnull))
 
108
#endif
 
109
;
 
110
void IDP_ConcatStringC(struct IDProperty *prop, const char *st)
 
111
#ifdef __GNUC__
 
112
__attribute__((nonnull))
 
113
#endif
 
114
;
 
115
void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append)
 
116
#ifdef __GNUC__
 
117
__attribute__((nonnull))
 
118
#endif
 
119
;
 
120
void IDP_FreeString(struct IDProperty *prop)
 
121
#ifdef __GNUC__
 
122
__attribute__((nonnull))
 
123
#endif
 
124
;
85
125
 
86
126
/*-------- ID Type -------*/
87
127
void IDP_LinkID(struct IDProperty *prop, ID *id);
90
130
/*-------- Group Functions -------*/
91
131
 
92
132
/** Sync values from one group to another, only where they match */
93
 
void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src);
 
133
void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src)
 
134
#ifdef __GNUC__
 
135
__attribute__((nonnull))
 
136
#endif
 
137
;
94
138
 
95
139
/**
96
140
 * replaces all properties with the same name in a destination group from a source group.
97
141
 */
98
 
void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src);
 
142
void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src)
 
143
#ifdef __GNUC__
 
144
__attribute__((nonnull))
 
145
#endif
 
146
;
99
147
 
100
148
/**
101
149
 * Checks if a property with the same name as prop exists, and if so replaces it.
102
150
 * Use this to preserve order!*/
103
 
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop);
 
151
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop)
 
152
#ifdef __GNUC__
 
153
__attribute__((nonnull))
 
154
#endif
 
155
;
 
156
 
 
157
void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite)
 
158
#ifdef __GNUC__
 
159
__attribute__((nonnull))
 
160
#endif
 
161
;
104
162
 
105
163
/**
106
164
 * This function has a sanity check to make sure ID properties with the same name don't
117
175
 * struct.  In the future this will just be IDP_FreeProperty and the code will
118
176
 * be reorganized to work properly.
119
177
 */
120
 
int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop);
 
178
int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop)
 
179
#ifdef __GNUC__
 
180
__attribute__((nonnull))
 
181
#endif
 
182
;
121
183
 
122
184
/** this is the same as IDP_AddToGroup, only you pass an item
123
185
 * in the group list to be inserted after. */
124
186
int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, 
125
 
                                          struct IDProperty *pnew);
 
187
                      struct IDProperty *pnew)
 
188
#ifdef __GNUC__
 
189
__attribute__((nonnull  (1, 3))) /* 'group', 'pnew' */
 
190
#endif
 
191
;
126
192
 
127
193
/** \note this does not free the property!!
128
194
 *
130
196
 * IDP_FreeProperty(prop); //free all subdata
131
197
 * MEM_freeN(prop); //free property struct itself
132
198
 */
133
 
void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop);
 
199
void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop)
 
200
#ifdef __GNUC__
 
201
__attribute__((nonnull))
 
202
#endif
 
203
;
134
204
 
135
 
IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name);
 
205
IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name)
 
206
#ifdef __GNUC__
 
207
__attribute__((warn_unused_result))
 
208
__attribute__((nonnull))
 
209
#endif
 
210
;
136
211
/** same as above but ensure type match */
137
 
IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type);
 
212
IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type)
 
213
#ifdef __GNUC__
 
214
__attribute__((warn_unused_result))
 
215
__attribute__((nonnull))
 
216
#endif
 
217
;
138
218
 
139
219
/**
140
220
 * Get an iterator to iterate over the members of an id property group.
141
221
 * Note that this will automatically free the iterator once iteration is complete;
142
222
 * if you stop the iteration before hitting the end, make sure to call
143
223
 * IDP_FreeIterBeforeEnd(). */
144
 
void *IDP_GetGroupIterator(struct IDProperty *prop);
 
224
void *IDP_GetGroupIterator(struct IDProperty *prop)
 
225
#ifdef __GNUC__
 
226
__attribute__((warn_unused_result))
 
227
#endif
 
228
;
145
229
 
146
230
/**
147
231
 * Returns the next item in the iteration.  To use, simple for a loop like the following:
149
233
 *     ...
150
234
 * }
151
235
 */
152
 
IDProperty *IDP_GroupIterNext(void *vself);
 
236
IDProperty *IDP_GroupIterNext(void *vself)
 
237
#ifdef __GNUC__
 
238
__attribute__((warn_unused_result))
 
239
__attribute__((nonnull))
 
240
#endif
 
241
;
153
242
 
154
243
/**
155
244
 * Frees the iterator pointed to at vself, only use this if iteration is stopped early; 
156
245
 * when the iterator hits the end of the list it'll automatically free itself.*/
157
 
void IDP_FreeIterBeforeEnd(void *vself);
 
246
void IDP_FreeIterBeforeEnd(void *vself)
 
247
#ifdef __GNUC__
 
248
__attribute__((nonnull))
 
249
#endif
 
250
;
158
251
 
159
252
/*-------- Main Functions --------*/
160
253
/** Get the Group property that contains the id properties for ID id.  Set create_if_needed
161
254
 * to create the Group property and attach it to id if it doesn't exist; otherwise
162
255
 * the function will return NULL if there's no Group property attached to the ID.*/
163
 
struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed);
164
 
struct IDProperty *IDP_CopyProperty(struct IDProperty *prop);
165
 
 
166
 
int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2);
 
256
struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed)
 
257
#ifdef __GNUC__
 
258
__attribute__((warn_unused_result))
 
259
__attribute__((nonnull))
 
260
#endif
 
261
;
 
262
struct IDProperty *IDP_CopyProperty(struct IDProperty *prop)
 
263
#ifdef __GNUC__
 
264
__attribute__((warn_unused_result))
 
265
__attribute__((nonnull))
 
266
#endif
 
267
;
 
268
 
 
269
int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict)
 
270
#ifdef __GNUC__
 
271
__attribute__((warn_unused_result))
 
272
#endif
 
273
;
 
274
 
 
275
int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2)
 
276
#ifdef __GNUC__
 
277
__attribute__((warn_unused_result))
 
278
#endif
 
279
;
167
280
 
168
281
/**
169
282
 * Allocate a new ID.
190
303
 * IDP_AddToGroup or MEM_freeN the property, doing anything else might result in
191
304
 * a memory leak.
192
305
 */
193
 
struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name);
 
306
struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
 
307
#ifdef __GNUC__
 
308
__attribute__((warn_unused_result))
 
309
__attribute__((nonnull))
 
310
#endif
 
311
;
194
312
 
195
313
/** \note this will free all child properties of list arrays and groups!
196
314
 * Also, note that this does NOT unlink anything!  Plus it doesn't free
197
315
 * the actual struct IDProperty struct either.*/
198
316
void IDP_FreeProperty(struct IDProperty *prop);
199
317
 
 
318
void IDP_ClearProperty(IDProperty *prop);
 
319
 
200
320
/** Unlinks any struct IDProperty<->ID linkage that might be going on.*/
201
321
void IDP_UnlinkProperty(struct IDProperty *prop);
202
322
 
203
 
#define IDP_Int(prop) ((prop)->data.val)
204
 
#define IDP_Float(prop) (*(float*)&(prop)->data.val)
205
 
#define IDP_String(prop) ((char*)(prop)->data.pointer)
206
 
#define IDP_Array(prop) ((prop)->data.pointer)
207
 
#define IDP_IDPArray(prop) ((IDProperty*)(prop)->data.pointer)
208
 
#define IDP_Double(prop) (*(double*)&(prop)->data.val)
 
323
#define IDP_Int(prop)                     ((prop)->data.val)
 
324
#define IDP_Float(prop)        (*(float *)&(prop)->data.val)
 
325
#define IDP_Double(prop)      (*(double *)&(prop)->data.val)
 
326
#define IDP_String(prop)         ((char *) (prop)->data.pointer)
 
327
#define IDP_Array(prop)                   ((prop)->data.pointer)
 
328
#define IDP_IDPArray(prop) ((IDProperty *) (prop)->data.pointer)
 
329
 
 
330
#ifdef DEBUG
 
331
/* for printout only */
 
332
void IDP_spit(IDProperty *prop);
 
333
#endif
209
334
 
210
335
#endif /* __BKE_IDPROP_H__ */