CFArray.pas 39 KB

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