2013-03-15 13:27:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
|
2017-05-25 07:05:35 +00:00
|
|
|
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-15 13:27:18 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
/**
|
|
|
|
* @file pcbnew_footprint_wizards.cpp
|
2018-01-30 19:23:06 +00:00
|
|
|
* @brief Class and PYTHON_FOOTPRINT_WIZARD_LIST and PYTHON_FOOTPRINT_WIZARD_LIST
|
2012-05-05 20:18:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pcbnew_footprint_wizards.h"
|
2012-08-02 17:24:53 +00:00
|
|
|
#include <python_scripting.h>
|
2012-05-05 20:18:47 +00:00
|
|
|
#include <stdio.h>
|
2013-05-01 17:32:36 +00:00
|
|
|
#include <macros.h>
|
2012-05-05 20:18:47 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
|
|
|
PYTHON_FOOTPRINT_WIZARD::PYTHON_FOOTPRINT_WIZARD( PyObject* aWizard )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
this->m_PyWizard = aWizard;
|
2012-09-24 16:03:03 +00:00
|
|
|
Py_XINCREF( aWizard );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
PYTHON_FOOTPRINT_WIZARD::~PYTHON_FOOTPRINT_WIZARD()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_XDECREF( this->m_PyWizard );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
|
|
|
PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod( const char* aMethod, PyObject* aArglist )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-16 03:27:48 +00:00
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-16 03:27:48 +00:00
|
|
|
PyErr_Clear();
|
2013-03-11 08:09:48 +00:00
|
|
|
// pFunc is a new reference to the desired method
|
2013-03-16 03:27:48 +00:00
|
|
|
PyObject* pFunc = PyObject_GetAttrString( this->m_PyWizard, aMethod );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( pFunc && PyCallable_Check( pFunc ) )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
PyObject* result = PyObject_CallObject( pFunc, aArglist );
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( PyErr_Occurred() )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2015-09-02 13:55:36 +00:00
|
|
|
#if 1 // defined(DEBUG)
|
2013-03-17 01:14:46 +00:00
|
|
|
wxMessageBox( PyErrStringWithTraceback(),
|
2018-03-30 16:43:17 +00:00
|
|
|
_( "Exception on python footprint wizard code" ),
|
2013-03-15 16:35:24 +00:00
|
|
|
wxICON_ERROR | wxOK );
|
2015-09-02 13:55:36 +00:00
|
|
|
#endif
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_XDECREF( pFunc );
|
|
|
|
return result;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-30 16:43:17 +00:00
|
|
|
wxString msg = wxString::Format(_( "Method \"%s\" not found, or not callable" ), aMethod );
|
|
|
|
wxMessageBox( msg, _( "Unknown Method" ), wxICON_ERROR | wxOK );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( pFunc )
|
2014-03-27 17:45:05 +00:00
|
|
|
{
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_XDECREF( pFunc );
|
2014-03-27 17:45:05 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod( const char* aMethod, PyObject* aArglist )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
wxString ret;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* result = CallMethod( aMethod, aArglist );
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
const char* str_res = PyString_AsString( result );
|
|
|
|
ret = FROM_UTF8( str_res );
|
|
|
|
Py_DECREF( result );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-09 23:04:08 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod( const char* aMethod,
|
|
|
|
PyObject* aArglist )
|
2012-05-09 23:04:08 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
wxArrayString ret;
|
|
|
|
wxString str_item;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* result = CallMethod( aMethod, aArglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-10 06:44:08 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
if( !PyList_Check( result ) )
|
|
|
|
{
|
|
|
|
Py_DECREF( result );
|
|
|
|
ret.Add( wxT(
|
|
|
|
"PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
|
|
|
|
1 );
|
|
|
|
return ret;
|
|
|
|
}
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-17 01:14:46 +00:00
|
|
|
ret = PyArrayStringToWx( result );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
Py_DECREF( result );
|
2012-05-10 06:44:08 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-10 06:44:08 +00:00
|
|
|
return ret;
|
2012-05-09 23:04:08 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetName()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
return CallRetStrMethod( "GetName" );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetImage()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
return CallRetStrMethod( "GetImage" );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetDescription()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
return CallRetStrMethod( "GetDescription" );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
int ret = 0;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
// Time to call the callback
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* result = CallMethod( "GetNumParameterPages", NULL );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
if( !PyInt_Check( result ) )
|
2012-07-31 21:00:33 +00:00
|
|
|
return -1;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
ret = PyInt_AsLong( result );
|
|
|
|
Py_DECREF( result );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetParameterPageName( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
wxString ret;
|
|
|
|
PyLOCK lock;
|
|
|
|
|
|
|
|
// Time to call the callback
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
PyObject* result = CallMethod( "GetParameterPageName", arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
const char* str_res = PyString_AsString( result );
|
|
|
|
ret = FROM_UTF8( str_res );
|
|
|
|
Py_DECREF( result );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
wxArrayString ret;
|
|
|
|
PyLOCK lock;
|
|
|
|
|
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
ret = CallRetArrayStrMethod( "GetParameterNames", arglist );
|
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-09-02 13:55:36 +00:00
|
|
|
for( unsigned i = 0; i < ret.GetCount(); i++ )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
wxString rest;
|
|
|
|
wxString item = ret[i];
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( item.StartsWith( wxT( "*" ), &rest ) )
|
2012-07-22 22:23:17 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
ret[i] = rest;
|
2012-07-22 22:23:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterTypes( int aPage )
|
2012-07-22 22:23:17 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
wxArrayString ret;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
ret = CallRetArrayStrMethod( "GetParameterTypes", arglist );
|
2013-03-11 08:09:48 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-10 06:44:08 +00:00
|
|
|
return ret;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 22:23:17 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterValues", arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-10 08:53:05 +00:00
|
|
|
return ret;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterErrors( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
|
|
|
|
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterErrors", arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterHints( int aPage )
|
|
|
|
{
|
2017-01-03 17:04:35 +00:00
|
|
|
PyLOCK lock;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterHints", arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
Py_DECREF( arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
return ret;
|
2017-01-03 15:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterDesignators( int aPage )
|
|
|
|
{
|
2017-01-03 17:04:35 +00:00
|
|
|
PyLOCK lock;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterDesignators", arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
Py_DECREF( arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
return ret;
|
2017-01-03 15:01:47 +00:00
|
|
|
}
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues( int aPage, wxArrayString& aValues )
|
2012-05-16 09:35:18 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
int len = aValues.size();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* py_list = PyList_New( len );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-09-02 13:55:36 +00:00
|
|
|
for( int i = 0; i < len; i++ )
|
2012-05-16 09:35:18 +00:00
|
|
|
{
|
2015-09-02 13:55:36 +00:00
|
|
|
wxString& str = aValues[i];
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* py_str = PyString_FromString( (const char*) str.mb_str() );
|
2012-07-31 21:00:33 +00:00
|
|
|
PyList_SetItem( py_list, i, py_str );
|
2012-05-16 09:35:18 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-12 00:37:45 +00:00
|
|
|
arglist = Py_BuildValue( "(i,O)", aPage, py_list );
|
2013-03-15 16:35:24 +00:00
|
|
|
wxString res = CallRetStrMethod( "SetParameterValues", arglist );
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-16 09:35:18 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
void PYTHON_FOOTPRINT_WIZARD::ResetParameters()
|
|
|
|
{
|
2017-01-03 17:04:35 +00:00
|
|
|
PyLOCK lock;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
CallMethod( "ResetWizard", NULL );
|
2017-01-03 15:01:47 +00:00
|
|
|
}
|
|
|
|
|
2012-05-10 08:53:05 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
// this is a SWIG function declaration -from module.i
|
|
|
|
MODULE* PyModule_to_MODULE( PyObject* obj0 );
|
|
|
|
|
|
|
|
|
2015-09-05 12:10:54 +00:00
|
|
|
MODULE* PYTHON_FOOTPRINT_WIZARD::GetFootprint( wxString * aMessages )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
PyLOCK lock;
|
2012-07-31 21:00:33 +00:00
|
|
|
|
2015-09-05 12:10:54 +00:00
|
|
|
PyObject* result = CallMethod( "GetFootprint", NULL );
|
|
|
|
|
|
|
|
if( aMessages )
|
|
|
|
*aMessages = CallRetStrMethod( "GetBuildMessages", NULL );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( !result )
|
|
|
|
return NULL;
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
PyObject* obj = PyObject_GetAttrString( result, "this" );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( PyErr_Occurred() )
|
2013-03-16 03:27:48 +00:00
|
|
|
{
|
2012-07-31 21:00:33 +00:00
|
|
|
PyErr_Print();
|
2013-03-16 03:27:48 +00:00
|
|
|
PyErr_Clear();
|
|
|
|
}
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
MODULE* mod = PyModule_to_MODULE( obj );
|
2012-08-01 12:50:21 +00:00
|
|
|
|
|
|
|
return mod;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-16 03:27:48 +00:00
|
|
|
void* PYTHON_FOOTPRINT_WIZARD::GetObject()
|
|
|
|
{
|
|
|
|
return (void*) m_PyWizard;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-30 19:23:06 +00:00
|
|
|
void PYTHON_FOOTPRINT_WIZARD_LIST::register_wizard( PyObject* aPyWizard )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
PYTHON_FOOTPRINT_WIZARD* fw = new PYTHON_FOOTPRINT_WIZARD( aPyWizard );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
fw->register_wizard();
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2013-03-16 03:27:48 +00:00
|
|
|
|
|
|
|
|
2018-01-30 19:23:06 +00:00
|
|
|
void PYTHON_FOOTPRINT_WIZARD_LIST::deregister_wizard( PyObject* aPyWizard )
|
2013-03-16 03:27:48 +00:00
|
|
|
{
|
|
|
|
// deregister also destroyes the previously created "PYTHON_FOOTPRINT_WIZARD object"
|
2018-01-30 19:23:06 +00:00
|
|
|
FOOTPRINT_WIZARD_LIST::deregister_object( (void*) aPyWizard );
|
2013-03-16 03:27:48 +00:00
|
|
|
}
|