[Mono-dev] Integrating C# and already existing C sources using GAPI or something similar
Mike Kestner
mkestner at novell.com
Mon Jan 23 12:04:54 EST 2006
On Mon, 2006-01-23 at 12:39 +0100, Mario Sánchez wrote:
> Hi, this is my first message to this list, so I'll try to do it my
> best...
This message should have been sent to gtk-sharp-list. Discussion of
Gtk# and the GAPI tools should occur there. I'm going to start nagging
everyone about this from now on, as people seem to think Gtk# discussion
is on topic on this list as well, and that just means duplicate
discussions are happening and it's harder to find information in the
archives.
> I'm currently working at a Gtk application and now I'm trying to make an
> small part of the already-made gtk interface (a simple use case of the
> whole application) using Mono with Gtk#, to see how this integration
> could work. As you can imagine, I'd like to use the most already written
> source code I can, so I'd like to call already written C functions from
> my new C# interface, using a Wrapper for that purpose. And this is the
> point in which I'm now stalled:
Another option for a large code base would be to embed mono into your
existing C application to extend it. That's on-topic for this list, but
I don't know much about it so I'll let others comment on it.
> 1.- I'd like to generate wrappers for a source directory and
> sub-directories of a currently installed library, and I don't know
> how to make this without explicitly specify those directories one-by-one
> in the parsing gapi source file, as you can see here:
Look in the gtk-sharp/sources directory for examples of how to combine
multiple source directories and even multiple native libraries into a
single api file. The Gdk and Gnome api file sections demonstrate this.
> 2.-I have more source code that I'd like to re-use but that is not
> installed as a library, because it's not a library but an application
> (the application in which I'm trying to re-implement a use case in Mono
> terms), but it has got, for example, several defined Gobjects and
> utilities that are useful for me to use from my Gtk# interface. The
> question is how could I automatically wrap those sources using Gapi (or
> something similar) into C# files, in order not to have to implement that
> already-written functionality again.
GAPI is not a C to C# translator. It won't transform C code into C#.
It uses the DllImport/PInvoke capability of .Net/mono to invoke native
library methods. So short answer is, no library, no GAPI.
> 3.- Another question using GAPI is how to wrap C sources that not
> correspond to GObject classes because, as I was able to see, gapi parser
> only recognizes those sources that represent classes using GObject, but
> not those other C sources as could be utility libraries containing
> useful functions for common situations at this application.
GAPI does parse some non-GObject libraries already, although it is not a
full-featured C parser. Non-GObject libraries tend to not follow the
same coding conventions as GObject libraries.
> I'll be so glad if someone was able to help me, because I can't find
> enough information and documentation about the Gapi parser across the
> Internet, so I can't find the way to achieve this issues. I'm open to
> other suggestions (not only Gapi) for me to integrate C# and C in the
> way I mean too, so if someone knows a better way to do this I'll be
> interested on it.
The definitive resource for GAPI is:
http://www.mono-project.com/GAPI
--
Mike Kestner <mkestner at novell.com>
More information about the Mono-devel-list
mailing list