From 67ebb5625577ec4b849d8ea4aec11f4b0fb98507 Mon Sep 17 00:00:00 2001 From: Merlijn Wajer Date: Tue, 28 Sep 2010 16:23:30 +0200 Subject: [PATCH] MMLCore: Multi platform library loading. If Simba cannot load a plugin a.dll, it will look for a plugin called a32.dll (or a64.dll) depending on the platform and try to load it. --- Units/MMLCore/libloader.pas | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Units/MMLCore/libloader.pas b/Units/MMLCore/libloader.pas index cfa7cac..cb4a738 100644 --- a/Units/MMLCore/libloader.pas +++ b/Units/MMLCore/libloader.pas @@ -23,6 +23,7 @@ interface procedure FreePlugins; procedure LoadPluginsDir(DirIndex : integer); function VerifyPath(Path : string) : string; + function LoadPluginNoFallback(PluginName : string) : integer; protected function InitPlugin(plugin: TLibHandle): boolean; virtual; abstract; public @@ -113,8 +114,7 @@ implementation end; end; - - function TGenericLoader.LoadPlugin(PluginName: string): Integer; + function TGenericLoader.LoadPluginNoFallback(PluginName: string): Integer; var i, ii : integer; PlugExt: String = {$IFDEF LINUX}'.so';{$ELSE}'.dll';{$ENDIF} @@ -151,6 +151,19 @@ implementation end; + function TGenericLoader.LoadPlugin(PluginName: string): Integer; + var + CpuBits: String = {$IFDEF CPU32}'32';{$ELSE}'64';{$ENDIF} + begin + try + Result := LoadPluginNoFallback(PluginName); + except + on exception do Result:= LoadPluginNoFallback(PluginName+CpuBits); + end; + + end; + + constructor TGenericLoader.Create; begin inherited Create;