OSA.pas 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047
  1. {
  2. File: OpenScripting/OSA.h
  3. Contains: Open Scripting Architecture Client Interfaces.
  4. Version: OSA-148~28
  5. Copyright: © 1992-2008 by Apple Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://bugs.freepascal.org
  9. }
  10. { Pascal Translation Updated: Gorazd Krosl <[email protected]>, October 2009 }
  11. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  12. {
  13. Modified for use with Free Pascal
  14. Version 308
  15. Please report any bugs to <[email protected]>
  16. }
  17. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  18. {$mode macpas}
  19. {$packenum 1}
  20. {$macro on}
  21. {$inline on}
  22. {$calling mwpascal}
  23. unit OSA;
  24. interface
  25. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  26. {$setc GAP_INTERFACES_VERSION := $0308}
  27. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  28. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  29. {$endc}
  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. {$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. {$ifc not defined __arm64__ and defined CPUAARCH64}
  62. {$setc __arm64__ := 1}
  63. {$elsec}
  64. {$setc __arm64__ := 0}
  65. {$endc}
  66. {$ifc defined cpu64}
  67. {$setc __LP64__ := 1}
  68. {$elsec}
  69. {$setc __LP64__ := 0}
  70. {$endc}
  71. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  72. {$error Conflicting definitions for __ppc__ and __i386__}
  73. {$endc}
  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_CPU_ARM64 := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_IPHONE := FALSE}
  83. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  84. {$setc TARGET_OS_EMBEDDED := FALSE}
  85. {$elifc defined __ppc64__ and __ppc64__}
  86. {$setc TARGET_CPU_PPC := FALSE}
  87. {$setc TARGET_CPU_PPC64 := TRUE}
  88. {$setc TARGET_CPU_X86 := FALSE}
  89. {$setc TARGET_CPU_X86_64 := FALSE}
  90. {$setc TARGET_CPU_ARM := FALSE}
  91. {$setc TARGET_CPU_ARM64 := FALSE}
  92. {$setc TARGET_OS_MAC := TRUE}
  93. {$setc TARGET_OS_IPHONE := FALSE}
  94. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  95. {$setc TARGET_OS_EMBEDDED := FALSE}
  96. {$elifc defined __i386__ and __i386__}
  97. {$setc TARGET_CPU_PPC := FALSE}
  98. {$setc TARGET_CPU_PPC64 := FALSE}
  99. {$setc TARGET_CPU_X86 := TRUE}
  100. {$setc TARGET_CPU_X86_64 := FALSE}
  101. {$setc TARGET_CPU_ARM := FALSE}
  102. {$setc TARGET_CPU_ARM64 := FALSE}
  103. {$ifc defined(iphonesim)}
  104. {$setc TARGET_OS_MAC := FALSE}
  105. {$setc TARGET_OS_IPHONE := TRUE}
  106. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  107. {$elsec}
  108. {$setc TARGET_OS_MAC := TRUE}
  109. {$setc TARGET_OS_IPHONE := FALSE}
  110. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  111. {$endc}
  112. {$setc TARGET_OS_EMBEDDED := FALSE}
  113. {$elifc defined __x86_64__ and __x86_64__}
  114. {$setc TARGET_CPU_PPC := FALSE}
  115. {$setc TARGET_CPU_PPC64 := FALSE}
  116. {$setc TARGET_CPU_X86 := FALSE}
  117. {$setc TARGET_CPU_X86_64 := TRUE}
  118. {$setc TARGET_CPU_ARM := FALSE}
  119. {$setc TARGET_CPU_ARM64 := FALSE}
  120. {$ifc defined(iphonesim)}
  121. {$setc TARGET_OS_MAC := FALSE}
  122. {$setc TARGET_OS_IPHONE := TRUE}
  123. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  124. {$elsec}
  125. {$setc TARGET_OS_MAC := TRUE}
  126. {$setc TARGET_OS_IPHONE := FALSE}
  127. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  128. {$endc}
  129. {$setc TARGET_OS_EMBEDDED := FALSE}
  130. {$elifc defined __arm__ and __arm__}
  131. {$setc TARGET_CPU_PPC := FALSE}
  132. {$setc TARGET_CPU_PPC64 := FALSE}
  133. {$setc TARGET_CPU_X86 := FALSE}
  134. {$setc TARGET_CPU_X86_64 := FALSE}
  135. {$setc TARGET_CPU_ARM := TRUE}
  136. {$setc TARGET_CPU_ARM64 := FALSE}
  137. { will require compiler define when/if other Apple devices with ARM cpus ship }
  138. {$setc TARGET_OS_MAC := FALSE}
  139. {$setc TARGET_OS_IPHONE := TRUE}
  140. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  141. {$setc TARGET_OS_EMBEDDED := TRUE}
  142. {$elifc defined __arm64__ and __arm64__}
  143. {$setc TARGET_CPU_PPC := FALSE}
  144. {$setc TARGET_CPU_PPC64 := FALSE}
  145. {$setc TARGET_CPU_X86 := FALSE}
  146. {$setc TARGET_CPU_X86_64 := FALSE}
  147. {$setc TARGET_CPU_ARM := FALSE}
  148. {$setc TARGET_CPU_ARM64 := TRUE}
  149. { will require compiler define when/if other Apple devices with ARM cpus ship }
  150. {$setc TARGET_OS_MAC := FALSE}
  151. {$setc TARGET_OS_IPHONE := TRUE}
  152. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  153. {$setc TARGET_OS_EMBEDDED := TRUE}
  154. {$elsec}
  155. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  156. {$endc}
  157. {$ifc defined __LP64__ and __LP64__ }
  158. {$setc TARGET_CPU_64 := TRUE}
  159. {$elsec}
  160. {$setc TARGET_CPU_64 := FALSE}
  161. {$endc}
  162. {$ifc defined FPC_BIG_ENDIAN}
  163. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  164. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  165. {$elifc defined FPC_LITTLE_ENDIAN}
  166. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  167. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  168. {$elsec}
  169. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  170. {$endc}
  171. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  172. {$setc CALL_NOT_IN_CARBON := FALSE}
  173. {$setc OLDROUTINENAMES := FALSE}
  174. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  175. {$setc OPAQUE_UPP_TYPES := TRUE}
  176. {$setc OTCARBONAPPLICATION := TRUE}
  177. {$setc OTKERNEL := FALSE}
  178. {$setc PM_USE_SESSION_APIS := TRUE}
  179. {$setc TARGET_API_MAC_CARBON := TRUE}
  180. {$setc TARGET_API_MAC_OS8 := FALSE}
  181. {$setc TARGET_API_MAC_OSX := TRUE}
  182. {$setc TARGET_CARBON := TRUE}
  183. {$setc TARGET_CPU_68K := FALSE}
  184. {$setc TARGET_CPU_MIPS := FALSE}
  185. {$setc TARGET_CPU_SPARC := FALSE}
  186. {$setc TARGET_OS_UNIX := FALSE}
  187. {$setc TARGET_OS_WIN32 := FALSE}
  188. {$setc TARGET_RT_MAC_68881 := FALSE}
  189. {$setc TARGET_RT_MAC_CFM := FALSE}
  190. {$setc TARGET_RT_MAC_MACHO := TRUE}
  191. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  192. {$setc TYPE_BOOL := FALSE}
  193. {$setc TYPE_EXTENDED := FALSE}
  194. {$setc TYPE_LONGLONG := TRUE}
  195. uses MacTypes,AEDataModel,MacErrors,AppleEvents,AEObjects,AEInteraction,Components,Files,CFBase,CFURL,CFAttributedString;
  196. {$endc} {not MACOSALLINCLUDE}
  197. {$ifc TARGET_OS_MAC}
  198. {$ALIGN POWER}
  199. {*************************************************************************
  200. Types and Constants
  201. *************************************************************************}
  202. { The componenent manager type code for components that
  203. support the OSA interface defined here. }
  204. { 0x6f736120 }
  205. const
  206. kOSAComponentType = FourCharCode('osa ');
  207. { 0x73637074 }
  208. const
  209. kOSAGenericScriptingComponentSubtype = FourCharCode('scpt');
  210. { Type of script document files. }
  211. { 0x6f736173 }
  212. const
  213. kOSAFileType = FourCharCode('osas');
  214. {
  215. Suite and event code of the RecordedText event.
  216. (See OSAStartRecording, below.)
  217. }
  218. { 0x61736372 }
  219. const
  220. kOSASuite = FourCharCode('ascr');
  221. { 0x72656364 }
  222. const
  223. kOSARecordedText = FourCharCode('recd');
  224. { Selector returns boolean }
  225. { 0x6d6f6469 }
  226. const
  227. kOSAScriptIsModified = FourCharCode('modi');
  228. { Selector returns boolean }
  229. { 0x63736372 }
  230. const
  231. kOSAScriptIsTypeCompiledScript = FourCharCode('cscr');
  232. { Selector returns boolean }
  233. { 0x76616c75 }
  234. const
  235. kOSAScriptIsTypeScriptValue = FourCharCode('valu');
  236. { Selector returns boolean }
  237. { 0x636e7478 }
  238. const
  239. kOSAScriptIsTypeScriptContext = FourCharCode('cntx');
  240. { Selector returns a DescType which may be passed to OSACoerceToDesc }
  241. { 0x62657374 }
  242. const
  243. kOSAScriptBestType = FourCharCode('best');
  244. {
  245. This selector is used to determine whether a script has source
  246. associated with it that when given to OSAGetSource, the call will not
  247. fail. The selector returns a boolean.
  248. }
  249. { 0x67737263 }
  250. const
  251. kOSACanGetSource = FourCharCode('gsrc');
  252. const
  253. typeOSADialectInfo = FourCharCode('difo'); { 0x6469666f }
  254. keyOSADialectName = FourCharCode('dnam'); { 0x646e616d }
  255. keyOSADialectCode = FourCharCode('dcod'); { 0x64636f64 }
  256. keyOSADialectLangCode = FourCharCode('dlcd'); { 0x646c6364 }
  257. keyOSADialectScriptCode = FourCharCode('dscd'); { 0x64736364 }
  258. type
  259. OSAError = ComponentResult;
  260. { Under the Open Scripting Architecture all error results are longs }
  261. type
  262. OSAID = UInt32;
  263. {
  264. OSAIDs allow transparent manipulation of scripts associated with
  265. various scripting systems.
  266. }
  267. const
  268. kOSANullScript = 0;
  269. { No -script constant. }
  270. const
  271. kOSANullMode = 0; { sounds better }
  272. kOSAModeNull = 0; { tastes consistent }
  273. {
  274. Some routines take flags that control their execution. This constant
  275. declares default mode settings are used.
  276. }
  277. type
  278. OSACreateAppleEventProcPtr = function( theAEEventClass: AEEventClass; theAEEventID: AEEventID; const (*var*) target: AEAddressDesc; returnID: SInt16; transactionID: SInt32; var result: AppleEvent; refCon: SRefCon ): OSErr;
  279. OSASendProcPtr = function( const (*var*) theAppleEvent: AppleEvent; var reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: SInt32; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: SRefCon ): OSErr;
  280. OSACreateAppleEventUPP = OSACreateAppleEventProcPtr;
  281. OSASendUPP = OSASendProcPtr;
  282. {
  283. * NewOSACreateAppleEventUPP()
  284. *
  285. * Availability:
  286. * Mac OS X: in version 10.0 and later in Carbon.framework
  287. * CarbonLib: in CarbonLib 1.0 and later
  288. * Non-Carbon CFM: available as macro/inline
  289. }
  290. function NewOSACreateAppleEventUPP( userRoutine: OSACreateAppleEventProcPtr ): OSACreateAppleEventUPP; external name '_NewOSACreateAppleEventUPP';
  291. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  292. {
  293. * NewOSASendUPP()
  294. *
  295. * Availability:
  296. * Mac OS X: in version 10.0 and later in Carbon.framework
  297. * CarbonLib: in CarbonLib 1.0 and later
  298. * Non-Carbon CFM: available as macro/inline
  299. }
  300. function NewOSASendUPP( userRoutine: OSASendProcPtr ): OSASendUPP; external name '_NewOSASendUPP';
  301. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  302. {
  303. * DisposeOSACreateAppleEventUPP()
  304. *
  305. * Availability:
  306. * Mac OS X: in version 10.0 and later in Carbon.framework
  307. * CarbonLib: in CarbonLib 1.0 and later
  308. * Non-Carbon CFM: available as macro/inline
  309. }
  310. procedure DisposeOSACreateAppleEventUPP( userUPP: OSACreateAppleEventUPP ); external name '_DisposeOSACreateAppleEventUPP';
  311. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  312. {
  313. * DisposeOSASendUPP()
  314. *
  315. * Availability:
  316. * Mac OS X: in version 10.0 and later in Carbon.framework
  317. * CarbonLib: in CarbonLib 1.0 and later
  318. * Non-Carbon CFM: available as macro/inline
  319. }
  320. procedure DisposeOSASendUPP( userUPP: OSASendUPP ); external name '_DisposeOSASendUPP';
  321. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  322. {
  323. * InvokeOSACreateAppleEventUPP()
  324. *
  325. * Availability:
  326. * Mac OS X: in version 10.0 and later in Carbon.framework
  327. * CarbonLib: in CarbonLib 1.0 and later
  328. * Non-Carbon CFM: available as macro/inline
  329. }
  330. function InvokeOSACreateAppleEventUPP( theAEEventClass: AEEventClass; theAEEventID: AEEventID; const (*var*) target: AEAddressDesc; returnID: SInt16; transactionID: SInt32; var result: AppleEvent; refCon: SRefCon; userUPP: OSACreateAppleEventUPP ): OSErr; external name '_InvokeOSACreateAppleEventUPP';
  331. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  332. {
  333. * InvokeOSASendUPP()
  334. *
  335. * Availability:
  336. * Mac OS X: in version 10.0 and later in Carbon.framework
  337. * CarbonLib: in CarbonLib 1.0 and later
  338. * Non-Carbon CFM: available as macro/inline
  339. }
  340. function InvokeOSASendUPP( const (*var*) theAppleEvent: AppleEvent; var reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: SInt32; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: SRefCon; userUPP: OSASendUPP ): OSErr; external name '_InvokeOSASendUPP';
  341. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  342. {*************************************************************************
  343. OSA Interface Descriptions
  344. **************************************************************************
  345. The OSA Interface is broken down into a required interface, and several
  346. optional interfaces to support additional functionality. A given scripting
  347. component may choose to support only some of the optional interfaces in
  348. addition to the basic interface. The OSA Component Flags may be used to
  349. query the Component Manager to find a scripting component with a particular
  350. capability, or determine if a particular scripting component supports a
  351. particular capability.
  352. *************************************************************************}
  353. { OSA Component Flags: }
  354. const
  355. kOSASupportsCompiling = $0002;
  356. kOSASupportsGetSource = $0004;
  357. kOSASupportsAECoercion = $0008;
  358. kOSASupportsAESending = $0010;
  359. kOSASupportsRecording = $0020;
  360. kOSASupportsConvenience = $0040;
  361. kOSASupportsDialects = $0080;
  362. kOSASupportsEventHandling = $0100;
  363. { Component Selectors: }
  364. const
  365. kOSASelectLoad = $0001;
  366. kOSASelectStore = $0002;
  367. kOSASelectExecute = $0003;
  368. kOSASelectDisplay = $0004;
  369. kOSASelectScriptError = $0005;
  370. kOSASelectDispose = $0006;
  371. kOSASelectSetScriptInfo = $0007;
  372. kOSASelectGetScriptInfo = $0008;
  373. kOSASelectSetActiveProc = $0009;
  374. kOSASelectGetActiveProc = $000A;
  375. kOSASelectCopyDisplayString = $000B;
  376. { Compiling: }
  377. const
  378. kOSASelectScriptingComponentName = $0102;
  379. kOSASelectCompile = $0103;
  380. kOSASelectCopyID = $0104;
  381. kOSASelectCopyScript = $0105;
  382. { GetSource: }
  383. const
  384. kOSASelectGetSource = $0201;
  385. kOSASelectCopySourceString = $0202;
  386. { AECoercion: }
  387. const
  388. kOSASelectCoerceFromDesc = $0301;
  389. kOSASelectCoerceToDesc = $0302;
  390. { AESending: }
  391. const
  392. kOSASelectSetSendProc = $0401;
  393. kOSASelectGetSendProc = $0402;
  394. kOSASelectSetCreateProc = $0403;
  395. kOSASelectGetCreateProc = $0404;
  396. kOSASelectSetDefaultTarget = $0405;
  397. { Recording: }
  398. const
  399. kOSASelectStartRecording = $0501;
  400. kOSASelectStopRecording = $0502;
  401. { Convenience: }
  402. const
  403. kOSASelectLoadExecute = $0601;
  404. kOSASelectCompileExecute = $0602;
  405. kOSASelectDoScript = $0603;
  406. { Dialects: }
  407. const
  408. kOSASelectSetCurrentDialect = $0701;
  409. kOSASelectGetCurrentDialect = $0702;
  410. kOSASelectAvailableDialects = $0703;
  411. kOSASelectGetDialectInfo = $0704;
  412. kOSASelectAvailableDialectCodeList = $0705;
  413. { Event Handling: }
  414. const
  415. kOSASelectSetResumeDispatchProc = $0801;
  416. kOSASelectGetResumeDispatchProc = $0802;
  417. kOSASelectExecuteEvent = $0803;
  418. kOSASelectDoEvent = $0804;
  419. kOSASelectMakeContext = $0805;
  420. { scripting component specific selectors are added beginning with this value }
  421. const
  422. kOSASelectComponentSpecificStart = $1001;
  423. { Mode Flags:
  424. Warning: These should not conflict with the AESend mode flags in
  425. AppleEvents.h, because we may want to use them as OSA mode flags too.
  426. }
  427. {
  428. This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  429. instruct the scripting component to not retain the "source" of an
  430. expression. This will cause the OSAGetSource call to return the error
  431. errOSASourceNotAvailable if used. However, some scripting components
  432. may not retain the source anyway. This is mainly used when either space
  433. efficiency is desired, or a script is to be "locked" so that its
  434. implementation may not be viewed.
  435. }
  436. const
  437. kOSAModePreventGetSource = $00000001;
  438. {
  439. These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  440. OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  441. indicate whether or not the script may interact with the user, switch
  442. layer or reconnect if necessary. Any AppleEvents will be sent with the
  443. corresponding AESend mode supplied.
  444. }
  445. const
  446. kOSAModeNeverInteract = kAENeverInteract;
  447. kOSAModeCanInteract = kAECanInteract;
  448. kOSAModeAlwaysInteract = kAEAlwaysInteract;
  449. kOSAModeDontReconnect = kAEDontReconnect;
  450. {
  451. This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  452. OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  453. indicate whether or not AppleEvents should be sent with the
  454. kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  455. opposite sense of the AppleEvent flag kAECanSwitchLayer. This is to
  456. provide a more convenient default, i.e. not supplying any mode
  457. (kOSAModeNull) means to send events with kAECanSwitchLayer. Supplying
  458. the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  459. without kAECanSwitchLayer.
  460. }
  461. const
  462. kOSAModeCantSwitchLayer = $00000040;
  463. {
  464. This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  465. OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  466. indicate whether or not AppleEvents should be sent with the kAEDontRecord
  467. mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  468. the AppleEvent flag kAEDontRecord. This is to provide a more convenient
  469. default, i.e. not supplying any mode (kOSAModeNull) means to send events
  470. with kAEDontRecord. Supplying the kOSAModeDoRecord mode flag will
  471. cause AESend to be called without kAEDontRecord.
  472. }
  473. const
  474. kOSAModeDoRecord = $00001000;
  475. {
  476. This is a mode flag for OSACompile that indicates that a context should
  477. be created as the result of compilation. All handler definitions are
  478. inserted into the new context, and variables are initialized by
  479. evaluating their initial values in a null context (i.e. they must be
  480. constant expressions).
  481. }
  482. const
  483. kOSAModeCompileIntoContext = $00000002;
  484. {
  485. This is a mode flag for OSACompile that indicates that the previous
  486. script ID (input to OSACompile) should be augmented with any new
  487. definitions in the sourceData rather than replaced with a new script.
  488. This means that the previous script ID must designate a context.
  489. The presence of this flag causes the kOSAModeCompileIntoContext flag
  490. to be implicitly used, causing any new definitions to be initialized
  491. in a null context.
  492. }
  493. const
  494. kOSAModeAugmentContext = $00000004;
  495. {
  496. This mode flag may be passed to OSADisplay or OSADoScript to indicate
  497. that output only need be human-readable, not re-compilable by OSACompile.
  498. If used, output may be arbitrarily "beautified", e.g. quotes may be left
  499. off of string values, long lists may have elipses, etc.
  500. }
  501. const
  502. kOSAModeDisplayForHumans = $00000008;
  503. {
  504. This mode flag may be passed to OSAStore in the case where the scriptID
  505. is a context. This causes the context to be saved, but not the context's
  506. parent context. When the stored context is loaded back in, the parent
  507. will be kOSANullScript.
  508. }
  509. const
  510. kOSAModeDontStoreParent = $00010000;
  511. {
  512. This mode flag may be passed to OSAExecuteEvent to cause the event to
  513. be dispatched to the direct object of the event. The direct object (or
  514. subject attribute if the direct object is a non-object specifier) will
  515. be resolved, and the resulting script object will be the recipient of
  516. the message. The context argument to OSAExecuteEvent will serve as the
  517. root of the lookup/resolution process.
  518. }
  519. const
  520. kOSAModeDispatchToDirectObject = $00020000;
  521. {
  522. This mode flag may be passed to OSAExecuteEvent to indicate that
  523. components do not have to get the data of object specifier arguments.
  524. }
  525. const
  526. kOSAModeDontGetDataForArguments = $00040000;
  527. {
  528. This mode flag may be passed to OSACoerceToDesc to indicate that
  529. the resulting descriptor should be fully qualified (i.e. should
  530. include the root application reference).
  531. }
  532. const
  533. kOSAModeFullyQualifyDescriptors = $00080000;
  534. {*************************************************************************
  535. OSA Basic Scripting Interface
  536. **************************************************************************
  537. Scripting components must at least support the Basic Scripting interface.
  538. *************************************************************************}
  539. { Loading and Storing Scripts:
  540. These routines allow scripts to be loaded and stored in their internal
  541. (possibly compiled, non-text) representation.
  542. }
  543. { Resource type for scripts }
  544. const
  545. kOSAScriptResourceType = kOSAGenericScriptingComponentSubtype;
  546. {
  547. Default type given to OSAStore which creates "generic" loadable script
  548. data descriptors.
  549. }
  550. const
  551. typeOSAGenericStorage = kOSAScriptResourceType;
  552. {
  553. * OSALoad()
  554. *
  555. * Availability:
  556. * Mac OS X: in version 10.0 and later in Carbon.framework
  557. * CarbonLib: in CarbonLib 1.0 and later
  558. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  559. }
  560. function OSALoad( scriptingComponent: ComponentInstance; const (*var*) scriptData: AEDesc; modeFlags: SInt32; var resultingScriptID: OSAID ): OSAError; external name '_OSALoad';
  561. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  562. {
  563. OSAComponentFunctionInline(kOSASelectLoad, 12);
  564. Errors:
  565. badComponentInstance invalid scripting component instance
  566. errOSASystemError
  567. errOSABadStorageType: scriptData not for this scripting component
  568. errOSACorruptData: data seems to be corrupt
  569. errOSADataFormatObsolete script data format is no longer supported
  570. errOSADataFormatTooNew script data format is from a newer version
  571. ModeFlags:
  572. kOSAModePreventGetSource
  573. }
  574. {
  575. * OSAStore()
  576. *
  577. * Availability:
  578. * Mac OS X: in version 10.0 and later in Carbon.framework
  579. * CarbonLib: in CarbonLib 1.0 and later
  580. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  581. }
  582. function OSAStore( scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: SInt32; var resultingScriptData: AEDesc ): OSAError; external name '_OSAStore';
  583. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  584. {
  585. OSAComponentFunctionInline(kOSASelectStore, 16);
  586. Errors:
  587. badComponentInstance invalid scripting component instance
  588. errOSASystemError
  589. errOSAInvalidID
  590. errOSABadStorageType: desiredType not for this scripting component
  591. ModeFlags:
  592. kOSAModePreventGetSource
  593. kOSAModeDontStoreParent
  594. }
  595. { Executing Scripts: }
  596. {
  597. * OSAExecute()
  598. *
  599. * Availability:
  600. * Mac OS X: in version 10.0 and later in Carbon.framework
  601. * CarbonLib: in CarbonLib 1.0 and later
  602. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  603. }
  604. function OSAExecute( scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: SInt32; var resultingScriptValueID: OSAID ): OSAError; external name '_OSAExecute';
  605. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  606. {
  607. OSAComponentFunctionInline(kOSASelectExecute, 16);
  608. This call runs a script. The contextID represents the environment
  609. with which global variables in the script are resolved. The constant
  610. kOSANullScript may be used for the contextID if the application wishes
  611. to not deal with context directly (a default one is associated with each
  612. scripting component instance). The resultingScriptValueID is the
  613. result of evaluation, and contains a value which may be displayed using
  614. the OSAGetSource call. The modeFlags convey scripting component
  615. specific information.
  616. Errors:
  617. badComponentInstance invalid scripting component instance
  618. errOSASystemError
  619. errOSAInvalidID
  620. errOSAScriptError: the executing script got an error
  621. ModeFlags:
  622. kOSAModeNeverInteract
  623. kOSAModeCanInteract
  624. kOSAModeAlwaysInteract
  625. kOSAModeCantSwitchLayer
  626. kOSAModeDontReconnect
  627. kOSAModeDoRecord
  628. }
  629. { Displaying results: }
  630. {
  631. * OSADisplay()
  632. *
  633. * Availability:
  634. * Mac OS X: in version 10.0 and later in Carbon.framework
  635. * CarbonLib: in CarbonLib 1.0 and later
  636. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  637. }
  638. function OSADisplay( scriptingComponent: ComponentInstance; scriptValueID: OSAID; desiredType: DescType; modeFlags: SInt32; var resultingText: AEDesc ): OSAError; external name '_OSADisplay';
  639. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  640. {
  641. OSAComponentFunctionInline(kOSASelectDisplay, 16);
  642. This call is used to convert results (script value IDs) into displayable
  643. text. The desiredType should be at least typeChar, and modeFlags are
  644. scripting system specific flags to control the formatting of the
  645. resulting text. This call differs from OSAGetSource in that (1) it
  646. always produces at least typeChar, (2) is only works on script values,
  647. (3) it may display it's output in non-compilable form (e.g. without
  648. string quotes, elipses inserted in long and/or circular lists, etc.) and
  649. (4) it is required by the basic scripting interface.
  650. Errors:
  651. badComponentInstance invalid scripting component instance
  652. errOSASystemError
  653. errOSAInvalidID
  654. errAECoercionFail: desiredType not supported by scripting component
  655. ModeFlags:
  656. kOSAModeDisplayForHumans
  657. }
  658. {
  659. @function OSACopyDisplayString
  660. @discussion Similar to OSADisplay, but returns the text as a CFAttributedStringRef.
  661. }
  662. {
  663. * OSACopyDisplayString()
  664. *
  665. * Availability:
  666. * Mac OS X: in version 10.5 and later in Carbon.framework
  667. * CarbonLib: not available
  668. * Non-Carbon CFM: not available
  669. }
  670. function OSACopyDisplayString( scriptingComponent: ComponentInstance; scriptID: OSAID; modeFlags: SInt32; var result: CFAttributedStringRef ): OSAError; external name '_OSACopyDisplayString';
  671. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  672. { Getting Error Information: }
  673. {
  674. * OSAScriptError()
  675. *
  676. * Availability:
  677. * Mac OS X: in version 10.0 and later in Carbon.framework
  678. * CarbonLib: in CarbonLib 1.0 and later
  679. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  680. }
  681. function OSAScriptError( scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; var resultingErrorDescription: AEDesc ): OSAError; external name '_OSAScriptError';
  682. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  683. {
  684. OSAComponentFunctionInline(kOSASelectScriptError, 12);
  685. Whenever script execution returns errOSAExecutionError, this routine
  686. may be used to get information about that error. The selector describes
  687. the type of information desired about the error (various selectors are
  688. listed below). The desiredType indicates the data type of the result
  689. desired for that selector.
  690. Errors:
  691. badComponentInstance invalid scripting component instance
  692. errOSASystemError
  693. errOSABadSelector: selector not supported by scripting component
  694. errAECoercionFail: desiredType not supported by scripting component
  695. }
  696. { OSAScriptError selectors: }
  697. {
  698. This selector is used to determine the error number of a script error.
  699. These error numbers may be either system error numbers, or error numbers
  700. that are scripting component specific.
  701. Required desiredTypes:
  702. typeSInt32
  703. }
  704. const
  705. kOSAErrorNumber = keyErrorNumber;
  706. {
  707. This selector is used to determine the full error message associated
  708. with the error number. It should include the name of the application
  709. which caused the error, as well as the specific error that occurred.
  710. This selector is sufficient for simple error reporting (but see
  711. kOSAErrorBriefMessage, below).
  712. Required desiredTypes:
  713. typeChar error message string
  714. }
  715. const
  716. kOSAErrorMessage = keyErrorString;
  717. {
  718. This selector is used to determine a brief error message associated with
  719. the error number. This message and should not mention the name of the
  720. application which caused the error, any partial results or offending
  721. object (see kOSAErrorApp, kOSAErrorPartialResult and
  722. kOSAErrorOffendingObject, below).
  723. Required desiredTypes:
  724. typeChar brief error message string
  725. }
  726. { 0x65727262 }
  727. const
  728. kOSAErrorBriefMessage = FourCharCode('errb');
  729. {
  730. This selector is used to determine which application actually got the
  731. error (if it was the result of an AESend), or the current application
  732. if ....
  733. Required desiredTypes:
  734. typeProcessSerialNumber PSN of the errant application
  735. typeChar name of the errant application
  736. }
  737. { 0x65726170 }
  738. const
  739. kOSAErrorApp = FourCharCode('erap');
  740. {
  741. This selector is used to determine any partial result returned by an
  742. operation. If an AESend call failed, but a partial result was returned,
  743. then the partial result may be returned as an AEDesc.
  744. Required desiredTypes:
  745. typeBest AEDesc of any partial result
  746. }
  747. { 0x70746c72 }
  748. const
  749. kOSAErrorPartialResult = FourCharCode('ptlr');
  750. {
  751. This selector is used to determine any object which caused the error
  752. that may have been indicated by an application. The result is an
  753. AEDesc.
  754. Required desiredTypes:
  755. typeBest AEDesc of any offending object
  756. }
  757. { 0x65726f62 }
  758. const
  759. kOSAErrorOffendingObject = FourCharCode('erob');
  760. {
  761. This selector is used to determine the type expected by a coercion
  762. operation if a type error occurred.
  763. }
  764. { 0x65727274 }
  765. const
  766. kOSAErrorExpectedType = FourCharCode('errt');
  767. {
  768. This selector is used to determine the source text range (start and
  769. end positions) of where the error occurred.
  770. Required desiredTypes:
  771. typeOSAErrorRange
  772. }
  773. { 0x65726e67 }
  774. const
  775. kOSAErrorRange = FourCharCode('erng');
  776. {
  777. An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  778. of type short.
  779. }
  780. { 0x65726e67 }
  781. const
  782. typeOSAErrorRange = FourCharCode('erng');
  783. { Field of a typeOSAErrorRange record of typeSInt16 }
  784. { 0x73726373 }
  785. const
  786. keyOSASourceStart = FourCharCode('srcs');
  787. { Field of a typeOSAErrorRange record of typeSInt16 }
  788. { 0x73726365 }
  789. const
  790. keyOSASourceEnd = FourCharCode('srce');
  791. { Disposing Script IDs: }
  792. {
  793. * OSADispose()
  794. *
  795. * Availability:
  796. * Mac OS X: in version 10.0 and later in Carbon.framework
  797. * CarbonLib: in CarbonLib 1.0 and later
  798. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  799. }
  800. function OSADispose( scriptingComponent: ComponentInstance; scriptID: OSAID ): OSAError; external name '_OSADispose';
  801. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  802. {
  803. OSAComponentFunctionInline(kOSASelectDispose, 4);
  804. Disposes a script or context.
  805. Errors:
  806. badComponentInstance invalid scripting component instance
  807. errOSASystemError
  808. errOSAInvalidID
  809. }
  810. { Getting and Setting Script Information: }
  811. {
  812. * OSASetScriptInfo()
  813. *
  814. * Availability:
  815. * Mac OS X: in version 10.0 and later in Carbon.framework
  816. * CarbonLib: in CarbonLib 1.0 and later
  817. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  818. }
  819. function OSASetScriptInfo( scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; value: SIGNEDLONG ): OSAError; external name '_OSASetScriptInfo';
  820. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  821. {
  822. OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  823. Errors:
  824. badComponentInstance invalid scripting component instance
  825. errOSASystemError
  826. errOSAInvalidID
  827. errOSABadSelector: selector not supported by scripting component
  828. or selector not for this scriptID
  829. }
  830. {
  831. * OSAGetScriptInfo()
  832. *
  833. * Availability:
  834. * Mac OS X: in version 10.0 and later in Carbon.framework
  835. * CarbonLib: in CarbonLib 1.0 and later
  836. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  837. }
  838. function OSAGetScriptInfo( scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; var result: SIGNEDLONG ): OSAError; external name '_OSAGetScriptInfo';
  839. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  840. {
  841. OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  842. Errors:
  843. badComponentInstance invalid scripting component instance
  844. errOSASystemError
  845. errOSAInvalidID
  846. errOSABadSelector: selector not supported by scripting component
  847. or selector not for this scriptID
  848. }
  849. { Manipulating the ActiveProc:
  850. Scripting systems will supply default values for these procedures if they
  851. are not set by the client:
  852. }
  853. type
  854. OSAActiveProcPtr = function( refCon: SRefCon ): OSErr;
  855. OSAActiveUPP = OSAActiveProcPtr;
  856. {
  857. * NewOSAActiveUPP()
  858. *
  859. * Availability:
  860. * Mac OS X: in version 10.0 and later in Carbon.framework
  861. * CarbonLib: in CarbonLib 1.0 and later
  862. * Non-Carbon CFM: available as macro/inline
  863. }
  864. function NewOSAActiveUPP( userRoutine: OSAActiveProcPtr ): OSAActiveUPP; external name '_NewOSAActiveUPP';
  865. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  866. {
  867. * DisposeOSAActiveUPP()
  868. *
  869. * Availability:
  870. * Mac OS X: in version 10.0 and later in Carbon.framework
  871. * CarbonLib: in CarbonLib 1.0 and later
  872. * Non-Carbon CFM: available as macro/inline
  873. }
  874. procedure DisposeOSAActiveUPP( userUPP: OSAActiveUPP ); external name '_DisposeOSAActiveUPP';
  875. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  876. {
  877. * InvokeOSAActiveUPP()
  878. *
  879. * Availability:
  880. * Mac OS X: in version 10.0 and later in Carbon.framework
  881. * CarbonLib: in CarbonLib 1.0 and later
  882. * Non-Carbon CFM: available as macro/inline
  883. }
  884. function InvokeOSAActiveUPP( refCon: SRefCon; userUPP: OSAActiveUPP ): OSErr; external name '_InvokeOSAActiveUPP';
  885. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  886. {
  887. * OSASetActiveProc()
  888. *
  889. * Availability:
  890. * Mac OS X: in version 10.0 and later in Carbon.framework
  891. * CarbonLib: in CarbonLib 1.0 and later
  892. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  893. }
  894. function OSASetActiveProc( scriptingComponent: ComponentInstance; activeProc: OSAActiveUPP; refCon: SRefCon ): OSAError; external name '_OSASetActiveProc';
  895. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  896. {
  897. OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  898. If activeProc is nil, the default activeProc is used.
  899. Errors:
  900. badComponentInstance invalid scripting component instance
  901. errOSASystemError
  902. }
  903. {
  904. * OSAGetActiveProc()
  905. *
  906. * Availability:
  907. * Mac OS X: in version 10.0 and later in Carbon.framework
  908. * CarbonLib: in CarbonLib 1.0 and later
  909. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  910. }
  911. function OSAGetActiveProc( scriptingComponent: ComponentInstance; var activeProc: OSAActiveUPP; var refCon: SRefCon ): OSAError; external name '_OSAGetActiveProc';
  912. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  913. {
  914. OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  915. Errors:
  916. badComponentInstance invalid scripting component instance
  917. errOSASystemError
  918. }
  919. {*************************************************************************
  920. OSA Optional Compiling Interface
  921. **************************************************************************
  922. Scripting components that support the Compiling interface have the
  923. kOSASupportsCompiling bit set in it's ComponentDescription.
  924. *************************************************************************}
  925. {
  926. * OSAScriptingComponentName()
  927. *
  928. * Availability:
  929. * Mac OS X: in version 10.0 and later in Carbon.framework
  930. * CarbonLib: in CarbonLib 1.0 and later
  931. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  932. }
  933. function OSAScriptingComponentName( scriptingComponent: ComponentInstance; var resultingScriptingComponentName: AEDesc ): OSAError; external name '_OSAScriptingComponentName';
  934. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  935. {
  936. OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  937. Given a scripting component, this routine returns the name of that
  938. scripting component in a type that is coercable to text (typeChar).
  939. The generic scripting component returns the name of the default
  940. scripting component. This name should be sufficient to convey to the
  941. user the kind of script (syntax) he is expected to write.
  942. Errors:
  943. badComponentInstance invalid scripting component instance
  944. errOSASystemError
  945. }
  946. {
  947. * OSACompile()
  948. *
  949. * Availability:
  950. * Mac OS X: in version 10.0 and later in Carbon.framework
  951. * CarbonLib: in CarbonLib 1.0 and later
  952. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  953. }
  954. function OSACompile( scriptingComponent: ComponentInstance; const (*var*) sourceData: AEDesc; modeFlags: SInt32; var previousAndResultingScriptID: OSAID ): OSAError; external name '_OSACompile';
  955. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  956. {
  957. OSAComponentFunctionInline(kOSASelectCompile, 12);
  958. Coerces input desc (possibly text) into a script's internal format.
  959. Once compiled, the script is ready to run. The modeFlags convey
  960. scripting component specific information. The previous script ID
  961. (result parameter) is made to refer to the newly compiled script,
  962. unless it was originally kOSANullScript. In this case a new script
  963. ID is created and used.
  964. Errors:
  965. badComponentInstance invalid scripting component instance
  966. errOSASystemError
  967. errAECoercionFail: sourceData is not compilable
  968. errOSAScriptError: sourceData was a bad script (syntax error)
  969. errOSAInvalidID: previousAndResultingCompiledScriptID was not
  970. valid on input
  971. ModeFlags:
  972. kOSAModePreventGetSource
  973. kOSAModeCompileIntoContext
  974. kOSAModeAugmentContext
  975. kOSAModeNeverInteract
  976. kOSAModeCanInteract
  977. kOSAModeAlwaysInteract
  978. kOSAModeCantSwitchLayer
  979. kOSAModeDontReconnect
  980. kOSAModeDoRecord
  981. }
  982. {
  983. * OSACopyID()
  984. *
  985. * Availability:
  986. * Mac OS X: in version 10.0 and later in Carbon.framework
  987. * CarbonLib: in CarbonLib 1.0 and later
  988. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  989. }
  990. function OSACopyID( scriptingComponent: ComponentInstance; fromID: OSAID; var toID: OSAID ): OSAError; external name '_OSACopyID';
  991. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  992. {
  993. OSAComponentFunctionInline(kOSASelectCopyID, 8);
  994. If toID is a reference to kOSANullScript then it is updated to have a
  995. new scriptID value. This call can be used to perform undo or revert
  996. operations on scripts.
  997. Errors:
  998. badComponentInstance invalid scripting component instance
  999. errOSASystemError
  1000. errOSAInvalidID
  1001. }
  1002. {
  1003. * OSACopyScript()
  1004. *
  1005. * Availability:
  1006. * Mac OS X: in version 10.6 and later in Carbon.framework
  1007. * CarbonLib: not available
  1008. * Non-Carbon CFM: in AppleScriptLib 1.5 and later
  1009. }
  1010. function OSACopyScript( scriptingComponent: ComponentInstance; fromID: OSAID; var toID: OSAID ): OSAError; external name '_OSACopyScript';
  1011. (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
  1012. {
  1013. OSAComponentFunctionInline(kOSASelectCopyScript, 8);
  1014. Creates a duplicate copy of the script with the given OSAID and returns
  1015. a new OSAID for it. Can be used by script editors or debuggers.
  1016. Errors:
  1017. badComponentInstance invalid scripting component instance
  1018. errOSASystemError
  1019. errOSAInvalidID
  1020. }
  1021. {*************************************************************************
  1022. OSA Optional GetSource Interface
  1023. **************************************************************************
  1024. Scripting components that support the GetSource interface have the
  1025. kOSASupportsGetSource bit set in their ComponentDescription.
  1026. *************************************************************************}
  1027. {
  1028. * OSAGetSource()
  1029. *
  1030. * Availability:
  1031. * Mac OS X: in version 10.0 and later in Carbon.framework
  1032. * CarbonLib: in CarbonLib 1.0 and later
  1033. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1034. }
  1035. function OSAGetSource( scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; var resultingSourceData: AEDesc ): OSAError; external name '_OSAGetSource';
  1036. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1037. {
  1038. OSAComponentFunctionInline(kOSASelectGetSource, 12);
  1039. This routine causes a compiled script to be output in a form (possibly
  1040. text) such that it is suitable to be passed back to OSACompile.
  1041. Errors:
  1042. badComponentInstance invalid scripting component instance
  1043. errOSASystemError
  1044. errOSAInvalidID
  1045. errOSASourceNotAvailable can't get source for this scriptID
  1046. }
  1047. {
  1048. @function OSACopySourceString
  1049. @discussion Similar to OSAGetSource, but returns the text as a CFAttributedStringRef.
  1050. }
  1051. {
  1052. * OSACopySourceString()
  1053. *
  1054. * Availability:
  1055. * Mac OS X: in version 10.5 and later in Carbon.framework
  1056. * CarbonLib: not available
  1057. * Non-Carbon CFM: not available
  1058. }
  1059. function OSACopySourceString( scriptingComponent: ComponentInstance; scriptID: OSAID; modeFlags: SInt32; var result: CFAttributedStringRef ): OSAError; external name '_OSACopySourceString';
  1060. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  1061. {*************************************************************************
  1062. OSA Optional AECoercion Interface
  1063. **************************************************************************
  1064. Scripting components that support the AECoercion interface have the
  1065. kOSASupportsAECoercion bit set in their ComponentDescription.
  1066. *************************************************************************}
  1067. {
  1068. * OSACoerceFromDesc()
  1069. *
  1070. * Availability:
  1071. * Mac OS X: in version 10.0 and later in Carbon.framework
  1072. * CarbonLib: in CarbonLib 1.0 and later
  1073. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1074. }
  1075. function OSACoerceFromDesc( scriptingComponent: ComponentInstance; const (*var*) scriptData: AEDesc; modeFlags: SInt32; var resultingScriptID: OSAID ): OSAError; external name '_OSACoerceFromDesc';
  1076. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1077. {
  1078. OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  1079. This routine causes script data to be coerced into a script value.
  1080. If the scriptData is an AppleEvent, then the resultingScriptID is a
  1081. compiled script ID (mode flags for OSACompile may be used in this case).
  1082. Other scriptData descriptors create script value IDs.
  1083. Errors:
  1084. badComponentInstance invalid scripting component instance
  1085. errOSASystemError
  1086. ModeFlags:
  1087. kOSAModePreventGetSource
  1088. kOSAModeCompileIntoContext
  1089. kOSAModeNeverInteract
  1090. kOSAModeCanInteract
  1091. kOSAModeAlwaysInteract
  1092. kOSAModeCantSwitchLayer
  1093. kOSAModeDontReconnect
  1094. kOSAModeDoRecord
  1095. }
  1096. {
  1097. * OSACoerceToDesc()
  1098. *
  1099. * Availability:
  1100. * Mac OS X: in version 10.0 and later in Carbon.framework
  1101. * CarbonLib: in CarbonLib 1.0 and later
  1102. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1103. }
  1104. function OSACoerceToDesc( scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: SInt32; var result: AEDesc ): OSAError; external name '_OSACoerceToDesc';
  1105. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1106. {
  1107. OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  1108. This routine causes a script value to be coerced into any desired form.
  1109. If the scriptID denotes a compiled script, then it may be coerced to
  1110. typeAppleEvent.
  1111. Errors:
  1112. badComponentInstance invalid scripting component instance
  1113. errOSASystemError
  1114. errOSAInvalidID
  1115. }
  1116. {*************************************************************************
  1117. OSA Optional AESending Interface
  1118. **************************************************************************
  1119. Scripting components that support the AESending interface have the
  1120. kOSASupportsAESending bit set in their ComponentDescription.
  1121. *************************************************************************}
  1122. {
  1123. Scripting systems will supply default values for these procedures if they
  1124. are not set by the client:
  1125. }
  1126. {
  1127. * OSASetSendProc()
  1128. *
  1129. * Availability:
  1130. * Mac OS X: in version 10.0 and later in Carbon.framework
  1131. * CarbonLib: in CarbonLib 1.0 and later
  1132. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1133. }
  1134. function OSASetSendProc( scriptingComponent: ComponentInstance; sendProc: OSASendUPP; refCon: SRefCon ): OSAError; external name '_OSASetSendProc';
  1135. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1136. {
  1137. OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1138. If sendProc is nil, the default sendProc is used.
  1139. Errors:
  1140. badComponentInstance invalid scripting component instance
  1141. errOSASystemError
  1142. }
  1143. {
  1144. * OSAGetSendProc()
  1145. *
  1146. * Availability:
  1147. * Mac OS X: in version 10.0 and later in Carbon.framework
  1148. * CarbonLib: in CarbonLib 1.0 and later
  1149. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1150. }
  1151. function OSAGetSendProc( scriptingComponent: ComponentInstance; var sendProc: OSASendUPP; var refCon: SRefCon ): OSAError; external name '_OSAGetSendProc';
  1152. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1153. {
  1154. OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1155. Errors:
  1156. badComponentInstance invalid scripting component instance
  1157. errOSASystemError
  1158. }
  1159. {
  1160. * OSASetCreateProc()
  1161. *
  1162. * Availability:
  1163. * Mac OS X: in version 10.0 and later in Carbon.framework
  1164. * CarbonLib: in CarbonLib 1.0 and later
  1165. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1166. }
  1167. function OSASetCreateProc( scriptingComponent: ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: SRefCon ): OSAError; external name '_OSASetCreateProc';
  1168. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1169. {
  1170. OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1171. If createProc is nil, the default createProc is used.
  1172. Errors:
  1173. badComponentInstance invalid scripting component instance
  1174. errOSASystemError
  1175. }
  1176. {
  1177. * OSAGetCreateProc()
  1178. *
  1179. * Availability:
  1180. * Mac OS X: in version 10.0 and later in Carbon.framework
  1181. * CarbonLib: in CarbonLib 1.0 and later
  1182. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1183. }
  1184. function OSAGetCreateProc( scriptingComponent: ComponentInstance; var createProc: OSACreateAppleEventUPP; var refCon: SRefCon ): OSAError; external name '_OSAGetCreateProc';
  1185. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1186. {
  1187. OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1188. Errors:
  1189. badComponentInstance invalid scripting component instance
  1190. errOSASystemError
  1191. }
  1192. {
  1193. * OSASetDefaultTarget()
  1194. *
  1195. * Availability:
  1196. * Mac OS X: in version 10.0 and later in Carbon.framework
  1197. * CarbonLib: in CarbonLib 1.0 and later
  1198. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1199. }
  1200. function OSASetDefaultTarget( scriptingComponent: ComponentInstance; const (*var*) target: AEAddressDesc ): OSAError; external name '_OSASetDefaultTarget';
  1201. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1202. {
  1203. OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1204. This routine sets the default target application for AE sending.
  1205. It also establishes the default target from which terminologies come.
  1206. It is effectively like having an AppleScript "tell" statement around
  1207. the entire program. If this routine is not called, or if the target
  1208. is a null AEDesc, then the current application is the default target.
  1209. Errors:
  1210. badComponentInstance invalid scripting component instance
  1211. errOSASystemError
  1212. }
  1213. {*************************************************************************
  1214. OSA Optional Recording Interface
  1215. **************************************************************************
  1216. Scripting components that support the Recording interface have the
  1217. kOSASupportsRecording bit set in their ComponentDescription.
  1218. *************************************************************************}
  1219. {
  1220. * OSAStartRecording()
  1221. *
  1222. * Availability:
  1223. * Mac OS X: in version 10.0 and later in Carbon.framework
  1224. * CarbonLib: in CarbonLib 1.0 and later
  1225. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1226. }
  1227. function OSAStartRecording( scriptingComponent: ComponentInstance; var compiledScriptToModifyID: OSAID ): OSAError; external name '_OSAStartRecording';
  1228. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1229. {
  1230. OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1231. Starts recording. If compiledScriptToModifyID is kOSANullScript, a
  1232. new script ID is created and returned. If the current application has
  1233. a handler for the kOSARecordedText event, then kOSARecordedText events
  1234. are sent to the application containing the text of each AppleEvent
  1235. recorded.
  1236. Errors:
  1237. badComponentInstance invalid scripting component instance
  1238. errOSASystemError
  1239. errOSAInvalidID
  1240. errOSARecordingIsAlreadyOn
  1241. }
  1242. {
  1243. * OSAStopRecording()
  1244. *
  1245. * Availability:
  1246. * Mac OS X: in version 10.0 and later in Carbon.framework
  1247. * CarbonLib: in CarbonLib 1.0 and later
  1248. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1249. }
  1250. function OSAStopRecording( scriptingComponent: ComponentInstance; compiledScriptID: OSAID ): OSAError; external name '_OSAStopRecording';
  1251. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1252. {
  1253. OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1254. If compiledScriptID is not being recorded into or recording is not
  1255. currently on, no error is returned.
  1256. Errors:
  1257. badComponentInstance invalid scripting component instance
  1258. errOSASystemError
  1259. errOSAInvalidID
  1260. }
  1261. {*************************************************************************
  1262. OSA Optional Convenience Interface
  1263. **************************************************************************
  1264. Scripting components that support the Convenience interface have the
  1265. kOSASupportsConvenience bit set in their ComponentDescription.
  1266. *************************************************************************}
  1267. {
  1268. * OSALoadExecute()
  1269. *
  1270. * Availability:
  1271. * Mac OS X: in version 10.0 and later in Carbon.framework
  1272. * CarbonLib: in CarbonLib 1.0 and later
  1273. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1274. }
  1275. function OSALoadExecute( scriptingComponent: ComponentInstance; const (*var*) scriptData: AEDesc; contextID: OSAID; modeFlags: SInt32; var resultingScriptValueID: OSAID ): OSAError; external name '_OSALoadExecute';
  1276. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1277. {
  1278. OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1279. This routine is effectively equivalent to calling OSALoad followed by
  1280. OSAExecute. After execution, the compiled source is disposed. Only the
  1281. resulting value ID is retained.
  1282. Errors:
  1283. badComponentInstance invalid scripting component instance
  1284. errOSASystemError
  1285. errOSABadStorageType: scriptData not for this scripting component
  1286. errOSACorruptData: data seems to be corrupt
  1287. errOSADataFormatObsolete script data format is no longer supported
  1288. errOSADataFormatTooNew script data format is from a newer version
  1289. errOSAInvalidID
  1290. errOSAScriptError: the executing script got an error
  1291. ModeFlags:
  1292. kOSAModeNeverInteract
  1293. kOSAModeCanInteract
  1294. kOSAModeAlwaysInteract
  1295. kOSAModeCantSwitchLayer
  1296. kOSAModeDontReconnect
  1297. kOSAModeDoRecord
  1298. }
  1299. {
  1300. * OSACompileExecute()
  1301. *
  1302. * Availability:
  1303. * Mac OS X: in version 10.0 and later in Carbon.framework
  1304. * CarbonLib: in CarbonLib 1.0 and later
  1305. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1306. }
  1307. function OSACompileExecute( scriptingComponent: ComponentInstance; const (*var*) sourceData: AEDesc; contextID: OSAID; modeFlags: SInt32; var resultingScriptValueID: OSAID ): OSAError; external name '_OSACompileExecute';
  1308. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1309. {
  1310. OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1311. This routine is effectively equivalent to calling OSACompile followed by
  1312. OSAExecute. After execution, the compiled source is disposed. Only the
  1313. resulting value ID is retained.
  1314. Errors:
  1315. badComponentInstance invalid scripting component instance
  1316. errOSASystemError
  1317. errAECoercionFail: sourceData is not compilable
  1318. errOSAScriptError: sourceData was a bad script (syntax error)
  1319. errOSAInvalidID: previousAndResultingCompiledScriptID was not
  1320. valid on input
  1321. errOSAScriptError: the executing script got an error
  1322. ModeFlags:
  1323. kOSAModeNeverInteract
  1324. kOSAModeCanInteract
  1325. kOSAModeAlwaysInteract
  1326. kOSAModeCantSwitchLayer
  1327. kOSAModeDontReconnect
  1328. kOSAModeDoRecord
  1329. }
  1330. {
  1331. * OSADoScript()
  1332. *
  1333. * Availability:
  1334. * Mac OS X: in version 10.0 and later in Carbon.framework
  1335. * CarbonLib: in CarbonLib 1.0 and later
  1336. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1337. }
  1338. function OSADoScript( scriptingComponent: ComponentInstance; const (*var*) sourceData: AEDesc; contextID: OSAID; desiredType: DescType; modeFlags: SInt32; var resultingText: AEDesc ): OSAError; external name '_OSADoScript';
  1339. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1340. {
  1341. OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1342. This routine is effectively equivalent to calling OSACompile followed by
  1343. OSAExecute and then OSADisplay. After execution, the compiled source
  1344. and the resulting value are is disposed. Only the resultingText
  1345. descriptor is retained. If a script error occur during processing, the
  1346. resultingText gets the error message of the error, and errOSAScriptError
  1347. is returned. OSAScriptError may still be used to extract more
  1348. information about the particular error.
  1349. Errors:
  1350. badComponentInstance invalid scripting component instance
  1351. errOSASystemError
  1352. errAECoercionFail: sourceData is not compilable or
  1353. desiredType not supported by scripting component
  1354. errOSAScriptError: sourceData was a bad script (syntax error)
  1355. errOSAInvalidID: previousAndResultingCompiledScriptID was not
  1356. valid on input
  1357. errOSAScriptError: the executing script got an error
  1358. ModeFlags:
  1359. kOSAModeNeverInteract
  1360. kOSAModeCanInteract
  1361. kOSAModeAlwaysInteract
  1362. kOSAModeCantSwitchLayer
  1363. kOSAModeDontReconnect
  1364. kOSAModeDoRecord
  1365. kOSAModeDisplayForHumans
  1366. }
  1367. {*************************************************************************
  1368. OSA Optional Dialects Interface
  1369. **************************************************************************
  1370. Scripting components that support the Dialects interface have the
  1371. kOSASupportsDialects bit set in their ComponentDescription.
  1372. *************************************************************************}
  1373. {
  1374. These calls allows an scripting component that supports different dialects
  1375. to dynamically switch between those dialects. Although this interface is
  1376. specified, the particular dialect codes are scripting component dependent.
  1377. }
  1378. {
  1379. * OSASetCurrentDialect()
  1380. *
  1381. * Availability:
  1382. * Mac OS X: in version 10.0 and later in Carbon.framework
  1383. * CarbonLib: in CarbonLib 1.0 and later
  1384. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1385. }
  1386. function OSASetCurrentDialect( scriptingComponent: ComponentInstance; dialectCode: SInt16 ): OSAError; external name '_OSASetCurrentDialect';
  1387. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1388. {
  1389. OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1390. Errors:
  1391. badComponentInstance invalid scripting component instance
  1392. errOSASystemError
  1393. errOSANoSuchDialect: invalid dialectCode
  1394. }
  1395. {
  1396. * OSAGetCurrentDialect()
  1397. *
  1398. * Availability:
  1399. * Mac OS X: in version 10.0 and later in Carbon.framework
  1400. * CarbonLib: in CarbonLib 1.0 and later
  1401. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1402. }
  1403. function OSAGetCurrentDialect( scriptingComponent: ComponentInstance; var resultingDialectCode: SInt16 ): OSAError; external name '_OSAGetCurrentDialect';
  1404. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1405. {
  1406. OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1407. Errors:
  1408. badComponentInstance invalid scripting component instance
  1409. errOSASystemError
  1410. }
  1411. {
  1412. * OSAAvailableDialects()
  1413. *
  1414. * Availability:
  1415. * Mac OS X: in version 10.0 and later in Carbon.framework
  1416. * CarbonLib: in CarbonLib 1.0 and later
  1417. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1418. }
  1419. function OSAAvailableDialects( scriptingComponent: ComponentInstance; var resultingDialectInfoList: AEDesc ): OSAError; external name '_OSAAvailableDialects';
  1420. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1421. {
  1422. OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1423. This call return an AEList containing information about each of the
  1424. currently available dialects of a scripting component. Each item
  1425. is an AERecord of typeOSADialectInfo that contains at least the fields
  1426. keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and
  1427. keyOSADialectScriptCode.
  1428. Errors:
  1429. badComponentInstance invalid scripting component instance
  1430. errOSASystemError
  1431. }
  1432. {
  1433. * OSAGetDialectInfo()
  1434. *
  1435. * Availability:
  1436. * Mac OS X: in version 10.0 and later in Carbon.framework
  1437. * CarbonLib: in CarbonLib 1.0 and later
  1438. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1439. }
  1440. function OSAGetDialectInfo( scriptingComponent: ComponentInstance; dialectCode: SInt16; selector: OSType; var resultingDialectInfo: AEDesc ): OSAError; external name '_OSAGetDialectInfo';
  1441. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1442. {
  1443. OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1444. This call gives information about the specified dialect of a scripting
  1445. component. It returns an AEDesc whose type depends on the selector
  1446. specified. Available selectors are the same as the field keys for a
  1447. dialect info record. The type of AEDesc returned is the same as the
  1448. type of the field that has same key as the selector.
  1449. Errors:
  1450. badComponentInstance invalid scripting component instance
  1451. errOSASystemError
  1452. errOSABadSelector
  1453. errOSANoSuchDialect: invalid dialectCode
  1454. }
  1455. {
  1456. * OSAAvailableDialectCodeList()
  1457. *
  1458. * Availability:
  1459. * Mac OS X: in version 10.0 and later in Carbon.framework
  1460. * CarbonLib: in CarbonLib 1.0 and later
  1461. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1462. }
  1463. function OSAAvailableDialectCodeList( scriptingComponent: ComponentInstance; var resultingDialectCodeList: AEDesc ): OSAError; external name '_OSAAvailableDialectCodeList';
  1464. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1465. {
  1466. OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1467. This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1468. and OSAGetDialectInfo to get information on dialects.
  1469. This call return an AEList containing dialect code for each of the
  1470. currently available dialects of a scripting component. Each dialect
  1471. code is a short integer of type typeSInt16.
  1472. Errors:
  1473. badComponentInstance invalid scripting component instance
  1474. errOSASystemError
  1475. Type of a dialect info record containing at least keyOSADialectName
  1476. and keyOSADialectCode fields.
  1477. keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1478. Field of a typeOSADialectInfo record of typeChar.
  1479. Field of a typeOSADialectInfo record of typeSInt16.
  1480. Field of a typeOSADialectInfo record of typeSInt16.
  1481. Field of a typeOSADialectInfo record of typeSInt16.
  1482. }
  1483. {*************************************************************************
  1484. OSA Optional Event Handling Interface
  1485. **************************************************************************
  1486. Scripting components that support the Event Handling interface have the
  1487. kOSASupportsEventHandling bit set in their ComponentDescription.
  1488. *************************************************************************}
  1489. {
  1490. * OSASetResumeDispatchProc()
  1491. *
  1492. * Availability:
  1493. * Mac OS X: in version 10.0 and later in Carbon.framework
  1494. * CarbonLib: in CarbonLib 1.0 and later
  1495. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1496. }
  1497. function OSASetResumeDispatchProc( scriptingComponent: ComponentInstance; resumeDispatchProc: AEEventHandlerUPP; refCon: SRefCon ): OSAError; external name '_OSASetResumeDispatchProc';
  1498. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1499. {
  1500. OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1501. This function is used to set the ResumeDispatchProc that will be used
  1502. by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1503. found in the context, or the context event hander "continues" control
  1504. onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1505. may also be passed to this routine indicating that the handler registered
  1506. in the application with AEInstallEventHandler should be used, or no
  1507. dispatch should occur, respectively.
  1508. Errors:
  1509. badComponentInstance invalid scripting component instance
  1510. errOSASystemError
  1511. }
  1512. const
  1513. kOSAUseStandardDispatch = kAEUseStandardDispatch;
  1514. {
  1515. Special ResumeDispatchProc constant which may be passed to
  1516. OSASetResumeDispatchProc indicating that the handler registered
  1517. in the application with AEInstallEventHandler should be used.
  1518. NOTE: Had to remove the cast (AEEventHandlerUPP). The C compiler
  1519. doesn't allow pointer types to be assigned to an enum. All
  1520. constants must be assigned as enums to translate properly to
  1521. Pascal.
  1522. }
  1523. const
  1524. kOSANoDispatch = kAENoDispatch;
  1525. {
  1526. Special ResumeDispatchProc constant which may be passed to
  1527. OSASetResumeDispatchProc indicating that no dispatch should occur.
  1528. NOTE: Had to remove the cast (AEEventHandlerUPP). The C compiler
  1529. doesn't allow pointer types to be assigned to an enum. All
  1530. constants must be assigned as enums to translate properly to
  1531. Pascal.
  1532. }
  1533. const
  1534. kOSADontUsePhac = $0001;
  1535. {
  1536. Special refCon constant that may be given to OSASetResumeDispatchProc
  1537. only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1538. This causes the standard dispatch to be performed, except the phac
  1539. handler is not called. This is useful during tinkerability, when
  1540. the phac handler is used to lookup a context associated with an event's
  1541. direct parameter, and call OSAExecuteEvent or OSADoEvent. Failure to
  1542. bypass the phac handler would result in an infinite loop.
  1543. }
  1544. {
  1545. * OSAGetResumeDispatchProc()
  1546. *
  1547. * Availability:
  1548. * Mac OS X: in version 10.0 and later in Carbon.framework
  1549. * CarbonLib: in CarbonLib 1.0 and later
  1550. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1551. }
  1552. function OSAGetResumeDispatchProc( scriptingComponent: ComponentInstance; var resumeDispatchProc: AEEventHandlerUPP; var refCon: SRefCon ): OSAError; external name '_OSAGetResumeDispatchProc';
  1553. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1554. {
  1555. OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1556. Returns the registered ResumeDispatchProc. If no ResumeDispatchProc has
  1557. been registered, then kOSAUseStandardDispatch (the default) is returned.
  1558. Errors:
  1559. badComponentInstance invalid scripting component instance
  1560. errOSASystemError
  1561. }
  1562. {
  1563. * OSAExecuteEvent()
  1564. *
  1565. * Availability:
  1566. * Mac OS X: in version 10.0 and later in Carbon.framework
  1567. * CarbonLib: in CarbonLib 1.0 and later
  1568. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1569. }
  1570. function OSAExecuteEvent( scriptingComponent: ComponentInstance; const (*var*) theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: SInt32; var resultingScriptValueID: OSAID ): OSAError; external name '_OSAExecuteEvent';
  1571. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1572. {
  1573. OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1574. This call is similar to OSAExecute except the initial command to
  1575. execute comes in the form of an AppleEvent. If the contextID
  1576. defines any event handlers for that event, they are used to process
  1577. the event. If no event handler can be found in the context
  1578. errAEEventNotHandled is returned. If an event handler is found and
  1579. the hander "continues" control onward, the ResumeDispatchProc
  1580. (registered with OSASetResumeDispatchProc, above) is called given the
  1581. AppleEvent. The result is returned as a scriptValueID.
  1582. Errors:
  1583. badComponentInstance invalid scripting component instance
  1584. errOSASystemError
  1585. errOSAInvalidID
  1586. errOSAScriptError: the executing script got an error
  1587. errAEEventNotHandled: no handler for event in contextID
  1588. ModeFlags:
  1589. kOSAModeNeverInteract
  1590. kOSAModeCanInteract
  1591. kOSAModeAlwaysInteract
  1592. kOSAModeCantSwitchLayer
  1593. kOSAModeDontReconnect
  1594. kOSAModeDoRecord
  1595. }
  1596. {
  1597. * OSADoEvent()
  1598. *
  1599. * Availability:
  1600. * Mac OS X: in version 10.0 and later in Carbon.framework
  1601. * CarbonLib: in CarbonLib 1.0 and later
  1602. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1603. }
  1604. function OSADoEvent( scriptingComponent: ComponentInstance; const (*var*) theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: SInt32; var reply: AppleEvent ): OSAError; external name '_OSADoEvent';
  1605. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1606. {
  1607. OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1608. This call is similar to OSADoScript except the initial command to
  1609. execute comes in the form of an AppleEvent, and the result is an
  1610. AppleEvent reply record. If the contextID defines any event handlers
  1611. for that event, they are used to process the event. If no event handler
  1612. can be found in the context errAEEventNotHandled is returned. If an
  1613. event handler is found and the hander "continues" control onward, the
  1614. ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1615. called given the AppleEvent. The result is returned in the form of an
  1616. AppleEvent reply descriptor. If at any time the script gets an error, or
  1617. if the ResumeDispatchProc returns a reply event indicating an error,
  1618. then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1619. should never return errOSAScriptError). Any error result returned by
  1620. the ResumeDispatchProc will be returned by OSADoEvent.
  1621. Errors:
  1622. badComponentInstance invalid scripting component instance
  1623. errOSASystemError
  1624. errOSAInvalidID
  1625. errAEEventNotHandled: no handler for event in contextID
  1626. ModeFlags:
  1627. kOSAModeNeverInteract
  1628. kOSAModeCanInteract
  1629. kOSAModeAlwaysInteract
  1630. kOSAModeCantSwitchLayer
  1631. kOSAModeDontReconnect
  1632. kOSAModeDoRecord
  1633. }
  1634. {
  1635. * OSAMakeContext()
  1636. *
  1637. * Availability:
  1638. * Mac OS X: in version 10.0 and later in Carbon.framework
  1639. * CarbonLib: in CarbonLib 1.0 and later
  1640. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  1641. }
  1642. function OSAMakeContext( scriptingComponent: ComponentInstance; const (*var*) contextName: AEDesc; parentContext: OSAID; var resultingContextID: OSAID ): OSAError; external name '_OSAMakeContext';
  1643. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  1644. {
  1645. OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1646. Makes a new empty context which may be passed to OSAExecute or
  1647. OSAExecuteEvent. If contextName is typeNull, an unnamed context is
  1648. created. If parentContext is kOSANullScript then the resulting context
  1649. does not inherit bindings from any other context.
  1650. Errors:
  1651. badComponentInstance invalid scripting component instance
  1652. errOSASystemError
  1653. errOSAInvalidID
  1654. errAECoercionFail: contextName is invalid
  1655. }
  1656. {*************************************************************************
  1657. OSA Script File Interface
  1658. *************************************************************************}
  1659. {
  1660. * OSAGetScriptDataFromURL()
  1661. *
  1662. * Availability:
  1663. * Mac OS X: in version 10.6 and later in Carbon.framework
  1664. * CarbonLib: not available
  1665. * Non-Carbon CFM: not available
  1666. }
  1667. function OSAGetScriptDataFromURL( scriptURL: CFURLRef; storable: BooleanPtr { can be NULL }; modeFlags: SInt32; var resultingScriptData: AEDesc ): OSAError; external name '_OSAGetScriptDataFromURL';
  1668. (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
  1669. {
  1670. This routine reads script data from a URL into a descriptor. The
  1671. URL may refer to a compiled script, script application, or source
  1672. text file. If "scriptURL" refers to a text file, the resulting data
  1673. is the source text. If "storable" is non-NULL, it will be set to
  1674. indicate whether a script can be stored into the script file using
  1675. OSAStoreFile().
  1676. You may use OSALoadScriptData() with the resulting descriptor to
  1677. load the script into a component instance. Doing this in two steps
  1678. affords the opportunity to examine the script data with
  1679. OSAGetStorageType() and select a component instance.
  1680. Errors:
  1681. errOSASystemError
  1682. File system errors.
  1683. ModeFlags:
  1684. No mode flags are supported at this time.
  1685. }
  1686. {
  1687. * OSALoadScriptData()
  1688. *
  1689. * Availability:
  1690. * Mac OS X: in version 10.6 and later in Carbon.framework
  1691. * CarbonLib: not available
  1692. * Non-Carbon CFM: not available
  1693. }
  1694. function OSALoadScriptData( scriptingComponent: ComponentInstance; const (*var*) scriptData: AEDesc; fromURL: CFURLRef { can be NULL }; modeFlags: SInt32; var resultingScriptID: OSAID ): OSAError; external name '_OSALoadScriptData';
  1695. (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
  1696. {
  1697. This routine loads script data from a descriptor into the specified
  1698. scripting component. If "scriptData" is source, it will be compiled.
  1699. If "fromURL" is non-NULL, it indicates the file from which the data
  1700. was read.
  1701. Errors:
  1702. See OSALoad() and OSACompile().
  1703. ModeFlags:
  1704. See OSALoad() and OSACompile().
  1705. }
  1706. {
  1707. * OSALoadFile()
  1708. *
  1709. * Availability:
  1710. * Mac OS X: in version 10.3 and later in Carbon.framework
  1711. * CarbonLib: not available
  1712. * Non-Carbon CFM: not available
  1713. }
  1714. function OSALoadFile( scriptingComponent: ComponentInstance; const (*var*) scriptFile: FSRef; storable: BooleanPtr { can be NULL }; modeFlags: SInt32; var resultingScriptID: OSAID ): OSAError; external name '_OSALoadFile';
  1715. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  1716. {
  1717. This routine loads a script into the specified scripting component.
  1718. If "scriptFile" is a text file, the script will be compiled. If
  1719. "storable" is non-NULL, it will be set to indicate whether a
  1720. script can be stored into the script file using OSAStoreFile().
  1721. Errors:
  1722. See OSALoad() and OSACompile().
  1723. ModeFlags:
  1724. See OSALoad() and OSACompile().
  1725. }
  1726. {
  1727. * OSAStoreFile()
  1728. *
  1729. * Availability:
  1730. * Mac OS X: in version 10.3 and later in Carbon.framework
  1731. * CarbonLib: not available
  1732. * Non-Carbon CFM: not available
  1733. }
  1734. function OSAStoreFile( scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: SInt32; const (*var*) scriptFile: FSRef ): OSAError; external name '_OSAStoreFile';
  1735. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  1736. {
  1737. This routine stores a script into the specified file.
  1738. Errors:
  1739. See OSAStore().
  1740. ModeFlags:
  1741. See OSAStore().
  1742. }
  1743. {
  1744. * OSALoadExecuteFile()
  1745. *
  1746. * Availability:
  1747. * Mac OS X: in version 10.3 and later in Carbon.framework
  1748. * CarbonLib: not available
  1749. * Non-Carbon CFM: not available
  1750. }
  1751. function OSALoadExecuteFile( scriptingComponent: ComponentInstance; const (*var*) scriptFile: FSRef; contextID: OSAID; modeFlags: SInt32; var resultingScriptValueID: OSAID ): OSAError; external name '_OSALoadExecuteFile';
  1752. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  1753. {
  1754. This routine is effectively equivalent to calling OSALoadFile followed by
  1755. OSAExecute. After execution, the compiled source is disposed. Only the
  1756. resulting value ID is retained.
  1757. Errors:
  1758. See OSALoadExecute() and OSACompileExecute().
  1759. ModeFlags:
  1760. See OSALoadExecute() and OSACompileExecute().
  1761. }
  1762. {
  1763. * OSADoScriptFile()
  1764. *
  1765. * Availability:
  1766. * Mac OS X: in version 10.3 and later in Carbon.framework
  1767. * CarbonLib: not available
  1768. * Non-Carbon CFM: not available
  1769. }
  1770. function OSADoScriptFile( scriptingComponent: ComponentInstance; const (*var*) scriptFile: FSRef; contextID: OSAID; desiredType: DescType; modeFlags: SInt32; var resultingText: AEDesc ): OSAError; external name '_OSADoScriptFile';
  1771. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  1772. {
  1773. This routine is effectively equivalent to calling OSALoadFile, followed by
  1774. OSAExecute, OSADisplay, and then OSAStoreFile if the script has persistent
  1775. properties. After execution, the compiled source and the resulting value are
  1776. disposed. Only the resultingText descriptor is retained. If a script error
  1777. occurs during processing, the resultingText gets the error message of the error,
  1778. and errOSAScriptError is returned. OSAScriptError may still be used to extract
  1779. more information about the particular error.
  1780. Errors:
  1781. See OSALoad(), OSACompile(), OSAExecute(), OSADisplay(), and OSAStore().
  1782. ModeFlags:
  1783. See OSALoad(), OSACompile(), OSAExecute(), and OSADisplay().
  1784. }
  1785. {$endc} {TARGET_OS_MAC}
  1786. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  1787. end.
  1788. {$endc} {not MACOSALLINCLUDE}