Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
eff50232
Commit
eff50232
authored
May 10, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Read string array results from python methods~
parent
c051c1a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
21 deletions
+41
-21
pcbnew.cpp
pcbnew/pcbnew.cpp
+2
-1
pcbnew_footprint_wizards.cpp
pcbnew/scripting/pcbnew_footprint_wizards.cpp
+39
-20
No files found.
pcbnew/pcbnew.cpp
View file @
eff50232
...
...
@@ -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
;
}
pcbnew/scripting/pcbnew_footprint_wizards.cpp
View file @
eff50232
...
...
@@ -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,17 +68,44 @@ 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
<
list_size
;
n
++
)
{
element
=
PyList_GetItem
(
result
,
n
);
const
char
*
str_res
=
PyString_AsString
(
element
);
str_item
=
wxString
::
FromUTF8
(
str_res
);
ret
.
Add
(
str_item
,
1
);
}
Py_DECREF
(
result
);
}
return
ret
;
}
...
...
@@ -134,25 +163,15 @@ wxString PYTHON_FOOTPRINT_WIZARD::GetParameterPageName(int aPage)
wxArrayString
PYTHON_FOOTPRINT_WIZARD
::
GetParameterNames
(
int
aPage
)
{
wxArrayString
a
;
wxString
ret
;
PyObject
*
arglist
;
PyObject
*
resul
t
;
wxArrayString
re
t
;
/* Time to call the callback */
arglist
=
Py_BuildValue
(
"(i)"
,
aPage
);
re
sult
=
CallMethod
(
"GetParameterPage
Names"
,
arglist
);
re
t
=
CallRetArrayStrMethod
(
"GetParameter
Names"
,
arglist
);
Py_DECREF
(
arglist
);
if
(
result
)
{
// TODO GET ITEMS IN LIST
const
char
*
str_res
=
PyString_AsString
(
result
);
ret
=
wxString
::
FromUTF8
(
str_res
);
Py_DECREF
(
result
);
}
return
a
;
return
ret
;
}
wxArrayString
PYTHON_FOOTPRINT_WIZARD
::
GetParameterValues
(
int
aPage
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment