CFArray.pas 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. { CFArray.h
  2. Copyright (c) 1998-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. {$packenum 1}
  12. {$macro on}
  13. {$inline on}
  14. {$calling mwpascal}
  15. unit CFArray;
  16. interface
  17. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  18. {$setc GAP_INTERFACES_VERSION := $0308}
  19. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  20. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  21. {$endc}
  22. {$ifc defined CPUPOWERPC and defined CPUI386}
  23. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  24. {$endc}
  25. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  26. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  27. {$endc}
  28. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  29. {$setc __ppc__ := 1}
  30. {$elsec}
  31. {$setc __ppc__ := 0}
  32. {$endc}
  33. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  34. {$setc __ppc64__ := 1}
  35. {$elsec}
  36. {$setc __ppc64__ := 0}
  37. {$endc}
  38. {$ifc not defined __i386__ and defined CPUI386}
  39. {$setc __i386__ := 1}
  40. {$elsec}
  41. {$setc __i386__ := 0}
  42. {$endc}
  43. {$ifc not defined __x86_64__ and defined CPUX86_64}
  44. {$setc __x86_64__ := 1}
  45. {$elsec}
  46. {$setc __x86_64__ := 0}
  47. {$endc}
  48. {$ifc not defined __arm__ and defined CPUARM}
  49. {$setc __arm__ := 1}
  50. {$elsec}
  51. {$setc __arm__ := 0}
  52. {$endc}
  53. {$ifc not defined __arm64__ and defined CPUAARCH64}
  54. {$setc __arm64__ := 1}
  55. {$elsec}
  56. {$setc __arm64__ := 0}
  57. {$endc}
  58. {$ifc defined cpu64}
  59. {$setc __LP64__ := 1}
  60. {$elsec}
  61. {$setc __LP64__ := 0}
  62. {$endc}
  63. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  64. {$error Conflicting definitions for __ppc__ and __i386__}
  65. {$endc}
  66. {$ifc defined __ppc__ and __ppc__}
  67. {$setc TARGET_CPU_PPC := TRUE}
  68. {$setc TARGET_CPU_PPC64 := FALSE}
  69. {$setc TARGET_CPU_X86 := FALSE}
  70. {$setc TARGET_CPU_X86_64 := FALSE}
  71. {$setc TARGET_CPU_ARM := FALSE}
  72. {$setc TARGET_CPU_ARM64 := FALSE}
  73. {$setc TARGET_OS_MAC := TRUE}
  74. {$setc TARGET_OS_IPHONE := FALSE}
  75. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  76. {$setc TARGET_OS_EMBEDDED := FALSE}
  77. {$elifc defined __ppc64__ and __ppc64__}
  78. {$setc TARGET_CPU_PPC := FALSE}
  79. {$setc TARGET_CPU_PPC64 := TRUE}
  80. {$setc TARGET_CPU_X86 := FALSE}
  81. {$setc TARGET_CPU_X86_64 := FALSE}
  82. {$setc TARGET_CPU_ARM := FALSE}
  83. {$setc TARGET_CPU_ARM64 := FALSE}
  84. {$setc TARGET_OS_MAC := TRUE}
  85. {$setc TARGET_OS_IPHONE := FALSE}
  86. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  87. {$setc TARGET_OS_EMBEDDED := FALSE}
  88. {$elifc defined __i386__ and __i386__}
  89. {$setc TARGET_CPU_PPC := FALSE}
  90. {$setc TARGET_CPU_PPC64 := FALSE}
  91. {$setc TARGET_CPU_X86 := TRUE}
  92. {$setc TARGET_CPU_X86_64 := FALSE}
  93. {$setc TARGET_CPU_ARM := FALSE}
  94. {$setc TARGET_CPU_ARM64 := FALSE}
  95. {$ifc defined(iphonesim)}
  96. {$setc TARGET_OS_MAC := FALSE}
  97. {$setc TARGET_OS_IPHONE := TRUE}
  98. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  99. {$elsec}
  100. {$setc TARGET_OS_MAC := TRUE}
  101. {$setc TARGET_OS_IPHONE := FALSE}
  102. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  103. {$endc}
  104. {$setc TARGET_OS_EMBEDDED := FALSE}
  105. {$elifc defined __x86_64__ and __x86_64__}
  106. {$setc TARGET_CPU_PPC := FALSE}
  107. {$setc TARGET_CPU_PPC64 := FALSE}
  108. {$setc TARGET_CPU_X86 := FALSE}
  109. {$setc TARGET_CPU_X86_64 := TRUE}
  110. {$setc TARGET_CPU_ARM := FALSE}
  111. {$setc TARGET_CPU_ARM64 := FALSE}
  112. {$ifc defined(iphonesim)}
  113. {$setc TARGET_OS_MAC := FALSE}
  114. {$setc TARGET_OS_IPHONE := TRUE}
  115. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  116. {$elsec}
  117. {$setc TARGET_OS_MAC := TRUE}
  118. {$setc TARGET_OS_IPHONE := FALSE}
  119. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  120. {$endc}
  121. {$setc TARGET_OS_EMBEDDED := FALSE}
  122. {$elifc defined __arm__ and __arm__}
  123. {$setc TARGET_CPU_PPC := FALSE}
  124. {$setc TARGET_CPU_PPC64 := FALSE}
  125. {$setc TARGET_CPU_X86 := FALSE}
  126. {$setc TARGET_CPU_X86_64 := FALSE}
  127. {$setc TARGET_CPU_ARM := TRUE}
  128. {$setc TARGET_CPU_ARM64 := FALSE}
  129. { will require compiler define when/if other Apple devices with ARM cpus ship }
  130. {$setc TARGET_OS_MAC := FALSE}
  131. {$setc TARGET_OS_IPHONE := TRUE}
  132. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  133. {$setc TARGET_OS_EMBEDDED := TRUE}
  134. {$elifc defined __arm64__ and __arm64__}
  135. {$setc TARGET_CPU_PPC := FALSE}
  136. {$setc TARGET_CPU_PPC64 := FALSE}
  137. {$setc TARGET_CPU_X86 := FALSE}
  138. {$setc TARGET_CPU_X86_64 := FALSE}
  139. {$setc TARGET_CPU_ARM := FALSE}
  140. {$setc TARGET_CPU_ARM64 := TRUE}
  141. { will require compiler define when/if other Apple devices with ARM cpus ship }
  142. {$setc TARGET_OS_MAC := FALSE}
  143. {$setc TARGET_OS_IPHONE := TRUE}
  144. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  145. {$setc TARGET_OS_EMBEDDED := TRUE}
  146. {$elsec}
  147. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  148. {$endc}
  149. {$ifc defined __LP64__ and __LP64__ }
  150. {$setc TARGET_CPU_64 := TRUE}
  151. {$elsec}
  152. {$setc TARGET_CPU_64 := FALSE}
  153. {$endc}
  154. {$ifc defined FPC_BIG_ENDIAN}
  155. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  156. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  157. {$elifc defined FPC_LITTLE_ENDIAN}
  158. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  159. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  160. {$elsec}
  161. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  162. {$endc}
  163. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  164. {$setc CALL_NOT_IN_CARBON := FALSE}
  165. {$setc OLDROUTINENAMES := FALSE}
  166. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  167. {$setc OPAQUE_UPP_TYPES := TRUE}
  168. {$setc OTCARBONAPPLICATION := TRUE}
  169. {$setc OTKERNEL := FALSE}
  170. {$setc PM_USE_SESSION_APIS := TRUE}
  171. {$setc TARGET_API_MAC_CARBON := TRUE}
  172. {$setc TARGET_API_MAC_OS8 := FALSE}
  173. {$setc TARGET_API_MAC_OSX := TRUE}
  174. {$setc TARGET_CARBON := TRUE}
  175. {$setc TARGET_CPU_68K := FALSE}
  176. {$setc TARGET_CPU_MIPS := FALSE}
  177. {$setc TARGET_CPU_SPARC := FALSE}
  178. {$setc TARGET_OS_UNIX := FALSE}
  179. {$setc TARGET_OS_WIN32 := FALSE}
  180. {$setc TARGET_RT_MAC_68881 := FALSE}
  181. {$setc TARGET_RT_MAC_CFM := FALSE}
  182. {$setc TARGET_RT_MAC_MACHO := TRUE}
  183. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  184. {$setc TYPE_BOOL := FALSE}
  185. {$setc TYPE_EXTENDED := FALSE}
  186. {$setc TYPE_LONGLONG := TRUE}
  187. uses MacTypes,CFBase;
  188. {$endc} {not MACOSALLINCLUDE}
  189. {$ALIGN POWER}
  190. {!
  191. @header CFArray
  192. CFArray implements an ordered, compact container of pointer-sized
  193. values. Values are accessed via integer keys (indices), from the
  194. range 0 to N-1, where N is the number of values in the array when
  195. an operation is performed. The array is said to be "compact" because
  196. deleted or inserted values do not leave a gap in the key space --
  197. the values with higher-numbered indices have their indices
  198. renumbered lower (or higher, in the case of insertion) so that the
  199. set of valid indices is always in the integer range [0, N-1]. Thus,
  200. the index to access a particular value in the array may change over
  201. time as other values are inserted into or deleted from the array.
  202. Arrays come in two flavors, immutable, which cannot have values
  203. added to them or removed from them after the array is created, and
  204. mutable, to which you can add values or from which remove values.
  205. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  206. Mutable arrays have two subflavors, fixed-capacity, for which there
  207. is a maximum number set at creation time of values which can be put
  208. into the array, and variable capacity, which can have an unlimited
  209. number of values (or rather, limited only by constraints external
  210. to CFArray, like the amount of available memory). Fixed-capacity
  211. arrays can be somewhat higher performing, if you can put a definite
  212. upper limit on the number of values that might be put into the
  213. array.
  214. #else
  215. Mutable arrays can have an unlimited number of values (or rather,
  216. limited only by constraints external to CFArray, like the amount
  217. of available memory).
  218. #endif
  219. As with all CoreFoundation collection types, arrays maintain hard
  220. references on the values you put in them, but the retaining and
  221. releasing functions are user-defined callbacks that can actually do
  222. whatever the user wants (for example, nothing).
  223. Computational Complexity
  224. The access time for a value in the array is guaranteed to be at
  225. worst O(lg N) for any implementation, current and future, but will
  226. often be O(1) (constant time). Linear search operations similarly
  227. have a worst case complexity of O(N*lg N), though typically the
  228. bounds will be tighter, and so on. Insertion or deletion operations
  229. will typically be linear in the number of values in the array, but
  230. may be O(N*lg N) clearly in the worst case in some implementations.
  231. There are no favored positions within the array for performance;
  232. that is, it is not necessarily faster to access values with low
  233. indices, or to insert or delete values with high indices, or
  234. whatever.
  235. }
  236. {!
  237. @typedef CFArrayCallBacks
  238. Structure containing the callbacks of a CFArray.
  239. @field version The version number of the structure type being passed
  240. in as a parameter to the CFArray creation functions. This
  241. structure is version 0.
  242. @field retain The callback used to add a retain for the array on
  243. values as they are put into the array. This callback returns
  244. the value to store in the array, which is usually the value
  245. parameter passed to this callback, but may be a different
  246. value if a different value should be stored in the array.
  247. The array's allocator is passed as the first argument.
  248. @field release The callback used to remove a retain previously added
  249. for the array from values as they are removed from the
  250. array. The array's allocator is passed as the first
  251. argument.
  252. @field copyDescription The callback used to create a descriptive
  253. string representation of each value in the array. This is
  254. used by the CFCopyDescription() function.
  255. @field equal The callback used to compare values in the array for
  256. equality for some operations.
  257. }
  258. type
  259. CFArrayRetainCallBack = function( allocator: CFAllocatorRef; value: {const} UnivPtr ): UnivPtr;
  260. CFArrayReleaseCallBack = procedure( allocator: CFAllocatorRef; value: {const} UnivPtr );
  261. CFArrayCopyDescriptionCallBack = function( value: {const} UnivPtr ): CFStringRef;
  262. CFArrayEqualCallBack = function( value1: {const} UnivPtr; value2: {const} UnivPtr ): Boolean;
  263. CFArrayCallBacks = record
  264. version: CFIndex;
  265. retain: CFArrayRetainCallBack;
  266. release: CFArrayReleaseCallBack;
  267. copyDescription: CFArrayCopyDescriptionCallBack;
  268. equal: CFArrayEqualCallBack;
  269. end;
  270. CFArrayCallBacksPtr = ^CFArrayCallBacks;
  271. {!
  272. @constant kCFTypeArrayCallBacks
  273. Predefined CFArrayCallBacks structure containing a set of callbacks
  274. appropriate for use when the values in a CFArray are all CFTypes.
  275. }
  276. var kCFTypeArrayCallBacks: CFArrayCallBacks; external name '_kCFTypeArrayCallBacks'; (* attribute const *)
  277. {!
  278. @typedef CFArrayApplierFunction
  279. Type of the callback function used by the apply functions of
  280. CFArrays.
  281. @param value The current value from the array.
  282. @param context The user-defined context parameter given to the apply
  283. function.
  284. }
  285. type
  286. CFArrayApplierFunction = procedure( value: {const} UnivPtr; context: UnivPtr );
  287. {!
  288. @typedef CFArrayRef
  289. This is the type of a reference to immutable CFArrays.
  290. }
  291. type
  292. CFArrayRef = ^__CFArray; { an opaque type }
  293. __CFArray = record end;
  294. CFArrayRefPtr = ^CFArrayRef;
  295. {!
  296. @typedef CFMutableArrayRef
  297. This is the type of a reference to mutable CFArrays.
  298. }
  299. type
  300. CFMutableArrayRef = CFArrayRef;
  301. CFMutableArrayRefPtr = ^CFMutableArrayRef;
  302. {!
  303. @function CFArrayGetTypeID
  304. Returns the type identifier of all CFArray instances.
  305. }
  306. function CFArrayGetTypeID: CFTypeID; external name '_CFArrayGetTypeID';
  307. {!
  308. @function CFArrayCreate
  309. Creates a new immutable array with the given values.
  310. @param allocator The CFAllocator which should be used to allocate
  311. memory for the array and its storage for values. This
  312. parameter may be NULL in which case the current default
  313. CFAllocator is used. If this reference is not a valid
  314. CFAllocator, the behavior is undefined.
  315. @param values A C array of the pointer-sized values to be in the
  316. array. The values in the array are ordered in the same order
  317. in which they appear in this C array. This parameter may be
  318. NULL if the numValues parameter is 0. This C array is not
  319. changed or freed by this function. If this parameter is not
  320. a valid pointer to a C array of at least numValues pointers,
  321. the behavior is undefined.
  322. @param numValues The number of values to copy from the values C
  323. array into the CFArray. This number will be the count of the
  324. array.
  325. If this parameter is negative, or greater than the number of
  326. values actually in the value's C array, the behavior is
  327. undefined.
  328. @param callBacks A pointer to a CFArrayCallBacks structure
  329. initialized with the callbacks for the array to use on each
  330. value in the array. The retain callback will be used within
  331. this function, for example, to retain all of the new values
  332. from the values C array. A copy of the contents of the
  333. callbacks structure is made, so that a pointer to a
  334. structure on the stack can be passed in, or can be reused
  335. for multiple array creations. If the version field of this
  336. callbacks structure is not one of the defined ones for
  337. CFArray, the behavior is undefined. The retain field may be
  338. NULL, in which case the CFArray will do nothing to add a
  339. retain to the contained values for the array. The release
  340. field may be NULL, in which case the CFArray will do nothing
  341. to remove the array's retain (if any) on the values when the
  342. array is destroyed. If the copyDescription field is NULL,
  343. the array will create a simple description for the value. If
  344. the equal field is NULL, the array will use pointer equality
  345. to test for equality of values. This callbacks parameter
  346. itself may be NULL, which is treated as if a valid structure
  347. of version 0 with all fields NULL had been passed in.
  348. Otherwise, if any of the fields are not valid pointers to
  349. functions of the correct type, or this parameter is not a
  350. valid pointer to a CFArrayCallBacks callbacks structure,
  351. the behavior is undefined. If any of the values put into the
  352. array is not one understood by one of the callback functions
  353. the behavior when that callback function is used is
  354. undefined.
  355. @result A reference to the new immutable CFArray.
  356. }
  357. function CFArrayCreate( allocator: CFAllocatorRef; {const} values: {variable-size-array} UnivPtrPtr; numValues: CFIndex; {const} callBacks: CFArrayCallBacksPtr { can be NULL } ): CFArrayRef; external name '_CFArrayCreate';
  358. {!
  359. @function CFArrayCreateCopy
  360. Creates a new immutable array with the values from the given array.
  361. @param allocator The CFAllocator which should be used to allocate
  362. memory for the array and its storage for values. This
  363. parameter may be NULL in which case the current default
  364. CFAllocator is used. If this reference is not a valid
  365. CFAllocator, the behavior is undefined.
  366. @param theArray The array which is to be copied. The values from the
  367. array are copied as pointers into the new array (that is,
  368. the values themselves are copied, not that which the values
  369. point to, if anything). However, the values are also
  370. retained by the new array. The count of the new array will
  371. be the same as the given array. The new array uses the same
  372. callbacks as the array to be copied. If this parameter is
  373. not a valid CFArray, the behavior is undefined.
  374. @result A reference to the new immutable CFArray.
  375. }
  376. function CFArrayCreateCopy( allocator: CFAllocatorRef; theArray: CFArrayRef ): CFArrayRef; external name '_CFArrayCreateCopy';
  377. {!
  378. @function CFArrayCreateMutable
  379. Creates a new empty mutable array.
  380. @param allocator The CFAllocator which should be used to allocate
  381. memory for the array and its storage for values. This
  382. parameter may be NULL in which case the current default
  383. CFAllocator is used. If this reference is not a valid
  384. CFAllocator, the behavior is undefined.
  385. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  386. @param capacity The maximum number of values that can be contained
  387. by the CFArray. The array starts empty, and can grow to this
  388. number of values (and it can have less). If this parameter
  389. is 0, the array's maximum capacity is unlimited (or rather,
  390. only limited by address space and available memory
  391. constraints). If this parameter is negative, the behavior is
  392. undefined.
  393. #else
  394. @param capacity A hint about the number of values that will be held
  395. by the CFArray. Pass 0 for no hint. The implementation may
  396. ignore this hint, or may use it to optimize various
  397. operations. An array's actual capacity is only limited by
  398. address space and available memory constraints). If this
  399. parameter is negative, the behavior is undefined.
  400. #endif
  401. @param callBacks A pointer to a CFArrayCallBacks structure
  402. initialized with the callbacks for the array to use on each
  403. value in the array. A copy of the contents of the
  404. callbacks structure is made, so that a pointer to a
  405. structure on the stack can be passed in, or can be reused
  406. for multiple array creations. If the version field of this
  407. callbacks structure is not one of the defined ones for
  408. CFArray, the behavior is undefined. The retain field may be
  409. NULL, in which case the CFArray will do nothing to add a
  410. retain to the contained values for the array. The release
  411. field may be NULL, in which case the CFArray will do nothing
  412. to remove the array's retain (if any) on the values when the
  413. array is destroyed. If the copyDescription field is NULL,
  414. the array will create a simple description for the value. If
  415. the equal field is NULL, the array will use pointer equality
  416. to test for equality of values. This callbacks parameter
  417. itself may be NULL, which is treated as if a valid structure
  418. of version 0 with all fields NULL had been passed in.
  419. Otherwise, if any of the fields are not valid pointers to
  420. functions of the correct type, or this parameter is not a
  421. valid pointer to a CFArrayCallBacks callbacks structure,
  422. the behavior is undefined. If any of the values put into the
  423. array is not one understood by one of the callback functions
  424. the behavior when that callback function is used is
  425. undefined.
  426. @result A reference to the new mutable CFArray.
  427. }
  428. function CFArrayCreateMutable( allocator: CFAllocatorRef; capacity: CFIndex; {const} callBacks: CFArrayCallBacksPtr { can be NULL } ): CFMutableArrayRef; external name '_CFArrayCreateMutable';
  429. {!
  430. @function CFArrayCreateMutableCopy
  431. Creates a new mutable array with the values from the given array.
  432. @param allocator The CFAllocator which should be used to allocate
  433. memory for the array and its storage for values. This
  434. parameter may be NULL in which case the current default
  435. CFAllocator is used. If this reference is not a valid
  436. CFAllocator, the behavior is undefined.
  437. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  438. @param capacity The maximum number of values that can be contained
  439. by the CFArray. The array starts empty, and can grow to this
  440. number of values (and it can have less). If this parameter
  441. is 0, the array's maximum capacity is unlimited (or rather,
  442. only limited by address space and available memory
  443. constraints). This parameter must be greater than or equal
  444. to the count of the array which is to be copied, or the
  445. behavior is undefined. If this parameter is negative, the
  446. behavior is undefined.
  447. #else
  448. @param capacity A hint about the number of values that will be held
  449. by the CFArray. Pass 0 for no hint. The implementation may
  450. ignore this hint, or may use it to optimize various
  451. operations. An array's actual capacity is only limited by
  452. address space and available memory constraints).
  453. This parameter must be greater than or equal
  454. to the count of the array which is to be copied, or the
  455. behavior is undefined. If this parameter is negative, the
  456. behavior is undefined.
  457. #endif
  458. @param theArray The array which is to be copied. The values from the
  459. array are copied as pointers into the new array (that is,
  460. the values themselves are copied, not that which the values
  461. point to, if anything). However, the values are also
  462. retained by the new array. The count of the new array will
  463. be the same as the given array. The new array uses the same
  464. callbacks as the array to be copied. If this parameter is
  465. not a valid CFArray, the behavior is undefined.
  466. @result A reference to the new mutable CFArray.
  467. }
  468. function CFArrayCreateMutableCopy( allocator: CFAllocatorRef; capacity: CFIndex; theArray: CFArrayRef ): CFMutableArrayRef; external name '_CFArrayCreateMutableCopy';
  469. {!
  470. @function CFArrayGetCount
  471. Returns the number of values currently in the array.
  472. @param theArray The array to be queried. If this parameter is not a valid
  473. CFArray, the behavior is undefined.
  474. @result The number of values in the array.
  475. }
  476. function CFArrayGetCount( theArray: CFArrayRef ): CFIndex; external name '_CFArrayGetCount';
  477. {!
  478. @function CFArrayGetCountOfValue
  479. Counts the number of times the given value occurs in the array.
  480. @param theArray The array to be searched. If this parameter is not a
  481. valid CFArray, the behavior is undefined.
  482. @param range The range within the array to search. If the range
  483. location or end point (defined by the location plus length
  484. minus 1) is outside the index space of the array (0 to
  485. N-1 inclusive, where N is the count of the array), the
  486. behavior is undefined. If the range length is negative, the
  487. behavior is undefined. The range may be empty (length 0).
  488. @param value The value for which to find matches in the array. The
  489. equal() callback provided when the array was created is
  490. used to compare. If the equal() callback was NULL, pointer
  491. equality (in C, ==) is used. If value, or any of the values
  492. in the array, are not understood by the equal() callback,
  493. the behavior is undefined.
  494. @result The number of times the given value occurs in the array,
  495. within the specified range.
  496. }
  497. function CFArrayGetCountOfValue( theArray: CFArrayRef; range: CFRange; value: {const} UnivPtr ): CFIndex; external name '_CFArrayGetCountOfValue';
  498. {!
  499. @function CFArrayContainsValue
  500. Reports whether or not the value is in the array.
  501. @param theArray The array to be searched. If this parameter is not a
  502. valid CFArray, the behavior is undefined.
  503. @param range The range within the array to search. If the range
  504. location or end point (defined by the location plus length
  505. minus 1) is outside the index space of the array (0 to
  506. N-1 inclusive, where N is the count of the array), the
  507. behavior is undefined. If the range length is negative, the
  508. behavior is undefined. The range may be empty (length 0).
  509. @param value The value for which to find matches in the array. The
  510. equal() callback provided when the array was created is
  511. used to compare. If the equal() callback was NULL, pointer
  512. equality (in C, ==) is used. If value, or any of the values
  513. in the array, are not understood by the equal() callback,
  514. the behavior is undefined.
  515. @result true, if the value is in the specified range of the array,
  516. otherwise false.
  517. }
  518. function CFArrayContainsValue( theArray: CFArrayRef; range: CFRange; value: {const} UnivPtr ): Boolean; external name '_CFArrayContainsValue';
  519. {!
  520. @function CFArrayGetValueAtIndex
  521. Retrieves the value at the given index.
  522. @param theArray The array to be queried. If this parameter is not a
  523. valid CFArray, the behavior is undefined.
  524. @param idx The index of the value to retrieve. If the index is
  525. outside the index space of the array (0 to N-1 inclusive,
  526. where N is the count of the array), the behavior is
  527. undefined.
  528. @result The value with the given index in the array.
  529. }
  530. function CFArrayGetValueAtIndex( theArray: CFArrayRef; idx: CFIndex ): UnivPtr; external name '_CFArrayGetValueAtIndex';
  531. {!
  532. @function CFArrayGetValues
  533. Fills the buffer with values from the array.
  534. @param theArray The array to be queried. If this parameter is not a
  535. valid CFArray, the behavior is undefined.
  536. @param range The range of values within the array to retrieve. If
  537. the range location or end point (defined by the location
  538. plus length minus 1) is outside the index space of the
  539. array (0 to N-1 inclusive, where N is the count of the
  540. array), the behavior is undefined. If the range length is
  541. negative, the behavior is undefined. The range may be empty
  542. (length 0), in which case no values are put into the buffer.
  543. @param values A C array of pointer-sized values to be filled with
  544. values from the array. The values in the C array are ordered
  545. in the same order in which they appear in the array. If this
  546. parameter is not a valid pointer to a C array of at least
  547. range.length pointers, the behavior is undefined.
  548. }
  549. procedure CFArrayGetValues( theArray: CFArrayRef; range: CFRange; {const} values: {variable-size-array} UnivPtrPtr ); external name '_CFArrayGetValues';
  550. {!
  551. @function CFArrayApplyFunction
  552. Calls a function once for each value in the array.
  553. @param theArray The array to be operated upon. If this parameter is not
  554. a valid CFArray, the behavior is undefined.
  555. @param range The range of values within the array to which to apply
  556. the function. If the range location or end point (defined by
  557. the location plus length minus 1) is outside the index
  558. space of the array (0 to N-1 inclusive, where N is the count
  559. of the array), the behavior is undefined. If the range
  560. length is negative, the behavior is undefined. The range may
  561. be empty (length 0).
  562. @param applier The callback function to call once for each value in
  563. the given range in the array. If this parameter is not a
  564. pointer to a function of the correct prototype, the behavior
  565. is undefined. If there are values in the range which the
  566. applier function does not expect or cannot properly apply
  567. to, the behavior is undefined.
  568. @param context A pointer-sized user-defined value, which is passed
  569. as the second parameter to the applier function, but is
  570. otherwise unused by this function. If the context is not
  571. what is expected by the applier function, the behavior is
  572. undefined.
  573. }
  574. procedure CFArrayApplyFunction( theArray: CFArrayRef; range: CFRange; applier: CFArrayApplierFunction; context: UnivPtr ); external name '_CFArrayApplyFunction';
  575. {!
  576. @function CFArrayGetFirstIndexOfValue
  577. Searches the array for the value.
  578. @param theArray The array to be searched. If this parameter is not a
  579. valid CFArray, the behavior is undefined.
  580. @param range The range within the array to search. If the range
  581. location or end point (defined by the location plus length
  582. minus 1) is outside the index space of the array (0 to
  583. N-1 inclusive, where N is the count of the array), the
  584. behavior is undefined. If the range length is negative, the
  585. behavior is undefined. The range may be empty (length 0).
  586. The search progresses from the smallest index defined by
  587. the range to the largest.
  588. @param value The value for which to find a match in the array. The
  589. equal() callback provided when the array was created is
  590. used to compare. If the equal() callback was NULL, pointer
  591. equality (in C, ==) is used. If value, or any of the values
  592. in the array, are not understood by the equal() callback,
  593. the behavior is undefined.
  594. @result The lowest index of the matching values in the range, or
  595. kCFNotFound if no value in the range matched.
  596. }
  597. function CFArrayGetFirstIndexOfValue( theArray: CFArrayRef; range: CFRange; value: {const} UnivPtr ): CFIndex; external name '_CFArrayGetFirstIndexOfValue';
  598. {!
  599. @function CFArrayGetLastIndexOfValue
  600. Searches the array for the value.
  601. @param theArray The array to be searched. If this parameter is not a
  602. valid CFArray, the behavior is undefined.
  603. @param range The range within the array to search. If the range
  604. location or end point (defined by the location plus length
  605. minus 1) is outside the index space of the array (0 to
  606. N-1 inclusive, where N is the count of the array), the
  607. behavior is undefined. If the range length is negative, the
  608. behavior is undefined. The range may be empty (length 0).
  609. The search progresses from the largest index defined by the
  610. range to the smallest.
  611. @param value The value for which to find a match in the array. The
  612. equal() callback provided when the array was created is
  613. used to compare. If the equal() callback was NULL, pointer
  614. equality (in C, ==) is used. If value, or any of the values
  615. in the array, are not understood by the equal() callback,
  616. the behavior is undefined.
  617. @result The highest index of the matching values in the range, or
  618. kCFNotFound if no value in the range matched.
  619. }
  620. function CFArrayGetLastIndexOfValue( theArray: CFArrayRef; range: CFRange; value: {const} UnivPtr ): CFIndex; external name '_CFArrayGetLastIndexOfValue';
  621. {!
  622. @function CFArrayBSearchValues
  623. Searches the array for the value using a binary search algorithm.
  624. @param theArray The array to be searched. If this parameter is not a
  625. valid CFArray, the behavior is undefined. If the array is
  626. not sorted from least to greatest according to the
  627. comparator function, the behavior is undefined.
  628. @param range The range within the array to search. If the range
  629. location or end point (defined by the location plus length
  630. minus 1) is outside the index space of the array (0 to
  631. N-1 inclusive, where N is the count of the array), the
  632. behavior is undefined. If the range length is negative, the
  633. behavior is undefined. The range may be empty (length 0).
  634. @param value The value for which to find a match in the array. If
  635. value, or any of the values in the array, are not understood
  636. by the comparator callback, the behavior is undefined.
  637. @param comparator The function with the comparator function type
  638. signature which is used in the binary search operation to
  639. compare values in the array with the given value. If this
  640. parameter is not a pointer to a function of the correct
  641. prototype, the behavior is undefined. If there are values
  642. in the range which the comparator function does not expect
  643. or cannot properly compare, the behavior is undefined.
  644. @param context A pointer-sized user-defined value, which is passed
  645. as the third parameter to the comparator function, but is
  646. otherwise unused by this function. If the context is not
  647. what is expected by the comparator function, the behavior is
  648. undefined.
  649. @result The return value is either 1) the index of a value that
  650. matched, if the target value matches one or more in the
  651. range, 2) greater than or equal to the end point of the
  652. range, if the value is greater than all the values in the
  653. range, or 3) the index of the value greater than the target
  654. value, if the value lies between two of (or less than all
  655. of) the values in the range.
  656. }
  657. function CFArrayBSearchValues( theArray: CFArrayRef; range: CFRange; value: {const} UnivPtr; comparator: CFComparatorFunction; context: UnivPtr ): CFIndex; external name '_CFArrayBSearchValues';
  658. {!
  659. @function CFArrayAppendValue
  660. Adds the value to the array giving it a new largest index.
  661. @param theArray The array to which the value is to be added. If this
  662. parameter is not a valid mutable CFArray, the behavior is
  663. undefined.
  664. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  665. If the array is a fixed-capacity array and it
  666. is full before this operation, the behavior is undefined.
  667. #endif
  668. @param value The value to add to the array. The value is retained by
  669. the array using the retain callback provided when the array
  670. was created. If the value is not of the sort expected by the
  671. retain callback, the behavior is undefined. The value is
  672. assigned to the index one larger than the previous largest
  673. index, and the count of the array is increased by one.
  674. }
  675. procedure CFArrayAppendValue( theArray: CFMutableArrayRef; value: {const} UnivPtr ); external name '_CFArrayAppendValue';
  676. {!
  677. @function CFArrayInsertValueAtIndex
  678. Adds the value to the array, giving it the given index.
  679. @param theArray The array to which the value is to be added. If this
  680. parameter is not a valid mutable CFArray, the behavior is
  681. undefined.
  682. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  683. If the array is a fixed-capacity array and it
  684. is full before this operation, the behavior is undefined.
  685. #endif
  686. @param idx The index to which to add the new value. If the index is
  687. outside the index space of the array (0 to N inclusive,
  688. where N is the count of the array before the operation), the
  689. behavior is undefined. If the index is the same as N, this
  690. function has the same effect as CFArrayAppendValue().
  691. @param value The value to add to the array. The value is retained by
  692. the array using the retain callback provided when the array
  693. was created. If the value is not of the sort expected by the
  694. retain callback, the behavior is undefined. The value is
  695. assigned to the given index, and all values with equal and
  696. larger indices have their indexes increased by one.
  697. }
  698. procedure CFArrayInsertValueAtIndex( theArray: CFMutableArrayRef; idx: CFIndex; value: {const} UnivPtr ); external name '_CFArrayInsertValueAtIndex';
  699. {!
  700. @function CFArraySetValueAtIndex
  701. Changes the value with the given index in the array.
  702. @param theArray The array in which the value is to be changed. If this
  703. parameter is not a valid mutable CFArray, the behavior is
  704. undefined.
  705. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  706. If the array is a fixed-capacity array and it
  707. is full before this operation and the index is the same as
  708. N, the behavior is undefined.
  709. #endif
  710. @param idx The index to which to set the new value. If the index is
  711. outside the index space of the array (0 to N inclusive,
  712. where N is the count of the array before the operation), the
  713. behavior is undefined. If the index is the same as N, this
  714. function has the same effect as CFArrayAppendValue().
  715. @param value The value to set in the array. The value is retained by
  716. the array using the retain callback provided when the array
  717. was created, and the previous value with that index is
  718. released. If the value is not of the sort expected by the
  719. retain callback, the behavior is undefined. The indices of
  720. other values is not affected.
  721. }
  722. procedure CFArraySetValueAtIndex( theArray: CFMutableArrayRef; idx: CFIndex; value: {const} UnivPtr ); external name '_CFArraySetValueAtIndex';
  723. {!
  724. @function CFArrayRemoveValueAtIndex
  725. Removes the value with the given index from the array.
  726. @param theArray The array from which the value is to be removed. If
  727. this parameter is not a valid mutable CFArray, the behavior
  728. is undefined.
  729. @param idx The index from which to remove the value. If the index is
  730. outside the index space of the array (0 to N-1 inclusive,
  731. where N is the count of the array before the operation), the
  732. behavior is undefined.
  733. }
  734. procedure CFArrayRemoveValueAtIndex( theArray: CFMutableArrayRef; idx: CFIndex ); external name '_CFArrayRemoveValueAtIndex';
  735. {!
  736. @function CFArrayRemoveAllValues
  737. Removes all the values from the array, making it empty.
  738. @param theArray The array from which all of the values are to be
  739. removed. If this parameter is not a valid mutable CFArray,
  740. the behavior is undefined.
  741. }
  742. procedure CFArrayRemoveAllValues( theArray: CFMutableArrayRef ); external name '_CFArrayRemoveAllValues';
  743. {!
  744. @function CFArrayReplaceValues
  745. Replaces a range of values in the array.
  746. @param theArray The array from which all of the values are to be
  747. removed. If this parameter is not a valid mutable CFArray,
  748. the behavior is undefined.
  749. @param range The range of values within the array to replace. If the
  750. range location or end point (defined by the location plus
  751. length minus 1) is outside the index space of the array (0
  752. to N inclusive, where N is the count of the array), the
  753. behavior is undefined. If the range length is negative, the
  754. behavior is undefined. The range may be empty (length 0),
  755. in which case the new values are merely inserted at the
  756. range location.
  757. @param newValues A C array of the pointer-sized values to be placed
  758. into the array. The new values in the array are ordered in
  759. the same order in which they appear in this C array. This
  760. parameter may be NULL if the newCount parameter is 0. This
  761. C array is not changed or freed by this function. If this
  762. parameter is not a valid pointer to a C array of at least
  763. newCount pointers, the behavior is undefined.
  764. @param newCount The number of values to copy from the values C
  765. array into the CFArray. If this parameter is different than
  766. the range length, the excess newCount values will be
  767. inserted after the range, or the excess range values will be
  768. deleted. This parameter may be 0, in which case no new
  769. values are replaced into the array and the values in the
  770. range are simply removed. If this parameter is negative, or
  771. greater than the number of values actually in the newValues
  772. C array, the behavior is undefined.
  773. }
  774. procedure CFArrayReplaceValues( theArray: CFMutableArrayRef; range: CFRange; {const} newValues: {variable-size-array} UnivPtrPtr; newCount: CFIndex ); external name '_CFArrayReplaceValues';
  775. {!
  776. @function CFArrayExchangeValuesAtIndices
  777. Exchanges the values at two indices of the array.
  778. @param theArray The array of which the values are to be swapped. If
  779. this parameter is not a valid mutable CFArray, the behavior
  780. is undefined.
  781. @param idx1 The first index whose values should be swapped. If the
  782. index is outside the index space of the array (0 to N-1
  783. inclusive, where N is the count of the array before the
  784. operation), the behavior is undefined.
  785. @param idx2 The second index whose values should be swapped. If the
  786. index is outside the index space of the array (0 to N-1
  787. inclusive, where N is the count of the array before the
  788. operation), the behavior is undefined.
  789. }
  790. procedure CFArrayExchangeValuesAtIndices( theArray: CFMutableArrayRef; idx1: CFIndex; idx2: CFIndex ); external name '_CFArrayExchangeValuesAtIndices';
  791. {!
  792. @function CFArraySortValues
  793. Sorts the values in the array using the given comparison function.
  794. @param theArray The array whose values are to be sorted. If this
  795. parameter is not a valid mutable CFArray, the behavior is
  796. undefined.
  797. @param range The range of values within the array to sort. If the
  798. range location or end point (defined by the location plus
  799. length minus 1) is outside the index space of the array (0
  800. to N-1 inclusive, where N is the count of the array), the
  801. behavior is undefined. If the range length is negative, the
  802. behavior is undefined. The range may be empty (length 0).
  803. @param comparator The function with the comparator function type
  804. signature which is used in the sort operation to compare
  805. values in the array with the given value. If this parameter
  806. is not a pointer to a function of the correct prototype, the
  807. the behavior is undefined. If there are values in the array
  808. which the comparator function does not expect or cannot
  809. properly compare, the behavior is undefined. The values in
  810. the range are sorted from least to greatest according to
  811. this function.
  812. @param context A pointer-sized user-defined value, which is passed
  813. as the third parameter to the comparator function, but is
  814. otherwise unused by this function. If the context is not
  815. what is expected by the comparator function, the behavior is
  816. undefined.
  817. }
  818. procedure CFArraySortValues( theArray: CFMutableArrayRef; range: CFRange; comparator: CFComparatorFunction; context: UnivPtr ); external name '_CFArraySortValues';
  819. {!
  820. @function CFArrayAppendArray
  821. Adds the values from an array to another array.
  822. @param theArray The array to which values from the otherArray are to
  823. be added. If this parameter is not a valid mutable CFArray,
  824. the behavior is undefined.
  825. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  826. If the array is a fixed-capacity
  827. array and adding range.length values from the otherArray
  828. exceeds the capacity of the array, the behavior is
  829. undefined.
  830. #endif
  831. @param otherArray The array providing the values to be added to the
  832. array. If this parameter is not a valid CFArray, the
  833. behavior is undefined.
  834. @param otherRange The range within the otherArray from which to add
  835. the values to the array. If the range location or end point
  836. (defined by the location plus length minus 1) is outside
  837. the index space of the otherArray (0 to N-1 inclusive, where
  838. N is the count of the otherArray), the behavior is
  839. undefined. The new values are retained by the array using
  840. the retain callback provided when the array was created. If
  841. the values are not of the sort expected by the retain
  842. callback, the behavior is undefined. The values are assigned
  843. to the indices one larger than the previous largest index
  844. in the array, and beyond, and the count of the array is
  845. increased by range.length. The values are assigned new
  846. indices in the array from smallest to largest index in the
  847. order in which they appear in the otherArray.
  848. }
  849. procedure CFArrayAppendArray( theArray: CFMutableArrayRef; otherArray: CFArrayRef; otherRange: CFRange ); external name '_CFArrayAppendArray';
  850. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  851. end.
  852. {$endc} {not MACOSALLINCLUDE}