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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
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;
|
|
|
|
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) {
|
|
|
|
membername= strstr(membername, ".") + strlen(".");
|
|
|
|
return rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
|
|
|
|
}
|
|
|
|
else if(cmp == 3) {
|
|
|
|
membername= strstr(membername, "->") + strlen("->");
|
|
|
|
return rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-18 23:34:19 +00:00
|
|
|
static int rna_validate_identifier(const char *identifier, char *error)
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(a=1; identifier[a] != '\0'; a++) {
|
2008-12-18 23:34:19 +00:00
|
|
|
if (identifier[a]=='_') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2008-11-07 02:58:25 +00:00
|
|
|
StructDefRNA *srna;
|
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);
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
for(srna=DefRNA.structs.first; srna; srna=srna->next)
|
|
|
|
rna_freelistN(&srna->properties);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_free(BlenderRNA *brna)
|
|
|
|
{
|
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, *nextsrna;
|
|
|
|
PropertyRNA *prop, *nextprop;
|
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_define_free(brna);
|
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
|
|
|
for(srna=brna->structs.first; srna; srna=srna->next)
|
|
|
|
rna_freelistN(&srna->properties);
|
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) {
|
|
|
|
nextsrna= srna->next;
|
|
|
|
|
|
|
|
for(prop=srna->properties.first; prop; prop=nextprop) {
|
|
|
|
nextprop= prop->next;
|
|
|
|
|
|
|
|
if(prop->flag & PROP_RUNTIME)
|
|
|
|
rna_freelinkN(&srna->properties, prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(srna->flag & STRUCT_RUNTIME)
|
|
|
|
rna_freelinkN(&brna->structs, srna);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
for(ds=DefRNA.structs.first; ds; ds=ds->next)
|
|
|
|
if(ds->srna == srna)
|
2008-12-02 23:45:11 +00:00
|
|
|
return ds;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PropertyDefRNA *rna_find_def_property(StructRNA *srna, PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds= rna_find_def_struct(srna);
|
|
|
|
PropertyDefRNA *dp;
|
2008-11-29 19:08:46 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
if(ds)
|
|
|
|
for(dp=ds->properties.first; dp; dp=dp->next)
|
|
|
|
if(dp->prop == prop)
|
|
|
|
return dp;
|
|
|
|
|
2008-11-29 19:08:46 +00:00
|
|
|
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;
|
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
|
|
|
PropertyRNA *prop, *propfrom;
|
2008-12-18 06:43:03 +00:00
|
|
|
|
|
|
|
if(DefRNA.preprocess) {
|
2008-12-18 23:34:19 +00:00
|
|
|
char error[512];
|
|
|
|
if (rna_validate_identifier(identifier, error) == 0) {
|
|
|
|
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 */
|
|
|
|
for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->next)
|
|
|
|
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));
|
|
|
|
srna->properties.first= srna->properties.last= NULL;
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
if(DefRNA.preprocess) {
|
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->from= (StructRNA*)from;
|
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
|
|
|
|
srna->from= srnafrom;
|
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) {
|
|
|
|
/* 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
|
|
|
|
|
|
|
for(propfrom= srnafrom->properties.first; propfrom; propfrom=propfrom->next) {
|
|
|
|
prop= RNA_def_property(srna, propfrom->identifier, propfrom->type, propfrom->subtype);
|
|
|
|
|
|
|
|
rna_remlink(&srna->properties, prop);
|
|
|
|
memcpy(prop, propfrom, rna_property_type_sizeof(propfrom->type));
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess)
|
|
|
|
prop->flag |= PROP_RUNTIME;
|
|
|
|
|
|
|
|
prop->next= prop->prev= NULL;
|
|
|
|
rna_addtail(&srna->properties, prop);
|
|
|
|
|
|
|
|
if(propfrom == srnafrom->nameproperty)
|
|
|
|
srna->nameproperty= prop;
|
|
|
|
if(propfrom == srnafrom->iteratorproperty)
|
|
|
|
srna->iteratorproperty= prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-29 19:08:46 +00:00
|
|
|
if(DefRNA.preprocess) {
|
|
|
|
PropertyDefRNA *dp, *dpfrom;
|
|
|
|
|
|
|
|
dp= ds->properties.last;
|
|
|
|
dpfrom= rna_find_def_property(srnafrom, propfrom);
|
|
|
|
|
|
|
|
rna_remlink(&ds->properties, dp);
|
|
|
|
memcpy(dp, dpfrom, sizeof(*dp));
|
|
|
|
dp->srna= srna;
|
|
|
|
dp->prop= prop;
|
|
|
|
dp->next= dp->prev= NULL;
|
|
|
|
rna_addtail(&ds->properties, dp);
|
|
|
|
}
|
|
|
|
}
|
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 */
|
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= RNA_def_property(srna, "rna_properties", PROP_COLLECTION, PROP_NONE);
|
|
|
|
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");
|
|
|
|
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, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
|
|
|
cprop->begin= rna_builtin_properties_begin;
|
|
|
|
cprop->next= rna_builtin_properties_next;
|
|
|
|
cprop->next= rna_iterator_listbase_end;
|
|
|
|
cprop->get= rna_builtin_properties_get;
|
|
|
|
cprop->structtype= &RNA_Property;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "rna_type", PROP_POINTER, PROP_NONE);
|
|
|
|
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
|
|
|
|
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");
|
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
|
|
|
pprop->get= rna_builtin_type_get;
|
|
|
|
pprop->structtype= &RNA_Struct;
|
|
|
|
#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)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds= DefRNA.structs.last;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds= DefRNA.structs.last;
|
|
|
|
|
|
|
|
if(!DefRNA.preprocess) {
|
|
|
|
fprintf(stderr, "RNA_def_struct_sdna_from: only during preprocessing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
|
|
|
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
|
|
|
|
{
|
|
|
|
rna_freelistN(&srna->properties);
|
|
|
|
rna_freelinkN(&brna->structs, srna);
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Property Definition */
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type, int subtype)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
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
|
|
|
PropertyDefRNA *dp= 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
|
|
|
|
2008-12-18 23:34:19 +00:00
|
|
|
if (rna_validate_identifier(identifier, error) == 0) {
|
|
|
|
fprintf(stderr, "RNA_def_property: property identifier \"%s\" - %s\n", identifier, error);
|
2008-12-18 06:43:03 +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
|
|
|
ds= DefRNA.structs.last;
|
|
|
|
dp= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
|
|
|
|
rna_addtail(&ds->properties, dp);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2008-11-01 00:23:08 +00:00
|
|
|
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) {
|
|
|
|
dp->srna= srna;
|
|
|
|
dp->prop= prop;
|
|
|
|
}
|
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
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
if(type == PROP_COLLECTION || type == PROP_POINTER)
|
2008-11-14 14:34:19 +00:00
|
|
|
prop->flag= PROP_NOT_EDITABLE|PROP_NOT_DRIVEABLE;
|
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
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
rna_addtail(&srna->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 17:05:25 +00:00
|
|
|
#if 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
|
|
|
StructRNA *srna;
|
2008-11-14 17:05:25 +00:00
|
|
|
#endif
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
prop->flag |= flag;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
#if 0
|
2008-11-07 02:58:25 +00:00
|
|
|
if(prop->type != PROP_POINTER && prop->type != PROP_COLLECTION) {
|
|
|
|
if(flag & (PROP_EVALUATE_DEPENDENCY|PROP_INVERSE_EVALUATE_DEPENDENCY|PROP_RENDER_DEPENDENCY|PROP_INVERSE_RENDER_DEPENDENCY)) {
|
2008-11-14 18:46:57 +00:00
|
|
|
fprintf(stderr, "RNA_def_property_flag: %s.%s, only pointer and collection types can create dependencies.\n", ds->srna->identifier, prop->identifier);
|
2008-11-07 02:58:25 +00:00
|
|
|
DefRNA.error= 1;
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
#endif
|
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
|
|
|
|
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;
|
|
|
|
pprop->structtype = (StructRNA*)type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION: {
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
|
|
|
cprop->structtype = (StructRNA*)type;
|
|
|
|
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;
|
|
|
|
pprop->structtype = type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION: {
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
|
|
|
cprop->structtype = type;
|
|
|
|
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;
|
2008-10-31 23:50:02 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
switch(prop->type) {
|
|
|
|
case PROP_ENUM: {
|
|
|
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
|
|
|
eprop->item= item;
|
|
|
|
eprop->totitem= 0;
|
2008-11-14 18:46:57 +00:00
|
|
|
for(i=0; item[i].identifier; i++)
|
2008-10-31 23:50:02 +00:00
|
|
|
eprop->totitem++;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
fprop->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_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;
|
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;
|
|
|
|
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;
|
|
|
|
StructDefRNA *ds= DefRNA.structs.last;
|
|
|
|
PropertyDefRNA *dp= ds->properties.last;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit);
|
|
|
|
|
|
|
|
if((ds=DefRNA.structs.last) && (dp=ds->properties.last))
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(prop->subtype == PROP_UNSIGNED)
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
|
|
|
RNA_def_property_enum_sdna(prop, structname, propname);
|
|
|
|
|
|
|
|
if((ds=DefRNA.structs.last) && (dp=ds->properties.last))
|
|
|
|
dp->enumbitflags= 1;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
StructDefRNA *ds= DefRNA.structs.last;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_enum_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-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;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *type, 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(type) pprop->type= (PropPointerTypeFunc)type;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *type, 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(type) cprop->type= (PropCollectionTypeFunc)type;
|
|
|
|
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
|
|
|
}
|
|
|
|
|