objc1.pp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2009 by the Free Pascal development team
  4. This unit provides an interface to the Objective-C 1.0
  5. run time as defined by Apple
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit objc1;
  13. interface
  14. {$ifdef darwin}
  15. const
  16. libname = 'objc';
  17. {$linkframework Cocoa}
  18. {$define targetok}
  19. {$endif}
  20. {$ifndef targetok}
  21. {$error Add support for the current target to the objc1 unit }
  22. {$endif}
  23. type
  24. { make all opaque types assignment-incompatible with other typed pointers by
  25. declaring them as pointers to empty records
  26. WARNING: do NOT change the names, types or field names/types of these
  27. types, as many are used internally by the compiler.
  28. }
  29. tobjc_class = record
  30. end;
  31. pobjc_class = ^tobjc_class;
  32. objc_object = record
  33. _class: pobjc_class;
  34. end;
  35. id = ^objc_object;
  36. pobjc_object = id;
  37. _fpc_objc_sel_type = record
  38. end;
  39. SEL = ^_fpc_objc_sel_type;
  40. IMP = function(target: id; msg: SEL): id; varargs; cdecl;
  41. objc_super = record
  42. receiver: id;
  43. _class: pobjc_class;
  44. end;
  45. pobjc_super = ^objc_super;
  46. _fpc_objc_protocol_type = record
  47. end;
  48. pobjc_protocal = ^_fpc_objc_protocol_type;
  49. { type that certainly will be returned by address }
  50. tdummyrecbyaddrresult = record
  51. a: array[0..1000] of shortstring;
  52. end;
  53. { sending messages }
  54. function objc_msgSend(self: id; op: SEL): id; cdecl; varargs; external libname;
  55. function objc_msgSendSuper(const super: pobjc_super; op: SEL): id; cdecl; varargs; external libname;
  56. { The following two are declared as procedures with the hidden result pointer
  57. as their first parameter. This corresponds to the declaration below as far
  58. as the code generator is concerned (and is easier to handle in the compiler). }
  59. function objc_msgSend_stret(self: id; op: SEL): tdummyrecbyaddrresult; cdecl; varargs; external libname;
  60. function objc_msgSendSuper_stret(const super: pobjc_super; op: SEL): tdummyrecbyaddrresult; cdecl; varargs; external libname;
  61. {$ifdef cpui386}
  62. function objc_msgSend_fpret (self: id; op: SEL): double; cdecl; varargs; external libname;
  63. {$endif cpui386}
  64. function class_getSuperclass(cls: pobjc_class): pobjc_class; cdecl; external libname;
  65. function objc_getMetaClass(name: pchar): id; cdecl; external libname;
  66. function class_getName(cls: pobjc_class): pchar; cdecl; external libname;
  67. implementation
  68. end.