[Lazarus] List the procedures of a object.

Everton Vieira tonvieira at gmail.com
Tue Mar 27 19:23:18 CEST 2012


Well, i manage to 'find' the procedure now is giving the SIGSEV when
is executed.

For the MethodAddress finds was need to be published.

unit Unit1;
{$mode objfpc}{$M+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TTeste }
TTeste = class
published
procedure Proc;
end;
type
 { TForm1 }
 TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
type
TProc = procedure of object;
implementation
procedure DoProc(Sender: TObject);
var
Proc: TProc;
begin
Proc := TProc(Sender.MethodAddress('Proc')^);
Proc; <-- Aqui gera o SIGSEV
end;
{ TTeste }
procedure TTeste.Proc;
begin
ShowMessage('oi');
end;
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
DoProc(TTeste.Create);
end;
end.

2012/3/27 Everton Vieira <tonvieira at gmail.com>

> I need to execute an procedure of an object if his exists, i'm doing some
> tests and get into this, but this is generating an SIGSEV:
>
> unit Unit1;
>
> {$mode objfpc}{$H+}
>
> interface
>
> uses
>   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
> StdCtrls;
>
> type
>   { TTeste }
>   TTeste = class
>     procedure Proc;
>   end;
>
> type
>   { TForm1 }
>   TForm1 = class(TForm)
>     Button1: TButton;
>     procedure Button1Click(Sender: TObject);
>   private
>     { private declarations }
>   public
>     { public declarations }
>   end;
>
> var
>   Form1: TForm1;
>
> type
>   TProc = procedure of object;
>
> implementation
>
> procedure DoProc(Sender: TObject);
> var
>   Proc: TProc;
> begin
>   Proc := TProc(Sender.MethodAddress('Proc')^);
>   Proc;
> end;
>
> { TTeste }
> procedure TTeste.Proc;
> begin
>   ShowMessage('oi');
> end;
>
> {$R *.lfm}
>
> { TForm1 }
> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   DoProc(TTeste.Create);
> end;
>
> end.
>
>
>
>
> 2012/3/27 Everton Vieira <tonvieira at gmail.com>
>
>> Is there any how to list the procedures of a object?
>> Att.
>> Everton Vieira.
>>
>
>
>
> --
> Everton Vieira.
>



-- 
Everton Vieira.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120327/ab3fadbd/attachment-0003.html>


More information about the Lazarus mailing list