mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 19:19:25 +02:00

the same as for exporting functions/procedures and variables: add the name of the class to the "exports" section of the library. By default, classes are only visible inside a shared library. git-svn-id: branches/objc@13765 -
53 lines
971 B
ObjectPascal
53 lines
971 B
ObjectPascal
{ %target=darwin }
|
|
{ %cpu=powerpc,powerpc64,i386,x86_64,arm }
|
|
{ %NEEDLIBRARY }
|
|
|
|
{$mode objfpc}
|
|
{$modeswitch objectivec1}
|
|
|
|
const
|
|
{$ifdef windows}
|
|
libname='tobjcl1.dll';
|
|
{$else}
|
|
libname='tobjcl1';
|
|
{$linklib tobjcl1}
|
|
{$endif}
|
|
|
|
type
|
|
MyLibObjCClass = objcclass(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; external;
|
|
|
|
MyDerivedClass = objcclass(MyLibObjCClass)
|
|
l: longint;
|
|
function callprotectedfun: byte; message 'callprotectedfun';
|
|
end;
|
|
|
|
|
|
function MyDerivedClass.callprotectedfun: byte;
|
|
begin
|
|
result:=protectedfun;
|
|
end;
|
|
|
|
|
|
var
|
|
a: MyLibObjCClass;
|
|
begin
|
|
a:=NSObject(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.
|