2008-10-31 23:50:02 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <float.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2008-12-18 06:43:03 +00:00
|
|
|
#include <ctype.h>
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_genfile.h"
|
|
|
|
#include "DNA_sdna_types.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
|
|
/* Global used during defining */
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
BlenderDefRNA DefRNA = {0, {0, 0}, {0, 0}, 0, 0, 0};
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
/* Duplicated code since we can't link in blenkernel or blenlib */
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
#ifndef MIN2
|
2008-10-31 23:50:02 +00:00
|
|
|
#define MIN2(x,y) ((x)<(y)? (x): (y))
|
|
|
|
#define MAX2(x,y) ((x)>(y)? (x): (y))
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
#endif
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
void rna_addtail(ListBase *listbase, void *vlink)
|
|
|
|
{
|
|
|
|
Link *link= vlink;
|
|
|
|
|
|
|
|
link->next = NULL;
|
|
|
|
link->prev = listbase->last;
|
|
|
|
|
|
|
|
if (listbase->last) ((Link *)listbase->last)->next = link;
|
|
|
|
if (listbase->first == 0) listbase->first = link;
|
|
|
|
listbase->last = link;
|
|
|
|
}
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
void rna_remlink(ListBase *listbase, void *vlink)
|
|
|
|
{
|
|
|
|
Link *link= vlink;
|
|
|
|
|
|
|
|
if (link->next) link->next->prev = link->prev;
|
|
|
|
if (link->prev) link->prev->next = link->next;
|
|
|
|
|
|
|
|
if (listbase->last == link) listbase->last = link->prev;
|
|
|
|
if (listbase->first == link) listbase->first = link->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rna_freelinkN(ListBase *listbase, void *vlink)
|
|
|
|
{
|
|
|
|
rna_remlink(listbase, vlink);
|
|
|
|
MEM_freeN(vlink);
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void rna_freelistN(ListBase *listbase)
|
|
|
|
{
|
|
|
|
Link *link, *next;
|
|
|
|
|
|
|
|
for(link=listbase->first; link; link=next) {
|
|
|
|
next= link->next;
|
|
|
|
MEM_freeN(link);
|
|
|
|
}
|
|
|
|
|
|
|
|
listbase->first= listbase->last= NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *rna_find_struct_def(StructRNA *srna)
|
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
/* we should never get here */
|
|
|
|
fprintf(stderr, "rna_find_struct_def: only at preprocess time.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsrna= DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna= dsrna->cont.prev)
|
|
|
|
if (dsrna->srna==srna)
|
|
|
|
return dsrna;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyDefRNA *rna_find_struct_property_def(PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
PropertyDefRNA *dprop;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
/* we should never get here */
|
|
|
|
fprintf(stderr, "rna_find_property_def: only at preprocess time.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsrna= rna_find_struct_def(DefRNA.laststruct);
|
|
|
|
dprop= dsrna->cont.properties.last;
|
|
|
|
for (; dprop; dprop= dprop->prev)
|
|
|
|
if (dprop->prop==prop)
|
|
|
|
return dprop;
|
|
|
|
|
|
|
|
dsrna= DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna= dsrna->cont.prev) {
|
|
|
|
dprop= dsrna->cont.properties.last;
|
|
|
|
for (; dprop; dprop= dprop->prev)
|
|
|
|
if (dprop->prop==prop)
|
|
|
|
return dprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyDefRNA *rna_find_property_def(PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dprop;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
/* we should never get here */
|
|
|
|
fprintf(stderr, "rna_find_property_def: only at preprocess time.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dprop= rna_find_struct_property_def(prop);
|
|
|
|
if (dprop)
|
|
|
|
return dprop;
|
|
|
|
|
|
|
|
dprop= rna_find_parameter_def(prop);
|
|
|
|
if (dprop)
|
|
|
|
return dprop;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionDefRNA *rna_find_function_def(FunctionRNA *func)
|
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
/* we should never get here */
|
|
|
|
fprintf(stderr, "rna_find_function_def: only at preprocess time.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsrna= rna_find_struct_def(DefRNA.laststruct);
|
|
|
|
dfunc= dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc= dfunc->cont.prev)
|
|
|
|
if (dfunc->func==func)
|
|
|
|
return dfunc;
|
|
|
|
|
|
|
|
dsrna= DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna= dsrna->cont.prev) {
|
|
|
|
dfunc= dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc= dfunc->cont.prev)
|
|
|
|
if (dfunc->func==func)
|
|
|
|
return dfunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyDefRNA *rna_find_parameter_def(PropertyRNA *parm)
|
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
PropertyDefRNA *dparm;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
/* we should never get here */
|
|
|
|
fprintf(stderr, "rna_find_parameter_def: only at preprocess time.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsrna= rna_find_struct_def(DefRNA.laststruct);
|
|
|
|
dfunc= dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc= dfunc->cont.prev) {
|
|
|
|
dparm= dfunc->cont.properties.last;
|
|
|
|
for (; dparm; dparm= dparm->prev)
|
|
|
|
if (dparm->prop==parm)
|
|
|
|
return dparm;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsrna= DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna= dsrna->cont.prev) {
|
|
|
|
dfunc= dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc= dfunc->cont.prev) {
|
|
|
|
dparm= dfunc->cont.properties.last;
|
|
|
|
for (; dparm; dparm= dparm->prev)
|
|
|
|
if (dparm->prop==parm)
|
|
|
|
return dparm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ContainerDefRNA *rna_find_container_def(ContainerRNA *cont)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
/* we should never get here */
|
|
|
|
fprintf(stderr, "rna_find_container_def: only at preprocess time.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ds= rna_find_struct_def((StructRNA*)cont);
|
|
|
|
if(ds)
|
|
|
|
return &ds->cont;
|
|
|
|
|
|
|
|
dfunc= rna_find_function_def((FunctionRNA*)cont);
|
|
|
|
if(dfunc)
|
|
|
|
return &dfunc->cont;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* DNA utility function for looking up members */
|
|
|
|
|
|
|
|
typedef struct DNAStructMember {
|
|
|
|
char *type;
|
|
|
|
char *name;
|
|
|
|
int arraylength;
|
2008-11-26 22:24:26 +00:00
|
|
|
int pointerlevel;
|
2008-10-31 23:50:02 +00:00
|
|
|
} DNAStructMember;
|
|
|
|
|
|
|
|
static int rna_member_cmp(const char *name, const char *oname)
|
|
|
|
{
|
|
|
|
int a=0;
|
|
|
|
|
|
|
|
/* compare without pointer or array part */
|
|
|
|
while(name[0]=='*')
|
|
|
|
name++;
|
|
|
|
while(oname[0]=='*')
|
|
|
|
oname++;
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
if(name[a]=='[' && oname[a]==0) return 1;
|
2009-03-26 13:56:32 +00:00
|
|
|
if(name[a]=='[' && oname[a]=='[') return 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
if(name[a]==0) break;
|
|
|
|
if(name[a] != oname[a]) return 0;
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
if(name[a]==0 && oname[a] == '.') return 2;
|
|
|
|
if(name[a]==0 && oname[a] == '-' && oname[a+1] == '>') return 3;
|
|
|
|
|
|
|
|
return (name[a] == oname[a]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *membername, DNAStructMember *smember)
|
|
|
|
{
|
|
|
|
char *dnaname;
|
|
|
|
short *sp;
|
2008-11-26 22:24:26 +00:00
|
|
|
int a, b, structnr, totmember, cmp;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
structnr= DNA_struct_find_nr(sdna, structname);
|
|
|
|
if(structnr == -1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
sp= sdna->structs[structnr];
|
|
|
|
totmember= sp[1];
|
|
|
|
sp+= 2;
|
|
|
|
|
|
|
|
for(a=0; a<totmember; a++, sp+=2) {
|
|
|
|
dnaname= sdna->names[sp[1]];
|
|
|
|
|
|
|
|
cmp= rna_member_cmp(dnaname, membername);
|
|
|
|
|
|
|
|
if(cmp == 1) {
|
|
|
|
smember->type= sdna->types[sp[0]];
|
|
|
|
smember->name= dnaname;
|
2009-03-26 13:56:32 +00:00
|
|
|
|
|
|
|
if(strstr(membername, "["))
|
|
|
|
smember->arraylength= 0;
|
|
|
|
else
|
|
|
|
smember->arraylength= DNA_elem_array_size(smember->name, strlen(smember->name));
|
2008-11-26 22:24:26 +00:00
|
|
|
|
|
|
|
smember->pointerlevel= 0;
|
|
|
|
for(b=0; dnaname[b] == '*'; b++)
|
|
|
|
smember->pointerlevel++;
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(cmp == 2) {
|
2009-04-19 17:12:16 +00:00
|
|
|
smember->type= "";
|
|
|
|
smember->name= dnaname;
|
|
|
|
smember->pointerlevel= 0;
|
|
|
|
smember->arraylength= 0;
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
membername= strstr(membername, ".") + strlen(".");
|
2009-04-19 17:12:16 +00:00
|
|
|
rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
|
|
|
|
|
|
|
|
return 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else if(cmp == 3) {
|
2009-04-19 17:12:16 +00:00
|
|
|
smember->type= "";
|
|
|
|
smember->name= dnaname;
|
|
|
|
smember->pointerlevel= 0;
|
|
|
|
smember->arraylength= 0;
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
membername= strstr(membername, "->") + strlen("->");
|
2009-04-19 17:12:16 +00:00
|
|
|
rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
|
|
|
|
|
|
|
|
return 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
static int rna_validate_identifier(const char *identifier, char *error, int property)
|
2008-12-18 06:43:03 +00:00
|
|
|
{
|
|
|
|
int a=0;
|
|
|
|
|
2008-12-18 23:34:19 +00:00
|
|
|
/* list from http://docs.python.org/reference/lexical_analysis.html#id5 */
|
|
|
|
static char *kwlist[] = {
|
|
|
|
"and", "as", "assert", "break",
|
|
|
|
"class", "continue", "def", "del",
|
|
|
|
"elif", "else", "except", "exec",
|
|
|
|
"finally", "for", "from", "global",
|
|
|
|
"if", "import", "in", "is",
|
|
|
|
"lambda", "not", "or", "pass",
|
|
|
|
"print", "raise", "return", "try",
|
|
|
|
"while", "with", "yield", NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-12-18 06:43:03 +00:00
|
|
|
if (!isalpha(identifier[0])) {
|
2008-12-18 23:34:19 +00:00
|
|
|
strcpy(error, "first character failed isalpha() check");
|
2008-12-18 06:43:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
for(a=0; identifier[a]; a++) {
|
|
|
|
if(DefRNA.preprocess && property) {
|
|
|
|
if(isalpha(identifier[a]) && isupper(identifier[a])) {
|
|
|
|
strcpy(error, "property names must contain lower case characters only");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-18 23:34:19 +00:00
|
|
|
if (identifier[a]=='_') {
|
|
|
|
continue;
|
|
|
|
}
|
2009-01-10 22:57:33 +00:00
|
|
|
|
2009-01-15 05:41:25 +00:00
|
|
|
if (identifier[a]==' ') {
|
|
|
|
strcpy(error, "spaces are not ok in identifier names");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-18 23:34:19 +00:00
|
|
|
if (isalnum(identifier[a])==0) {
|
|
|
|
strcpy(error, "one of the characters failed an isalnum() check and is not an underscore");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(a=0; kwlist[a]; a++) {
|
|
|
|
if (strcmp(identifier, kwlist[a]) == 0) {
|
|
|
|
strcpy(error, "this keyword is reserved by python");
|
|
|
|
return 0;
|
|
|
|
}
|
2008-12-18 06:43:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Blender Data Definition */
|
|
|
|
|
|
|
|
BlenderRNA *RNA_create()
|
|
|
|
{
|
|
|
|
BlenderRNA *brna;
|
|
|
|
|
|
|
|
brna= MEM_callocN(sizeof(BlenderRNA), "BlenderRNA");
|
|
|
|
|
|
|
|
DefRNA.sdna= DNA_sdna_from_data(DNAstr, DNAlen, 0);
|
|
|
|
DefRNA.structs.first= DefRNA.structs.last= NULL;
|
|
|
|
DefRNA.error= 0;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
DefRNA.preprocess= 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return brna;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_define_free(BlenderRNA *brna)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
|
|
|
FunctionDefRNA *dfunc;
|
2008-10-31 23:50:02 +00:00
|
|
|
AllocDefRNA *alloc;
|
|
|
|
|
|
|
|
for(alloc=DefRNA.allocs.first; alloc; alloc=alloc->next)
|
|
|
|
MEM_freeN(alloc->mem);
|
|
|
|
rna_freelistN(&DefRNA.allocs);
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
for(ds=DefRNA.structs.first; ds; ds=ds->cont.next) {
|
|
|
|
for (dfunc= ds->functions.first; dfunc; dfunc= dfunc->cont.next)
|
|
|
|
rna_freelistN(&dfunc->cont.properties);
|
|
|
|
|
|
|
|
rna_freelistN(&ds->cont.properties);
|
|
|
|
rna_freelistN(&ds->functions);
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
rna_freelistN(&DefRNA.structs);
|
|
|
|
|
|
|
|
if(DefRNA.sdna) {
|
|
|
|
DNA_sdna_free(DefRNA.sdna);
|
|
|
|
DefRNA.sdna= NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DefRNA.error= 0;
|
|
|
|
}
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
FunctionRNA *func, *nextfunc;
|
2009-04-19 13:37:59 +00:00
|
|
|
PropertyRNA *prop, *nextprop;
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *parm, *nextparm;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
for(prop=srna->cont.properties.first; prop; prop=nextprop) {
|
|
|
|
nextprop= prop->next;
|
|
|
|
|
|
|
|
if(prop->flag & PROP_RUNTIME)
|
|
|
|
rna_freelinkN(&srna->cont.properties, prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(func=srna->functions.first; func; func=nextfunc) {
|
|
|
|
nextfunc= func->cont.next;
|
|
|
|
|
|
|
|
for(parm=func->cont.properties.first; parm; parm=nextparm) {
|
|
|
|
nextparm= parm->next;
|
|
|
|
|
|
|
|
if(parm->flag & PROP_RUNTIME)
|
|
|
|
rna_freelinkN(&func->cont.properties, parm);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(func->flag & FUNC_RUNTIME) {
|
|
|
|
rna_freelinkN(&srna->functions, func);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(srna->flag & STRUCT_RUNTIME)
|
|
|
|
rna_freelinkN(&brna->structs, srna);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_free(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna, *nextsrna;
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
RNA_define_free(brna);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
for(srna=brna->structs.first; srna; srna=srna->cont.next) {
|
|
|
|
for (func= srna->functions.first; func; func= func->cont.next)
|
|
|
|
rna_freelistN(&func->cont.properties);
|
|
|
|
|
|
|
|
rna_freelistN(&srna->cont.properties);
|
|
|
|
rna_freelistN(&srna->functions);
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_freelistN(&brna->structs);
|
|
|
|
|
|
|
|
MEM_freeN(brna);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(srna=brna->structs.first; srna; srna=nextsrna) {
|
2009-04-07 00:49:39 +00:00
|
|
|
nextsrna= srna->cont.next;
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_struct_free(brna, srna);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t rna_property_type_sizeof(PropertyType type)
|
|
|
|
{
|
|
|
|
switch(type) {
|
|
|
|
case PROP_BOOLEAN: return sizeof(BooleanPropertyRNA);
|
|
|
|
case PROP_INT: return sizeof(IntPropertyRNA);
|
|
|
|
case PROP_FLOAT: return sizeof(FloatPropertyRNA);
|
|
|
|
case PROP_STRING: return sizeof(StringPropertyRNA);
|
|
|
|
case PROP_ENUM: return sizeof(EnumPropertyRNA);
|
|
|
|
case PROP_POINTER: return sizeof(PointerPropertyRNA);
|
|
|
|
case PROP_COLLECTION: return sizeof(CollectionPropertyRNA);
|
|
|
|
default: return 0;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
static StructDefRNA *rna_find_def_struct(StructRNA *srna)
|
2008-11-29 19:08:46 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
|
2008-11-29 19:08:46 +00:00
|
|
|
if(ds->srna == srna)
|
2008-12-02 23:45:11 +00:00
|
|
|
return ds;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Struct Definition */
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
StructRNA *srna, *srnafrom= NULL;
|
2008-12-02 23:45:11 +00:00
|
|
|
StructDefRNA *ds= NULL, *dsfrom= NULL;
|
2009-02-02 19:57:57 +00:00
|
|
|
PropertyRNA *prop;
|
2008-12-18 06:43:03 +00:00
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
2008-12-18 23:34:19 +00:00
|
|
|
char error[512];
|
2009-01-10 22:57:33 +00:00
|
|
|
|
|
|
|
if (rna_validate_identifier(identifier, error, 0) == 0) {
|
2008-12-18 23:34:19 +00:00
|
|
|
fprintf(stderr, "RNA_def_struct: struct identifier \"%s\" error - %s\n", identifier, error);
|
2008-12-18 06:43:03 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(from) {
|
|
|
|
/* find struct to derive from */
|
2009-04-07 00:49:39 +00:00
|
|
|
for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->cont.next)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(strcmp(srnafrom->identifier, from) == 0)
|
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!srnafrom) {
|
|
|
|
fprintf(stderr, "RNA_def_struct: struct %s not found to define %s.\n", from, identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
srna= MEM_callocN(sizeof(StructRNA), "StructRNA");
|
2008-11-24 12:12:24 +00:00
|
|
|
DefRNA.laststruct= srna;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(srnafrom) {
|
2008-11-29 19:08:46 +00:00
|
|
|
/* copy from struct to derive stuff, a bit clumsy since we can't
|
|
|
|
* use MEM_dupallocN, data structs may not be alloced but builtin */
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
memcpy(srna, srnafrom, sizeof(StructRNA));
|
2009-04-07 00:49:39 +00:00
|
|
|
srna->cont.properties.first= srna->cont.properties.last= NULL;
|
|
|
|
srna->functions.first= srna->functions.last= NULL;
|
2009-05-28 02:03:48 +00:00
|
|
|
srna->py_type= NULL;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
if(DefRNA.preprocess) {
|
2009-01-10 22:57:33 +00:00
|
|
|
srna->base= srnafrom;
|
2008-12-02 23:45:11 +00:00
|
|
|
dsfrom= rna_find_def_struct(srnafrom);
|
|
|
|
}
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
else
|
2009-01-10 22:57:33 +00:00
|
|
|
srna->base= srnafrom;
|
2008-11-29 19:08:46 +00:00
|
|
|
}
|
2009-05-28 02:03:48 +00:00
|
|
|
|
2008-11-29 19:08:46 +00:00
|
|
|
srna->identifier= identifier;
|
2008-12-19 04:06:24 +00:00
|
|
|
srna->name= identifier; /* may be overwritten later RNA_def_struct_ui_text */
|
|
|
|
srna->description= "";
|
2008-11-29 19:08:46 +00:00
|
|
|
|
|
|
|
rna_addtail(&brna->structs, srna);
|
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
ds= MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
|
|
|
|
ds->srna= srna;
|
|
|
|
rna_addtail(&DefRNA.structs, ds);
|
2008-12-02 23:45:11 +00:00
|
|
|
|
|
|
|
if(dsfrom)
|
|
|
|
ds->dnafromname= dsfrom->dnaname;
|
2008-11-29 19:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* in preprocess, try to find sdna */
|
|
|
|
if(DefRNA.preprocess)
|
|
|
|
RNA_def_struct_sdna(srna, srna->identifier);
|
|
|
|
else
|
|
|
|
srna->flag |= STRUCT_RUNTIME;
|
|
|
|
|
|
|
|
if(srnafrom) {
|
2009-02-02 19:57:57 +00:00
|
|
|
srna->nameproperty= srnafrom->nameproperty;
|
|
|
|
srna->iteratorproperty= srnafrom->iteratorproperty;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
2008-11-29 19:08:46 +00:00
|
|
|
else {
|
|
|
|
/* define some builtin properties */
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(&srna->cont, "rna_properties", PROP_COLLECTION, PROP_NONE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_BUILTIN);
|
|
|
|
RNA_def_property_ui_text(prop, "Properties", "RNA property collection.");
|
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
RNA_def_property_struct_type(prop, "Property");
|
2009-02-02 19:57:57 +00:00
|
|
|
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);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
|
|
|
cprop->begin= rna_builtin_properties_begin;
|
|
|
|
cprop->next= rna_builtin_properties_next;
|
|
|
|
cprop->get= rna_builtin_properties_get;
|
2009-03-23 13:24:48 +00:00
|
|
|
cprop->type= &RNA_Property;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(&srna->cont, "rna_type", PROP_POINTER, PROP_NONE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_ui_text(prop, "RNA", "RNA type definition.");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2009-02-02 19:57:57 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
|
|
|
pprop->get= rna_builtin_type_get;
|
2009-03-23 13:24:48 +00:00
|
|
|
pprop->type= &RNA_Struct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
return srna;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
ds= rna_find_def_struct(srna);
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
if(!DNA_struct_find_nr(DefRNA.sdna, structname)) {
|
|
|
|
if(!DefRNA.silent) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_sdna: %s not found.\n", structname);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ds->dnaname= structname;
|
|
|
|
}
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
2008-12-02 23:45:11 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_sdna_from: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
ds= rna_find_def_struct(srna);
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
if(!ds->dnaname) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_sdna_from: %s base struct must know DNA already.\n", structname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!DNA_struct_find_nr(DefRNA.sdna, structname)) {
|
|
|
|
if(!DefRNA.silent) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_sdna_from: %s not found.\n", structname);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ds->dnafromprop= propname;
|
|
|
|
ds->dnaname= structname;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
if(prop->type != PROP_STRING) {
|
2008-11-14 18:46:57 +00:00
|
|
|
fprintf(stderr, "RNA_def_struct_name_property: %s.%s, must be a string property.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
srna->nameproperty= prop;
|
|
|
|
}
|
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
|
2009-01-09 16:08:47 +00:00
|
|
|
{
|
2009-01-10 22:57:33 +00:00
|
|
|
StructRNA *srnafrom;
|
2009-01-09 16:08:47 +00:00
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
/* find struct to derive from */
|
2009-04-07 00:49:39 +00:00
|
|
|
for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->cont.next)
|
2009-01-10 22:57:33 +00:00
|
|
|
if(strcmp(srnafrom->identifier, structname) == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(!srnafrom) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_nested: struct %s not found.\n", structname);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
srna->nested= srnafrom;
|
2009-01-09 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_struct_flag(StructRNA *srna, int flag)
|
|
|
|
{
|
|
|
|
srna->flag= flag;
|
|
|
|
}
|
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
{
|
|
|
|
if(!DefRNA.preprocess) {
|
2009-01-01 15:52:51 +00:00
|
|
|
fprintf(stderr, "RNA_def_struct_refine_func: only during preprocessing.\n");
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(refine) srna->refine= (StructRefineFunc)refine;
|
|
|
|
}
|
|
|
|
|
2009-05-20 09:52:02 +00:00
|
|
|
void RNA_def_struct_idproperties_func(StructRNA *srna, const char *idproperties)
|
|
|
|
{
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_idproperties_func: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(idproperties) srna->idproperties= (IDPropertiesFunc)idproperties;
|
|
|
|
}
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg)
|
|
|
|
{
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_register_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(reg) srna->reg= (StructRegisterFunc)reg;
|
|
|
|
if(unreg) srna->unreg= (StructUnregisterFunc)unreg;
|
|
|
|
}
|
|
|
|
|
2009-03-25 20:29:01 +00:00
|
|
|
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
|
|
|
|
{
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_path_func: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(path) srna->path= (StructPathFunc)path;
|
|
|
|
}
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
void RNA_def_struct_identifier(StructRNA *srna, const char *identifier)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
{
|
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_name_runtime: only at runtime.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
srna->identifier= identifier;
|
2008-12-19 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
|
|
|
|
{
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
srna->name= name;
|
2008-12-19 04:06:24 +00:00
|
|
|
srna->description= description;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Property Definition */
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
|
|
|
ContainerRNA *cont= cont_;
|
|
|
|
ContainerDefRNA *dcont;
|
|
|
|
PropertyDefRNA *dprop= NULL;
|
2008-10-31 23:50:02 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(DefRNA.preprocess) {
|
2008-12-18 23:34:19 +00:00
|
|
|
char error[512];
|
2008-12-18 06:43:03 +00:00
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
if (rna_validate_identifier(identifier, error, 1) == 0) {
|
2008-12-18 23:34:19 +00:00
|
|
|
fprintf(stderr, "RNA_def_property: property identifier \"%s\" - %s\n", identifier, error);
|
2008-12-18 06:43:03 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
dcont= rna_find_container_def(cont);
|
|
|
|
dprop= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
|
|
|
|
rna_addtail(&dcont->properties, dprop);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
prop= MEM_callocN(rna_property_type_sizeof(type), "PropertyRNA");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
break;
|
|
|
|
case PROP_INT: {
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
iprop->hardmin= (subtype == PROP_UNSIGNED)? 0: INT_MIN;
|
|
|
|
iprop->hardmax= INT_MAX;
|
|
|
|
|
|
|
|
iprop->softmin= (subtype == PROP_UNSIGNED)? 0: -10000; /* rather arbitrary .. */
|
|
|
|
iprop->softmax= 10000;
|
2008-11-14 17:05:25 +00:00
|
|
|
iprop->step= 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-01 00:23:08 +00:00
|
|
|
fprop->hardmin= (subtype == PROP_UNSIGNED)? 0.0f: -FLT_MAX;
|
2008-10-31 23:50:02 +00:00
|
|
|
fprop->hardmax= FLT_MAX;
|
|
|
|
|
2009-01-02 13:47:33 +00:00
|
|
|
if(subtype == PROP_COLOR) {
|
|
|
|
fprop->softmin= 0.0f;
|
|
|
|
fprop->softmax= 1.0f;
|
|
|
|
}
|
2009-02-17 21:07:01 +00:00
|
|
|
else if(subtype == PROP_PERCENTAGE) {
|
|
|
|
fprop->softmin= fprop->hardmin= 0.0f;
|
|
|
|
fprop->softmax= fprop->hardmax= 1.0f;
|
|
|
|
}
|
2009-01-02 13:47:33 +00:00
|
|
|
else {
|
|
|
|
fprop->softmin= (subtype == PROP_UNSIGNED)? 0.0f: -10000.0f; /* rather arbitrary .. */
|
|
|
|
fprop->softmax= 10000.0f;
|
|
|
|
}
|
2008-11-14 17:05:25 +00:00
|
|
|
fprop->step= 10;
|
|
|
|
fprop->precision= 3;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_STRING: {
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
sprop->defaultvalue= "";
|
|
|
|
sprop->maxlength= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_ENUM:
|
|
|
|
case PROP_POINTER:
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
break;
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property: %s.%s, invalid property type.\n", srna->identifier, identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
dprop->cont= cont;
|
|
|
|
dprop->prop= prop;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-17 18:44:06 +00:00
|
|
|
prop->magic= RNA_MAGIC;
|
2008-11-14 18:46:57 +00:00
|
|
|
prop->identifier= identifier;
|
2008-10-31 23:50:02 +00:00
|
|
|
prop->type= type;
|
|
|
|
prop->subtype= subtype;
|
2008-11-14 18:46:57 +00:00
|
|
|
prop->name= identifier;
|
2008-10-31 23:50:02 +00:00
|
|
|
prop->description= "";
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
if(type != PROP_COLLECTION && type != PROP_POINTER) {
|
|
|
|
prop->flag= PROP_EDITABLE;
|
|
|
|
|
|
|
|
if(type != PROP_STRING)
|
|
|
|
prop->flag |= PROP_ANIMATEABLE;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
switch(type) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
DefRNA.silent= 1;
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, identifier, 0);
|
|
|
|
DefRNA.silent= 0;
|
|
|
|
break;
|
|
|
|
case PROP_INT: {
|
|
|
|
DefRNA.silent= 1;
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, identifier);
|
|
|
|
DefRNA.silent= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
|
|
|
DefRNA.silent= 1;
|
|
|
|
RNA_def_property_float_sdna(prop, NULL, identifier);
|
|
|
|
DefRNA.silent= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_STRING: {
|
|
|
|
DefRNA.silent= 1;
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, identifier);
|
|
|
|
DefRNA.silent= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_ENUM:
|
|
|
|
DefRNA.silent= 1;
|
2008-12-03 20:17:12 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, identifier);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
DefRNA.silent= 0;
|
|
|
|
break;
|
|
|
|
case PROP_POINTER:
|
|
|
|
DefRNA.silent= 1;
|
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, identifier);
|
|
|
|
DefRNA.silent= 0;
|
|
|
|
break;
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
DefRNA.silent= 1;
|
|
|
|
RNA_def_property_collection_sdna(prop, NULL, identifier, NULL);
|
|
|
|
DefRNA.silent= 0;
|
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
else
|
|
|
|
prop->flag |= PROP_IDPROPERTY|PROP_RUNTIME;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_addtail(&cont->properties, prop);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_flag(PropertyRNA *prop, int flag)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-14 14:34:19 +00:00
|
|
|
prop->flag |= flag;
|
2009-03-23 13:24:48 +00:00
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2009-03-23 13:24:48 +00:00
|
|
|
void RNA_def_property_clear_flag(PropertyRNA *prop, int flag)
|
|
|
|
{
|
|
|
|
prop->flag &= ~flag;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_array(PropertyRNA *prop, int arraylength)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
|
|
|
if(arraylength<0) {
|
|
|
|
fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be zero of greater.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
if(arraylength>RNA_MAX_ARRAY) {
|
|
|
|
fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be smaller than %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
case PROP_INT:
|
|
|
|
case PROP_FLOAT:
|
|
|
|
prop->arraylength= arraylength;
|
|
|
|
break;
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_array: %s.%s, only boolean/int/float can be array.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
|
|
|
|
{
|
|
|
|
prop->name= name;
|
|
|
|
prop->description= description;
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_INT: {
|
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
iprop->softmin= (int)min;
|
|
|
|
iprop->softmax= (int)max;
|
|
|
|
iprop->step= (int)step;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
fprop->softmin= (float)min;
|
|
|
|
fprop->softmax= (float)max;
|
|
|
|
fprop->step= (float)step;
|
2008-11-14 18:46:57 +00:00
|
|
|
fprop->precision= (int)precision;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_ui_range: %s.%s, invalid type for ui range.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_INT: {
|
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
iprop->hardmin= (int)min;
|
|
|
|
iprop->hardmax= (int)max;
|
2008-11-01 00:23:08 +00:00
|
|
|
iprop->softmin= MAX2((int)min, iprop->hardmin);
|
|
|
|
iprop->softmax= MIN2((int)max, iprop->hardmax);
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
fprop->hardmin= (float)min;
|
|
|
|
fprop->hardmax= (float)max;
|
2008-11-01 00:23:08 +00:00
|
|
|
fprop->softmin= MAX2((float)min, fprop->hardmin);
|
|
|
|
fprop->softmax= MIN2((float)max, fprop->hardmax);
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_range: %s.%s, invalid type for range.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_struct_type: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_POINTER: {
|
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
2009-03-23 13:24:48 +00:00
|
|
|
pprop->type = (StructRNA*)type;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION: {
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
2009-03-23 13:24:48 +00:00
|
|
|
cprop->type = (StructRNA*)type;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_struct_type: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
|
|
|
|
{
|
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_struct_runtime: only at runtime.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_POINTER: {
|
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
2009-03-23 13:24:48 +00:00
|
|
|
pprop->type = type;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION: {
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
2009-03-23 13:24:48 +00:00
|
|
|
cprop->type = type;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "RNA_def_property_struct_runtime: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2009-03-06 10:22:12 +00:00
|
|
|
int i, defaultfound= 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_ENUM: {
|
|
|
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
|
|
|
eprop->item= item;
|
|
|
|
eprop->totitem= 0;
|
2009-03-06 10:22:12 +00:00
|
|
|
for(i=0; item[i].identifier; i++) {
|
2008-10-31 23:50:02 +00:00
|
|
|
eprop->totitem++;
|
|
|
|
|
2009-03-06 10:22:12 +00:00
|
|
|
if(item[i].value == eprop->defaultvalue)
|
|
|
|
defaultfound= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!defaultfound)
|
|
|
|
eprop->defaultvalue= item[0].value;
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2009-01-02 13:47:33 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_enum_items: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_STRING: {
|
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
|
|
|
sprop->maxlength= maxlength;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_string_maxlength: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_BOOLEAN: {
|
|
|
|
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
|
|
|
bprop->defaultvalue= value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_BOOLEAN: {
|
|
|
|
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
|
|
|
bprop->defaultarray= array;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_int_default(PropertyRNA *prop, int value)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_INT: {
|
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
iprop->defaultvalue= value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_INT: {
|
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
iprop->defaultarray= array;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_float_default(PropertyRNA *prop, float value)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_FLOAT: {
|
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
fprop->defaultvalue= value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-02-01 14:24:44 +00:00
|
|
|
/* array must remain valid after this function finishes */
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_FLOAT: {
|
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
2009-02-01 14:24:44 +00:00
|
|
|
fprop->defaultarray= array; /* WARNING, this array must not come from the stack and lost */
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_STRING: {
|
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
|
|
|
sprop->defaultvalue= value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_string_default: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
|
|
|
|
{
|
2008-11-29 14:35:50 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2009-03-06 10:22:12 +00:00
|
|
|
int i, defaultfound= 0;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_ENUM: {
|
|
|
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
|
|
|
eprop->defaultvalue= value;
|
2009-03-06 10:22:12 +00:00
|
|
|
|
|
|
|
for(i=0; i<eprop->totitem; i++) {
|
|
|
|
if(eprop->item[i].value == eprop->defaultvalue)
|
|
|
|
defaultfound= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!defaultfound && eprop->totitem) {
|
|
|
|
if(value == 0) {
|
|
|
|
eprop->defaultvalue= eprop->item[0].value;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "RNA_def_property_enum_default: %s.%s, default is not in items.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_enum_default: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SDNA */
|
|
|
|
|
|
|
|
static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
DNAStructMember smember;
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
|
|
|
dp= rna_find_struct_property_def(prop);
|
|
|
|
if (dp==NULL) return NULL;
|
|
|
|
|
|
|
|
ds= rna_find_struct_def((StructRNA*)dp->cont);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
if(!structname)
|
|
|
|
structname= ds->dnaname;
|
|
|
|
if(!propname)
|
2008-11-14 18:46:57 +00:00
|
|
|
propname= prop->identifier;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
if(!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember)) {
|
|
|
|
if(!DefRNA.silent) {
|
|
|
|
fprintf(stderr, "rna_def_property_sdna: %s.%s not found.\n", structname, propname);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(smember.arraylength > 1)
|
|
|
|
prop->arraylength= smember.arraylength;
|
|
|
|
else
|
|
|
|
prop->arraylength= 0;
|
|
|
|
|
|
|
|
dp->dnastructname= structname;
|
2008-12-02 23:45:11 +00:00
|
|
|
dp->dnastructfromname= ds->dnafromname;
|
|
|
|
dp->dnastructfromprop= ds->dnafromprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
dp->dnaname= propname;
|
|
|
|
dp->dnatype= smember.type;
|
|
|
|
dp->dnaarraylength= smember.arraylength;
|
2008-11-26 22:24:26 +00:00
|
|
|
dp->dnapointerlevel= smember.pointerlevel;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return dp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->type != PROP_BOOLEAN) {
|
|
|
|
fprintf(stderr, "RNA_def_property_boolean_sdna: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
if((dp=rna_def_property_sdna(prop, structname, propname)))
|
|
|
|
dp->booleanbit= bit;
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:17:12 +00:00
|
|
|
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int booleanbit)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit);
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
dp= rna_find_struct_property_def(prop);
|
|
|
|
|
|
|
|
if(dp)
|
2008-12-03 20:17:12 +00:00
|
|
|
dp->booleannegative= 1;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->type != PROP_INT) {
|
|
|
|
fprintf(stderr, "RNA_def_property_int_sdna: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
if((dp= rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
/* SDNA doesn't pass us unsigned unfortunately .. */
|
|
|
|
if(strcmp(dp->dnatype, "char") == 0) {
|
|
|
|
iprop->hardmin= iprop->softmin= CHAR_MIN;
|
|
|
|
iprop->hardmax= iprop->softmax= CHAR_MAX;
|
|
|
|
}
|
|
|
|
else if(strcmp(dp->dnatype, "short") == 0) {
|
|
|
|
iprop->hardmin= iprop->softmin= SHRT_MIN;
|
|
|
|
iprop->hardmax= iprop->softmax= SHRT_MAX;
|
|
|
|
}
|
|
|
|
else if(strcmp(dp->dnatype, "int") == 0) {
|
|
|
|
iprop->hardmin= INT_MIN;
|
|
|
|
iprop->hardmax= INT_MAX;
|
|
|
|
|
|
|
|
iprop->softmin= -10000; /* rather arbitrary .. */
|
|
|
|
iprop->softmax= 10000;
|
|
|
|
}
|
|
|
|
|
UI:
* Added support for soft/hard range in the buttons code. Currently
it works by only allowing to drag or click increment in the soft
range, but typing a number value allows to go outside it.
If the number is outside the soft range, the range will be extended,
rounded to values like:
.., 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, ..
2009-03-29 18:44:49 +00:00
|
|
|
if(prop->subtype == PROP_UNSIGNED || prop->subtype == PROP_PERCENTAGE)
|
2008-10-31 23:50:02 +00:00
|
|
|
iprop->hardmin= iprop->softmin= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(prop->type != PROP_FLOAT) {
|
|
|
|
fprintf(stderr, "RNA_def_property_float_sdna: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
rna_def_property_sdna(prop, structname, propname);
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:17:12 +00:00
|
|
|
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->type != PROP_ENUM) {
|
|
|
|
fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
if((dp=rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
if(prop->arraylength) {
|
|
|
|
prop->arraylength= 0;
|
|
|
|
if(!DefRNA.silent) {
|
|
|
|
fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, array not supported for enum type.\n", structname, propname);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:17:12 +00:00
|
|
|
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
|
|
|
RNA_def_property_enum_sdna(prop, structname, propname);
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
dp= rna_find_struct_property_def(prop);
|
|
|
|
|
|
|
|
if(dp)
|
2009-04-11 01:43:50 +00:00
|
|
|
dp->enumbitflags= 1;
|
2008-12-03 20:17:12 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->type != PROP_STRING) {
|
|
|
|
fprintf(stderr, "RNA_def_property_string_sdna: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
if((dp=rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
if(prop->arraylength) {
|
|
|
|
sprop->maxlength= prop->arraylength;
|
|
|
|
prop->arraylength= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->type != PROP_POINTER) {
|
|
|
|
fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
if((dp=rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
if(prop->arraylength) {
|
|
|
|
prop->arraylength= 0;
|
|
|
|
if(!DefRNA.silent) {
|
|
|
|
fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, array not supported for pointer type.\n", structname, propname);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->type != PROP_COLLECTION) {
|
|
|
|
fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
if((dp=rna_def_property_sdna(prop, structname, propname))) {
|
2008-12-02 23:45:11 +00:00
|
|
|
if(prop->arraylength && !lengthpropname) {
|
2008-10-31 23:50:02 +00:00
|
|
|
prop->arraylength= 0;
|
|
|
|
|
|
|
|
if(!DefRNA.silent) {
|
2008-12-02 23:45:11 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, array of collections not supported.\n", structname, propname);
|
2008-10-31 23:50:02 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(dp->dnatype, "ListBase") == 0) {
|
|
|
|
cprop->next= (PropCollectionNextFunc)"rna_iterator_listbase_next";
|
|
|
|
cprop->get= (PropCollectionGetFunc)"rna_iterator_listbase_get";
|
2008-11-17 18:44:06 +00:00
|
|
|
cprop->end= (PropCollectionEndFunc)"rna_iterator_listbase_end";
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
|
|
|
|
if(dp && lengthpropname) {
|
|
|
|
DNAStructMember smember;
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds= rna_find_struct_def((StructRNA*)dp->cont);
|
2008-11-07 02:58:25 +00:00
|
|
|
|
|
|
|
if(!structname)
|
|
|
|
structname= ds->dnaname;
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
if(lengthpropname[0] == 0 || rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember)) {
|
|
|
|
if(lengthpropname[0] == 0) {
|
|
|
|
dp->dnalengthfixed= prop->arraylength;
|
|
|
|
prop->arraylength= 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dp->dnalengthstructname= structname;
|
|
|
|
dp->dnalengthname= lengthpropname;
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cprop->next= (PropCollectionNextFunc)"rna_iterator_array_next";
|
|
|
|
cprop->end= (PropCollectionEndFunc)"rna_iterator_array_end";
|
2008-11-26 22:24:26 +00:00
|
|
|
|
|
|
|
if(dp->dnapointerlevel >= 2)
|
|
|
|
cprop->get= (PropCollectionGetFunc)"rna_iterator_array_dereference_get";
|
|
|
|
else
|
|
|
|
cprop->get= (PropCollectionGetFunc)"rna_iterator_array_get";
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-12-02 23:45:11 +00:00
|
|
|
else {
|
|
|
|
if(!DefRNA.silent) {
|
|
|
|
fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s not found.\n", structname, lengthpropname);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Functions */
|
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(!DefRNA.preprocess) {
|
2009-01-01 15:52:51 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_editable_func: only during preprocessing.\n");
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(editable) prop->editable= (EditableFunc)editable;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
|
|
|
|
{
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_refine_func: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop->noteflag= noteflag;
|
|
|
|
prop->update= (UpdateFunc)func;
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_BOOLEAN: {
|
|
|
|
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
|
|
|
|
|
|
|
if(prop->arraylength) {
|
|
|
|
if(get) bprop->getarray= (PropBooleanArrayGetFunc)get;
|
|
|
|
if(set) bprop->setarray= (PropBooleanArraySetFunc)set;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(get) bprop->get= (PropBooleanGetFunc)get;
|
|
|
|
if(set) bprop->set= (PropBooleanSetFunc)set;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_boolean_funcs: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_INT: {
|
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
|
|
|
|
if(prop->arraylength) {
|
|
|
|
if(get) iprop->getarray= (PropIntArrayGetFunc)get;
|
|
|
|
if(set) iprop->setarray= (PropIntArraySetFunc)set;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(get) iprop->get= (PropIntGetFunc)get;
|
|
|
|
if(set) iprop->set= (PropIntSetFunc)set;
|
|
|
|
}
|
2008-11-24 12:12:24 +00:00
|
|
|
if(range) iprop->range= (PropIntRangeFunc)range;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_int_funcs: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_FLOAT: {
|
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
|
|
|
|
if(prop->arraylength) {
|
|
|
|
if(get) fprop->getarray= (PropFloatArrayGetFunc)get;
|
|
|
|
if(set) fprop->setarray= (PropFloatArraySetFunc)set;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(get) fprop->get= (PropFloatGetFunc)get;
|
|
|
|
if(set) fprop->set= (PropFloatSetFunc)set;
|
|
|
|
}
|
2008-11-24 12:12:24 +00:00
|
|
|
if(range) fprop->range= (PropFloatRangeFunc)range;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_float_funcs: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-28 23:23:47 +00:00
|
|
|
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
|
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_ENUM: {
|
|
|
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
if(get) eprop->get= (PropEnumGetFunc)get;
|
|
|
|
if(set) eprop->set= (PropEnumSetFunc)set;
|
2009-05-28 23:23:47 +00:00
|
|
|
if(item) eprop->itemf= (PropEnumItemFunc)item;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_enum_funcs: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_STRING: {
|
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
|
|
|
|
|
|
|
if(get) sprop->get= (PropStringGetFunc)get;
|
|
|
|
if(length) sprop->length= (PropStringLengthFunc)length;
|
|
|
|
if(set) sprop->set= (PropStringSetFunc)set;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_string_funcs: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_POINTER: {
|
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
|
|
|
|
|
|
|
if(get) pprop->get= (PropPointerGetFunc)get;
|
|
|
|
if(set) pprop->set= (PropPointerSetFunc)set;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_pointer_funcs: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
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)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
StructRNA *srna= DefRNA.laststruct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
|
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_COLLECTION: {
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
if(begin) cprop->begin= (PropCollectionBeginFunc)begin;
|
|
|
|
if(next) cprop->next= (PropCollectionNextFunc)next;
|
|
|
|
if(end) cprop->end= (PropCollectionEndFunc)end;
|
|
|
|
if(get) cprop->get= (PropCollectionGetFunc)get;
|
|
|
|
if(length) cprop->length= (PropCollectionLengthFunc)length;
|
|
|
|
if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint;
|
|
|
|
if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_collection_funcs: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
|
2008-11-14 14:34:19 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 23:53:11 +00:00
|
|
|
/* Compact definitions */
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, int default_value, const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_boolean_default(prop, default_value);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value,
|
|
|
|
const char *ui_name, const char *ui_description)
|
2009-03-04 15:30:47 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-03-04 15:30:47 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
|
2009-03-04 15:30:47 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if(default_value) RNA_def_property_boolean_array_default(prop, default_value);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value,
|
|
|
|
const char *ui_name, const char *ui_description)
|
2009-03-04 15:30:47 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-03-04 15:30:47 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_VECTOR);
|
2009-03-04 15:30:47 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if(default_value) RNA_def_property_boolean_array_default(prop, default_value);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description, int softmin, int softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_int_default(prop, default_value);
|
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_INT, PROP_VECTOR);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_int_array_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_int_array_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_STRING, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_string_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_STRING, PROP_FILEPATH);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_string_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_string_dir_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_STRING, PROP_DIRPATH);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_string_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, EnumPropertyItem *items, int default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(items) RNA_def_property_enum_items(prop, items);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_enum_default(prop, default_value);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_float_default(prop, default_value);
|
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_VECTOR);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_float_array_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_COLOR);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_float_array_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_float_array_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_ROTATION);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_float_array_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(len != 0) RNA_def_property_array(prop, len);
|
2009-01-16 23:58:10 +00:00
|
|
|
if(default_value) RNA_def_property_float_array_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_, const char *identifier, float default_value,
|
2009-02-17 21:07:01 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-02-17 21:07:01 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE);
|
2009-02-17 21:07:01 +00:00
|
|
|
RNA_def_property_float_default(prop, default_value);
|
|
|
|
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type,
|
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
|
|
|
ContainerRNA *cont= cont_;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
prop= RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
|
|
|
|
RNA_def_property_struct_type(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_struct_runtime(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_collection(StructOrFunctionRNA *cont_, const char *identifier, const char *type,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerRNA *cont= cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
prop= RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
|
|
|
|
RNA_def_property_struct_type(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type,
|
|
|
|
const char *ui_name, const char *ui_description)
|
|
|
|
{
|
|
|
|
ContainerRNA *cont= cont_;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
prop= RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_struct_runtime(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
/* Function */
|
|
|
|
|
|
|
|
static FunctionRNA *rna_def_function(StructRNA *srna, const char *identifier)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
char error[512];
|
|
|
|
|
|
|
|
if (rna_validate_identifier(identifier, error, 0) == 0) {
|
|
|
|
fprintf(stderr, "RNA_def_function: function identifier \"%s\" - %s\n", identifier, error);
|
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func= MEM_callocN(sizeof(FunctionRNA), "FunctionRNA");
|
|
|
|
func->identifier= identifier;
|
|
|
|
func->description= identifier;
|
|
|
|
|
|
|
|
rna_addtail(&srna->functions, func);
|
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
dsrna= rna_find_struct_def(srna);
|
|
|
|
dfunc= MEM_callocN(sizeof(FunctionDefRNA), "FunctionDefRNA");
|
|
|
|
rna_addtail(&dsrna->functions, dfunc);
|
|
|
|
dfunc->func= func;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
func->flag|= FUNC_RUNTIME;
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
|
|
|
func= rna_def_function(srna, identifier);
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_function: only at preprocess time.\n");
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
dfunc= rna_find_function_def(func);
|
|
|
|
dfunc->call= call;
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
|
|
|
func= rna_def_function(srna, identifier);
|
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_function_call_runtime: only at runtime.\n");
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
func->call= call;
|
|
|
|
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
|
|
|
|
{
|
|
|
|
func->ret= ret;
|
2009-04-19 13:37:59 +00:00
|
|
|
ret->flag|=PROP_RETURN;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_function_flag(FunctionRNA *func, int flag)
|
|
|
|
{
|
|
|
|
func->flag|= flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
|
|
|
|
{
|
|
|
|
func->description= description;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rna_parameter_size(PropertyRNA *parm)
|
|
|
|
{
|
|
|
|
PropertyType ptype= parm->type;
|
|
|
|
int len= parm->arraylength;
|
|
|
|
|
|
|
|
if(len > 0) {
|
|
|
|
switch (ptype) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
case PROP_INT:
|
|
|
|
return sizeof(int)*len;
|
|
|
|
case PROP_FLOAT:
|
|
|
|
return sizeof(float)*len;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (ptype) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
case PROP_INT:
|
|
|
|
case PROP_ENUM:
|
|
|
|
return sizeof(int);
|
|
|
|
case PROP_FLOAT:
|
|
|
|
return sizeof(float);
|
|
|
|
case PROP_STRING:
|
|
|
|
return sizeof(char *);
|
|
|
|
case PROP_POINTER: {
|
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)parm;
|
|
|
|
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
if(pprop->type == &RNA_AnyType)
|
|
|
|
return sizeof(PointerRNA);
|
|
|
|
else
|
|
|
|
return sizeof(void *);
|
|
|
|
#else
|
|
|
|
if(strcmp((char*)pprop->type, "AnyType") == 0)
|
|
|
|
return sizeof(PointerRNA);
|
|
|
|
else
|
|
|
|
return sizeof(void *);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
/* XXX does not work yet */
|
|
|
|
return sizeof(ListBase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sizeof(void *);
|
|
|
|
}
|
|
|
|
|