Re: C++ and glue/gmodule



On Mon, 2006-08-14 at 10:32 +0200, Johannes Schmid wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi!
> 
> OK, I found out that I can use this glue stuff in C somehow but I need
> to call g_type_module_register_type () to register the plugin types
> somehow and I did not find a way to the GTypeInfo of the C++ class which
> is needed as an argument.

You might need to register a custom GType for your C++ class. The GType
system can not normally use C++ RTTI types. Look at the "custom"
examples to see how to do this.

This macro seems to define two library API functions that Anjuta can
call on each plugin library.
- glue_register_component(): It just instantiates the GType, so you can
just call 
YourClass::get_type().
- glue_get_component_type(): This seems to be a way for Anjuta to ask
all the plugin libraries whether they implement a certain GType (via
name). If this library does implement the GType (via name) then it
returns the actual GType.

> 
> Regards,
> Johannes
> 
> Johannes Schmid wrote:
> > Hi!
> > 
> > I am working on C++ wrapper for libanjuta which will allow it to write
> > Anjuta plugins in C++.
> > 
> > The last problem I have is that anjuta uses glue/gmodule to load plugins
> > and some weird macros in every plugin to export some symbols in the
> > plugins. How can I wrap this to C++ in a clean or at least in a working way.
> > 
> > All plugins derive from Anjuta::Plugin (AnjutaPlugin) and "activate()"
> > is called to activate them after the class has been created. But in
> > addition this macro is used for the gmodule mechanism:
> > 
> > #define ANJUTA_SIMPLE_PLUGIN(class_name, prefix)                      \
> > G_MODULE_EXPORT void glue_register_components (GluePlugin *plugin);   \
> > G_MODULE_EXPORT GType glue_get_component_type (GluePlugin *plugin, const
> > char *name); \
> > G_MODULE_EXPORT void                                                  \
> > glue_register_components (GluePlugin *plugin)                         \
> > {                                                                     \
> > 	prefix##_get_type (plugin);                                       \
> > }                                                                     \
> > G_MODULE_EXPORT GType                                                 \
> > glue_get_component_type (GluePlugin *plugin, const char *name)        \
> > {                                                                     \
> > 	if (!strcmp (name, #class_name)) {                                \
> > 		return prefix##_get_type (plugin);                            \
> > 	} else {                                                          \
> > 		return G_TYPE_INVALID;                                        \
> > 	}                                                                 \
> > }
> > 
> > Thanks and regards,
> > Johannes
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFE4DUE7Dsf+G5b/WsRAqvnAJ9verggIszMZwJfGEch2zRE299/SwCdFe6d
> yGU0NNovAPvP0HPTuA+G/Jc=
> =ywn3
> -----END PGP SIGNATURE-----
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]