Delphi parte:¿Cómo pasar el objeto interconectado a la llamada a la función Pascal Script?
tengo una clase con el evento y de ese evento que tiene que llamar a un procedimiento pasando el objeto de interfaz con él. Funciona bien en Delphi, pero tengo problemas para declararlo en Pascal Script.
Para el fondo - la interfaz IGPGraphics
es una parte de la Delphi GDI+ library
y sin métodos se define así:
type
IGdiplusBase = interface
['{24A5D3F5-4A9B-42A2-9F60-20825E2740F5}']
IGPGraphics = interface(IGdiPlusBase)
['{57F85BA4-CB01-4466-8441-948D03588F54}']
El siguiente es sólo un pseudocódigo Delphi simplificada de lo que tengo que hacer en Pascal Script:
type
TRenderEvent = procedure(Sender: TObject; const GPGraphics: IGPGraphics) of object;
TRenderClass = class(TGraphicControl)
private
FOnRender: TRenderEvent;
public
property OnRender: TRenderEvent read FOnRender write FOnRender;
end;
// when the TRenderClass object instance fires its OnRender event I want to call
// the RenderObject procedure passing the IGPGraphics interfaced object to it; I
// hope I'm doing it right, I'm just a newbie to this stuff - but it works so far
// in Delphi (since I didn't get it to work in Pascal Script)
procedure TForm1.RenderClass1Render(Sender: TObject; const GPGraphics: IGPGraphics);
begin
RenderObject(GPGraphics, 10, 10);
end;
// what I need in Pascal Script is between these two lines; just pass the interface
// object from the event fired by component to the procedure called from inside it
procedure RenderObject(const GPGraphics: IGPGraphics; X, Y);
begin
// and here to work with the interfaced object somehow
end;
Pascal script parte compilación:
Mi objetivo es tener la clase con evento disponible en Pascal Script y necesito pasar ese objeto interconectado a ese procedimiento como el anterior, por lo que el primero que he intentado declarar para el tiempo de compilación esto (pero no estoy seguro si esa es la forma correcta de hacerlo):
// the interface
PS.AddInterface(Cl.FindInterface('IUnknown'), StringToGuid('{57F85BA4-CB01-4466-8441-948D03588F54}'), 'IGPGraphics');
// the type for the event
PS.AddTypeS('TRenderEvent', 'procedure(Sender: TObject; const GPGraphics: IGPGraphics)');
// and the class with the event itself
with PS.AddClassN(PS.FindClass('TGraphicControl'), 'TRenderClass') do
begin
RegisterProperty('OnRender', 'TRenderEvent', iptrw);
end;
Pascal parte de secuencias de comandos en tiempo de ejecución:
Dónde estoy perdido definitivamente es la parte de tiempo de ejecución. No puedo encontrar la manera de obtener el objeto de interfaz de la pila de llamadas y pasarlo a mi procedimiento RenderObject:
function RenderClassProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global,
Stack: TPSStack): Boolean;
var
PStart: Cardinal;
begin
PStart := Stack.Count-1;
Result := True;
if Proc.Name = 'RENDEROBJECT' then
begin
// how do I get the interfaced object from Stack (or whatever else) and pass
// it to the RenderObject proc here ? I can't find anything related about it
// except functions that has no parameter index
RenderObject(Stack.Get ?, Stack.GetInt(PStart-2), Stack.GetInt(PStart-3));
end;
end;
y la pregunta es:
Puede alguien me sugieren cómo ¿Definir correctamente la compilación y la parte del tiempo de ejecución para este caso o corregirme pasando el objeto interconectado de alguna manera?
P.S. perdón por esa etiqueta Inno-Setup, pero tal vez alguien desde allí intentó personalizar InnoSetup de esta manera.
¡Muchas gracias!