diff --git a/trunk/Projects/SAMufasaGUI/testunit.pas b/trunk/Projects/SAMufasaGUI/testunit.pas index ad27e3f..9811ab6 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.pas +++ b/trunk/Projects/SAMufasaGUI/testunit.pas @@ -43,7 +43,7 @@ uses ColorBox , about, framefunctionlist, ocr, updateform, simbasettings; const - SimbaVersion = 501; + SimbaVersion = 521; type @@ -293,6 +293,7 @@ type procedure SpeedButtonSearchClick(Sender: TObject); procedure SplitterFunctionListCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean); + procedure TB_ReloadPluginsClick(Sender: TObject); procedure TrayPopupPopup(Sender: TObject); procedure TT_UpdateClick(Sender: TObject); procedure UpdateMenuButtonClick(Sender: TObject); @@ -445,6 +446,11 @@ begin NewSize := ScriptPanel.Width div 2; end; +procedure TForm1.TB_ReloadPluginsClick(Sender: TObject); +begin +// PluginsGlob.FreePlugins; +end; + procedure TForm1.TrayPopupPopup(Sender: TObject); begin MenuItemHide.enabled:= Form1.Visible; diff --git a/trunk/Units/MMLAddon/mmlpsthread.pas b/trunk/Units/MMLAddon/mmlpsthread.pas index f8d4594..685e588 100644 --- a/trunk/Units/MMLAddon/mmlpsthread.pas +++ b/trunk/Units/MMLAddon/mmlpsthread.pas @@ -494,6 +494,16 @@ begin Continue:= ProcessDirective(DirectiveName, DirectiveParam); end; +function Muf_Conv_to_PS_Conv( conv : integer) : TDelphiCallingConvention; +begin + case conv of + cv_StdCall : result := cdStdCall; + cv_Register: result := cdRegister; + else + raise exception.createfmt('Unknown Calling Convention[%d]',[conv]); + end; +end; + procedure TPSThread.OnCompile(Sender: TPSScript); var i,ii : integer; @@ -507,7 +517,8 @@ begin for i := high(PluginsToLoad) downto 0 do for ii := 0 to PluginsGlob.MPlugins[PluginsToLoad[i]].MethodLen - 1 do PSScript.AddFunctionEx(PluginsGlob.MPlugins[PluginsToLoad[i]].Methods[ii].FuncPtr, - PluginsGlob.MPlugins[PluginsToLoad[i]].Methods[ii].FuncStr, cdStdCall); + PluginsGlob.MPlugins[PluginsToLoad[i]].Methods[ii].FuncStr, + Muf_Conv_to_PS_Conv(PluginsGlob.MPlugins[PluginsToLoad[i]].Methods[ii].FuncConv)); for i := 0 to high(VirtualKeys) do PSScript.Comp.AddConstantN(Format('VK_%S',[VirtualKeys[i].Str]),'Byte').SetInt(VirtualKeys[i].Key); diff --git a/trunk/Units/MMLAddon/plugins.pas b/trunk/Units/MMLAddon/plugins.pas index c8bd112..94531f9 100644 --- a/trunk/Units/MMLAddon/plugins.pas +++ b/trunk/Units/MMLAddon/plugins.pas @@ -36,10 +36,14 @@ interface uses Classes, SysUtils, dynlibs, libloader; +const + cv_StdCall = 0; //StdCall + cv_Register = 1; //Register type TMPluginMethod = record FuncPtr : pointer; FuncStr : string; + FuncConv: integer; end; TMPlugin = record @@ -74,6 +78,7 @@ function TMPlugins.InitPlugin(plugin: TLibHandle): boolean; var pntrArrc : function : integer; stdcall; GetFuncInfo : function (x: Integer; var ProcAddr: Pointer; var ProcDef: PChar) : Integer; stdcall; + GetFuncConv : function (x: integer) : integer; stdcall; GetTypeCount : function : Integer; stdcall; GetTypeInfo : function (x: Integer; var sType, sTypeDef: string): Integer; stdcall; PD : PChar; @@ -81,9 +86,11 @@ var arrc, ii : integer; begin Pointer(pntrArrc) := GetProcAddress(plugin, PChar('GetFunctionCount')); - if @pntrArrc = nil then begin result:= false; exit; end; + if pntrArrc = nil then begin result:= false; exit; end; Pointer(GetFuncInfo) := GetProcAddress(plugin, PChar('GetFunctionInfo')); - if @GetFuncInfo = nil then begin result:= false; exit; end; + if GetFuncInfo = nil then begin result:= false; exit; end; + Pointer(GetFuncConv) := GetProcAddress(plugin,pchar('GetFunctionCallingConv')); + arrc := pntrArrc(); SetLength(Plugins,NumPlugins+1); Plugins[NumPlugins].MethodLen := Arrc; @@ -95,8 +102,13 @@ begin Continue; Plugins[NumPlugins].Methods[ii].FuncPtr := pntr; Plugins[NumPlugins].Methods[ii].FuncStr := pd; + if GetFuncConv <> nil then + Plugins[NumPlugins].Methods[ii].FuncConv := GetFuncConv(ii) + else + Plugins[NumPlugins].Methods[ii].FuncConv := cv_stdcall; end; StrDispose(pd); + inc(NumPlugins); result:= true; end;