One of the more heated points in the ongoing KDevelop team meeting here in Munich is the good old language war - while I love (and hate just as much) Perl, Alex likes Ruby, Roberto JavaScript and I’m sure we can find someone who prefers Python.
Since Revision 797621 of KDevPlatform, scripting via Kross is now supported. This allows everyone to write an extension to KDevelop in his favorite scripting language. Since I’m most familiar with QtScript (yes, I did forget all my Perl a moment ago), here’s an example KDevelop script:
function documentLoaded(doc) {
print(KDevTools.toDocument(doc).url());
}
documentController = KDevTools.toDocumentController(KDevCore.documentController());
documentController.documentLoaded.connect(docLoaded);
This little script will listen to all documentLoaded signals from the document controller and outpout the URL of the file once it’s loaded.
So, let’s load a file:
documentController.openDocument("test.cpp");
and watch the URL being printed to command line. The available scripting backend could already be used to implement a simple “switch header/source” plugin, that opens the corresponding *.h/*.cpp file when invoked.
For the moment, the “casts” using KDevTools are required as long as I don’t understand how to auto-convert meta-types in a script-independent way
My goal for this meeting - implement a version control system plugin completely in a scripting language, so it can be deployed without headache for all supported OSes.
7 Responses to “KDevelop gets Kross scripting”
Nice to hear, I would call myself a pythonista or pythoniac so I appreciate python support via Kross. I’ve had some time to test parts of KDevelop4 because I’m currently sick and can’t really leave my room/bed, so here is some feedback:
Some code lines that caused compile errors in KDevPlatform (commenting them out helped):
./vcs/widgets/vcsannotationwidget.cpp: d->m_job->setAutoDelete(false);
./vcs/widgets/vcseventwidget.cpp: d->m_job->setAutoDelete( false );
I’d like to know if there exists an official bugtracker or contributors page/info for KDevelop4?
Does Kross support Perl anyway? I was under the impression it didn’t. (If not, how would one go about making it support Perl? One of my friends is a Perl programmer and would be interested in scripting KDE stuff with it.)
@Sascha: You probably need a newer kdelibs release. Bugreports are best posted on irc, #kde-devel
@David: You’re right, no perl support so far in Kross. But from the amount of code to bind Python, Ruby or qtscript, it doesn’t look like an impossible task
Any hope of getting a Qt-only version of Kross? I realize you’re not the best person to ask, but Kross seems like such a clean way to offer Qt scripting beyond QtScript. I know I’d certainly like it for my Qt-based project and it would be nice if we don’t need to import all of kdelibs just for Kross.
You mean you actually got Roberto to come around to the fact that Kross can actually be useful??? How on earth did you manage that! =D
I wish I could still be there with you guys getting into some KDevelop hacking, unfortunately work calls!
I had a great time at the weekend though!
@harald
That are fantastic news. I’ll try to find on the weekend the time to look more detailed at it and will try to find a proper answer to your question
@Geoff
Thanks to the Scribus devels for asking that question very early, a lot of work was done there plus it’s now very much at the top of my todo. In fact the backends don’t link against KDE/kdelibs at all (well, except kross-core which is in kdelibs) while kross-core only does use kdelibs only for 2-3 remaining cases now - iirc things like KIcon and KStandardDirs but nothing “essential” - just grep kdelibs/kross/core/* ;-).
Any idea what is required, and what amount of time involved would you estimate, to make a Perl plugin for Kross?
I had a short glance at the webpage without success.