class definition
authorClaus Gittinger <cg@exept.de>
Sun, 15 Apr 2012 18:58:21 +0200
changeset 14103 3df000b77712
parent 14102 93c008b8e304
child 14104 2c06d704086a
class definition added: #dllMapping changed: #linkToModule #loadLibrary:
ExternalLibraryFunction.st
--- a/ExternalLibraryFunction.st	Sat Apr 14 20:01:08 2012 +0200
+++ b/ExternalLibraryFunction.st	Sun Apr 15 18:58:21 2012 +0200
@@ -16,7 +16,7 @@
 	classVariableNames:'DLLPATH FLAG_VIRTUAL FLAG_NONVIRTUAL FLAG_ASYNC
 		FLAG_UNLIMITEDSTACK FLAG_RETVAL_IS_CONST CALLTYPE_MASK
 		CALLTYPE_API CALLTYPE_C CALLTYPE_OLE CALLTYPE_V8 CALLTYPE_V9
-		CALLTYPE_UNIX64'
+		CALLTYPE_UNIX64 DllMapping'
 	poolDictionaries:''
 	category:'System-Support'
 !
@@ -184,6 +184,24 @@
     ]
 !
 
+dllMapping
+    "allows for dll's to be replaced,
+     for example, if you want to use the mozilla sqlite dll
+        C:\Program Files\Mozilla Firefox\mozsqlite3.dll
+     for the sqlite3, execute:
+        ExternalLibraryFunction 
+            dllMapping at:'sqlite3'
+            put: 'C:\Program Files\Mozilla Firefox\mozsqlite3.dll'
+    "
+
+    DllMapping isNil ifTrue:[
+        DllMapping := Dictionary new.
+    ].
+    ^ DllMapping
+
+    "Created: / 10-04-2012 / 12:21:45 / cg"
+!
+
 dllPath
     ^ DLLPATH
 !
@@ -600,7 +618,7 @@
     moduleHandle isNil ifTrue:[
         handle := self loadLibrary:moduleNameUsed.
         handle isNil ifTrue:[
-            self error:('Cannot load module: "%1"' bindWith: moduleNameUsed).
+            self error:('Cannot load dll/module: "%1"' bindWith: moduleNameUsed).
         ].
         moduleHandle := handle.
     ].
@@ -616,14 +634,18 @@
         ].
     ].
 
-    "Modified: / 01-08-2006 / 16:24:14 / cg"
-    "Modified (comment): / 07-10-2011 / 16:43:11 / cg"
+    "Modified: / 10-04-2012 / 12:12:44 / cg"
 !
 
 loadLibrary:dllName
     |handle nameString filename|
 
-    filename := dllName asFilename.
+    filename := dllName.
+    DllMapping notNil ifTrue:[
+        filename := DllMapping at:filename ifAbsent:[ filename ]
+    ].
+
+    filename := filename asFilename.
     nameString := filename name.
 
     "try to load, maybe the system knows where to find the dll"
@@ -653,6 +675,8 @@
     ].
 
     ^ nil
+
+    "Modified: / 10-04-2012 / 12:21:06 / cg"
 !
 
 prepareInvoke
@@ -1604,7 +1628,7 @@
 !ExternalLibraryFunction class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalLibraryFunction.st,v 1.85 2012-03-01 15:22:21 mb Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalLibraryFunction.st,v 1.86 2012-04-15 16:58:21 cg Exp $'
 !
 
 version_SVN