[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52707] trunk/blender: change uiButGetStrInfo() to use a trailing NULL arg rather then passing the number of args as an arg .

Campbell Barton ideasman42 at gmail.com
Sun Dec 2 05:51:20 CET 2012


Revision: 52707
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52707
Author:   campbellbarton
Date:     2012-12-02 04:51:15 +0000 (Sun, 02 Dec 2012)
Log Message:
-----------
change uiButGetStrInfo() to use a trailing NULL arg rather then passing the number of args as an arg.

Modified Paths:
--------------
    trunk/blender/doc/python_api/rst/info_tips_and_tricks.rst
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_handlers.c
    trunk/blender/source/blender/editors/interface/interface_ops.c
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/python/mathutils/mathutils.c
    trunk/blender/source/blender/python/mathutils/mathutils.h

Modified: trunk/blender/doc/python_api/rst/info_tips_and_tricks.rst
===================================================================
--- trunk/blender/doc/python_api/rst/info_tips_and_tricks.rst	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/doc/python_api/rst/info_tips_and_tricks.rst	2012-12-02 04:51:15 UTC (rev 52707)
@@ -218,6 +218,14 @@
 ``code.interact`` can be added at any line in the script and will pause the script an launch an interactive interpreter in the terminal, when you're done you can quit the interpreter and the script will continue execution.
 
 
+If you have **IPython** installed you can use their ``embed()`` function which will implicitly use the current namespace, this has autocomplete and some useful features that the standard python eval-loop doesn't have.
+
+.. code-block:: python
+
+   import IPython
+   IPython.embed()
+
+
 Admittedly this highlights the lack of any python debugging support built into blender, but its still handy to know.
 
 .. note::

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2012-12-02 04:51:15 UTC (rev 52707)
@@ -542,7 +542,7 @@
 /* Note: Expects pointers to uiStringInfo structs as parameters.
  *       Will fill them with translated strings, when possible.
  *       Strings in uiStringInfo must be MEM_freeN'ed by caller. */
-void uiButGetStrInfo(struct bContext *C, uiBut *but, int nbr, ...);
+void uiButGetStrInfo(struct bContext *C, uiBut *but, ...);
 
 /* Edit i18n stuff. */
 /* Name of the main py op from i18n addon. */

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/source/blender/editors/interface/interface.c	2012-12-02 04:51:15 UTC (rev 52707)
@@ -3797,16 +3797,16 @@
 	wm_event_add(win, &event);
 }
 
-void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...)
+void uiButGetStrInfo(bContext *C, uiBut *but, ...)
 {
 	va_list args;
+	uiStringInfo *si;
 
 	EnumPropertyItem *items = NULL, *item = NULL;
 	int totitems, free_items = FALSE;
 
-	va_start(args, nbr);
-	while (nbr--) {
-		uiStringInfo *si = (uiStringInfo *) va_arg(args, void *);
+	va_start(args, but);
+	while ((si = (uiStringInfo *) va_arg(args, void *))) {
 		int type = si->type;
 		char *tmp = NULL;
 

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-12-02 04:51:15 UTC (rev 52707)
@@ -4634,7 +4634,7 @@
 	uiPopupMenu *pup;
 	uiLayout *layout;
 	int length;
-	char *name;
+	const char *name;
 	uiStringInfo label = {BUT_GET_LABEL, NULL};
 
 /*	if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/
@@ -4642,7 +4642,7 @@
 	
 	button_timers_tooltip_remove(C, but);
 
-	uiButGetStrInfo(C, but, 1, &label);
+	uiButGetStrInfo(C, but, &label, NULL);
 	name = label.strinfo;
 
 	pup = uiPupMenuBegin(C, name, ICON_NONE);

Modified: trunk/blender/source/blender/editors/interface/interface_ops.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_ops.c	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/source/blender/editors/interface/interface_ops.c	2012-12-02 04:51:15 UTC (rev 52707)
@@ -960,7 +960,6 @@
 		const char *root = U.i18ndir;
 		const char *uilng = BLF_lang_get();
 
-		const int bufs_nbr = 10;
 		uiStringInfo but_label = {BUT_GET_LABEL, NULL};
 		uiStringInfo rna_label = {BUT_GET_RNA_LABEL, NULL};
 		uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
@@ -990,8 +989,8 @@
 			return OPERATOR_CANCELLED;
 		}
 
-		uiButGetStrInfo(C, but, bufs_nbr, &but_label, &rna_label, &enum_label, &but_tip, &rna_tip, &enum_tip,
-		                &rna_struct, &rna_prop, &rna_enum, &rna_ctxt);
+		uiButGetStrInfo(C, but, &but_label, &rna_label, &enum_label, &but_tip, &rna_tip, &enum_tip,
+		                &rna_struct, &rna_prop, &rna_enum, &rna_ctxt, NULL);
 
 		WM_operator_properties_create(&ptr, EDTSRC_I18N_OP_NAME);
 		RNA_string_set(&ptr, "lang", uilng);

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2012-12-02 04:51:15 UTC (rev 52707)
@@ -426,7 +426,6 @@
 	rctf rect_fl;
 	rcti rect_i;
 
-	const int nbr_info = 6;
 	uiStringInfo but_tip = {BUT_GET_TIP, NULL};
 	uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
 	uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
@@ -440,7 +439,7 @@
 	/* create tooltip data */
 	data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
 
-	uiButGetStrInfo(C, but, nbr_info, &but_tip, &enum_label, &enum_tip, &op_keymap, &rna_struct, &rna_prop);
+	uiButGetStrInfo(C, but, &but_tip, &enum_label, &enum_tip, &op_keymap, &rna_struct, &rna_prop, NULL);
 
 	/* special case, enum rna buttons only have enum item description,
 	 * use general enum description too before the specific one */
@@ -616,13 +615,16 @@
 	}
 #else
 	if ((U.flag & USER_TOOLTIPS_PYTHON) == 0 && !but->optype && rna_struct.strinfo) {
-		if (rna_prop.strinfo)
+		if (rna_prop.strinfo) {
 			/* Struct and prop */
 			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
 			             TIP_("Python: %s.%s"), rna_struct.strinfo, rna_prop.strinfo);
-		else
+		}
+		else {
 			/* Only struct (e.g. menus) */
-			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), rna_struct.strinfo);
+			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
+			             TIP_("Python: %s"), rna_struct.strinfo);
+		}
 		data->color_id[data->totline] = UI_TIP_LC_PYTHON;
 		data->totline++;
 	}

Modified: trunk/blender/source/blender/python/mathutils/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.c	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/source/blender/python/mathutils/mathutils.c	2012-12-02 04:51:15 UTC (rev 52707)
@@ -302,7 +302,7 @@
 
 /*---------------------- EXPP_VectorsAreEqual -------------------------
  * Builds on EXPP_FloatsAreEqual to test vectors */
-int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps)
+int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int floatSteps)
 {
 	int x;
 	for (x = 0; x < size; x++) {

Modified: trunk/blender/source/blender/python/mathutils/mathutils.h
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.h	2012-12-02 01:34:47 UTC (rev 52706)
+++ trunk/blender/source/blender/python/mathutils/mathutils.h	2012-12-02 04:51:15 UTC (rev 52707)
@@ -74,7 +74,7 @@
 PyMODINIT_FUNC PyInit_mathutils(void);
 
 int EXPP_FloatsAreEqual(float A, float B, int floatSteps);
-int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);
+int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int floatSteps);
 
 #define Py_NEW  1
 #define Py_WRAP 2




More information about the Bf-blender-cvs mailing list