fpc/compiler/objcgutl.pas
Jonas Maebe b1b9894ae3 * initial Objective-C 1.0 support:
o support for declaring external Objective-C classes (see
      rtl/inc/objcbase.pas), including derived classes
    o support for converting methods of objcclasses into selectors
      (see tests/test/tobjc1.pp)
    o support for loading from/storing to fields of objcclasses
    o support for calling Objective-C methods using regular
      Object Pascal syntax (see tests/test/tobjc1.pp)
    o some things that are known to be not yet working:
      o automatic conversion from ID to objcclasses and back
      o declaring and implementing new objcclasses/methods in Pascal code
      o debug information (objcclasses are currently plain pointers
        as far as the debugger knows)

git-svn-id: branches/objc@13162 -
2009-05-17 13:42:50 +00:00

77 lines
2.5 KiB
ObjectPascal

{
Copyright (c) 2009 by Jonas Maebe
This unit implements some Objective-C helper routines at the code generator
level.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
{$i fpcdefs.inc}
unit objcgutl;
interface
uses
cclasses,
aasmbase;
procedure objcfinishstringrefpoolentry(entry: phashsetitem; refsec, stringsec: tasmsectiontype);
implementation
uses
globtype,
aasmdata,aasmtai,
cgbase,cgutils,
symsym,
verbose;
procedure objcfinishstringrefpoolentry(entry: phashsetitem; refsec, stringsec: tasmsectiontype);
var
reflab,
strlab : tasmlabel;
pc : pchar;
begin
{ have we already generated this selector? }
if not assigned(entry^.Data) then
begin
{ create new one
(no getdatalabel, because these labels have to be local)
}
current_asmdata.getlabel(reflab,alt_data);
current_asmdata.getlabel(strlab,alt_data);
entry^.Data:=reflab;
getmem(pc,entry^.keylength+1);
move(entry^.key^,pc^,entry^.keylength);
pc[entry^.keylength]:=#0;
{ add a pointer to the message name in the string references section }
new_section(current_asmdata.asmlists[al_objc_data],refsec,reflab.name,sizeof(pint));
current_asmdata.asmlists[al_objc_data].concat(Tai_label.Create(reflab));
current_asmdata.asmlists[al_objc_data].concat(Tai_const.Create_sym(strlab));
{ and now add the message name to the associated strings section }
new_section(current_asmdata.asmlists[al_objc_data],stringsec,strlab.name,1);
current_asmdata.asmlists[al_objc_data].concat(Tai_label.Create(strlab));
current_asmdata.asmlists[al_objc_data].concat(Tai_string.Create_pchar(pc,entry^.keylength+1));
end;
end;
end.