diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-07 05:58:25 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-07 05:58:25 +0300 |
commit | 7e8ba5c84d4d35fe6ee4e3d73d08265ae931e2d3 (patch) | |
tree | c7f1e0e2a0297460e6bdcc1d70f6a45fc8ebdd1e /source/blender/makesrna/intern/rna_ID.c | |
parent | 21a0e55c501d9bb02d98ef4987eb83371d1f0ecf (diff) |
RNA
* Added more error prints for wrong definitions, for cases that
would laters cause problems compiling or crash at runtime, and
also made messages more clear.
* Added some skeleton code for main/ID/mesh/vertex types for testing.
* Added support for automatic arrays as collections using SDNA.
* Changed how pointers to data work. Now they are always wrapped
in a PointerRNA struct, which contains the data pointer and type,
and also the data pointer and type of the ID datablock that this
belongs to, since for example a vertex on it's own may not have
enough information for some operations, it also needs the mesh.
* Added some code for defining dependencies with RNA, and looking up
data with paths like: scenes[0].objects["Cube"].data.verts[7].co.
Note sure either will end up being used, this is experimental.
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNA
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c new file mode 100644 index 00000000000..7688042525a --- /dev/null +++ b/source/blender/makesrna/intern/rna_ID.c @@ -0,0 +1,69 @@ +/** + * $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 "RNA_define.h" +#include "RNA_types.h" + +#include "DNA_ID.h" + +#ifdef RNA_RUNTIME + +/* name functions that ignore the first two ID characters */ +static void rna_ID_name_get(PointerRNA *ptr, char *value) +{ + ID *id= (ID*)ptr->data; + BLI_strncpy(value, id->name+2, sizeof(id->name)-2); +} + +static int rna_ID_name_length(PointerRNA *ptr) +{ + ID *id= (ID*)ptr->data; + return strlen(id->name+2); +} + +static void rna_ID_name_set(PointerRNA *ptr, const char *value) +{ + ID *id= (ID*)ptr->data; + BLI_strncpy(id->name+2, value, sizeof(id->name)-2); +} + +#else + +void RNA_def_ID(StructRNA *srna) +{ + PropertyRNA *prop; + + RNA_def_struct_flag(srna, STRUCT_ID); + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, "ID", "name"); + RNA_def_property_ui_text(prop, "Name", "Object ID name."); + RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set"); + RNA_def_struct_name_property(srna, prop); +} + +#endif + |