Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-08 20:40:46 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-08 20:40:46 +0400
commit9b3b52dfd6229d5456d818e2b919acae9d6ab47b (patch)
tree32d2c028986cb56b921da16b5fffbd20ae56a49f /source
parent4b2072bec302c9e0b38337eebd0ba9ad9933841a (diff)
RNA:
* Added the build system code to compile files named editors/*/*_api.c into the makesrna preprocessing. The reason to do this is to keep operators and API close together, but it doesn't fit well with the build system, especially Makefiles use an ugly hack here. * Some fixes to pass an RNA AnyType through the API, this will give a PointerRNA, for use in the interface code for example. * Added RNA wrapping of some UI template code as a test.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/SConscript3
-rw-r--r--source/blender/editors/interface/interface_api.c67
-rw-r--r--source/blender/makesrna/SConscript2
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt6
-rw-r--r--source/blender/makesrna/intern/Makefile23
-rw-r--r--source/blender/makesrna/intern/SConscript8
-rw-r--r--source/blender/makesrna/intern/makesrna.c15
-rw-r--r--source/blender/makesrna/intern/rna_internal.h7
-rw-r--r--source/blender/makesrna/intern/rna_screen.c4
-rw-r--r--source/blender/makesrna/intern/rna_ui.c55
10 files changed, 177 insertions, 13 deletions
diff --git a/source/blender/editors/interface/SConscript b/source/blender/editors/interface/SConscript
index 38cb876beb7..fa89cd4891c 100644
--- a/source/blender/editors/interface/SConscript
+++ b/source/blender/editors/interface/SConscript
@@ -3,6 +3,9 @@ Import ('env')
sources = env.Glob('*.c')
+for source in env.Glob('*_api.c'):
+ sources.remove(source)
+
incs = '../include ../../blenlib ../../blenfont ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../makesrna ../../windowmanager #/intern/guardedalloc #intern/bmfont'
incs += ' #/extern/glew/include'
diff --git a/source/blender/editors/interface/interface_api.c b/source/blender/editors/interface/interface_api.c
new file mode 100644
index 00000000000..98a4384f333
--- /dev/null
+++ b/source/blender/editors/interface/interface_api.c
@@ -0,0 +1,67 @@
+/**
+ * $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.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+void RNA_api_ui_layout(StructRNA *srna)
+{
+ FunctionRNA *func;
+
+ /* templates */
+ func= RNA_def_function(srna, "template_column", "uiTemplateColumn");
+ func= RNA_def_function(srna, "template_left_right", "uiTemplateLeftRight");
+ func= RNA_def_function(srna, "template_stack", "uiTemplateStack");
+
+ func= RNA_def_function(srna, "template_header_menus", "uiTemplateHeaderMenus");
+ func= RNA_def_function(srna, "template_header_buttons", "uiTemplateHeaderButtons");
+ //func= RNA_def_function(srna, "template_header_ID", "uiTemplateHeaderID");
+
+ /* items */
+ func= RNA_def_function(srna, "itemR", "uiItemR");
+ RNA_def_int(func, "slot", 0, 0, 5, "", "", 0, 5);
+ RNA_def_string(func, "name", "", 0, "", "");
+ RNA_def_int(func, "icon", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+ RNA_def_pointer(func, "data", "AnyType", "", "");
+ RNA_def_string(func, "property", "", 0, "", "");
+
+ func= RNA_def_function(srna, "itemO", "uiItemO");
+ RNA_def_int(func, "slot", 0, 0, 5, "", "", 0, 5);
+ RNA_def_string(func, "name", "", 0, "", "");
+ RNA_def_int(func, "icon", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+ RNA_def_string(func, "operator", "", 0, "", "");
+
+ func= RNA_def_function(srna, "itemL", "uiItemLabel");
+ RNA_def_int(func, "slot", 0, 0, 5, "", "", 0, 5);
+ RNA_def_string(func, "name", "", 0, "", "");
+ RNA_def_int(func, "icon", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+}
+
diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript
index 94ea9ad764a..7bf968a0979 100644
--- a/source/blender/makesrna/SConscript
+++ b/source/blender/makesrna/SConscript
@@ -7,6 +7,6 @@ o = SConscript('intern/SConscript')
objs += o
incs = '#/intern/guardedalloc ../blenkernel ../blenlib ../makesdna intern .'
-incs += ' ../windowmanager ../editors'
+incs += ' ../windowmanager ../editors/include'
env.BlenderLib ( 'bf_rna', objs, Split(incs), [], libtype=['core'], priority = [195] )
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index ecdc2ca865c..0971727cbf6 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -26,17 +26,19 @@
FILE(GLOB DEFSRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
LIST(REMOVE_ITEM DEFSRC rna_access.c rna_define.c makesrna.c)
-
+FILE(GLOB_RECURSE APISRC "../../editors/*/*_api.c")
+
STRING(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
SET(SRC
makesrna.c
rna_define.c
${DEFSRC}
+ ${APISRC}
../../../../intern/guardedalloc/intern/mallocn.c
../../../../intern/guardedalloc/intern/mmap_win.c)
-INCLUDE_DIRECTORIES(../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../windowmanager ../../editors .)
+INCLUDE_DIRECTORIES(../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../windowmanager ../../editors/include .)
FILE(GLOB INC_FILES ../*.h ../../makesdna/*.h)
# Build makesrna executable
diff --git a/source/blender/makesrna/intern/Makefile b/source/blender/makesrna/intern/Makefile
index 070f6f264bd..f64c11ac718 100644
--- a/source/blender/makesrna/intern/Makefile
+++ b/source/blender/makesrna/intern/Makefile
@@ -31,8 +31,8 @@ DEFRNA = $(filter-out %rna_define.c, $(filter-out %rna_access.c, $(ALLRNA)))
GENSRCS = $(patsubst rna_%.c, rna_%_gen.c, $(DEFRNA))
GENTARGET = $(patsubst %.c, $(DIR)/$(DEBUG_DIR)%.c, $(GENSRCS))
-MAKESRCS = $(DEFRNA) makesrna.c rna_define.c
-MAKEOBJS = $(patsubst %.c, $(DIR)/$(DEBUG_DIR)%.o, $(MAKESRCS))
+MAKESRCS = $(DEFRNA) makesrna.c rna_define.c $(wildcard ../../editors/*/*_api.c)
+MAKEOBJS = $(patsubst %.c, $(DIR)/$(DEBUG_DIR)%.o, $(notdir $(MAKESRCS)))
CSRCS = $(GENSRCS) rna_access.c
@@ -49,6 +49,7 @@ CPPFLAGS += -I../../blenlib
CPPFLAGS += -I../../blenkernel
CPPFLAGS += -I../../makesdna
CPPFLAGS += -I../../windowmanager
+CPPFLAGS += -I../../editors/include
CPPFLAGS += -I..
CPPFLAGS += -I.
@@ -72,6 +73,24 @@ clean::
# TODO include right .mk for ldflags
+# XXX this is an ugly hack, copying code from nan_compile.mk
+# we want the .o's to be in the makesrna/ directory, but the
+# .c's are in the editors/*/ directories
+
+$(DIR)/$(DEBUG_DIR)%_api.o: ../../editors/*/%_api.c
+ ifdef NAN_DEPEND
+ @set -e; $(CC) -M $(CPPFLAGS) $< 2>/dev/null \
+ | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \
+ > $(DIR)/$(DEBUG_DIR)$*.d; \
+ [ -s $(DIR)/$(DEBUG_DIR)$*.d ] || $(RM) $(DIR)/$*.d
+ endif
+ ifdef NAN_QUIET
+ @echo " -- $< -- "
+ @$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+ else
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@)
+ endif
+
# A small note: we do not use the debug version of the alloc lib. That
# is done quite intentionally. If there is a bug in that lib, it needs
# to be fixed by the module maintainer.
diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript
index 46f748f7c7c..a8cc452d350 100644
--- a/source/blender/makesrna/intern/SConscript
+++ b/source/blender/makesrna/intern/SConscript
@@ -11,17 +11,15 @@ defines = []
root_build_dir=normpath(env['BF_BUILDDIR'])
source_files = env.Glob('*.c')
-
-# making rna_access.c part of both makesrna and blender seems to
-# give conflict, how to solve?
source_files.remove('rna_access.c')
generated_files = source_files[:]
generated_files.remove('rna_define.c')
generated_files.remove('makesrna.c')
-
generated_files = [filename[:-2] + '_gen.c' for filename in generated_files]
+source_files.extend(env.Glob('../../editors/*/*_api.c'))
+
makesrna_tool = env.Clone()
rna = env.Clone()
makesrna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesrna/\\"" ')
@@ -32,7 +30,7 @@ makesrna_tool.Append (CPPPATH = ['#/intern/guardedalloc',
'../../makesdna',
'../../makesrna',
'../../windowmanager',
- '../../editors'])
+ '../../editors/include'])
if env['OURPLATFORM'] == 'linuxcross':
USE_WINE = True # when cross compiling on linux 64bit this is useful
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index a9f08f8f82a..5eceb62f897 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1116,12 +1116,20 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
dparm= dfunc->cont.properties.first;
for(; dparm; dparm= dparm->next) {
- ptrstr= (dparm->prop->type == PROP_POINTER || dparm->prop->arraylength > 0)? "*" : "";
-
if(dparm->prop==func->ret)
fprintf(f, "\t_retdata= _data;\n");
+ else if(dparm->prop->arraylength)
+ fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
+ else if(dparm->prop->type == PROP_POINTER) {
+ PointerPropertyRNA *pprop= (PointerPropertyRNA*)dparm->prop;
+
+ if(strcmp((char*)pprop->type, "AnyType") == 0)
+ fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
+ else
+ fprintf(f, "\t%s= *((%s%s**)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
+ }
else
- fprintf(f, "\t%s= *((%s%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr);
+ fprintf(f, "\t%s= *((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
if(dparm->next)
fprintf(f, "\t_data+= %d;\n", rna_parameter_size(dparm->prop));
@@ -1694,6 +1702,7 @@ RNAProcessItem PROCESS_ITEMS[]= {
{"rna_text.c", RNA_def_text},
{"rna_timeline.c", RNA_def_timeline_marker},
{"rna_sound.c", RNA_def_sound},
+ {"rna_ui.c", RNA_def_ui},
{"rna_userdef.c", RNA_def_userdef},
{"rna_vfont.c", RNA_def_vfont},
{"rna_vpaint.c", RNA_def_vpaint},
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 572c8b2ae14..d0aa60dc390 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -153,12 +153,15 @@ void RNA_def_text(struct BlenderRNA *brna);
void RNA_def_texture(struct BlenderRNA *brna);
void RNA_def_timeline_marker(struct BlenderRNA *brna);
void RNA_def_sound(struct BlenderRNA *brna);
+void RNA_def_ui(struct BlenderRNA *brna);
void RNA_def_userdef(struct BlenderRNA *brna);
void RNA_def_vfont(struct BlenderRNA *brna);
void RNA_def_vpaint(struct BlenderRNA *brna);
void RNA_def_wm(struct BlenderRNA *brna);
void RNA_def_world(struct BlenderRNA *brna);
+/* Common Define functions */
+
void rna_def_animdata_common(struct StructRNA *srna);
void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable);
@@ -177,6 +180,10 @@ void rna_object_vgroup_name_set(struct PointerRNA *ptr, const char *value, char
void rna_object_uvlayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
+/* API functions */
+
+void RNA_api_ui_layout(struct StructRNA *srna);
+
/* ID Properties */
extern StringPropertyRNA rna_IDProperty_string;
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 00cf29bfc51..a976cd54abc 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -72,10 +72,14 @@ static void rna_def_scrarea(BlenderRNA *brna)
static void rna_def_panel(BlenderRNA *brna)
{
StructRNA *srna;
+ PropertyRNA *prop;
srna= RNA_def_struct(brna, "Panel", NULL);
RNA_def_struct_ui_text(srna, "Panel", "Buttons panel.");
RNA_def_struct_sdna(srna, "Panel");
+
+ prop= RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "UILayout");
}
static void rna_def_region(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
new file mode 100644
index 00000000000..8a93fb4a49d
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -0,0 +1,55 @@
+/**
+ * $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 (2009)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#include "rna_internal.h"
+
+#ifdef RNA_RUNTIME
+
+#include "UI_interface.h"
+
+#else
+
+static void rna_def_ui_layout(BlenderRNA *brna)
+{
+ StructRNA *srna;
+
+ srna= RNA_def_struct(brna, "UILayout", NULL);
+ RNA_def_struct_sdna(srna, "uiLayout");
+ RNA_def_struct_ui_text(srna, "UI Layout", "User interface layout in a panel or header.");
+
+ RNA_api_ui_layout(srna);
+}
+
+void RNA_def_ui(BlenderRNA *brna)
+{
+ rna_def_ui_layout(brna);
+}
+
+#endif
+