[Mono-devel-list] binding GObjects into Mono

Frederic Peters fpeters at entrouvert.com
Fri Jan 21 09:54:43 EST 2005


I am developing a Mono binding for Lasso <http://lasso.entrouvert.org>
which uses lots of GObject.  The basis is done with SWIG but it is not
enough and I need some custom code to cast GObject* pointers to right

Mapped to well-known GTK+ my case looks like this:

struct GtkBin {
        GtkContainer container;
        GtkWidget *child;

I would then need to do object->child and get a GtkButton, a GtkVBox,
whatever the object is but not a GtkWidget object.

For reference the JNI binding does something like this (it is not by me):

/* classPath is the appropritate class name, created with G_OBJECT_TYPE_NAME */
clazz = (*jenv)->FindClass(jenv, classPath);
jmethodID mid = (*jenv)->GetMethodID(jenv, clazz, "<init>", "(JZ)V");
if (mid)
        *(void**)&$result = (*jenv)->NewObject(jenv, clazz, mid, $1, false);

(the $ are for swig)

What would be Mono/.net equivalent to FindClass and GetMethodID ?  Or
is this something completely different ?

I looked at Gtk# but couldn't find anything.



More information about the Mono-devel-list mailing list