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_identifier(StructRNA *srna, const char *identifier)
519 if(DefRNA.preprocess) {
520 fprintf(stderr, "RNA_def_struct_name_runtime: only at runtime.\n");
524 srna->identifier= identifier;
527 void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
530 srna->description= description;
533 void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
535 rna_freelistN(&srna->properties);
536 rna_freelinkN(&brna->structs, srna);
539 /* Property Definition */
541 PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type, int subtype)
544 PropertyDefRNA *dp= NULL;
547 if(DefRNA.preprocess) {
550 if (rna_validate_identifier(identifier, error, 1) == 0) {
551 fprintf(stderr, "RNA_def_property: property identifier \"%s\" - %s\n", identifier, error);
555 ds= DefRNA.structs.last;
556 dp= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
557 rna_addtail(&ds->properties, dp);
560 prop= MEM_callocN(rna_property_type_sizeof(type), "PropertyRNA");
566 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
568 iprop->hardmin= (subtype == PROP_UNSIGNED)? 0: INT_MIN;
569 iprop->hardmax= INT_MAX;
571 iprop->softmin= (subtype == PROP_UNSIGNED)? 0: -10000; /* rather arbitrary .. */
572 iprop->softmax= 10000;
577 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
579 fprop->hardmin= (subtype == PROP_UNSIGNED)? 0.0f: -FLT_MAX;
580 fprop->hardmax= FLT_MAX;
582 if(subtype == PROP_COLOR) {
583 fprop->softmin= 0.0f;
584 fprop->softmax= 1.0f;
586 else if(subtype == PROP_PERCENTAGE) {
587 fprop->softmin= fprop->hardmin= 0.0f;
588 fprop->softmax= fprop->hardmax= 1.0f;
591 fprop->softmin= (subtype == PROP_UNSIGNED)? 0.0f: -10000.0f; /* rather arbitrary .. */
592 fprop->softmax= 10000.0f;
599 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
601 sprop->defaultvalue= "";
607 case PROP_COLLECTION:
610 fprintf(stderr, "RNA_def_property: %s.%s, invalid property type.\n", srna->identifier, identifier);
615 if(DefRNA.preprocess) {
620 prop->magic= RNA_MAGIC;
621 prop->identifier= identifier;
623 prop->subtype= subtype;
624 prop->name= identifier;
625 prop->description= "";
627 if(type != PROP_COLLECTION && type != PROP_POINTER)
628 prop->flag= PROP_EDITABLE|PROP_ANIMATEABLE;
630 if(DefRNA.preprocess) {
634 RNA_def_property_boolean_sdna(prop, NULL, identifier, 0);
639 RNA_def_property_int_sdna(prop, NULL, identifier);
645 RNA_def_property_float_sdna(prop, NULL, identifier);
651 RNA_def_property_string_sdna(prop, NULL, identifier);
657 RNA_def_property_enum_sdna(prop, NULL, identifier);
662 RNA_def_property_pointer_sdna(prop, NULL, identifier);
665 case PROP_COLLECTION:
667 RNA_def_property_collection_sdna(prop, NULL, identifier, NULL);
673 prop->flag |= PROP_IDPROPERTY|PROP_RUNTIME;
675 rna_addtail(&srna->properties, prop);
680 void RNA_def_property_flag(PropertyRNA *prop, int flag)
685 void RNA_def_property_clear_flag(PropertyRNA *prop, int flag)
690 void RNA_def_property_array(PropertyRNA *prop, int arraylength)
692 StructRNA *srna= DefRNA.laststruct;
695 fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be zero of greater.\n", srna->identifier, prop->identifier);
700 if(arraylength>RNA_MAX_ARRAY) {
701 fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be smaller than %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY);
710 prop->arraylength= arraylength;
713 fprintf(stderr, "RNA_def_property_array: %s.%s, only boolean/int/float can be array.\n", srna->identifier, prop->identifier);
719 void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
722 prop->description= description;
725 void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
727 StructRNA *srna= DefRNA.laststruct;
731 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
732 iprop->softmin= (int)min;
733 iprop->softmax= (int)max;
734 iprop->step= (int)step;
738 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
739 fprop->softmin= (float)min;
740 fprop->softmax= (float)max;
741 fprop->step= (float)step;
742 fprop->precision= (int)precision;
746 fprintf(stderr, "RNA_def_property_ui_range: %s.%s, invalid type for ui range.\n", srna->identifier, prop->identifier);
752 void RNA_def_property_range(PropertyRNA *prop, double min, double max)
754 StructRNA *srna= DefRNA.laststruct;
758 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
759 iprop->hardmin= (int)min;
760 iprop->hardmax= (int)max;
761 iprop->softmin= MAX2((int)min, iprop->hardmin);
762 iprop->softmax= MIN2((int)max, iprop->hardmax);
766 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
767 fprop->hardmin= (float)min;
768 fprop->hardmax= (float)max;
769 fprop->softmin= MAX2((float)min, fprop->hardmin);
770 fprop->softmax= MIN2((float)max, fprop->hardmax);
774 fprintf(stderr, "RNA_def_property_range: %s.%s, invalid type for range.\n", srna->identifier, prop->identifier);
780 void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
782 StructRNA *srna= DefRNA.laststruct;
784 if(!DefRNA.preprocess) {
785 fprintf(stderr, "RNA_def_property_struct_type: only during preprocessing.\n");
791 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
792 pprop->type = (StructRNA*)type;
795 case PROP_COLLECTION: {
796 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
797 cprop->type = (StructRNA*)type;
801 fprintf(stderr, "RNA_def_property_struct_type: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
807 void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
809 StructRNA *srna= DefRNA.laststruct;
811 if(DefRNA.preprocess) {
812 fprintf(stderr, "RNA_def_property_struct_runtime: only at runtime.\n");
818 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
822 case PROP_COLLECTION: {
823 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
828 fprintf(stderr, "RNA_def_property_struct_runtime: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
834 void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
836 StructRNA *srna= DefRNA.laststruct;
837 int i, defaultfound= 0;
841 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
844 for(i=0; item[i].identifier; i++) {
847 if(item[i].value == eprop->defaultvalue)
852 eprop->defaultvalue= item[0].value;
857 fprintf(stderr, "RNA_def_property_enum_items: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
863 void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
865 StructRNA *srna= DefRNA.laststruct;
869 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
870 sprop->maxlength= maxlength;
874 fprintf(stderr, "RNA_def_property_string_maxlength: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
880 void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
882 StructRNA *srna= DefRNA.laststruct;
886 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
887 bprop->defaultvalue= value;
891 fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
897 void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
899 StructRNA *srna= DefRNA.laststruct;
903 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
904 bprop->defaultarray= array;
908 fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
914 void RNA_def_property_int_default(PropertyRNA *prop, int value)
916 StructRNA *srna= DefRNA.laststruct;
920 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
921 iprop->defaultvalue= value;
925 fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
931 void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
933 StructRNA *srna= DefRNA.laststruct;
937 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
938 iprop->defaultarray= array;
942 fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
948 void RNA_def_property_float_default(PropertyRNA *prop, float value)
950 StructRNA *srna= DefRNA.laststruct;
954 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
955 fprop->defaultvalue= value;
959 fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
964 /* array must remain valid after this function finishes */
965 void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
967 StructRNA *srna= DefRNA.laststruct;
971 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
972 fprop->defaultarray= array; /* WARNING, this array must not come from the stack and lost */
976 fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
982 void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
984 StructRNA *srna= DefRNA.laststruct;
988 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
989 sprop->defaultvalue= value;
993 fprintf(stderr, "RNA_def_property_string_default: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
999 void RNA_def_property_enum_default(PropertyRNA *prop, int value)
1001 StructRNA *srna= DefRNA.laststruct;
1002 int i, defaultfound= 0;
1004 switch(prop->type) {
1006 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1007 eprop->defaultvalue= value;
1009 for(i=0; i<eprop->totitem; i++) {
1010 if(eprop->item[i].value == eprop->defaultvalue)
1014 if(!defaultfound && eprop->totitem) {
1016 eprop->defaultvalue= eprop->item[0].value;
1019 fprintf(stderr, "RNA_def_property_enum_default: %s.%s, default is not in items.\n", srna->identifier, prop->identifier);
1027 fprintf(stderr, "RNA_def_property_enum_default: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
1035 static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1037 DNAStructMember smember;
1038 StructDefRNA *ds= DefRNA.structs.last;
1039 PropertyDefRNA *dp= ds->properties.last;
1042 structname= ds->dnaname;
1044 propname= prop->identifier;
1046 if(!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember)) {
1047 if(!DefRNA.silent) {
1048 fprintf(stderr, "rna_def_property_sdna: %s.%s not found.\n", structname, propname);
1054 if(smember.arraylength > 1)
1055 prop->arraylength= smember.arraylength;
1057 prop->arraylength= 0;
1059 dp->dnastructname= structname;
1060 dp->dnastructfromname= ds->dnafromname;
1061 dp->dnastructfromprop= ds->dnafromprop;
1062 dp->dnaname= propname;
1063 dp->dnatype= smember.type;
1064 dp->dnaarraylength= smember.arraylength;
1065 dp->dnapointerlevel= smember.pointerlevel;
1070 void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit)
1073 StructRNA *srna= DefRNA.laststruct;
1075 if(!DefRNA.preprocess) {
1076 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1080 if(prop->type != PROP_BOOLEAN) {
1081 fprintf(stderr, "RNA_def_property_boolean_sdna: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
1086 if((dp=rna_def_property_sdna(prop, structname, propname)))
1087 dp->booleanbit= bit;
1090 void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int booleanbit)
1095 RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit);
1097 if((ds=DefRNA.structs.last) && (dp=ds->properties.last))
1098 dp->booleannegative= 1;
1101 void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1104 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
1105 StructRNA *srna= DefRNA.laststruct;
1107 if(!DefRNA.preprocess) {
1108 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1112 if(prop->type != PROP_INT) {
1113 fprintf(stderr, "RNA_def_property_int_sdna: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
1118 if((dp= rna_def_property_sdna(prop, structname, propname))) {
1119 /* SDNA doesn't pass us unsigned unfortunately .. */
1120 if(strcmp(dp->dnatype, "char") == 0) {
1121 iprop->hardmin= iprop->softmin= CHAR_MIN;
1122 iprop->hardmax= iprop->softmax= CHAR_MAX;
1124 else if(strcmp(dp->dnatype, "short") == 0) {
1125 iprop->hardmin= iprop->softmin= SHRT_MIN;
1126 iprop->hardmax= iprop->softmax= SHRT_MAX;
1128 else if(strcmp(dp->dnatype, "int") == 0) {
1129 iprop->hardmin= INT_MIN;
1130 iprop->hardmax= INT_MAX;
1132 iprop->softmin= -10000; /* rather arbitrary .. */
1133 iprop->softmax= 10000;
1136 if(prop->subtype == PROP_UNSIGNED)
1137 iprop->hardmin= iprop->softmin= 0;
1141 void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1143 StructRNA *srna= DefRNA.laststruct;
1145 if(!DefRNA.preprocess) {
1146 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1150 if(prop->type != PROP_FLOAT) {
1151 fprintf(stderr, "RNA_def_property_float_sdna: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
1156 rna_def_property_sdna(prop, structname, propname);
1159 void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1162 StructRNA *srna= DefRNA.laststruct;
1164 if(!DefRNA.preprocess) {
1165 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1169 if(prop->type != PROP_ENUM) {
1170 fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
1175 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1176 if(prop->arraylength) {
1177 prop->arraylength= 0;
1178 if(!DefRNA.silent) {
1179 fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, array not supported for enum type.\n", structname, propname);
1186 void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1191 RNA_def_property_enum_sdna(prop, structname, propname);
1193 if((ds=DefRNA.structs.last) && (dp=ds->properties.last))
1194 dp->enumbitflags= 1;
1197 void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1200 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
1201 StructRNA *srna= DefRNA.laststruct;
1203 if(!DefRNA.preprocess) {
1204 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1208 if(prop->type != PROP_STRING) {
1209 fprintf(stderr, "RNA_def_property_string_sdna: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
1214 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1215 if(prop->arraylength) {
1216 sprop->maxlength= prop->arraylength;
1217 prop->arraylength= 0;
1222 void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
1225 StructRNA *srna= DefRNA.laststruct;
1227 if(!DefRNA.preprocess) {
1228 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1232 if(prop->type != PROP_POINTER) {
1233 fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
1238 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1239 if(prop->arraylength) {
1240 prop->arraylength= 0;
1241 if(!DefRNA.silent) {
1242 fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, array not supported for pointer type.\n", structname, propname);
1249 void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
1252 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
1253 StructRNA *srna= DefRNA.laststruct;
1255 if(!DefRNA.preprocess) {
1256 fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
1260 if(prop->type != PROP_COLLECTION) {
1261 fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
1266 if((dp=rna_def_property_sdna(prop, structname, propname))) {
1267 if(prop->arraylength && !lengthpropname) {
1268 prop->arraylength= 0;
1270 if(!DefRNA.silent) {
1271 fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, array of collections not supported.\n", structname, propname);
1276 if(strcmp(dp->dnatype, "ListBase") == 0) {
1277 cprop->next= (PropCollectionNextFunc)"rna_iterator_listbase_next";
1278 cprop->get= (PropCollectionGetFunc)"rna_iterator_listbase_get";
1279 cprop->end= (PropCollectionEndFunc)"rna_iterator_listbase_end";
1283 if(dp && lengthpropname) {
1284 DNAStructMember smember;
1285 StructDefRNA *ds= DefRNA.structs.last;
1288 structname= ds->dnaname;
1290 if(lengthpropname[0] == 0 || rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember)) {
1291 if(lengthpropname[0] == 0) {
1292 dp->dnalengthfixed= prop->arraylength;
1293 prop->arraylength= 0;
1296 dp->dnalengthstructname= structname;
1297 dp->dnalengthname= lengthpropname;
1300 cprop->next= (PropCollectionNextFunc)"rna_iterator_array_next";
1301 cprop->end= (PropCollectionEndFunc)"rna_iterator_array_end";
1303 if(dp->dnapointerlevel >= 2)
1304 cprop->get= (PropCollectionGetFunc)"rna_iterator_array_dereference_get";
1306 cprop->get= (PropCollectionGetFunc)"rna_iterator_array_get";
1309 if(!DefRNA.silent) {
1310 fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s not found.\n", structname, lengthpropname);
1319 void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
1321 if(!DefRNA.preprocess) {
1322 fprintf(stderr, "RNA_def_property_editable_func: only during preprocessing.\n");
1326 if(editable) prop->editable= (EditableFunc)editable;
1329 void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
1331 if(!DefRNA.preprocess) {
1332 fprintf(stderr, "RNA_def_struct_refine_func: only during preprocessing.\n");
1336 prop->noteflag= noteflag;
1337 prop->update= (UpdateFunc)func;
1340 void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
1342 StructRNA *srna= DefRNA.laststruct;
1344 if(!DefRNA.preprocess) {
1345 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1349 switch(prop->type) {
1350 case PROP_BOOLEAN: {
1351 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
1353 if(prop->arraylength) {
1354 if(get) bprop->getarray= (PropBooleanArrayGetFunc)get;
1355 if(set) bprop->setarray= (PropBooleanArraySetFunc)set;
1358 if(get) bprop->get= (PropBooleanGetFunc)get;
1359 if(set) bprop->set= (PropBooleanSetFunc)set;
1364 fprintf(stderr, "RNA_def_property_boolean_funcs: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
1370 void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
1372 StructRNA *srna= DefRNA.laststruct;
1374 if(!DefRNA.preprocess) {
1375 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1379 switch(prop->type) {
1381 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
1383 if(prop->arraylength) {
1384 if(get) iprop->getarray= (PropIntArrayGetFunc)get;
1385 if(set) iprop->setarray= (PropIntArraySetFunc)set;
1388 if(get) iprop->get= (PropIntGetFunc)get;
1389 if(set) iprop->set= (PropIntSetFunc)set;
1391 if(range) iprop->range= (PropIntRangeFunc)range;
1395 fprintf(stderr, "RNA_def_property_int_funcs: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
1401 void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
1403 StructRNA *srna= DefRNA.laststruct;
1405 if(!DefRNA.preprocess) {
1406 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1410 switch(prop->type) {
1412 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
1414 if(prop->arraylength) {
1415 if(get) fprop->getarray= (PropFloatArrayGetFunc)get;
1416 if(set) fprop->setarray= (PropFloatArraySetFunc)set;
1419 if(get) fprop->get= (PropFloatGetFunc)get;
1420 if(set) fprop->set= (PropFloatSetFunc)set;
1422 if(range) fprop->range= (PropFloatRangeFunc)range;
1426 fprintf(stderr, "RNA_def_property_float_funcs: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
1432 void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set)
1434 StructRNA *srna= DefRNA.laststruct;
1436 if(!DefRNA.preprocess) {
1437 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1441 switch(prop->type) {
1443 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1445 if(get) eprop->get= (PropEnumGetFunc)get;
1446 if(set) eprop->set= (PropEnumSetFunc)set;
1450 fprintf(stderr, "RNA_def_property_enum_funcs: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
1456 void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
1458 StructRNA *srna= DefRNA.laststruct;
1460 if(!DefRNA.preprocess) {
1461 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1465 switch(prop->type) {
1467 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
1469 if(get) sprop->get= (PropStringGetFunc)get;
1470 if(length) sprop->length= (PropStringLengthFunc)length;
1471 if(set) sprop->set= (PropStringSetFunc)set;
1475 fprintf(stderr, "RNA_def_property_string_funcs: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
1481 void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set)
1483 StructRNA *srna= DefRNA.laststruct;
1485 if(!DefRNA.preprocess) {
1486 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1490 switch(prop->type) {
1491 case PROP_POINTER: {
1492 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
1494 if(get) pprop->get= (PropPointerGetFunc)get;
1495 if(set) pprop->set= (PropPointerSetFunc)set;
1499 fprintf(stderr, "RNA_def_property_pointer_funcs: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
1505 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)
1507 StructRNA *srna= DefRNA.laststruct;
1509 if(!DefRNA.preprocess) {
1510 fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
1514 switch(prop->type) {
1515 case PROP_COLLECTION: {
1516 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
1518 if(begin) cprop->begin= (PropCollectionBeginFunc)begin;
1519 if(next) cprop->next= (PropCollectionNextFunc)next;
1520 if(end) cprop->end= (PropCollectionEndFunc)end;
1521 if(get) cprop->get= (PropCollectionGetFunc)get;
1522 if(length) cprop->length= (PropCollectionLengthFunc)length;
1523 if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint;
1524 if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring;
1528 fprintf(stderr, "RNA_def_property_collection_funcs: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
1534 /* Compact definitions */
1536 PropertyRNA *RNA_def_boolean(StructRNA *srna, const char *identifier, int default_value,
1537 const char *ui_name, const char *ui_description)
1541 prop= RNA_def_property(srna, identifier, PROP_BOOLEAN, PROP_NONE);
1542 RNA_def_property_boolean_default(prop, default_value);
1543 RNA_def_property_ui_text(prop, ui_name, ui_description);
1548 PropertyRNA *RNA_def_boolean_array(StructRNA *srna, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description)
1552 prop= RNA_def_property(srna, identifier, PROP_BOOLEAN, PROP_NONE);
1553 if(len != 0) RNA_def_property_array(prop, len);
1554 if(default_value) RNA_def_property_boolean_array_default(prop, default_value);
1555 RNA_def_property_ui_text(prop, ui_name, ui_description);
1560 PropertyRNA *RNA_def_boolean_vector(StructRNA *srna, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description)
1564 prop= RNA_def_property(srna, identifier, PROP_BOOLEAN, PROP_VECTOR);
1565 if(len != 0) RNA_def_property_array(prop, len);
1566 if(default_value) RNA_def_property_boolean_array_default(prop, default_value);
1567 RNA_def_property_ui_text(prop, ui_name, ui_description);
1572 PropertyRNA *RNA_def_int(StructRNA *srna, const char *identifier, int default_value, int hardmin, int hardmax,
1573 const char *ui_name, const char *ui_description, int softmin, int softmax)
1577 prop= RNA_def_property(srna, identifier, PROP_INT, PROP_NONE);
1578 RNA_def_property_int_default(prop, default_value);
1579 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1580 RNA_def_property_ui_text(prop, ui_name, ui_description);
1581 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1586 PropertyRNA *RNA_def_int_vector(StructRNA *srna, const char *identifier, int len, const int *default_value,
1587 int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
1591 prop= RNA_def_property(srna, identifier, PROP_INT, PROP_VECTOR);
1592 if(len != 0) RNA_def_property_array(prop, len);
1593 if(default_value) RNA_def_property_int_array_default(prop, default_value);
1594 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1595 RNA_def_property_ui_text(prop, ui_name, ui_description);
1596 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1601 PropertyRNA *RNA_def_int_array(StructRNA *srna, const char *identifier, int len, const int *default_value,
1602 int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
1606 prop= RNA_def_property(srna, identifier, PROP_INT, PROP_NONE);
1607 if(len != 0) RNA_def_property_array(prop, len);
1608 if(default_value) RNA_def_property_int_array_default(prop, default_value);
1609 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1610 RNA_def_property_ui_text(prop, ui_name, ui_description);
1611 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1616 PropertyRNA *RNA_def_string(StructRNA *srna, const char *identifier, const char *default_value, int maxlen,
1617 const char *ui_name, const char *ui_description)
1621 prop= RNA_def_property(srna, identifier, PROP_STRING, PROP_NONE);
1622 if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
1623 if(default_value) RNA_def_property_string_default(prop, default_value);
1624 RNA_def_property_ui_text(prop, ui_name, ui_description);
1629 PropertyRNA *RNA_def_string_file_path(StructRNA *srna, const char *identifier, const char *default_value, int maxlen,
1630 const char *ui_name, const char *ui_description)
1634 prop= RNA_def_property(srna, identifier, PROP_STRING, PROP_FILEPATH);
1635 if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
1636 if(default_value) RNA_def_property_string_default(prop, default_value);
1637 RNA_def_property_ui_text(prop, ui_name, ui_description);
1642 PropertyRNA *RNA_def_string_dir_path(StructRNA *srna, const char *identifier, const char *default_value, int maxlen,
1643 const char *ui_name, const char *ui_description)
1647 prop= RNA_def_property(srna, identifier, PROP_STRING, PROP_DIRPATH);
1648 if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
1649 if(default_value) RNA_def_property_string_default(prop, default_value);
1650 RNA_def_property_ui_text(prop, ui_name, ui_description);
1655 PropertyRNA *RNA_def_enum(StructRNA *srna, const char *identifier, EnumPropertyItem *items, int default_value,
1656 const char *ui_name, const char *ui_description)
1660 prop= RNA_def_property(srna, identifier, PROP_ENUM, PROP_NONE);
1661 if(items) RNA_def_property_enum_items(prop, items);
1662 RNA_def_property_enum_default(prop, default_value);
1663 RNA_def_property_ui_text(prop, ui_name, ui_description);
1668 PropertyRNA *RNA_def_float(StructRNA *srna, const char *identifier, float default_value,
1669 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1673 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_NONE);
1674 RNA_def_property_float_default(prop, default_value);
1675 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1676 RNA_def_property_ui_text(prop, ui_name, ui_description);
1677 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1682 PropertyRNA *RNA_def_float_vector(StructRNA *srna, const char *identifier, int len, const float *default_value,
1683 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1687 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_VECTOR);
1688 if(len != 0) RNA_def_property_array(prop, len);
1689 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1690 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1691 RNA_def_property_ui_text(prop, ui_name, ui_description);
1692 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1697 PropertyRNA *RNA_def_float_color(StructRNA *srna, const char *identifier, int len, const float *default_value,
1698 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1702 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_COLOR);
1703 if(len != 0) RNA_def_property_array(prop, len);
1704 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1705 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1706 RNA_def_property_ui_text(prop, ui_name, ui_description);
1707 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1713 PropertyRNA *RNA_def_float_matrix(StructRNA *srna, const char *identifier, int len, const float *default_value,
1714 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1718 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_MATRIX);
1719 if(len != 0) RNA_def_property_array(prop, len);
1720 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1721 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1722 RNA_def_property_ui_text(prop, ui_name, ui_description);
1723 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1728 PropertyRNA *RNA_def_float_rotation(StructRNA *srna, const char *identifier, int len, const float *default_value,
1729 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1733 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_ROTATION);
1734 if(len != 0) RNA_def_property_array(prop, len);
1735 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1736 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1737 RNA_def_property_ui_text(prop, ui_name, ui_description);
1738 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1743 PropertyRNA *RNA_def_float_array(StructRNA *srna, const char *identifier, int len, const float *default_value,
1744 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1748 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_NONE);
1749 if(len != 0) RNA_def_property_array(prop, len);
1750 if(default_value) RNA_def_property_float_array_default(prop, default_value);
1751 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1752 RNA_def_property_ui_text(prop, ui_name, ui_description);
1753 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1758 PropertyRNA *RNA_def_float_percentage(StructRNA *srna, const char *identifier, float default_value,
1759 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
1763 prop= RNA_def_property(srna, identifier, PROP_FLOAT, PROP_PERCENTAGE);
1764 RNA_def_property_float_default(prop, default_value);
1765 if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
1766 RNA_def_property_ui_text(prop, ui_name, ui_description);
1767 RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
1772 PropertyRNA *RNA_def_pointer_runtime(StructRNA *srna, const char *identifier, StructRNA *type,
1773 const char *ui_name, const char *ui_description)
1777 prop= RNA_def_property(srna, identifier, PROP_POINTER, PROP_NONE);
1778 RNA_def_property_struct_runtime(prop, type);
1779 RNA_def_property_ui_text(prop, ui_name, ui_description);
1784 PropertyRNA *RNA_def_collection_runtime(StructRNA *srna, const char *identifier, StructRNA *type,
1785 const char *ui_name, const char *ui_description)
1789 prop= RNA_def_property(srna, identifier, PROP_COLLECTION, PROP_NONE);
1790 RNA_def_property_struct_runtime(prop, type);
1791 RNA_def_property_ui_text(prop, ui_name, ui_description);