Re-added the list. You should look at the documentation for TypeModule<http://valadoc.org/references/gobject-2.0/0.11.5/GLib.TypeModule.html>. Basically you subclass this, and implement the load/unload methods to use Module <http://valadoc.org/references/gmodule-2.0/0.11.5/GLib.Module.html>. In the load method you construct Module, and in unload you assign null to the member referencing it, causing an unref and deletion. That in turn unloads the actual code.
Next, the module you want to load and unload must have a method annotated with [ModuleInit], that is public, void and takes a TypeModule as a parameter. This is a trigger for the compiler to build a dynamic init function, instead of a static one. I'd suggest a suitable name, like 'module_init' for this. Build your new module like this: valac --pkg gmodule-2.0 --library=mymodule.so -C mymodule.vala gcc -shared -fPIC $(pkg-config --cflags --libs glib-2.0 gmodule-2.0) -o mymodule.so mymodule.c Next, in your load method (from earlier), use the method 'symbol' on Module (which you have just constructed) to lookup the init method, and invoke it. Like so: delegate void ModuleInit(TypeModule type_module); // Declare this outside of the method somewhere void* function; if (module.symbol("module_init", out function)) { ModuleInit module_init = (ModuleInit)function; module_init(this); // Assuming 'this' is your class that is a subclass of TypeModule } Then you want to load a module, construct your loader class and call 'use'. When you are done, call 'unuse'. Now for the caveat. You said that you want to re-load because the code has changed. Please read about g_type_module_register_type<http://developer.gnome.org/gobject/unstable/GTypeModule.html#g-type-module-register-type>. Infact, read the whole page, but that particular method holds the caveat. Essentially, once a module is loaded, in future loads the classes must come from the same instance of TypeModule, and conform to the same hierarchy. It's an important caveat if you are expecting the code to change. Oh, and another caveat. If you leave pointers into your module lying around, things will break badly. On 19 August 2011 17:15, Joseph Montanez <jmonta...@gorilla3d.com> wrote: > Reload the same module because it has changed. > > On Fri, Aug 19, 2011 at 3:53 AM, Michael Brown > <mich...@supersoftcafe.com> wrote: > > Do you mean reload the same module, or reload because it has changed? > > > > On 19 August 2011 07:19, Joseph Montanez <jmonta...@gorilla3d.com> > wrote: > >> > >> I was looking at http://live.gnome.org/Vala/TypeModules and tried > >> digging around Rygel but I couldn't find a way to reload a module. > >> > >> -- > >> Joseph Montanez > >> Web Developer > >> Gorilla3D > >> Design, Develop, Deploy > >> _______________________________________________ > >> vala-list mailing list > >> vala-list@gnome.org > >> http://mail.gnome.org/mailman/listinfo/vala-list > > > > > > > > -- > > Michael Brown > > > > Windows / Linux / Mac / iPhone / Android > > Java / C# / C / C++ / Objective-C > > From design to delivery > > > > Mobile: 07775620097 > > Telephone: 01206577456 > > Email: mich...@supersoftcafe.com > > > > > > -- > Joseph Montanez > Web Developer > Gorilla3D > Design, Develop, Deploy > -- Michael Brown Windows / Linux / Mac / iPhone / Android Java / C# / C / C++ / Objective-C >From design to delivery Mobile: 07775620097 Telephone: 01206577456 Email: mich...@supersoftcafe.com
_______________________________________________ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list