CFNumber.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. { CFNumber.h
  2. Copyright (c) 1999-2013, Apple Inc. All rights reserved.
  3. }
  4. {
  5. Modified for use with Free Pascal
  6. Version 308
  7. Please report any bugs to <[email protected]>
  8. }
  9. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  10. {$mode macpas}
  11. {$modeswitch cblocks}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$calling mwpascal}
  16. {$IFNDEF FPC_DOTTEDUNITS}
  17. unit CFNumber;
  18. {$ENDIF FPC_DOTTEDUNITS}
  19. interface
  20. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  21. {$setc GAP_INTERFACES_VERSION := $0308}
  22. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  23. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  24. {$endc}
  25. {$ifc defined CPUPOWERPC and defined CPUI386}
  26. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  27. {$endc}
  28. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  29. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  30. {$endc}
  31. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  32. {$setc __ppc__ := 1}
  33. {$elsec}
  34. {$setc __ppc__ := 0}
  35. {$endc}
  36. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  37. {$setc __ppc64__ := 1}
  38. {$elsec}
  39. {$setc __ppc64__ := 0}
  40. {$endc}
  41. {$ifc not defined __i386__ and defined CPUI386}
  42. {$setc __i386__ := 1}
  43. {$elsec}
  44. {$setc __i386__ := 0}
  45. {$endc}
  46. {$ifc not defined __x86_64__ and defined CPUX86_64}
  47. {$setc __x86_64__ := 1}
  48. {$elsec}
  49. {$setc __x86_64__ := 0}
  50. {$endc}
  51. {$ifc not defined __arm__ and defined CPUARM}
  52. {$setc __arm__ := 1}
  53. {$elsec}
  54. {$setc __arm__ := 0}
  55. {$endc}
  56. {$ifc not defined __arm64__ and defined CPUAARCH64}
  57. {$setc __arm64__ := 1}
  58. {$elsec}
  59. {$setc __arm64__ := 0}
  60. {$endc}
  61. {$ifc defined cpu64}
  62. {$setc __LP64__ := 1}
  63. {$elsec}
  64. {$setc __LP64__ := 0}
  65. {$endc}
  66. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  67. {$error Conflicting definitions for __ppc__ and __i386__}
  68. {$endc}
  69. {$ifc defined __ppc__ and __ppc__}
  70. {$setc TARGET_CPU_PPC := TRUE}
  71. {$setc TARGET_CPU_PPC64 := FALSE}
  72. {$setc TARGET_CPU_X86 := FALSE}
  73. {$setc TARGET_CPU_X86_64 := FALSE}
  74. {$setc TARGET_CPU_ARM := FALSE}
  75. {$setc TARGET_CPU_ARM64 := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_IPHONE := FALSE}
  78. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  79. {$setc TARGET_OS_EMBEDDED := FALSE}
  80. {$elifc defined __ppc64__ and __ppc64__}
  81. {$setc TARGET_CPU_PPC := FALSE}
  82. {$setc TARGET_CPU_PPC64 := TRUE}
  83. {$setc TARGET_CPU_X86 := FALSE}
  84. {$setc TARGET_CPU_X86_64 := FALSE}
  85. {$setc TARGET_CPU_ARM := FALSE}
  86. {$setc TARGET_CPU_ARM64 := FALSE}
  87. {$setc TARGET_OS_MAC := TRUE}
  88. {$setc TARGET_OS_IPHONE := FALSE}
  89. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  90. {$setc TARGET_OS_EMBEDDED := FALSE}
  91. {$elifc defined __i386__ and __i386__}
  92. {$setc TARGET_CPU_PPC := FALSE}
  93. {$setc TARGET_CPU_PPC64 := FALSE}
  94. {$setc TARGET_CPU_X86 := TRUE}
  95. {$setc TARGET_CPU_X86_64 := FALSE}
  96. {$setc TARGET_CPU_ARM := FALSE}
  97. {$setc TARGET_CPU_ARM64 := FALSE}
  98. {$ifc defined iphonesim}
  99. {$setc TARGET_OS_MAC := FALSE}
  100. {$setc TARGET_OS_IPHONE := TRUE}
  101. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  102. {$elsec}
  103. {$setc TARGET_OS_MAC := TRUE}
  104. {$setc TARGET_OS_IPHONE := FALSE}
  105. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  106. {$endc}
  107. {$setc TARGET_OS_EMBEDDED := FALSE}
  108. {$elifc defined __x86_64__ and __x86_64__}
  109. {$setc TARGET_CPU_PPC := FALSE}
  110. {$setc TARGET_CPU_PPC64 := FALSE}
  111. {$setc TARGET_CPU_X86 := FALSE}
  112. {$setc TARGET_CPU_X86_64 := TRUE}
  113. {$setc TARGET_CPU_ARM := FALSE}
  114. {$setc TARGET_CPU_ARM64 := FALSE}
  115. {$ifc defined iphonesim}
  116. {$setc TARGET_OS_MAC := FALSE}
  117. {$setc TARGET_OS_IPHONE := TRUE}
  118. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  119. {$elsec}
  120. {$setc TARGET_OS_MAC := TRUE}
  121. {$setc TARGET_OS_IPHONE := FALSE}
  122. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  123. {$endc}
  124. {$setc TARGET_OS_EMBEDDED := FALSE}
  125. {$elifc defined __arm__ and __arm__}
  126. {$setc TARGET_CPU_PPC := FALSE}
  127. {$setc TARGET_CPU_PPC64 := FALSE}
  128. {$setc TARGET_CPU_X86 := FALSE}
  129. {$setc TARGET_CPU_X86_64 := FALSE}
  130. {$setc TARGET_CPU_ARM := TRUE}
  131. {$setc TARGET_CPU_ARM64 := FALSE}
  132. {$setc TARGET_OS_MAC := FALSE}
  133. {$setc TARGET_OS_IPHONE := TRUE}
  134. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  135. {$setc TARGET_OS_EMBEDDED := TRUE}
  136. {$elifc defined __arm64__ and __arm64__}
  137. {$setc TARGET_CPU_PPC := FALSE}
  138. {$setc TARGET_CPU_PPC64 := FALSE}
  139. {$setc TARGET_CPU_X86 := FALSE}
  140. {$setc TARGET_CPU_X86_64 := FALSE}
  141. {$setc TARGET_CPU_ARM := FALSE}
  142. {$setc TARGET_CPU_ARM64 := TRUE}
  143. {$ifc defined ios}
  144. {$setc TARGET_OS_MAC := FALSE}
  145. {$setc TARGET_OS_IPHONE := TRUE}
  146. {$setc TARGET_OS_EMBEDDED := TRUE}
  147. {$elsec}
  148. {$setc TARGET_OS_MAC := TRUE}
  149. {$setc TARGET_OS_IPHONE := FALSE}
  150. {$setc TARGET_OS_EMBEDDED := FALSE}
  151. {$endc}
  152. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  153. {$elsec}
  154. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  155. {$endc}
  156. {$ifc defined __LP64__ and __LP64__ }
  157. {$setc TARGET_CPU_64 := TRUE}
  158. {$elsec}
  159. {$setc TARGET_CPU_64 := FALSE}
  160. {$endc}
  161. {$ifc defined FPC_BIG_ENDIAN}
  162. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  163. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  164. {$elifc defined FPC_LITTLE_ENDIAN}
  165. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  166. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  167. {$elsec}
  168. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  169. {$endc}
  170. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  171. {$setc CALL_NOT_IN_CARBON := FALSE}
  172. {$setc OLDROUTINENAMES := FALSE}
  173. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  174. {$setc OPAQUE_UPP_TYPES := TRUE}
  175. {$setc OTCARBONAPPLICATION := TRUE}
  176. {$setc OTKERNEL := FALSE}
  177. {$setc PM_USE_SESSION_APIS := TRUE}
  178. {$setc TARGET_API_MAC_CARBON := TRUE}
  179. {$setc TARGET_API_MAC_OS8 := FALSE}
  180. {$setc TARGET_API_MAC_OSX := TRUE}
  181. {$setc TARGET_CARBON := TRUE}
  182. {$setc TARGET_CPU_68K := FALSE}
  183. {$setc TARGET_CPU_MIPS := FALSE}
  184. {$setc TARGET_CPU_SPARC := FALSE}
  185. {$setc TARGET_OS_UNIX := FALSE}
  186. {$setc TARGET_OS_WIN32 := FALSE}
  187. {$setc TARGET_RT_MAC_68881 := FALSE}
  188. {$setc TARGET_RT_MAC_CFM := FALSE}
  189. {$setc TARGET_RT_MAC_MACHO := TRUE}
  190. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  191. {$setc TYPE_BOOL := FALSE}
  192. {$setc TYPE_EXTENDED := FALSE}
  193. {$setc TYPE_LONGLONG := TRUE}
  194. {$IFDEF FPC_DOTTEDUNITS}
  195. uses MacOsApi.MacTypes,MacOsApi.CFBase;
  196. {$ELSE FPC_DOTTEDUNITS}
  197. uses MacTypes,CFBase;
  198. {$ENDIF FPC_DOTTEDUNITS}
  199. {$endc} {not MACOSALLINCLUDE}
  200. {$ALIGN POWER}
  201. type
  202. CFBooleanRef = ^__CFBoolean; { an opaque type }
  203. __CFBoolean = record end;
  204. CFBooleanRefPtr = ^CFBooleanRef;
  205. var kCFBooleanTrue: CFBooleanRef; external name '_kCFBooleanTrue'; (* attribute const *)
  206. var kCFBooleanFalse: CFBooleanRef; external name '_kCFBooleanFalse'; (* attribute const *)
  207. function CFBooleanGetTypeID: CFTypeID; external name '_CFBooleanGetTypeID';
  208. function CFBooleanGetValue( value: CFBooleanRef ): Boolean; external name '_CFBooleanGetValue';
  209. type
  210. CFNumberType = CFIndex;
  211. const
  212. { Types from MacTypes.h }
  213. kCFNumberSInt8Type = 1;
  214. kCFNumberSInt16Type = 2;
  215. kCFNumberSInt32Type = 3;
  216. kCFNumberSInt64Type = 4;
  217. kCFNumberFloat32Type = 5;
  218. kCFNumberFloat64Type = 6; { 64-bit IEEE 754 }
  219. { Basic C types }
  220. kCFNumberCharType = 7;
  221. kCFNumberShortType = 8;
  222. kCFNumberIntType = 9;
  223. kCFNumberLongType = 10;
  224. kCFNumberLongLongType = 11;
  225. kCFNumberFloatType = 12;
  226. kCFNumberDoubleType = 13; { Other }
  227. kCFNumberCFIndexType = 14;
  228. kCFNumberMaxType_MAC_OS_X_VERSION_PRE_10_5 = 14;
  229. {#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  230. kCFNumberNSIntegerType = 15; (* CF_AVAILABLE_STARTING(10_5, 2_0) *)
  231. kCFNumberCGFloatType = 16; (* CF_AVAILABLE_STARTING(10_5, 2_0) *)
  232. kCFNumberMaxType = 16;
  233. {#else
  234. kCFNumberMaxType = 14
  235. #endif}
  236. type
  237. CFNumberRef = ^__CFNumber; { an opaque type }
  238. __CFNumber = record end;
  239. CFNumberRefPtr = ^CFNumberRef;
  240. var kCFNumberPositiveInfinity: CFNumberRef; external name '_kCFNumberPositiveInfinity'; (* attribute const *)
  241. var kCFNumberNegativeInfinity: CFNumberRef; external name '_kCFNumberNegativeInfinity'; (* attribute const *)
  242. var kCFNumberNaN: CFNumberRef; external name '_kCFNumberNaN'; (* attribute const *)
  243. function CFNumberGetTypeID: CFTypeID; external name '_CFNumberGetTypeID';
  244. {
  245. Creates a CFNumber with the given value. The type of number pointed
  246. to by the valuePtr is specified by type. If type is a floating point
  247. type and the value represents one of the infinities or NaN, the
  248. well-defined CFNumber for that value is returned. If either of
  249. valuePtr or type is an invalid value, the result is undefined.
  250. }
  251. function CFNumberCreate( allocator: CFAllocatorRef; theType: CFNumberType; valuePtr: {const} UnivPtr ): CFNumberRef; external name '_CFNumberCreate';
  252. {
  253. Returns the storage format of the CFNumber's value. Note that
  254. this is not necessarily the type provided in CFNumberCreate().
  255. }
  256. function CFNumberGetType( number: CFNumberRef ): CFNumberType; external name '_CFNumberGetType';
  257. {
  258. Returns the size in bytes of the type of the number.
  259. }
  260. function CFNumberGetByteSize( number: CFNumberRef ): CFIndex; external name '_CFNumberGetByteSize';
  261. {
  262. Returns true if the type of the CFNumber's value is one of
  263. the defined floating point types.
  264. }
  265. function CFNumberIsFloatType( number: CFNumberRef ): Boolean; external name '_CFNumberIsFloatType';
  266. {
  267. Copies the CFNumber's value into the space pointed to by
  268. valuePtr, as the specified type. If conversion needs to take
  269. place, the conversion rules follow human expectation and not
  270. C's promotion and truncation rules. If the conversion is
  271. lossy, or the value is out of range, false is returned. Best
  272. attempt at conversion will still be in *valuePtr.
  273. }
  274. function CFNumberGetValue( number: CFNumberRef; theType: CFNumberType; valuePtr: UnivPtr ): Boolean; external name '_CFNumberGetValue';
  275. {
  276. Compares the two CFNumber instances. If conversion of the
  277. types of the values is needed, the conversion and comparison
  278. follow human expectations and not C's promotion and comparison
  279. rules. Negative zero compares less than positive zero.
  280. Positive infinity compares greater than everything except
  281. itself, to which it compares equal. Negative infinity compares
  282. less than everything except itself, to which it compares equal.
  283. Unlike standard practice, if both numbers are NaN, then they
  284. compare equal; if only one of the numbers is NaN, then the NaN
  285. compares greater than the other number if it is negative, and
  286. smaller than the other number if it is positive. (Note that in
  287. CFEqual() with two CFNumbers, if either or both of the numbers
  288. is NaN, true is returned.)
  289. }
  290. function CFNumberCompare( number: CFNumberRef; otherNumber: CFNumberRef; context: UnivPtr ): CFComparisonResult; external name '_CFNumberCompare';
  291. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  292. end.
  293. {$endc} {not MACOSALLINCLUDE}