/packages/univint/src/CFMessagePort.pas
Pascal | 239 lines | 40 code | 25 blank | 174 comment | 0 complexity | 539ef2856f1ce66408b7f6022c234f22 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
1{ CFMessagePort.h 2 Copyright (c) 1998-2012, Apple Inc. All rights reserved. 3} 4{ Pascal Translation: Peter N Lewis, <peter@stairways.com.au>, 2004 } 5{ Pascal Translation Updated: Peter N Lewis, <peter@stairways.com.au>, September 2005 } 6{ Pascal Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2009 } 7{ Pascal Translation Updated: Jonas Maebe <jonas@freepascal.org>, September 2012 } 8{ 9 Modified for use with Free Pascal 10 Version 308 11 Please report any bugs to <gpc@microbizz.nl> 12} 13 14{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 15{$mode macpas} 16{$packenum 1} 17{$macro on} 18{$inline on} 19{$calling mwpascal} 20 21unit CFMessagePort; 22interface 23{$setc UNIVERSAL_INTERFACES_VERSION := $0400} 24{$setc GAP_INTERFACES_VERSION := $0308} 25 26{$ifc not defined USE_CFSTR_CONSTANT_MACROS} 27 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE} 28{$endc} 29 30{$ifc defined CPUPOWERPC and defined CPUI386} 31 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386} 32{$endc} 33{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN} 34 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN} 35{$endc} 36 37{$ifc not defined __ppc__ and defined CPUPOWERPC32} 38 {$setc __ppc__ := 1} 39{$elsec} 40 {$setc __ppc__ := 0} 41{$endc} 42{$ifc not defined __ppc64__ and defined CPUPOWERPC64} 43 {$setc __ppc64__ := 1} 44{$elsec} 45 {$setc __ppc64__ := 0} 46{$endc} 47{$ifc not defined __i386__ and defined CPUI386} 48 {$setc __i386__ := 1} 49{$elsec} 50 {$setc __i386__ := 0} 51{$endc} 52{$ifc not defined __x86_64__ and defined CPUX86_64} 53 {$setc __x86_64__ := 1} 54{$elsec} 55 {$setc __x86_64__ := 0} 56{$endc} 57{$ifc not defined __arm__ and defined CPUARM} 58 {$setc __arm__ := 1} 59{$elsec} 60 {$setc __arm__ := 0} 61{$endc} 62 63{$ifc defined cpu64} 64 {$setc __LP64__ := 1} 65{$elsec} 66 {$setc __LP64__ := 0} 67{$endc} 68 69 70{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__} 71 {$error Conflicting definitions for __ppc__ and __i386__} 72{$endc} 73 74{$ifc defined __ppc__ and __ppc__} 75 {$setc TARGET_CPU_PPC := TRUE} 76 {$setc TARGET_CPU_PPC64 := FALSE} 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 __ppc64__ and __ppc64__} 85 {$setc TARGET_CPU_PPC := FALSE} 86 {$setc TARGET_CPU_PPC64 := TRUE} 87 {$setc TARGET_CPU_X86 := FALSE} 88 {$setc TARGET_CPU_X86_64 := FALSE} 89 {$setc TARGET_CPU_ARM := FALSE} 90 {$setc TARGET_OS_MAC := TRUE} 91 {$setc TARGET_OS_IPHONE := FALSE} 92 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 93 {$setc TARGET_OS_EMBEDDED := FALSE} 94{$elifc defined __i386__ and __i386__} 95 {$setc TARGET_CPU_PPC := FALSE} 96 {$setc TARGET_CPU_PPC64 := FALSE} 97 {$setc TARGET_CPU_X86 := TRUE} 98 {$setc TARGET_CPU_X86_64 := FALSE} 99 {$setc TARGET_CPU_ARM := FALSE} 100{$ifc defined(iphonesim)} 101 {$setc TARGET_OS_MAC := FALSE} 102 {$setc TARGET_OS_IPHONE := TRUE} 103 {$setc TARGET_IPHONE_SIMULATOR := TRUE} 104{$elsec} 105 {$setc TARGET_OS_MAC := TRUE} 106 {$setc TARGET_OS_IPHONE := FALSE} 107 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 108{$endc} 109 {$setc TARGET_OS_EMBEDDED := FALSE} 110{$elifc defined __x86_64__ and __x86_64__} 111 {$setc TARGET_CPU_PPC := FALSE} 112 {$setc TARGET_CPU_PPC64 := FALSE} 113 {$setc TARGET_CPU_X86 := FALSE} 114 {$setc TARGET_CPU_X86_64 := TRUE} 115 {$setc TARGET_CPU_ARM := FALSE} 116 {$setc TARGET_OS_MAC := TRUE} 117 {$setc TARGET_OS_IPHONE := FALSE} 118 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 119 {$setc TARGET_OS_EMBEDDED := FALSE} 120{$elifc defined __arm__ and __arm__} 121 {$setc TARGET_CPU_PPC := FALSE} 122 {$setc TARGET_CPU_PPC64 := FALSE} 123 {$setc TARGET_CPU_X86 := FALSE} 124 {$setc TARGET_CPU_X86_64 := FALSE} 125 {$setc TARGET_CPU_ARM := TRUE} 126 { will require compiler define when/if other Apple devices with ARM cpus ship } 127 {$setc TARGET_OS_MAC := FALSE} 128 {$setc TARGET_OS_IPHONE := TRUE} 129 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 130 {$setc TARGET_OS_EMBEDDED := TRUE} 131{$elsec} 132 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.} 133{$endc} 134 135{$ifc defined __LP64__ and __LP64__ } 136 {$setc TARGET_CPU_64 := TRUE} 137{$elsec} 138 {$setc TARGET_CPU_64 := FALSE} 139{$endc} 140 141{$ifc defined FPC_BIG_ENDIAN} 142 {$setc TARGET_RT_BIG_ENDIAN := TRUE} 143 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE} 144{$elifc defined FPC_LITTLE_ENDIAN} 145 {$setc TARGET_RT_BIG_ENDIAN := FALSE} 146 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE} 147{$elsec} 148 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.} 149{$endc} 150{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE} 151{$setc CALL_NOT_IN_CARBON := FALSE} 152{$setc OLDROUTINENAMES := FALSE} 153{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE} 154{$setc OPAQUE_UPP_TYPES := TRUE} 155{$setc OTCARBONAPPLICATION := TRUE} 156{$setc OTKERNEL := FALSE} 157{$setc PM_USE_SESSION_APIS := TRUE} 158{$setc TARGET_API_MAC_CARBON := TRUE} 159{$setc TARGET_API_MAC_OS8 := FALSE} 160{$setc TARGET_API_MAC_OSX := TRUE} 161{$setc TARGET_CARBON := TRUE} 162{$setc TARGET_CPU_68K := FALSE} 163{$setc TARGET_CPU_MIPS := FALSE} 164{$setc TARGET_CPU_SPARC := FALSE} 165{$setc TARGET_OS_UNIX := FALSE} 166{$setc TARGET_OS_WIN32 := FALSE} 167{$setc TARGET_RT_MAC_68881 := FALSE} 168{$setc TARGET_RT_MAC_CFM := FALSE} 169{$setc TARGET_RT_MAC_MACHO := TRUE} 170{$setc TYPED_FUNCTION_POINTERS := TRUE} 171{$setc TYPE_BOOL := FALSE} 172{$setc TYPE_EXTENDED := FALSE} 173{$setc TYPE_LONGLONG := TRUE} 174uses MacTypes,CFBase,CFString,CFRunLoop,CFData,CFDate; 175{$endc} {not MACOSALLINCLUDE} 176 177{$ALIGN POWER} 178 179 180type 181 CFMessagePortRef = ^__CFMessagePort; { an opaque type } 182 __CFMessagePort = record end; 183 184const 185 kCFMessagePortSuccess = 0; 186 kCFMessagePortSendTimeout = -1; 187 kCFMessagePortReceiveTimeout = -2; 188 kCFMessagePortIsInvalid = -3; 189 kCFMessagePortTransportError = -4; 190 kCFMessagePortBecameInvalidError = -5; 191 192type 193 CFMessagePortContext = record 194 version: CFIndex; 195 info: UnivPtr; 196 retain: function( info: {const} UnivPtr ): UnivPtr; 197 release: procedure( info: {const} UnivPtr ); 198 copyDescription: function( info: {const} UnivPtr ): CFStringRef; 199 end; 200 CFMessagePortContextPtr = ^CFMessagePortContext; 201 202type 203 CFMessagePortCallBack = function( local: CFMessagePortRef; msgid: SInt32; data: CFDataRef; info: UnivPtr ): CFDataRef; 204{ If callout wants to keep a hold of the data past the return of the callout, it must COPY the data. This includes the case where the data is given to some routine which _might_ keep a hold of it; System will release returned CFData. } 205type 206 CFMessagePortInvalidationCallBack = procedure( ms: CFMessagePortRef; info: UnivPtr ); 207 208function CFMessagePortGetTypeID: CFTypeID; external name '_CFMessagePortGetTypeID'; 209 210function CFMessagePortCreateLocal( allocator: CFAllocatorRef; name: CFStringRef; callout: CFMessagePortCallBack; var context: CFMessagePortContext; var shouldFreeInfo: Boolean ): CFMessagePortRef; external name '_CFMessagePortCreateLocal'; 211function CFMessagePortCreateRemote( allocator: CFAllocatorRef; name: CFStringRef ): CFMessagePortRef; external name '_CFMessagePortCreateRemote'; 212 213function CFMessagePortIsRemote( ms: CFMessagePortRef ): Boolean; external name '_CFMessagePortIsRemote'; 214function CFMessagePortGetName( ms: CFMessagePortRef ): CFStringRef; external name '_CFMessagePortGetName'; 215function CFMessagePortSetName( ms: CFMessagePortRef; newName: CFStringRef ): Boolean; external name '_CFMessagePortSetName'; 216procedure CFMessagePortGetContext( ms: CFMessagePortRef; var context: CFMessagePortContext ); external name '_CFMessagePortGetContext'; 217procedure CFMessagePortInvalidate( ms: CFMessagePortRef ); external name '_CFMessagePortInvalidate'; 218function CFMessagePortIsValid( ms: CFMessagePortRef ): Boolean; external name '_CFMessagePortIsValid'; 219function CFMessagePortGetInvalidationCallBack( ms: CFMessagePortRef ): CFMessagePortInvalidationCallBack; external name '_CFMessagePortGetInvalidationCallBack'; 220procedure CFMessagePortSetInvalidationCallBack( ms: CFMessagePortRef; callout: CFMessagePortInvalidationCallBack ); external name '_CFMessagePortSetInvalidationCallBack'; 221 222{ NULL replyMode argument means no return value expected, dont wait for it } 223function CFMessagePortSendRequest( remote: CFMessagePortRef; msgid: SInt32; data: CFDataRef; sendTimeout: CFTimeInterval; rcvTimeout: CFTimeInterval; replyMode: CFStringRef; returnData: CFDataRefPtr ): SInt32; external name '_CFMessagePortSendRequest'; 224 225function CFMessagePortCreateRunLoopSource( allocator: CFAllocatorRef; local: CFMessagePortRef; order: CFIndex ): CFRunLoopSourceRef; external name '_CFMessagePortCreateRunLoopSource'; 226 227{#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)} 228{ 229First requires translation of dispatch/dispatch.h and the files it includes 230 231procedure CFMessagePortSetDispatchQueue( ms: CFMessagePortRef; queue: dispatch_queue_t ); external name '_CFMessagePortSetDispatchQueue'; 232(* CF_AVAILABLE_STARTING(10_6, 4_0) *) 233} 234 235{#endif} 236{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 237 238end. 239{$endc} {not MACOSALLINCLUDE}