AEHelpers.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. {
  2. File: AEHelpers.p
  3. Contains: AEPrint, AEBuild and AEStream for Carbon
  4. Version: Technology: Mac OS X, CarbonLib
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1999-2002 by Apple Computer, Inc., all rights reserved.
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. * Originally from AEGIzmos by Jens Alfke, circa 1992.
  13. }
  14. {
  15. Modified for use with Free Pascal
  16. Version 200
  17. Please report any bugs to <[email protected]>
  18. }
  19. {$mode macpas}
  20. {$packenum 1}
  21. {$macro on}
  22. {$inline on}
  23. {$CALLING MWPASCAL}
  24. unit AEHelpers;
  25. interface
  26. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  27. {$setc GAP_INTERFACES_VERSION := $0200}
  28. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  29. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  30. {$endc}
  31. {$ifc defined CPUPOWERPC and defined CPUI386}
  32. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  33. {$endc}
  34. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  35. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  36. {$endc}
  37. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  38. {$setc __ppc__ := 1}
  39. {$elsec}
  40. {$setc __ppc__ := 0}
  41. {$endc}
  42. {$ifc not defined __i386__ and defined CPUI386}
  43. {$setc __i386__ := 1}
  44. {$elsec}
  45. {$setc __i386__ := 0}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  48. {$error Conflicting definitions for __ppc__ and __i386__}
  49. {$endc}
  50. {$ifc defined __ppc__ and __ppc__}
  51. {$setc TARGET_CPU_PPC := TRUE}
  52. {$setc TARGET_CPU_X86 := FALSE}
  53. {$elifc defined __i386__ and __i386__}
  54. {$setc TARGET_CPU_PPC := FALSE}
  55. {$setc TARGET_CPU_X86 := TRUE}
  56. {$elsec}
  57. {$error Neither __ppc__ nor __i386__ is defined.}
  58. {$endc}
  59. {$setc TARGET_CPU_PPC_64 := FALSE}
  60. {$ifc defined FPC_BIG_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  63. {$elifc defined FPC_LITTLE_ENDIAN}
  64. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  65. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  66. {$elsec}
  67. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  68. {$endc}
  69. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  70. {$setc CALL_NOT_IN_CARBON := FALSE}
  71. {$setc OLDROUTINENAMES := FALSE}
  72. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  73. {$setc OPAQUE_UPP_TYPES := TRUE}
  74. {$setc OTCARBONAPPLICATION := TRUE}
  75. {$setc OTKERNEL := FALSE}
  76. {$setc PM_USE_SESSION_APIS := TRUE}
  77. {$setc TARGET_API_MAC_CARBON := TRUE}
  78. {$setc TARGET_API_MAC_OS8 := FALSE}
  79. {$setc TARGET_API_MAC_OSX := TRUE}
  80. {$setc TARGET_CARBON := TRUE}
  81. {$setc TARGET_CPU_68K := FALSE}
  82. {$setc TARGET_CPU_MIPS := FALSE}
  83. {$setc TARGET_CPU_SPARC := FALSE}
  84. {$setc TARGET_OS_MAC := TRUE}
  85. {$setc TARGET_OS_UNIX := FALSE}
  86. {$setc TARGET_OS_WIN32 := FALSE}
  87. {$setc TARGET_RT_MAC_68881 := FALSE}
  88. {$setc TARGET_RT_MAC_CFM := FALSE}
  89. {$setc TARGET_RT_MAC_MACHO := TRUE}
  90. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  91. {$setc TYPE_BOOL := FALSE}
  92. {$setc TYPE_EXTENDED := FALSE}
  93. {$setc TYPE_LONGLONG := TRUE}
  94. uses MacTypes,AppleEvents,AEDataModel;
  95. {$ALIGN MAC68K}
  96. {
  97. * AEBuild is only available for C programmers.
  98. }
  99. {
  100. * AEPrintDescToHandle
  101. *
  102. * AEPrintDescToHandle provides a way to turn an AEDesc into a textual
  103. * representation. This is most useful for debugging calls to
  104. * AEBuildDesc and friends. The Handle returned should be disposed by
  105. * the caller. The size of the handle is the actual number of
  106. * characters in the string.
  107. }
  108. {
  109. * AEPrintDescToHandle()
  110. *
  111. * Availability:
  112. * Non-Carbon CFM: not available
  113. * CarbonLib: in CarbonLib 1.1 and later
  114. * Mac OS X: in version 10.0 and later
  115. }
  116. function AEPrintDescToHandle(const (*var*) desc: AEDesc; var result: Handle): OSStatus; external name '_AEPrintDescToHandle';
  117. {
  118. * AEStream:
  119. *
  120. * The AEStream interface allows you to build AppleEvents by appending
  121. * to an opaque structure (an AEStreamRef) and then turning this
  122. * structure into an AppleEvent. The basic idea is to open the
  123. * stream, write data, and then close it - closing it produces an
  124. * AEDesc, which may be partially complete, or may be a complete
  125. * AppleEvent.
  126. }
  127. type
  128. AEStreamRef = ^SInt32; { an opaque 32-bit type }
  129. AEStreamRefPtr = ^AEStreamRef; { when a var xx:AEStreamRef parameter can be nil, it is changed to xx: AEStreamRefPtr }
  130. {
  131. Create and return an AEStreamRef
  132. Returns NULL on memory allocation failure
  133. }
  134. {
  135. * AEStreamOpen()
  136. *
  137. * Availability:
  138. * Non-Carbon CFM: not available
  139. * CarbonLib: in CarbonLib 1.1 and later
  140. * Mac OS X: in version 10.0 and later
  141. }
  142. function AEStreamOpen: AEStreamRef; external name '_AEStreamOpen';
  143. {
  144. Closes and disposes of an AEStreamRef, producing
  145. results in the desc. You must dispose of the desc yourself.
  146. If you just want to dispose of the AEStreamRef, you can pass NULL for desc.
  147. }
  148. {
  149. * AEStreamClose()
  150. *
  151. * Availability:
  152. * Non-Carbon CFM: not available
  153. * CarbonLib: in CarbonLib 1.1 and later
  154. * Mac OS X: in version 10.0 and later
  155. }
  156. function AEStreamClose(ref: AEStreamRef; var desc: AEDesc): OSStatus; external name '_AEStreamClose';
  157. {
  158. Prepares an AEStreamRef for appending data to a newly created desc.
  159. You append data with AEStreamWriteData
  160. }
  161. {
  162. * AEStreamOpenDesc()
  163. *
  164. * Availability:
  165. * Non-Carbon CFM: not available
  166. * CarbonLib: in CarbonLib 1.1 and later
  167. * Mac OS X: in version 10.0 and later
  168. }
  169. function AEStreamOpenDesc(ref: AEStreamRef; newType: DescType): OSStatus; external name '_AEStreamOpenDesc';
  170. { Append data to the previously opened desc. }
  171. {
  172. * AEStreamWriteData()
  173. *
  174. * Availability:
  175. * Non-Carbon CFM: not available
  176. * CarbonLib: in CarbonLib 1.1 and later
  177. * Mac OS X: in version 10.0 and later
  178. }
  179. function AEStreamWriteData(ref: AEStreamRef; data: UnivPtr; length: Size): OSStatus; external name '_AEStreamWriteData';
  180. {
  181. Finish a desc. After this, you can close the stream, or adding new
  182. descs, if you're assembling a list.
  183. }
  184. {
  185. * AEStreamCloseDesc()
  186. *
  187. * Availability:
  188. * Non-Carbon CFM: not available
  189. * CarbonLib: in CarbonLib 1.1 and later
  190. * Mac OS X: in version 10.0 and later
  191. }
  192. function AEStreamCloseDesc(ref: AEStreamRef): OSStatus; external name '_AEStreamCloseDesc';
  193. { Write data as a desc to the stream }
  194. {
  195. * AEStreamWriteDesc()
  196. *
  197. * Availability:
  198. * Non-Carbon CFM: not available
  199. * CarbonLib: in CarbonLib 1.1 and later
  200. * Mac OS X: in version 10.0 and later
  201. }
  202. function AEStreamWriteDesc(ref: AEStreamRef; newType: DescType; data: UnivPtr; length: Size): OSStatus; external name '_AEStreamWriteDesc';
  203. { Write an entire desc to the stream }
  204. {
  205. * AEStreamWriteAEDesc()
  206. *
  207. * Availability:
  208. * Non-Carbon CFM: not available
  209. * CarbonLib: in CarbonLib 1.1 and later
  210. * Mac OS X: in version 10.0 and later
  211. }
  212. function AEStreamWriteAEDesc(ref: AEStreamRef; const (*var*) desc: AEDesc): OSStatus; external name '_AEStreamWriteAEDesc';
  213. {
  214. Begin a list. You can then append to the list by doing
  215. AEStreamOpenDesc, or AEStreamWriteDesc.
  216. }
  217. {
  218. * AEStreamOpenList()
  219. *
  220. * Availability:
  221. * Non-Carbon CFM: not available
  222. * CarbonLib: in CarbonLib 1.1 and later
  223. * Mac OS X: in version 10.0 and later
  224. }
  225. function AEStreamOpenList(ref: AEStreamRef): OSStatus; external name '_AEStreamOpenList';
  226. { Finish a list. }
  227. {
  228. * AEStreamCloseList()
  229. *
  230. * Availability:
  231. * Non-Carbon CFM: not available
  232. * CarbonLib: in CarbonLib 1.1 and later
  233. * Mac OS X: in version 10.0 and later
  234. }
  235. function AEStreamCloseList(ref: AEStreamRef): OSStatus; external name '_AEStreamCloseList';
  236. {
  237. Begin a record. A record usually has type 'reco', however, this is
  238. rather generic, and frequently a different type is used.
  239. }
  240. {
  241. * AEStreamOpenRecord()
  242. *
  243. * Availability:
  244. * Non-Carbon CFM: not available
  245. * CarbonLib: in CarbonLib 1.1 and later
  246. * Mac OS X: in version 10.0 and later
  247. }
  248. function AEStreamOpenRecord(ref: AEStreamRef; newType: DescType): OSStatus; external name '_AEStreamOpenRecord';
  249. { Change the type of a record. }
  250. {
  251. * AEStreamSetRecordType()
  252. *
  253. * Availability:
  254. * Non-Carbon CFM: not available
  255. * CarbonLib: in CarbonLib 1.1 and later
  256. * Mac OS X: in version 10.0 and later
  257. }
  258. function AEStreamSetRecordType(ref: AEStreamRef; newType: DescType): OSStatus; external name '_AEStreamSetRecordType';
  259. { Finish a record }
  260. {
  261. * AEStreamCloseRecord()
  262. *
  263. * Availability:
  264. * Non-Carbon CFM: not available
  265. * CarbonLib: in CarbonLib 1.1 and later
  266. * Mac OS X: in version 10.0 and later
  267. }
  268. function AEStreamCloseRecord(ref: AEStreamRef): OSStatus; external name '_AEStreamCloseRecord';
  269. {
  270. Add a keyed descriptor to a record. This is analogous to AEPutParamDesc.
  271. it can only be used when writing to a record.
  272. }
  273. {
  274. * AEStreamWriteKeyDesc()
  275. *
  276. * Availability:
  277. * Non-Carbon CFM: not available
  278. * CarbonLib: in CarbonLib 1.1 and later
  279. * Mac OS X: in version 10.0 and later
  280. }
  281. function AEStreamWriteKeyDesc(ref: AEStreamRef; key: AEKeyword; newType: DescType; data: UnivPtr; length: Size): OSStatus; external name '_AEStreamWriteKeyDesc';
  282. {
  283. OpenDesc for a keyed record entry. You can youse AEStreamWriteData
  284. after opening a keyed desc.
  285. }
  286. {
  287. * AEStreamOpenKeyDesc()
  288. *
  289. * Availability:
  290. * Non-Carbon CFM: not available
  291. * CarbonLib: in CarbonLib 1.1 and later
  292. * Mac OS X: in version 10.0 and later
  293. }
  294. function AEStreamOpenKeyDesc(ref: AEStreamRef; key: AEKeyword; newType: DescType): OSStatus; external name '_AEStreamOpenKeyDesc';
  295. { Write a key to the stream - you can follow this with an AEWriteDesc. }
  296. {
  297. * AEStreamWriteKey()
  298. *
  299. * Availability:
  300. * Non-Carbon CFM: not available
  301. * CarbonLib: in CarbonLib 1.1 and later
  302. * Mac OS X: in version 10.0 and later
  303. }
  304. function AEStreamWriteKey(ref: AEStreamRef; key: AEKeyword): OSStatus; external name '_AEStreamWriteKey';
  305. {
  306. Create a complete AppleEvent. This creates and returns a new stream.
  307. Use this call to populate the meta fields in an AppleEvent record.
  308. After this, you can add your records, lists and other parameters.
  309. }
  310. {
  311. * AEStreamCreateEvent()
  312. *
  313. * Availability:
  314. * Non-Carbon CFM: not available
  315. * CarbonLib: in CarbonLib 1.1 and later
  316. * Mac OS X: in version 10.0 and later
  317. }
  318. function AEStreamCreateEvent(clazz: AEEventClass; id: AEEventID; targetType: DescType; targetData: UnivPtr; targetLength: SInt32; returnID: SInt16; transactionID: SInt32): AEStreamRef; external name '_AEStreamCreateEvent';
  319. {
  320. This call lets you augment an existing AppleEvent using the stream
  321. APIs. This would be useful, for example, in constructing the reply
  322. record in an AppleEvent handler. Note that AEStreamOpenEvent will
  323. consume the AppleEvent passed in - you can't access it again until the
  324. stream is closed. When you're done building the event, AEStreamCloseStream
  325. will reconstitute it.
  326. }
  327. {
  328. * AEStreamOpenEvent()
  329. *
  330. * Availability:
  331. * Non-Carbon CFM: not available
  332. * CarbonLib: in CarbonLib 1.1 and later
  333. * Mac OS X: in version 10.0 and later
  334. }
  335. function AEStreamOpenEvent(var event: AppleEvent): AEStreamRef; external name '_AEStreamOpenEvent';
  336. { Mark a keyword as being an optional parameter. }
  337. {
  338. * AEStreamOptionalParam()
  339. *
  340. * Availability:
  341. * Non-Carbon CFM: not available
  342. * CarbonLib: in CarbonLib 1.1 and later
  343. * Mac OS X: in version 10.0 and later
  344. }
  345. function AEStreamOptionalParam(ref: AEStreamRef; key: AEKeyword): OSStatus; external name '_AEStreamOptionalParam';
  346. {$ALIGN MAC68K}
  347. end.