1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module glib.Module; 26 27 private import glib.Str; 28 private import gtkc.glib; 29 public import gtkc.glibtypes; 30 31 32 /** 33 * The #GModule struct is an opaque data structure to represent a 34 * [dynamically-loaded module][glib-Dynamic-Loading-of-Modules]. 35 * It should only be accessed via the following functions. 36 */ 37 public class Module 38 { 39 /** the main Gtk struct */ 40 protected GModule* gModule; 41 42 /** Get the main Gtk struct */ 43 public GModule* getModuleStruct() 44 { 45 return gModule; 46 } 47 48 /** the main Gtk struct as a void* */ 49 protected void* getStruct() 50 { 51 return cast(void*)gModule; 52 } 53 54 /** 55 * Sets our main struct and passes it to the parent class. 56 */ 57 public this (GModule* gModule) 58 { 59 this.gModule = gModule; 60 } 61 62 /** 63 */ 64 65 /** 66 * Closes a module. 67 * 68 * Return: %TRUE on success 69 */ 70 public bool close() 71 { 72 return g_module_close(gModule) != 0; 73 } 74 75 /** 76 * Ensures that a module will never be unloaded. 77 * Any future g_module_close() calls on the module will be ignored. 78 */ 79 public void makeResident() 80 { 81 g_module_make_resident(gModule); 82 } 83 84 /** 85 * Returns the filename that the module was opened with. 86 * 87 * If @module refers to the application itself, "main" is returned. 88 * 89 * Return: the filename of the module 90 */ 91 public string name() 92 { 93 return Str.toString(g_module_name(gModule)); 94 } 95 96 /** 97 * Gets a symbol pointer from a module, such as one exported 98 * by #G_MODULE_EXPORT. Note that a valid symbol can be %NULL. 99 * 100 * Params: 101 * symbolName = the name of the symbol to find 102 * symbol = returns the pointer to the symbol value 103 * 104 * Return: %TRUE on success 105 */ 106 public bool symbol(string symbolName, void** symbol) 107 { 108 return g_module_symbol(gModule, Str.toStringz(symbolName), symbol) != 0; 109 } 110 111 /** 112 * A portable way to build the filename of a module. The platform-specific 113 * prefix and suffix are added to the filename, if needed, and the result 114 * is added to the directory, using the correct separator character. 115 * 116 * The directory should specify the directory where the module can be found. 117 * It can be %NULL or an empty string to indicate that the module is in a 118 * standard platform-specific directory, though this is not recommended 119 * since the wrong module may be found. 120 * 121 * For example, calling g_module_build_path() on a Linux system with a 122 * @directory of `/lib` and a @module_name of "mylibrary" will return 123 * `/lib/libmylibrary.so`. On a Windows system, using `\Windows` as the 124 * directory it will return `\Windows\mylibrary.dll`. 125 * 126 * Params: 127 * directory = the directory where the module is. This can be 128 * %NULL or the empty string to indicate that the standard platform-specific 129 * directories will be used, though that is not recommended 130 * moduleName = the name of the module 131 * 132 * Return: the complete path of the module, including the standard library 133 * prefix and suffix. This should be freed when no longer needed 134 */ 135 public static string buildPath(string directory, string moduleName) 136 { 137 return Str.toString(g_module_build_path(Str.toStringz(directory), Str.toStringz(moduleName))); 138 } 139 140 /** 141 * Gets a string describing the last module error. 142 * 143 * Return: a string describing the last module error 144 */ 145 public static string error() 146 { 147 return Str.toString(g_module_error()); 148 } 149 150 /** 151 * Opens a module. If the module has already been opened, 152 * its reference count is incremented. 153 * 154 * First of all g_module_open() tries to open @file_name as a module. 155 * If that fails and @file_name has the ".la"-suffix (and is a libtool 156 * archive) it tries to open the corresponding module. If that fails 157 * and it doesn't have the proper module suffix for the platform 158 * (#G_MODULE_SUFFIX), this suffix will be appended and the corresponding 159 * module will be opended. If that fails and @file_name doesn't have the 160 * ".la"-suffix, this suffix is appended and g_module_open() tries to open 161 * the corresponding module. If eventually that fails as well, %NULL is 162 * returned. 163 * 164 * Params: 165 * fileName = the name of the file containing the module, or %NULL 166 * to obtain a #GModule representing the main program itself 167 * flags = the flags used for opening the module. This can be the 168 * logical OR of any of the #GModuleFlags 169 * 170 * Return: a #GModule on success, or %NULL on failure 171 */ 172 public static Module open(string fileName, GModuleFlags flags) 173 { 174 auto p = g_module_open(Str.toStringz(fileName), flags); 175 176 if(p is null) 177 { 178 return null; 179 } 180 181 return new Module(cast(GModule*) p); 182 } 183 184 /** 185 * Checks if modules are supported on the current platform. 186 * 187 * Return: %TRUE if modules are supported 188 */ 189 public static bool supported() 190 { 191 return g_module_supported() != 0; 192 } 193 }