From 9ce8fcd2684c576e92f2a6f127172f332e2c9025 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Thu, 10 May 2012 08:44:08 +0200 Subject: [PATCH] * Read string array results from python methods~ --- pcbnew/pcbnew.cpp | 3 +- pcbnew/scripting/pcbnew_footprint_wizards.cpp | 57 ++++++++++++------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 926b80d100..e20552f91d 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -204,8 +204,9 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); */ frame->SetFocus(); frame->GetCanvas()->SetFocus(); - +#if 0 DIALOG_SCRIPTING* sw = new DIALOG_SCRIPTING(frame); sw->Show(true); +#endif return true; } diff --git a/pcbnew/scripting/pcbnew_footprint_wizards.cpp b/pcbnew/scripting/pcbnew_footprint_wizards.cpp index 7313326a0e..f7142a613b 100644 --- a/pcbnew/scripting/pcbnew_footprint_wizards.cpp +++ b/pcbnew/scripting/pcbnew_footprint_wizards.cpp @@ -59,6 +59,8 @@ PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aAr wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject *aArglist) { wxString ret; + + ret.Clear(); PyObject *result = CallMethod(aMethod,aArglist); if (result) { @@ -66,18 +68,45 @@ wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject ret = wxString::FromUTF8(str_res); Py_DECREF(result); } - else - { - printf("method not found, or not callable: %s\n",aMethod); - } - return ret; } wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod (const char *aMethod, PyObject *aArglist) { + PyObject *result, *element; + wxArrayString ret; + wxString str_item; + + result = CallMethod(aMethod,aArglist); + + if (result) + { + if (!PyList_Check(result)) + { + Py_DECREF(result); + ret.Add(wxT("PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, " + "result is not a list"),1); + return ret; + } + int list_size = PyList_Size(result); + + for (int n=0;n