[lazarus] Multiplataform

Peter Vreman pfvreman at wins.uva.nl
Thu Jul 1 06:14:14 EDT 1999


> > Hello,
> > 
> > >It should be fixed now. at least the test programs we got from you, and our
> > >own, seem to work correctly. Get the latest version from CVS to test.
> > 
> > Are you sure? 
> > 
> > Having;
> > 
> > type
> >   TProcedureOfObject = procedure of object;
> > 
> > Will this work?
> > 
> > procedure Blah( a: TProcedureOfObject );
> 
> Most definitely. : the following crucial test programs work:
> 
> --------------------8<-----------------------
> {$MODE objfpc}
> 
> program procofobject_arg;
> type
>   TProcOfObject = procedure of object;
>   TTestClass = class
>     constructor Create;
>     procedure SomeMethod;
>   end;
> 
> 
> procedure CrashProc(i1: Integer; method: TProcOfObject; i2: Integer);
> begin
>   WriteLn('i1 is :', i1);
>   method;
>   WriteLn('i2 is :', i2);
> end;
> 
> constructor TTestClass.Create;
> begin
>   CrashProc(123, @SomeMethod, 456);
> end;
> 
> procedure TTestClass.SomeMethod;
> begin
>   WriteLn('In SomeMethod');
> end;
> 
> var
>   instance: TTestClass;
> begin
>   instance := TTestClass.Create;
> end.
> --------------------8<-----------------------
> 
> Output is:
> 
> home: >ppc386 testpo
> home: >testpo
> i1 is :123
> In SomeMethod
> i2 is :456
> home: >
> 
> And then the following program:
> 
> --------------------8<-----------------------
> {$MODE objfpc}
> 
> program procofobject_arg;
> type
>   TProcOfObject = procedure of object;
>   TTestClass = class
>     constructor Create;
>     procedure SomeMethod;
>   end;
> 
>   TProcOfObjectInternal = packed record
>     method: Pointer;
>     obj: TObject;
>   end;
> 
> 
> constructor TTestClass.Create;
> var
>   method: TProcOfObject;
> begin
>   method := @Self.SomeMethod;
>   WriteLn('In Constructor:');
>   WriteLn('  Self = ', Integer(Self));
>   WriteLn('  Method = ',
>     longint(TProcOfObjectInternal(method).method), '/',
>     longint(TProcOfObjectInternal(method).obj));
> end;
> 
> procedure TTestClass.SomeMethod;
> var
>   method: TProcOfObject;
> begin
>   method := @SomeMethod;
>   WriteLn('In SomeMethod:');
>   WriteLn('  Self = ', Integer(Self));
>   WriteLn('  Method = ',
>     Longint(TProcOfObjectInternal(method).method), '/',
>     Longint(TProcOfObjectInternal(method).obj));
> end;
> 
> var
>   instance: TTestClass;
>   method: TProcOfObject;
> begin
>   instance := TTestClass.Create;
> 
>   method := @instance.SomeMethod;
>   WriteLn;
>   WriteLn('In main program:');
>   WriteLn('  instance = ', Integer(instance));
>   WriteLn('  Method = ',
>     Longint(TProcOfObjectInternal(method).method), '/',
>     Longint(TProcOfObjectInternal(method).obj));
>   WriteLn;
>   instance.SomeMethod;
> end.
> --------------------8<-----------------------
> 
> output is:
> 
> home: >ppc386 testp
> home: >testp
> In Constructor:
>   Self = 134552384
>   Method = 134544316/134552384
> 
> In main program:
>   instance = 134552384
>   Method = 134544316/134552384
> 
> In SomeMethod:
>   Self = 134552384
>   Method = 134544316/134552384
> home: >
> 
> I hope this convinces everyone :-)
This only works with the latest compiler from the main CVS tree, not the
release 0.99.12a compiler.

Peter







More information about the Lazarus mailing list