mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-06 07:47:32 +01:00
* don't call class_getSuperClass() anymore to obtain the superclass, but
load it inline. This should be safe even on the non-fragile ABI, because
the isa and superclass fields are expected at fixed offsets by the runtime
(and gcc and clang also use direct memory accesses in this case)
git-svn-id: branches/objc@13784 -
This commit is contained in:
parent
3660bf7f98
commit
8700874a96
@ -64,7 +64,7 @@ implementation
|
|||||||
verbose,systems,
|
verbose,systems,
|
||||||
symtable,symconst,symsym,
|
symtable,symconst,symsym,
|
||||||
defutil,paramgr,
|
defutil,paramgr,
|
||||||
nbas,nmem,ncal,nld,ncon,
|
nbas,nmem,ncal,nld,ncon,ncnv,
|
||||||
export;
|
export;
|
||||||
|
|
||||||
|
|
||||||
@ -120,6 +120,8 @@ end;
|
|||||||
function objcsuperclassnode(def: tdef): tnode;
|
function objcsuperclassnode(def: tdef): tnode;
|
||||||
var
|
var
|
||||||
para : tcallparanode;
|
para : tcallparanode;
|
||||||
|
class_type : tdef;
|
||||||
|
vs : tsym;
|
||||||
begin
|
begin
|
||||||
{ only valid for Objective-C classes and classrefs }
|
{ only valid for Objective-C classes and classrefs }
|
||||||
if not is_objcclass(def) and
|
if not is_objcclass(def) and
|
||||||
@ -140,12 +142,17 @@ end;
|
|||||||
superclass. For the fragile ABI, we have to do this ourselves.
|
superclass. For the fragile ABI, we have to do this ourselves.
|
||||||
|
|
||||||
NOTE: those send2 methods are only available on Mac OS X 10.6 and later!
|
NOTE: those send2 methods are only available on Mac OS X 10.6 and later!
|
||||||
(but on also all iPhone SDK revisions we support) }
|
(but also on all iPhone SDK revisions we support) }
|
||||||
if not(target_info.system in system_objc_nfabi) then
|
if not(target_info.system in system_objc_nfabi) then
|
||||||
{$endif onlymacosx10_6 or arm}
|
{$endif onlymacosx10_6 or arm}
|
||||||
begin
|
begin
|
||||||
para:=ccallparanode.create(result,nil);
|
class_type:=search_named_unit_globaltype('OBJC','OBJC_OBJECT').typedef;
|
||||||
result:=ccallnode.createinternfromunit('OBJC','CLASS_GETSUPERCLASS',para);
|
result:=ctypeconvnode.create_internal(cderefnode.create(ctypeconvnode.create_internal(result,voidpointertype)),class_type);
|
||||||
|
vs:=tsym(tabstractrecorddef(class_type).symtable.Find('SUPERCLASS'));
|
||||||
|
if not assigned(vs) or
|
||||||
|
(vs.typ<>fieldvarsym) then
|
||||||
|
internalerror(200909301);
|
||||||
|
result:=csubscriptnode.create(vs,result);
|
||||||
end;
|
end;
|
||||||
typecheckpass(result);
|
typecheckpass(result);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -60,6 +60,7 @@ type
|
|||||||
|
|
||||||
objc_object = record
|
objc_object = record
|
||||||
isa: pobjc_class;
|
isa: pobjc_class;
|
||||||
|
superclass: pobjc_class;
|
||||||
end;
|
end;
|
||||||
id = ^objc_object;
|
id = ^objc_object;
|
||||||
pobjc_object = id;
|
pobjc_object = id;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user