[Kde-bindings] Some refactoring

Richard Dale rdale at foton.es
Mon Jan 15 10:29:09 UTC 2007


On Sunday 14 January 2007 14:04, Arno Rehn wrote:
> Am Samstag, 13. Januar 2007 12:25 schrieb Paolo Capriotti:
> > Hi,
> > I've found some time to come back to Qyoto hacking, and I've decided to
> > port most of the code that was using ArrayList's, Hashtable's and other
> > .NET 1.1 idioms to .NET 2.
>
> Great! That was what I wanted to do today. ;)
>
> > This should bring an improvement both in terms of code readability and
> > performance.
> > Not all legacy containers have disappeared, though, because I still have
> > to figure out what those methods like AddAddObjectObjectToHashtable do :)
>
> The Add* methods in C++ create a Callback, which we can use to call C#
> Methods from C++. It works like this: You first create a delegate in C# and
> a typedef in C++; both with the same signature (IntPtr in C# becomes void*
> in C++, look at qyoto.h). Then you have the Add* methods in C++, which take
> a method pointer (or a delegate in C#) as an argument and set the
> pointer/delegate to a method pointer with the type of the equivalent
> typedef. Now you can call a C# method with (*whatever)() from C++.
> AddObjectObjectToHashtable takes the pointer to a C# Hashtable and the
> pointers of two C# objects as arguments. In C# the pointer to the Hashtable
> is used to get the real Hashtable, same goes for the two objects. Then the
> objects (one key, one value) are added to the Hastable.
I see how it works. Setting up a delegate to call back from C/C++ takes quite 
a lot of effort and we need to have a consistent naming scheme like we have 
now. But a bit less confusing, as 'AddAddObjectObjectToHashtable ' is a bit 
of a mouthful. Are we using 'Add' for both 'add an item to a hash table', and 
for 'setup a delegate to do something'? Maybe 'Install' would be a better 
word for setting up a delegate - eg 'InstallAddObjectObjectToHashtable'. 
And 'ObjectObject' seems a bit redundant, could that be shortened to 
just 'Object', so we have 'InstallAddObjectToHashtable'? 

I was wondering if it would be a good idea to move marshalling code out of 
SmokeInvocation.cs to SmokeMarshallers.cs or similar, to make the code 
clearer.

-- Richard



More information about the Kde-bindings mailing list