|
Blender
V2.59
|
00001 /* 00002 * $Id: RNA_types.h 37295 2011-06-07 10:54:57Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Contributor(s): Blender Foundation (2008). 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include "BLO_sys_types.h" 00031 00032 #ifndef RNA_TYPES_H 00033 #define RNA_TYPES_H 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 struct ParameterList; 00040 struct FunctionRNA; 00041 struct PropertyRNA; 00042 struct EnumPropertyRNA; 00043 struct StructRNA; 00044 struct BlenderRNA; 00045 struct IDProperty; 00046 struct bContext; 00047 struct Main; 00048 struct ReportList; 00049 00057 typedef struct PointerRNA { 00058 struct { 00059 void *data; 00060 } id; 00061 00062 struct StructRNA *type; 00063 void *data; 00064 } PointerRNA; 00065 00066 typedef struct PropertyPointerRNA { 00067 PointerRNA ptr; 00068 struct PropertyRNA *prop; 00069 } PropertyPointerRNA; 00070 00071 /* Property */ 00072 00073 typedef enum PropertyType { 00074 PROP_BOOLEAN = 0, 00075 PROP_INT = 1, 00076 PROP_FLOAT = 2, 00077 PROP_STRING = 3, 00078 PROP_ENUM = 4, 00079 PROP_POINTER = 5, 00080 PROP_COLLECTION = 6 00081 } PropertyType; 00082 00083 /* also update rna_property_subtype_unit when you change this */ 00084 typedef enum PropertyUnit { 00085 PROP_UNIT_NONE = (0<<16), 00086 PROP_UNIT_LENGTH = (1<<16), /* m */ 00087 PROP_UNIT_AREA = (2<<16), /* m^2 */ 00088 PROP_UNIT_VOLUME = (3<<16), /* m^3 */ 00089 PROP_UNIT_MASS = (4<<16), /* kg */ 00090 PROP_UNIT_ROTATION = (5<<16), /* radians */ 00091 PROP_UNIT_TIME = (6<<16), /* frame */ 00092 PROP_UNIT_VELOCITY = (7<<16), /* m/s */ 00093 PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */ 00094 } PropertyUnit; 00095 00096 #define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000) 00097 #define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000) 00098 #define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype)>>16) 00099 00100 #define RNA_ENUM_BITFLAG_SIZE 32 00101 00102 /* also update enums in bpy_props.c when adding items here */ 00103 typedef enum PropertySubType { 00104 PROP_NONE = 0, 00105 00106 /* strings */ 00107 PROP_FILEPATH = 1, 00108 PROP_DIRPATH = 2, 00109 PROP_FILENAME = 3, 00110 00111 /* numbers */ 00112 PROP_UNSIGNED = 13, 00113 PROP_PERCENTAGE = 14, 00114 PROP_FACTOR = 15, 00115 PROP_ANGLE = 16|PROP_UNIT_ROTATION, 00116 PROP_TIME = 17|PROP_UNIT_TIME, 00117 PROP_DISTANCE = 18|PROP_UNIT_LENGTH, 00118 00119 /* number arrays */ 00120 PROP_COLOR = 20, 00121 PROP_TRANSLATION = 21|PROP_UNIT_LENGTH, 00122 PROP_DIRECTION = 22, 00123 PROP_VELOCITY = 23|PROP_UNIT_VELOCITY, 00124 PROP_ACCELERATION = 24|PROP_UNIT_ACCELERATION, 00125 PROP_MATRIX = 25, 00126 PROP_EULER = 26|PROP_UNIT_ROTATION, 00127 PROP_QUATERNION = 27, 00128 PROP_AXISANGLE = 28, 00129 PROP_XYZ = 29, 00130 PROP_XYZ_LENGTH = 29|PROP_UNIT_LENGTH, 00131 PROP_COLOR_GAMMA = 30, 00132 PROP_COORDS = 31, /* generic array, no units applied, only that x/y/z/w are used (python vec) */ 00133 00134 /* booleans */ 00135 PROP_LAYER = 40, 00136 PROP_LAYER_MEMBER = 41 00137 } PropertySubType; 00138 00139 /* Make sure enums are updated with thses */ 00140 typedef enum PropertyFlag { 00141 /* editable means the property is editable in the user 00142 * interface, properties are editable by default except 00143 * for pointers and collections. */ 00144 PROP_EDITABLE = 1<<0, 00145 00146 /* this property is editable even if it is lib linked, 00147 * meaning it will get lost on reload, but it's useful 00148 * for editing. */ 00149 PROP_LIB_EXCEPTION = 1<<16, 00150 00151 /* animateable means the property can be driven by some 00152 * other input, be it animation curves, expressions, .. 00153 * properties are animateable by default except for pointers 00154 * and collections */ 00155 PROP_ANIMATABLE = 1<<1, 00156 00157 /* icon */ 00158 PROP_ICONS_CONSECUTIVE = 1<<12, 00159 00160 /* hidden in the user interface */ 00161 PROP_HIDDEN = 1<<19, 00162 /* do not write in presets */ 00163 PROP_SKIP_SAVE = 1<<28, 00164 00165 /* function paramater flags */ 00166 PROP_REQUIRED = 1<<2, 00167 PROP_OUTPUT = 1<<3, 00168 PROP_RNAPTR = 1<<11, 00169 /* registering */ 00170 PROP_REGISTER = 1<<4, 00171 PROP_REGISTER_OPTIONAL = (1<<4)|(1<<5), 00172 00173 /* pointers */ 00174 PROP_ID_REFCOUNT = 1<<6, 00175 00176 /* disallow assigning a variable to its self, eg an object tracking its self 00177 * only apply this to types that are derived from an ID ()*/ 00178 PROP_ID_SELF_CHECK = 1<<20, 00179 PROP_NEVER_NULL = 1<<18, 00180 /* currently only used for UI, this is similar to PROP_NEVER_NULL 00181 * except that the value may be NULL at times, used for ObData, where an Empty's will be NULL 00182 * but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */ 00183 PROP_NEVER_UNLINK = 1<<25, 00184 00185 /* flag contains multiple enums. 00186 * note: not to be confused with prop->enumbitflags 00187 * this exposes the flag as multiple options in python and the UI. 00188 * 00189 * note: these can't be animated so use with care. 00190 */ 00191 PROP_ENUM_FLAG = 1<<21, 00192 00193 /* need context for update function */ 00194 PROP_CONTEXT_UPDATE = 1<<22, 00195 PROP_CONTEXT_PROPERTY_UPDATE = (1<<22)|(1<<27), 00196 00197 /* Use for arrays or for any data that should not have a referene kept 00198 * most common case is functions that return arrays where the array */ 00199 PROP_THICK_WRAP = 1<<23, 00200 00201 /* Reject values outside limits, use for python api only so far 00202 * this is for use when silently clamping string length will give 00203 * bad behavior later. Could also enforce this for INT's and other types. 00204 * note: currently no support for function arguments or non utf8 paths (filepaths) */ 00205 PROP_NEVER_CLAMP = 1<<26, 00206 00207 /* internal flags */ 00208 PROP_BUILTIN = 1<<7, 00209 PROP_EXPORT = 1<<8, 00210 PROP_RUNTIME = 1<<9, 00211 PROP_IDPROPERTY = 1<<10, 00212 PROP_RAW_ACCESS = 1<<13, 00213 PROP_RAW_ARRAY = 1<<14, 00214 PROP_FREE_POINTERS = 1<<15, 00215 PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */ 00216 PROP_ENUM_NO_CONTEXT = 1<<24 /* for enum that shouldn't be contextual */ 00217 } PropertyFlag; 00218 00219 typedef struct CollectionPropertyIterator { 00220 /* internal */ 00221 PointerRNA parent; 00222 PointerRNA builtin_parent; 00223 struct PropertyRNA *prop; 00224 void *internal; 00225 int idprop; 00226 int level; 00227 00228 /* external */ 00229 int valid; 00230 PointerRNA ptr; 00231 } CollectionPropertyIterator; 00232 00233 typedef struct CollectionPointerLink { 00234 struct CollectionPointerLink *next, *prev; 00235 PointerRNA ptr; 00236 } CollectionPointerLink; 00237 00238 typedef enum RawPropertyType { 00239 PROP_RAW_UNSET=-1, 00240 PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing. 00241 PROP_RAW_SHORT, 00242 PROP_RAW_CHAR, 00243 PROP_RAW_DOUBLE, 00244 PROP_RAW_FLOAT 00245 } RawPropertyType; 00246 00247 typedef struct RawArray { 00248 void *array; 00249 RawPropertyType type; 00250 int len; 00251 int stride; 00252 } RawArray; 00253 00254 typedef struct EnumPropertyItem { 00255 int value; 00256 const char *identifier; 00257 int icon; 00258 const char *name; 00259 const char *description; 00260 } EnumPropertyItem; 00261 00262 /* this is a copy of 'PropEnumItemFunc' defined in rna_internal_types.h */ 00263 typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, int *free); 00264 00265 typedef struct PropertyRNA PropertyRNA; 00266 00267 /* Parameter List */ 00268 00269 typedef struct ParameterList { 00270 /* storage for parameters */ 00271 void *data; 00272 00273 /* store the parameter size */ 00274 int alloc_size; 00275 00276 int arg_count, ret_count; 00277 00278 /* function passed at creation time */ 00279 struct FunctionRNA *func; 00280 } ParameterList; 00281 00282 typedef struct ParameterIterator { 00283 struct ParameterList *parms; 00284 PointerRNA funcptr; 00285 void *data; 00286 int size, offset; 00287 00288 PropertyRNA *parm; 00289 int valid; 00290 } ParameterIterator; 00291 00292 /* mainly to avoid confusing casts */ 00293 typedef struct ParameterDynAlloc { 00294 intptr_t array_tot; /* important, this breaks when set to an int */ 00295 void *array; 00296 } ParameterDynAlloc; 00297 00298 /* Function */ 00299 00300 typedef enum FunctionFlag { 00301 FUNC_NO_SELF = 1, /* for static functions */ 00302 FUNC_USE_CONTEXT = 2, 00303 FUNC_USE_REPORTS = 4, 00304 FUNC_USE_SELF_ID = 2048, 00305 00306 /* registering */ 00307 FUNC_REGISTER = 8, 00308 FUNC_REGISTER_OPTIONAL = 8|16, 00309 00310 /* internal flags */ 00311 FUNC_BUILTIN = 128, 00312 FUNC_EXPORT = 256, 00313 FUNC_RUNTIME = 512, 00314 FUNC_FREE_POINTERS = 1024 00315 } FunctionFlag; 00316 00317 typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms); 00318 00319 typedef struct FunctionRNA FunctionRNA; 00320 00321 /* Struct */ 00322 00323 typedef enum StructFlag { 00324 /* indicates that this struct is an ID struct, and to use refcounting */ 00325 STRUCT_ID = 1, 00326 STRUCT_ID_REFCOUNT = 2, 00327 00328 /* internal flags */ 00329 STRUCT_RUNTIME = 4, 00330 STRUCT_GENERATED = 8, 00331 STRUCT_FREE_POINTERS = 16, 00332 STRUCT_NO_IDPROPERTIES = 32 /* Menu's and Panels don't need properties */ 00333 } StructFlag; 00334 00335 typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function); 00336 typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list); 00337 typedef void (*StructFreeFunc)(void *data); 00338 typedef struct StructRNA *(*StructRegisterFunc)(struct Main *bmain, struct ReportList *reports, void *data, 00339 const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); 00340 typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type); 00341 typedef void **(*StructInstanceFunc)(PointerRNA *ptr); 00342 00343 typedef struct StructRNA StructRNA; 00344 00345 /* Blender RNA 00346 * 00347 * Root RNA data structure that lists all struct types. */ 00348 00349 typedef struct BlenderRNA BlenderRNA; 00350 00351 /* Extending 00352 * 00353 * This struct must be embedded in *Type structs in 00354 * order to make then definable through RNA. */ 00355 00356 typedef struct ExtensionRNA { 00357 void *data; 00358 StructRNA *srna; 00359 StructCallbackFunc call; 00360 StructFreeFunc free; 00361 00362 } ExtensionRNA; 00363 00364 #ifdef __cplusplus 00365 } 00366 #endif 00367 00368 #endif /* RNA_TYPES_H */