PageRenderTime 53ms CodeModel.GetById 12ms app.highlight 23ms RepoModel.GetById 10ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  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
 13{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 14{$mode macpas}
 15{$packenum 1}
 16{$macro on}
 17{$inline on}
 18{$calling mwpascal}
 19
 20unit CFRunLoop;
 21interface
 22{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
 23{$setc GAP_INTERFACES_VERSION := $0308}
 24
 25{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 26    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 27{$endc}
 28
 29{$ifc defined CPUPOWERPC and defined CPUI386}
 30	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 31{$endc}
 32{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 33	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 34{$endc}
 35
 36{$ifc not defined __ppc__ and defined CPUPOWERPC32}
 37	{$setc __ppc__ := 1}
 38{$elsec}
 39	{$setc __ppc__ := 0}
 40{$endc}
 41{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
 42	{$setc __ppc64__ := 1}
 43{$elsec}
 44	{$setc __ppc64__ := 0}
 45{$endc}
 46{$ifc not defined __i386__ and defined CPUI386}
 47	{$setc __i386__ := 1}
 48{$elsec}
 49	{$setc __i386__ := 0}
 50{$endc}
 51{$ifc not defined __x86_64__ and defined CPUX86_64}
 52	{$setc __x86_64__ := 1}
 53{$elsec}
 54	{$setc __x86_64__ := 0}
 55{$endc}
 56{$ifc not defined __arm__ and defined CPUARM}
 57	{$setc __arm__ := 1}
 58{$elsec}
 59	{$setc __arm__ := 0}
 60{$endc}
 61
 62{$ifc defined cpu64}
 63  {$setc __LP64__ := 1}
 64{$elsec}
 65  {$setc __LP64__ := 0}
 66{$endc}
 67
 68
 69{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 70	{$error Conflicting definitions for __ppc__ and __i386__}
 71{$endc}
 72
 73{$ifc defined __ppc__ and __ppc__}
 74	{$setc TARGET_CPU_PPC := TRUE}
 75	{$setc TARGET_CPU_PPC64 := FALSE}
 76	{$setc TARGET_CPU_X86 := FALSE}
 77	{$setc TARGET_CPU_X86_64 := FALSE}
 78	{$setc TARGET_CPU_ARM := FALSE}
 79	{$setc TARGET_OS_MAC := TRUE}
 80	{$setc TARGET_OS_IPHONE := FALSE}
 81	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 82	{$setc TARGET_OS_EMBEDDED := FALSE}
 83{$elifc defined __ppc64__ and __ppc64__}
 84	{$setc TARGET_CPU_PPC := FALSE}
 85	{$setc TARGET_CPU_PPC64 := TRUE}
 86	{$setc TARGET_CPU_X86 := FALSE}
 87	{$setc TARGET_CPU_X86_64 := FALSE}
 88	{$setc TARGET_CPU_ARM := FALSE}
 89	{$setc TARGET_OS_MAC := TRUE}
 90	{$setc TARGET_OS_IPHONE := FALSE}
 91	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 92	{$setc TARGET_OS_EMBEDDED := FALSE}
 93{$elifc defined __i386__ and __i386__}
 94	{$setc TARGET_CPU_PPC := FALSE}
 95	{$setc TARGET_CPU_PPC64 := FALSE}
 96	{$setc TARGET_CPU_X86 := TRUE}
 97	{$setc TARGET_CPU_X86_64 := FALSE}
 98	{$setc TARGET_CPU_ARM := FALSE}
 99{$ifc defined(iphonesim)}
100 	{$setc TARGET_OS_MAC := FALSE}
101	{$setc TARGET_OS_IPHONE := TRUE}
102	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
103{$elsec}
104	{$setc TARGET_OS_MAC := TRUE}
105	{$setc TARGET_OS_IPHONE := FALSE}
106	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
107{$endc}
108	{$setc TARGET_OS_EMBEDDED := FALSE}
109{$elifc defined __x86_64__ and __x86_64__}
110	{$setc TARGET_CPU_PPC := FALSE}
111	{$setc TARGET_CPU_PPC64 := FALSE}
112	{$setc TARGET_CPU_X86 := FALSE}
113	{$setc TARGET_CPU_X86_64 := TRUE}
114	{$setc TARGET_CPU_ARM := FALSE}
115	{$setc TARGET_OS_MAC := TRUE}
116	{$setc TARGET_OS_IPHONE := FALSE}
117	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
118	{$setc TARGET_OS_EMBEDDED := FALSE}
119{$elifc defined __arm__ and __arm__}
120	{$setc TARGET_CPU_PPC := FALSE}
121	{$setc TARGET_CPU_PPC64 := FALSE}
122	{$setc TARGET_CPU_X86 := FALSE}
123	{$setc TARGET_CPU_X86_64 := FALSE}
124	{$setc TARGET_CPU_ARM := TRUE}
125	{ will require compiler define when/if other Apple devices with ARM cpus ship }
126	{$setc TARGET_OS_MAC := FALSE}
127	{$setc TARGET_OS_IPHONE := TRUE}
128	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
129	{$setc TARGET_OS_EMBEDDED := TRUE}
130{$elsec}
131	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
132{$endc}
133
134{$ifc defined __LP64__ and __LP64__ }
135  {$setc TARGET_CPU_64 := TRUE}
136{$elsec}
137  {$setc TARGET_CPU_64 := FALSE}
138{$endc}
139
140{$ifc defined FPC_BIG_ENDIAN}
141	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
142	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
143{$elifc defined FPC_LITTLE_ENDIAN}
144	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
145	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
146{$elsec}
147	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
148{$endc}
149{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
150{$setc CALL_NOT_IN_CARBON := FALSE}
151{$setc OLDROUTINENAMES := FALSE}
152{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
153{$setc OPAQUE_UPP_TYPES := TRUE}
154{$setc OTCARBONAPPLICATION := TRUE}
155{$setc OTKERNEL := FALSE}
156{$setc PM_USE_SESSION_APIS := TRUE}
157{$setc TARGET_API_MAC_CARBON := TRUE}
158{$setc TARGET_API_MAC_OS8 := FALSE}
159{$setc TARGET_API_MAC_OSX := TRUE}
160{$setc TARGET_CARBON := TRUE}
161{$setc TARGET_CPU_68K := FALSE}
162{$setc TARGET_CPU_MIPS := FALSE}
163{$setc TARGET_CPU_SPARC := FALSE}
164{$setc TARGET_OS_UNIX := FALSE}
165{$setc TARGET_OS_WIN32 := FALSE}
166{$setc TARGET_RT_MAC_68881 := FALSE}
167{$setc TARGET_RT_MAC_CFM := FALSE}
168{$setc TARGET_RT_MAC_MACHO := TRUE}
169{$setc TYPED_FUNCTION_POINTERS := TRUE}
170{$setc TYPE_BOOL := FALSE}
171{$setc TYPE_EXTENDED := FALSE}
172{$setc TYPE_LONGLONG := TRUE}
173uses MacTypes,CFBase,CFArray,CFDate,CFString,MacOSXPosix;
174{$endc} {not MACOSALLINCLUDE}
175
176{$ALIGN POWER}
177
178
179{!
180	@header CFRunLoop
181	CFRunLoops monitor sources of input to a task and dispatch control
182	when sources become ready for processing. Examples of input sources
183	might include user input devices, network connections, periodic
184	or time-delayed events, and asynchronous callbacks. Input sources
185	are registered with a run loop, and when a run loop is "run",
186	callback functions associated with each source are called when
187	the sources have some activity.
188
189	There is one run loop per thread. Each run loop has different
190	sets of input sources, called modes, which are named with strings.
191	A run loop is run -- in a named mode -- to have it monitor the
192	sources that have been registered in that mode, and the run loop
193	blocks there until something happens. Examples of modes include
194	the default mode, which a process would normally spend most of
195	its time in, and a modal panel mode, which might be run when
196	a modal panel is up, to restrict the set of input sources that
197	are allowed to "fire". This is not to the granularity of, for
198	example, what type of user input events are interesting, however.
199	That sort of finer-grained granularity is given by UI-level
200	frameworks with "get next event matching mask" or similar
201	functionality.
202
203	The CFRunLoopSource type is an abstraction of input sources that
204	can be put in a run loop. An input source type would normally
205	define an API for creating and operating on instances of the type,
206	as if it were a separate entity from the run loop, then provide a
207	function to create a CFRunLoopSource for an instance. The
208	CFRunLoopSource can then be registered with the run loop,
209	represents the input source to the run loop, and acts as
210	intermediary between the run loop and the actual input source
211	type instance. Examples include CFMachPort and CFSocket.
212
213	A CFRunLoopTimer is a specialization of run loop sources, a way
214	to generate either a one-shot delayed action, or a recurrent
215	action.
216
217	While being run, a run loop goes through a cycle of activities.
218	Input sources are checked, timers which need firing are fired,
219	and then the run loop blocks, waiting for something to happen 
220	(or in the case of timers, waiting for it to be time for
221	something to happen). When something does happen, the run loop
222	wakes up, processes the activity (usually by calling a callback
223	function for an input source), checks other sources, fires timers,
224	and goes back to sleep. And so on. CFRunLoopObservers can be
225	used to do processing at special points in this cycle.
226
227
228}
229
230
231{!
232	@typedef CFRunLoopRef
233	This is the type of a reference to a run loop.
234}
235type
236	CFRunLoopRef = ^__CFRunLoop; { an opaque type }
237	__CFRunLoop = record end;
238
239{!
240	@typedef CFRunLoopSourceRef
241	This is the type of a reference to general run loop input sources.
242}
243type
244	CFRunLoopSourceRef = ^__CFRunLoopSource; { an opaque type }
245	__CFRunLoopSource = record end;
246
247{!
248	@typedef CFRunLoopObserverRef
249	This is the type of a reference to a run loop observer.
250}
251type
252	CFRunLoopObserverRef = ^__CFRunLoopObserver; { an opaque type }
253	__CFRunLoopObserver = record end;
254
255{!
256	@typedef CFRunLoopTimerRef
257	This is the type of a reference to a run loop timer.
258}
259type
260	CFRunLoopTimerRef = ^__CFRunLoopTimer; { an opaque type }
261	__CFRunLoopTimer = record end;
262
263{ Reasons for CFRunLoopRunInMode() to Return }
264const
265	kCFRunLoopRunFinished = 1;
266	kCFRunLoopRunStopped = 2;
267	kCFRunLoopRunTimedOut = 3;
268	kCFRunLoopRunHandledSource = 4;
269
270{ Run Loop Observer Activities }
271type
272	CFRunLoopActivity = CFOptionFlags;
273const
274	kCFRunLoopEntry = 1 shl 0;
275    kCFRunLoopBeforeTimers = 1 shl 1;
276    kCFRunLoopBeforeSources = 1 shl 2;
277    kCFRunLoopBeforeWaiting = 1 shl 5;
278    kCFRunLoopAfterWaiting = 1 shl 6;
279    kCFRunLoopExit = 1 shl 7;
280    kCFRunLoopAllActivities = $0FFFFFFF;
281
282var kCFRunLoopDefaultMode: CFStringRef; external name '_kCFRunLoopDefaultMode'; (* attribute const *)
283var kCFRunLoopCommonModes: CFStringRef; external name '_kCFRunLoopCommonModes'; (* attribute const *)
284
285{!
286	@function CFRunLoopGetTypeID
287	Returns the type identifier of all CFRunLoop instances.
288}
289function CFRunLoopGetTypeID: CFTypeID; external name '_CFRunLoopGetTypeID';
290
291{!
292	@function CFRunLoopGetCurrent
293	Returns the run loop for the current thread. There is exactly
294	one run loop per thread.
295}
296function CFRunLoopGetCurrent: CFRunLoopRef; external name '_CFRunLoopGetCurrent';
297
298function CFRunLoopGetMain: CFRunLoopRef; external name '_CFRunLoopGetMain';
299(* AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER *)
300
301{!
302	@function CFRunLoopCopyCurrentMode
303	Returns the name of the mode in which the run loop is running.
304	NULL is returned if the run loop is not running.
305	@param rl The run loop for which the current mode should be
306		reported.
307}
308function CFRunLoopCopyCurrentMode( rl: CFRunLoopRef ): CFStringRef; external name '_CFRunLoopCopyCurrentMode';
309
310{!
311	@function CFRunLoopCopyAllModes
312	Returns an array of all the names of the modes known to the run
313	loop.
314	@param rl The run loop for which the mode list should be returned.
315}
316function CFRunLoopCopyAllModes( rl: CFRunLoopRef ): CFArrayRef; external name '_CFRunLoopCopyAllModes';
317
318{!
319	@function CFRunLoopAddCommonMode
320	Makes the named mode a "common mode" for the run loop. The set of
321	common modes are collectively accessed with the global constant
322	kCFRunLoopCommonModes. Input sources previously added to the
323	common modes are added to the new common mode.
324	@param rl The run loop for which the mode should be made common.
325	@param mode The name of the mode to mark as a common mode.
326}
327procedure CFRunLoopAddCommonMode( rl: CFRunLoopRef; mode: CFStringRef ); external name '_CFRunLoopAddCommonMode';
328
329{!
330	@function CFRunLoopGetNextTimerFireDate
331	Returns the time at which the next timer will fire.
332	@param rl The run loop for which the next timer fire date should
333		be reported.
334	@param mode The name of the mode to query.
335}
336function CFRunLoopGetNextTimerFireDate( rl: CFRunLoopRef; mode: CFStringRef ): CFAbsoluteTime; external name '_CFRunLoopGetNextTimerFireDate';
337
338procedure CFRunLoopRun; external name '_CFRunLoopRun';
339function CFRunLoopRunInMode( mode: CFStringRef; seconds: CFTimeInterval; returnAfterSourceHandled: Boolean ): SInt32; external name '_CFRunLoopRunInMode';
340function CFRunLoopIsWaiting( rl: CFRunLoopRef ): Boolean; external name '_CFRunLoopIsWaiting';
341procedure CFRunLoopWakeUp( rl: CFRunLoopRef ); external name '_CFRunLoopWakeUp';
342procedure CFRunLoopStop( rl: CFRunLoopRef ); external name '_CFRunLoopStop';
343
344{#if __BLOCKS__ && MAC_OS_X_VERSION_10_6 <= MAC_OS_X_VERSION_MAX_ALLOWED}
345{ requires support for blocks
346extern void CFRunLoopPerformBlock(CFRunLoopRef rl, CFTypeRef mode, void (^block)(void)) CF_AVAILABLE_STARTING(10_6, 4_0); 
347}
348{#endif}
349
350function CFRunLoopContainsSource( rl: CFRunLoopRef; source: CFRunLoopSourceRef; mode: CFStringRef ): Boolean; external name '_CFRunLoopContainsSource';
351procedure CFRunLoopAddSource( rl: CFRunLoopRef; source: CFRunLoopSourceRef; mode: CFStringRef ); external name '_CFRunLoopAddSource';
352procedure CFRunLoopRemoveSource( rl: CFRunLoopRef; source: CFRunLoopSourceRef; mode: CFStringRef ); external name '_CFRunLoopRemoveSource';
353
354function CFRunLoopContainsObserver( rl: CFRunLoopRef; observer: CFRunLoopObserverRef; mode: CFStringRef ): Boolean; external name '_CFRunLoopContainsObserver';
355procedure CFRunLoopAddObserver( rl: CFRunLoopRef; observer: CFRunLoopObserverRef; mode: CFStringRef ); external name '_CFRunLoopAddObserver';
356procedure CFRunLoopRemoveObserver( rl: CFRunLoopRef; observer: CFRunLoopObserverRef; mode: CFStringRef ); external name '_CFRunLoopRemoveObserver';
357
358function CFRunLoopContainsTimer( rl: CFRunLoopRef; timer: CFRunLoopTimerRef; mode: CFStringRef ): Boolean; external name '_CFRunLoopContainsTimer';
359procedure CFRunLoopAddTimer( rl: CFRunLoopRef; timer: CFRunLoopTimerRef; mode: CFStringRef ); external name '_CFRunLoopAddTimer';
360procedure CFRunLoopRemoveTimer( rl: CFRunLoopRef; timer: CFRunLoopTimerRef; mode: CFStringRef ); external name '_CFRunLoopRemoveTimer';
361
362{!
363	@typedef CFRunLoopSourceContext
364	Structure containing the callbacks of a CFRunLoopSource.
365	@field version The version number of the structure type being
366		passed in as a parameter to the CFArray creation
367		functions. Valid version numbers are currently 0 and 1.
368		Version 0 sources are fairly generic, but may require a
369		bit more implementation, or may require a separate
370		thread as part of the implementation, for a complex
371		source. Version 1 sources are available on Mach and Windows,
372		and have performance advantages when the source type can
373		be described with this style.
374	@field info An arbitrary pointer to client-defined data, which
375		can be associated with the source at creation time, and
376		is passed to the callbacks.
377	@field retain The callback used to add a retain for the source on
378		the info pointer for the life of the source, and may be
379		used for temporary references the source needs to take.
380		This callback returns the actual info pointer to store in
381		the source, almost always just the pointer passed as the
382		parameter.
383	@field release The callback used to remove a retain previously
384		added for the source on the info pointer. 
385	@field copyDescription The callback used to create a descriptive
386		string representation of the info pointer (or the data
387		pointed to by the info pointer) for debugging purposes.
388		This is used by the CFCopyDescription() function.
389	@field equal The callback used to compare the info pointers of
390		two sources, to determine equality of sources.
391	@field hash The callback used to compute a hash code for the info
392		pointer for the source. The source uses this hash code
393		information to produce its own hash code.
394	@field schedule For a version 0 source, this callback is called
395		whenever the source is added to a run loop mode. This
396		information is often needed to implement complex sources.
397	@field cancel For a version 0 source, this callback is called
398		whenever the source is removed from a run loop mode. This
399		information is often needed to implement complex sources.
400	@field getPort Defined in version 1 sources, this function returns
401		the Mach port or Windows HANDLE of a kernel object to
402		represent the source to the run loop.  This function
403		must return the same result every time it is called, for the
404                lifetime of the source, and should be quick.
405	@field perform This callback is the workhorse of a run loop source.
406		It is called when the source needs to be "handled" or
407		processing is needed for input or conditions relating to
408		the source. For version 0 sources, this function is called
409		when the source has been marked "signaled" with the
410		CFRunLoopSourceSignal() function, and should do whatever
411		handling is required for the source. For a version 1 source
412		on Mach, this function is called when a Mach message arrives
413		on the source's Mach port, with the message, its
414		length, an allocator, and the source's info pointer. A
415		version 1 source performs whatever processing is required
416		on the Mach message, then can return a pointer to a Mach
417		message (or NULL if none) to be sent (usually this is a
418		"reply" message), which should be allocated with the
419		allocator (and will be deallocated by the run loop after
420		sending).  For a version 1 source on Windows the function
421		is called when the kernel object is in the signaled state.
422}
423type
424	CFRunLoopSourceContext = record
425		version: CFIndex;
426		info: UnivPtr;
427		retain: function( info: {const} UnivPtr ): UnivPtr;
428		release: procedure( info: {const} UnivPtr );
429		copyDescription: function( info: {const} UnivPtr ): CFStringRef;
430		equal: function( info1: {const} UnivPtr; info2: {const} UnivPtr ): Boolean;
431		hash: function( info: {const} UnivPtr ): CFHashCode;
432		schedule: function( info: {const} UnivPtr; rl: CFRunLoopRef; mode: CFStringRef ): CFHashCode;
433		cancel: function( info: {const} UnivPtr; rl: CFRunLoopRef; mode: CFStringRef ): CFHashCode;
434		perform: procedure( info: {const} UnivPtr );
435	end;
436
437type
438	CFRunLoopSourceContext1 = record
439		version: CFIndex;
440		info: UnivPtr;
441		retain: function( info: {const} UnivPtr ): UnivPtr;
442		release: procedure( info: {const} UnivPtr );
443		copyDescription: function( info: {const} UnivPtr ): CFStringRef;
444		equal: function( info1: {const} UnivPtr; info2: {const} UnivPtr ): Boolean;
445		hash: function( info: {const} UnivPtr ): CFHashCode;
446		getPort: function( info: {const} UnivPtr ): mach_port_t;
447		perform: function( msg: UnivPtr; size: CFIndex; allocator: CFAllocatorRef; info: UnivPtr ): UnivPtr;
448	end;
449
450{!
451	@function CFRunLoopSourceGetTypeID
452	Returns the type identifier of all CFRunLoopSource instances.
453}
454function CFRunLoopSourceGetTypeID: CFTypeID; external name '_CFRunLoopSourceGetTypeID';
455
456{!
457	@function CFRunLoopSourceCreate
458	Creates a new run loop source with the given context.
459	@param allocator The CFAllocator which should be used to allocate
460		memory for the array and its storage for values. If this
461		reference is not a valid CFAllocator, the behavior is
462		undefined.
463	@param order On platforms which support it, for source versions
464		which support it, this parameter determines the order in
465		which the sources which are ready to be processed are
466		handled. A lower order number causes processing before
467		higher order number sources. It is inadvisable to depend
468		on the order number for any architectural or design aspect
469		of code. In the absence of any reason to do otherwise,
470		zero should be used.
471	@param context A pointer to the context structure for the source.
472}
473function CFRunLoopSourceCreate( allocator: CFAllocatorRef; order: CFIndex; var context: CFRunLoopSourceContext ): CFRunLoopSourceRef; external name '_CFRunLoopSourceCreate';
474
475{!
476	@function CFRunLoopSourceGetOrder
477	Returns the ordering parameter of the run loop source.
478	@param source The run loop source for which the order number
479		should be returned.
480}
481function CFRunLoopSourceGetOrder( source: CFRunLoopSourceRef ): CFIndex; external name '_CFRunLoopSourceGetOrder';
482
483{!
484	@function CFRunLoopSourceInvalidate
485	Invalidates the run loop source. The run loop source is never
486	performed again after it becomes invalid, and will automatically
487	be removed from any run loops and modes which contain it. The
488	source is not destroyed by this operation, however -- the memory
489	is still valid; only the release of all references on the source
490	through the reference counting system can do that. But note, that
491	if the only retains on the source were held by run loops, those
492	retains may all be released by the time this function returns,
493	and the source may actually be destroyed through that process.
494	@param source The run loop source which should be invalidated.
495}
496procedure CFRunLoopSourceInvalidate( source: CFRunLoopSourceRef ); external name '_CFRunLoopSourceInvalidate';
497
498{!
499	@function CFRunLoopSourceIsValid
500	Reports whether or not the source is valid.
501	@param source The run loop source for which the validity should
502		be returned.
503}
504function CFRunLoopSourceIsValid( source: CFRunLoopSourceRef ): Boolean; external name '_CFRunLoopSourceIsValid';
505
506{!
507	@function CFRunLoopSourceGetContext
508	Fills the memory pointed to by the context parameter with the
509	context structure of the source.
510	@param source The run loop source for which the context structure
511		should be returned.
512	@param context A pointer to a context structure to be filled.
513}
514procedure CFRunLoopSourceGetContext( source: CFRunLoopSourceRef; var context: CFRunLoopSourceContext ); external name '_CFRunLoopSourceGetContext';
515
516{!
517	@function CFRunLoopSourceSignal
518	Marks the source as signalled, ready for handling by the run loop.
519	Has no effect on version 1 sources, which are automatically
520	handled when Mach messages for them come in.
521	@param source The run loop source which should be signalled.
522}
523procedure CFRunLoopSourceSignal( source: CFRunLoopSourceRef ); external name '_CFRunLoopSourceSignal';
524
525type
526	CFRunLoopObserverContext = record
527		version: CFIndex;
528		info: UnivPtr;
529		retain: function( info: {const} UnivPtr ): UnivPtr;
530		release: procedure( info: {const} UnivPtr );
531		copyDescription: function( info: {const} UnivPtr ): CFStringRef;
532	end;
533
534type
535	CFRunLoopObserverCallBack = procedure( observer: CFRunLoopObserverRef; activity: CFRunLoopActivity; info: UnivPtr );
536
537{!
538	@function CFRunLoopObserverGetTypeID
539	Returns the type identifier of all CFRunLoopObserver instances.
540}
541function CFRunLoopObserverGetTypeID: CFTypeID; external name '_CFRunLoopObserverGetTypeID';
542
543function CFRunLoopObserverCreate( allocator: CFAllocatorRef; activities: CFOptionFlags; repeats: Boolean; order: CFIndex; callout: CFRunLoopObserverCallBack; var context: CFRunLoopObserverContext ): CFRunLoopObserverRef; external name '_CFRunLoopObserverCreate';
544
545function CFRunLoopObserverGetActivities( observer: CFRunLoopObserverRef ): CFOptionFlags; external name '_CFRunLoopObserverGetActivities';
546function CFRunLoopObserverDoesRepeat( observer: CFRunLoopObserverRef ): Boolean; external name '_CFRunLoopObserverDoesRepeat';
547function CFRunLoopObserverGetOrder( observer: CFRunLoopObserverRef ): CFIndex; external name '_CFRunLoopObserverGetOrder';
548procedure CFRunLoopObserverInvalidate( observer: CFRunLoopObserverRef ); external name '_CFRunLoopObserverInvalidate';
549function CFRunLoopObserverIsValid( observer: CFRunLoopObserverRef ): Boolean; external name '_CFRunLoopObserverIsValid';
550procedure CFRunLoopObserverGetContext( observer: CFRunLoopObserverRef; var context: CFRunLoopObserverContext ); external name '_CFRunLoopObserverGetContext';
551
552type
553	CFRunLoopTimerContext = record
554		version: CFIndex;
555		info: UnivPtr;
556		retain: function( info: {const} UnivPtr ): UnivPtr;
557		release: procedure( info: {const} UnivPtr );
558		copyDescription: function( info: {const} UnivPtr ): CFStringRef;
559	end;
560
561type
562	CFRunLoopTimerCallBack = procedure( timer: CFRunLoopTimerRef; info: UnivPtr );
563
564{!
565	@function CFRunLoopTimerGetTypeID
566	Returns the type identifier of all CFRunLoopTimer instances.
567}
568function CFRunLoopTimerGetTypeID: CFTypeID; external name '_CFRunLoopTimerGetTypeID';
569
570function CFRunLoopTimerCreate( allocator: CFAllocatorRef; fireDate: CFAbsoluteTime; interval: CFTimeInterval; flags: CFOptionFlags; order: CFIndex; callout: CFRunLoopTimerCallBack; var context: CFRunLoopTimerContext ): CFRunLoopTimerRef; external name '_CFRunLoopTimerCreate';
571function CFRunLoopTimerGetNextFireDate( timer: CFRunLoopTimerRef ): CFAbsoluteTime; external name '_CFRunLoopTimerGetNextFireDate';
572procedure CFRunLoopTimerSetNextFireDate( timer: CFRunLoopTimerRef; fireDate: CFAbsoluteTime ); external name '_CFRunLoopTimerSetNextFireDate';
573function CFRunLoopTimerGetInterval( timer: CFRunLoopTimerRef ): CFTimeInterval; external name '_CFRunLoopTimerGetInterval';
574function CFRunLoopTimerDoesRepeat( timer: CFRunLoopTimerRef ): Boolean; external name '_CFRunLoopTimerDoesRepeat';
575function CFRunLoopTimerGetOrder( timer: CFRunLoopTimerRef ): CFIndex; external name '_CFRunLoopTimerGetOrder';
576procedure CFRunLoopTimerInvalidate( timer: CFRunLoopTimerRef ); external name '_CFRunLoopTimerInvalidate';
577function CFRunLoopTimerIsValid( timer: CFRunLoopTimerRef ): Boolean; external name '_CFRunLoopTimerIsValid';
578procedure CFRunLoopTimerGetContext( timer: CFRunLoopTimerRef; var context: CFRunLoopTimerContext ); external name '_CFRunLoopTimerGetContext';
579
580{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
581
582end.
583{$endc} {not MACOSALLINCLUDE}