[Lazarus] List the procedures of a object.

Everton Vieira tonvieira at gmail.com
Tue Mar 27 22:41:58 CEST 2012


I just did, the real case just saved me to do about 10.000 lines of code in
a very tedious job.

Became like this:

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
  M : TMethod;
  P: TProc;
begin
  M.Data := Pointer(Sender) ;
  M.Code := Sender.MethodAddress('Proc') ;
  P := TProc(M);
  P;
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 Michael Van Canneyt <michael at freepascal.org>

>
>
> On Tue, 27 Mar 2012, Marco van de Voort wrote:
>
>  On Tue, Mar 27, 2012 at 09:00:07PM +0200, Michael Van Canneyt wrote:
>>
>>>
>>>> 2010 actually. And since this list has been _very_ sensitive about bloat
>>>> recently, I would not even dare to suggest that way ;-)
>>>>
>>>
>>> I would.
>>>
>>> Under command of some switch, of course, it surely would come in handy.
>>>
>>> The rtti unit they made for it is of course totally convoluted, but the
>>> idea
>>> to be able to use introspection on all aspects of a class is definitely
>>> useful
>>> and would make RPC frameworks a breeze.
>>>
>>
>> That's roughly my opinion too, after a short read-up during D2010 times.
>> Never enable it globally only for certain classes in frameworks that
>> benefit
>> from it.  Haven't really used it yet though.
>>
>
> Well, I am using it - I'm exposing a JSON RPC through it.
>
> The 'only for certain classes' is my point of view as well.
>
> It would only be necessary for the classes that get exposed as data, and
> the interfaces.
>
> Michael.
>
>
> --
> ______________________________**_________________
> Lazarus mailing list
> Lazarus at lists.lazarus.**freepascal.org<Lazarus at lists.lazarus.freepascal.org>
> http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>
>



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


More information about the Lazarus mailing list