← Back to team overview

kicad-developers team mailing list archive

Re: How to compile with Python support?

 

Laurent Dufrechou wrote:

>well, I was thinking of writing a parser for that reason ... with
>special macros such as __SWIG_EXPORT ...

I don’t understand this last point, why do you need a parser??????
To make the wrapper c++ to python?


The fact is I am thinking of a way to automate the .i file creation, not to have to maintain them on the side ... KiCAD is evolving fast, and I don't want any code modification to break the binding. So instead of having a .i file, we would have in the code :

__SWIG_EXPORT class MyClass
{
public:
__SWIG_EXPORT void DoSomethingNice() {}
}


although the syntax is not what it will be ... yet just thinking about that.


>- May proove really painfull to use on the C++ calling other language
>thing (although I read a thread explaining bits of it ...)
>- Increase complexity of the code (you got to know what you are doing
>... and few devs know SWIG), that point can be solved with some macro magic

I’m not OK with what you said on code complexity. If you use SWIG well you’ll use .i files that are mainly a copy f your headers. And in THESE .i file you specify what you want to wrap or not.

well if you change a method/function name, you have to update the .i file ... unless you have the .i file automagically created for you (with that parser)

So if you want to provide a python wrapper, your devs will not have to know about SWIG. I’ve wrapped a big library WITHOUT modyfing line of C++ code. Only .i file where created in a separate directory.

they have to be maintained ...

For the two way binding, what do you want to do ? I’ve done in my project a python scrpit launcher called from c++. Is it suffciient for your needs?

well, I would need :

- calling scripts at startup
- registering some objects from python side that the C++ would then call (event callbacks handling/registering) - allow the python code to modify any part of the gui (that's the easy one, wx handles it for us)

If you want some .i example I can try to hepl you little with what I ‘ve seen from my previous project.

As I told you, the one way binding (the .i file), that is calling C++ code from Python is not a problem

Can you explain the parser story, I really don’t undersatnd it’s usage with SWIG ?_?

see above

If you want a little help for this I can share my XP with you.

well, that could be interesting to work together on that yes

--

Florian Delizy






References