obcpas: fix categories implementing protocols

Allocate the ImplementedInterfaces array for them and save to/load from ppu

Solves #39375
This commit is contained in:
Jonas Maebe 2021-09-25 16:14:30 +02:00
parent e924dd0d16
commit fcb646bc3b
3 changed files with 34 additions and 3 deletions

View File

@ -48,7 +48,7 @@ const
CurrentPPUVersion = 208;
{ for any other changes to the ppu format, increase this version number
(it's a cardinal) }
CurrentPPULongVersion = 13;
CurrentPPULongVersion = 14;
{ unit flags }
uf_big_endian = $000004;

View File

@ -7431,7 +7431,7 @@ implementation
if objecttype in [odt_interfacecorba,odt_interfacecom,odt_dispinterface] then
prepareguid;
{ setup implemented interfaces }
if objecttype in [odt_class,odt_objcclass,odt_objcprotocol,odt_javaclass,odt_interfacejava] then
if objecttype in [odt_class,odt_objcclass,odt_objcprotocol,odt_objccategory,odt_javaclass,odt_interfacejava] then
ImplementedInterfaces:=TFPObjectList.Create(true)
else
ImplementedInterfaces:=nil;
@ -7489,7 +7489,7 @@ implementation
end;
{ load implemented interfaces }
if objecttype in [odt_class,odt_objcclass,odt_objcprotocol,odt_javaclass,odt_interfacejava] then
if objecttype in [odt_class,odt_objcclass,odt_objcprotocol,odt_objccategory,odt_javaclass,odt_interfacejava] then
begin
ImplementedInterfaces:=TFPObjectList.Create(true);
implintfcount:=ppufile.getlongint;

31
tests/webtbs/tw39375.pp Normal file
View File

@ -0,0 +1,31 @@
{ %target=darwin,ios,iphonesim }
program Project1;
{$mode objfpc}{$H+}
{$ModeSwitch objectivec1}
type
CBCentralManager = pointer;
CBCentralManagerDelegateProtocol = objcprotocol external
procedure centralManagerDidUpdateState (central: CBCentralManager); message 'centralManagerDidUpdateState:';
end;
Test=objccategory(NSObject,CBCentralManagerDelegateProtocol)
procedure centralManagerDidUpdateState (central: CBCentralManager);
end;
var
called: boolean = false;
procedure Test.centralManagerDidUpdateState (central: CBCentralManager);
begin
called:=true;
end;
var
o: NSObject;
begin
o := NSObject.alloc.init;
o.centralManagerDidUpdateState(nil);
if not called then
halt(1);
end.