comparison dwt/dwthelper/Loader.d @ 238:380bad9f6852

reverted char[] to String
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:42:55 +0200
parents 384b3a0c9cd7
children
comparison
equal deleted inserted replaced
237:98b80b00af79 238:380bad9f6852
17 an early version of mango 17 an early version of mango
18 18
19 ******************************************************************************/ 19 ******************************************************************************/
20 20
21 module dwt.dwthelper.Loader; 21 module dwt.dwthelper.Loader;
22
23 import dwt.dwthelper.utils;
22 24
23 private import tango.io.Stdout, 25 private import tango.io.Stdout,
24 tango.sys.SharedLib; 26 tango.sys.SharedLib;
25 27
26 /***************************************************************************** 28 /*****************************************************************************
55 57
56 *****************************************************************************/ 58 *****************************************************************************/
57 59
58 version (Windows) 60 version (Windows)
59 { 61 {
60 const char[][LIBRARY.max+1] importLibs = [ 62 const String[LIBRARY.max+1] importLibs = [
61 LIBRARY.ATK: "libatk-1.0-0.dll", 63 LIBRARY.ATK: "libatk-1.0-0.dll",
62 LIBRARY.CAIRO: "libcairo-2.dll", 64 LIBRARY.CAIRO: "libcairo-2.dll",
63 LIBRARY.GDK: "libgdk-win32-2.0-0.dll", 65 LIBRARY.GDK: "libgdk-win32-2.0-0.dll",
64 LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0-0.dll", 66 LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0-0.dll",
65 LIBRARY.GLIB: "libglib-2.0-0.dll", 67 LIBRARY.GLIB: "libglib-2.0-0.dll",
84 86
85 *****************************************************************************/ 87 *****************************************************************************/
86 88
87 version(linux) 89 version(linux)
88 { 90 {
89 const char[][LIBRARY.max+1] importLibs = [ 91 const String[LIBRARY.max+1] importLibs = [
90 LIBRARY.ATK: "libatk-1.0.so", 92 LIBRARY.ATK: "libatk-1.0.so",
91 LIBRARY.CAIRO: "libcairo.so.2", 93 LIBRARY.CAIRO: "libcairo.so.2",
92 LIBRARY.GDK: "libgdk-x11-2.0.so", 94 LIBRARY.GDK: "libgdk-x11-2.0.so",
93 LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0.so", 95 LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0.so",
94 LIBRARY.GLIB: "libglib-2.0.so", 96 LIBRARY.GLIB: "libglib-2.0.so",
117 ******************************************************************************/ 119 ******************************************************************************/
118 120
119 121
120 version(Windows) 122 version(Windows)
121 { 123 {
122 char[] getLibraryPath() 124 String getLibraryPath()
123 { 125 {
124 return "\\Program Files\\GTK2-Runtime\\lib\\"; 126 return "\\Program Files\\GTK2-Runtime\\lib\\";
125 } 127 }
126 } 128 }
127 129
131 133
132 ******************************************************************************/ 134 ******************************************************************************/
133 135
134 version(linux) 136 version(linux)
135 { 137 {
136 char[] getLibraryPath() { return ""; } 138 String getLibraryPath() { return ""; }
137 } 139 }
138 140
139 /***************************************************************************** 141 /*****************************************************************************
140 142
141 ProcLink is used to record the library, function, and function name 143 ProcLink is used to record the library, function, and function name
143 145
144 ******************************************************************************/ 146 ******************************************************************************/
145 147
146 public struct Symbol 148 public struct Symbol
147 { 149 {
148 char[] name; 150 String name;
149 void** pointer; 151 void** pointer;
150 } 152 }
151 153
152 /***************************************************************************** 154 /*****************************************************************************
153 155
155 157
156 ******************************************************************************/ 158 ******************************************************************************/
157 159
158 public class Linker 160 public class Linker
159 { 161 {
160 static char[][][char[]] loadFailures; 162 static String[][String] loadFailures;
161 163
162 /************************************************************************* 164 /*************************************************************************
163 165
164 Gets all the failed loads for a specific library. This is filled in 166 Gets all the failed loads for a specific library. This is filled in
165 only if the default onFailure method is used during load. 167 only if the default onFailure method is used during load.
167 returns: an array of the names that failed to load for a specific 169 returns: an array of the names that failed to load for a specific
168 library or null if none was found. 170 library or null if none was found.
169 171
170 **************************************************************************/ 172 **************************************************************************/
171 173
172 public static char[][] getLoadFailures(char[] libName) 174 public static String[] getLoadFailures(String libName)
173 { 175 {
174 if ( libName in loadFailures ) 176 if ( libName in loadFailures )
175 { 177 {
176 return loadFailures[libName]; 178 return loadFailures[libName];
177 } 179 }
188 190
189 returns: an array of the library names. 191 returns: an array of the library names.
190 192
191 **************************************************************************/ 193 **************************************************************************/
192 194
193 public static char[][] getLoadLibraries() 195 public static String[] getLoadLibraries()
194 { 196 {
195 return loadFailures.keys; 197 return loadFailures.keys;
196 } 198 }
197 199
198 /************************************************************************* 200 /*************************************************************************
211 213
212 **************************************************************************/ 214 **************************************************************************/
213 215
214 public static void dumpFailedLoads() 216 public static void dumpFailedLoads()
215 { 217 {
216 foreach ( char[] lib ; Linker.getLoadLibraries() ) 218 foreach ( String lib ; Linker.getLoadLibraries() )
217 { 219 {
218 foreach ( char[] symbol ; Linker.getLoadFailures(lib) ) 220 foreach ( String symbol ; Linker.getLoadFailures(lib) )
219 { 221 {
220 version(Tango) 222 version(Tango)
221 Stdout.formatln("failed ({}) {}", lib, symbol).newline; 223 Stdout.formatln("failed ({}) {}", lib, symbol).newline;
222 } 224 }
223 } 225 }
228 **************************************************************************/ 230 **************************************************************************/
229 231
230 private SharedLib primaryLib; 232 private SharedLib primaryLib;
231 private SharedLib alternateLib; 233 private SharedLib alternateLib;
232 234
233 private char[] libraryName; 235 private String libraryName;
234 private char[] alternateLibraryName; 236 private String alternateLibraryName;
235 237
236 alias void function( char[] libraryName, char[] symbolName, char[] message=null) FailureCallback; 238 alias void function( String libraryName, String symbolName, String message=null) FailureCallback;
237 239
238 private FailureCallback onLoadFailure; 240 private FailureCallback onLoadFailure;
239 241
240 /************************************************************************* 242 /*************************************************************************
241 243
242 **************************************************************************/ 244 **************************************************************************/
243 245
244 this( char[] libraryName, char[] alternateLibraryName=null ) 246 this( String libraryName, String alternateLibraryName=null )
245 { 247 {
246 this(libraryName, alternateLibraryName, &(Linker.defaultFail)); 248 this(libraryName, alternateLibraryName, &(Linker.defaultFail));
247 } 249 }
248 250
249 /************************************************************************* 251 /*************************************************************************
250 252
251 **************************************************************************/ 253 **************************************************************************/
252 254
253 this (char[] libraryName, char[] alternateLibraryName, FailureCallback fn ) 255 this (String libraryName, String alternateLibraryName, FailureCallback fn )
254 { 256 {
255 this.libraryName = libraryName; 257 this.libraryName = libraryName;
256 this.alternateLibraryName = alternateLibraryName; 258 this.alternateLibraryName = alternateLibraryName;
257 onLoadFailure = fn; 259 onLoadFailure = fn;
258 260
281 283
282 Default load failure callback. Logs the symbols that failed to load. 284 Default load failure callback. Logs the symbols that failed to load.
283 285
284 **************************************************************************/ 286 **************************************************************************/
285 287
286 static void defaultFail( char[] libraryName, char[] symbolName, char[] message=null ) 288 static void defaultFail( String libraryName, String symbolName, String message=null )
287 { 289 {
288 if ( !(libraryName in loadFailures) ) 290 if ( !(libraryName in loadFailures) )
289 { 291 {
290 char[][] cc; 292 String[] cc;
291 loadFailures[libraryName] = cc; 293 loadFailures[libraryName] = cc;
292 } 294 }
293 295
294 loadFailures[libraryName] ~= symbolName.dup; 296 loadFailures[libraryName] ~= symbolName.dup;
295 } 297 }