CFPlugInCOM.pas 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. { CFPlugInCOM.h
  2. Copyright (c) 1999-2005, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, September 2005 }
  5. {
  6. Modified for use with Free Pascal
  7. Version 200
  8. Please report any bugs to <[email protected]>
  9. }
  10. {$mode macpas}
  11. {$packenum 1}
  12. {$macro on}
  13. {$inline on}
  14. {$CALLING MWPASCAL}
  15. unit CFPlugInCOM;
  16. interface
  17. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  18. {$setc GAP_INTERFACES_VERSION := $0200}
  19. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  20. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  21. {$endc}
  22. {$ifc defined CPUPOWERPC and defined CPUI386}
  23. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  24. {$endc}
  25. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  26. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  27. {$endc}
  28. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  29. {$setc __ppc__ := 1}
  30. {$elsec}
  31. {$setc __ppc__ := 0}
  32. {$endc}
  33. {$ifc not defined __i386__ and defined CPUI386}
  34. {$setc __i386__ := 1}
  35. {$elsec}
  36. {$setc __i386__ := 0}
  37. {$endc}
  38. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  39. {$error Conflicting definitions for __ppc__ and __i386__}
  40. {$endc}
  41. {$ifc defined __ppc__ and __ppc__}
  42. {$setc TARGET_CPU_PPC := TRUE}
  43. {$setc TARGET_CPU_X86 := FALSE}
  44. {$elifc defined __i386__ and __i386__}
  45. {$setc TARGET_CPU_PPC := FALSE}
  46. {$setc TARGET_CPU_X86 := TRUE}
  47. {$elsec}
  48. {$error Neither __ppc__ nor __i386__ is defined.}
  49. {$endc}
  50. {$setc TARGET_CPU_PPC_64 := FALSE}
  51. {$ifc defined FPC_BIG_ENDIAN}
  52. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  53. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  54. {$elifc defined FPC_LITTLE_ENDIAN}
  55. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  56. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  57. {$elsec}
  58. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  59. {$endc}
  60. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  61. {$setc CALL_NOT_IN_CARBON := FALSE}
  62. {$setc OLDROUTINENAMES := FALSE}
  63. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  64. {$setc OPAQUE_UPP_TYPES := TRUE}
  65. {$setc OTCARBONAPPLICATION := TRUE}
  66. {$setc OTKERNEL := FALSE}
  67. {$setc PM_USE_SESSION_APIS := TRUE}
  68. {$setc TARGET_API_MAC_CARBON := TRUE}
  69. {$setc TARGET_API_MAC_OS8 := FALSE}
  70. {$setc TARGET_API_MAC_OSX := TRUE}
  71. {$setc TARGET_CARBON := TRUE}
  72. {$setc TARGET_CPU_68K := FALSE}
  73. {$setc TARGET_CPU_MIPS := FALSE}
  74. {$setc TARGET_CPU_SPARC := FALSE}
  75. {$setc TARGET_OS_MAC := TRUE}
  76. {$setc TARGET_OS_UNIX := FALSE}
  77. {$setc TARGET_OS_WIN32 := FALSE}
  78. {$setc TARGET_RT_MAC_68881 := FALSE}
  79. {$setc TARGET_RT_MAC_CFM := FALSE}
  80. {$setc TARGET_RT_MAC_MACHO := TRUE}
  81. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  82. {$setc TYPE_BOOL := FALSE}
  83. {$setc TYPE_EXTENDED := FALSE}
  84. {$setc TYPE_LONGLONG := TRUE}
  85. uses MacTypes,CFPlugIn,CFUUID;
  86. {$ALIGN POWER}
  87. { ================= IUnknown definition (C struct) ================= }
  88. { All interface structs must have an IUnknownStruct at the beginning. }
  89. { The _reserved field is part of the Microsoft COM binary standard on Macintosh. }
  90. { You can declare new C struct interfaces by defining a new struct that includes "IUNKNOWN_C_GUTS;" before the first field of the struct. }
  91. type
  92. HRESULT = SInt32;
  93. ULONG = UInt32;
  94. LPVOID = UnivPtr;
  95. REFIID = CFUUIDBytes;
  96. { Macros for more detailed HRESULT analysis }
  97. function SUCCEEDED( Status: HRESULT ): Boolean; inline;
  98. function FAILED( Status: HRESULT ): Boolean; inline;
  99. function IS_ERROR( Status: HRESULT ): Boolean; inline;
  100. function HRESULT_CODE( hr: HRESULT ): HRESULT; inline;
  101. function HRESULT_FACILITY( hr: HRESULT ): HRESULT; inline;
  102. function HRESULT_SEVERITY( hr: HRESULT ): HRESULT; inline;
  103. const
  104. SEVERITY_SUCCESS = 0;
  105. const
  106. SEVERITY_ERROR = 1;
  107. { Creating an HRESULT from its component pieces }
  108. function MAKE_HRESULT( sev, fac, code: ULONG ): HRESULT; inline;
  109. { Pre-defined success HRESULTS }
  110. const
  111. S_OK = 0;
  112. const
  113. S_FALSE = 1;
  114. { Common error HRESULTS }
  115. const
  116. E_UNEXPECTED = $8000FFFF;
  117. E_NOTIMPL = $80000001;
  118. E_OUTOFMEMORY = $80000002;
  119. E_INVALIDARG = $80000003;
  120. E_NOINTERFACE = $80000004;
  121. E_POINTER = $80000005;
  122. E_HANDLE = $80000006;
  123. E_ABORT = $80000007;
  124. E_FAIL = $80000008;
  125. E_ACCESSDENIED = $80000009;
  126. { This macro should be used when defining all interface functions (as it is for the IUnknown functions below). }
  127. {#define STDMETHODCALLTYPE}
  128. { The __RPC_FAR macro is for COM source compatibility only. This macro is used a lot in COM interface definitions. If your CFPlugIn interfaces need to be COM interfaces as well, you can use this macro to get better source compatibility. It is not used in the IUnknown definition below, because when doing COM, you will be using the Microsoft supplied IUnknown interface anyway. }
  129. {#define __RPC_FAR}
  130. { The IUnknown interface }
  131. function IUnknownUUID: CFUUIDRef; inline;
  132. type
  133. IUnknownVTbl = record
  134. _reserved: UnivPtr;
  135. QueryInterface: function( thisPointer: UnivPtr; iid: REFIID; var ppv: LPVOID ): HRESULT;
  136. AddRef: function( thisPointer: UnivPtr ): ULONG;
  137. Release: function( thisPointer: UnivPtr ): ULONG;
  138. end;
  139. { End of extern "C" stuff }
  140. { C++ specific stuff }
  141. implementation
  142. {$R-}
  143. function SUCCEEDED( Status: HRESULT ): Boolean; inline;
  144. begin
  145. SUCCEEDED := Status >= 0;
  146. end;
  147. function FAILED( Status: HRESULT ): Boolean; inline;
  148. begin
  149. FAILED := Status < 0;
  150. end;
  151. function IS_ERROR( Status: HRESULT ): Boolean; inline;
  152. begin
  153. IS_ERROR := Status shr 31 = SEVERITY_ERROR;
  154. end;
  155. function HRESULT_CODE( hr: HRESULT ): HRESULT; inline;
  156. begin
  157. HRESULT_CODE := hr and $FFFF;
  158. end;
  159. function HRESULT_FACILITY( hr: HRESULT ): HRESULT; inline;
  160. begin
  161. HRESULT_FACILITY := (hr shr 16) and $1FFF;
  162. end;
  163. function HRESULT_SEVERITY( hr: HRESULT ): HRESULT; inline;
  164. begin
  165. HRESULT_SEVERITY := (hr shr 31) and $01;
  166. end;
  167. function MAKE_HRESULT( sev, fac, code: ULONG ): HRESULT; inline;
  168. begin
  169. MAKE_HRESULT := HRESULT((sev shl 31) or (fac shl 16) or code);
  170. end;
  171. function IUnknownUUID: CFUUIDRef; inline;
  172. begin
  173. IUnknownUUID:= CFUUIDGetConstantUUIDWithBytes( nil, $00, $00, $00, $00, $00, $00, $00, $00, ByteParameter($C0), $00, $00, $00, $00, $00, $00, $46 )
  174. end;
  175. end.