2008-10-31 23:50:02 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
#include "DNA_ID.h"
|
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
2008-11-11 18:28:00 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_dynstr.h"
|
|
|
|
|
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
|
|
|
#include "BKE_idprop.h"
|
2008-11-21 19:14:38 +00:00
|
|
|
#include "BKE_utildefines.h"
|
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-01-01 15:52:51 +00:00
|
|
|
#include "WM_api.h"
|
2008-11-17 18:44:06 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "RNA_access.h"
|
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
|
|
|
#include "RNA_define.h"
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "RNA_types.h"
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
#include "rna_internal.h"
|
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
|
|
|
/* Exit */
|
|
|
|
|
|
|
|
void RNA_exit()
|
|
|
|
{
|
|
|
|
RNA_free(&BLENDER_RNA);
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
/* Pointer */
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_main_pointer_create(struct Main *main, PointerRNA *r_ptr)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-07 02:58:25 +00:00
|
|
|
r_ptr->id.type= NULL;
|
2008-11-24 15:51:55 +00:00
|
|
|
r_ptr->id.data= NULL;
|
|
|
|
r_ptr->type= &RNA_Main;
|
|
|
|
r_ptr->data= main;
|
|
|
|
}
|
|
|
|
|
2009-01-08 15:33:34 +00:00
|
|
|
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
|
2008-11-24 15:51:55 +00:00
|
|
|
{
|
2009-01-08 15:33:34 +00:00
|
|
|
PointerRNA tmp;
|
|
|
|
StructRNA *idtype= NULL;
|
|
|
|
|
|
|
|
if(id) {
|
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
|
|
|
tmp.data= id;
|
|
|
|
idtype= rna_ID_refine(&tmp);
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
r_ptr->id.type= idtype;
|
|
|
|
r_ptr->id.data= id;
|
|
|
|
r_ptr->type= idtype;
|
|
|
|
r_ptr->data= id;
|
|
|
|
}
|
|
|
|
|
2009-01-08 15:33:34 +00:00
|
|
|
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
|
2008-11-24 15:51:55 +00:00
|
|
|
{
|
2009-01-08 15:33:34 +00:00
|
|
|
PointerRNA tmp;
|
|
|
|
StructRNA *idtype= NULL;
|
|
|
|
|
|
|
|
if(id) {
|
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
|
|
|
tmp.data= id;
|
|
|
|
idtype= rna_ID_refine(&tmp);
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
r_ptr->id.type= idtype;
|
|
|
|
r_ptr->id.data= id;
|
|
|
|
r_ptr->type= type;
|
|
|
|
r_ptr->data= data;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-12-16 20:03:28 +00:00
|
|
|
static void rna_pointer_inherit_id(StructRNA *type, PointerRNA *parent, PointerRNA *ptr)
|
2008-11-07 02:58:25 +00:00
|
|
|
{
|
2008-12-16 20:03:28 +00:00
|
|
|
if(type && type->flag & STRUCT_ID) {
|
2008-11-07 02:58:25 +00:00
|
|
|
ptr->id.data= ptr->data;
|
2008-12-16 20:03:28 +00:00
|
|
|
ptr->id.type= type;
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ptr->id.data= parent->id.data;
|
|
|
|
ptr->id.type= parent->id.type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-15 13:46:50 +00:00
|
|
|
void RNA_blender_rna_pointer_create(PointerRNA *r_ptr)
|
|
|
|
{
|
|
|
|
r_ptr->id.type= NULL;
|
|
|
|
r_ptr->id.data= NULL;
|
|
|
|
r_ptr->type= &RNA_BlenderRNA;
|
|
|
|
r_ptr->data= &BLENDER_RNA;
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:44:06 +00:00
|
|
|
/* ID Properties */
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
IDProperty *rna_idproperties_get(PointerRNA *ptr, int create)
|
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-01-01 20:44:40 +00:00
|
|
|
if(ptr->type->flag & STRUCT_ID)
|
|
|
|
return IDP_GetProperties(ptr->data, create);
|
2009-01-10 22:57:33 +00:00
|
|
|
else if(ptr->type == &RNA_IDPropertyGroup || ptr->type->base == &RNA_IDPropertyGroup)
|
2009-01-01 20:44:40 +00:00
|
|
|
return ptr->data;
|
2009-01-10 22:57:33 +00:00
|
|
|
else if(ptr->type->base == &RNA_OperatorProperties) {
|
2009-01-01 20:44:40 +00:00
|
|
|
if(create && !ptr->data) {
|
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
|
|
|
IDPropertyTemplate val;
|
|
|
|
val.i = 0; /* silence MSVC warning about uninitialized var when debugging */
|
2009-01-01 20:44:40 +00:00
|
|
|
ptr->data= IDP_New(IDP_GROUP, val, "RNA_OperatorProperties group");
|
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-01-01 20:44:40 +00:00
|
|
|
return ptr->data;
|
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
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
2009-01-01 20:44:40 +00:00
|
|
|
IDProperty *group= rna_idproperties_get(ptr, 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
|
|
|
IDProperty *idprop;
|
|
|
|
|
|
|
|
if(group) {
|
|
|
|
for(idprop=group->data.group.first; idprop; idprop=idprop->next)
|
|
|
|
if(strcmp(idprop->name, name) == 0)
|
|
|
|
return idprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-11-21 19:14:38 +00:00
|
|
|
static int rna_idproperty_verify_valid(PropertyRNA *prop, IDProperty *idprop)
|
|
|
|
{
|
|
|
|
/* this verifies if the idproperty actually matches the property
|
|
|
|
* description and otherwise removes it. this is to ensure that
|
|
|
|
* rna property access is type safe, e.g. if you defined the rna
|
|
|
|
* to have a certain array length you can count on that staying so */
|
|
|
|
|
|
|
|
switch(idprop->type) {
|
2008-12-31 13:16:37 +00:00
|
|
|
case IDP_IDPARRAY:
|
|
|
|
if(prop->type != PROP_COLLECTION)
|
|
|
|
return 0;
|
|
|
|
break;
|
2008-11-21 19:14:38 +00:00
|
|
|
case IDP_ARRAY:
|
2008-12-31 13:16:37 +00:00
|
|
|
if(prop->arraylength != idprop->len)
|
2008-11-21 19:14:38 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(idprop->subtype == IDP_FLOAT && prop->type != PROP_FLOAT)
|
|
|
|
return 0;
|
|
|
|
if(idprop->subtype == IDP_INT && !ELEM3(prop->type, PROP_BOOLEAN, PROP_INT, PROP_ENUM))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case IDP_INT:
|
|
|
|
if(!ELEM3(prop->type, PROP_BOOLEAN, PROP_INT, PROP_ENUM))
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case IDP_FLOAT:
|
|
|
|
case IDP_DOUBLE:
|
|
|
|
if(prop->type != PROP_FLOAT)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case IDP_STRING:
|
|
|
|
if(prop->type != PROP_STRING)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case IDP_GROUP:
|
|
|
|
if(prop->type != PROP_POINTER)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:44:06 +00:00
|
|
|
IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
/* This is quite a hack, but avoids some complexity in the API. we
|
|
|
|
* pass IDProperty structs as PropertyRNA pointers to the outside.
|
|
|
|
* We store some bytes in PropertyRNA structs that allows us to
|
|
|
|
* distinguish it from IDProperty structs. If it is an ID property,
|
|
|
|
* we look up an IDP PropertyRNA based on the type, and set the data
|
|
|
|
* pointer to the IDProperty. */
|
|
|
|
|
|
|
|
if((*prop)->magic == RNA_MAGIC) {
|
2008-11-21 19:14:38 +00:00
|
|
|
if((*prop)->flag & PROP_IDPROPERTY) {
|
|
|
|
IDProperty *idprop= rna_idproperty_find(ptr, (*prop)->identifier);
|
|
|
|
|
|
|
|
if(idprop && !rna_idproperty_verify_valid(*prop, idprop)) {
|
2009-01-01 20:44:40 +00:00
|
|
|
IDProperty *group= rna_idproperties_get(ptr, 0);
|
2008-11-21 19:14:38 +00:00
|
|
|
|
|
|
|
IDP_RemFromGroup(group, idprop);
|
|
|
|
IDP_FreeProperty(idprop);
|
|
|
|
MEM_freeN(idprop);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return idprop;
|
|
|
|
}
|
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
|
|
|
|
return NULL;
|
2008-11-17 18:44:06 +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
|
|
|
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
static PropertyRNA *typemap[IDP_NUMTYPES] =
|
|
|
|
{(PropertyRNA*)&rna_IDProperty_string,
|
|
|
|
(PropertyRNA*)&rna_IDProperty_int,
|
|
|
|
(PropertyRNA*)&rna_IDProperty_float,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
(PropertyRNA*)&rna_IDProperty_group, NULL,
|
|
|
|
(PropertyRNA*)&rna_IDProperty_double};
|
|
|
|
|
|
|
|
static PropertyRNA *arraytypemap[IDP_NUMTYPES] =
|
2009-01-10 22:57:33 +00:00
|
|
|
{NULL, (PropertyRNA*)&rna_IDProperty_int_array,
|
|
|
|
(PropertyRNA*)&rna_IDProperty_float_array,
|
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
|
|
|
NULL, NULL, NULL,
|
|
|
|
(PropertyRNA*)&rna_IDProperty_collection, NULL,
|
2009-01-10 22:57:33 +00:00
|
|
|
(PropertyRNA*)&rna_IDProperty_double_array};
|
2008-11-17 18:44:06 +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
|
|
|
IDProperty *idprop= (IDProperty*)(*prop);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
|
|
|
if(idprop->type == IDP_ARRAY)
|
|
|
|
*prop= arraytypemap[(int)(idprop->subtype)];
|
|
|
|
else
|
|
|
|
*prop= typemap[(int)(idprop->type)];
|
|
|
|
|
|
|
|
return idprop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
/* Structs */
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
const char *RNA_struct_identifier(PointerRNA *ptr)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-14 18:46:57 +00:00
|
|
|
return ptr->type->identifier;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *RNA_struct_ui_name(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return ptr->type->name;
|
|
|
|
}
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
const char *RNA_struct_ui_description(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return ptr->type->description;
|
|
|
|
}
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
PropertyRNA *RNA_struct_name_property(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return ptr->type->nameproperty;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyRNA *RNA_struct_iterator_property(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return ptr->type->iteratorproperty;
|
|
|
|
}
|
|
|
|
|
2008-11-29 15:43:53 +00:00
|
|
|
int RNA_struct_is_ID(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return (ptr->type->flag & STRUCT_ID) != 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
|
|
|
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
|
|
|
|
{
|
|
|
|
CollectionPropertyIterator iter;
|
|
|
|
PropertyRNA *iterprop, *prop;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
iterprop= RNA_struct_iterator_property(ptr);
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_begin(ptr, iterprop, &iter);
|
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= NULL;
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
for(; iter.valid; RNA_property_collection_next(&iter), i++) {
|
|
|
|
if(strcmp(identifier, RNA_property_identifier(&iter.ptr, iter.ptr.data)) == 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
|
|
|
prop= iter.ptr.data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_end(&iter);
|
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 prop;
|
|
|
|
}
|
|
|
|
|
2008-12-31 13:16:37 +00:00
|
|
|
const struct ListBase *RNA_struct_defined_properties(StructRNA *srna)
|
|
|
|
{
|
|
|
|
return &srna->properties;
|
|
|
|
}
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
/* Property Information */
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
const char *RNA_property_identifier(PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
IDProperty *idprop;
|
|
|
|
|
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((idprop=rna_idproperty_check(&prop, ptr)))
|
2008-11-17 18:44:06 +00:00
|
|
|
return idprop->name;
|
|
|
|
else
|
|
|
|
return prop->identifier;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
PropertyType RNA_property_type(PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-14 14:34:19 +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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
return prop->type;
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
PropertySubType RNA_property_subtype(PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-14 14:34:19 +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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
return prop->subtype;
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
IDProperty *idprop;
|
|
|
|
|
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((idprop=rna_idproperty_check(&prop, ptr)) && idprop->type==IDP_ARRAY)
|
2008-11-17 18:44:06 +00:00
|
|
|
return idprop->len;
|
|
|
|
else
|
|
|
|
return prop->arraylength;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, int *hardmax)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
IntPropertyRNA *iprop;
|
|
|
|
|
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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
iprop= (IntPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(iprop->range) {
|
|
|
|
iprop->range(ptr, hardmin, hardmax);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*hardmin= iprop->hardmin;
|
|
|
|
*hardmax= iprop->hardmax;
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin, int *softmax, int *step)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
IntPropertyRNA *iprop;
|
2008-11-24 12:12:24 +00:00
|
|
|
int hardmin, hardmax;
|
2008-11-17 18:44:06 +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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
iprop= (IntPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(iprop->range) {
|
|
|
|
iprop->range(ptr, &hardmin, &hardmax);
|
|
|
|
*softmin= MAX2(iprop->softmin, hardmin);
|
|
|
|
*softmax= MIN2(iprop->softmax, hardmax);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*softmin= iprop->softmin;
|
|
|
|
*softmax= iprop->softmax;
|
|
|
|
}
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
*step= iprop->step;
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
FloatPropertyRNA *fprop;
|
|
|
|
|
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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
fprop= (FloatPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(fprop->range) {
|
|
|
|
fprop->range(ptr, hardmin, hardmax);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*hardmin= fprop->hardmin;
|
|
|
|
*hardmax= fprop->hardmax;
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
FloatPropertyRNA *fprop;
|
2008-11-24 12:12:24 +00:00
|
|
|
float hardmin, hardmax;
|
2008-11-17 18:44:06 +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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
fprop= (FloatPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(fprop->range) {
|
|
|
|
fprop->range(ptr, &hardmin, &hardmax);
|
|
|
|
*softmin= MAX2(fprop->softmin, hardmin);
|
|
|
|
*softmax= MIN2(fprop->softmax, hardmax);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*softmin= fprop->softmin;
|
|
|
|
*softmax= fprop->softmax;
|
|
|
|
}
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
*step= fprop->step;
|
2008-12-26 02:06:54 +00:00
|
|
|
*precision= (float)fprop->precision;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_string_maxlength(PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
StringPropertyRNA *sprop;
|
2008-11-14 14:34:19 +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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
sprop= (StringPropertyRNA*)prop;
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
return sprop->maxlength;
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem)
|
2008-11-14 14:34:19 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
EnumPropertyRNA *eprop;
|
|
|
|
|
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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
eprop= (EnumPropertyRNA*)prop;
|
2008-11-14 14:34:19 +00:00
|
|
|
|
|
|
|
*item= eprop->item;
|
|
|
|
*totitem= eprop->totitem;
|
|
|
|
}
|
|
|
|
|
2008-12-02 14:36:35 +00:00
|
|
|
int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value)
|
|
|
|
{
|
|
|
|
const EnumPropertyItem *item;
|
|
|
|
int totitem, i;
|
|
|
|
|
|
|
|
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
|
|
|
|
|
|
|
for (i=0; i<totitem; i++) {
|
|
|
|
if (strcmp(item[i].identifier, identifier)==0) {
|
|
|
|
*value = item[i].value;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
|
|
|
|
{
|
|
|
|
const EnumPropertyItem *item;
|
|
|
|
int totitem, i;
|
|
|
|
|
|
|
|
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
|
|
|
|
|
|
|
for (i=0; i<totitem; i++) {
|
|
|
|
if (item[i].value==value) {
|
|
|
|
*identifier = item[i].identifier;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
const char *RNA_property_ui_name(PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-14 14:34:19 +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
|
|
|
PropertyRNA *oldprop= prop;
|
2008-11-17 18:44:06 +00:00
|
|
|
IDProperty *idprop;
|
|
|
|
|
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((idprop=rna_idproperty_check(&prop, ptr)) && oldprop!=prop)
|
2008-11-17 18:44:06 +00:00
|
|
|
return idprop->name;
|
|
|
|
else
|
|
|
|
return prop->name;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
const char *RNA_property_ui_description(PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-14 14:34:19 +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
|
|
|
PropertyRNA *oldprop= prop;
|
|
|
|
|
|
|
|
if(rna_idproperty_check(&prop, ptr) && oldprop!=prop)
|
2008-11-17 18:44:06 +00:00
|
|
|
return "";
|
|
|
|
else
|
|
|
|
return prop->description;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
int flag;
|
|
|
|
|
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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->editable)
|
|
|
|
flag= prop->editable(ptr);
|
|
|
|
else
|
|
|
|
flag= prop->flag;
|
|
|
|
|
|
|
|
return !(flag & PROP_NOT_EDITABLE);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_evaluated(PointerRNA *ptr, PropertyRNA *prop)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 12:12:24 +00:00
|
|
|
int flag;
|
|
|
|
|
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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(prop->editable)
|
|
|
|
flag= prop->editable(ptr);
|
|
|
|
else
|
|
|
|
flag= prop->flag;
|
|
|
|
|
|
|
|
return (flag & PROP_EVALUATED);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
void RNA_property_update(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop)
|
2008-11-07 02:58:25 +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_idproperty_check(&prop, ptr);
|
2008-11-17 18:44:06 +00:00
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
if(prop->update)
|
|
|
|
prop->update(C, ptr);
|
|
|
|
if(prop->noteflag)
|
|
|
|
WM_event_add_notifier(C, prop->noteflag, ptr->id.data);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
2008-11-17 18:44:06 +00:00
|
|
|
/* Property Data */
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
|
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
|
|
|
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
return IDP_Int(idprop);
|
|
|
|
else if(bprop->get)
|
|
|
|
return bprop->get(ptr);
|
|
|
|
else
|
|
|
|
return bprop->defaultvalue;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value)
|
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
|
|
|
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
IDP_Int(idprop)= value;
|
|
|
|
else if(bprop->set)
|
2008-11-14 14:34:19 +00:00
|
|
|
bprop->set(ptr, value);
|
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 if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.i= value;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(group)
|
|
|
|
IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier));
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, int index)
|
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
|
|
|
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
return ((int*)IDP_Array(idprop))[index];
|
|
|
|
else if(bprop->getarray)
|
|
|
|
return bprop->getarray(ptr, index);
|
|
|
|
else
|
|
|
|
return bprop->defaultarray[index];
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
|
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
|
|
|
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
((int*)IDP_Array(idprop))[index]= value;
|
|
|
|
else if(bprop->setarray)
|
2008-11-14 14:34:19 +00:00
|
|
|
bprop->setarray(ptr, index, value);
|
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 if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.array.len= prop->arraylength;
|
|
|
|
val.array.type= IDP_INT;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(group) {
|
|
|
|
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
|
|
|
|
IDP_AddToGroup(group, idprop);
|
|
|
|
memcpy(idprop->data.pointer, bprop->defaultarray, sizeof(int)*prop->arraylength);
|
|
|
|
((int*)idprop->data.pointer)[index]= value;
|
|
|
|
}
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
|
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
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
return IDP_Int(idprop);
|
|
|
|
else if(iprop->get)
|
|
|
|
return iprop->get(ptr);
|
|
|
|
else
|
|
|
|
return iprop->defaultvalue;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
|
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
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
IDP_Int(idprop)= value;
|
|
|
|
else if(iprop->set)
|
2008-11-14 14:34:19 +00:00
|
|
|
iprop->set(ptr, value);
|
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 if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.i= value;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(group)
|
|
|
|
IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier));
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int index)
|
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
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
return ((int*)IDP_Array(idprop))[index];
|
|
|
|
else if(iprop->getarray)
|
|
|
|
return iprop->getarray(ptr, index);
|
|
|
|
else
|
|
|
|
return iprop->defaultarray[index];
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
|
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
|
|
|
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
((int*)IDP_Array(idprop))[index]= value;
|
|
|
|
else if(iprop->setarray)
|
2008-11-14 14:34:19 +00:00
|
|
|
iprop->setarray(ptr, index, value);
|
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 if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.array.len= prop->arraylength;
|
|
|
|
val.array.type= IDP_INT;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(group) {
|
|
|
|
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
|
|
|
|
IDP_AddToGroup(group, idprop);
|
|
|
|
memcpy(idprop->data.pointer, iprop->defaultarray, sizeof(int)*prop->arraylength);
|
|
|
|
((int*)idprop->data.pointer)[index]= value;
|
|
|
|
}
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
|
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
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
|
|
|
if(idprop->type == IDP_FLOAT)
|
|
|
|
return IDP_Float(idprop);
|
|
|
|
else
|
|
|
|
return (float)IDP_Double(idprop);
|
|
|
|
}
|
|
|
|
else if(fprop->get)
|
|
|
|
return fprop->get(ptr);
|
|
|
|
else
|
|
|
|
return fprop->defaultvalue;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
|
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
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
|
|
|
if(idprop->type == IDP_FLOAT)
|
|
|
|
IDP_Float(idprop)= value;
|
|
|
|
else
|
|
|
|
IDP_Double(idprop)= value;
|
|
|
|
}
|
|
|
|
else if(fprop->set) {
|
2008-11-14 14:34:19 +00:00
|
|
|
fprop->set(ptr, value);
|
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 if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.f= value;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(group)
|
|
|
|
IDP_AddToGroup(group, IDP_New(IDP_FLOAT, val, (char*)prop->identifier));
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
float RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, int index)
|
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
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
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
|
|
|
if(idprop->subtype == IDP_FLOAT)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return ((float*)IDP_Array(idprop))[index];
|
|
|
|
else
|
|
|
|
return (float)(((double*)IDP_Array(idprop))[index]);
|
|
|
|
}
|
|
|
|
else if(fprop->getarray)
|
|
|
|
return fprop->getarray(ptr, index);
|
|
|
|
else
|
|
|
|
return fprop->defaultarray[index];
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
|
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
|
|
|
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
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
|
|
|
if(idprop->subtype == IDP_FLOAT)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
((float*)IDP_Array(idprop))[index]= value;
|
|
|
|
else
|
|
|
|
((double*)IDP_Array(idprop))[index]= value;
|
|
|
|
}
|
|
|
|
else if(fprop->setarray) {
|
2008-11-14 14:34:19 +00:00
|
|
|
fprop->setarray(ptr, index, value);
|
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 if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.array.len= prop->arraylength;
|
|
|
|
val.array.type= IDP_FLOAT;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(group) {
|
|
|
|
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
|
|
|
|
IDP_AddToGroup(group, idprop);
|
|
|
|
memcpy(idprop->data.pointer, fprop->defaultarray, sizeof(float)*prop->arraylength);
|
2008-12-31 13:16:37 +00:00
|
|
|
((float*)IDP_Array(idprop))[index]= value;
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
|
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
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
strcpy(value, IDP_String(idprop));
|
|
|
|
else if(sprop->get)
|
|
|
|
sprop->get(ptr, value);
|
|
|
|
else
|
|
|
|
strcpy(value, sprop->defaultvalue);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen)
|
2008-11-11 15:03:26 +00:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
int length;
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
length= RNA_property_string_length(ptr, prop);
|
2008-11-11 15:03:26 +00:00
|
|
|
|
|
|
|
if(length+1 < fixedlen)
|
|
|
|
buf= fixedbuf;
|
|
|
|
else
|
|
|
|
buf= MEM_callocN(sizeof(char)*(length+1), "RNA_string_get_alloc");
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_string_get(ptr, prop, buf);
|
2008-11-11 15:03:26 +00:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
|
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
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
return strlen(IDP_String(idprop));
|
|
|
|
else if(sprop->length)
|
|
|
|
return sprop->length(ptr);
|
|
|
|
else
|
|
|
|
return strlen(sprop->defaultvalue);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
|
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
|
|
|
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
IDP_AssignString(idprop, (char*)value);
|
|
|
|
else if(sprop->set)
|
2008-11-14 14:34:19 +00:00
|
|
|
sprop->set(ptr, value);
|
2008-12-25 14:17:54 +00:00
|
|
|
else if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
2008-12-26 02:06:54 +00:00
|
|
|
val.str= (char*)value;
|
2008-12-25 14:17:54 +00:00
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
2008-12-25 14:17:54 +00:00
|
|
|
if(group)
|
|
|
|
IDP_AddToGroup(group, IDP_New(IDP_STRING, val, (char*)prop->identifier));
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
|
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
|
|
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
return IDP_Int(idprop);
|
|
|
|
else if(eprop->get)
|
|
|
|
return eprop->get(ptr);
|
|
|
|
else
|
|
|
|
return eprop->defaultvalue;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-12-02 14:36:35 +00:00
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
|
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
|
|
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
IDP_Int(idprop)= value;
|
|
|
|
else if(eprop->set) {
|
2008-11-14 14:34:19 +00:00
|
|
|
eprop->set(ptr, value);
|
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 if(!(prop->flag & PROP_NOT_EDITABLE)) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.i= value;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 1);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(group)
|
|
|
|
IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier));
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
static StructRNA *rna_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
|
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
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
|
|
|
StructRNA *type;
|
2008-11-17 18:44:06 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(pprop->type)
|
|
|
|
type= pprop->type(ptr);
|
|
|
|
else
|
|
|
|
type= pprop->structtype;
|
|
|
|
|
2008-12-16 20:03:28 +00:00
|
|
|
if(type) {
|
|
|
|
rna_pointer_inherit_id(type, ptr, r_ptr);
|
|
|
|
|
|
|
|
if(type->refine)
|
|
|
|
type= type->refine(r_ptr);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
r_ptr->type= type;
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
|
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
|
|
|
{
|
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
|
|
|
r_ptr->data= idprop; /* for groups, data is idprop itself */
|
|
|
|
else if(pprop->get)
|
|
|
|
r_ptr->data= pprop->get(ptr);
|
|
|
|
else
|
|
|
|
r_ptr->data= NULL;
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-12-16 20:03:28 +00:00
|
|
|
if(!(r_ptr->data && rna_property_pointer_type(ptr, prop, r_ptr)))
|
2008-11-07 02:58:25 +00:00
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *ptr_value)
|
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
|
|
|
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
if(pprop->set)
|
|
|
|
pprop->set(ptr, ptr_value->data);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
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_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
IDProperty *idprop;
|
|
|
|
|
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
|
|
|
/* already exists */
|
|
|
|
}
|
|
|
|
else if(prop->flag & PROP_IDPROPERTY) {
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *group;
|
|
|
|
|
|
|
|
val.i= 0;
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 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
|
|
|
if(group)
|
|
|
|
IDP_AddToGroup(group, IDP_New(IDP_GROUP, val, (char*)prop->identifier));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("RNA_property_pointer_add %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier);
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
static StructRNA *rna_property_collection_type(CollectionPropertyIterator *iter)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 15:51:55 +00:00
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->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
|
|
|
StructRNA *type;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 17:05:25 +00:00
|
|
|
if(cprop->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
|
|
|
type= cprop->type(iter);
|
|
|
|
else
|
|
|
|
type= cprop->structtype;
|
2008-11-14 17:05:25 +00:00
|
|
|
|
2008-12-16 20:03:28 +00:00
|
|
|
if(type) {
|
|
|
|
rna_pointer_inherit_id(type, &iter->parent, &iter->ptr);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2008-12-16 20:03:28 +00:00
|
|
|
if(type->refine)
|
|
|
|
type= type->refine(&iter->ptr);
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
iter->ptr.type= 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
|
|
|
return type;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
static void rna_property_collection_get(CollectionPropertyIterator *iter)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 15:51:55 +00:00
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
iter->ptr.data= cprop->get(iter);
|
2008-11-14 17:05:25 +00:00
|
|
|
|
2008-12-16 20:03:28 +00:00
|
|
|
if(!(iter->ptr.data && rna_property_collection_type(iter)))
|
2008-11-24 15:51:55 +00:00
|
|
|
memset(&iter->ptr, 0, sizeof(iter->ptr));
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
static void rna_property_collection_get_idp(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
|
|
|
|
|
2008-12-31 13:16:37 +00:00
|
|
|
iter->ptr.data= rna_iterator_array_get(iter);
|
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
|
|
|
iter->ptr.type= cprop->structtype;
|
|
|
|
rna_pointer_inherit_id(cprop->structtype, &iter->parent, &iter->ptr);
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
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
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
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
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)) || (prop->flag & PROP_IDPROPERTY)) {
|
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
|
|
|
iter->parent= *ptr;
|
2008-11-24 15:51:55 +00:00
|
|
|
iter->prop= prop;
|
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
|
|
|
|
|
|
|
if(idprop)
|
2008-12-31 13:16:37 +00:00
|
|
|
rna_iterator_array_begin(iter, IDP_IDPArray(idprop), sizeof(IDProperty), idprop->len, NULL);
|
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
|
|
|
else
|
2008-12-31 13:16:37 +00:00
|
|
|
rna_iterator_array_begin(iter, NULL, sizeof(IDProperty), 0, NULL);
|
2008-11-14 17:05:25 +00:00
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
if(iter->valid)
|
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
|
|
|
rna_property_collection_get_idp(iter);
|
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
|
|
|
|
memset(&iter->ptr, 0, sizeof(iter->ptr));
|
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
|
|
|
|
|
|
|
iter->idprop= 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
|
|
|
|
|
|
|
if(cprop->begin) {
|
|
|
|
iter->parent= *ptr;
|
|
|
|
iter->prop= prop;
|
|
|
|
iter->idprop= 0;
|
|
|
|
cprop->begin(iter, ptr);
|
|
|
|
|
|
|
|
if(iter->valid)
|
|
|
|
rna_property_collection_get(iter);
|
|
|
|
else
|
|
|
|
memset(&iter->ptr, 0, sizeof(iter->ptr));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
memset(iter, 0, sizeof(*iter));
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_collection_next(CollectionPropertyIterator *iter)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 15:51:55 +00:00
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
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
|
|
|
if(iter->idprop) {
|
|
|
|
rna_iterator_array_next(iter);
|
2008-11-07 02:58:25 +00:00
|
|
|
|
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
|
|
|
if(iter->valid)
|
|
|
|
rna_property_collection_get_idp(iter);
|
|
|
|
else
|
|
|
|
memset(&iter->ptr, 0, sizeof(iter->ptr));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cprop->next(iter);
|
|
|
|
|
|
|
|
if(iter->valid)
|
|
|
|
rna_property_collection_get(iter);
|
|
|
|
else
|
|
|
|
memset(&iter->ptr, 0, sizeof(iter->ptr));
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
void RNA_property_collection_end(CollectionPropertyIterator *iter)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-24 15:51:55 +00:00
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
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
|
|
|
if(iter->idprop)
|
|
|
|
rna_iterator_array_end(iter);
|
|
|
|
else if(cprop->end)
|
2008-11-14 17:05:25 +00:00
|
|
|
cprop->end(iter);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
|
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
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
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
|
|
|
IDProperty *idprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
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
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
|
|
|
return idprop->len;
|
|
|
|
}
|
|
|
|
else if(cprop->length) {
|
2008-11-07 02:58:25 +00:00
|
|
|
return cprop->length(ptr);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
CollectionPropertyIterator iter;
|
|
|
|
int length= 0;
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_begin(ptr, prop, &iter);
|
|
|
|
for(; iter.valid; RNA_property_collection_next(&iter))
|
2008-10-31 23:50:02 +00:00
|
|
|
length++;
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_end(&iter);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
|
|
|
|
{
|
|
|
|
IDProperty *idprop;
|
|
|
|
|
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr))) {
|
2008-12-31 13:16:37 +00:00
|
|
|
IDPropertyTemplate val;
|
|
|
|
IDProperty *item;
|
|
|
|
val.i= 0;
|
|
|
|
|
|
|
|
item= IDP_New(IDP_GROUP, val, "");
|
|
|
|
IDP_AppendArray(idprop, item);
|
|
|
|
IDP_FreeProperty(item);
|
|
|
|
MEM_freeN(item);
|
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
|
|
|
}
|
|
|
|
else if(prop->flag & PROP_IDPROPERTY) {
|
2008-12-31 13:16:37 +00:00
|
|
|
IDProperty *group, *item;
|
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
|
|
|
IDPropertyTemplate val;
|
2008-12-31 13:16:37 +00:00
|
|
|
val.i= 0;
|
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
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
group= rna_idproperties_get(ptr, 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
|
|
|
if(group) {
|
2008-12-31 13:16:37 +00:00
|
|
|
idprop= IDP_NewIDPArray(prop->identifier);
|
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
|
|
|
IDP_AddToGroup(group, idprop);
|
2008-12-31 13:16:37 +00:00
|
|
|
|
|
|
|
item= IDP_New(IDP_GROUP, val, "");
|
|
|
|
IDP_AppendArray(idprop, item);
|
|
|
|
IDP_FreeProperty(item);
|
|
|
|
MEM_freeN(item);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("RNA_property_collection_add %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier);
|
|
|
|
|
|
|
|
if(r_ptr) {
|
|
|
|
if(idprop) {
|
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
|
|
|
|
2008-12-31 13:16:37 +00:00
|
|
|
r_ptr->data= IDP_GetIndexArray(idprop, idprop->len-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
|
|
|
r_ptr->type= cprop->structtype;
|
|
|
|
rna_pointer_inherit_id(NULL, ptr, r_ptr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
IDProperty *idprop;
|
|
|
|
|
|
|
|
if((idprop=rna_idproperty_check(&prop, ptr)))
|
2008-12-31 13:16:37 +00:00
|
|
|
IDP_ResizeIDPArray(idprop, 0);
|
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
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
|
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
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
if(cprop->lookupint) {
|
2008-11-07 02:58:25 +00:00
|
|
|
/* we have a callback defined, use it */
|
|
|
|
r_ptr->data= cprop->lookupint(ptr, key, &r_ptr->type);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
if(r_ptr->data) {
|
|
|
|
if(!r_ptr->type)
|
|
|
|
r_ptr->type= cprop->structtype;
|
2008-12-16 20:03:28 +00:00
|
|
|
rna_pointer_inherit_id(r_ptr->type, ptr, r_ptr);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-11-07 02:58:25 +00:00
|
|
|
/* no callback defined, just iterate and find the nth item */
|
2008-10-31 23:50:02 +00:00
|
|
|
CollectionPropertyIterator iter;
|
2008-11-07 02:58:25 +00:00
|
|
|
int i;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_begin(ptr, prop, &iter);
|
|
|
|
for(i=0; iter.valid; RNA_property_collection_next(&iter), i++) {
|
2008-11-07 02:58:25 +00:00
|
|
|
if(i == key) {
|
2008-11-14 17:05:25 +00:00
|
|
|
*r_ptr= iter.ptr;
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_end(&iter);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
if(!iter.valid)
|
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
return iter.valid;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
|
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
|
|
|
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
if(cprop->lookupstring) {
|
2008-11-07 02:58:25 +00:00
|
|
|
/* we have a callback defined, use it */
|
|
|
|
r_ptr->data= cprop->lookupstring(ptr, key, &r_ptr->type);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
if(r_ptr->data) {
|
|
|
|
if(!r_ptr->type)
|
|
|
|
r_ptr->type= cprop->structtype;
|
2008-12-16 20:03:28 +00:00
|
|
|
rna_pointer_inherit_id(r_ptr->type, ptr, r_ptr);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-11-07 02:58:25 +00:00
|
|
|
/* no callback defined, compare with name properties if they exist */
|
2008-10-31 23:50:02 +00:00
|
|
|
CollectionPropertyIterator iter;
|
2008-11-11 18:28:00 +00:00
|
|
|
PropertyRNA *nameprop;
|
2008-10-31 23:50:02 +00:00
|
|
|
char name[256], *nameptr;
|
2008-11-29 15:43:53 +00:00
|
|
|
int found= 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_begin(ptr, prop, &iter);
|
|
|
|
for(; iter.valid; RNA_property_collection_next(&iter)) {
|
2008-11-14 17:05:25 +00:00
|
|
|
if(iter.ptr.data && iter.ptr.type->nameproperty) {
|
|
|
|
nameprop= iter.ptr.type->nameproperty;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-29 15:43:53 +00:00
|
|
|
nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
if(strcmp(nameptr, key) == 0) {
|
2008-11-14 17:05:25 +00:00
|
|
|
*r_ptr= iter.ptr;
|
2008-11-07 02:58:25 +00:00
|
|
|
found= 1;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-11-30 02:30:34 +00:00
|
|
|
if ((char *)&name != nameptr)
|
2008-11-07 02:58:25 +00:00
|
|
|
MEM_freeN(nameptr);
|
|
|
|
|
|
|
|
if(found)
|
|
|
|
break;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_end(&iter);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
if(!iter.valid)
|
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
return iter.valid;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Standard iterator functions */
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
ListBaseIterator *internal;
|
|
|
|
|
|
|
|
internal= MEM_callocN(sizeof(ListBaseIterator), "ListBaseIterator");
|
|
|
|
internal->link= lb->first;
|
2008-11-24 12:12:24 +00:00
|
|
|
internal->skip= skip;
|
2008-11-17 18:44:06 +00:00
|
|
|
|
|
|
|
iter->internal= internal;
|
|
|
|
iter->valid= (internal->link != NULL);
|
2008-11-24 12:12:24 +00:00
|
|
|
|
|
|
|
if(skip && iter->valid && skip(iter, internal->link))
|
|
|
|
rna_iterator_listbase_next(iter);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rna_iterator_listbase_next(CollectionPropertyIterator *iter)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
ListBaseIterator *internal= iter->internal;
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(internal->skip) {
|
|
|
|
do {
|
|
|
|
internal->link= internal->link->next;
|
|
|
|
iter->valid= (internal->link != NULL);
|
|
|
|
} while(iter->valid && internal->skip(iter, internal->link));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
internal->link= internal->link->next;
|
|
|
|
iter->valid= (internal->link != NULL);
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *rna_iterator_listbase_get(CollectionPropertyIterator *iter)
|
|
|
|
{
|
2008-11-17 18:44:06 +00:00
|
|
|
ListBaseIterator *internal= iter->internal;
|
|
|
|
|
|
|
|
return internal->link;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rna_iterator_listbase_end(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
MEM_freeN(iter->internal);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, IteratorSkipFunc skip)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
ArrayIterator *internal;
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(ptr == NULL)
|
|
|
|
length= 0;
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
internal= MEM_callocN(sizeof(ArrayIterator), "ArrayIterator");
|
|
|
|
internal->ptr= ptr;
|
2008-11-01 00:23:08 +00:00
|
|
|
internal->endptr= ((char*)ptr)+length*itemsize;
|
2008-11-07 02:58:25 +00:00
|
|
|
internal->itemsize= itemsize;
|
2008-11-24 12:12:24 +00:00
|
|
|
internal->skip= skip;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
iter->internal= internal;
|
|
|
|
iter->valid= (internal->ptr != internal->endptr);
|
2008-11-24 12:12:24 +00:00
|
|
|
|
|
|
|
if(skip && iter->valid && skip(iter, internal->ptr))
|
|
|
|
rna_iterator_array_next(iter);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rna_iterator_array_next(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
ArrayIterator *internal= iter->internal;
|
|
|
|
|
2008-11-24 12:12:24 +00:00
|
|
|
if(internal->skip) {
|
|
|
|
do {
|
|
|
|
internal->ptr += internal->itemsize;
|
|
|
|
iter->valid= (internal->ptr != internal->endptr);
|
|
|
|
} while(iter->valid && internal->skip(iter, internal->ptr));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
internal->ptr += internal->itemsize;
|
|
|
|
iter->valid= (internal->ptr != internal->endptr);
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *rna_iterator_array_get(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
ArrayIterator *internal= iter->internal;
|
|
|
|
|
|
|
|
return internal->ptr;
|
|
|
|
}
|
|
|
|
|
2008-11-26 22:24:26 +00:00
|
|
|
void *rna_iterator_array_dereference_get(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
ArrayIterator *internal= iter->internal;
|
|
|
|
|
|
|
|
/* for ** arrays */
|
|
|
|
return *(void**)(internal->ptr);
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
void rna_iterator_array_end(CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
MEM_freeN(iter->internal);
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
/* RNA Path - Experiment */
|
|
|
|
|
|
|
|
static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int bracket)
|
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
char *buf;
|
|
|
|
int i, j, len, escape;
|
|
|
|
|
|
|
|
len= 0;
|
|
|
|
|
|
|
|
if(bracket) {
|
|
|
|
/* get data between [], check escaping ] with \] */
|
|
|
|
if(**path == '[') (*path)++;
|
|
|
|
else return NULL;
|
|
|
|
|
|
|
|
p= *path;
|
|
|
|
|
|
|
|
escape= 0;
|
|
|
|
while(*p && (*p != ']' || escape)) {
|
|
|
|
escape= (*p == '\\');
|
|
|
|
len++;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*p != ']') return NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* get data until . or [ */
|
|
|
|
p= *path;
|
|
|
|
|
|
|
|
while(*p && *p != '.' && *p != '[') {
|
|
|
|
len++;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* empty, return */
|
|
|
|
if(len == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* try to use fixed buffer if possible */
|
|
|
|
if(len+1 < fixedlen)
|
|
|
|
buf= fixedbuf;
|
|
|
|
else
|
|
|
|
buf= MEM_callocN(sizeof(char)*(len+1), "rna_path_token");
|
|
|
|
|
|
|
|
/* copy string, taking into account escaped ] */
|
|
|
|
for(p=*path, i=0, j=0; i<len; i++, p++) {
|
|
|
|
if(*p == '\\' && *(p+1) == ']');
|
|
|
|
else buf[j++]= *p;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[j]= 0;
|
|
|
|
|
|
|
|
/* set path to start of next token */
|
|
|
|
if(*p == ']') p++;
|
|
|
|
if(*p == '.') p++;
|
|
|
|
*path= p;
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
|
|
|
|
{
|
2008-11-14 14:34:19 +00:00
|
|
|
CollectionPropertyIterator iter;
|
|
|
|
PropertyRNA *prop, *iterprop;
|
2008-11-07 02:58:25 +00:00
|
|
|
PointerRNA curptr, nextptr;
|
|
|
|
char fixedbuf[256], *token;
|
|
|
|
int len, intkey;
|
|
|
|
|
|
|
|
prop= NULL;
|
|
|
|
curptr= *ptr;
|
|
|
|
|
|
|
|
while(*path) {
|
|
|
|
/* look up property name in current struct */
|
|
|
|
token= rna_path_token(&path, fixedbuf, sizeof(fixedbuf), 0);
|
|
|
|
|
|
|
|
if(!token)
|
|
|
|
return 0;
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
iterprop= RNA_struct_iterator_property(&curptr);
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_begin(&curptr, iterprop, &iter);
|
2008-11-14 14:34:19 +00:00
|
|
|
prop= NULL;
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
for(; iter.valid; RNA_property_collection_next(&iter)) {
|
|
|
|
if(strcmp(token, RNA_property_identifier(&iter.ptr, iter.ptr.data)) == 0) {
|
2008-11-14 17:05:25 +00:00
|
|
|
prop= iter.ptr.data;
|
2008-11-07 02:58:25 +00:00
|
|
|
break;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_end(&iter);
|
2008-11-07 02:58:25 +00:00
|
|
|
|
|
|
|
if(token != fixedbuf)
|
|
|
|
MEM_freeN(token);
|
|
|
|
|
|
|
|
if(!prop)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* now look up the value of this property if it is a pointer or
|
|
|
|
* collection, otherwise return the property rna so that the
|
|
|
|
* caller can read the value of the property itself */
|
2008-11-24 15:51:55 +00:00
|
|
|
if(RNA_property_type(&curptr, prop) == PROP_POINTER) {
|
|
|
|
RNA_property_pointer_get(&curptr, prop, &nextptr);
|
2008-11-07 02:58:25 +00:00
|
|
|
|
|
|
|
if(nextptr.data)
|
|
|
|
curptr= nextptr;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2008-11-24 15:51:55 +00:00
|
|
|
else if(RNA_property_type(&curptr, prop) == PROP_COLLECTION && *path) {
|
2008-11-07 02:58:25 +00:00
|
|
|
/* resolve the lookup with [] brackets */
|
|
|
|
token= rna_path_token(&path, fixedbuf, sizeof(fixedbuf), 1);
|
|
|
|
|
|
|
|
if(!token)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
len= strlen(token);
|
|
|
|
|
|
|
|
/* check for "" to see if it is a string */
|
|
|
|
if(len >= 2 && *token == '"' && token[len-2] == '"') {
|
|
|
|
/* strip away "" */
|
|
|
|
token[len-2]= 0;
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_lookup_string(&curptr, prop, token+1, &nextptr);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* otherwise do int lookup */
|
|
|
|
intkey= atoi(token);
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(token != fixedbuf)
|
|
|
|
MEM_freeN(token);
|
|
|
|
|
|
|
|
if(nextptr.data)
|
|
|
|
curptr= nextptr;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*r_ptr= curptr;
|
|
|
|
*r_prop= prop;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:44:06 +00:00
|
|
|
char *RNA_path_append(const char *path, PointerRNA *ptr, PropertyRNA *prop, int intkey, const char *strkey)
|
2008-11-07 02:58:25 +00:00
|
|
|
{
|
|
|
|
DynStr *dynstr;
|
|
|
|
const char *s;
|
|
|
|
char appendstr[128], *result;
|
|
|
|
|
|
|
|
dynstr= BLI_dynstr_new();
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
/* add .identifier */
|
2008-11-07 02:58:25 +00:00
|
|
|
if(path) {
|
|
|
|
BLI_dynstr_append(dynstr, (char*)path);
|
|
|
|
if(*path)
|
|
|
|
BLI_dynstr_append(dynstr, ".");
|
|
|
|
}
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
BLI_dynstr_append(dynstr, (char*)RNA_property_identifier(ptr, prop));
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
if(RNA_property_type(ptr, prop) == PROP_COLLECTION) {
|
2008-11-07 02:58:25 +00:00
|
|
|
/* add ["strkey"] or [intkey] */
|
|
|
|
BLI_dynstr_append(dynstr, "[");
|
|
|
|
|
|
|
|
if(strkey) {
|
|
|
|
BLI_dynstr_append(dynstr, "\"");
|
|
|
|
for(s=strkey; *s; s++) {
|
|
|
|
if(*s == '[') {
|
|
|
|
appendstr[0]= '\\';
|
|
|
|
appendstr[1]= *s;
|
|
|
|
appendstr[2]= 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
appendstr[0]= *s;
|
|
|
|
appendstr[1]= 0;
|
|
|
|
}
|
|
|
|
BLI_dynstr_append(dynstr, appendstr);
|
|
|
|
}
|
|
|
|
BLI_dynstr_append(dynstr, "\"");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(appendstr, "%d", intkey);
|
|
|
|
BLI_dynstr_append(dynstr, appendstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_dynstr_append(dynstr, "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
result= BLI_dynstr_get_cstring(dynstr);
|
|
|
|
BLI_dynstr_free(dynstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *RNA_path_back(const char *path)
|
|
|
|
{
|
|
|
|
char fixedbuf[256];
|
|
|
|
const char *previous, *current;
|
|
|
|
char *result, *token;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(!path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
previous= NULL;
|
|
|
|
current= path;
|
|
|
|
|
|
|
|
/* parse token by token until the end, then we back up to the previous
|
|
|
|
* position and strip of the next token to get the path one step back */
|
|
|
|
while(*current) {
|
|
|
|
token= rna_path_token(¤t, fixedbuf, sizeof(fixedbuf), 0);
|
|
|
|
|
|
|
|
if(!token)
|
|
|
|
return NULL;
|
|
|
|
if(token != fixedbuf)
|
|
|
|
MEM_freeN(token);
|
|
|
|
|
|
|
|
/* in case of collection we also need to strip off [] */
|
|
|
|
token= rna_path_token(¤t, fixedbuf, sizeof(fixedbuf), 1);
|
|
|
|
if(token && token != fixedbuf)
|
|
|
|
MEM_freeN(token);
|
|
|
|
|
|
|
|
if(!*current)
|
|
|
|
break;
|
|
|
|
|
|
|
|
previous= current;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!previous)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* copy and strip off last token */
|
|
|
|
i= previous - path;
|
|
|
|
result= BLI_strdup(path);
|
|
|
|
|
|
|
|
if(i > 0 && result[i-1] == '.') i--;
|
|
|
|
result[i]= 0;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* Quick name based property access */
|
|
|
|
|
|
|
|
int RNA_boolean_get(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
return RNA_property_boolean_get(ptr, 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
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_boolean_get: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_boolean_set(PointerRNA *ptr, const char *name, int value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_boolean_set(ptr, prop, value);
|
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
|
|
|
|
printf("RNA_boolean_set: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_boolean_get_array(PointerRNA *ptr, const char *name, int *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
int i, length;
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
length= RNA_property_array_length(ptr, 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
|
|
|
for(i=0; i<length; i++)
|
2008-11-24 15:51:55 +00:00
|
|
|
values[i]= RNA_property_boolean_get_array(ptr, prop, i);
|
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
|
|
|
|
printf("RNA_boolean_get_array: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_boolean_set_array(PointerRNA *ptr, const char *name, const int *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
int i, length;
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
length= RNA_property_array_length(ptr, 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
|
|
|
for(i=0; i<length; i++)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_boolean_set_array(ptr, prop, i, values[i]);
|
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
|
|
|
|
printf("RNA_boolean_set_array: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
int RNA_int_get(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
return RNA_property_int_get(ptr, 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
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_int_get: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_int_set(ptr, prop, value);
|
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
|
|
|
|
printf("RNA_int_set: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
int i, length;
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
length= RNA_property_array_length(ptr, 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
|
|
|
for(i=0; i<length; i++)
|
2008-11-24 15:51:55 +00:00
|
|
|
values[i]= RNA_property_int_get_array(ptr, prop, i);
|
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
|
|
|
|
printf("RNA_int_get_array: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
int i, length;
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
length= RNA_property_array_length(ptr, 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
|
|
|
for(i=0; i<length; i++)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_int_set_array(ptr, prop, i, values[i]);
|
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
|
|
|
|
printf("RNA_int_set_array: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
float RNA_float_get(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
return RNA_property_float_get(ptr, 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
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_float_get: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_float_set(ptr, prop, value);
|
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
|
|
|
|
printf("RNA_float_set: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
int i, length;
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
length= RNA_property_array_length(ptr, 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
|
|
|
for(i=0; i<length; i++)
|
2008-11-24 15:51:55 +00:00
|
|
|
values[i]= RNA_property_float_get_array(ptr, prop, i);
|
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
|
|
|
|
printf("RNA_float_get_array: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
int i, length;
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
length= RNA_property_array_length(ptr, 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
|
|
|
for(i=0; i<length; i++)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_float_set_array(ptr, prop, i, values[i]);
|
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
|
|
|
|
printf("RNA_float_set_array: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
int RNA_enum_get(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
return RNA_property_enum_get(ptr, 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
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_enum_get: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_enum_set(ptr, prop, value);
|
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
|
|
|
|
printf("RNA_enum_set: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
2008-12-24 10:50:39 +00:00
|
|
|
int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
const EnumPropertyItem *item;
|
|
|
|
int a, totitem;
|
|
|
|
|
|
|
|
if(prop) {
|
|
|
|
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
|
|
|
|
|
|
|
for(a=0; a<totitem; a++)
|
2008-12-24 18:06:51 +00:00
|
|
|
if(strcmp(item[a].identifier, enumname) == 0)
|
|
|
|
return (item[a].value == RNA_property_enum_get(ptr, prop));
|
2008-12-24 10:50:39 +00:00
|
|
|
|
|
|
|
printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_enum_is_equal: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 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
|
|
|
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_string_get(ptr, prop, value);
|
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
|
|
|
|
printf("RNA_string_get: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen);
|
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 {
|
|
|
|
printf("RNA_string_get_alloc: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int RNA_string_length(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
2008-11-24 15:51:55 +00:00
|
|
|
return RNA_property_string_length(ptr, 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
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_string_length: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_property_string_set(ptr, prop, value);
|
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
|
|
|
|
printf("RNA_string_set: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
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_pointer_get(PointerRNA *ptr, const char *name, PointerRNA *r_value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
|
|
|
RNA_property_pointer_get(ptr, prop, r_value);
|
|
|
|
else
|
|
|
|
printf("RNA_pointer_get: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_pointer_add(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
|
|
|
RNA_property_pointer_add(ptr, prop);
|
|
|
|
else
|
|
|
|
printf("RNA_pointer_set: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_collection_begin(PointerRNA *ptr, const char *name, CollectionPropertyIterator *iter)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
|
|
|
RNA_property_collection_begin(ptr, prop, iter);
|
|
|
|
else
|
|
|
|
printf("RNA_collection_begin: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
|
|
|
RNA_property_collection_add(ptr, prop, r_value);
|
|
|
|
else
|
|
|
|
printf("RNA_collection_add: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RNA_collection_clear(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop)
|
|
|
|
RNA_property_collection_clear(ptr, prop);
|
|
|
|
else
|
|
|
|
printf("RNA_collection_clear: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
int RNA_collection_length(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
|
|
|
return RNA_property_collection_length(ptr, prop);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_collection_length: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 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
|
|
|
int RNA_property_is_set(PointerRNA *ptr, const char *name)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
|
|
|
|
|
|
|
if(prop) {
|
|
|
|
return (rna_idproperty_find(ptr, name) != NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RNA_property_is_set: %s.%s not found.\n", ptr->type->identifier, name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* string representation of a property, python
|
|
|
|
* compatible but can be used for display too*/
|
2008-12-26 03:56:52 +00:00
|
|
|
char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
int type = RNA_property_type(ptr, prop);
|
|
|
|
int len = RNA_property_array_length(ptr, prop);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
DynStr *dynstr= BLI_dynstr_new();
|
|
|
|
char *cstring;
|
|
|
|
|
|
|
|
|
|
|
|
/* see if we can coorce into a python type - PropertyType */
|
|
|
|
switch (type) {
|
|
|
|
case PROP_BOOLEAN:
|
|
|
|
if (len==0) {
|
|
|
|
BLI_dynstr_append(dynstr, RNA_property_boolean_get(ptr, prop) ? "True" : "False");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_dynstr_append(dynstr, "(");
|
|
|
|
for(i=0; i<len; i++) {
|
|
|
|
BLI_dynstr_appendf(dynstr, i?"%s, ":"%s", RNA_property_boolean_get_array(ptr, prop, i) ? "True" : "False");
|
|
|
|
}
|
|
|
|
BLI_dynstr_append(dynstr, ")");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROP_INT:
|
|
|
|
if (len==0) {
|
|
|
|
BLI_dynstr_appendf(dynstr, "%d", RNA_property_int_get(ptr, prop));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_dynstr_append(dynstr, "(");
|
|
|
|
for(i=0; i<len; i++) {
|
|
|
|
BLI_dynstr_appendf(dynstr, i?"%d, ":"%d", RNA_property_int_get_array(ptr, prop, i));
|
|
|
|
}
|
|
|
|
BLI_dynstr_append(dynstr, ")");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROP_FLOAT:
|
|
|
|
if (len==0) {
|
2008-12-27 16:35:15 +00:00
|
|
|
BLI_dynstr_appendf(dynstr, "%f", RNA_property_float_get(ptr, prop));
|
2008-12-26 03:56:52 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_dynstr_append(dynstr, "(");
|
|
|
|
for(i=0; i<len; i++) {
|
|
|
|
BLI_dynstr_appendf(dynstr, i?"%f, ":"%f", RNA_property_float_get_array(ptr, prop, i));
|
|
|
|
}
|
|
|
|
BLI_dynstr_append(dynstr, ")");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROP_STRING:
|
|
|
|
{
|
|
|
|
/* string arrays dont exist */
|
|
|
|
char *buf;
|
|
|
|
buf = RNA_property_string_get_alloc(ptr, prop, NULL, -1);
|
|
|
|
BLI_dynstr_appendf(dynstr, "\"%s\"", buf);
|
|
|
|
MEM_freeN(buf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
|
|
|
/* string arrays dont exist */
|
|
|
|
const char *identifier;
|
|
|
|
int val = RNA_property_enum_get(ptr, prop);
|
|
|
|
|
|
|
|
if (RNA_property_enum_identifier(ptr, prop, val, &identifier)) {
|
|
|
|
BLI_dynstr_appendf(dynstr, "'%s'", identifier);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_dynstr_appendf(dynstr, "'<UNKNOWN ENUM>'", identifier);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
|
|
|
BLI_dynstr_append(dynstr, "'<POINTER>'"); /* TODO */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
BLI_dynstr_append(dynstr, "'<COLLECTION>'"); /* TODO */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_dynstr_append(dynstr, "'<UNKNOWN TYPE>'"); /* TODO */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cstring = BLI_dynstr_get_cstring(dynstr);
|
|
|
|
BLI_dynstr_free(dynstr);
|
|
|
|
return cstring;
|
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
|
|
|
}
|
2008-12-31 13:16:37 +00:00
|
|
|
|