CFArray.pas 40 KB

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