change uiButGetStrInfo() to use a trailing NULL arg rather then passing the number of args as an arg.

This commit is contained in:
Campbell Barton
2012-12-02 04:51:15 +00:00
parent 9865ee7637
commit f7f4148b40
8 changed files with 26 additions and 17 deletions

View File

@@ -218,6 +218,14 @@ The next example is an equivalent single line version of the script above which
``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::

View File

@@ -542,7 +542,7 @@ typedef struct uiStringInfo {
/* 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. */

View File

@@ -3797,16 +3797,16 @@ void uiButSetFocusOnEnter(wmWindow *win, uiBut *but)
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;

View File

@@ -4634,7 +4634,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
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 @@ static int ui_but_menu(bContext *C, uiBut *but)
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);

View File

@@ -960,7 +960,6 @@ static int edittranslation_exec(bContext *C, wmOperator *op)
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 @@ static int edittranslation_exec(bContext *C, wmOperator *op)
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);

View File

@@ -426,7 +426,6 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
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 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* 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 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
#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++;
}

View File

@@ -302,7 +302,7 @@ int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
/*---------------------- 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++) {

View File

@@ -74,7 +74,7 @@ void BaseMathObject_dealloc(BaseMathObject * self);
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