CFArray.pas 40 KB

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