mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 18:19:54 +02:00
* make hidden '_cmd' (selector) parameter available in Objective-C methods
* don't give a hint if this hidden _cmd parameter is unused git-svn-id: branches/objc@13700 -
This commit is contained in:
parent
b2d66522d5
commit
8e81477fcf
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8597,6 +8597,7 @@ tests/test/tobjc18.pp svneol=native#text/plain
|
||||
tests/test/tobjc19.pp svneol=native#text/plain
|
||||
tests/test/tobjc2.pp svneol=native#text/plain
|
||||
tests/test/tobjc20.pp svneol=native#text/plain
|
||||
tests/test/tobjc21.pp svneol=native#text/plain
|
||||
tests/test/tobjc3.pp svneol=native#text/plain
|
||||
tests/test/tobjc4.pp svneol=native#text/plain
|
||||
tests/test/tobjc4a.pp svneol=native#text/plain
|
||||
|
@ -162,6 +162,8 @@ implementation
|
||||
vs : tparavarsym;
|
||||
hdef : tdef;
|
||||
vsp : tvarspez;
|
||||
aliasvs : tabsolutevarsym;
|
||||
sl : tpropaccesslist;
|
||||
begin
|
||||
if (pd.typ=procdef) and
|
||||
is_objc_class_or_protocol(tprocdef(pd)._class) then
|
||||
@ -169,6 +171,13 @@ implementation
|
||||
{ insert Objective-C self and selector parameters }
|
||||
vs:=tparavarsym.create('$_cmd',paranr_objc_cmd,vs_value,objc_seltype,[vo_is_msgsel,vo_is_hidden_para]);
|
||||
pd.parast.insert(vs);
|
||||
{ make accessible to code }
|
||||
sl:=tpropaccesslist.create;
|
||||
sl.addsym(sl_load,vs);
|
||||
aliasvs:=tabsolutevarsym.create_ref('_CMD',objc_seltype,sl);
|
||||
include(aliasvs.varoptions,vo_is_msgsel);
|
||||
tlocalsymtable(tprocdef(pd).localst).insert(aliasvs);
|
||||
|
||||
vs:=tparavarsym.create('$self',paranr_objc_self,vs_value,objc_idtype,[vo_is_self,vo_is_hidden_para]);
|
||||
pd.parast.insert(vs);
|
||||
end
|
||||
|
@ -630,7 +630,10 @@ implementation
|
||||
(tsym(sym).typ<>procsym) or
|
||||
((tsym(sym).owner.symtabletype=staticsymtable) and
|
||||
not current_module.is_unit)
|
||||
) then
|
||||
) and
|
||||
{ don't complain about alias for hidden _cmd parameter to
|
||||
obj-c methods }
|
||||
not (vo_is_msgsel in tabstractvarsym(sym).varoptions) then
|
||||
MessagePos2(tsym(sym).fileinfo,sym_h_local_symbol_not_used,SymTypeName[tsym(sym).typ],tsym(sym).prettyname);
|
||||
end;
|
||||
end;
|
||||
|
37
tests/test/tobjc21.pp
Normal file
37
tests/test/tobjc21.pp
Normal file
@ -0,0 +1,37 @@
|
||||
{ %target=darwin }
|
||||
{ %cpu=powerpc,i386 }
|
||||
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$modeswitch objectivec1}
|
||||
type
|
||||
|
||||
MyObject = objcclass(NSObject)
|
||||
|
||||
function getsspara(l1,l2: longint): shortstring ; message 'getss:l1:';
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
m: MyObject;
|
||||
b: boolean;
|
||||
|
||||
function MyObject.getsspara(l1,l2: longint): shortstring;
|
||||
begin
|
||||
if (self<>m) then
|
||||
halt(1);
|
||||
if _cmd<>objcselector('getss:l1:') then
|
||||
halt(2);
|
||||
result:='';
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
m := MyObject.alloc;
|
||||
m:=m.init;
|
||||
|
||||
m.getsspara(1,2);
|
||||
|
||||
m.release;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user