[Kde-bindings] Some refactoring

Arno Rehn arno at arnorehn.de
Sun Jan 14 14:04:07 UTC 2007


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.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list