fpc/tests/test/tobjcl2.pp
Jonas Maebe f29598384b * Objective-Pascal inferred result type and improved category method searching
--- Merging r42815 through r42817 into '.':
U    tests/test/tobjc34.pp
U    tests/test/tobjc36.pp
U    tests/test/tobjcl2.pp
A    tests/test/units/cocoaall
A    tests/test/units/cocoaall/tw35994.pp
U    compiler/defcmp.pas
U    compiler/ncal.pas
C    compiler/pdecl.pas
C    compiler/symconst.pas
C    compiler/utils/ppuutils/ppudump.pp
U    compiler/symtable.pas
--- Recording mergeinfo for merge of r42815 through r42817 into '.':
 U   .
--- Merging r42857 into '.':
G    compiler/symtable.pas
--- Recording mergeinfo for merge of r42857 into '.':
 G   .
  

git-svn-id: branches/fixes_3_2@42883 -
2019-08-31 11:43:41 +00:00

55 lines
1.0 KiB
ObjectPascal

{ %target=darwin }
{ %cpu=powerpc,powerpc64,i386,x86_64,arm,aarch64 }
{ %NEEDLIBRARY }
{ Written by Jonas Maebe in 2009, released into the public domain }
{$mode objfpc}
{$modeswitch objectivec1}
const
{$ifdef windows}
libname='tobjcl1.dll';
{$else}
libname='tobjcl1';
{$linklib tobjcl1}
{$endif}
type
MyLibObjCClass = objcclass external (NSObject)
public
fa: byte;
function publicfun: byte; message 'publicfun';
protected
fb: byte;
function protectedfun: byte; message 'protectedfun';
private
fc: byte;
function privatefun: byte; message 'privatefun';
end;
MyDerivedClass = objcclass(MyLibObjCClass)
l: longint;
function callprotectedfun: byte; message 'callprotectedfun';
end;
function MyDerivedClass.callprotectedfun: byte;
begin
result:=protectedfun;
end;
var
a: MyLibObjCClass;
begin
a:=MyDerivedClass.alloc.init;
a.fa:=55;
a.fb:=66;
if a.publicfun<>55 then
halt(1);
if MyDerivedClass(a).callprotectedfun<>66 then
halt(2);
a.release;
end.