2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-10-31 23:50:02 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-10-31 23:50:02 +00:00
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:20:01 +00:00
|
|
|
/** \file blender/makesrna/intern/rna_define.c
|
|
|
|
* \ingroup RNA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#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"
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
#include "BLI_ghash.h"
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
2009-06-19 23:05:21 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
|
|
/* Global used during defining */
|
|
|
|
|
2011-03-03 17:58:06 +00:00
|
|
|
BlenderDefRNA DefRNA = {NULL, {NULL, NULL}, {NULL, NULL}, NULL, 0, 0, 0, 1};
|
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
|
|
|
|
2011-09-21 17:52:51 +00:00
|
|
|
/* pedantic check for '.', do this since its a hassle for translators */
|
|
|
|
#ifndef NDEBUG
|
|
|
|
# define DESCR_CHECK(description, id1, id2) \
|
2012-03-18 09:27:36 +00:00
|
|
|
if (description && (description)[0]) { \
|
2011-09-21 17:52:51 +00:00
|
|
|
int i = strlen(description); \
|
2012-03-18 09:27:36 +00:00
|
|
|
if ((description)[i - 1] == '.') { \
|
2011-09-21 17:52:51 +00:00
|
|
|
fprintf(stderr, "%s: '%s' '%s' description ends with a '.' !\n", \
|
|
|
|
__func__, id1 ? id1 : "", id2 ? id2 : ""); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
|
|
|
|
#else
|
|
|
|
# define DESCR_CHECK(description, id1, id2)
|
|
|
|
#endif
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void rna_addtail(ListBase *listbase, void *vlink)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Link *link = vlink;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
link->next = NULL;
|
|
|
|
link->prev = listbase->last;
|
|
|
|
|
|
|
|
if (listbase->last) ((Link *)listbase->last)->next = link;
|
2011-03-03 17:58:06 +00:00
|
|
|
if (listbase->first == NULL) listbase->first = link;
|
2008-10-31 23:50:02 +00:00
|
|
|
listbase->last = link;
|
|
|
|
}
|
|
|
|
|
2009-09-14 16:52:06 +00:00
|
|
|
static void rna_remlink(ListBase *listbase, void *vlink)
|
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
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Link *link = vlink;
|
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 (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;
|
|
|
|
}
|
|
|
|
|
2009-08-09 10:05:33 +00:00
|
|
|
PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier)
|
|
|
|
{
|
|
|
|
Link *link;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (link = listbase->first; link; link = link->next) {
|
|
|
|
PropertyRNA *prop = ((PropertyDefRNA *)link)->prop;
|
|
|
|
if (prop && (strcmp(prop->identifier, identifier) == 0)) {
|
2009-08-09 10:05:33 +00:00
|
|
|
return (PropertyDefRNA *)link;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
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;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (link = listbase->first; link; link = next) {
|
|
|
|
next = link->next;
|
2008-10-31 23:50:02 +00:00
|
|
|
MEM_freeN(link);
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
listbase->first = listbase->last = NULL;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *rna_find_struct_def(StructRNA *srna)
|
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
/* we should never get here */
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at preprocess time.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna = dsrna->cont.prev)
|
|
|
|
if (dsrna->srna == srna)
|
2009-04-07 00:49:39 +00:00
|
|
|
return dsrna;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
RNA
Implementation of RNA side of foreach_get/foreach_set,
Campbell will do python code.
Three functions for efficiently setting some property for all
items in a collection. RNA_property_collection_raw_array gives
access to the properties as an array with length, stride, and
type specified, if this is possible, i.e. not when it uses a
ListBase, or if a manual get/set function is implemented.
Two other functions take a C array pointer and get/set it
using the a collection + property name, using efficient array
access if possible, and otherwise using slower RNA iterator.
RNA_property_collection_raw_get
RNA_property_collection_raw_set
The number of type conversion required here got a bit out of
hand, it could be more efficient still if checking for more
cases, but function is already long enough.
Example: http://www.pasteall.org/6362/c
2009-06-29 19:15:51 +00:00
|
|
|
PropertyDefRNA *rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
PropertyDefRNA *dprop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
/* we should never get here */
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at preprocess time.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = rna_find_struct_def(srna);
|
|
|
|
dprop = dsrna->cont.properties.last;
|
|
|
|
for (; dprop; dprop = dprop->prev)
|
|
|
|
if (dprop->prop == prop)
|
2009-04-07 00:49:39 +00:00
|
|
|
return dprop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna = dsrna->cont.prev) {
|
|
|
|
dprop = dsrna->cont.properties.last;
|
|
|
|
for (; dprop; dprop = dprop->prev)
|
|
|
|
if (dprop->prop == prop)
|
2009-04-07 00:49:39 +00:00
|
|
|
return dprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-16 18:04:01 +00:00
|
|
|
#if 0
|
2009-09-14 16:52:06 +00:00
|
|
|
static PropertyDefRNA *rna_find_property_def(PropertyRNA *prop)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
|
|
|
PropertyDefRNA *dprop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
/* we should never get here */
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at preprocess time.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dprop = rna_find_struct_property_def(DefRNA.laststruct, prop);
|
2009-04-07 00:49:39 +00:00
|
|
|
if (dprop)
|
|
|
|
return dprop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dprop = rna_find_parameter_def(prop);
|
2009-04-07 00:49:39 +00:00
|
|
|
if (dprop)
|
|
|
|
return dprop;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-09-16 18:04:01 +00:00
|
|
|
#endif
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
FunctionDefRNA *rna_find_function_def(FunctionRNA *func)
|
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
/* we should never get here */
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at preprocess time.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = rna_find_struct_def(DefRNA.laststruct);
|
|
|
|
dfunc = dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc = dfunc->cont.prev)
|
|
|
|
if (dfunc->func == func)
|
2009-04-07 00:49:39 +00:00
|
|
|
return dfunc;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna = dsrna->cont.prev) {
|
|
|
|
dfunc = dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc = dfunc->cont.prev)
|
|
|
|
if (dfunc->func == func)
|
2009-04-07 00:49:39 +00:00
|
|
|
return dfunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyDefRNA *rna_find_parameter_def(PropertyRNA *parm)
|
|
|
|
{
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
PropertyDefRNA *dparm;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
/* we should never get here */
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at preprocess time.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = rna_find_struct_def(DefRNA.laststruct);
|
|
|
|
dfunc = dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc = dfunc->cont.prev) {
|
|
|
|
dparm = dfunc->cont.properties.last;
|
|
|
|
for (; dparm; dparm = dparm->prev)
|
|
|
|
if (dparm->prop == parm)
|
2009-04-07 00:49:39 +00:00
|
|
|
return dparm;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = DefRNA.structs.last;
|
|
|
|
for (; dsrna; dsrna = dsrna->cont.prev) {
|
|
|
|
dfunc = dsrna->functions.last;
|
|
|
|
for (; dfunc; dfunc = dfunc->cont.prev) {
|
|
|
|
dparm = dfunc->cont.properties.last;
|
|
|
|
for (; dparm; dparm = dparm->prev)
|
|
|
|
if (dparm->prop == parm)
|
2009-04-07 00:49:39 +00:00
|
|
|
return dparm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-14 16:52:06 +00:00
|
|
|
static ContainerDefRNA *rna_find_container_def(ContainerRNA *cont)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
/* we should never get here */
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at preprocess time.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ds = rna_find_struct_def((StructRNA*)cont);
|
|
|
|
if (ds)
|
2009-04-07 00:49:39 +00:00
|
|
|
return &ds->cont;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dfunc = rna_find_function_def((FunctionRNA*)cont);
|
|
|
|
if (dfunc)
|
2009-04-07 00:49:39 +00:00
|
|
|
return &dfunc->cont;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* DNA utility function for looking up members */
|
|
|
|
|
|
|
|
typedef struct DNAStructMember {
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *type;
|
|
|
|
const char *name;
|
2008-10-31 23:50:02 +00:00
|
|
|
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)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
int a = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
/* compare without pointer or array part */
|
2012-03-05 23:30:41 +00:00
|
|
|
while (name[0] =='*')
|
2008-10-31 23:50:02 +00:00
|
|
|
name++;
|
2012-03-05 23:30:41 +00:00
|
|
|
while (oname[0] =='*')
|
2008-10-31 23:50:02 +00:00
|
|
|
oname++;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
while (1) {
|
|
|
|
if (name[a] =='[' && oname[a] == 0) return 1;
|
|
|
|
if (name[a] =='[' && oname[a] =='[') return 1;
|
|
|
|
if (name[a] == 0) break;
|
|
|
|
if (name[a] != oname[a]) return 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
a++;
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
if (name[a] == 0 && oname[a] == '.') return 2;
|
|
|
|
if (name[a] == 0 && oname[a] == '-' && oname[a+1] == '>') return 3;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return (name[a] == oname[a]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *membername, DNAStructMember *smember)
|
|
|
|
{
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *dnaname;
|
2008-10-31 23:50:02 +00:00
|
|
|
short *sp;
|
2008-11-26 22:24:26 +00:00
|
|
|
int a, b, structnr, totmember, cmp;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
structnr = DNA_struct_find_nr(sdna, structname);
|
|
|
|
if (structnr == -1)
|
2008-10-31 23:50:02 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
sp = sdna->structs[structnr];
|
|
|
|
totmember = sp[1];
|
|
|
|
sp += 2;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (a = 0; a<totmember; a++, sp += 2) {
|
|
|
|
dnaname = sdna->names[sp[1]];
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
cmp = rna_member_cmp(dnaname, membername);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (cmp == 1) {
|
|
|
|
smember->type = sdna->types[sp[0]];
|
|
|
|
smember->name = dnaname;
|
2009-03-26 13:56:32 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (strstr(membername, "["))
|
|
|
|
smember->arraylength = 0;
|
2009-03-26 13:56:32 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
smember->arraylength = DNA_elem_array_size(smember->name, strlen(smember->name));
|
2008-11-26 22:24:26 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
smember->pointerlevel = 0;
|
|
|
|
for (b = 0; dnaname[b] == '*'; b++)
|
2008-11-26 22:24:26 +00:00
|
|
|
smember->pointerlevel++;
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (cmp == 2) {
|
|
|
|
smember->type = "";
|
|
|
|
smember->name = dnaname;
|
|
|
|
smember->pointerlevel = 0;
|
|
|
|
smember->arraylength = 0;
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
membername = strstr(membername, ".") + strlen(".");
|
2009-04-19 17:12:16 +00:00
|
|
|
rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
|
|
|
|
|
|
|
|
return 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (cmp == 3) {
|
|
|
|
smember->type = "";
|
|
|
|
smember->name = dnaname;
|
|
|
|
smember->pointerlevel = 0;
|
|
|
|
smember->arraylength = 0;
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
membername = strstr(membername, "->") + strlen("->");
|
2009-04-19 17:12:16 +00:00
|
|
|
rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
|
|
|
|
|
|
|
|
return 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
static int rna_validate_identifier(const char *identifier, char *error, int property)
|
2008-12-18 06:43:03 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
int a = 0;
|
2008-12-18 06:43:03 +00:00
|
|
|
|
2008-12-18 23:34:19 +00:00
|
|
|
/* list from http://docs.python.org/reference/lexical_analysis.html#id5 */
|
2010-12-03 17:05:21 +00:00
|
|
|
static const char *kwlist[] = {
|
2008-12-18 23:34:19 +00:00
|
|
|
"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;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (a = 0; identifier[a]; a++) {
|
|
|
|
if (DefRNA.preprocess && property) {
|
|
|
|
if (isalpha(identifier[a]) && isupper(identifier[a])) {
|
2009-01-10 22:57:33 +00:00
|
|
|
strcpy(error, "property names must contain lower case characters only");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (identifier[a] =='_') {
|
2008-12-18 23:34:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-01-10 22:57:33 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (identifier[a] ==' ') {
|
2011-04-11 01:18:25 +00:00
|
|
|
strcpy(error, "spaces are not okay in identifier names");
|
2009-01-15 05:41:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (isalnum(identifier[a]) == 0) {
|
2008-12-18 23:34:19 +00:00
|
|
|
strcpy(error, "one of the characters failed an isalnum() check and is not an underscore");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (a = 0; kwlist[a]; a++) {
|
2008-12-18 23:34:19 +00:00
|
|
|
if (strcmp(identifier, kwlist[a]) == 0) {
|
|
|
|
strcpy(error, "this keyword is reserved by python");
|
|
|
|
return 0;
|
|
|
|
}
|
2008-12-18 06:43:03 +00:00
|
|
|
}
|
2011-03-25 02:12:44 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (property) {
|
2011-03-25 02:12:44 +00:00
|
|
|
static const char *kwlist_prop[] = {
|
|
|
|
/* not keywords but reserved all the same because py uses */
|
|
|
|
"keys", "values", "items", "get",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (a = 0; kwlist_prop[a]; a++) {
|
2011-03-25 02:12:44 +00:00
|
|
|
if (strcmp(identifier, kwlist_prop[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 */
|
|
|
|
|
2011-02-13 15:02:21 +00:00
|
|
|
BlenderRNA *RNA_create(void)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
BlenderRNA *brna;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
brna = MEM_callocN(sizeof(BlenderRNA), "BlenderRNA");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.sdna = DNA_sdna_from_data(DNAstr, DNAlen, 0);
|
|
|
|
DefRNA.structs.first = DefRNA.structs.last = NULL;
|
|
|
|
DefRNA.error = 0;
|
|
|
|
DefRNA.preprocess = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return brna;
|
|
|
|
}
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
void RNA_define_free(BlenderRNA *UNUSED(brna))
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
|
|
|
FunctionDefRNA *dfunc;
|
2008-10-31 23:50:02 +00:00
|
|
|
AllocDefRNA *alloc;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (alloc = DefRNA.allocs.first; alloc; alloc = alloc->next)
|
2008-10-31 23:50:02 +00:00
|
|
|
MEM_freeN(alloc->mem);
|
|
|
|
rna_freelistN(&DefRNA.allocs);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
|
|
|
for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_freelistN(&dfunc->cont.properties);
|
|
|
|
|
|
|
|
rna_freelistN(&ds->cont.properties);
|
|
|
|
rna_freelistN(&ds->functions);
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
rna_freelistN(&DefRNA.structs);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.sdna) {
|
2008-10-31 23:50:02 +00:00
|
|
|
DNA_sdna_free(DefRNA.sdna);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.sdna = NULL;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 01:14:55 +00:00
|
|
|
void RNA_define_verify_sdna(int verify)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.verify = verify;
|
2009-07-21 01:14:55 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 07:26:29 +00:00
|
|
|
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext)
|
|
|
|
{
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
ext->free(ext->data); /* decref's the PyObject that the srna owns */
|
|
|
|
RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */
|
|
|
|
RNA_struct_py_type_set(srna, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */
|
2012-03-05 23:30:41 +00:00
|
|
|
#endif
|
2009-08-16 07:26:29 +00:00
|
|
|
}
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2009-07-21 20:05:16 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
2009-04-07 00:49:39 +00:00
|
|
|
FunctionRNA *func, *nextfunc;
|
2009-04-19 13:37:59 +00:00
|
|
|
PropertyRNA *prop, *nextprop;
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *parm, *nextparm;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2010-10-12 23:47:43 +00:00
|
|
|
/*
|
2012-03-24 06:24:53 +00:00
|
|
|
if (srna->flag & STRUCT_RUNTIME) {
|
|
|
|
if (RNA_struct_py_type_get(srna)) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s '%s' freed while holding a python reference\n", __func__, srna->identifier);
|
2009-08-14 12:29:55 +00:00
|
|
|
}
|
2010-10-12 23:47:43 +00:00
|
|
|
} */
|
2009-08-14 12:29:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (prop = srna->cont.properties.first; prop; prop = nextprop) {
|
|
|
|
nextprop = prop->next;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_def_property_free_pointers(prop);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_RUNTIME)
|
2009-04-19 13:37:59 +00:00
|
|
|
rna_freelinkN(&srna->cont.properties, prop);
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (func = srna->functions.first; func; func = nextfunc) {
|
|
|
|
nextfunc = func->cont.next;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (parm = func->cont.properties.first; parm; parm = nextparm) {
|
|
|
|
nextparm = parm->next;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_def_property_free_pointers(parm);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (parm->flag & PROP_RUNTIME)
|
2009-04-19 13:37:59 +00:00
|
|
|
rna_freelinkN(&func->cont.properties, parm);
|
|
|
|
}
|
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_def_func_free_pointers(func);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_RUNTIME)
|
2009-04-19 13:37:59 +00:00
|
|
|
rna_freelinkN(&srna->functions, func);
|
|
|
|
}
|
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_def_struct_free_pointers(srna);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->flag & STRUCT_RUNTIME)
|
2009-04-19 13:37:59 +00:00
|
|
|
rna_freelinkN(&brna->structs, srna);
|
2009-08-14 12:29:55 +00:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
#endif
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_free(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna, *nextsrna;
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
2012-03-05 23:30:41 +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
|
|
|
RNA_define_free(brna);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (srna = brna->structs.first; srna; srna = srna->cont.next) {
|
|
|
|
for (func = srna->functions.first; func; func = func->cont.next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_freelistN(&func->cont.properties);
|
|
|
|
|
|
|
|
rna_freelistN(&srna->cont.properties);
|
|
|
|
rna_freelistN(&srna->functions);
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
rna_freelistN(&brna->structs);
|
|
|
|
|
|
|
|
MEM_freeN(brna);
|
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
for (srna = brna->structs.first; srna; srna = nextsrna) {
|
|
|
|
nextsrna = srna->cont.next;
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_struct_free(brna, srna);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t rna_property_type_sizeof(PropertyType type)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (type) {
|
2011-12-01 22:08:42 +00:00
|
|
|
case PROP_BOOLEAN: return sizeof(BoolPropertyRNA);
|
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
|
|
|
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;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
|
|
|
if (ds->srna == srna)
|
2008-12-02 23:45:11 +00:00
|
|
|
return ds;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Struct Definition */
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna, *srnafrom = NULL;
|
|
|
|
StructDefRNA *ds = NULL, *dsfrom = NULL;
|
2009-02-02 19:57:57 +00:00
|
|
|
PropertyRNA *prop;
|
2008-12-18 06:43:03 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
2008-12-18 23:34:19 +00:00
|
|
|
char error[512];
|
2009-01-10 22:57:33 +00:00
|
|
|
|
|
|
|
if (rna_validate_identifier(identifier, error, 0) == 0) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: struct identifier \"%s\" error - %s\n", __func__, identifier, error);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-12-18 06:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (from) {
|
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
|
|
|
/* find struct to derive from */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (srnafrom = brna->structs.first; srnafrom; srnafrom = srnafrom->cont.next)
|
|
|
|
if (strcmp(srnafrom->identifier, from) == 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
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!srnafrom) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: struct %s not found to define %s.\n", __func__, from, identifier);
|
2012-03-05 23:30:41 +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
|
|
|
}
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = MEM_callocN(sizeof(StructRNA), "StructRNA");
|
|
|
|
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
|
|
|
|
2012-03-05 23:30:41 +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));
|
2012-03-05 23:30:41 +00:00
|
|
|
srna->cont.prophash = NULL;
|
|
|
|
srna->cont.properties.first = srna->cont.properties.last = NULL;
|
|
|
|
srna->functions.first = srna->functions.last = NULL;
|
|
|
|
srna->py_type = NULL;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
|
|
|
srna->base = srnafrom;
|
|
|
|
dsfrom = rna_find_def_struct(srnafrom);
|
2008-12-02 23:45:11 +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
|
2012-03-05 23:30:41 +00:00
|
|
|
srna->base = srnafrom;
|
2008-11-29 19:08:46 +00:00
|
|
|
}
|
2009-05-28 02:03:48 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna->identifier = identifier;
|
|
|
|
srna->name = identifier; /* may be overwritten later RNA_def_struct_ui_text */
|
|
|
|
srna->description = "";
|
2011-11-08 15:11:27 +00:00
|
|
|
srna->flag |= STRUCT_UNDO;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!srnafrom)
|
|
|
|
srna->icon = ICON_DOT;
|
2008-11-29 19:08:46 +00:00
|
|
|
|
|
|
|
rna_addtail(&brna->structs, srna);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
|
|
|
ds = MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
|
|
|
|
ds->srna = srna;
|
2008-11-29 19:08:46 +00:00
|
|
|
rna_addtail(&DefRNA.structs, ds);
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dsfrom)
|
|
|
|
ds->dnafromname = dsfrom->dnaname;
|
2008-11-29 19:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* in preprocess, try to find sdna */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess)
|
2008-11-29 19:08:46 +00:00
|
|
|
RNA_def_struct_sdna(srna, srna->identifier);
|
|
|
|
else
|
|
|
|
srna->flag |= STRUCT_RUNTIME;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srnafrom) {
|
|
|
|
srna->nameproperty = srnafrom->nameproperty;
|
|
|
|
srna->iteratorproperty = srnafrom->iteratorproperty;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
2008-11-29 19:08:46 +00:00
|
|
|
else {
|
|
|
|
/* define some builtin properties */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(&srna->cont, "rna_properties", PROP_COLLECTION, PROP_NONE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_BUILTIN);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Properties", "RNA property collection");
|
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
|
|
|
|
2012-03-05 23:30:41 +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
|
|
|
RNA_def_property_struct_type(prop, "Property");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next",
|
|
|
|
"rna_iterator_listbase_end", "rna_builtin_properties_get", NULL, NULL,
|
|
|
|
"rna_builtin_properties_lookup_string", NULL);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef RNA_RUNTIME
|
2012-03-05 23:30:41 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA*)prop;
|
|
|
|
cprop->begin = rna_builtin_properties_begin;
|
|
|
|
cprop->next = rna_builtin_properties_next;
|
|
|
|
cprop->get = rna_builtin_properties_get;
|
|
|
|
cprop->item_type = &RNA_Property;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(&srna->cont, "rna_type", PROP_POINTER, PROP_NONE);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "RNA", "RNA type definition");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +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
|
|
|
RNA_def_property_struct_type(prop, "Struct");
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL, NULL);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef RNA_RUNTIME
|
2012-03-05 23:30:41 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA*)prop;
|
|
|
|
pprop->get = rna_builtin_type_get;
|
|
|
|
pprop->type = &RNA_Struct;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
return srna;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ds = rna_find_def_struct(srna);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DNA_struct_find_nr(DefRNA.sdna, structname)) {
|
|
|
|
if (!DefRNA.silent) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: %s not found.\n", __func__, structname);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ds->dnaname = structname;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname)
|
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
2008-12-02 23:45:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ds = rna_find_def_struct(srna);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!ds->dnaname) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: %s base struct must know DNA already.\n", __func__, structname);
|
2008-12-02 23:45:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DNA_struct_find_nr(DefRNA.sdna, structname)) {
|
|
|
|
if (!DefRNA.silent) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: %s not found.\n", __func__, structname);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-12-02 23:45:11 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ds->dnafromprop = propname;
|
|
|
|
ds->dnaname = structname;
|
2008-12-02 23:45:11 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_STRING) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", must be a string property.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
srna->nameproperty = prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
|
2009-01-09 16:08:47 +00:00
|
|
|
{
|
2009-01-10 22:57:33 +00:00
|
|
|
StructRNA *srnafrom;
|
2009-01-09 16:08:47 +00:00
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
/* find struct to derive from */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (srnafrom = brna->structs.first; srnafrom; srnafrom = srnafrom->cont.next)
|
|
|
|
if (strcmp(srnafrom->identifier, structname) == 0)
|
2009-01-10 22:57:33 +00:00
|
|
|
break;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!srnafrom) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: struct %s not found for %s.\n", __func__, structname, srna->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-01-10 22:57:33 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna->nested = srnafrom;
|
2009-01-09 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_struct_flag(StructRNA *srna, int flag)
|
|
|
|
{
|
2009-05-29 15:12:31 +00:00
|
|
|
srna->flag |= flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_struct_clear_flag(StructRNA *srna, int flag)
|
|
|
|
{
|
|
|
|
srna->flag &= ~flag;
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (refine) srna->refine = (StructRefineFunc)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
|
|
|
}
|
|
|
|
|
2010-08-19 10:16:30 +00:00
|
|
|
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
|
2009-05-20 09:52:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
2009-05-20 09:52:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (idproperties) srna->idproperties = (IDPropertiesFunc)idproperties;
|
2009-05-20 09:52:02 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 11:21:10 +00:00
|
|
|
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
2009-04-19 13:37:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (reg) srna->reg = (StructRegisterFunc)reg;
|
|
|
|
if (unreg) srna->unreg = (StructUnregisterFunc)unreg;
|
|
|
|
if (instance) srna->instance = (StructInstanceFunc)instance;
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2009-03-25 20:29:01 +00:00
|
|
|
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
2009-03-25 20:29:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (path) srna->path = (StructPathFunc)path;
|
2009-03-25 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at runtime.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
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)
|
|
|
|
{
|
2011-09-21 17:52:51 +00:00
|
|
|
DESCR_CHECK(description, srna->identifier, NULL);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna->name = name;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-06-03 23:16:51 +00:00
|
|
|
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
srna->icon = icon;
|
2009-06-03 23:16:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-16 15:39:25 +00:00
|
|
|
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
|
|
|
|
{
|
|
|
|
srna->translation_context = context;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Property Definition */
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2011-01-16 15:02:07 +00:00
|
|
|
/*StructRNA *srna= DefRNA.laststruct;*/ /* invalid for python defined props */
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-04-07 00:49:39 +00:00
|
|
|
ContainerDefRNA *dcont;
|
2012-03-05 23:30:41 +00:00
|
|
|
PropertyDefRNA *dprop = NULL;
|
2008-10-31 23:50:02 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
2008-12-18 23:34:19 +00:00
|
|
|
char error[512];
|
2008-12-18 06:43:03 +00:00
|
|
|
|
2009-01-10 22:57:33 +00:00
|
|
|
if (rna_validate_identifier(identifier, error, 1) == 0) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: property identifier \"%s.%s\" - %s\n", __func__,
|
|
|
|
CONTAINER_RNA_ID(cont), identifier, error);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-12-18 06:43:03 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dcont = rna_find_container_def(cont);
|
2009-08-09 10:05:33 +00:00
|
|
|
|
|
|
|
/* XXX - toto, detect supertype collisions */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (rna_findlink(&dcont->properties, identifier)) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: duplicate identifier \"%s.%s\"\n", __func__, CONTAINER_RNA_ID(cont), identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-08-09 10:05:33 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dprop = MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_addtail(&dcont->properties, dprop);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = MEM_callocN(rna_property_type_sizeof(type), "PropertyRNA");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
break;
|
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
iprop->hardmin = (subtype == PROP_UNSIGNED)? 0: INT_MIN;
|
|
|
|
iprop->hardmax = INT_MAX;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
iprop->softmin = (subtype == PROP_UNSIGNED)? 0: -10000; /* rather arbitrary .. */
|
|
|
|
iprop->softmax = 10000;
|
|
|
|
iprop->step = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
fprop->hardmin = (subtype == PROP_UNSIGNED)? 0.0f: -FLT_MAX;
|
|
|
|
fprop->hardmax = FLT_MAX;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) {
|
|
|
|
fprop->softmin = 0.0f;
|
|
|
|
fprop->softmax = 1.0f;
|
2009-01-02 13:47:33 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (subtype == PROP_FACTOR) {
|
|
|
|
fprop->softmin = fprop->hardmin = 0.0f;
|
|
|
|
fprop->softmax = fprop->hardmax = 1.0f;
|
2009-02-17 21:07:01 +00:00
|
|
|
}
|
2009-01-02 13:47:33 +00:00
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
fprop->softmin = (subtype == PROP_UNSIGNED)? 0.0f: -10000.0f; /* rather arbitrary .. */
|
|
|
|
fprop->softmax = 10000.0f;
|
2009-01-02 13:47:33 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
fprop->step = 10;
|
|
|
|
fprop->precision = 3;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_STRING: {
|
2012-03-05 23:30:41 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
sprop->defaultvalue = "";
|
|
|
|
sprop->maxlength = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_ENUM:
|
|
|
|
case PROP_POINTER:
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
break;
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", invalid property type.\n", __func__, CONTAINER_RNA_ID(cont), identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
|
|
|
dprop->cont = cont;
|
|
|
|
dprop->prop = prop;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->magic = RNA_MAGIC;
|
|
|
|
prop->identifier = identifier;
|
|
|
|
prop->type = type;
|
|
|
|
prop->subtype = subtype;
|
|
|
|
prop->name = identifier;
|
|
|
|
prop->description = "";
|
2010-01-04 22:30:09 +00:00
|
|
|
/* a priori not raw editable */
|
|
|
|
prop->rawtype = -1;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type != PROP_COLLECTION && type != PROP_POINTER) {
|
|
|
|
prop->flag = PROP_EDITABLE;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type != PROP_STRING)
|
2010-02-02 00:02:55 +00:00
|
|
|
prop->flag |= PROP_ANIMATABLE;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
|
|
|
switch (type) {
|
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
|
|
|
case PROP_BOOLEAN:
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, identifier, 0);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
break;
|
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
RNA_def_property_int_sdna(prop, NULL, identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
RNA_def_property_float_sdna(prop, NULL, identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_STRING: {
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
RNA_def_property_string_sdna(prop, NULL, identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_ENUM:
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 1;
|
2008-12-03 20:17:12 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
break;
|
|
|
|
case PROP_POINTER:
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
break;
|
|
|
|
case PROP_COLLECTION:
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
RNA_def_property_collection_sdna(prop, NULL, identifier, NULL);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.silent = 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
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-19 23:05:21 +00:00
|
|
|
else {
|
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->flag |= PROP_IDPROPERTY|PROP_RUNTIME;
|
2009-06-19 23:05:21 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
2012-03-05 23:30:41 +00:00
|
|
|
if (cont->prophash)
|
2009-06-19 23:05:21 +00:00
|
|
|
BLI_ghash_insert(cont->prophash, (void*)prop->identifier, prop);
|
|
|
|
#endif
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_addtail(&cont->properties, prop);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
void RNA_def_property_flag(PropertyRNA *prop, int flag)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-14 14:34:19 +00:00
|
|
|
prop->flag |= flag;
|
2009-03-23 13:24:48 +00:00
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2009-03-23 13:24:48 +00:00
|
|
|
void RNA_def_property_clear_flag(PropertyRNA *prop, int flag)
|
|
|
|
{
|
|
|
|
prop->flag &= ~flag;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 01:46:26 +00:00
|
|
|
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->subtype = subtype;
|
2010-11-01 01:46:26 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:40:46 +00:00
|
|
|
void RNA_def_property_array(PropertyRNA *prop, int length)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (length<0) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", array length must be zero of greater.\n", __func__,
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (length>RNA_MAX_ARRAY_LENGTH) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", array length must be smaller than %d.\n", __func__,
|
|
|
|
srna->identifier, prop->identifier, RNA_MAX_ARRAY_LENGTH);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-02-02 19:57:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->arraydimension > 1) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", array dimensions has been set to %u but would be overwritten as 1.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier, prop->arraydimension);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2010-11-15 06:38:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
case PROP_INT:
|
|
|
|
case PROP_FLOAT:
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->arraylength[0] = length;
|
|
|
|
prop->totarraylength = length;
|
|
|
|
prop->arraydimension = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", only boolean/int/float can be array.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 06:38:07 +00:00
|
|
|
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2009-09-09 19:40:46 +00:00
|
|
|
int i;
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
|
|
|
|
if (dimension < 1 || dimension > RNA_MAX_ARRAY_DIMENSION) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", array dimension must be between 1 and %d.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier, RNA_MAX_ARRAY_DIMENSION);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2009-09-09 19:40:46 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
case PROP_INT:
|
|
|
|
case PROP_FLOAT:
|
|
|
|
break;
|
|
|
|
default:
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", only boolean/int/float can be array.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-09-09 19:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->arraydimension = dimension;
|
|
|
|
prop->totarraylength = 0;
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (length) {
|
2009-09-09 19:40:46 +00:00
|
|
|
memcpy(prop->arraylength, length, sizeof(int)*dimension);
|
2009-09-06 15:13:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->totarraylength = length[0];
|
|
|
|
for (i = 1; i<dimension; i++)
|
2009-09-09 19:40:46 +00:00
|
|
|
prop->totarraylength *= length[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
memset(prop->arraylength, 0, sizeof(prop->arraylength));
|
|
|
|
|
|
|
|
/* TODO make sure arraylength values are sane */
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
|
|
|
|
{
|
2011-09-21 17:52:51 +00:00
|
|
|
DESCR_CHECK(description, prop->identifier, NULL);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->name = name;
|
|
|
|
prop->description = description;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-06-16 00:52:21 +00:00
|
|
|
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->icon = icon;
|
|
|
|
if (consecutive)
|
2009-06-16 00:52:21 +00:00
|
|
|
prop->flag |= PROP_ICONS_CONSECUTIVE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
|
|
|
iprop->softmin = (int)min;
|
|
|
|
iprop->softmax = (int)max;
|
|
|
|
iprop->step = (int)step;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
|
|
|
fprop->softmin = (float)min;
|
|
|
|
fprop->softmax = (float)max;
|
|
|
|
fprop->step = (float)step;
|
|
|
|
fprop->precision = (int)precision;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", invalid type for ui range.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
|
|
|
iprop->hardmin = (int)min;
|
|
|
|
iprop->hardmax = (int)max;
|
|
|
|
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: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
|
|
|
fprop->hardmin = (float)min;
|
|
|
|
fprop->hardmax = (float)max;
|
|
|
|
fprop->softmin = MAX2((float)min, fprop->hardmin);
|
|
|
|
fprop->softmax = MIN2((float)max, fprop->hardmax);
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", invalid type for range.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
|
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s \"%s.%s\": only during preprocessing.\n", __func__, srna->identifier, prop->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
|
|
|
return;
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_POINTER: {
|
2012-03-05 23:30:41 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA*)prop;
|
2009-03-23 13:24:48 +00:00
|
|
|
pprop->type = (StructRNA*)type;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION: {
|
2012-03-05 23:30:41 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA*)prop;
|
2009-11-13 16:08:03 +00:00
|
|
|
cprop->item_type = (StructRNA*)type;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", invalid type for struct type.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
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)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at runtime.\n", __func__);
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
case PROP_POINTER: {
|
2012-03-05 23:30:41 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA*)prop;
|
2009-03-23 13:24:48 +00:00
|
|
|
pprop->type = type;
|
2009-05-29 15:12:31 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type && (type->flag & STRUCT_ID_REFCOUNT))
|
2009-05-29 15:12:31 +00:00
|
|
|
prop->flag |= PROP_ID_REFCOUNT;
|
|
|
|
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION: {
|
2012-03-05 23:30:41 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA*)prop;
|
2009-11-13 16:08:03 +00:00
|
|
|
cprop->item_type = type;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", invalid type for struct type.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
|
|
|
int i, defaultfound = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_ENUM: {
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA*)prop;
|
|
|
|
eprop->item = (EnumPropertyItem*)item;
|
|
|
|
eprop->totitem = 0;
|
|
|
|
for (i = 0; item[i].identifier; i++) {
|
2008-10-31 23:50:02 +00:00
|
|
|
eprop->totitem++;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (item[i].identifier[0] && item[i].value == eprop->defaultvalue)
|
|
|
|
defaultfound = 1;
|
2009-03-06 10:22:12 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!defaultfound) {
|
|
|
|
for (i = 0; item[i].identifier; i++) {
|
|
|
|
if (item[i].identifier[0]) {
|
|
|
|
eprop->defaultvalue = item[i].value;
|
2009-08-21 02:51:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-06 10:22:12 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", invalid type for struct type.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_STRING: {
|
2012-03-05 23:30:41 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA*)prop;
|
|
|
|
sprop->maxlength = maxlength;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not string.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_BOOLEAN: {
|
2012-03-05 23:30:41 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA*)prop;
|
|
|
|
bprop->defaultvalue = value;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not boolean.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_BOOLEAN: {
|
2012-03-05 23:30:41 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA*)prop;
|
|
|
|
bprop->defaultarray = array;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not boolean.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_int_default(PropertyRNA *prop, int value)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
|
|
|
iprop->defaultvalue = value;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not int.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
|
|
|
iprop->defaultarray = array;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not int.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_float_default(PropertyRNA *prop, float value)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
|
|
|
fprop->defaultvalue = value;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not float.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-02-01 14:24:44 +00:00
|
|
|
/* array must remain valid after this function finishes */
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
|
|
|
fprop->defaultarray = array; /* WARNING, this array must not come from the stack and lost */
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not float.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_STRING: {
|
2012-03-05 23:30:41 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA*)prop;
|
|
|
|
sprop->defaultvalue = value;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not string.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
|
|
|
int i, defaultfound = 0;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_ENUM: {
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA*)prop;
|
|
|
|
eprop->defaultvalue = value;
|
2009-03-06 10:22:12 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_ENUM_FLAG) {
|
2011-01-13 14:29:57 +00:00
|
|
|
/* check all bits are accounted for */
|
2012-03-05 23:30:41 +00:00
|
|
|
int totflag = 0;
|
|
|
|
for (i = 0; i<eprop->totitem; i++) {
|
|
|
|
if (eprop->item[i].identifier[0]) {
|
2011-01-13 14:29:57 +00:00
|
|
|
totflag |= eprop->item[i].value;
|
|
|
|
}
|
2009-03-06 10:22:12 +00:00
|
|
|
}
|
2011-01-13 14:29:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->defaultvalue & ~totflag) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", default includes unused bits (%d).\n",
|
|
|
|
__func__, srna->identifier, prop->identifier, eprop->defaultvalue & ~totflag);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-03-06 10:22:12 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-13 14:29:57 +00:00
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
for (i = 0; i<eprop->totitem; i++) {
|
|
|
|
if (eprop->item[i].identifier[0] && eprop->item[i].value == eprop->defaultvalue)
|
|
|
|
defaultfound = 1;
|
2011-01-13 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!defaultfound && eprop->totitem) {
|
|
|
|
if (value == 0) {
|
|
|
|
eprop->defaultvalue = eprop->item[0].value;
|
2011-01-13 14:29:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", default is not in items.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2011-01-13 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-06 10:22:12 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not enum.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SDNA */
|
|
|
|
|
|
|
|
static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
DNAStructMember smember;
|
2009-04-07 00:49:39 +00:00
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dp = rna_find_struct_property_def(DefRNA.laststruct, prop);
|
|
|
|
if (dp == NULL) return NULL;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ds = rna_find_struct_def((StructRNA*)dp->cont);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!structname)
|
|
|
|
structname = ds->dnaname;
|
|
|
|
if (!propname)
|
|
|
|
propname = prop->identifier;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember)) {
|
|
|
|
if (DefRNA.silent) {
|
2009-07-21 01:14:55 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (!DefRNA.verify) {
|
2009-07-21 01:14:55 +00:00
|
|
|
/* some basic values to survive even with sdna info */
|
2012-03-05 23:30:41 +00:00
|
|
|
dp->dnastructname = structname;
|
|
|
|
dp->dnaname = propname;
|
|
|
|
if (prop->type == PROP_BOOLEAN)
|
|
|
|
dp->dnaarraylength = 1;
|
|
|
|
if (prop->type == PROP_POINTER)
|
|
|
|
dp->dnapointerlevel = 1;
|
2009-07-21 01:14:55 +00:00
|
|
|
return dp;
|
|
|
|
}
|
|
|
|
else {
|
2011-11-21 14:03:10 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\" (identifier \"%s\") not found.\n",
|
|
|
|
__func__, structname, propname, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-07-21 01:14:55 +00:00
|
|
|
return NULL;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (smember.arraylength > 1) {
|
|
|
|
prop->arraylength[0] = smember.arraylength;
|
|
|
|
prop->totarraylength = smember.arraylength;
|
|
|
|
prop->arraydimension = 1;
|
2009-09-09 19:40:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->arraydimension = 0;
|
|
|
|
prop->totarraylength = 0;
|
2009-09-09 19:40:46 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dp->dnastructname = structname;
|
|
|
|
dp->dnastructfromname = ds->dnafromname;
|
|
|
|
dp->dnastructfromprop = ds->dnafromprop;
|
|
|
|
dp->dnaname = propname;
|
|
|
|
dp->dnatype = smember.type;
|
|
|
|
dp->dnaarraylength = smember.arraylength;
|
|
|
|
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;
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_BOOLEAN) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not boolean.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((dp = rna_def_property_sdna(prop, structname, propname))) {
|
2010-12-31 04:12:20 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.silent == 0) {
|
2010-12-31 04:12:20 +00:00
|
|
|
/* error check to ensure floats are not wrapped as ints/bools */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnatype && *dp->dnatype && IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: %s.%s is a '%s' but wrapped as type '%s'.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier, dp->dnatype, RNA_property_typename(prop->type));
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2010-12-31 04:12:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dp->booleanbit = bit;
|
2010-12-31 04:12:20 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname,
|
|
|
|
const char *propname, int booleanbit)
|
2008-12-03 20:17:12 +00:00
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dp = rna_find_struct_property_def(DefRNA.laststruct, prop);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp)
|
|
|
|
dp->booleannegative = 1;
|
2008-12-03 20:17:12 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_INT) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not int.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((dp = rna_def_property_sdna(prop, structname, propname))) {
|
2010-12-31 04:12:20 +00:00
|
|
|
|
|
|
|
/* error check to ensure floats are not wrapped as ints/bools */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.silent == 0) {
|
|
|
|
if (dp->dnatype && *dp->dnatype && IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: %s.%s is a '%s' but wrapped as type '%s'.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier, dp->dnatype, RNA_property_typename(prop->type));
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2010-12-31 04:12:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* SDNA doesn't pass us unsigned unfortunately .. */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnatype && strcmp(dp->dnatype, "char") == 0) {
|
|
|
|
iprop->hardmin = iprop->softmin = CHAR_MIN;
|
|
|
|
iprop->hardmax = iprop->softmax = CHAR_MAX;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (dp->dnatype && strcmp(dp->dnatype, "short") == 0) {
|
|
|
|
iprop->hardmin = iprop->softmin = SHRT_MIN;
|
|
|
|
iprop->hardmax = iprop->softmax = SHRT_MAX;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (dp->dnatype && strcmp(dp->dnatype, "int") == 0) {
|
|
|
|
iprop->hardmin = INT_MIN;
|
|
|
|
iprop->hardmax = INT_MAX;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
iprop->softmin = -10000; /* rather arbitrary .. */
|
|
|
|
iprop->softmax = 10000;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->subtype == PROP_UNSIGNED || prop->subtype == PROP_PERCENTAGE || prop->subtype == PROP_FACTOR)
|
|
|
|
iprop->hardmin = iprop->softmin = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
2010-12-31 04:12:20 +00:00
|
|
|
PropertyDefRNA *dp;
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-11-24 12:12:24 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_FLOAT) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not float.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((dp = rna_def_property_sdna(prop, structname, propname))) {
|
2010-12-31 04:12:20 +00:00
|
|
|
/* silent is for internal use */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.silent == 0) {
|
|
|
|
if (dp->dnatype && *dp->dnatype && IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) {
|
|
|
|
if (prop->subtype != PROP_COLOR_GAMMA) { /* colors are an exception. these get translated */
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: %s.%s is a '%s' but wrapped as type '%s'.\n",
|
|
|
|
__func__, srna->identifier, prop->identifier, dp->dnatype,
|
|
|
|
RNA_property_typename(prop->type));
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2010-12-31 04:12:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-01 09:39:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnatype && strcmp(dp->dnatype, "char") == 0) {
|
|
|
|
fprop->hardmin = fprop->softmin = 0.0f;
|
|
|
|
fprop->hardmax = fprop->softmax = 1.0f;
|
2012-01-01 09:39:43 +00:00
|
|
|
}
|
2010-12-31 04:12:20 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-01-10 03:58:07 +00:00
|
|
|
/* PropertyDefRNA *dp; */
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_ENUM) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not enum.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (( /* dp= */ rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
if (prop->arraydimension) {
|
|
|
|
prop->arraydimension = 0;
|
|
|
|
prop->totarraylength = 0;
|
2009-09-09 19:40:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.silent) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", array not supported for enum type.\n",
|
|
|
|
__func__, structname, propname);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:17:12 +00:00
|
|
|
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
|
|
|
RNA_def_property_enum_sdna(prop, structname, propname);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dp = rna_find_struct_property_def(DefRNA.laststruct, prop);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp)
|
|
|
|
dp->enumbitflags = 1;
|
2008-12-03 20:17:12 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
2011-01-10 03:58:07 +00:00
|
|
|
/* PropertyDefRNA *dp; */
|
2012-03-05 23:30:41 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA*)prop;
|
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_STRING) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not string.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((/* dp= */ rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
if (prop->arraydimension) {
|
|
|
|
sprop->maxlength = prop->totarraylength;
|
|
|
|
prop->arraydimension = 0;
|
|
|
|
prop->totarraylength = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
|
|
|
|
{
|
2011-01-10 03:58:07 +00:00
|
|
|
/* PropertyDefRNA *dp; */
|
2012-03-05 23:30:41 +00:00
|
|
|
StructRNA *srna = DefRNA.laststruct;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_POINTER) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not pointer.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((/* dp= */ rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
if (prop->arraydimension) {
|
|
|
|
prop->arraydimension = 0;
|
|
|
|
prop->totarraylength = 0;
|
2009-09-09 19:40:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.silent) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", array not supported for pointer type.\n",
|
|
|
|
__func__, structname, propname);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +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;
|
2012-03-05 23:30:41 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA*)prop;
|
|
|
|
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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type != PROP_COLLECTION) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not collection.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-24 12:12:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((dp = rna_def_property_sdna(prop, structname, propname))) {
|
|
|
|
if (prop->arraydimension && !lengthpropname) {
|
|
|
|
prop->arraydimension = 0;
|
|
|
|
prop->totarraylength = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.silent) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", array of collections not supported.\n",
|
|
|
|
__func__, structname, propname);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) {
|
|
|
|
cprop->next = (PropCollectionNextFunc)"rna_iterator_listbase_next";
|
|
|
|
cprop->get = (PropCollectionGetFunc)"rna_iterator_listbase_get";
|
|
|
|
cprop->end = (PropCollectionEndFunc)"rna_iterator_listbase_end";
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp && lengthpropname) {
|
2008-11-07 02:58:25 +00:00
|
|
|
DNAStructMember smember;
|
2012-03-05 23:30:41 +00:00
|
|
|
StructDefRNA *ds = rna_find_struct_def((StructRNA*)dp->cont);
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!structname)
|
|
|
|
structname = ds->dnaname;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (lengthpropname[0] == 0 || rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember)) {
|
|
|
|
if (lengthpropname[0] == 0) {
|
|
|
|
dp->dnalengthfixed = prop->totarraylength;
|
|
|
|
prop->arraydimension = 0;
|
|
|
|
prop->totarraylength = 0;
|
2008-12-02 23:45:11 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
dp->dnalengthstructname = structname;
|
|
|
|
dp->dnalengthname = lengthpropname;
|
|
|
|
prop->totarraylength = 0;
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
cprop->next = (PropCollectionNextFunc)"rna_iterator_array_next";
|
|
|
|
cprop->end = (PropCollectionEndFunc)"rna_iterator_array_end";
|
2008-11-26 22:24:26 +00:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
if (dp->dnapointerlevel >= 2)
|
2012-03-05 23:30:41 +00:00
|
|
|
cprop->get = (PropCollectionGetFunc)"rna_iterator_array_dereference_get";
|
2008-11-26 22:24:26 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
cprop->get = (PropCollectionGetFunc)"rna_iterator_array_get";
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-12-02 23:45:11 +00:00
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.silent) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\" not found.\n", __func__, structname, lengthpropname);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-12-02 23:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2011-12-22 18:25:59 +00:00
|
|
|
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->translation_context = context;
|
2011-12-22 18:25:59 +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
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (editable) prop->editable = (EditableFunc)editable;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-25 12:00:31 +00:00
|
|
|
void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
2009-11-25 12:00:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (editable) prop->itemeditable = (ItemEditableFunc)editable;
|
2009-11-25 12:00:31 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
2009-01-01 15:52:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->noteflag = noteflag;
|
|
|
|
prop->update = (UpdateFunc)func;
|
2009-01-01 15:52:51 +00:00
|
|
|
}
|
|
|
|
|
2011-06-06 17:50:20 +00:00
|
|
|
void RNA_def_property_update_runtime(PropertyRNA *prop, void *func)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->update = func;
|
2011-06-06 17:50:20 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:40:46 +00:00
|
|
|
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(prop->flag & PROP_DYNAMIC)) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: property is a not dynamic array.\n", __func__);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (getlength) prop->getlength = (PropArrayLengthGetFunc)getlength;
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-11-14 14:34:19 +00:00
|
|
|
case PROP_BOOLEAN: {
|
2012-03-05 23:30:41 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->arraydimension) {
|
|
|
|
if (get) bprop->getarray = (PropBooleanArrayGetFunc)get;
|
|
|
|
if (set) bprop->setarray = (PropBooleanArraySetFunc)set;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (get) bprop->get = (PropBooleanGetFunc)get;
|
|
|
|
if (set) bprop->set = (PropBooleanSetFunc)set;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not boolean.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-14 14:34:19 +00:00
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-11-14 14:34:19 +00:00
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->arraydimension) {
|
|
|
|
if (get) iprop->getarray = (PropIntArrayGetFunc)get;
|
|
|
|
if (set) iprop->setarray = (PropIntArraySetFunc)set;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (get) iprop->get = (PropIntGetFunc)get;
|
|
|
|
if (set) iprop->set = (PropIntSetFunc)set;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
if (range) iprop->range = (PropIntRangeFunc)range;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not int.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-14 14:34:19 +00:00
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-11-14 14:34:19 +00:00
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->arraydimension) {
|
|
|
|
if (get) fprop->getarray = (PropFloatArrayGetFunc)get;
|
|
|
|
if (set) fprop->setarray = (PropFloatArraySetFunc)set;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (get) fprop->get = (PropFloatGetFunc)get;
|
|
|
|
if (set) fprop->set = (PropFloatSetFunc)set;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
if (range) fprop->range = (PropFloatRangeFunc)range;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not float.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-28 23:23:47 +00:00
|
|
|
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-11-14 14:34:19 +00:00
|
|
|
case PROP_ENUM: {
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (get) eprop->get = (PropEnumGetFunc)get;
|
|
|
|
if (set) eprop->set = (PropEnumSetFunc)set;
|
|
|
|
if (item) eprop->itemf = (PropEnumItemFunc)item;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not enum.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-14 14:34:19 +00:00
|
|
|
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
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-11-14 14:34:19 +00:00
|
|
|
case PROP_STRING: {
|
2012-03-05 23:30:41 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (get) sprop->get = (PropStringGetFunc)get;
|
|
|
|
if (length) sprop->length = (PropStringLengthFunc)length;
|
|
|
|
if (set) sprop->set = (PropStringSetFunc)set;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not string.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set,
|
|
|
|
const char *typef, const char *poll)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-11-14 14:34:19 +00:00
|
|
|
case PROP_POINTER: {
|
2012-03-05 23:30:41 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (get) pprop->get = (PropPointerGetFunc)get;
|
|
|
|
if (set) pprop->set = (PropPointerSetFunc)set;
|
|
|
|
if (typef) pprop->typef = (PropPointerTypeFunc)typef;
|
|
|
|
if (poll) pprop->poll = (PropPointerPollFunc)poll;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not pointer.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end,
|
|
|
|
const char *get, const char *length, const char *lookupint,
|
|
|
|
const char *lookupstring, const char *assignint)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +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
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-11-14 14:34:19 +00:00
|
|
|
case PROP_COLLECTION: {
|
2012-03-05 23:30:41 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA*)prop;
|
|
|
|
|
|
|
|
if (begin) cprop->begin = (PropCollectionBeginFunc)begin;
|
|
|
|
if (next) cprop->next = (PropCollectionNextFunc)next;
|
|
|
|
if (end) cprop->end = (PropCollectionEndFunc)end;
|
|
|
|
if (get) cprop->get = (PropCollectionGetFunc)get;
|
|
|
|
if (length) cprop->length = (PropCollectionLengthFunc)length;
|
|
|
|
if (lookupint) cprop->lookupint = (PropCollectionLookupIntFunc)lookupint;
|
|
|
|
if (lookupstring) cprop->lookupstring = (PropCollectionLookupStringFunc)lookupstring;
|
|
|
|
if (assignint) cprop->assignint = (PropCollectionAssignIntFunc)assignint;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", type is not collection.\n", __func__, srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-14 14:34:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-13 16:08:03 +00:00
|
|
|
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
|
2009-11-03 16:07:29 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->srna = (StructRNA*)type;
|
2009-11-03 16:07:29 +00:00
|
|
|
}
|
|
|
|
|
2011-06-06 17:50:20 +00:00
|
|
|
void RNA_def_py_data(PropertyRNA *prop, void *py_data)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->py_data = py_data;
|
2011-06-06 17:50:20 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 23:53:11 +00:00
|
|
|
/* Compact definitions */
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, int default_value,
|
|
|
|
const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_boolean_default(prop, default_value);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value,
|
|
|
|
const char *ui_name, const char *ui_description)
|
2009-03-04 15:30:47 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-03-04 15:30:47 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
|
2009-03-04 15:30:47 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_boolean_layer(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value,
|
|
|
|
const char *ui_name, const char *ui_description)
|
2009-09-09 17:39:19 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-09-09 17:39:19 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER);
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
|
2009-09-09 17:39:19 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_boolean_layer_member(StructOrFunctionRNA *cont_, const char *identifier, int len,
|
|
|
|
int *default_value, const char *ui_name, const char *ui_description)
|
2009-09-09 17:39:19 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-09-09 17:39:19 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER_MEMBER);
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
|
2009-09-09 17:39:19 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value,
|
|
|
|
const char *ui_name, const char *ui_description)
|
2009-03-04 15:30:47 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-03-04 15:30:47 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_XYZ); /* XXX */
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
|
2009-03-04 15:30:47 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin,
|
|
|
|
int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_int_default(prop, default_value);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value,
|
|
|
|
int hardmin, int hardmax, const char *ui_name, const char *ui_description,
|
|
|
|
int softmin, int softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); /* XXX */
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_int_array_default(prop, default_value);
|
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value,
|
|
|
|
int hardmin, int hardmax, const char *ui_name, const char *ui_description,
|
|
|
|
int softmin, int softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_int_array_default(prop, default_value);
|
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen,
|
|
|
|
const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_NONE);
|
|
|
|
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
|
|
|
if (default_value) RNA_def_property_string_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value,
|
|
|
|
int maxlen, const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_FILEPATH);
|
|
|
|
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
|
|
|
if (default_value) RNA_def_property_string_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_string_dir_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value,
|
|
|
|
int maxlen, const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_DIRPATH);
|
|
|
|
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
|
|
|
if (default_value) RNA_def_property_string_default(prop, default_value);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_string_file_name(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value,
|
|
|
|
int maxlen, const char *ui_name, const char *ui_description)
|
2009-09-12 19:54:39 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-09-12 19:54:39 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_FILENAME);
|
|
|
|
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
|
|
|
if (default_value) RNA_def_property_string_default(prop, default_value);
|
2009-09-12 19:54:39 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_string_translate(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value,
|
|
|
|
int maxlen, const char *ui_name, const char *ui_description)
|
2011-09-21 13:53:35 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2011-09-21 13:53:35 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_TRANSLATE);
|
|
|
|
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
|
|
|
if (default_value) RNA_def_property_string_default(prop, default_value);
|
2011-09-21 13:53:35 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items,
|
|
|
|
int default_value, const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
2009-10-14 19:19:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!items) {
|
2011-09-28 05:20:14 +00:00
|
|
|
printf("%s: items not allowed to be NULL.\n", __func__);
|
2009-10-14 19:19:43 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-01-16 23:53:11 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
|
|
|
|
if (items) RNA_def_property_enum_items(prop, items);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_enum_default(prop, default_value);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2011-01-13 14:29:57 +00:00
|
|
|
/* same as above but sets 'PROP_ENUM_FLAG' before setting the default value */
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items,
|
|
|
|
int default_value, const char *ui_name, const char *ui_description)
|
2011-01-13 14:29:57 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2011-01-13 14:29:57 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!items) {
|
2011-09-28 05:20:14 +00:00
|
|
|
printf("%s: items not allowed to be NULL.\n", __func__);
|
2011-01-13 14:29:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
|
2011-01-13 14:29:57 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_FLAG); /* important to run before default set */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (items) RNA_def_property_enum_items(prop, items);
|
2011-01-13 14:29:57 +00:00
|
|
|
RNA_def_property_enum_default(prop, default_value);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-07-08 15:34:41 +00:00
|
|
|
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA*)prop;
|
|
|
|
eprop->itemf = itemfunc;
|
2009-07-08 15:34:41 +00:00
|
|
|
}
|
|
|
|
|
2011-05-26 16:07:28 +00:00
|
|
|
void RNA_def_enum_py_data(PropertyRNA *prop, void *py_data)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA*)prop;
|
|
|
|
eprop->py_data = py_data;
|
2011-05-26 16:07:28 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value,
|
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description,
|
|
|
|
float softmin, float softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_float_default(prop, default_value);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len,
|
|
|
|
const float *default_value, float hardmin, float hardmax, const char *ui_name,
|
|
|
|
const char *ui_description, float softmin, float softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ);
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_float_array_default(prop, default_value);
|
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_float_vector_xyz(StructOrFunctionRNA *cont_, const char *identifier, int len,
|
|
|
|
const float *default_value, float hardmin, float hardmax, const char *ui_name,
|
|
|
|
const char *ui_description, float softmin, float softmax)
|
2010-08-26 00:06:10 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
prop = RNA_def_float_vector(cont_, identifier, len, default_value, hardmin, hardmax, ui_name, ui_description,
|
|
|
|
softmin, softmax);
|
2010-09-03 14:53:54 +00:00
|
|
|
prop->subtype = PROP_XYZ_LENGTH;
|
2010-08-26 00:06:10 +00:00
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, int len,
|
|
|
|
const float *default_value, float hardmin, float hardmax, const char *ui_name,
|
|
|
|
const char *ui_description, float softmin, float softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_COLOR);
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_float_array_default(prop, default_value);
|
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int rows, int columns,
|
|
|
|
const float *default_value, float hardmin, float hardmax, const char *ui_name,
|
|
|
|
const char *ui_description, float softmin, float softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
2010-11-02 13:12:30 +00:00
|
|
|
int length[2];
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
length[0] = rows;
|
|
|
|
length[1] = columns;
|
2010-11-02 13:12:30 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX);
|
2009-09-09 19:40:46 +00:00
|
|
|
RNA_def_property_multi_array(prop, 2, length);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (default_value) RNA_def_property_float_array_default(prop, default_value);
|
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *identifier, int len,
|
|
|
|
const float *default_value, float hardmin, float hardmax, const char *ui_name,
|
|
|
|
const char *ui_description, float softmin, float softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, (len != 0) ? PROP_EULER : PROP_ANGLE);
|
|
|
|
if (len != 0) {
|
2011-11-18 09:23:55 +00:00
|
|
|
RNA_def_property_array(prop, len);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (default_value) RNA_def_property_float_array_default(prop, default_value);
|
2011-11-18 09:23:55 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* RNA_def_property_float_default must be called outside */
|
|
|
|
BLI_assert(default_value == NULL);
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, int len,
|
|
|
|
const float *default_value, float hardmin, float hardmax, const char *ui_name,
|
|
|
|
const char *ui_description, float softmin, float softmax)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
|
|
|
|
if (len != 0) RNA_def_property_array(prop, len);
|
|
|
|
if (default_value) RNA_def_property_float_array_default(prop, default_value);
|
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_, const char *identifier, float default_value,
|
2012-03-18 09:27:36 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description,
|
|
|
|
float softmin, float softmax)
|
2009-02-17 21:07:01 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-02-17 21:07:01 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE);
|
2009-02-17 21:07:01 +00:00
|
|
|
RNA_def_property_float_default(prop, default_value);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-02-17 21:07:01 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-09-21 21:19:58 +00:00
|
|
|
PropertyRNA *RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, float default_value,
|
2012-03-18 09:27:36 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description,
|
|
|
|
float softmin, float softmax)
|
2009-09-21 21:19:58 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-09-21 21:19:58 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_FACTOR);
|
2009-09-21 21:19:58 +00:00
|
|
|
RNA_def_property_float_default(prop, default_value);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
|
2009-09-21 21:19:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type,
|
2012-03-18 09:27:36 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_struct_type(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type,
|
2012-03-18 09:27:36 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_struct_runtime(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_collection(StructOrFunctionRNA *cont_, const char *identifier, const char *type,
|
2012-03-18 09:27:36 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
2009-01-16 23:53:11 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-01-16 23:53:11 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
|
2009-04-07 00:49:39 +00:00
|
|
|
RNA_def_property_struct_type(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type,
|
2012-03-18 09:27:36 +00:00
|
|
|
const char *ui_name, const char *ui_description)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_property_struct_runtime(prop, type);
|
|
|
|
RNA_def_property_ui_text(prop, ui_name, ui_description);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
/* Function */
|
|
|
|
|
|
|
|
static FunctionRNA *rna_def_function(StructRNA *srna, const char *identifier)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
2009-04-07 00:49:39 +00:00
|
|
|
char error[512];
|
|
|
|
|
|
|
|
if (rna_validate_identifier(identifier, error, 0) == 0) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: function identifier \"%s\" - %s\n", __func__, identifier, error);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = MEM_callocN(sizeof(FunctionRNA), "FunctionRNA");
|
|
|
|
func->identifier = identifier;
|
|
|
|
func->description = identifier;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
rna_addtail(&srna->functions, func);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
|
|
|
dsrna = rna_find_struct_def(srna);
|
|
|
|
dfunc = MEM_callocN(sizeof(FunctionDefRNA), "FunctionDefRNA");
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_addtail(&dsrna->functions, dfunc);
|
2012-03-05 23:30:41 +00:00
|
|
|
dfunc->func = func;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
func->flag |= FUNC_RUNTIME;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_def_function(srna, identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at preprocess time.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dfunc = rna_find_function_def(func);
|
|
|
|
dfunc->call = call;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_def_function(srna, identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (DefRNA.preprocess) {
|
2011-09-28 05:20:14 +00:00
|
|
|
fprintf(stderr, "%s: only at runtime.\n", __func__);
|
2009-04-07 00:49:39 +00:00
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func->call = call;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2010-01-24 10:51:59 +00:00
|
|
|
/* C return value only!, multiple RNA returns can be done with RNA_def_function_output */
|
2009-04-07 00:49:39 +00:00
|
|
|
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
|
|
|
|
{
|
2010-01-24 10:51:59 +00:00
|
|
|
if (ret->flag & PROP_DYNAMIC) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", dynamic values are not allowed as strict returns, "
|
|
|
|
"use RNA_def_function_output instead.\n", __func__, func->identifier, ret->identifier);
|
2010-01-24 10:51:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (ret->arraydimension) {
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(stderr, "%s: \"%s.%s\", arrays are not allowed as strict returns, "
|
|
|
|
"use RNA_def_function_output instead.\n", __func__, func->identifier, ret->identifier);
|
2010-01-24 10:51:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func->c_ret = ret;
|
2010-01-02 10:42:38 +00:00
|
|
|
|
2010-01-24 10:51:59 +00:00
|
|
|
RNA_def_function_output(func, ret);
|
2010-01-02 10:42:38 +00:00
|
|
|
}
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
|
2010-01-02 10:42:38 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ret->flag |= PROP_OUTPUT;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_function_flag(FunctionRNA *func, int flag)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
func->flag |= flag;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
func->description = description;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int rna_parameter_size(PropertyRNA *parm)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
PropertyType ptype = parm->type;
|
|
|
|
int len = parm->totarraylength; /* only supports fixed length at the moment */
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (len > 0) {
|
2010-01-24 10:51:59 +00:00
|
|
|
/* XXX in other parts is mentioned that strings can be dynamic as well */
|
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
|
|
|
if (parm->flag & PROP_DYNAMIC)
|
|
|
|
return sizeof(void *);
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
switch (ptype) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
case PROP_INT:
|
|
|
|
return sizeof(int)*len;
|
|
|
|
case PROP_FLOAT:
|
|
|
|
return sizeof(float)*len;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (ptype) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
case PROP_INT:
|
|
|
|
case PROP_ENUM:
|
|
|
|
return sizeof(int);
|
|
|
|
case PROP_FLOAT:
|
|
|
|
return sizeof(float);
|
|
|
|
case PROP_STRING:
|
2012-02-24 11:04:09 +00:00
|
|
|
/* return values don't store a pointer to the original */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (parm->flag & PROP_THICK_WRAP) {
|
|
|
|
StringPropertyRNA *sparm = (StringPropertyRNA*)parm;
|
2010-01-08 13:52:38 +00:00
|
|
|
return sizeof(char) * sparm->maxlength;
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-08 13:52:38 +00:00
|
|
|
return sizeof(char *);
|
2009-04-07 00:49:39 +00:00
|
|
|
case PROP_POINTER: {
|
|
|
|
#ifdef RNA_RUNTIME
|
2012-03-05 23:30:41 +00:00
|
|
|
if (parm->flag & PROP_RNAPTR)
|
2009-04-07 00:49:39 +00:00
|
|
|
return sizeof(PointerRNA);
|
|
|
|
else
|
|
|
|
return sizeof(void *);
|
|
|
|
#else
|
2012-03-05 23:30:41 +00:00
|
|
|
if (parm->flag & PROP_RNAPTR)
|
2009-04-07 00:49:39 +00:00
|
|
|
return sizeof(PointerRNA);
|
|
|
|
else
|
|
|
|
return sizeof(void *);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
return sizeof(ListBase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sizeof(void *);
|
|
|
|
}
|
|
|
|
|
2010-01-24 10:51:59 +00:00
|
|
|
/* this function returns the size of the memory allocated for the parameter,
|
2012-03-09 18:28:30 +00:00
|
|
|
* useful for instance for memory alignment or for storing additional information */
|
2010-01-24 10:51:59 +00:00
|
|
|
int rna_parameter_size_alloc(PropertyRNA *parm)
|
|
|
|
{
|
|
|
|
int size = rna_parameter_size(parm);
|
|
|
|
|
|
|
|
if (parm->flag & PROP_DYNAMIC)
|
2012-03-05 23:30:41 +00:00
|
|
|
size += sizeof(((ParameterDynAlloc *)NULL)->array_tot);
|
2010-01-24 10:51:59 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
/* Dynamic Enums */
|
|
|
|
|
2011-11-25 03:47:34 +00:00
|
|
|
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
{
|
|
|
|
EnumPropertyItem *newitems;
|
2012-03-05 23:30:41 +00:00
|
|
|
int tot = *totitem;
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (tot == 0) {
|
|
|
|
*items = MEM_callocN(sizeof(EnumPropertyItem)*8, "RNA_enum_items_add");
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
else if (tot >= 8 && (tot&(tot-1)) == 0) {
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
/* power of two > 8 */
|
2012-03-05 23:30:41 +00:00
|
|
|
newitems = MEM_callocN(sizeof(EnumPropertyItem)*tot*2, "RNA_enum_items_add");
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
memcpy(newitems, *items, sizeof(EnumPropertyItem)*tot);
|
|
|
|
MEM_freeN(*items);
|
2012-03-05 23:30:41 +00:00
|
|
|
*items = newitems;
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
(*items)[tot] = *item;
|
|
|
|
*totitem = tot+1;
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
}
|
|
|
|
|
2009-07-14 17:35:07 +00:00
|
|
|
void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem)
|
|
|
|
{
|
|
|
|
static EnumPropertyItem sepr = {0, "", 0, NULL, NULL};
|
|
|
|
RNA_enum_item_add(items, totitem, &sepr);
|
|
|
|
}
|
|
|
|
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
for (; item->identifier; item++)
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
RNA_enum_item_add(items, totitem, item);
|
|
|
|
}
|
|
|
|
|
2009-07-14 17:35:07 +00:00
|
|
|
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item, int value)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
for (; item->identifier; item++) {
|
|
|
|
if (item->value == value) {
|
2009-07-14 17:35:07 +00:00
|
|
|
RNA_enum_item_add(items, totitem, item);
|
2012-03-18 09:27:36 +00:00
|
|
|
/* break on first match - does this break anything?
|
|
|
|
* (is quick hack to get object->parent_type working ok for armature/lattice) */
|
|
|
|
break;
|
2009-07-24 11:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-14 17:35:07 +00:00
|
|
|
}
|
|
|
|
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
|
|
|
|
{
|
|
|
|
static EnumPropertyItem empty = {0, NULL, 0, NULL, NULL};
|
|
|
|
RNA_enum_item_add(items, totitem, &empty);
|
|
|
|
}
|
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
/* Memory management */
|
|
|
|
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
void RNA_def_struct_duplicate_pointers(StructRNA *srna)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->identifier) srna->identifier = BLI_strdup(srna->identifier);
|
|
|
|
if (srna->name) srna->name = BLI_strdup(srna->name);
|
|
|
|
if (srna->description) srna->description = BLI_strdup(srna->description);
|
2009-07-21 20:05:16 +00:00
|
|
|
|
|
|
|
srna->flag |= STRUCT_FREE_POINTERS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_struct_free_pointers(StructRNA *srna)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->flag & STRUCT_FREE_POINTERS) {
|
|
|
|
if (srna->identifier) MEM_freeN((void*)srna->identifier);
|
|
|
|
if (srna->name) MEM_freeN((void*)srna->name);
|
|
|
|
if (srna->description) MEM_freeN((void*)srna->description);
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_func_duplicate_pointers(FunctionRNA *func)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->identifier) func->identifier = BLI_strdup(func->identifier);
|
|
|
|
if (func->description) func->description = BLI_strdup(func->description);
|
2009-07-21 20:05:16 +00:00
|
|
|
|
|
|
|
func->flag |= FUNC_FREE_POINTERS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_func_free_pointers(FunctionRNA *func)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_FREE_POINTERS) {
|
|
|
|
if (func->identifier) MEM_freeN((void*)func->identifier);
|
|
|
|
if (func->description) MEM_freeN((void*)func->description);
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-06 15:54:08 +00:00
|
|
|
void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop)
|
2009-07-21 20:05:16 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2009-07-21 20:05:16 +00:00
|
|
|
EnumPropertyItem *earray;
|
|
|
|
float *farray;
|
|
|
|
int *iarray;
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
int a;
|
2009-07-21 20:05:16 +00:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
/* annoying since we just added this to a hash, could make this add the correct key to the hash
|
|
|
|
* in the first place */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->identifier) {
|
|
|
|
if (cont->prophash) {
|
2010-09-06 15:54:08 +00:00
|
|
|
BLI_ghash_remove(cont->prophash, (void*)prop->identifier, NULL, NULL);
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->identifier = BLI_strdup(prop->identifier);
|
2010-09-06 15:54:08 +00:00
|
|
|
BLI_ghash_insert(cont->prophash, (void*)prop->identifier, prop);
|
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->identifier = BLI_strdup(prop->identifier);
|
2010-09-06 15:54:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->name) prop->name = BLI_strdup(prop->name);
|
|
|
|
if (prop->description) prop->description = BLI_strdup(prop->description);
|
2009-07-21 20:05:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2009-07-21 20:05:16 +00:00
|
|
|
case PROP_BOOLEAN: {
|
2012-03-05 23:30:41 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA*)prop;
|
2009-07-21 20:05:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (bprop->defaultarray) {
|
|
|
|
iarray = MEM_callocN(sizeof(int)*prop->totarraylength, "RNA_def_property_store");
|
2009-09-09 19:40:46 +00:00
|
|
|
memcpy(iarray, bprop->defaultarray, sizeof(int)*prop->totarraylength);
|
2012-03-05 23:30:41 +00:00
|
|
|
bprop->defaultarray = iarray;
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
2009-07-21 20:05:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (iprop->defaultarray) {
|
|
|
|
iarray = MEM_callocN(sizeof(int)*prop->totarraylength, "RNA_def_property_store");
|
2009-09-09 19:40:46 +00:00
|
|
|
memcpy(iarray, iprop->defaultarray, sizeof(int)*prop->totarraylength);
|
2012-03-05 23:30:41 +00:00
|
|
|
iprop->defaultarray = iarray;
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_ENUM: {
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA*)prop;
|
2009-07-21 20:05:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->item) {
|
|
|
|
earray = MEM_callocN(sizeof(EnumPropertyItem)*(eprop->totitem+1), "RNA_def_property_store"),
|
2009-07-21 20:05:16 +00:00
|
|
|
memcpy(earray, eprop->item, sizeof(EnumPropertyItem)*(eprop->totitem+1));
|
2012-03-05 23:30:41 +00:00
|
|
|
eprop->item = earray;
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (a = 0; a<eprop->totitem; a++) {
|
2012-03-18 09:27:36 +00:00
|
|
|
if (eprop->item[a].identifier)
|
|
|
|
eprop->item[a].identifier = BLI_strdup(eprop->item[a].identifier);
|
|
|
|
if (eprop->item[a].name)
|
|
|
|
eprop->item[a].name = BLI_strdup(eprop->item[a].name);
|
|
|
|
if (eprop->item[a].description)
|
|
|
|
eprop->item[a].description = BLI_strdup(eprop->item[a].description);
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
}
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
break;
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
2009-07-21 20:05:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (fprop->defaultarray) {
|
|
|
|
farray = MEM_callocN(sizeof(float)*prop->totarraylength, "RNA_def_property_store");
|
2009-09-09 19:40:46 +00:00
|
|
|
memcpy(farray, fprop->defaultarray, sizeof(float)*prop->totarraylength);
|
2012-03-05 23:30:41 +00:00
|
|
|
fprop->defaultarray = farray;
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_STRING: {
|
2012-03-05 23:30:41 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA*)prop;
|
2012-03-18 09:27:36 +00:00
|
|
|
if (sprop->defaultvalue)
|
|
|
|
sprop->defaultvalue = BLI_strdup(sprop->defaultvalue);
|
2009-07-21 20:05:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop->flag |= PROP_FREE_POINTERS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_def_property_free_pointers(PropertyRNA *prop)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_FREE_POINTERS) {
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
int a;
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
if (prop->identifier)
|
|
|
|
MEM_freeN((void*)prop->identifier);
|
|
|
|
if (prop->name)
|
|
|
|
MEM_freeN((void*)prop->name);
|
|
|
|
if (prop->description)
|
|
|
|
MEM_freeN((void*)prop->description);
|
|
|
|
if (prop->py_data)
|
|
|
|
MEM_freeN(prop->py_data);
|
2009-07-21 20:05:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2009-07-21 20:05:16 +00:00
|
|
|
case PROP_BOOLEAN: {
|
2012-03-05 23:30:41 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA*)prop;
|
2012-03-18 09:27:36 +00:00
|
|
|
if (bprop->defaultarray)
|
|
|
|
MEM_freeN((void*)bprop->defaultarray);
|
2009-07-21 20:05:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_INT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA*)prop;
|
2012-03-18 09:27:36 +00:00
|
|
|
if (iprop->defaultarray)
|
|
|
|
MEM_freeN((void*)iprop->defaultarray);
|
2009-07-21 20:05:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLOAT: {
|
2012-03-05 23:30:41 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA*)prop;
|
2012-03-18 09:27:36 +00:00
|
|
|
if (fprop->defaultarray)
|
|
|
|
MEM_freeN((void*)fprop->defaultarray);
|
2009-07-21 20:05:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_ENUM: {
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA*)prop;
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (a = 0; a<eprop->totitem; a++) {
|
2012-03-18 09:27:36 +00:00
|
|
|
if (eprop->item[a].identifier)
|
|
|
|
MEM_freeN((void*)eprop->item[a].identifier);
|
|
|
|
if (eprop->item[a].name)
|
|
|
|
MEM_freeN((void*)eprop->item[a].name);
|
|
|
|
if (eprop->item[a].description)
|
|
|
|
MEM_freeN((void*)eprop->item[a].description);
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
}
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->item) MEM_freeN((void*)eprop->item);
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
break;
|
2009-07-21 20:05:16 +00:00
|
|
|
}
|
|
|
|
case PROP_STRING: {
|
2012-03-05 23:30:41 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA*)prop;
|
2012-03-18 09:27:36 +00:00
|
|
|
if (sprop->defaultvalue)
|
|
|
|
MEM_freeN((void*)sprop->defaultvalue);
|
2009-07-21 20:05:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-08 23:34:54 +00:00
|
|
|
|
2011-04-03 10:04:16 +00:00
|
|
|
static void rna_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop)
|
2010-05-08 23:34:54 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2010-05-08 23:34:54 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_RUNTIME) {
|
|
|
|
if (cont->prophash)
|
2010-05-08 23:34:54 +00:00
|
|
|
BLI_ghash_remove(cont->prophash, (void*)prop->identifier, NULL, NULL);
|
|
|
|
|
2010-08-13 21:49:31 +00:00
|
|
|
RNA_def_property_free_pointers(prop);
|
2010-05-08 23:34:54 +00:00
|
|
|
rna_freelinkN(&cont->properties, prop);
|
|
|
|
}
|
2010-08-13 21:49:31 +00:00
|
|
|
else {
|
|
|
|
RNA_def_property_free_pointers(prop);
|
|
|
|
}
|
2010-05-08 23:34:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* note: only intended for removing dynamic props */
|
|
|
|
int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ContainerRNA *cont = cont_;
|
2010-05-08 23:34:54 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (prop = cont->properties.first; prop; prop = prop->next) {
|
|
|
|
if (strcmp(prop->identifier, identifier) == 0) {
|
|
|
|
if (prop->flag & PROP_RUNTIME) {
|
2011-04-03 10:04:16 +00:00
|
|
|
rna_def_property_free(cont_, prop);
|
2010-05-08 23:34:54 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
2010-05-09 00:06:35 +00:00
|
|
|
return -1;
|
2010-05-08 23:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-21 20:05:16 +00:00
|
|
|
#endif
|
|
|
|
|
2010-12-31 04:12:20 +00:00
|
|
|
const char *RNA_property_typename(PropertyType type)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (type) {
|
2010-12-31 04:12:20 +00:00
|
|
|
case PROP_BOOLEAN: return "PROP_BOOLEAN";
|
|
|
|
case PROP_INT: return "PROP_INT";
|
|
|
|
case PROP_FLOAT: return "PROP_FLOAT";
|
|
|
|
case PROP_STRING: return "PROP_STRING";
|
|
|
|
case PROP_ENUM: return "PROP_ENUM";
|
|
|
|
case PROP_POINTER: return "PROP_POINTER";
|
|
|
|
case PROP_COLLECTION: return "PROP_COLLECTION";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "PROP_UNKNOWN";
|
|
|
|
}
|