Posts: 1,265
Joined: Oct 2009
Reputation:
29
takoi
Team-Kodi Member
Posts: 1,265
How can I extend the python interface now with the new swig system in place?
Correct me if I'm wrong, but this is isn't vanilla swig.. For instance: how do I map a simple struct?
When defining it in the .i files, I still end up with compilation error saying something like 'Cannot convert swig type'
Posts: 16,946
Joined: Feb 2011
Reputation:
256
If i understood correctly you just add the C++ implementation and and include the header of c++ into the .i file.
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much:
click here
HowTo setup NFS for Kodi:
NFS (wiki)
HowTo configure avahi (zeroconf):
Avahi_Zeroconf (wiki)
READ THE IOS FAQ!:
iOS FAQ (wiki)
Posts: 492
Joined: Dec 2006
Reputation:
5
Keep in mind we're still working through bugs with this changes.
Posts: 492
Joined: Dec 2006
Reputation:
5
2012-09-11, 23:03
(This post was last modified: 2012-09-11, 23:05 by jfcarroll.)
It's not full SWIG and can't be used out of the box to solve the general codegeneration case. It's meant to tie the well defined API to different bindings. You have three problems with your two examples.
1) The generated code assumes any api class (or struct) instances inherit from AddonClass.
2) You need a single constructor. (I can fix it so that it handles a default constructor if there isn't any) but if you inherit from AddonClass you'll be required to supply one anyway.
3) It doesn't handle absolutely every type (SWIG does this by shuffling around opaque references). That's overkill for this API.
I tried for quite a while to get straight SWIG code to run directly. The code it generated was unstable when run embedded with multiple interpreters and very bulky and awkward (a necessary effect of trying to solve the general case). The Groovy piece gives us much more fine grained control over the generated code but it's not meant to solve the general case of any C++ code you can imagine. Some restrictions apply (like 1 through 3 above for a rough sampling).
It will handle "Dictionary's" (see interfaces/legacy/Dictionary.h), std::map's, std::vector's and a Tuple (see interfaces/legacy/Tuple.h). Feel free to extend the template if you want.
EDIT: I supplied those examples as alternatives to your struct. Not as the full suite of what it will currently handle. /EDIT
Posts: 1,265
Joined: Oct 2009
Reputation:
29
takoi
Team-Kodi Member
Posts: 1,265
2012-09-12, 15:53
(This post was last modified: 2012-09-12, 15:53 by takoi.)
Thanks! That's very helpful
Posts: 1,265
Joined: Oct 2009
Reputation:
29
takoi
Team-Kodi Member
Posts: 1,265
Are there any plans on supporting fields? I mean I can wrap my 10 fields in methods no problem, but is that something you would accept in a patch?
Posts: 492
Joined: Dec 2006
Reputation:
5
You can do read-only fields (constants) now. I am actually going to add fields. Yes. I'm just not sure when. For the time being I'd suggest wrapping them in getters and setters.
Posts: 1,265
Joined: Oct 2009
Reputation:
29
takoi
Team-Kodi Member
Posts: 1,265
I meant fields as in class members. You saying you can already can do that? How?
Posts: 5,184
Joined: Jan 2009
Reputation:
131
Nope it's not yet possible but we plan to add it.
Always read the
online manual (wiki),
FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the
forum rules (wiki).
Please read the pages on
troubleshooting (wiki) and
bug reporting (wiki) before reporting issues.