/packages/univint/src/CFRunLoop.pas

https://github.com/slibre/freepascal · Pascal · 583 lines · 124 code · 54 blank · 405 comment · 0 complexity · ff0704f8155ddfac4ad5b066a6b1052d MD5 · raw file

  1. { CFRunLoop.h
  2. Copyright (c) 1998-2012, Apple Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <peter@stairways.com.au>, September 2005 }
  5. { Pascal Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2009 }
  6. { Pascal Translation Updated: Jonas Maebe <jonas@freepascal.org>, September 2012 }
  7. {
  8. Modified for use with Free Pascal
  9. Version 308
  10. Please report any bugs to <gpc@microbizz.nl>
  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 CFRunLoop;
  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,CFArray,CFDate,CFString,MacOSXPosix;
  163. {$endc} {not MACOSALLINCLUDE}
  164. {$ALIGN POWER}
  165. {!
  166. @header CFRunLoop
  167. CFRunLoops monitor sources of input to a task and dispatch control
  168. when sources become ready for processing. Examples of input sources
  169. might include user input devices, network connections, periodic
  170. or time-delayed events, and asynchronous callbacks. Input sources
  171. are registered with a run loop, and when a run loop is "run",
  172. callback functions associated with each source are called when
  173. the sources have some activity.
  174. There is one run loop per thread. Each run loop has different
  175. sets of input sources, called modes, which are named with strings.
  176. A run loop is run -- in a named mode -- to have it monitor the
  177. sources that have been registered in that mode, and the run loop
  178. blocks there until something happens. Examples of modes include
  179. the default mode, which a process would normally spend most of
  180. its time in, and a modal panel mode, which might be run when
  181. a modal panel is up, to restrict the set of input sources that
  182. are allowed to "fire". This is not to the granularity of, for
  183. example, what type of user input events are interesting, however.
  184. That sort of finer-grained granularity is given by UI-level
  185. frameworks with "get next event matching mask" or similar
  186. functionality.
  187. The CFRunLoopSource type is an abstraction of input sources that
  188. can be put in a run loop. An input source type would normally
  189. define an API for creating and operating on instances of the type,
  190. as if it were a separate entity from the run loop, then provide a
  191. function to create a CFRunLoopSource for an instance. The
  192. CFRunLoopSource can then be registered with the run loop,
  193. represents the input source to the run loop, and acts as
  194. intermediary between the run loop and the actual input source
  195. type instance. Examples include CFMachPort and CFSocket.
  196. A CFRunLoopTimer is a specialization of run loop sources, a way
  197. to generate either a one-shot delayed action, or a recurrent
  198. action.
  199. While being run, a run loop goes through a cycle of activities.
  200. Input sources are checked, timers which need firing are fired,
  201. and then the run loop blocks, waiting for something to happen
  202. (or in the case of timers, waiting for it to be time for
  203. something to happen). When something does happen, the run loop
  204. wakes up, processes the activity (usually by calling a callback
  205. function for an input source), checks other sources, fires timers,
  206. and goes back to sleep. And so on. CFRunLoopObservers can be
  207. used to do processing at special points in this cycle.
  208. }
  209. {!
  210. @typedef CFRunLoopRef
  211. This is the type of a reference to a run loop.
  212. }
  213. type
  214. CFRunLoopRef = ^__CFRunLoop; { an opaque type }
  215. __CFRunLoop = record end;
  216. {!
  217. @typedef CFRunLoopSourceRef
  218. This is the type of a reference to general run loop input sources.
  219. }
  220. type
  221. CFRunLoopSourceRef = ^__CFRunLoopSource; { an opaque type }
  222. __CFRunLoopSource = record end;
  223. {!
  224. @typedef CFRunLoopObserverRef
  225. This is the type of a reference to a run loop observer.
  226. }
  227. type
  228. CFRunLoopObserverRef = ^__CFRunLoopObserver; { an opaque type }
  229. __CFRunLoopObserver = record end;
  230. {!
  231. @typedef CFRunLoopTimerRef
  232. This is the type of a reference to a run loop timer.
  233. }
  234. type
  235. CFRunLoopTimerRef = ^__CFRunLoopTimer; { an opaque type }
  236. __CFRunLoopTimer = record end;
  237. { Reasons for CFRunLoopRunInMode() to Return }
  238. const
  239. kCFRunLoopRunFinished = 1;
  240. kCFRunLoopRunStopped = 2;
  241. kCFRunLoopRunTimedOut = 3;
  242. kCFRunLoopRunHandledSource = 4;
  243. { Run Loop Observer Activities }
  244. type
  245. CFRunLoopActivity = CFOptionFlags;
  246. const
  247. kCFRunLoopEntry = 1 shl 0;
  248. kCFRunLoopBeforeTimers = 1 shl 1;
  249. kCFRunLoopBeforeSources = 1 shl 2;
  250. kCFRunLoopBeforeWaiting = 1 shl 5;
  251. kCFRunLoopAfterWaiting = 1 shl 6;
  252. kCFRunLoopExit = 1 shl 7;
  253. kCFRunLoopAllActivities = $0FFFFFFF;
  254. var kCFRunLoopDefaultMode: CFStringRef; external name '_kCFRunLoopDefaultMode'; (* attribute const *)
  255. var kCFRunLoopCommonModes: CFStringRef; external name '_kCFRunLoopCommonModes'; (* attribute const *)
  256. {!
  257. @function CFRunLoopGetTypeID
  258. Returns the type identifier of all CFRunLoop instances.
  259. }
  260. function CFRunLoopGetTypeID: CFTypeID; external name '_CFRunLoopGetTypeID';
  261. {!
  262. @function CFRunLoopGetCurrent
  263. Returns the run loop for the current thread. There is exactly
  264. one run loop per thread.
  265. }
  266. function CFRunLoopGetCurrent: CFRunLoopRef; external name '_CFRunLoopGetCurrent';
  267. function CFRunLoopGetMain: CFRunLoopRef; external name '_CFRunLoopGetMain';
  268. (* AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER *)
  269. {!
  270. @function CFRunLoopCopyCurrentMode
  271. Returns the name of the mode in which the run loop is running.
  272. NULL is returned if the run loop is not running.
  273. @param rl The run loop for which the current mode should be
  274. reported.
  275. }
  276. function CFRunLoopCopyCurrentMode( rl: CFRunLoopRef ): CFStringRef; external name '_CFRunLoopCopyCurrentMode';
  277. {!
  278. @function CFRunLoopCopyAllModes
  279. Returns an array of all the names of the modes known to the run
  280. loop.
  281. @param rl The run loop for which the mode list should be returned.
  282. }
  283. function CFRunLoopCopyAllModes( rl: CFRunLoopRef ): CFArrayRef; external name '_CFRunLoopCopyAllModes';
  284. {!
  285. @function CFRunLoopAddCommonMode
  286. Makes the named mode a "common mode" for the run loop. The set of
  287. common modes are collectively accessed with the global constant
  288. kCFRunLoopCommonModes. Input sources previously added to the
  289. common modes are added to the new common mode.
  290. @param rl The run loop for which the mode should be made common.
  291. @param mode The name of the mode to mark as a common mode.
  292. }
  293. procedure CFRunLoopAddCommonMode( rl: CFRunLoopRef; mode: CFStringRef ); external name '_CFRunLoopAddCommonMode';
  294. {!
  295. @function CFRunLoopGetNextTimerFireDate
  296. Returns the time at which the next timer will fire.
  297. @param rl The run loop for which the next timer fire date should
  298. be reported.
  299. @param mode The name of the mode to query.
  300. }
  301. function CFRunLoopGetNextTimerFireDate( rl: CFRunLoopRef; mode: CFStringRef ): CFAbsoluteTime; external name '_CFRunLoopGetNextTimerFireDate';
  302. procedure CFRunLoopRun; external name '_CFRunLoopRun';
  303. function CFRunLoopRunInMode( mode: CFStringRef; seconds: CFTimeInterval; returnAfterSourceHandled: Boolean ): SInt32; external name '_CFRunLoopRunInMode';
  304. function CFRunLoopIsWaiting( rl: CFRunLoopRef ): Boolean; external name '_CFRunLoopIsWaiting';
  305. procedure CFRunLoopWakeUp( rl: CFRunLoopRef ); external name '_CFRunLoopWakeUp';
  306. procedure CFRunLoopStop( rl: CFRunLoopRef ); external name '_CFRunLoopStop';
  307. {#if __BLOCKS__ && MAC_OS_X_VERSION_10_6 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  308. { requires support for blocks
  309. extern void CFRunLoopPerformBlock(CFRunLoopRef rl, CFTypeRef mode, void (^block)(void)) CF_AVAILABLE_STARTING(10_6, 4_0);
  310. }
  311. {#endif}
  312. function CFRunLoopContainsSource( rl: CFRunLoopRef; source: CFRunLoopSourceRef; mode: CFStringRef ): Boolean; external name '_CFRunLoopContainsSource';
  313. procedure CFRunLoopAddSource( rl: CFRunLoopRef; source: CFRunLoopSourceRef; mode: CFStringRef ); external name '_CFRunLoopAddSource';
  314. procedure CFRunLoopRemoveSource( rl: CFRunLoopRef; source: CFRunLoopSourceRef; mode: CFStringRef ); external name '_CFRunLoopRemoveSource';
  315. function CFRunLoopContainsObserver( rl: CFRunLoopRef; observer: CFRunLoopObserverRef; mode: CFStringRef ): Boolean; external name '_CFRunLoopContainsObserver';
  316. procedure CFRunLoopAddObserver( rl: CFRunLoopRef; observer: CFRunLoopObserverRef; mode: CFStringRef ); external name '_CFRunLoopAddObserver';
  317. procedure CFRunLoopRemoveObserver( rl: CFRunLoopRef; observer: CFRunLoopObserverRef; mode: CFStringRef ); external name '_CFRunLoopRemoveObserver';
  318. function CFRunLoopContainsTimer( rl: CFRunLoopRef; timer: CFRunLoopTimerRef; mode: CFStringRef ): Boolean; external name '_CFRunLoopContainsTimer';
  319. procedure CFRunLoopAddTimer( rl: CFRunLoopRef; timer: CFRunLoopTimerRef; mode: CFStringRef ); external name '_CFRunLoopAddTimer';
  320. procedure CFRunLoopRemoveTimer( rl: CFRunLoopRef; timer: CFRunLoopTimerRef; mode: CFStringRef ); external name '_CFRunLoopRemoveTimer';
  321. {!
  322. @typedef CFRunLoopSourceContext
  323. Structure containing the callbacks of a CFRunLoopSource.
  324. @field version The version number of the structure type being
  325. passed in as a parameter to the CFArray creation
  326. functions. Valid version numbers are currently 0 and 1.
  327. Version 0 sources are fairly generic, but may require a
  328. bit more implementation, or may require a separate
  329. thread as part of the implementation, for a complex
  330. source. Version 1 sources are available on Mach and Windows,
  331. and have performance advantages when the source type can
  332. be described with this style.
  333. @field info An arbitrary pointer to client-defined data, which
  334. can be associated with the source at creation time, and
  335. is passed to the callbacks.
  336. @field retain The callback used to add a retain for the source on
  337. the info pointer for the life of the source, and may be
  338. used for temporary references the source needs to take.
  339. This callback returns the actual info pointer to store in
  340. the source, almost always just the pointer passed as the
  341. parameter.
  342. @field release The callback used to remove a retain previously
  343. added for the source on the info pointer.
  344. @field copyDescription The callback used to create a descriptive
  345. string representation of the info pointer (or the data
  346. pointed to by the info pointer) for debugging purposes.
  347. This is used by the CFCopyDescription() function.
  348. @field equal The callback used to compare the info pointers of
  349. two sources, to determine equality of sources.
  350. @field hash The callback used to compute a hash code for the info
  351. pointer for the source. The source uses this hash code
  352. information to produce its own hash code.
  353. @field schedule For a version 0 source, this callback is called
  354. whenever the source is added to a run loop mode. This
  355. information is often needed to implement complex sources.
  356. @field cancel For a version 0 source, this callback is called
  357. whenever the source is removed from a run loop mode. This
  358. information is often needed to implement complex sources.
  359. @field getPort Defined in version 1 sources, this function returns
  360. the Mach port or Windows HANDLE of a kernel object to
  361. represent the source to the run loop. This function
  362. must return the same result every time it is called, for the
  363. lifetime of the source, and should be quick.
  364. @field perform This callback is the workhorse of a run loop source.
  365. It is called when the source needs to be "handled" or
  366. processing is needed for input or conditions relating to
  367. the source. For version 0 sources, this function is called
  368. when the source has been marked "signaled" with the
  369. CFRunLoopSourceSignal() function, and should do whatever
  370. handling is required for the source. For a version 1 source
  371. on Mach, this function is called when a Mach message arrives
  372. on the source's Mach port, with the message, its
  373. length, an allocator, and the source's info pointer. A
  374. version 1 source performs whatever processing is required
  375. on the Mach message, then can return a pointer to a Mach
  376. message (or NULL if none) to be sent (usually this is a
  377. "reply" message), which should be allocated with the
  378. allocator (and will be deallocated by the run loop after
  379. sending). For a version 1 source on Windows the function
  380. is called when the kernel object is in the signaled state.
  381. }
  382. type
  383. CFRunLoopSourceContext = record
  384. version: CFIndex;
  385. info: UnivPtr;
  386. retain: function( info: {const} UnivPtr ): UnivPtr;
  387. release: procedure( info: {const} UnivPtr );
  388. copyDescription: function( info: {const} UnivPtr ): CFStringRef;
  389. equal: function( info1: {const} UnivPtr; info2: {const} UnivPtr ): Boolean;
  390. hash: function( info: {const} UnivPtr ): CFHashCode;
  391. schedule: function( info: {const} UnivPtr; rl: CFRunLoopRef; mode: CFStringRef ): CFHashCode;
  392. cancel: function( info: {const} UnivPtr; rl: CFRunLoopRef; mode: CFStringRef ): CFHashCode;
  393. perform: procedure( info: {const} UnivPtr );
  394. end;
  395. type
  396. CFRunLoopSourceContext1 = record
  397. version: CFIndex;
  398. info: UnivPtr;
  399. retain: function( info: {const} UnivPtr ): UnivPtr;
  400. release: procedure( info: {const} UnivPtr );
  401. copyDescription: function( info: {const} UnivPtr ): CFStringRef;
  402. equal: function( info1: {const} UnivPtr; info2: {const} UnivPtr ): Boolean;
  403. hash: function( info: {const} UnivPtr ): CFHashCode;
  404. getPort: function( info: {const} UnivPtr ): mach_port_t;
  405. perform: function( msg: UnivPtr; size: CFIndex; allocator: CFAllocatorRef; info: UnivPtr ): UnivPtr;
  406. end;
  407. {!
  408. @function CFRunLoopSourceGetTypeID
  409. Returns the type identifier of all CFRunLoopSource instances.
  410. }
  411. function CFRunLoopSourceGetTypeID: CFTypeID; external name '_CFRunLoopSourceGetTypeID';
  412. {!
  413. @function CFRunLoopSourceCreate
  414. Creates a new run loop source with the given context.
  415. @param allocator The CFAllocator which should be used to allocate
  416. memory for the array and its storage for values. If this
  417. reference is not a valid CFAllocator, the behavior is
  418. undefined.
  419. @param order On platforms which support it, for source versions
  420. which support it, this parameter determines the order in
  421. which the sources which are ready to be processed are
  422. handled. A lower order number causes processing before
  423. higher order number sources. It is inadvisable to depend
  424. on the order number for any architectural or design aspect
  425. of code. In the absence of any reason to do otherwise,
  426. zero should be used.
  427. @param context A pointer to the context structure for the source.
  428. }
  429. function CFRunLoopSourceCreate( allocator: CFAllocatorRef; order: CFIndex; var context: CFRunLoopSourceContext ): CFRunLoopSourceRef; external name '_CFRunLoopSourceCreate';
  430. {!
  431. @function CFRunLoopSourceGetOrder
  432. Returns the ordering parameter of the run loop source.
  433. @param source The run loop source for which the order number
  434. should be returned.
  435. }
  436. function CFRunLoopSourceGetOrder( source: CFRunLoopSourceRef ): CFIndex; external name '_CFRunLoopSourceGetOrder';
  437. {!
  438. @function CFRunLoopSourceInvalidate
  439. Invalidates the run loop source. The run loop source is never
  440. performed again after it becomes invalid, and will automatically
  441. be removed from any run loops and modes which contain it. The
  442. source is not destroyed by this operation, however -- the memory
  443. is still valid; only the release of all references on the source
  444. through the reference counting system can do that. But note, that
  445. if the only retains on the source were held by run loops, those
  446. retains may all be released by the time this function returns,
  447. and the source may actually be destroyed through that process.
  448. @param source The run loop source which should be invalidated.
  449. }
  450. procedure CFRunLoopSourceInvalidate( source: CFRunLoopSourceRef ); external name '_CFRunLoopSourceInvalidate';
  451. {!
  452. @function CFRunLoopSourceIsValid
  453. Reports whether or not the source is valid.
  454. @param source The run loop source for which the validity should
  455. be returned.
  456. }
  457. function CFRunLoopSourceIsValid( source: CFRunLoopSourceRef ): Boolean; external name '_CFRunLoopSourceIsValid';
  458. {!
  459. @function CFRunLoopSourceGetContext
  460. Fills the memory pointed to by the context parameter with the
  461. context structure of the source.
  462. @param source The run loop source for which the context structure
  463. should be returned.
  464. @param context A pointer to a context structure to be filled.
  465. }
  466. procedure CFRunLoopSourceGetContext( source: CFRunLoopSourceRef; var context: CFRunLoopSourceContext ); external name '_CFRunLoopSourceGetContext';
  467. {!
  468. @function CFRunLoopSourceSignal
  469. Marks the source as signalled, ready for handling by the run loop.
  470. Has no effect on version 1 sources, which are automatically
  471. handled when Mach messages for them come in.
  472. @param source The run loop source which should be signalled.
  473. }
  474. procedure CFRunLoopSourceSignal( source: CFRunLoopSourceRef ); external name '_CFRunLoopSourceSignal';
  475. type
  476. CFRunLoopObserverContext = record
  477. version: CFIndex;
  478. info: UnivPtr;
  479. retain: function( info: {const} UnivPtr ): UnivPtr;
  480. release: procedure( info: {const} UnivPtr );
  481. copyDescription: function( info: {const} UnivPtr ): CFStringRef;
  482. end;
  483. type
  484. CFRunLoopObserverCallBack = procedure( observer: CFRunLoopObserverRef; activity: CFRunLoopActivity; info: UnivPtr );
  485. {!
  486. @function CFRunLoopObserverGetTypeID
  487. Returns the type identifier of all CFRunLoopObserver instances.
  488. }
  489. function CFRunLoopObserverGetTypeID: CFTypeID; external name '_CFRunLoopObserverGetTypeID';
  490. function CFRunLoopObserverCreate( allocator: CFAllocatorRef; activities: CFOptionFlags; repeats: Boolean; order: CFIndex; callout: CFRunLoopObserverCallBack; var context: CFRunLoopObserverContext ): CFRunLoopObserverRef; external name '_CFRunLoopObserverCreate';
  491. function CFRunLoopObserverGetActivities( observer: CFRunLoopObserverRef ): CFOptionFlags; external name '_CFRunLoopObserverGetActivities';
  492. function CFRunLoopObserverDoesRepeat( observer: CFRunLoopObserverRef ): Boolean; external name '_CFRunLoopObserverDoesRepeat';
  493. function CFRunLoopObserverGetOrder( observer: CFRunLoopObserverRef ): CFIndex; external name '_CFRunLoopObserverGetOrder';
  494. procedure CFRunLoopObserverInvalidate( observer: CFRunLoopObserverRef ); external name '_CFRunLoopObserverInvalidate';
  495. function CFRunLoopObserverIsValid( observer: CFRunLoopObserverRef ): Boolean; external name '_CFRunLoopObserverIsValid';
  496. procedure CFRunLoopObserverGetContext( observer: CFRunLoopObserverRef; var context: CFRunLoopObserverContext ); external name '_CFRunLoopObserverGetContext';
  497. type
  498. CFRunLoopTimerContext = record
  499. version: CFIndex;
  500. info: UnivPtr;
  501. retain: function( info: {const} UnivPtr ): UnivPtr;
  502. release: procedure( info: {const} UnivPtr );
  503. copyDescription: function( info: {const} UnivPtr ): CFStringRef;
  504. end;
  505. type
  506. CFRunLoopTimerCallBack = procedure( timer: CFRunLoopTimerRef; info: UnivPtr );
  507. {!
  508. @function CFRunLoopTimerGetTypeID
  509. Returns the type identifier of all CFRunLoopTimer instances.
  510. }
  511. function CFRunLoopTimerGetTypeID: CFTypeID; external name '_CFRunLoopTimerGetTypeID';
  512. function CFRunLoopTimerCreate( allocator: CFAllocatorRef; fireDate: CFAbsoluteTime; interval: CFTimeInterval; flags: CFOptionFlags; order: CFIndex; callout: CFRunLoopTimerCallBack; var context: CFRunLoopTimerContext ): CFRunLoopTimerRef; external name '_CFRunLoopTimerCreate';
  513. function CFRunLoopTimerGetNextFireDate( timer: CFRunLoopTimerRef ): CFAbsoluteTime; external name '_CFRunLoopTimerGetNextFireDate';
  514. procedure CFRunLoopTimerSetNextFireDate( timer: CFRunLoopTimerRef; fireDate: CFAbsoluteTime ); external name '_CFRunLoopTimerSetNextFireDate';
  515. function CFRunLoopTimerGetInterval( timer: CFRunLoopTimerRef ): CFTimeInterval; external name '_CFRunLoopTimerGetInterval';
  516. function CFRunLoopTimerDoesRepeat( timer: CFRunLoopTimerRef ): Boolean; external name '_CFRunLoopTimerDoesRepeat';
  517. function CFRunLoopTimerGetOrder( timer: CFRunLoopTimerRef ): CFIndex; external name '_CFRunLoopTimerGetOrder';
  518. procedure CFRunLoopTimerInvalidate( timer: CFRunLoopTimerRef ); external name '_CFRunLoopTimerInvalidate';
  519. function CFRunLoopTimerIsValid( timer: CFRunLoopTimerRef ): Boolean; external name '_CFRunLoopTimerIsValid';
  520. procedure CFRunLoopTimerGetContext( timer: CFRunLoopTimerRef; var context: CFRunLoopTimerContext ); external name '_CFRunLoopTimerGetContext';
  521. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  522. end.
  523. {$endc} {not MACOSALLINCLUDE}