|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Gobject and c++ types.Hello. I'm trying to implement a system that works in a perfect way
with the GObject C library, so that things are easier to integrate c++ classes in tools that use the metadata from GObject, like glade. Maybe when I finish this, I could send it here to be able to integrate it with glibmm and improve the object model. My system must allow to register (yes, with macros, no other way) properties, gobjects and signals, etc. So for now, what I can do is the following: class MyClass : public glib::object { };... GLIB_REGISTER_CLASS(MyClass, glib::object); int main(int argc, char * argv[]) { MyClass * c = (MyClass *)g_type_new(g_type_from_name("MyClass", NULL)); c->method(); } My problem is that now I want to install properties and use them. In order for properties to work well in C programs (like glade), they should be able to be set from GObject: g_object_set(G_OBJECT(c), "Prop", value); My problem is that G_OBJECT macro fails with the following: GLib-GObject-CRITICAL **: g_object_set: assertion `G_IS_OBJECT (object)' failed But if I query this: g_type_is_a(g_type_from_name("MyClass"), G_TYPE_OBJECT) it returns 1. So I want to know why this fails in order to solve the problem. I'm stuck here for now. I use InstanceInit from GTypeInfo to call the c++ constructor, and class_init from GTypeInfo to install properties. But the casting fails and I don't know why. Thanks in advance. _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: Gobject and c++ types.On Thu, 2009-11-05 at 14:02 +0100, Germán Diago wrote:
> Hello. I'm trying to implement a system that works in a perfect way > with the GObject C library, so that things are easier to integrate > c++ classes in tools that use the metadata from GObject, like glade. > > Maybe when I finish this, I could send it here to be able to integrate it > with glibmm and improve the object model. > > My system must allow to register (yes, with macros, no other way) properties, > gobjects and signals, etc. So for now, what I can do is the following: > > class MyClass : public glib::object { > > };... > > > GLIB_REGISTER_CLASS(MyClass, glib::object); class MyClass : Glib::Object { }; MyClass::MyClass : Glib::ObjectBase("myclassname") { } will also register a derived GType. -- murrayc@... www.murrayc.com www.openismus.com _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
|
|
|
|
|
|
Re: Gobject and c++ types.> Just reading this and thinking about it, it occured to me that there is a
> rather uncumbersome way, similar to propertyproxy, by which we can have > automatically C and C++ signals Maybe I can try some of the above. I have a doubt about wrapping Gobjects from c++ (for now I'm trying my own implementation of Glib::Object too) I have class glib::object { GObject parent_class; public: .... }; class MyClass : public glib::object { .... }; My problem is that if I make my destructors virtual (which I do want to do), then: GObject * obj = G_OBJECT(g_type_new(g_type_from_name("MyClass"), NULL)); G_OBJECT casting won't work. I think it's because with a vtable, the layout for the type changes, but I don't know how to workaround this and keep G_OBJECT macro working, which is very important for C compatibility and exposure. _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
| Free embeddable forum powered by Nabble | Forum Help |