On Tue, Feb 11, 2014 at 4:52 PM, Marco van de Voort <mar...@stack.nl> wrote:
> In our previous episode, Mark Morgan Lloyd said: > > If a method a.WriteBuff() is passed another method b.finish() as a > > parameter, can it access b before calling finish(), or would this > > require an explicit parameter? > > > > If yes, how? > > tobject(tmethod(func).data) > One word of caution though: Not sure about FPC but in Delphi a caller may pass a class method instead of an instance method to a method variable. In this case the correct typecast would be: T Class(tmethod(func).data) and AFAIK there is no safe way to test if the bare pointer TMethod.Data points to an instance or a class VMT in order to do the correct cast without AVs. Jedi code library (JCL) has an IsObject() and an IsClass() function but I have found them not to be fullproof and can raise AVs as well. Maybe the OP could consider using interfaces instead of method variables. -- Constantine.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal