Revision: 19601
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19601
Author:   blendix
Date:     2009-04-08 18:40:46 +0200 (Wed, 08 Apr 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/interface/SConscript
    branches/blender2.5/blender/source/blender/makesrna/SConscript
    branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt
    branches/blender2.5/blender/source/blender/makesrna/intern/Makefile
    branches/blender2.5/blender/source/blender/makesrna/intern/SConscript
    branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_screen.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/interface/interface_api.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui.c

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/SConscript
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/SConscript     
2009-04-08 16:25:00 UTC (rev 19600)
+++ branches/blender2.5/blender/source/blender/editors/interface/SConscript     
2009-04-08 16:40:46 UTC (rev 19601)
@@ -3,6 +3,9 @@
 
 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'

Added: 
branches/blender2.5/blender/source/blender/editors/interface/interface_api.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/interface/interface_api.c    
                            (rev 0)
+++ 
branches/blender2.5/blender/source/blender/editors/interface/interface_api.c    
    2009-04-08 16:40:46 UTC (rev 19601)
@@ -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);
+}
+

Modified: branches/blender2.5/blender/source/blender/makesrna/SConscript
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/SConscript      
2009-04-08 16:25:00 UTC (rev 19600)
+++ branches/blender2.5/blender/source/blender/makesrna/SConscript      
2009-04-08 16:40:46 UTC (rev 19601)
@@ -7,6 +7,6 @@
 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] )

Modified: 
branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt   
2009-04-08 16:25:00 UTC (rev 19600)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt   
2009-04-08 16:40:46 UTC (rev 19601)
@@ -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

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/Makefile
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/Makefile 
2009-04-08 16:25:00 UTC (rev 19600)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/Makefile 
2009-04-08 16:40:46 UTC (rev 19601)
@@ -31,8 +31,8 @@
 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../../blenkernel
 CPPFLAGS += -I../../makesdna
 CPPFLAGS += -I../../windowmanager
+CPPFLAGS += -I../../editors/include
 CPPFLAGS += -I..
 CPPFLAGS += -I.
 
@@ -72,6 +73,24 @@
 
 # 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.

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/SConscript
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/SConscript       
2009-04-08 16:25:00 UTC (rev 19600)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/SConscript       
2009-04-08 16:40:46 UTC (rev 19601)
@@ -11,17 +11,15 @@
 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 @@
                                  '../../makesdna',
                                  '../../makesrna',
                                                                 
'../../windowmanager',
-                                                                
'../../editors'])
+                                                                
'../../editors/include'])
 
 if env['OURPLATFORM'] == 'linuxcross':
        USE_WINE = True # when cross compiling on linux 64bit this is useful

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c       
2009-04-08 16:25:00 UTC (rev 19600)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c       
2009-04-08 16:40:46 UTC (rev 19601)
@@ -1116,12 +1116,20 @@
 
        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 @@
        {"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},

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to