[fpc-pascal] Interface, _AddRef, _Release, etc.

Marcos Douglas md at delfire.net
Fri Sep 16 15:55:07 CEST 2011


On Fri, Sep 16, 2011 at 4:46 AM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
> You're original problem is exactly why I said mixing class instances and
> interface instance is looking for trouble. You better know what you are
> doing.
>
> Attached are two examples of your program. One using CORBA interfaces,
> the other using non-reference counting COM style interface. Both work
> under 64-bit FPC 2.4.5 under Linux.

Thanks, but...
The testme.pas has the TNonRefCountedObject class, but it isn't used.
Both has the {$interfaces corba} directive.

Anyway, corba interfaces looks like solve my "problem" but I did more
tests, using corba:
1- If I change the Run procedure (see comments), how I release [f] variable?
procedure Run;
var
  f: IFoo;  // <<< now is an interface
  o: TObj;
begin
  f := TFoo.Create;
  //f.SetInfo('foo');  // do not exists in IFoo, but OK
  o := TObj.Create;
  o.Foo := f;
  writeln(o.Foo.GetInfo);
  o.Free;
  //f.Free  // <<< how I release this?
end;

I.e. this is the inverse of COM interfaces -- inverse of my problem
too -- because I just could instantiate variables of concrete classes
and not variables of type interface.
Maybe the union of both... or Am I saying a nonsense?

Marcos Douglas



More information about the fpc-pascal mailing list