[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41549] trunk/blender/source/blender: py operators - don't use the screen as an operators ID anymore, screen' s don' t store operator instances and operator functions have access to the context if they need the current screen .

Campbell Barton ideasman42 at gmail.com
Sat Nov 5 09:40:09 CET 2011


Revision: 41549
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41549
Author:   campbellbarton
Date:     2011-11-05 08:40:07 +0000 (Sat, 05 Nov 2011)
Log Message:
-----------
py operators - don't use the screen as an operators ID anymore, screen's don't store operator instances and operator functions have access to the context if they need the current screen.

also add some more py api file descriptions.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/makesrna/intern/rna_wm.c
    trunk/blender/source/blender/python/generic/bgl.c
    trunk/blender/source/blender/python/generic/bgl.h
    trunk/blender/source/blender/python/generic/blf_py_api.c
    trunk/blender/source/blender/python/generic/bpy_internal_import.c
    trunk/blender/source/blender/python/generic/noise_py_api.c
    trunk/blender/source/blender/python/generic/py_capi_utils.c
    trunk/blender/source/blender/python/intern/bpy_driver.c
    trunk/blender/source/blender/python/intern/bpy_library.c
    trunk/blender/source/blender/python/intern/bpy_util.c

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/editors/interface/interface.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -766,7 +766,7 @@
 {
 	uiBut *but;
 
-	unsigned int meny_key_mask= 0;
+	unsigned int menu_key_mask= 0;
 	unsigned char menu_key;
 	const char *str_pt;
 	int pass;
@@ -788,8 +788,8 @@
 				if(but->str) {
 					for(str_pt= but->str; *str_pt; ) {
 						menu_key= tolower(*str_pt);
-						if((menu_key >= 'a' && menu_key <= 'z') && !(meny_key_mask & 1<<(menu_key-'a'))) {
-							meny_key_mask |= 1<<(menu_key-'a');
+						if((menu_key >= 'a' && menu_key <= 'z') && !(menu_key_mask & 1<<(menu_key-'a'))) {
+							menu_key_mask |= 1<<(menu_key-'a');
 							break;
 						}
 
@@ -816,7 +816,7 @@
 					}
 
 					/* if all keys have been used just exit, unlikely */
-					if(meny_key_mask == (1<<26)-1) {
+					if(menu_key_mask == (1<<26)-1) {
 						return;
 					}
 				}

Modified: trunk/blender/source/blender/makesrna/intern/rna_wm.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_wm.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/makesrna/intern/rna_wm.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -821,7 +821,7 @@
 	void *ret;
 	int result;
 
-	RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+	RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
 	func= &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */
 
 	RNA_parameter_list_create(&list, &opr, func);
@@ -847,7 +847,7 @@
 	void *ret;
 	int result;
 
-	RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+	RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
 	func= &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */
 
 	RNA_parameter_list_create(&list, &opr, func);
@@ -872,7 +872,7 @@
 	void *ret;
 	int result;
 
-	RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+	RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
 	func= &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */
 
 	RNA_parameter_list_create(&list, &opr, func);
@@ -899,7 +899,7 @@
 	void *ret;
 	int result;
 
-	RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+	RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
 	func= &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */
 
 	RNA_parameter_list_create(&list, &opr, func);
@@ -923,7 +923,7 @@
 	ParameterList list;
 	FunctionRNA *func;
 
-	RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+	RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
 	func= &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */
 
 	RNA_parameter_list_create(&list, &opr, func);
@@ -944,7 +944,7 @@
 	void *ret;
 	int result;
 
-	RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+	RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
 	func= &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
 
 	RNA_parameter_list_create(&list, &opr, func);

Modified: trunk/blender/source/blender/python/generic/bgl.c
===================================================================
--- trunk/blender/source/blender/python/generic/bgl.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/generic/bgl.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -1,5 +1,4 @@
-/* 
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -21,20 +20,21 @@
  *
  * This is a new part of Blender.
  *
- * Contributor(s): Willian P. Germano
+ * Contributor(s): Willian P. Germano, Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
 /** \file blender/python/generic/bgl.c
  *  \ingroup pygen
+ *
+ * This file is the 'bgl' module which wraps OpenGL functions and constants,
+ * allowing script writers to make OpenGL calls in their Python scripts.
+ *
+ * \note
+ * This module is very similar to 'PyOpenGL' which could replace 'bgl' one day.
  */
 
-
-/* This file is the 'bgl' module.
- * The BGL submodule "wraps" OpenGL functions and constants,
- * allowing script writers to make OpenGL calls in their Python scripts. */
-
 #include <Python.h>
 
 #include "bgl.h" /*This must come first */

Modified: trunk/blender/source/blender/python/generic/bgl.h
===================================================================
--- trunk/blender/source/blender/python/generic/bgl.h	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/generic/bgl.h	2011-11-05 08:40:07 UTC (rev 41549)
@@ -1,5 +1,4 @@
-/* 
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or

Modified: trunk/blender/source/blender/python/generic/blf_py_api.c
===================================================================
--- trunk/blender/source/blender/python/generic/blf_py_api.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/generic/blf_py_api.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -22,9 +22,10 @@
 
 /** \file blender/python/generic/blf_py_api.c
  *  \ingroup pygen
+ *
+ * This file defines the 'bgl' module, used for drawing text in OpenGL.
  */
 
-
 #include <Python.h>
 #include "blf_py_api.h"
 

Modified: trunk/blender/source/blender/python/generic/bpy_internal_import.c
===================================================================
--- trunk/blender/source/blender/python/generic/bpy_internal_import.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/generic/bpy_internal_import.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -17,14 +17,19 @@
  *
  * This is a new part of Blender.
  *
- * Contributor(s): Willian P. Germano,
- *                 Campbell Barton
+ * Contributor(s): Willian P. Germano, Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
 /** \file blender/python/generic/bpy_internal_import.c
  *  \ingroup pygen
+ *
+ * This file defines replacements for pythons '__import__' and 'imp.reload'
+ * functions which can import from blender textblocks.
+ *
+ * \note
+ * This should eventually be replaced by import hooks (pep 302).
  */
 
 

Modified: trunk/blender/source/blender/python/generic/noise_py_api.c
===================================================================
--- trunk/blender/source/blender/python/generic/noise_py_api.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/generic/noise_py_api.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -1,8 +1,4 @@
 /*
- *
- * Blender.Noise BPython module implementation.
- * This submodule has functions to generate noise of various types.
- * 
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -24,13 +20,16 @@
  *
  * This is a new part of Blender.
  *
- * Contributor(s): eeshlo
+ * Contributor(s): eeshlo, Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
 /** \file blender/python/generic/noise_py_api.c
  *  \ingroup pygen
+ *
+ * This file defines the 'noise' module, a general purpose module to access
+ * blenders noise functions.
  */
 
 

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -20,6 +20,13 @@
 
 /** \file blender/python/generic/py_capi_utils.c
  *  \ingroup pygen
+ *
+ * Extend upon CPython's API, filling in some gaps, these functions use PyC_
+ * prefix to distinguish them apart from CPython.
+ *
+ * \note
+ * This module should only depend on CPython, however it currently uses
+ * BLI_string_utf8() for unicode conversion.
  */
 
 

Modified: trunk/blender/source/blender/python/intern/bpy_driver.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_driver.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/intern/bpy_driver.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -23,7 +23,7 @@
 /** \file blender/python/intern/bpy_driver.c
  *  \ingroup pythonintern
  *
- * This file defines the 'BPY_driver_exec' to execute python drivers,
+ * This file defines the 'BPY_driver_exec' to execute python driver expressions,
  * called by the animation system, there are also some utility functions
  * to deal with the namespace used for driver execution.
  */

Modified: trunk/blender/source/blender/python/intern/bpy_library.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_library.c	2011-11-05 08:21:12 UTC (rev 41548)
+++ trunk/blender/source/blender/python/intern/bpy_library.c	2011-11-05 08:40:07 UTC (rev 41549)
@@ -27,7 +27,8 @@
  * this would be done via RNA api but in this case a hand written python api
  * allows us to use pythons context manager (__enter__ and __exit__).
  *
- * Everything here is exposed via bpy.data.libraries.load(...) context manager.
+ * Everything here is exposed via bpy.data.libraries.load(...) which returns
+ * a context manager.
  */
 
 /* nifty feature. swap out strings for RNA data */
@@ -77,8 +78,8 @@
 
 static PyMethodDef bpy_lib_methods[]= {
 	{"__enter__", (PyCFunction)bpy_lib_enter, METH_NOARGS},
-	{"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS},
-	{"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS},
+	{"__exit__",  (PyCFunction)bpy_lib_exit,  METH_VARARGS},
+	{"__dir__",   (PyCFunction)bpy_lib_dir,   METH_NOARGS},
 	{NULL}           /* sentinel */
 };
 
@@ -289,7 +290,7 @@
 	PyObject *exc, *val, *tb;
 	PyErr_Fetch(&exc, &val, &tb);
 	if (PyErr_WarnFormat(PyExc_UserWarning, 1,
-						 "load: '%s' does not contain %s[\"%s\"]",
+	                     "load: '%s' does not contain %s[\"%s\"]",
 	                     self->abspath, name_plural, idname)) {
 		/* Spurious errors can appear at shutdown */
 		if (PyErr_ExceptionMatches(PyExc_Warning)) {
@@ -304,7 +305,7 @@
 	PyObject *exc, *val, *tb;
 	PyErr_Fetch(&exc, &val, &tb);
 	if (PyErr_WarnFormat(PyExc_UserWarning, 1,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list