[Mono-list] Qt C# bindings and a simple HelloWorld
Jonathan Pryor
jonpryor@vt.edu
04 Feb 2002 21:39:06 -0500
I would suggest not changing the name of the method itself, as this will
require changes to any source code that uses the method whenever the
name mangling changes.
A better approach would be to use the EntryPoint attribute to specify
the actual exported name:
[DllImport("libqt.so.2", EntryPoint="@qt_new_QApplication@")]
public static extern Object qt_new_QApplication (
int argc, string[] argv);
Then, you could use `nm' and a `sed' script to replace
"@qt_new_QApplication@" with the appropriately mangled entrypoint.
See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_B_8.asp
- Jon
On Mon, 2002-02-04 at 21:04, Adam Treat wrote:
> So I've been mucking about for a bit with some c-sharp bindings to the
> qt-toolkit. I've been successful with a generic helloworld program. I think
> I am ready to begin generating some bindings in earnest after a few problems
> are solved:
>
> 1. Not sure how to handle Slots and Signals. (biggest problem) ;)
>
> 2. I have been using the qtc bindings from kde3 in the pinvoke statements. I
> would like to stop using the libqtc library and just dllimport from libqt but
> the name mangling (see http://www.delorie.com/gnu/docs/gcc/gxxint_15.html) is
> going to have to be accounted for. Thinking about writing a tool that will
> automatically mangle the dllimport statement. ie:
>
> From:
> [DllImport("libqtc.so.1.0.0")]
> public static extern Object qt_new_QApplication(int argc, string[] argv);
>
> To:
> [DllImport("libqt.so.2")]
> public static extern Object __12QApplicationRiPPc(int argc, string[] argv);
>
> 3. I don't know how to use kalyptus (don't know perl) and I am a frankly
> little frightened to go in that direction... Thinking about using the kdoc
> html output and generating the bindings from that, similar to what the intel
> guys did with the ECMA documentation to c# stubs... Richard, Miguel, Mike do
> you have some suggestions on the best way to proceed?
>
> Well tell me what you think.
>
> Adam
>
> P.S. I am primarly a java programmer, with little experience in qt, c++, or
> c. This is an exercise to hopefully do something useful and allow me to
> learn a little so feel free to offer up some pointers ;)
>
> // qt_HelloWorld.cs - qt-csharp Hello World
>
> namespace QtSamples {
>
> using Qt;
> using System;
>
> public class qt_HelloWorld {
>
> public static int Main (string[] args)
> {
>
> QApplication a = new QApplication(args);
> QPushButton hello = new QPushButton("Hello world!", 0);
> hello.resize(100, 30);
> a.setMainWidget(hello);
> hello.show();
> return a.exec();
>
> }
> }
> }