1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 18:52:15 -05:00

Added a way for plugins to expot functions non-stdcall (Might want to delete later, need it now because PS doesn't *fucking* work with StdCall).

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@521 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2010-02-04 23:32:24 +00:00
parent 3c571474a2
commit e358ab9a2a
3 changed files with 33 additions and 4 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;