AppleScript.pas 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. {
  2. File: AppleScript.p
  3. Contains: AppleScript Specific Interfaces.
  4. Version: Technology: AppleScript 1.1
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1992-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. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit AppleScript;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,AEDataModel,Components,MacErrors,AppleEvents,OSA,TextEdit;
  92. {$ALIGN MAC68K}
  93. {*************************************************************************
  94. Types and Constants
  95. *************************************************************************}
  96. {
  97. The specific type for the AppleScript instance of the
  98. Open Scripting Architecture type.
  99. }
  100. const
  101. typeAppleScript = $61736372 (* 'ascr' *);
  102. kAppleScriptSubtype = $61736372 (* 'ascr' *);
  103. typeASStorage = $61736372 (* 'ascr' *);
  104. { *************************************************************************
  105. Component Selectors
  106. ************************************************************************* }
  107. kASSelectInit = $1001;
  108. kASSelectSetSourceStyles = $1002;
  109. kASSelectGetSourceStyles = $1003;
  110. kASSelectGetSourceStyleNames = $1004;
  111. { *************************************************************************
  112. OSAGetScriptInfo Selectors
  113. ************************************************************************* }
  114. kASHasOpenHandler = $68736F64 (* 'hsod' *);
  115. {
  116. This selector is used to query a context as to whether it contains
  117. a handler for the kAEOpenDocuments event. This allows "applets" to be
  118. distinguished from "droplets." OSAGetScriptInfo returns false if
  119. there is no kAEOpenDocuments handler, and returns the error value
  120. errOSAInvalidAccess if the input is not a context.
  121. }
  122. { *************************************************************************
  123. Initialization
  124. ************************************************************************* }
  125. {
  126. * ASInit()
  127. *
  128. * Availability:
  129. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  130. * CarbonLib: in CarbonLib 1.0 and later
  131. * Mac OS X: in version 10.0 and later
  132. }
  133. function ASInit(scriptingComponent: ComponentInstance; modeFlags: SInt32; minStackSize: SInt32; preferredStackSize: SInt32; maxStackSize: SInt32; minHeapSize: SInt32; preferredHeapSize: SInt32; maxHeapSize: SInt32): OSAError; external name '_ASInit';
  134. {
  135. ComponentCallNow(kASSelectInit, 28);
  136. This call can be used to explicitly initialize AppleScript. If it is
  137. not called, the a scripting size resource is looked for and used. If
  138. there is no scripting size resource, then the constants listed below
  139. are used. If at any stage (the init call, the size resource, the
  140. defaults) any of these parameters are zero, then parameters from the
  141. next stage are used. ModeFlags are not currently used.
  142. Errors:
  143. errOSASystemError initialization failed
  144. }
  145. {
  146. These values will be used if ASInit is not called explicitly, or if any
  147. of ASInit's parameters are zero:
  148. }
  149. const
  150. kASDefaultMinStackSize = 4096;
  151. kASDefaultPreferredStackSize = 16384;
  152. kASDefaultMaxStackSize = 16384;
  153. kASDefaultMinHeapSize = 4096;
  154. kASDefaultPreferredHeapSize = 16384;
  155. kASDefaultMaxHeapSize = 33554432;
  156. { *************************************************************************
  157. Source Styles
  158. ************************************************************************* }
  159. {
  160. * ASSetSourceStyles()
  161. *
  162. * Availability:
  163. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  164. * CarbonLib: in CarbonLib 1.0 and later
  165. * Mac OS X: in version 10.0 and later
  166. }
  167. function ASSetSourceStyles(scriptingComponent: ComponentInstance; sourceStyles: STHandle): OSAError; external name '_ASSetSourceStyles';
  168. {
  169. ComponentCallNow(kASSelectSetSourceStyles, 4);
  170. Errors:
  171. errOSASystemError operation failed
  172. }
  173. {
  174. * ASGetSourceStyles()
  175. *
  176. * Availability:
  177. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  178. * CarbonLib: in CarbonLib 1.0 and later
  179. * Mac OS X: in version 10.0 and later
  180. }
  181. function ASGetSourceStyles(scriptingComponent: ComponentInstance; var resultingSourceStyles: STHandle): OSAError; external name '_ASGetSourceStyles';
  182. {
  183. ComponentCallNow(kASSelectGetSourceStyles, 4);
  184. Errors:
  185. errOSASystemError operation failed
  186. }
  187. {
  188. * ASGetSourceStyleNames()
  189. *
  190. * Availability:
  191. * Non-Carbon CFM: in AppleScriptLib 1.1 and later
  192. * CarbonLib: in CarbonLib 1.0 and later
  193. * Mac OS X: in version 10.0 and later
  194. }
  195. function ASGetSourceStyleNames(scriptingComponent: ComponentInstance; modeFlags: SInt32; var resultingSourceStyleNamesList: AEDescList): OSAError; external name '_ASGetSourceStyleNames';
  196. {
  197. ComponentCallNow(kASSelectGetSourceStyleNames, 8);
  198. This call returns an AEList of styled text descriptors the names of the
  199. source styles in the current dialect. The order of the names corresponds
  200. to the order of the source style constants, below. The style of each
  201. name is the same as the styles returned by ASGetSourceStyles.
  202. Errors:
  203. errOSASystemError operation failed
  204. }
  205. {
  206. Elements of STHandle correspond to following categories of tokens, and
  207. accessed through following index constants:
  208. }
  209. const
  210. kASSourceStyleUncompiledText = 0;
  211. kASSourceStyleNormalText = 1;
  212. kASSourceStyleLanguageKeyword = 2;
  213. kASSourceStyleApplicationKeyword = 3;
  214. kASSourceStyleComment = 4;
  215. kASSourceStyleLiteral = 5;
  216. kASSourceStyleUserSymbol = 6;
  217. kASSourceStyleObjectSpecifier = 7;
  218. kASNumberOfSourceStyles = 8;
  219. {$ALIGN MAC68K}
  220. end.