For the developer in charge of SWIG.
#1
I'm trying to add a new python control. I'm basing it off of DialogProgress.

The only two files a search came up with, that seem relevant are Dialog.cpp and Dialog.h.

The issue is its not generating AddonModuleXbmcgui.cpp with my changes. It does build that file though.

Any tips? I'm trying a full rebuild to see if that helps.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#2
It's generating AddonModuleXbmcgui.cpp now. I guess I had to build outside visual c++ for it to update or it was the full build.

Either way all seems fine now.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
Hey Nuka,

A full clean/build should result in a regeneration of all of the code. There's some idiosyncrasies with the way VS handles dependencies for those special build targets but deleting the xbmc/interfaces/python/generated directory ought to cause the next build to regenerate everything.

Montellese set that up for me in Windows, I'll see if I can get him to take a look.
Reply
#4
Thanks, the only issue I'm having is trying to get the pydocs to format properly.

By appending \n to each line seems to have the best results so far.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
(2013-03-17, 20:55)Nuka1195 Wrote: Thanks, the only issue I'm having is trying to get the pydocs to format properly.

By appending \n to each line seems to have the best results so far.

yeah pydoc generation is broken atm and according to jfcarrol not easy fixable.
I created a reminder ticket http://trac.xbmc.org/ticket/14186
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#6
If you just want to force re-generation of the *.cpp files from the *.i you can rightclick the *.i files in VS's solution explorer (you can select multiple ones if you want) and use the "Compile" action and it will regenerate the files.
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.
Reply
#7
Good to know.

Pydocs works here, just the formatting is off some.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#8
Yeah. The pydoc issue has more to do with filtering and formatting. It should currently work though.

One problem is filtering out methods that shouldn't be included at all. For example, most of the calls on the Control class shouldn't be in the docs as they are stubs. Nuka, any suggestions on how to handle this?

Thanks
Reply
#9
Typed a long message and now it's gone?

I'm not sure what can be done with pydocs, maybe pydocs.py will need to be modified.

I have a few more questions.

1. in control.h i see your notes about getControl(), I use to be able to use:
PHP Code:
type(self.getControl(100)) 
it would return something like
Quote:<type 'xbmcgui.ControlLabel'>
now it returns
Quote:<type 'xbmcgui.Control'>
so i can't differentiate control types and call the correct methods.
Is this going to be changed or do i need to find some other way?

2. how do you add controls to control.h/.cpp
I get the following when using self.getControl() for the new control type ControlSpinEx.
Quote:RuntimeError: Unknown control type for python
the only files i edit are control.h/.cpp, is this the only place i need to add them. i had a PR on git before the swig change and am unable to get it to work.

3. how do you add constants to xbmcgui.
i'm using:
PHP Code:
SWIG_CONSTANT2(int,SPIN_CONTROL_TYPE_INTCGUISpinControl::SPIN_CONTROL_TYPE_INT); 
or
PHP Code:
SWIG_CONSTANT(int,SPIN_CONTROL_TYPE_INT); 
which both create
PHP Code:
PyModule_AddIntConstant(module,"SPIN_CONTROL_TYPE_INT",(int)CGUISpinControl::SPIN_CONTROL_TYPE_INT); 
which gives me errors
Quote: 9 IntelliSense: expected an identifier d:\development\source\xbmc\xbmc\interfaces\python\generated\addonmodulexbmcgui.cpp 14678
Error 1 error C2589: 'constant' : illegal token on right side of '::' D:\Development\source\XBMC\xbmc\interfaces\python\generated\AddonModuleXbmcgui.cpp 14678
Error 2 error C2059: syntax error : '::' D:\Development\source\XBMC\xbmc\interfaces\python\generated\AddonModuleXbmcgui.cpp 14678

if i manually change it to:
PHP Code:
PyModule_AddIntConstant(module,"SPIN_CONTROL_TYPE_INT",(int)SPIN_CONTROL_TYPE_INT); 
it works.

any help, i'm lost,

thank you
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#10
while looking thru "ListItem.h" i found you include it.

#include "ListItem.h"

i've also seen some double includes, do you want a patch for those?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#11
1. @jfcaroll, i just realized i answered why the pydocs are not filtering out methods. it's because they all return type xbmcgui.Control as apposed to xbmcgui.ControlLabel. I really need that fixed is there any way you could do what your notes in the source say even if you think it's ugly?

2. fixed. you have to add them to window.cpp also. duh

3. partially fixed, it wasn't that the constant wasn't being added to xbmcgui correctly.
this works fine.
PHP Code:
SWIG_CONSTANT(int,SPIN_CONTROL_TYPE_INT); 

it is else where in the code that isn't working when i make reference to SPIN_CONTROL_TYPE_INT in ControlSpinEx(..., iType=SPIN_CONTROL_TYPE_INT) constructor in control.h as a default value. How do i handle this.

4. is there any way to create overridden functions? I need to have to setValue() take an integer or string.

with
PHP Code:
virtual void setValue(const Stringvalue) throw (UnimplementedException);
      
virtual void setValue(int value) throw (UnimplementedException); 
i get.
Quote: [D:\Development\source\xbmc\xbmc\interfaces\python\generated\AddonModuleXbmcgui.xml, D:\Development\source\xbmc\xbmc\interfaces\python\PythonSwig.cpp.template, D:\Development\source\xbmc\xbmc\interfaces\python\generated\AddonModuleXbmcgui.cpp, D:\Development\source\xbmc\xbmc\interfaces\python\generated\doxygenxml]
Caught: java.lang.AssertionError: Cannot handle overloaded methods unless simply using defaulting: [function[attributes={throw=1, name=setValue, ismember=1, throws=5e3ba8, sym_name=setValue, decl=f(r.q(const).String)., access=public, sym_overloaded=5e3be8, type=void, code={ throw UnimplementedException("Control", __FUNCTION__); }, storage=virtual, id=5e3be8}; value=[catchlist[attributes={id=5e3ba8}; value=[parm[attributes={type=UnimplementedException}; value=[]]]], parm[attributes={name=value, type=r.q(const).String}; value=[]]]], function[attributes={throw=1, name=setValue, ismember=1, throws=5e3d78, sym_name=setValue, decl=f(int)., access=public, sym_overloaded=5e3be8, type=void, code={ throw UnimplementedException("Control", __FUNCTION__); }, storage=virtual, id=5e3db8}; value=[catchlist[attributes={id=5e3d78}; value=[parm[attributes={type=UnimplementedException}; value=[]]]], parm[attributes={name=value, type=int}; value=[]]]]]. Expression: (value.size() == 1)
java.lang.AssertionError: Cannot handle overloaded methods unless simply using defaulting: [function[attributes={throw=1, name=setValue, ismember=1, throws=5e3ba8, sym_name=setValue, decl=f(r.q(const).String)., access=public, sym_overloaded=5e3be8, type=void, code={ throw UnimplementedException("Control", __FUNCTION__); }, storage=virtual, id=5e3be8}; value=[catchlist[attributes={id=5e3ba8}; value=[parm[attributes={type=UnimplementedException}; value=[]]]], parm[attributes={name=value, type=r.q(const).String}; value=[]]]], function[attributes={throw=1, name=setValue, ismember=1, throws=5e3d78, sym_name=setValue, decl=f(int)., access=public, sym_overloaded=5e3be8, type=void, code={ throw UnimplementedException("Control", __FUNCTION__); }, storage=virtual, id=5e3db8}; value=[catchlist[attributes={id=5e3d78}; value=[parm[attributes={type=UnimplementedException}; value=[]]]], parm[attributes={name=value, type=int}; value=[]]]]]. Expression: (value.size() == 1)
at Helper$_transformSwigXml_closure10.doCall(Helper.groovy:455)
at Helper.transformSwigXml(Helper.groovy:455)
at Helper$transformSwigXml.call(Unknown Source)
at Generator.run(Generator.groovy:61)

also getValue() to return either an integer or string. i know you can't override a function that takes no args, but you use to be able to pass a python object, then return an integer or string based on what type of spincontrol it was. Is there any way to do this now?

I could pass you the diff for a look, it's ugly copy and paste right now, but if you could help.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#12
1. This is a general problem with mapping a statically typed language (C++) to a dynamically typed language (python). There's no easy way to fix this BUT in general it's really bad practice to 'switch' on a type. The way I resolved this for the control hierarchy is to add every method to the parent Control class but stub it out. I'm not thrilled with this approach (as the comments indicate) but so far it's covered every case we've needed.

3. What error are you getting? The compiler needs to see SPIN_CONTROL_TYPE_INT before it's used in the constructor.

4. I know it's ugly but true method override support would be about a full weeks work which I can add to a TODO list but can't get done for you now. Can you use the string and convert?
Reply
#13
1. So nobody else uses:
PHP Code:
isinstance(self.getControl(100xbmcgui.ControlLabel)) 
that's kind of an important ability. And i'm not sure pydocs can be fixed to handle the way this is done currently.

3. is odd when hovering over it shows the actual value correctly, but gives an error, which i'll have to look at again. i'm sure i'm doing something wrong.

4. would be helpful, i read some of the python/swig documentations and couldn't figure out what i was doing wrong.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#14
1. never came up as an issue in existing plugins. In general writing code that does that (calls a different method in a switch/case or if/else statements based on the type of the object) side-steps polymorphism. My fix so far has been to make sure everything is supported at the top level.

Maybe I can fix this. Let me take another look.

3. Point me to your code, I'll take a look.

4. The error message tells it all. Plus the codegenerator wiki mentions it. Method overriding is currently not supported (except through the use of defaulting).
Reply
#15
1. Yeah, I've read http://www.canonical.org/~kragen/isinstance/ and understand it's not ideal, but it worked so well Smile. i can change it to the more acceptable hasattr() if that will work with xbmc as is. it won't change the flow any.

3. thanks: http://xbmc-addons.googlecode.com/svn/pa...inEx.patch

4. i saw that wasn't sure what it meant exactly, but not sure it matters anyway.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply

Logout Mark Read Team Forum Stats Members Help
For the developer in charge of SWIG.0