home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / Mac / OSA.xs < prev    next >
Text File  |  1998-04-05  |  25KB  |  721 lines

  1. /* $Header: /home/neeri/MacCVS/MacPerl/perl/ext/Mac/OSA/OSA.xs,v 1.2 1997/11/18 00:53:06 neeri Exp $
  2.  *
  3.  *    Copyright (c) 1996 Matthias Neeracher
  4.  *
  5.  *    You may distribute under the terms of the Perl Artistic License,
  6.  *    as specified in the README file.
  7.  *
  8.  * $Log: OSA.xs,v $
  9.  * Revision 1.2  1997/11/18 00:53:06  neeri
  10.  * MacPerl 5.1.5
  11.  *
  12.  * Revision 1.1  1997/04/07 20:50:21  neeri
  13.  * Synchronized with MacPerl 5.1.4a1
  14.  *
  15.  */
  16.  
  17. #define MAC_CONTEXT
  18.  
  19. #include "EXTERN.h"
  20. #include "perl.h"
  21. #include "XSUB.h"
  22. #include <Types.h>
  23. #include <Memory.h>
  24. #include <OSA.h>
  25. #include <OSAGeneric.h>
  26.  
  27. MODULE = Mac::OSA   PACKAGE = Mac::OSA
  28.  
  29. =head2 Functions
  30.  
  31. =over 4
  32.  
  33. =item OSALoad SCRIPTINGCOMPONENT, SCRIPTDATA, MODEFLAGS
  34.  
  35. The OSALoad function loads script data and returns a script ID. The generic
  36. scripting component uses the descriptor record in the SCRIPTDATA parameter to
  37. determine which scripting component should load the script. If the descriptor
  38. record is of type typeOSAGenericStorage, the generic scripting component uses the
  39. trailer at the end of the SCRIPTDATA to identify the scripting component. If the
  40. descriptor record's type is the subtype value for another scripting component,
  41. the generic scripting component uses the descriptor type to identify the
  42. scripting component.
  43. Return C<undef> if an error was detected.
  44.  
  45. =cut
  46. OSAID
  47. OSALoad(scriptingComponent, scriptData, modeFlags)
  48.     ComponentInstance scriptingComponent
  49.     AEDesc              scriptData
  50.     long                    modeFlags
  51.     CODE:
  52.     if (gLastMacOSErr = (short) OSALoad(scriptingComponent, &scriptData, modeFlags, &RETVAL)) {
  53.         XSRETURN_UNDEF;
  54.     }
  55.     OUTPUT:
  56.     RETVAL
  57.  
  58. =item OSAStore SCRIPTINGCOMPONENT, SCRIPTID, DESIREDTYPE, MODEFLAGS
  59.  
  60. The OSAStore function returns script data in a descriptor record so that the data
  61. can later be saved in a resource or written to the data fork of a document. You
  62. can then reload the data for the descriptor record as a compiled script (although
  63. possibly with a different script ID) by passing the descriptor record to OSALoad().
  64. Return C<undef> if an error was detected.
  65.  
  66. =cut
  67. AEDesc
  68. OSAStore(scriptingComponent, scriptID, desiredType, modeFlags)
  69.     ComponentInstance scriptingComponent
  70.     OSAID               scriptID
  71.     OSType              desiredType 
  72.     long                    modeFlags
  73.     CODE:
  74.     if (gLastMacOSErr = (short) OSAStore(scriptingComponent, scriptID, desiredType, modeFlags, &RETVAL)) {
  75.         XSRETURN_UNDEF;
  76.     }
  77.     OUTPUT:
  78.     RETVAL
  79.  
  80. =item OSAExecute SCRIPTINGCOMPONENT, COMPILEDSCRIPTID, CONTEXTID, MODEFLAGS
  81.  
  82. The OSAExecute function executes the compiled script identified by the
  83. COMPILEDSCRIPTID parameter, using the script context identified by the CONTEXTID
  84. parameter to maintain state information, such as the binding of variables, for
  85. the compiled script. After successfully executing a script, OSAExecute returns
  86. the script ID for a resulting script value, or, if execution does not result in a
  87. value, C<undef>.
  88.  
  89. =cut
  90. OSAID
  91. OSAExecute(scriptingComponent, compiledScriptID, contextID, modeFlags)
  92.     ComponentInstance scriptingComponent
  93.     OSAID               compiledScriptID
  94.     OSAID               contextID
  95.     long                    modeFlags
  96.     CODE:
  97.     if (gLastMacOSErr = (short) OSAExecute(scriptingComponent, compiledScriptID, contextID, modeFlags, &RETVAL)) {
  98.         XSRETURN_UNDEF;
  99.     }
  100.     OUTPUT:
  101.     RETVAL
  102.  
  103. =item OSADisplay SCRIPTINGCOMPONENT, SCRIPTVALUEID, DESIREDTYPE, MODEFLAGS
  104.  
  105. The OSADisplay function coerces the script value identified by SCRIPTVALUEID to a
  106. descriptor record of the text type specified by the DESIREDTYPE parameter, if
  107. possible. Valid types include all the standard text descriptor types defined in
  108. the Apple Event Registry: Standard Suites, plus any special types supported by
  109. the scripting component.
  110. Return C<undef> if an error was detected.
  111.  
  112. =cut
  113. AEDesc
  114. OSADisplay(scriptingComponent, scriptValueID, desiredType, modeFlags)
  115.     ComponentInstance scriptingComponent
  116.     OSAID               scriptValueID
  117.     OSType              desiredType
  118.     long                    modeFlags
  119.     CODE:
  120.     if (gLastMacOSErr = (short) OSADisplay(scriptingComponent, scriptValueID, desiredType, modeFlags, &RETVAL)) {
  121.         XSRETURN_UNDEF;
  122.     }
  123.     OUTPUT:
  124.     RETVAL
  125.  
  126. =item OSAScriptError SCRIPTINGCOMPONENT, SELECTOR, DESIREDTYPE
  127.  
  128. Whenever the OSAExecute() function returns the error errOSAScriptError, you can use
  129. the OSAScriptError function to get more specific information about the error from
  130. the scripting component that encountered it. (This information remains available
  131. only until the next call to the same scripting component.) The information
  132. returned by OSAScriptError depends on the value passed in the SELECTOR parameter,
  133. which also determines the descriptor type you should specify in the DESIREDTYPE
  134. parameter. 
  135.  
  136. Return C<undef> if an error was detected.
  137.  
  138. =cut
  139. AEDesc
  140. OSAScriptError(scriptingComponent, selector, desiredType)
  141.     ComponentInstance scriptingComponent
  142.     OSType              selector
  143.     OSType              desiredType
  144.     CODE:
  145.     if (gLastMacOSErr = (short) OSAScriptError(scriptingComponent, selector, desiredType, &RETVAL)) {
  146.         XSRETURN_UNDEF;
  147.     }
  148.     OUTPUT:
  149.     RETVAL
  150.  
  151. =item OSADispose SCRIPTINGCOMPONENT, SCRIPTID
  152.  
  153. The OSADispose function releases the memory assigned to the script data identified
  154. by the SCRIPTID parameter. The SCRIPTID passed to the OSADispose function is no
  155. longer valid if the function returns successfully. A scripting component can then
  156. reuse that SCRIPTID for other script data. 
  157. Return zero if no error was detected.
  158.  
  159. =cut
  160. OSAError
  161. OSADispose(scriptingComponent, scriptID)
  162.     ComponentInstance scriptingComponent
  163.     OSAID               scriptID
  164.  
  165. =item OSASetScriptInfo SCRIPTINGCOMPONENT, SCRIPTID, SELECTOR, VALUE
  166.  
  167. The OSASetScriptInfo function sets script information according to the value you
  168. pass in the selector parameter. If you use the kOSAScriptIsModified constant,
  169. OSASetScriptInfo sets a value that indicates how many times the script data has
  170. been modified since it was created or passed to OSALoad. Some scripting
  171. components may provide additional constants.
  172. Return zero if no error was detected.
  173.  
  174. =cut
  175. OSAError
  176. OSASetScriptInfo(scriptingComponent, scriptID, selector, value)
  177.     ComponentInstance scriptingComponent
  178.     OSAID               scriptID
  179.     OSType              selector
  180.     long                    value
  181.  
  182. =item OSAGetScriptInfo SCRIPTINGCOMPONENT, SCRIPTID, SELECTOR
  183.  
  184. The OSAGetScriptInfo function returns various results according to the value you
  185. pass in the SELECTOR parameter.
  186. Returns an integer value which may need to be recast as the desired type.
  187.  
  188. =cut
  189. long
  190. OSAGetScriptInfo(scriptingComponent, scriptID, selector)
  191.     ComponentInstance scriptingComponent
  192.     OSAID               scriptID
  193.     OSType              selector
  194.     CODE:
  195.     if (gLastMacOSErr = (short) OSAGetScriptInfo(scriptingComponent, scriptID, selector, &RETVAL)) {
  196.         XSRETURN_UNDEF;
  197.     }
  198.     OUTPUT:
  199.     RETVAL
  200.  
  201. =item OSAScriptingComponentName SCRIPTINGCOMPONENT
  202.  
  203. The OSAScriptingComponentName function returns a descriptor record that you can
  204. coerce to a text descriptor type such as typeChar. This can be useful if you want
  205. to display the name of the scripting language in which the user should write a
  206. new script.
  207. Return C<undef> if an error was detected.
  208.  
  209. =cut
  210. AEDesc
  211. OSAScriptingComponentName(scriptingComponent)
  212.     ComponentInstance scriptingComponent
  213.     CODE:
  214.     if (gLastMacOSErr = (short) OSAScriptingComponentName(scriptingComponent, &RETVAL)) {
  215.         XSRETURN_UNDEF;
  216.     }
  217.     OUTPUT:
  218.     RETVAL
  219.  
  220. =item OSACompile SCRIPTINGCOMPONENT, SOURCEDATA, MODEFLAGS, [PREVIOUSSCRIPTID]
  221.  
  222. You can pass a descriptor record containing source data suitable for a specific
  223. scripting component (usually text) to the OSACompile function to obtain a script
  224. ID for the equivalent compiled script or script context. To compile the source
  225. data as a script context for use with OSAExecuteEvent() or OSADoEvent(), you must set
  226. the kOSACompileIntoContext flag, and the source data should include appropriate
  227. handlers.
  228. Return zero if no error was detected.
  229.  
  230. =cut
  231. OSAID
  232. OSACompile(scriptingComponent, sourceData, modeFlags, previousScriptID = 0)
  233.     ComponentInstance scriptingComponent
  234.     AEDesc              sourceData
  235.     long                    modeFlags
  236.     OSAID                   previousScriptID
  237.     CODE:
  238.     RETVAL = previousScriptID;
  239.     if (gLastMacOSErr = (short) OSACompile(scriptingComponent, &sourceData, modeFlags, &RETVAL)) {
  240.         XSRETURN_UNDEF;
  241.     }
  242.     OUTPUT:
  243.     RETVAL
  244.  
  245. =item OSACopyID SCRIPTINGCOMPONENT, FROMID, [TOID]
  246.  
  247. The OSACopyID function replaces the script data identified by the script ID in
  248. the TOID parameter with the script data identified by the script ID in the FROMID
  249. parameter.
  250. Return C<undef> if an error was detected.
  251.  
  252. =cut
  253. OSAID
  254. OSACopyID(scriptingComponent, fromID, toID = 0)
  255.     ComponentInstance scriptingComponent
  256.     OSAID               fromID
  257.     OSAID                   toID    
  258.     CODE:
  259.     RETVAL = toID;
  260.     if (gLastMacOSErr = (short) OSACopyID(scriptingComponent, fromID, &RETVAL)) {
  261.         XSRETURN_UNDEF;
  262.     }
  263.     OUTPUT:
  264.     RETVAL
  265.  
  266. =item OSAGetSource SCRIPTINGCOMPONENT, SCRIPTID, [DESIREDTYPE]
  267.  
  268. The OSAGetSource function decompiles the script data identified by the specified
  269. script ID and returns a descriptor record containing the equivalent source data.
  270. Return C<undef> if an error was detected.
  271.  
  272. =cut
  273. AEDesc
  274. OSAGetSource(scriptingComponent, scriptID, desiredType = 'TEXT')
  275.     ComponentInstance scriptingComponent
  276.     OSAID               scriptID
  277.     OSType              desiredType
  278.     CODE:
  279.     if (gLastMacOSErr = (short) OSAGetSource(scriptingComponent, scriptID, desiredType, &RETVAL)) {
  280.         XSRETURN_UNDEF;
  281.     }
  282.     OUTPUT:
  283.     RETVAL
  284.  
  285. =item OSACoerceFromDesc SCRIPTINGCOMPONENT, SCRIPTDATA, MODEFLAGS
  286.  
  287. The OSACoerceFromDesc function coerces the descriptor record in the SCRIPTDATA
  288. parameter to the equivalent script value and returns a script ID for that value. 
  289. Return C<undef> if an error was detected.
  290.  
  291. =cut
  292. OSAID
  293. OSACoerceFromDesc(scriptingComponent, scriptData, modeFlags)
  294.     ComponentInstance scriptingComponent
  295.     AEDesc              scriptData
  296.     long                    modeFlags
  297.     CODE:
  298.     if (gLastMacOSErr = (short) OSACoerceFromDesc(scriptingComponent, &scriptData, modeFlags, &RETVAL)) {
  299.         XSRETURN_UNDEF;
  300.     }
  301.     OUTPUT:
  302.     RETVAL
  303.  
  304. =item OSACoerceToDesc SCRIPTINGCOMPONENT, SCRIPTID, DESIREDTYPE, MODEFLAGS
  305.  
  306. The OSACoerceToDesc function coerces the script value identified by SCRIPTID
  307. to a descriptor record of the type specified by the DESIREDTYPE parameter, if
  308. possible.
  309. Return C<undef> if an error was detected.
  310.  
  311. =cut
  312. AEDesc
  313. OSACoerceToDesc(scriptingComponent, scriptID, desiredType, modeFlags)
  314.     ComponentInstance scriptingComponent
  315.     OSAID               scriptID
  316.     OSType              desiredType
  317.     long                    modeFlags
  318.     CODE:
  319.     if (gLastMacOSErr = (short) OSACoerceToDesc(scriptingComponent, scriptID, desiredType, modeFlags, &RETVAL)) {
  320.         XSRETURN_UNDEF;
  321.     }
  322.     OUTPUT:
  323.     RETVAL
  324.  
  325. =item OSASetDefaultTarget SCRIPTINGCOMPONENT, TARGET
  326.  
  327. The OSASetDefaultTarget function establishes the default target application for
  328. Apple event sending and the default application from which the scripting
  329. component should obtain terminology information. For example, AppleScript
  330. statements that refer to the default application do not need to be enclosed in
  331. C<tell/end tell> statements. 
  332. Return zero if no error was detected.
  333.  
  334. =cut
  335. OSAError
  336. OSASetDefaultTarget(scriptingComponent, target)
  337.     ComponentInstance scriptingComponent
  338.     AEDesc              &target
  339.  
  340. =item OSAStartRecording SCRIPTINGCOMPONENT, [COMPILEDSCRIPTTOMODIFYID]
  341.  
  342. The OSAStartRecording routine turns on Apple event recording. Subsequent Apple
  343. events are recorded (that is, appended to any existing statements) in the
  344. compiled script specified by the COMPILEDSCRIPTTOMODIFYID parameter.
  345. Return C<undef> if an error was detected.
  346.  
  347. =cut
  348. OSAID
  349. OSAStartRecording(scriptingComponent, compiledScriptToModifyID = 0)
  350.     ComponentInstance scriptingComponent
  351.     OSAID                   compiledScriptToModifyID
  352.     CODE:
  353.     RETVAL = compiledScriptToModifyID;
  354.     if (gLastMacOSErr = (short) OSAStartRecording(scriptingComponent, &RETVAL)) {
  355.         XSRETURN_UNDEF;
  356.     }
  357.     OUTPUT:
  358.     RETVAL
  359.  
  360. =item OSAStopRecording SCRIPTINGCOMPONENT, COMPILEDSCRIPTID
  361.  
  362. The OSAStopRecording function turns off recording. If the script is not currently
  363. open in a script editor window, the COMPILEDSCRIPTTOMODIFYID parameter supplied
  364. to OSAStartRecording() is then augmented to contain the newly recorded statements.
  365. If the script is currently open in a script editor window, the script data that
  366. corresponds to the compiledScriptToModifyID parameter supplied to
  367. OSAStartRecording() is updated continuously until the client application calls
  368. OSAStopRecording. 
  369. Return zero if no error was detected.
  370.  
  371. =cut
  372. OSAError
  373. OSAStopRecording(scriptingComponent, compiledScriptID)
  374.     ComponentInstance scriptingComponent
  375.     OSAID                   compiledScriptID
  376.  
  377. =item OSALoadExecute SCRIPTINGCOMPONENT, SCRIPTDATA, CONTEXTID, MODEFLAGS
  378.  
  379. The OSALoadExecute function loads script data and executes the resulting compiled
  380. script, using the script context identified by the CONTEXTID parameter to
  381. maintain state information such as the binding of variables. After successfully
  382. executing the script, OSALoadExecute disposes of the compiled script and returns
  383. either the script ID for the resulting script value or, if execution does not
  384. result in a value, the constant kOSANullScript. 
  385. Return C<undef> if an error was detected.
  386.  
  387. =cut
  388. OSAID
  389. OSALoadExecute(scriptingComponent, scriptData, contextID, modeFlags)
  390.     ComponentInstance scriptingComponent
  391.     AEDesc              scriptData
  392.     OSAID               contextID
  393.     long                    modeFlags
  394.     CODE:
  395.     if (gLastMacOSErr = (short) OSALoadExecute(scriptingComponent, &scriptData, contextID, modeFlags, &RETVAL)) {
  396.         XSRETURN_UNDEF;
  397.     }
  398.     OUTPUT:
  399.     RETVAL
  400.  
  401. =item OSACompileExecute SCRIPTINGCOMPONENT, SOURCEDATA, CONTEXTID, MODEFLAGS
  402.  
  403. The OSACompileExecute function compiles source data and executes the resulting
  404. compiled script, using the script context identified by the CONTEXTID parameter
  405. to maintain state information such as the binding of variables. After
  406. successfully executing the script, OSACompileExecute disposes of the compiled
  407. script and returns either the script ID for the resulting script value or, if
  408. execution does not result in a value, the constant kOSANullScript.
  409. Return C<undef> if an error was detected.
  410.  
  411. =cut
  412. OSAID
  413. OSACompileExecute(scriptingComponent, sourceData, contextID, modeFlags)
  414.     ComponentInstance scriptingComponent
  415.     AEDesc              sourceData
  416.     OSAID               contextID
  417.     long                    modeFlags
  418.     CODE:
  419.     if (gLastMacOSErr = (short) OSACompileExecute(scriptingComponent, &sourceData, contextID, modeFlags, &RETVAL)) {
  420.         XSRETURN_UNDEF;
  421.     }
  422.     OUTPUT:
  423.     RETVAL
  424.  
  425. =item OSADoScript SCRIPTINGCOMPONENT, SOURCEDATA, CONTEXTID, DESIREDTYPE, MODEFLAGS
  426.  
  427. Calling the OSADoScript function is equivalent to calling OSACompile() followed by
  428. OSAExecute() and OSADisplay(). After compiling the source data, executing the
  429. compiled script using the script context identified by the CONTEXTID parameter,
  430. and returning the text equivalent of the resulting script value, OSADoScript
  431. disposes of both the compiled script and the resulting script value.
  432. Return C<undef> if an error was detected.
  433.  
  434. =cut
  435. AEDesc
  436. OSADoScript(scriptingComponent, sourceData, contextID, desiredType, modeFlags)
  437.     ComponentInstance scriptingComponent
  438.     AEDesc              sourceData
  439.     OSAID               contextID
  440.     OSType              desiredType
  441.     long                    modeFlags
  442.     CODE:
  443.     if (gLastMacOSErr = (short) OSADoScript(scriptingComponent, &sourceData, contextID, desiredType, modeFlags, &RETVAL)) {
  444.         XSRETURN_UNDEF;
  445.     }
  446.     OUTPUT:
  447.     RETVAL
  448.  
  449. =item OSASetCurrentDialect SCRIPTINGCOMPONENT, DIALECTCODE
  450.  
  451. Set the current dialect for a scripting component.
  452. Return zero if no error was detected.
  453.  
  454. =cut
  455. OSAError
  456. OSASetCurrentDialect(scriptingComponent, dialectCode)
  457.     ComponentInstance scriptingComponent
  458.     short               dialectCode
  459.  
  460. =item OSAGetCurrentDialect SCRIPTINGCOMPONENT
  461.  
  462. Get the dialect code for the dialect currently being used by a scripting
  463. component.
  464. Returns the code for the current dialect of the specified scripting component.
  465.  
  466. =cut
  467. short
  468. OSAGetCurrentDialect(scriptingComponent)
  469.     ComponentInstance scriptingComponent    
  470.     CODE:
  471.     if (gLastMacOSErr = (short) OSAGetCurrentDialect(scriptingComponent, &RETVAL)) {
  472.         XSRETURN_UNDEF;
  473.     }
  474.     OUTPUT:
  475.     RETVAL
  476.  
  477. =item OSAAvailableDialects SCRIPTINGCOMPONENT
  478.  
  479. Obtain a descriptor list containing information about each of the currently
  480. available dialects for a scripting component. 
  481. Return C<undef> if an error was detected.
  482.  
  483. =cut
  484. AEDesc
  485. OSAAvailableDialects(scriptingComponent)
  486.     ComponentInstance scriptingComponent    
  487.     CODE:
  488.     if (gLastMacOSErr = (short) OSAAvailableDialects(scriptingComponent, &RETVAL)) {
  489.         XSRETURN_UNDEF;
  490.     }
  491.     OUTPUT:
  492.     RETVAL
  493.  
  494. =item OSAGetDialectInfo SCRIPTINGCOMPONENT, DIALECTCODE, SELECTOR
  495.  
  496. After you obtain a list of dialect codes by calling OSAAvailableDialectCodeList(),
  497. you can pass any of those codes to OSAGetDialectInfo to get information about the
  498. corresponding dialect. The descriptor type of the descriptor record returned by
  499. OSAGetDialectInfo depends on the constant specified in the SELECTOR parameter.
  500. Return C<undef> if an error was detected.
  501.  
  502. =cut
  503. AEDesc
  504. OSAGetDialectInfo(scriptingComponent, dialectCode, selector)
  505.     ComponentInstance scriptingComponent
  506.     short               dialectCode
  507.     OSType              selector
  508.     CODE:
  509.     if (gLastMacOSErr = (short) OSAGetDialectInfo(scriptingComponent, dialectCode, selector, &RETVAL)) {
  510.         XSRETURN_UNDEF;
  511.     }
  512.     OUTPUT:
  513.     RETVAL
  514.  
  515. =item OSAAvailableDialectCodeList SCRIPTINGCOMPONENT
  516.  
  517. Obtain a descriptor list containing dialect codes for each of a scripting
  518. component's currently available dialects. 
  519. Return C<undef> if an error was detected.
  520.  
  521. =cut
  522. AEDesc
  523. OSAAvailableDialectCodeList(scriptingComponent)
  524.     ComponentInstance scriptingComponent    
  525.     CODE:
  526.     if (gLastMacOSErr = (short) OSAAvailableDialectCodeList(scriptingComponent, &RETVAL)) {
  527.         XSRETURN_UNDEF;
  528.     }
  529.     OUTPUT:
  530.     RETVAL
  531.  
  532. =item OSAExecuteEvent SCRIPTINGCOMPONENT, THEAPPLEEVENT, CONTEXTID, MODEFLAGS
  533.  
  534. The OSAExecuteEvent function attempts to use the script context specified by the
  535. contextID parameter to handle the Apple event specified by the THEAPPLEEVENT
  536. parameter.
  537. Return C<undef> if an error was detected.
  538.  
  539. =cut
  540. OSAID
  541. OSAExecuteEvent(scriptingComponent, theAppleEvent, contextID, modeFlags)
  542.     ComponentInstance scriptingComponent
  543.     AEDesc              theAppleEvent
  544.     OSAID               contextID
  545.     long                    modeFlags
  546.     CODE:
  547.     if (gLastMacOSErr = (short) OSAExecuteEvent(scriptingComponent, &theAppleEvent, contextID, modeFlags, &RETVAL)) {
  548.         XSRETURN_UNDEF;
  549.     }
  550.     OUTPUT:
  551.     RETVAL
  552.  
  553. =item OSADoEvent SCRIPTINGCOMPONENT, THEAPPLEEVENT, CONTEXTID, MODEFLAGS
  554.  
  555. The OSADoEvent function resembles both OSADoScript() and OSAExecuteEvent().
  556. However,
  557. unlike OSADoScript(), the script OSADoEvent executes must be in the form of a
  558. script context, and execution is initiated by an Apple event. Unlike
  559. OSAExecuteEvent(), OSADoEvent returns a reply Apple event rather than the script ID
  560. of the resulting script value.
  561. Return C<undef> if an error was detected.
  562.  
  563. =cut
  564. AEDesc
  565. OSADoEvent(scriptingComponent, theAppleEvent, contextID, modeFlags)
  566.     ComponentInstance scriptingComponent
  567.     AEDesc              theAppleEvent
  568.     OSAID               contextID
  569.     long                    modeFlags
  570.     CODE:
  571.     if (gLastMacOSErr = (short) OSADoEvent(scriptingComponent, &theAppleEvent, contextID, modeFlags, &RETVAL)) {
  572.         XSRETURN_UNDEF;
  573.     }
  574.     OUTPUT:
  575.     RETVAL
  576.  
  577. =item OSAMakeContext SCRIPTINGCOMPONENT, CONTEXTNAME, [PARENTCONTEXT]
  578.  
  579. The OSAMakeContext function creates a new script context that you may pass to
  580. OSAExecute() or OSAExecuteEvent(). The new script context inherits the bindings of
  581. the script context specified in the PARENTCONTEXT parameter.
  582. Return C<undef> if an error was detected.
  583.  
  584. =cut
  585. OSAID
  586. OSAMakeContext(scriptingComponent,contextName, parentContext = 0)
  587.     ComponentInstance scriptingComponent
  588.     AEDesc              contextName
  589.     OSAID               parentContext
  590.     CODE:
  591.     if (gLastMacOSErr = (short) OSAMakeContext(scriptingComponent, &contextName, parentContext, &RETVAL)) {
  592.         XSRETURN_UNDEF;
  593.     }
  594.     OUTPUT:
  595.     RETVAL
  596.  
  597. =item OSAGetDefaultScriptingComponent GENERICSCRIPTINGCOMPONENT
  598.  
  599. The OSAGetDefaultScriptingComponent function returns the subtype code for the
  600. default scripting component. This is the scripting component that will be used by
  601. OSAStartRecording(), OSACompile(), or OSACompileExecute() if no existing script ID is
  602. specified. From the user's point of view, the default scripting component
  603. corresponds to the scripting language selected in the Script Editor application
  604. when the user first creates a new script.
  605. Return C<undef> if an error was detected.
  606.  
  607. =cut
  608. OSType
  609. OSAGetDefaultScriptingComponent(genericScriptingComponent)
  610.     ComponentInstance   genericScriptingComponent
  611.     CODE:
  612.     if (gLastMacOSErr = (short) OSAGetDefaultScriptingComponent(genericScriptingComponent, &RETVAL)) {
  613.         XSRETURN_UNDEF;
  614.     }
  615.     OUTPUT:
  616.     RETVAL
  617.  
  618. =item OSASetDefaultScriptingComponent GENERICSCRIPTINGCOMPONENT, SCRIPTINGSUBTYPE
  619.  
  620. The OSASetDefaultScriptingComponent function sets the default scripting component
  621. for the specified instance of the generic scripting component to the scripting
  622. component identified by the SCRIPTINGSUBTYPE parameter.
  623. Return zero if no error was detected.
  624.  
  625. =cut
  626. OSAError
  627. OSASetDefaultScriptingComponent(genericScriptingComponent, scriptingSubType)
  628.     ComponentInstance genericScriptingComponent
  629.     OSType              scriptingSubType
  630.  
  631. =item OSAGetScriptingComponent GENERICSCRIPTINGCOMPONENT, SCRIPTINGSUBTYPE
  632.  
  633. The OSAGetScriptingComponent function returns an instance of the scripting
  634. component identified by the
  635. SCRIPTINGSUBTYPE parameter. Each instance of the generic scripting component
  636. keeps track of a single instance of each component subtype, so
  637. OSAGetScriptingComponent always returns the same instance of a specified
  638. scripting component that the generic scripting component uses for standard
  639. scripting component routines.
  640. Return C<undef> if an error was detected.
  641.  
  642. =cut
  643. ComponentInstance
  644. OSAGetScriptingComponent(genericScriptingComponent, scriptingSubType)
  645.     ComponentInstance genericScriptingComponent
  646.     OSType              scriptingSubType
  647.     CODE:
  648.     if (gLastMacOSErr = (short) OSAGetScriptingComponent(genericScriptingComponent, scriptingSubType, &RETVAL)) {
  649.         XSRETURN_UNDEF;
  650.     }
  651.     OUTPUT:
  652.     RETVAL
  653.  
  654. =item OSAGetScriptingComponentFromStored GENERICSCRIPTINGCOMPONENT, SCRIPTDATA
  655.  
  656. The OSAGetScriptingComponentFromStored function returns the subtype code for the
  657. scripting component that created the script
  658. data specified by the SCRIPTDATA parameter. 
  659. Return C<undef> if an error was detected.
  660.  
  661. =cut
  662. OSType
  663. OSAGetScriptingComponentFromStored(genericScriptingComponent, scriptData)
  664.     ComponentInstance genericScriptingComponent
  665.     AEDesc              scriptData
  666.     CODE:
  667.     if (gLastMacOSErr = (short) OSAGetScriptingComponentFromStored(genericScriptingComponent, &scriptData, &RETVAL)) {
  668.         XSRETURN_UNDEF;
  669.     }
  670.     OUTPUT:
  671.     RETVAL
  672.  
  673. =item OSAGenericToRealID GENERICSCRIPTINGCOMPONENT, GENERICSCRIPTID
  674.  
  675. Given a GENERICSCRIPTID (that is, a script ID returned by a call to a standard
  676. component routine via the generic scripting component), the OSAGenericToRealID
  677. function returns the equivalent component-specific script ID and the component
  678. instance that created that script ID as an array.
  679.  
  680. =cut
  681. void
  682. OSAGenericToRealID(genericScriptingComponent, genericScriptID)
  683.     ComponentInstance genericScriptingComponent
  684.     OSAID                   genericScriptID
  685.     PREINIT:
  686.     ComponentInstance   exactScriptingComponent;
  687.     PPCODE:
  688.     if (gLastMacOSErr = (short) OSAGenericToRealID(genericScriptingComponent, &genericScriptID, &exactScriptingComponent)) {
  689.         XSRETURN_EMPTY;
  690.     }
  691.     XS_XPUSH(OSAID, genericScriptID);
  692.     XS_XPUSH(ComponentInstance, exactScriptingComponent);
  693.  
  694.     
  695. =item OSARealToGenericID GENERICSCRIPTINGCOMPONENT, THESCRIPTID, THEEXACTCOMPONENT
  696.  
  697. The OSARealToGenericID function performs the reverse of the task performed by
  698. OSAGenericToRealID(). Given a component-specific SCRIPTID and an exact scripting
  699. component instance (that is, the component instance that created the
  700. component-specific script ID), the OSARealToGenericID function returns the
  701. corresponding generic script ID.
  702. Return C<undef> if an error was detected.
  703.  
  704. =cut
  705. OSAID
  706. OSARealToGenericID(genericScriptingComponent, theScriptID, theExactComponent)
  707.     ComponentInstance genericScriptingComponent
  708.     OSAID                   theScriptID
  709.     ComponentInstance theExactComponent
  710.     CODE:
  711.     RETVAL = theScriptID;
  712.     if (gLastMacOSErr = (short) OSARealToGenericID(genericScriptingComponent, &RETVAL, theExactComponent)) {
  713.         XSRETURN_UNDEF;
  714.     }
  715.     OUTPUT:
  716.     RETVAL
  717.  
  718. =back
  719.  
  720. =cut
  721.