Author Archives: Arno

Current git branch in shell prompt

Since I”ve read much about git and how great it is, I recently thought that I had to try it myself. And indeed, it is quite amazing and is nice to work with. There was one thing that I disliked, though: I never quite knew in which branch of my repository I was, especially after I”ve been away from coding for a few hours.
Of course I could just look that up, but I tend to forget that and then end up with code that belongs to a different branch. Now the shell prompt looked like a good place to show the current branch, but simply executing “git branch | grep ^*” would only work in the top-level directory of the repository. So I wrote the following function which will traverse all containing directories and look for a .git directory. Having found one, it will nicely print the the branch in dark green color, with a @ sign in front of it:

Update: As many people have pointed out, bash-completion provides a function called __git_ps1 which will happily print the current git branch and can be used as well. I don”t quite like the rest of bash-completion, though, so I”ll stick with my own.
As Yuri pointed out, git branch works from any directory, so here”s the updated (and much shorter 🙂 ) version:

function formattedGitBranch {
    _branch="$(git branch 2>/dev/null | sed -e "/^\s/d" -e "s/^\*\s//")"
    test -n "$_branch" && echo -e " @\e[0;32m $_branch"

Having this in my .bashrc, I could integrate it quite nicely with my prompt:

\[\e[1;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\]$(formattedGitBranch) \[\e[1;32m\]\$ \[\e[m\]\[\e[0m\]

git prompt

Qyoto on Windows!

Now that the new smokegenerator is in trunk and generating smoke on windows shouldn”t be a pain anymore, I thought that I could dig out my nearly unused Vista partition on my laptop and start porting Qyoto to Windows.
First thing I did was removing the preinstalled Vista and installing it again to get rid of all the preinstalled crap Dell thought I needed. Next was installing Visual C++ and C# (the Express editions are free as in beer and work ok – nothing in comparison to KDevelop4 though) and KDE 4.3. Thanks to all of the KDE Windows team – you make Windows much more bearable! I also installed msys – can”t live without a proper shell anymore.

Now came the actual porting: To support MS .NET and not only Mono, I needed to add support for csc.exe (the MS C# compiler) to the existing C# macros. As I recently discovered how to add support for a new language to cmake (which lacks documentation but is really easy once you understood it) I simply rewrote the C# macros as a new cmake language plugin. Compilation was pretty straight-forward, then.
But as was to be expected, the examples simply crashed upon start. Long story short: Some of them work now and this is how it looks:

Qt tutorial t5 with Qyoto

This is still really unstable and crashes every few minutes with an AccessViolationException. Have to figure out why it does that.. But first I have to do some other things, mainly porting the remaining kalyptus-generated smoke modules to the new smokegenerator. This shouldn”t take too long, so I think I can complete the Windows port soon 🙂 So stay tuned!

Update: The AccessViolationExceptions should be fixed now. If you want to try Qyoto on Windows and have problems getting it to compile or run, please send a mail to the kde-bindings mailinglist and include the complete error and backtrace. You can also search the mailing list archives since this topic came up quite often recently.

gsoc, week 11 – generating smokekde :)

Now that the Qt classes generate and compile fine (as Richard already wrote) I tried to generate the smokekde sources with the new generator last week.

After fixing quite a bunch of bugs that didn”t surface when generating smokeqt, it works now really well.
There isn”t much difference between the config files for qt and kde, too – it”s mainly the lists of stuff to include and very little stuff to be excluded (d pointers, q pointers, other private stuff…).
This really shows that the new parser is superior to kalyptus, which had dozens of hacks in it for the code to generate nicely.

In case you want to test it, get the source from /trunk/playground/bindings/smokegenerator. To make testing easier, I wrapped the generation in cmake, so a normal cmake; make; make install should build and install smokeqt and smokekde for you.

The new generator still generates a lot of code for deprecated methods, which isn”t really nice – but maybe the parser can be modified so it recognizes __attribute__((deprecated)) flags.
There are also still issues with fixed-width array types, which luckily don”t occur too often in KDE sources. This only affects KMD5 for the moment. I”ll fix this next week, so then should smokekde with smokegenerator be equal to smokekde with kalyptus 🙂

Hello Planet!


my name is Arno Rehn and I”m a bindings developer. I”m working mainly on the C# bindings for Qt and KDE together with Richard Dale.

Currently I”m also working on my gsoc project – Rewriting the SMOKE generator using one of Roberto Raggi”s C++ parsers.
SMOKE is a library which provides the possibility to dynamically call methods on classes. It is the foundation for many of the Qt/KDE bindings, like Ruby, C# and PHP.
The old generator for the SMOKE sources is based on a perl tool, kalyptus, and only works with a bunch of hacks in the code. It tends to break on new releases of Qt or KDE which introduce new features.

The goal of my project is to create a stable and robust tool, similar to the moc, which you just run on the headers of your project and you then end up with a bunch of source files that are the basis for bindings for your project.

Eventually I decided to use the new parser from KDevelop4, since that has a pretty convenient API (unlike the QtJambi / qtscriptgenerator one). It took some time to remove the KDevPlatform/KDevelop specific bits, though. It would”ve also been nice if I could”ve used the DUChain from KDevelop, but that seems to be so tightly integrated that I would have to provide half of KDevelop to use it.

I”m pretty much ahead of time – the generator is nearly finished. By the end of the GCDS, which I”m attending until Thursday, it should be working completely – at least with the Qt classes.

P.S.: I know that gsoc has started quite some time back, but I was really to lazy/busy to start a blog 😉