Commit Graph

31 Commits

Author SHA1 Message Date
Jonas Maebe
df3a0af7e0 objc: use compile-time macOS version checks
Use "modern" APIs for calling inherited messages when targeting Mac OS X 10.6
or later
2022-09-16 11:21:05 +02:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
svenbarth
3b71841a84 Merged revision(s) 28691, 31914 from branches/svenbarth/packages:
Convert export options from constants to a set and accordingly adjust all usage locations

git-svn-id: trunk@32945 -
2016-01-15 16:06:06 +00:00
Jonas Maebe
f402b0d7df * changed getpointerdef() into a tpointerdef.getreusable() class method
o allows removing the ugly x86 hacks

git-svn-id: trunk@31144 -
2015-06-22 08:17:49 +00:00
Jonas Maebe
703e31512d * moved JVM-specific code of tloadvmtaddrnode.pass_1 to njvmmem
* create separate nodes for Objective-C in tloadvmtaddrnode.pass_1
    instead of implicitly relying on the fact that the Objective-C
    ISA field is at the same offset as the VMT of Object-Pascal
    classes
   o translate the resulting loads of ISA field into direct pointer
     accesses, so that even on non-fragile ABI platforms we don't
     go via an indirection (like clang/gcc)

git-svn-id: trunk@30947 -
2015-05-31 16:50:39 +00:00
Jonas Maebe
2340da410c * we cannot directly load the ISA pointer on AArch64, we have to call the
class instance method
   (http://www.sealiesoftware.com/blog/archive/2013/09/24/objc_explain_Non-pointer_isa.html )

git-svn-id: trunk@29943 -
2015-02-23 22:54:18 +00:00
Jonas Maebe
bd09b88a5b + support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension)
o blocks are implemented as a variation of procedure variables
   o declaration of a block variable: "test: procedure(c: char) is block;"
     (C equivalent: (void)(^test)(char c) )
   o the compiler automatically converts procedures/functions whose address
     is passed to a block parameter or assigned to a block variable into
     a "block". This consists of
    1) generating a block descriptor (containing the size of the "block
       literal" (see below) and the signature of the invocation function
       encoded as an Objective-C selector)
    2) generating a wrapper function around the original funcion (with C
       calling convention), that has an extra first hidden parameter
       (marked as vo_is_parentfp in the compiler) whose type is a pointer
       to the describing "block literal"
    3) generating the "block literal", which contains a pointer to an
       external variable indicating whether this block captures context or
       not, some flags (see compiler/blockutl.get_block_literal_flags for
       info), a pointer to the wrapper function and a pointer to the
       descriptor. In the future, it will also contain captured variables.
   o right now, only global procedures/functions can be converted to blocks
     (because they don't require state capturing). The next steps are (Object
     Pascal) methods (not Objective-C methods, because Objective-C method
     procvars don't exist) and finally nested functions
   o on Mac OS X, the functionality will only work on Mac OS X 10.7 and later,
     because we have to use the so-called "ABI.2010.3.16" to ensure that
     our blocks aren't called as variadic functions by the runtime (which
     came out after the Mac OS X 10.6 release)
   o while the currently implemented functionality does not require any
     library support at all, there's no use enabling it on other platforms
     because unless it has been confirmed to work with a blocks runtime,
     there's no point in using blocks (they're just somewhat bulky procvars
     right now). Enabling it on other platforms (in combination with the
     GNUStep Objective-C run time), should simply be a matter of adding
     the right {$linklib xxx} statement to rtl/inc/blockrtl.pp file, adding
     that file to Makefile.fpc for that platform and adding that platform
     to the compiler/systems.systems_blocks_supported set

git-svn-id: branches/blocks@28232 -
2014-07-18 09:15:22 +00:00
Jonas Maebe
8525a30d9f * don't generate a classClass call for objc loadvmtaddrnodes generated
for inherited calls (that is only required when not using them for
    dispatch purposes, and calling an inherited method is obviously
    a dispatch situation)

git-svn-id: trunk@20664 -
2012-03-29 20:54:47 +00:00
Jonas Maebe
c4c9661f84 * set "forcall" to true for the objc loadvmtaddrnodes generated as
self parameter for invoking inherited method calls (if you are in a
    category method or a method of a child class, the extended or parent
    class must have already been loaded by the run time, so we can
    directly load the ISA pointer rather than detouring via the "class"
    method)

git-svn-id: trunk@20624 -
2012-03-25 12:59:17 +00:00
Jonas Maebe
cec5843f95 * renamed objcdef.addencodedtype to objcaddencodedtype for consistency
reasons, and to prevent name clashes

git-svn-id: trunk@16598 -
2010-12-19 19:37:47 +00:00
joost
07bf44517c * Merged XPCom branch into trunk, added support for constref and changed
the IInterface implementation to be XPCom-compatible
--- Merging r15997 through r16179 into '.':
U    rtl/inc/variants.pp
U    rtl/inc/objpash.inc
U    rtl/inc/objpas.inc
U    rtl/objpas/classes/persist.inc
U    rtl/objpas/classes/compon.inc
U    rtl/objpas/classes/classesh.inc
A    tests/test/tconstref1.pp
A    tests/test/tconstref2.pp
A    tests/test/tconstref3.pp
U    tests/test/tinterface4.pp
A    tests/test/tconstref4.pp
U    tests/webtbs/tw10897.pp
U    tests/webtbs/tw4086.pp
U    tests/webtbs/tw15363.pp
U    tests/webtbs/tw2177.pp
U    tests/webtbs/tw16592.pp
U    tests/tbs/tb0546.pp
U    compiler/sparc/cpupara.pas
U    compiler/i386/cpupara.pas
U    compiler/pdecsub.pas
U    compiler/symdef.pas
U    compiler/powerpc/cpupara.pas
U    compiler/avr/cpupara.pas
U    compiler/browcol.pas
U    compiler/defcmp.pas
U    compiler/powerpc64/cpupara.pas
U    compiler/ncgrtti.pas
U    compiler/x86_64/cpupara.pas
U    compiler/opttail.pas
U    compiler/htypechk.pas
U    compiler/tokens.pas
U    compiler/objcutil.pas
U    compiler/ncal.pas
U    compiler/symtable.pas
U    compiler/symsym.pas
U    compiler/m68k/cpupara.pas
U    compiler/regvars.pas
U    compiler/arm/cpupara.pas
U    compiler/symconst.pas
U    compiler/mips/cpupara.pas
U    compiler/paramgr.pas
U    compiler/psub.pas
U    compiler/pdecvar.pas
U    compiler/dbgstabs.pas
U    compiler/options.pas
U    packages/fcl-fpcunit/src/testutils.pp

git-svn-id: trunk@16180 -
2010-10-17 20:58:22 +00:00
Jonas Maebe
f13f6627c4 * moved use_fixed_stack from cgutils to a method in paramgr so it can
be used outside the code generator
  * renamed tabstractprocdef.requiredargarea into callerargareasize,
    and also added calleeargareasize field; added init_paraloc_info(side)
    method to init the parameter locations and init those size fields and
    replaced all "if not procdef.has_paraloc_info then ..." blocks with
    procdef.init_paraloc_info(callersize)"
  * moved detection of stack tainting parameters from psub to
    symdef/tabstractprocdef
  + added tcallparanode.contains_stack_tainting_call(), which detects
    whether a parameter contains a call that makes use of stack paramters
  * record for each parameter whether or not any following parameter
    contains a call with stack parameters; if not, in case the current
    parameter itself is a stack parameter immediately place it in its
    final location also for use_fixed_stack platforms rather than
    first putting it in a temporary location (part of mantis #17442)
  * on use_fixed_stack platforms, always first evaluate parameters
    containing a stack tainting call, since those force any preceding
    stack parameters of the current call to be stored in a temp location
    and copied to the final location afterwards

git-svn-id: trunk@16050 -
2010-09-26 21:24:14 +00:00
Jonas Maebe
caca6cea37 * allow any kind of fields in Object Pascal classes that are passed to
Objective-C methods or which are fields of Objective-C classes (since they
    are basically opaque to the Objective-C runtime) + fixed tobjc11 so it
    expects classes to be encoded as opaque types
  * give a proper error message when using illegal field/parameter types in
    Objective-C classes/methods instead of an internal error (only checked
    during rtti generation rather than during parsing, because during parsing
    some types may still be forwarddefs)
  * split objcutil in objcdef and objcutil, with objcdef depending only on
    the symtable so it can be used in symdef

git-svn-id: trunk@14838 -
2010-01-31 21:13:41 +00:00
florian
c1f3d8dcaa * unified names of system_*/systems_* sets
git-svn-id: trunk@14566 -
2010-01-07 18:16:20 +00:00
Jonas Maebe
f191ab39cd * don't use a voidpointer typecast to access hardcoded objc fields, because
that sets the alignment to 1 and hence causes unnecessary unaligned
    loads/stores on ARM

git-svn-id: trunk@14291 -
2009-11-30 20:43:48 +00:00
Jonas Maebe
a6716fd2a2 * fixed calling inherited class methods from category methods when using
the iPhoneOS/Mac OS X 10.6 objc runtime interface (tests/test/tobjc25.pp)

git-svn-id: trunk@14289 -
2009-11-29 21:41:47 +00:00
Jonas Maebe
f8754d8fab + Objective-C category support (old and new ABI, both external and
implemented in Pascal). See
    http://wiki.freepascal.org/FPC_PasCocoa#Category_declaration for syntax
    details

git-svn-id: trunk@14196 -
2009-11-16 00:12:08 +00:00
Jonas Maebe
8700874a96 * 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 -
2009-10-01 12:07:22 +00:00
Jonas Maebe
97ba8de56c * don't export the symbols for "strict private" fields (it was only not
done for regular private fields)

git-svn-id: branches/objc@13782 -
2009-10-01 11:55:23 +00:00
Jonas Maebe
3f0eee741a * fixed checking whether first character of a selector is valid (patch by
Dmitry Boyarintsev, mantis #14680)

git-svn-id: branches/objc@13768 -
2009-09-28 08:40:27 +00:00
Jonas Maebe
6f3bace0f3 + support for exporting Objective-C classes from dynamic libraries. It works
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 -
2009-09-27 15:40:52 +00:00
Jonas Maebe
0c675a4039 * the objc1 unit has been renamed to objc
* the objc unit links against the Foundation instead of against the Cocoa
    framework, and inludes an interface to either the fragile or non-fragile
    obj-c run time depending on the target platform
  + support for the non-fragile Objective-C runtime/ABI, as used on Mac OS X
    for ARM (iPhone) 64 bit (PowerPC/64, x86_64) -- all these targets now
    are now also supported for the objectivec1 modeswitch
  + support for private_extern symbol bindings, required for the above
  * mark objcclasses that are declared in the implementation section of a
    unit as "hidden" (not sure what the effect is, since the Objective-C
    runtime does not seem to do anything with this flag)
  * enabled all obj-c tests for the newly supported platforms

git-svn-id: branches/objc@13763 -
2009-09-27 15:24:50 +00:00
Jonas Maebe
b76def10b2 + check whether selector names are valid when they are specified in a class
delcaration (instead of only for objcselector() nodes)
  * also print the wrong selector itself when it's wrong

git-svn-id: branches/objc@13689 -
2009-09-11 16:12:27 +00:00
Jonas Maebe
3c9e1742dd * fixed calling inherited methods in Objective-C + test
git-svn-id: branches/objc@13686 -
2009-09-09 22:27:39 +00:00
Jonas Maebe
e0b7e8aa55 * made internalerror unique
git-svn-id: branches/objc@13683 -
2009-09-09 09:30:52 +00:00
Jonas Maebe
1048ac96d5 * skip hidden function result parameters when generating message signatures
git-svn-id: branches/objc@13662 -
2009-09-06 17:18:49 +00:00
Jonas Maebe
27385550f8 * use the (sorted) paras rather than the (unsorted) parasymtable when
generating method signatures

git-svn-id: branches/objc@13661 -
2009-09-06 17:15:00 +00:00
Jonas Maebe
b3737214b0 * use paraloc info to obtain parameter size (instead of (re)calulcating it
from the def)
  + added (disabled) code to correctly calculate the parameter offsets for
    ppc, see comments why it's not activated

git-svn-id: branches/objc@13619 -
2009-08-30 09:30:59 +00:00
Jonas Maebe
8def2c2ac3 * fixed compilation after introduction of strict class type checking
for var/out parameters

git-svn-id: branches/objc@13597 -
2009-08-25 19:43:45 +00:00
Jonas Maebe
5885866990 + support for objcencode() (equivalent of Objective-C's @encode()) + test
+ functionality to encode Objective-C function signatures (untested)

git-svn-id: branches/objc@13557 -
2009-08-18 19:54:02 +00:00
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