Python scripting: make UTF8 class accessible by python scripts. Add python method GetChars() to UTF8 class to get its char buffer.
See scripts/test_kicad_plugin.py for example.
This commit is contained in:
+25
-2
@@ -53,6 +53,7 @@
|
||||
%ignore operator <<;
|
||||
%ignore operator=;
|
||||
|
||||
|
||||
/* headers/imports that must be included in the _wrapper.cpp at top */
|
||||
|
||||
%{
|
||||
@@ -62,7 +63,7 @@
|
||||
#include <common.h>
|
||||
#include <wx_python_helpers.h>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <vector>
|
||||
|
||||
#include <class_title_block.h>
|
||||
#include <class_colors_design_settings.h>
|
||||
@@ -70,7 +71,6 @@
|
||||
#include <eda_text.h>
|
||||
#include <convert_from_iu.h>
|
||||
#include <convert_to_biu.h>
|
||||
|
||||
%}
|
||||
|
||||
/* all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. */
|
||||
@@ -110,7 +110,30 @@
|
||||
|
||||
/* std template mappings */
|
||||
%template(intVector) std::vector<int>;
|
||||
%template(str_utf8_Map) std::map< std::string,UTF8 >;
|
||||
|
||||
/* KiCad plugin handling */
|
||||
%include "kicadplugins.i"
|
||||
|
||||
// ignore warning relative to operator = and operator ++:
|
||||
#pragma SWIG nowarn=362,383
|
||||
|
||||
// Rename operators defined in utf8.h
|
||||
%rename(utf8_to_charptr) operator char* () const;
|
||||
%rename(utf8_to_wxstring) operator wxString () const;
|
||||
|
||||
#include <utf8.h>
|
||||
%include <utf8.h>
|
||||
|
||||
%extend UTF8
|
||||
{
|
||||
const char* Cast_to_CChar() { return (self->c_str()); }
|
||||
|
||||
%pythoncode
|
||||
{
|
||||
|
||||
def GetChars(self):
|
||||
return self.Cast_to_CChar()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user