CFArray.pas 35 KB

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