4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
32 #include "MEM_guardedalloc.h"
34 #include "DNA_genfile.h"
35 #include "DNA_sdna_types.h"
37 #include "RNA_access.h"
38 #include "RNA_define.h"
39 #include "RNA_types.h"
41 #include "rna_internal.h"
43 /* Global used during defining */
45 BlenderDefRNA DefRNA = {0, {0, 0}, {0, 0}, 0, 0, 0};
47 /* Duplicated code since we can't link in blenkernel or blenlib */
50 #define MIN2(x,y) ((x)<(y)? (x): (y))
51 #define MAX2(x,y) ((x)>(y)? (x): (y))
54 void rna_addtail(ListBase *listbase, void *vlink)
59 link->prev = listbase->last;
61 if (listbase->last) ((Link *)listbase->last)->next = link;
62 if (listbase->first == 0) listbase->first = link;
63 listbase->last = link;
66 void rna_remlink(ListBase *listbase, void *vlink)
70 if (link->next) link->next->prev = link->prev;
71 if (link->prev) link->prev->next = link->next;
73 if (listbase->last == link) listbase->last = link->prev;
74 if (listbase->first == link) listbase->first = link->next;
77 void rna_freelinkN(ListBase *listbase, void *vlink)
79 rna_remlink(listbase, vlink);
83 void rna_freelistN(ListBase *listbase)
87 for(link=listbase->first; link; link=next) {
92 listbase->first= listbase->last= NULL;
95 /* DNA utility function for looking up members */
97 typedef struct DNAStructMember {
104 static int rna_member_cmp(const char *name, const char *oname)
108 /* compare without pointer or array part */
115 if(name[a]=='[' && oname[a]==0) return 1;
116 if(name[a]==0) break;
117 if(name[a] != oname[a]) return 0;
120 if(name[a]==0 && oname[a] == '.') return 2;
121 if(name[a]==0 && oname[a] == '-' && oname[a+1] == '>') return 3;
123 return (name[a] == oname[a]);
126 static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *membername, DNAStructMember *smember)
130 int a, b, structnr, totmember, cmp;
132 structnr= DNA_struct_find_nr(sdna, structname);
136 sp= sdna->structs[structnr];
140 for(a=0; a<totmember; a++, sp+=2) {
141 dnaname= sdna->names[sp[1]];
143 cmp= rna_member_cmp(dnaname, membername);
146 smember->type= sdna->types[sp[0]];
147 smember->name= dnaname;
148 smember->arraylength= DNA_elem_array_size(smember->name, strlen(smember->name));
150 smember->pointerlevel= 0;
151 for(b=0; dnaname[b] == '*'; b++)
152 smember->pointerlevel++;
157 membername= strstr(membername, ".") + strlen(".");
158 return rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
161 membername= strstr(membername, "->") + strlen("->");
162 return rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
169 static int rna_validate_identifier(const char *identifier, char *error, int property)
173 /* list from http://docs.python.org/reference/lexical_analysis.html#id5 */
174 static char *kwlist[] = {
175 "and", "as", "assert", "break",
176 "class", "continue", "def", "del",
177 "elif", "else", "except", "exec",
178 "finally", "for", "from", "global",
179 "if", "import", "in", "is",
180 "lambda", "not", "or", "pass",
181 "print", "raise", "return", "try",
182 "while", "with", "yield", NULL
186 if (!isalpha(identifier[0])) {
187 strcpy(error, "first character failed isalpha() check");
191 for(a=0; identifier[a]; a++) {
192 if(DefRNA.preprocess && property) {
193 if(isalpha(identifier[a]) && isupper(identifier[a])) {
194 strcpy(error, "property names must contain lower case characters only");
199 if (identifier[a]=='_') {
203 if (identifier[a]==' ') {
204 strcpy(error, "spaces are not ok in identifier names");
208 if (isalnum(identifier[a])==0) {
209 strcpy(error, "one of the characters failed an isalnum() check and is not an underscore");
214 for(a=0; kwlist[a]; a++) {
215 if (strcmp(identifier, kwlist[a]) == 0) {
216 strcpy(error, "this keyword is reserved by python");
224 /* Blender Data Definition */
226 BlenderRNA *RNA_create()
230 brna= MEM_callocN(sizeof(BlenderRNA), "BlenderRNA");
232 DefRNA.sdna= DNA_sdna_from_data(DNAstr, DNAlen, 0);
233 DefRNA.structs.first= DefRNA.structs.last= NULL;
235 DefRNA.preprocess= 1;
240 void RNA_define_free(BlenderRNA *brna)
245 for(alloc=DefRNA.allocs.first; alloc; alloc=alloc->next)
246 MEM_freeN(alloc->mem);
247 rna_freelistN(&DefRNA.allocs);
249 for(srna=DefRNA.structs.first; srna; srna=srna->next)
250 rna_freelistN(&srna->properties);
252 rna_freelistN(&DefRNA.structs);
255 DNA_sdna_free(DefRNA.sdna);
262 void RNA_free(BlenderRNA *brna)
264 StructRNA *srna, *nextsrna;
265 PropertyRNA *prop, *nextprop;
267 if(DefRNA.preprocess) {
268 RNA_define_free(brna);
270 for(srna=brna->structs.first; srna; srna=srna->next)
271 rna_freelistN(&srna->properties);
273 rna_freelistN(&brna->structs);
278 for(srna=brna->structs.first; srna; srna=nextsrna) {
279 nextsrna= srna->next;
281 for(prop=srna->properties.first; prop; prop=nextprop) {
282 nextprop= prop->next;
284 if(prop->flag & PROP_RUNTIME)
285 rna_freelinkN(&srna->properties, prop);
288 if(srna->flag & STRUCT_RUNTIME)
289 rna_freelinkN(&brna->structs, srna);
294 static size_t rna_property_type_sizeof(PropertyType type)
297 case PROP_BOOLEAN: return sizeof(BooleanPropertyRNA);
298 case PROP_INT: return sizeof(IntPropertyRNA);
299 case PROP_FLOAT: return sizeof(FloatPropertyRNA);
300 case PROP_STRING: return sizeof(StringPropertyRNA);
301 case PROP_ENUM: return sizeof(EnumPropertyRNA);
302 case PROP_POINTER: return sizeof(PointerPropertyRNA);
303 case PROP_COLLECTION: return sizeof(CollectionPropertyRNA);
308 static StructDefRNA *rna_find_def_struct(StructRNA *srna)
312 for(ds=DefRNA.structs.first; ds; ds=ds->next)
319 /* Struct Definition */
321 StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
323 StructRNA *srna, *srnafrom= NULL;
324 StructDefRNA *ds= NULL, *dsfrom= NULL;
327 if(DefRNA.preprocess) {
330 if (rna_validate_identifier(identifier, error, 0) == 0) {
331 fprintf(stderr, "RNA_def_struct: struct identifier \"%s\" error - %s\n", identifier, error);
337 /* find struct to derive from */
338 for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->next)
339 if(strcmp(srnafrom->identifier, from) == 0)
343 fprintf(stderr, "RNA_def_struct: struct %s not found to define %s.\n", from, identifier);
348 srna= MEM_callocN(sizeof(StructRNA), "StructRNA");
349 DefRNA.laststruct= srna;
352 /* copy from struct to derive stuff, a bit clumsy since we can't
353 * use MEM_dupallocN, data structs may not be alloced but builtin */
354 memcpy(srna, srnafrom, sizeof(StructRNA));
355 srna->properties.first= srna->properties.last= NULL;
357 if(DefRNA.preprocess) {
358 srna->base= srnafrom;
359 dsfrom= rna_find_def_struct(srnafrom);
362 srna->base= srnafrom;
365 srna->identifier= identifier;
366 srna->name= identifier; /* may be overwritten later RNA_def_struct_ui_text */
367 srna->description= "";
369 rna_addtail(&brna->structs, srna);
371 if(DefRNA.preprocess) {
372 ds= MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
374 rna_addtail(&DefRNA.structs, ds);
377 ds->dnafromname= dsfrom->dnaname;
380 /* in preprocess, try to find sdna */
381 if(DefRNA.preprocess)
382 RNA_def_struct_sdna(srna, srna->identifier);
384 srna->flag |= STRUCT_RUNTIME;
387 srna->nameproperty= srnafrom->nameproperty;
388 srna->iteratorproperty= srnafrom->iteratorproperty;
391 /* define some builtin properties */
392 prop= RNA_def_property(srna, "rna_properties", PROP_COLLECTION, PROP_NONE);
393 RNA_def_property_flag(prop, PROP_BUILTIN);
394 RNA_def_property_ui_text(prop, "Properties", "RNA property collection.");
396 if(DefRNA.preprocess) {
397 RNA_def_property_struct_type(prop, "Property");
398 RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, 0);
402 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
403 cprop->begin= rna_builtin_properties_begin;
404 cprop->next= rna_builtin_properties_next;
405 cprop->get= rna_builtin_properties_get;
406 cprop->type= &RNA_Property;
410 prop= RNA_def_property(srna, "rna_type", PROP_POINTER, PROP_NONE);
411 RNA_def_property_ui_text(prop, "RNA", "RNA type definition.");
413 if(DefRNA.preprocess) {
414 RNA_def_property_struct_type(prop, "Struct");
415 RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL);
419 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
420 pprop->get= rna_builtin_type_get;
421 pprop->type= &RNA_Struct;
429 void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
431 StructDefRNA *ds= DefRNA.structs.last;
433 if(!DefRNA.preprocess) {
434 fprintf(stderr, "RNA_def_struct_sdna: only during preprocessing.\n");
438 if(!DNA_struct_find_nr(DefRNA.sdna, structname)) {
440 fprintf(stderr, "RNA_def_struct_sdna: %s not found.\n", structname);
446 ds->dnaname= structname;
449 void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname)
451 StructDefRNA *ds= DefRNA.structs.last;
453 if(!DefRNA.preprocess) {
454 fprintf(stderr, "RNA_def_struct_sdna_from: only during preprocessing.\n");
459 fprintf(stderr, "RNA_def_struct_sdna_from: %s base struct must know DNA already.\n", structname);
463 if(!DNA_struct_find_nr(DefRNA.sdna, structname)) {
465 fprintf(stderr, "RNA_def_struct_sdna_from: %s not found.\n", structname);
471 ds->dnafromprop= propname;
472 ds->dnaname= structname;
475 void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
477 if(prop->type != PROP_STRING) {
478 fprintf(stderr, "RNA_def_struct_name_property: %s.%s, must be a string property.\n", srna->identifier, prop->identifier);
482 srna->nameproperty= prop;
485 void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
489 /* find struct to derive from */
490 for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->next)
491 if(strcmp(srnafrom->identifier, structname) == 0)
495 fprintf(stderr, "RNA_def_struct_nested: struct %s not found.\n", structname);
499 srna->nested= srnafrom;
502 void RNA_def_struct_flag(StructRNA *srna, int flag)
507 void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
509 if(!DefRNA.preprocess) {
510 fprintf(stderr, "RNA_def_struct_refine_func: only during preprocessing.\n");
514 if(refine) srna->refine= (StructRefineFunc)refine;
517 void RNA_def_struct_path_func(StructRNA *srna, const char *path)
519 if(!DefRNA.preprocess) {
520 fprintf(stderr, "RNA_def_struct_path_func: only during preprocessing.\n");
524 if(path) srna->path= (StructPathFunc)path;
527 void RNA_def_struct_identifier(StructRNA *srna, const char *identifier)
529 if(DefRNA.preprocess) {
530 fprintf(stderr, "RNA_def_struct_name_runtime: only at runtime.\n");
534 srna->identifier= identifier;
537 void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
540 srna->description= description;
543 void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
545 rna_freelistN(&srna->properties);
546 rna_freelinkN(&brna->structs, srna);
549 /* Property Definition */
551 PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type, int subtype)
554 PropertyDefRNA *dp= NULL;
557 if(DefRNA.preprocess) {
560 if (rna_validate_identifier(identifier, error, 1) == 0) {
561 fprintf(stderr, "RNA_def_property: property identifier \"%s\" - %s\n", identifier, error);
565 ds= DefRNA.structs.last;
566 dp= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
567 rna_addtail(&ds->properties, dp);
570 prop= MEM_callocN(rna_property_type_sizeof(type), "PropertyRNA");
576 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
578 iprop->hardmin= (subtype == PROP_UNSIGNED)? 0: INT_MIN;
579 iprop->hardmax= INT_MAX;
581 iprop->softmin= (subtype == PROP_UNSIGNED)? 0: -10000; /* rather arbitrary .. */
582 iprop->softmax= 10000;
587 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
589 fprop->hardmin= (subtype == PROP_UNSIGNED)? 0.0f: -FLT_MAX;
590 fprop->hardmax= FLT_MAX;
592 if(subtype == PROP_COLOR) {
593 fprop->softmin= 0.0f;
594 fprop->softmax= 1.0f;
596 else if(subtype == PROP_PERCENTAGE) {
597 fprop->softmin= fprop->hardmin= 0.0f;
598 fprop->softmax= fprop->hardmax= 1.0f;
601 fprop->softmin= (subtype == PROP_UNSIGNED)? 0.0f: -10000.0f; /* rather arbitrary .. */
602 fprop->softmax= 10000.0f;
609 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
611 sprop->defaultvalue= "";
617 case PROP_COLLECTION:
620 fprintf(stderr, "RNA_def_property: %s.%s, invalid property type.\n", srna->identifier, identifier);
625 if(DefRNA.preprocess) {
630 prop->magic= RNA_MAGIC;
631 prop->identifier= identifier;
633 prop->subtype= subtype;
634 prop->name= identifier;
635 prop->description= "";
637 if(type != PROP_COLLECTION && type != PROP_POINTER)
638 prop->flag= PROP_EDITABLE|PROP_ANIMATEABLE;
640 if(DefRNA.preprocess) {
644 RNA_def_property_boolean_sdna(prop, NULL, identifier, 0);
649 RNA_def_property_int_sdna(prop, NULL, identifier);
655 RNA_def_property_float_sdna(prop, NULL, identifier);
661 RNA_def_property_string_sdna(prop, NULL, identifier);
667 RNA_def_property_enum_sdna(prop, NULL, identifier);
672 RNA_def_property_pointer_sdna(prop, NULL, identifier);
675 case PROP_COLLECTION:
677 RNA_def_property_collection_sdna(prop, NULL, identifier, NULL);
683 prop->flag |= PROP_IDPROPERTY|PROP_RUNTIME;
685 rna_addtail(&srna->properties, prop);
690 void RNA_def_property_flag(PropertyRNA *prop, int flag)
695 void RNA_def_property_clear_flag(PropertyRNA *prop, int flag)
700 void RNA_def_property_array(PropertyRNA *prop, int arraylength)
702 StructRNA *srna= DefRNA.laststruct;
705 fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be zero of greater.\n", srna->identifier, prop->identifier);
710 if(arraylength>RNA_MAX_ARRAY) {
711 fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be smaller than %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY);
720 prop->arraylength= arraylength;
723 fprintf(stderr, "RNA_def_property_array: %s.%s, only boolean/int/float can be array.\n", srna->identifier, prop->identifier);
729 void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
732 prop->description= description;
735 void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
737 StructRNA *srna= DefRNA.laststruct;
741 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
742 iprop->softmin= (int)min;
743 iprop->softmax= (int)max;
744 iprop->step= (int)step;
748 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
749 fprop->softmin= (float)min;
750 fprop->softmax= (float)max;
751 fprop->step= (float)step;
752 fprop->precision= (int)precision;
756 fprintf(stderr, "RNA_def_property_ui_range: %s.%s, invalid type for ui range.\n", srna->identifier, prop->identifier);
762 void RNA_def_property_range(PropertyRNA *prop, double min, double max)
764 StructRNA *srna= DefRNA.laststruct;
768 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
769 iprop->hardmin= (int)min;
770 iprop->hardmax= (int)max;
771 iprop->softmin= MAX2((int)min, iprop->hardmin);
772 iprop->softmax= MIN2((int)max, iprop->hardmax);
776 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
777 fprop->hardmin= (float)min;
778 fprop->hardmax= (float)max;
779 fprop->softmin= MAX2((float)min, fprop->hardmin);
780 fprop->softmax= MIN2((float)max, fprop->hardmax);
784 fprintf(stderr, "RNA_def_property_range: %s.%s, invalid type for range.\n", srna->identifier, prop->identifier);
790 void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
792 StructRNA *srna= DefRNA.laststruct;
794 if(!DefRNA.preprocess) {
795 fprintf(stderr, "RNA_def_property_struct_type: only during preprocessing.\n");
801 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
802 pprop->type = (StructRNA*)type;
805 case PROP_COLLECTION: {
806 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
807 cprop->type = (StructRNA*)type;
811 fprintf(stderr, "RNA_def_property_struct_type: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
817 void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
819 StructRNA *srna= DefRNA.laststruct;
821 if(DefRNA.preprocess) {
822 fprintf(stderr, "RNA_def_property_struct_runtime: only at runtime.\n");
828 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
832 case PROP_COLLECTION: {
833 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
838 fprintf(stderr, "RNA_def_property_struct_runtime: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
844 void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
846 StructRNA *srna= DefRNA.laststruct;
847 int i, defaultfound= 0;
851 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
854 for(i=0; item[i].identifier; i++) {
857 if(item[i].value == eprop->defaultvalue)
862 eprop->defaultvalue= item[0].value;
867 fprintf(stderr, "RNA_def_property_enum_items: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
873 void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
875 StructRNA *srna= DefRNA.laststruct;
879 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
880 sprop->maxlength= maxlength;
884 fprintf(stderr, "RNA_def_property_string_maxlength: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
890 void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
892 StructRNA *srna= DefRNA.laststruct;
896 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
897 bprop->defaultvalue= value;
901 fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
907 void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
909 StructRNA *srna= DefRNA.laststruct;
913 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
914 bprop->defaultarray= array;
918 fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
924 void RNA_def_property_int_default(PropertyRNA *prop, int value)
926 StructRNA *srna= DefRNA.laststruct;
930 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
931 iprop->defaultvalue= value;
935 fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
941 void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
943 StructRNA *srna= DefRNA.laststruct;
947 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
948 iprop->defaultarray= array;
952 fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
958 void RNA_def_property_float_default(PropertyRNA *prop, float value)
960 StructRNA *srna= DefRNA.laststruct;
964 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
965 fprop->defaultvalue= value;
969 fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
974 /* array must remain valid after this function finishes */
975 void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
977 StructRNA *srna= DefRNA.laststruct;
981 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
982 fprop->defaultarray= array; /* WARNING, this array must not come from the stack and lost */
986 fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
992 void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
994 StructRNA *srna= DefRNA.laststruct;
998 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
999 sprop->defaultvalue= value;
1003 fprintf(stderr, "RNA_def_property_string_default: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
1009 void RNA_def_property_enum_default(PropertyRNA *prop, int value)
1011 StructRNA *srna= DefRNA.laststruct;
1012 int i, defaultfound= 0;
1014 switch(prop->type) {
1016 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1017 eprop->defaultvalue= value;
1019 for(i=0; i<eprop->totitem; i++) {
1020 if(eprop->item[i].value == eprop->defaultvalue)
1024 if(!defaultfound && eprop->totitem) {
1026 eprop->defaultvalue= eprop->item[0].value;
1029 fprintf(stderr, "RNA_def_property_enum_default: %s.%s, default is not in items.\n", srna->identifier, prop->identifier);
1037 fprintf(stderr, "RNA_def_property_enum_default: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
1045 static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1047 DNAStructMember smember;
1048 StructDefRNA *ds= DefRNA.structs.last;
1049 PropertyDefRNA *dp= ds->properties.last;
1052 structname= ds->dnaname;
1054 propname= prop->identifier;
1056 if(!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember)) {
1057 if(!DefRNA.silent) {
1058 fprintf(stderr, "rna_def_property_sdna: %s.%s not found.\n", structname, propname);
1064 if(smember.arraylength > 1)
1065 prop->arraylength= smember.arraylength;
1067 prop->arraylength= 0;
1069 dp->dnastructname= structname;
1070 dp->dnastructfromname= ds->dnafromname;
1071 dp->dnastructfromprop= ds->dnafromprop;
1072 dp->dnaname= propname;
1073 dp->dnatype= smember.type;
1074 dp->dnaarraylength= smember.arraylength;
1075 dp->dnapointerlevel= smember.pointerlevel;
1080 void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit)
1083 StructRNA *srna= DefRNA.laststruct;
1085 if(!DefRNA.preprocess) {
1086 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1090 if(prop->type != PROP_BOOLEAN) {
1091 fprintf(stderr, "RNA_def_property_boolean_sdna: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
1096 if((dp=rna_def_property_sdna(prop, structname, propname)))
1097 dp->booleanbit= bit;
1100 void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int booleanbit)
1105 RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit);
1107 if((ds=DefRNA.structs.last) && (dp=ds->properties.last))
1108 dp->booleannegative= 1;
1111 void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1114 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
1115 StructRNA *srna= DefRNA.laststruct;
1117 if(!DefRNA.preprocess) {
1118 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1122 if(prop->type != PROP_INT) {
1123 fprintf(stderr, "RNA_def_property_int_sdna: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
1128 if((dp= rna_def_property_sdna(prop, structname, propname))) {
1129 /* SDNA doesn't pass us unsigned unfortunately .. */
1130 if(strcmp(dp->dnatype, "char") == 0) {
1131 iprop->hardmin= iprop->softmin= CHAR_MIN;
1132 iprop->hardmax= iprop->softmax= CHAR_MAX;
1134 else if(strcmp(dp->dnatype, "short") == 0) {
1135 iprop->hardmin= iprop->softmin= SHRT_MIN;
1136 iprop->hardmax= iprop->softmax= SHRT_MAX;
1138 else if(strcmp(dp->dnatype, "int") == 0) {
1139 iprop->hardmin= INT_MIN;
1140 iprop->hardmax= INT_MAX;
1142 iprop->softmin= -10000; /* rather arbitrary .. */
1143 iprop->softmax= 10000;
1146 if(prop->subtype == PROP_UNSIGNED)
1147 iprop->hardmin= iprop->softmin= 0;
1151 void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1153 StructRNA *srna= DefRNA.laststruct;
1155 if(!DefRNA.preprocess) {
1156 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1160 if(prop->type != PROP_FLOAT) {
1161 fprintf(stderr, "RNA_def_property_float_sdna: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
1166 rna_def_property_sdna(prop, structname, propname);
1169 void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1172 StructRNA *srna= DefRNA.laststruct;
1174 if(!DefRNA.preprocess) {
1175 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1179 if(prop->type != PROP_ENUM) {
1180 fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
1185 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1186 if(prop->arraylength) {
1187 prop->arraylength= 0;
1188 if(!DefRNA.silent) {
1189 fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, array not supported for enum type.\n", structname, propname);
1196 void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1201 RNA_def_property_enum_sdna(prop, structname, propname);
1203 if((ds=DefRNA.structs.last) && (dp=ds->properties.last))
1204 dp->enumbitflags= 1;
1207 void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1210 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
1211 StructRNA *srna= DefRNA.laststruct;
1213 if(!DefRNA.preprocess) {
1214 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1218 if(prop->type != PROP_STRING) {
1219 fprintf(stderr, "RNA_def_property_string_sdna: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
1224 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1225 if(prop->arraylength) {
1226 sprop->maxlength= prop->arraylength;
1227 prop->arraylength= 0;
1232 void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1235 StructRNA *srna= DefRNA.laststruct;
1237 if(!DefRNA.preprocess) {
1238 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1242 if(prop->type != PROP_POINTER) {
1243 fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
1248 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1249 if(prop->arraylength) {
1250 prop->arraylength= 0;
1251 if(!DefRNA.silent) {
1252 fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, array not supported for pointer type.\n", structname, propname);
1259 void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
1262 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
1263 StructRNA *srna= DefRNA.laststruct;
1265 if(!DefRNA.preprocess) {
1266 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1270 if(prop->type != PROP_COLLECTION) {
1271 fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
1276 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1277 if(prop->arraylength && !lengthpropname) {
1278 prop->arraylength= 0;
1280 if(!DefRNA.silent) {
1281 fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, array of collections not supported.\n", structname, propname);
1286 if(strcmp(dp->dnatype, "ListBase") == 0) {
1287 cprop->next= (PropCollectionNextFunc)"rna_iterator_listbase_next";
1288 cprop->get= (PropCollectionGetFunc)"rna_iterator_listbase_get";
1289 cprop->end= (PropCollectionEndFunc)"rna_iterator_listbase_end";
1293 if(dp && lengthpropname) {
1294 DNAStructMember smember;
1295 StructDefRNA *ds= DefRNA.structs.last;
1298 structname= ds->dnaname;
1300 if(lengthpropname[0] == 0 || rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember)) {
1301 if(lengthpropname[0] == 0) {
1302 dp->dnalengthfixed= prop->arraylength;
1303 prop->arraylength= 0;
1306 dp->dnalengthstructname= structname;
1307 dp->dnalengthname= lengthpropname;
1310 cprop->next= (PropCollectionNextFunc)"rna_iterator_array_next";
1311 cprop->end= (PropCollectionEndFunc)"rna_iterator_array_end";
1313 if(dp->dnapointerlevel >= 2)
1314 cprop->get= (PropCollectionGetFunc)"rna_iterator_array_dereference_get";
1316 cprop->get= (PropCollectionGetFunc)"rna_iterator_array_get";
1319 if(!DefRNA.silent) {
1320 fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s not found.\n", structname, lengthpropname);
1329 void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
1331 if(!DefRNA.preprocess) {
1332 fprintf(stderr, "RNA_def_property_editable_func: only during preprocessing.\n");
1336 if(editable) prop->editable= (EditableFunc)editable;
1339 void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
1341 if(!DefRNA.preprocess) {
1342 fprintf(stderr, "RNA_def_struct_refine_func: only during preprocessing.\n");
1346 prop->noteflag= noteflag;
1347 prop->update= (UpdateFunc)func;
1350 void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
1352 StructRNA *srna= DefRNA.laststruct;
1354 if(!DefRNA.preprocess) {
1355 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1359 switch(prop->type) {
1360 case PROP_BOOLEAN: {
1361 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
1363 if(prop->arraylength) {
1364 if(get) bprop->getarray= (PropBooleanArrayGetFunc)get;
1365 if(set) bprop->setarray= (PropBooleanArraySetFunc)set;
1368 if(get) bprop->get= (PropBooleanGetFunc)get;
1369 if(set) bprop->set= (PropBooleanSetFunc)set;
1374 fprintf(stderr, "RNA_def_property_boolean_funcs: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
1380 void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
1382 StructRNA *srna= DefRNA.laststruct;
1384 if(!DefRNA.preprocess) {
1385 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1389 switch(prop->type) {
1391 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
1393 if(prop->arraylength) {
1394 if(get) iprop->getarray= (PropIntArrayGetFunc)get;
1395 if(set) iprop->setarray= (PropIntArraySetFunc)set;
1398 if(get) iprop->get= (PropIntGetFunc)get;
1399 if(set) iprop->set= (PropIntSetFunc)set;
1401 if(range) iprop->range= (PropIntRangeFunc)range;
1405 fprintf(stderr, "RNA_def_property_int_funcs: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
1411 void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
1413 StructRNA *srna= DefRNA.laststruct;
1415 if(!DefRNA.preprocess) {
1416 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1420 switch(prop->type) {
1422 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
1424 if(prop->arraylength) {
1425 if(get) fprop->getarray= (PropFloatArrayGetFunc)get;
1426 if(set) fprop->setarray= (PropFloatArraySetFunc)set;
1429 if(get) fprop->get= (PropFloatGetFunc)get;
1430 if(set) fprop->set= (PropFloatSetFunc)set;
1432 if(range) fprop->range= (PropFloatRangeFunc)range;
1436 fprintf(stderr, "RNA_def_property_float_funcs: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
1442 void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set)
1444 StructRNA *srna= DefRNA.laststruct;
1446 if(!DefRNA.preprocess) {
1447 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1451 switch(prop->type) {
1453 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1455 if(get) eprop->get= (PropEnumGetFunc)get;
1456 if(set) eprop->set= (PropEnumSetFunc)set;
1460 fprintf(stderr, "RNA_def_property_enum_funcs: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
1466 void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
1468 StructRNA *srna= DefRNA.laststruct;
1470 if(!DefRNA.preprocess) {
1471 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1475 switch(prop->type) {
1477 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
1479 if(get) sprop->get= (PropStringGetFunc)get;
1480 if(length) sprop->length= (PropStringLengthFunc)length;
1481 if(set) sprop->set= (PropStringSetFunc)set;
1485 fprintf(stderr, "RNA_def_property_string_funcs: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
1491 void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set)
1493 StructRNA *srna= DefRNA.laststruct;
1495 if(!DefRNA.preprocess) {
1496 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1500 switch(prop->type) {
1501 case PROP_POINTER: {
1502 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
1504 if(get) pprop->get= (PropPointerGetFunc)get;
1505 if(set) pprop->set= (PropPointerSetFunc)set;
1509 fprintf(stderr, "RNA_def_property_pointer_funcs: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
1515 void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring)
1517 StructRNA *srna= DefRNA.laststruct;
1519 if(!DefRNA.preprocess) {
1520 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1524 switch(prop->type) {
1525 case PROP_COLLECTION: {
1526 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
1528 if(begin) cprop->begin= (PropCollectionBeginFunc)begin;
1529 if(next) cprop->next= (PropCollectionNextFunc)next;
1530 if(end) cprop->end= (PropCollectionEndFunc)end;
1531 if(get) cprop->get= (PropCollectionGetFunc)get;
1532 if(length) cprop->length= (PropCollectionLengthFunc)length;
1533 if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint;
1534 if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring;
1538 fprintf(stderr, "RNA_def_property_collection_funcs: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
1544 /* Compact definitions */
1546 PropertyRNA *RNA_def_boolean(StructRNA *srna, const char *identifier, int default_value,
1547 const char *ui_name, const char *ui_description)
1551 prop= RNA_def_property(srna, identifier, PROP_BOOLEAN, PROP_NONE);
1552 RNA_def_property_boolean_default(prop, default_value);
1553 RNA_def_property_ui_text(prop, ui_name, ui_description);
1558 PropertyRNA *RNA_def_boolean_array(StructRNA *srna, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description)
1562 prop= RNA_def_property(srna, identifier, PROP_BOOLEAN, PROP_NONE);
1563 if(len != 0) RNA_def_property_array(prop, len);
1564 if(default_value) RNA_def_property_boolean_array_default(prop, default_value);
1565 RNA_def_property_ui_text(prop, ui_name, ui_description);
1570 PropertyRNA *RNA_def_boolean_vector(StructRNA *srna, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description)
1574 prop= RNA_def_property(srna, identifier, PROP_BOOLEAN, PROP_VECTOR);
1575 if(len != 0) RNA_def_property_array(prop, len);
1576 if(default_value) RNA_def_property_boolean_array_default(prop, default_value);
1577 RNA_def_property_ui_text(prop, ui_name, ui_description);
1582 PropertyRNA *RNA_def_int(StructRNA *srna, const char *identifier, int default_value, int hardmin, int hardmax,
1583 const char *ui_name, const char *ui_description, int softmin, int softmax)
1587 prop= RNA_def_property(srna, identifier, PROP_INT, PROP_NONE);
1588 RNA_def_property_int_default(prop, default_value);
1589 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1590 RNA_def_property_ui_text(prop, ui_name, ui_description);
1591 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1596 PropertyRNA *RNA_def_int_vector(StructRNA *srna, const char *identifier, int len, const int *default_value,
1597 int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
1601 prop= RNA_def_property(srna, identifier, PROP_INT, PROP_VECTOR);
1602 if(len != 0) RNA_def_property_array(prop, len);
1603 if(default_value) RNA_def_property_int_array_default(prop, default_value);
1604 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1605 RNA_def_property_ui_text(prop, ui_name, ui_description);
1606 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1611 PropertyRNA *RNA_def_int_array(StructRNA *srna, const char *identifier, int len, const int *default_value,
1612 int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
1616 prop= RNA_def_property(srna, identifier, PROP_INT, PROP_NONE);
1617 if(len != 0) RNA_def_property_array(prop, len);
1618 if(default_value) RNA_def_property_int_array_default(prop, default_value);
1619 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1620 RNA_def_property_ui_text(prop, ui_name, ui_description);
1621 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1626 PropertyRNA *RNA_def_string(StructRNA *srna, const char *identifier, const char *default_value, int maxlen,
1627 const char *ui_name, const char *ui_description)
1631 prop= RNA_def_property(srna, identifier, PROP_STRING, PROP_NONE);
1632 if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
1633 if(default_value) RNA_def_property_string_default(prop, default_value);
1634 RNA_def_property_ui_text(prop, ui_name, ui_description);
1639 PropertyRNA *RNA_def_string_file_path(StructRNA *srna, const char *identifier, const char *default_value, int maxlen,
1640 const char *ui_name, const char *ui_description)
1644 prop= RNA_def_property(srna, identifier, PROP_STRING, PROP_FILEPATH);
1645 if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
1646 if(default_value) RNA_def_property_string_default(prop, default_value);
1647 RNA_def_property_ui_text(prop, ui_name, ui_description);
1652 PropertyRNA *RNA_def_string_dir_path(StructRNA *srna, const char *identifier, const char *default_value, int maxlen,
1653 const char *ui_name, const char *ui_description)
1657 prop= RNA_def_property(srna, identifier, PROP_STRING, PROP_DIRPATH);
1658 if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
1659 if(default_value) RNA_def_property_string_default(prop, default_value);
1660 RNA_def_property_ui_text(prop, ui_name, ui_description);
1665 PropertyRNA *RNA_def_enum(StructRNA *srna, const char *identifier, EnumPropertyItem *items, int default_value,
1666 const char *ui_name, const char *ui_description)
1670 prop= RNA_def_property(srna, identifier, PROP_ENUM, PROP_NONE);
1671 if(items) RNA_def_property_enum_items(prop, items);
1672 RNA_def_property_enum_default(prop, default_value);
1673 RNA_def_property_ui_text(prop, ui_name, ui_description);
1678 PropertyRNA *RNA_def_float(StructRNA *srna, const char *identifier, float default_value,
1679 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1683 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_NONE);
1684 RNA_def_property_float_default(prop, default_value);
1685 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1686 RNA_def_property_ui_text(prop, ui_name, ui_description);
1687 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1692 PropertyRNA *RNA_def_float_vector(StructRNA *srna, const char *identifier, int len, const float *default_value,
1693 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1697 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_VECTOR);
1698 if(len != 0) RNA_def_property_array(prop, len);
1699 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1700 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1701 RNA_def_property_ui_text(prop, ui_name, ui_description);
1702 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1707 PropertyRNA *RNA_def_float_color(StructRNA *srna, const char *identifier, int len, const float *default_value,
1708 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1712 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_COLOR);
1713 if(len != 0) RNA_def_property_array(prop, len);
1714 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1715 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1716 RNA_def_property_ui_text(prop, ui_name, ui_description);
1717 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1723 PropertyRNA *RNA_def_float_matrix(StructRNA *srna, const char *identifier, int len, const float *default_value,
1724 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1728 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_MATRIX);
1729 if(len != 0) RNA_def_property_array(prop, len);
1730 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1731 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1732 RNA_def_property_ui_text(prop, ui_name, ui_description);
1733 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1738 PropertyRNA *RNA_def_float_rotation(StructRNA *srna, const char *identifier, int len, const float *default_value,
1739 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1743 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_ROTATION);
1744 if(len != 0) RNA_def_property_array(prop, len);
1745 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1746 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1747 RNA_def_property_ui_text(prop, ui_name, ui_description);
1748 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1753 PropertyRNA *RNA_def_float_array(StructRNA *srna, const char *identifier, int len, const float *default_value,
1754 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1758 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_NONE);
1759 if(len != 0) RNA_def_property_array(prop, len);
1760 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1761 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1762 RNA_def_property_ui_text(prop, ui_name, ui_description);
1763 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1768 PropertyRNA *RNA_def_float_percentage(StructRNA *srna, const char *identifier, float default_value,
1769 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1773 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_PERCENTAGE);
1774 RNA_def_property_float_default(prop, default_value);
1775 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1776 RNA_def_property_ui_text(prop, ui_name, ui_description);
1777 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1782 PropertyRNA *RNA_def_pointer_runtime(StructRNA *srna, const char *identifier, StructRNA *type,
1783 const char *ui_name, const char *ui_description)
1787 prop= RNA_def_property(srna, identifier, PROP_POINTER, PROP_NONE);
1788 RNA_def_property_struct_runtime(prop, type);
1789 RNA_def_property_ui_text(prop, ui_name, ui_description);
1794 PropertyRNA *RNA_def_collection_runtime(StructRNA *srna, const char *identifier, StructRNA *type,
1795 const char *ui_name, const char *ui_description)
1799 prop= RNA_def_property(srna, identifier, PROP_COLLECTION, PROP_NONE);
1800 RNA_def_property_struct_runtime(prop, type);
1801 RNA_def_property_ui_text(prop, ui_name, ui_description);