aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk/PlatGTK.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/PlatGTK.cxx')
-rw-r--r--gtk/PlatGTK.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index aa0fb3659..d0778c707 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -9,6 +9,7 @@
#include <stddef.h>
#include <glib.h>
+#include <gmodule.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@@ -1918,6 +1919,41 @@ ElapsedTime::ElapsedTime() {
littleBit = curTime.tv_usec;
}
+class DynamicLibraryImpl : public DynamicLibrary {
+protected:
+ GModule* m;
+public:
+ DynamicLibraryImpl(const char *modulePath) {
+ m = g_module_open(modulePath, G_MODULE_BIND_LAZY);
+ }
+
+ virtual ~DynamicLibraryImpl() {
+ if (m != NULL)
+ g_module_close(m);
+ }
+
+ // Use g_module_symbol to get a pointer to the relevant function.
+ virtual Function *FindFunction(const char *name) {
+ if (m != NULL) {
+ gpointer fn_address = NULL;
+ gboolean status = g_module_symbol(m, name, &fn_address);
+ if (status)
+ return static_cast<Function*>( fn_address );
+ else
+ return NULL;
+ } else
+ return NULL;
+ }
+
+ virtual bool IsValid() {
+ return m != NULL;
+ }
+};
+
+DynamicLibrary *DynamicLibrary::Load(const char *modulePath) {
+ return static_cast<DynamicLibrary *>( new DynamicLibraryImpl(modulePath) );
+}
+
double ElapsedTime::Duration(bool reset) {
GTimeVal curTime;
g_get_current_time(&curTime);