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