objcbase.pp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 the definition of the NSObject root class
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit objcbase;
  12. {$ifdef FPC_HAS_FEATURE_OBJECTIVEC1}
  13. {$modeswitch objectivec1}
  14. interface
  15. uses
  16. ctypes;
  17. type
  18. {
  19. NSString = objcclass; external;
  20. NSInvocation = objcclass; external;
  21. NSMethodSignature = objcclass; external;
  22. NSCoder = objcclass; external;
  23. }
  24. NSZone = record
  25. end;
  26. PNSZone = ^NSZone;
  27. Protocol = objcclass
  28. end; external;
  29. NSObjectProtocol = objcprotocol
  30. function isEqual_(obj: id): boolean; message 'isEqual:';
  31. function hash: cuint; message 'hash';
  32. function superclass: pobjc_class; message 'superclass';
  33. function _class: pobjc_class; message 'class';
  34. { "self" is both a hidden parameter to each method, and a method of
  35. NSObject and thereby of each subclass as well
  36. }
  37. function self: id; message 'self';
  38. function zone: PNSZone; message 'zone';
  39. function performSelector_(aSelector: SEL): id; message 'performSelector:';
  40. function performSelector_withObject_(aSelector: SEL; obj: id): id; message 'performSelector:withObject:';
  41. function performSelector_withObject_withObject_(aSelector: SEL; obj1, obj2: id): id; message 'performSelector:withObject:withObject:';
  42. function isProxy: boolean; message 'isProxy';
  43. function isKindOfClass_(aClass: pobjc_class): boolean; message 'isKindOfClass:';
  44. function isMemberOfClass_(aClass: pobjc_class): boolean; message 'isMemberOfClass:';
  45. function conformsToProtocol_(aProtocol: Protocol): boolean; message 'conformsToProtocol:';
  46. function respondsToSelector_(aSelector: SEL): boolean; message 'respondsToSelector:';
  47. function retain: id; message 'retain';
  48. procedure release; message 'release'; { oneway }
  49. function autorelease: id; message 'autorelease';
  50. function retainCount: cint; message 'retainCount';
  51. function description: {NSString} id; message 'description';
  52. end; external name 'NSObject';
  53. NSObject = objcclass(NSObjectProtocol)
  54. strict protected
  55. isa: pobjc_class;
  56. public
  57. { NSObjectProtocol -- the message names are copied from the protocol
  58. definition by the compiler, but you can still repeat them if you want }
  59. function isEqual_(obj: id): boolean;
  60. function hash: cuint;
  61. function superclass: pobjc_class;
  62. function _class: pobjc_class;
  63. { "self" is both a hidden parameter to each method, and a method of
  64. NSObject and thereby of each subclass as well
  65. }
  66. function self: id;
  67. function zone: PNSZone;
  68. function performSelector_(aSelector: SEL): id;
  69. function performSelector_withObject_(aSelector: SEL; obj: id): id;
  70. function performSelector_withObject_withObject_(aSelector: SEL; obj1, obj2: id): id;
  71. function isProxy: boolean;
  72. function isKindOfClass_(aClass: pobjc_class): boolean;
  73. function isMemberOfClass_(aClass: pobjc_class): boolean;
  74. function conformsToProtocol_(aProtocol: Protocol): boolean;
  75. function respondsToSelector_(aSelector: SEL): boolean;
  76. function retain: id;
  77. procedure release; { oneway }
  78. function autorelease: id;
  79. function retainCount: cint;
  80. function description: {NSString} id;
  81. { NSObject class }
  82. { "class" prefix to method name to avoid name collision with NSObjectProtocol }
  83. class function classIsEqual_(obj: id): boolean; message 'isEqual:';
  84. { "class" prefix to method name to avoid name collision with NSObjectProtocol }
  85. class function classHash: cuint; message 'hash';
  86. { NSObject methods }
  87. class procedure load; message 'load';
  88. class procedure initialize; message 'initialize';
  89. function init: id; message 'init';
  90. class function new: id; message 'new';
  91. class function allocWithZone_(_zone: PNSZone): id; message 'allocWithZone:';
  92. class function alloc: id; message 'alloc';
  93. procedure dealloc; message 'dealloc';
  94. { if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 }
  95. procedure finalize; message 'finalize';
  96. { endif }
  97. function copy: id; message 'copy';
  98. function mutableCopy: id; message 'mutableCopy';
  99. class function copyWithZone_(_zone: PNSZone): id; message 'copyWithZone:';
  100. class function mutableCopyWithZone_(_zone: PNSZone): id; message 'mutableCopyWithZone:';
  101. { "class" prefix to method name to avoid name collision with NSObjectProtocol }
  102. class function classSuperclass: pobjc_class; message 'superclass';
  103. { "class" prefix to method name to avoid name collision with NSObjectProtocol }
  104. class function classClass: pobjc_class; message 'class';
  105. class procedure poseAsClass_(aClass: pobjc_class); message 'poseAsClass:';
  106. class function instancesRespondToSelector_(aSelector: SEL): boolean; message 'instancesRespondToSelector:';
  107. { "class" prefix to method name to avoid name collision with NSObjectProtocol }
  108. class function classConformsToProtocol_(aProtocol: Protocol): boolean; message 'conformsToProtocol:';
  109. function methodForSelector_(aSelector: SEL): IMP; message 'methodForSelector:';
  110. class function instanceMethodForSelector_(aSelector: SEL): IMP; message 'instanceMethodForSelector:';
  111. class function version: cint; message 'version';
  112. class procedure setVersion_(aVersion: cint); message 'setVersion:';
  113. procedure doesNotRecognizeSelector_(aSelector: SEL); message 'doesNotRecognizeSelector:';
  114. procedure forwardInvocation_(anInvocation: id {NSInvocation}); message 'forwardInvocation:';
  115. function methodSignatureForSelector_(aSelector: SEL): id {NSMethodSignature}; message 'methodSignatureForSelector:';
  116. class function classDescription: id {NSString}; message 'description';
  117. function classForCoder: pobjc_class; message 'classForCoder';
  118. function replacementObjectForCoder_(aCoder: id {NSCoder}): id; message 'replacementObjectForCoder:';
  119. function awakeAfterUsingCoder_(aDecoder: id {NSCoder}): id; message 'awakeAfterUsingCoder:';
  120. end; external;
  121. implementation
  122. {$else }
  123. interface
  124. implementation
  125. {$endif}
  126. end.