[Mono-list] Fwd: Possible replacement for Windows.Forms

murban murban@houston.rr.com
Tue, 16 Jul 2002 22:05:27 -0500


Have you looked at some of the other bindings that call C++ from C#? One 
example is Qt#. It's a work in progress, but the basic concepts of using a 
C++ based toolkit from C# are working. There are many other examples, such as 
WxPython and QtJava.

The bindings that I have looked at use a two-level approach. The first level 
is a set of C functions. There are one or more C functions that perform 'new 
WhateverObject' and then return the result, and there are other C functions 
that simply call the C++ function. Thiis lower level is compiled #extern "C" 
so that name mangling is not performed. The second level consists of a set of 
C# methods that call the C functions. In the case of Qt#, the C functions are 
provided by another library QtC.

I believe it is possible to minimize (probably not eliminate) the C layer, but 
the C functions that perform the 'new' for C++ objects are difficult to 
eliminate. The other two complications of calling C++ directly are that the 
compiler does name-mangling on the C++ methods, and the fact that virtual 
methods only appear as methods on the base class.

> I have been looking at wxWindows for quite some time.  I don't
> think I personally want to deal with importing C++ classes and looking
> at them as structs.  This seems very, very painful.  Unless someone can
> explain an easier way to platform invoke these, I don't think this will
> work.