[Kde-bindings] KDE/kdebindings

Arno Rehn arno at arnorehn.de
Mon Jun 9 12:28:13 UTC 2008


Am Montag 09 Juni 2008 11:38:12 schrieb Richard Dale:
> On Sunday 08 June 2008 11:27:54 Arno Rehn wrote:
> > Am Samstag 07 Juni 2008 19:14:43 schrieb Richard Dale:
> > > On Saturday 07 June 2008 12:13:54 Arno Rehn wrote:
> > > > SVN commit 817998 by arnorehn:
> > > >
> > > > * C++ namespaces are now mapped to C# namespaces. If a class is in no
> > > > namespace, it is put into 'Kimono' (or 'Qyoto' for Qt).
> > > > * The functions within a namespace are put into a class called
> > > > 'Global' in the C# namespace.
> > > > * Added the qxmlstream.h header.
> > >
> > > Sounds good. What about the idea to move nested classes into there own
> > > source files that you talked about on irc? I've thought about that
> > > since, and I'm really not keen on the idea. For instance, there are
> > > some really small nested classes in Qt, and it will just clutter the
> > > project up if we move them out.
> >
> > Yep, I've removed that part of the patch. Nested classes are still in the
> > same source file as their containing class.
>
> I had a look at the generated code, and I think it has come out very nice.
> I slightly simplified the declaration of the Global classes to look like
> this:
>
> 	[SmokeClass("Soprano")]
> 	public class Global {
> 		private static SmokeInvocation staticInterceptor = null;
> 		static Global() {
> 			staticInterceptor = new SmokeInvocation(typeof(Global), null);
> 		}
>
> Without explicitly inheriting from Object, and no interceptor needed for
> instance methods as they are all static in a namespace. In the Soprano
> classes with nested namespaces it generated code like this:
>
> namespace Soprano.Vocabulary.NAO {
>   ...
>
> Which is really nice - I didn't realize that was valid C#.
Heh, good :)

> The only thing I don't like is subclassing SmokeInvocation and giving it a
> different name in the generated code. That seems pointless and ugly to me
> any old static constructor will load the smoke lib. In the soprano bindings
> I had a source called 'Soprano.cs' with this:
>
> namespace Soprano {
> 	using Qyoto;
> 	using System;
> 	using System.Runtime.InteropServices;
>
> 	public class InitSoprano {
> 		[DllImport("libsoprano-sharp", CharSet=CharSet.Ansi)]
> 		static extern void Init_soprano();
>
> 		static InitSoprano() {
> 			Init_soprano();
> 		}
> 	}
> }
>
> And just left SmokeInvocation as it was in the generated code. So I think
> we should have a Kimono.cs source with the same thing in it.
My intention was to simplify the code for those who actually use the C# 
bindings. And a static constructor is called when the class that defines it 
is used for the first time. Since SmokeInvocation is always used before any 
other thing, it makes sure that the smoke lib is always loaded. If we put 
that code into another class that is completely unrelated to the binding, we 
will always have to call InitFoo() if we want to use it. So subclassing 
SmokeInvocation for the different bindings seemed to be the best solution to 
me.

> When I tried to compile the Kimono code I got an error about an
> unimplemented abstract method. I wonder if the easiest thing to fix that is
> to have partial classes with the missing methods in them with empty bodies.
Mh, I thought I had marked all the classes 'abstract' by hand that gave 
errors. Maybe we need to look if all abstract members are implemented in a 
subclass of an abstract class and if not, mark it abstract as well.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list