[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26188] trunk/blender/source/blender/ makesrna: RNA: added option to pass self ID to RNA functions.

Brecht Van Lommel brecht at blender.org
Fri Jan 22 11:58:02 CET 2010


Revision: 26188
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26188
Author:   blendix
Date:     2010-01-22 11:58:02 +0100 (Fri, 22 Jan 2010)

Log Message:
-----------
RNA: added option to pass self ID to RNA functions.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/RNA_types.h
    trunk/blender/source/blender/makesrna/intern/makesrna.c

Modified: trunk/blender/source/blender/makesrna/RNA_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_types.h	2010-01-22 10:56:50 UTC (rev 26187)
+++ trunk/blender/source/blender/makesrna/RNA_types.h	2010-01-22 10:58:02 UTC (rev 26188)
@@ -266,6 +266,7 @@
 	FUNC_NO_SELF = 1, /* for static functions */
 	FUNC_USE_CONTEXT = 2,
 	FUNC_USE_REPORTS = 4,
+	FUNC_USE_SELF_ID = 2048,
 
 	/* registering */
 	FUNC_REGISTER = 8,

Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c	2010-01-22 10:56:50 UTC (rev 26187)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c	2010-01-22 10:58:02 UTC (rev 26188)
@@ -1293,7 +1293,7 @@
 	srna= dsrna->srna;
 	func= dfunc->func;
 
-	if(func->flag & FUNC_REGISTER)
+	if(!dfunc->call)
 		return;
 
 	funcname= rna_alloc_function_name(srna->identifier, func->identifier, "call");
@@ -1304,6 +1304,9 @@
 
 	/* variable definitions */
 	if((func->flag & FUNC_NO_SELF)==0) {
+		if(func->flag & FUNC_USE_SELF_ID)
+			fprintf(f, "\tstruct ID *_selfid;\n");
+
 		if(dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
 		else fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
 	}
@@ -1332,6 +1335,9 @@
 
 	/* assign self */
 	if((func->flag & FUNC_NO_SELF)==0) {
+		if(func->flag & FUNC_USE_SELF_ID)
+			fprintf(f, "\t_selfid= (struct ID*)_ptr->id.data;\n");
+
 		if(dsrna->dnaname) fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", dsrna->dnaname);
 		else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier);
 	}
@@ -1375,6 +1381,9 @@
 		first= 1;
 
 		if((func->flag & FUNC_NO_SELF)==0) {
+			if(func->flag & FUNC_USE_SELF_ID)
+				fprintf(f, "_selfid, ");
+
 			fprintf(f, "_self");
 			first= 0;
 		}
@@ -1672,6 +1681,9 @@
 
 	/* self, context and reports parameters */
 	if((func->flag & FUNC_NO_SELF)==0) {
+		if(func->flag & FUNC_USE_SELF_ID)
+			fprintf(f, "struct ID *_selfid, ");
+
 		if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
 		else fprintf(f, "struct %s *_self", srna->identifier);
 		first= 0;
@@ -1719,16 +1731,19 @@
 {
 	FunctionRNA *func;
 	FunctionDefRNA *dfunc;
+	int first= 1;
 
-	fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
-
 	for(func= srna->functions.first; func; func= func->cont.next) {
-		if(func->flag & FUNC_REGISTER)
-			continue;
+		dfunc= rna_find_function_def(func);
 
-		dfunc= rna_find_function_def(func);
-		if(dfunc->call)
+		if(dfunc->call) {
+			if(first) {
+				fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
+				first= 0;
+			}
+
 			rna_generate_static_parameter_prototypes(brna, srna, dfunc, f);
+		}
 	}
 
 	fprintf(f, "\n");





More information about the Bf-blender-cvs mailing list