Permalink
Browse files

Merge pull request #95 from BenLand100/master

EIOS Fixes/Updates
  • Loading branch information...
2 parents 4da2790 + 529f20d commit 5b8e936ecd61269f68a9d2a8ddd7ec0bc94b63d8 @MerlijnWajer MerlijnWajer committed Mar 20, 2012
@@ -15,7 +15,7 @@ end;
procedure Lape_SetEIOSTarget(const Params: PParamArray; const Result: Pointer);
begin
- Pinteger(Result)^ := ps_SetEIOSTarget(Pstring(Params^[0])^, PVariant(Params^[1])^);
+ Pinteger(Result)^:= CurrThread.Client.IOManager.SetTarget(Pstring(Params^[0])^, Pstring(Params^[1])^);
end;
procedure Lape_SetImageTarget(const Params: PParamArray);
@@ -477,7 +477,7 @@ AddGlobalFunc('function CopyATPA(const ATPA: T2DPointArray): T2DPointArray', @La
AddGlobalFunc('procedure SetDesktopAsClient;', @Lape_SetDesktopAsClient);
AddGlobalFunc('function SetTargetArray(P: Integer; w, h: integer): integer', @Lape_SetTargetArray);
AddGlobalFunc('function SetTargetBitmap(bitmap: Integer): integer', @Lape_SetTargetBitmap);
-AddGlobalFunc('function SetEIOSTarget(name: string; args: Variant): integer', @Lape_SetEIOSTarget);
+AddGlobalFunc('function SetEIOSTarget(name, args: String): integer', @Lape_SetEIOSTarget);
AddGlobalFunc('procedure SetImageTarget(idx: integer);', @Lape_SetImageTarget);
AddGlobalFunc('procedure SetKeyMouseTarget(idx: integer);', @Lape_SetKeyMouseTarget);
AddGlobalFunc('function GetImageTarget: integer', @Lape_GetImageTarget);
@@ -336,7 +336,7 @@ AddGlobalFunc('function CopyATPA(const ATPA: T2DPointArray): T2DPointArray', @La
AddGlobalFunc('procedure SetDesktopAsClient;', @Lape_SetDesktopAsClient);
AddGlobalFunc('function SetTargetArray(P: Integer; w, h: integer): integer', @Lape_SetTargetArray);
AddGlobalFunc('function SetTargetBitmap(bitmap: Integer): integer', @Lape_SetTargetBitmap);
-AddGlobalFunc('function SetEIOSTarget(name: string; args: Variant): integer', @Lape_SetEIOSTarget);
+AddGlobalFunc('function SetEIOSTarget(name, args: String): integer', @Lape_SetEIOSTarget);
AddGlobalFunc('procedure SetImageTarget(idx: integer);', @Lape_SetImageTarget);
AddGlobalFunc('procedure SetKeyMouseTarget(idx: integer);', @Lape_SetKeyMouseTarget);
AddGlobalFunc('function GetImageTarget: integer', @Lape_GetImageTarget);
@@ -36,9 +36,9 @@ begin;
result:= CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps[Bitmap]);
end;
-function ps_SetEIOSTarget(name: string; args: Variant): integer; extdecl;
+function ps_SetEIOSTarget(name, args: String): integer; extdecl;
begin
- result:= CurrThread.Client.IOManager.SetTarget(name, @args);
+ result:= CurrThread.Client.IOManager.SetTarget(name, args);
end;
procedure ps_SetImageTarget(idx: integer); extdecl;
@@ -124,7 +124,7 @@ AddFunction(@ps_GetClientDimensions, 'procedure GetClientDimensions(var w, h:int
AddFunction(@ps_GetClientPosition, 'procedure GetClientPosition(var left, top:integer);');
AddFunction(@ps_SetTargetBitmap,'function SetTargetBitmap(Bitmap : integer): integer;');
AddFunction(@ps_SetTargetArray, 'function SetTargetArray(P: Integer; w, h: integer): integer;');
-AddFunction(@ps_SetEIOSTarget, 'function SetEIOSTarget(name: string; initargs: Variant): integer;');
+AddFunction(@ps_SetEIOSTarget, 'function SetEIOSTarget(name, initargs: String): integer;');
AddFunction(@ps_SetImageTarget,'procedure SetImageTarget(idx: integer);');
AddFunction(@ps_SetKeyMouseTarget,'procedure SetKeyMouseTarget(idx: integer);');
AddFunction(@ps_GetImageTarget,'function GetImageTarget: integer;');
@@ -15,7 +15,7 @@ end;
procedure RUTIS_ps_SetEIOSTarget(Params: PRutisParamInfoArray; Result: PRutisParamInfo);
begin
- Pinteger(Result^.Data)^ := ps_SetEIOSTarget(Pstring(Params^[0].Data)^, PVariant(Params^[1].Data)^);
+ Pinteger(Result^.Data)^ := ps_SetEIOSTarget(Pstring(Params^[0].Data)^, Pstring(Params^[1].Data)^);
end;
procedure RUTIS_ps_SetImageTarget(Params: PRutisParamInfoArray; Result: PRutisParamInfo);
@@ -135,7 +135,7 @@ TWindow_Abstract = class(TTarget)
| finalized that is. Trust me, its >9000 times easier to use a buffer across the language
| barrier. And the internal target implementation of EIOS will make that verry efficient. }
TEIOS_Client = record
- RequestTarget: function(initdata: pointer): pointer; stdcall;
+ RequestTarget: function(initdata: PChar): pointer; stdcall;
ReleaseTarget: procedure(target: pointer); stdcall;
GetTargetDimensions: procedure(target: pointer; var w, h: integer); stdcall;
@@ -169,7 +169,7 @@ TEIOS_Client = record
TEIOS_Target = class(TTarget)
public
- constructor Create(client: TEIOS_Client; initval: pointer);
+ constructor Create(client: TEIOS_Client; initval: String);
destructor Destroy; override;
procedure GetTargetDimensions(out w, h: integer); override;
@@ -195,13 +195,6 @@ TEIOS_Target = class(TTarget)
buffer: prgb32;
width,height: integer;
end;
-
- { EIOS Clients will give an exported name, have a loaded library associated, and have
- | a TEIOS_Client with the method pointers set. }
- type TEIOS_LoadedPlugin = record
- name: string;
- client: TEIOS_Client;
- end;
{ This is just a class that loads EIOS clients (like SMART) and sets them up to be used
| as targets. I hope to have a method like...
@@ -222,8 +215,8 @@ TEIOS_Controller = class(TGenericLoader)
protected
function InitPlugin(plugin: TLibHandle): boolean; override;
private
- plugs: array of TEIOS_LoadedPlugin;
- function FindClient(name:string): integer;
+ clients: array of TEIOS_Client;
+ function FindClient(name: string): integer;
end;
{Basically like TEIOS_Client, only this is exported to some plugin, whilst TEIOS_Client is Imported
@@ -275,7 +268,7 @@ TIOManager_Abstract = class(TObject)
procedure SetDesktop; virtual; abstract;
function SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; overload;
function SetTarget(bmp : TMufasaBitmap) : integer; overload;
- function SetTarget(name: string; initargs: pointer): integer; overload;
+ function SetTarget(name, initargs: string): integer; overload;
function TargetValid: Boolean;
procedure BitmapDestroyed(Bitmap : TMufasaBitmap);
@@ -578,7 +571,7 @@ function TIOManager_Abstract.SetTarget(bmp : TMufasaBitmap) : integer;
bmp.OnDestroy:= @BitmapDestroyed;
end;
-function TIOManager_Abstract.SetTarget(name: string; initargs: pointer): integer;
+function TIOManager_Abstract.SetTarget(name, initargs: String): integer;
var
client: TEIOS_Client;
begin
@@ -811,11 +804,14 @@ function TTarget.GetKeyCode(C: char): integer;
//***implementation*** TEIOS_Target
-constructor TEIOS_Target.Create(client: TEIOS_Client; initval: pointer); begin
+constructor TEIOS_Target.Create(client: TEIOS_Client; initval: String); begin
inherited Create;
self.client:= client;
+ self.target:= nil;
if Pointer(client.RequestTarget) <> nil then
- self.target:= client.RequestTarget(initval);
+ self.target:= client.RequestTarget(PChar(initval));
+ if (self.target = nil) then
+ raise Exception.Create('Setting EIOS target failed.');
if Pointer(client.GetImageBuffer) <> nil then
self.buffer:= client.GetImageBuffer(target)
else
@@ -1036,26 +1032,18 @@ constructor TEIOS_Controller.Create();
destructor TEIOS_Controller.Destroy;
begin
- SetLength(plugs,0);
+ SetLength(clients,0);
inherited Destroy;
end;
function TEIOS_Controller.InitPlugin(plugin: TLibHandle): boolean;
var
- GetName: procedure(name: pchar); stdcall;
- buffer: pchar;
idx: integer;
begin
- Pointer(GetName) := GetProcAddress(plugin, PChar('EIOS_GetName'));
- if Pointer(GetName) = nil then begin result:= false; exit; end;
- idx:= Length(plugs);
- SetLength(plugs,idx+1);
- buffer:= stralloc(255);
- GetName(buffer);
- plugs[idx].name:= buffer;
- strdispose(buffer);
+ idx:= Length(clients);
+ SetLength(clients,idx+1);
{link in all eios methods that *might* exist}
- with plugs[idx].client do
+ with clients[idx] do
begin
Pointer(RequestTarget):= GetProcAddress(plugin, PChar('EIOS_RequestTarget'));
Pointer(ReleaseTarget):= GetProcAddress(plugin, PChar('EIOS_ReleaseTarget'));
@@ -1084,8 +1072,7 @@ function TEIOS_Controller.FindClient(name: string): integer;
var
i: integer;
begin
- i:= LoadPlugin(name);
- result:= -1;
+ result:= LoadPlugin(name);
end;
function TEIOS_Controller.ClientExists(name: string): boolean;
@@ -1099,7 +1086,7 @@ function TEIOS_Controller.GetClient(name: string): TEIOS_Client;
begin
i:= FindClient(name);
if i >= 0 then
- result:= plugs[i].client
+ result:= clients[i]
end;
//***implementation*** TEIS_Exported wrappers

0 comments on commit 5b8e936

Please sign in to comment.