]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Adding an interface to the high-level Open Scripting Architecture,
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 3 Dec 2003 22:34:19 +0000 (22:34 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 3 Dec 2003 22:34:19 +0000 (22:34 +0000)
by request of Donovan Preston. In return, he promised to use this
to create a Python OSA component, which would turn Python
into a first-class OSA scripting language (like AppleScript itself).

Lib/plat-mac/Carbon/OSAconst.py [new file with mode: 0644]
Lib/plat-mac/Carbon/WASTEconst.py
Mac/Modules/osa/_OSAmodule.c [new file with mode: 0644]
Mac/Modules/osa/osascan.py [new file with mode: 0644]
Mac/Modules/osa/osasupport.py [new file with mode: 0644]
setup.py

diff --git a/Lib/plat-mac/Carbon/OSAconst.py b/Lib/plat-mac/Carbon/OSAconst.py
new file mode 100644 (file)
index 0000000..c6d4851
--- /dev/null
@@ -0,0 +1,129 @@
+# Generated from 'OSA.h'
+
+def FOUR_CHAR_CODE(x): return x
+from Carbon.AppleEvents import *
+kAEUseStandardDispatch = -1
+kOSAComponentType = FOUR_CHAR_CODE('osa ')
+kOSAGenericScriptingComponentSubtype = FOUR_CHAR_CODE('scpt')
+kOSAFileType = FOUR_CHAR_CODE('osas')
+kOSASuite = FOUR_CHAR_CODE('ascr')
+kOSARecordedText = FOUR_CHAR_CODE('recd')
+kOSAScriptIsModified = FOUR_CHAR_CODE('modi')
+kOSAScriptIsTypeCompiledScript = FOUR_CHAR_CODE('cscr')
+kOSAScriptIsTypeScriptValue = FOUR_CHAR_CODE('valu')
+kOSAScriptIsTypeScriptContext = FOUR_CHAR_CODE('cntx')
+kOSAScriptBestType = FOUR_CHAR_CODE('best')
+kOSACanGetSource = FOUR_CHAR_CODE('gsrc')
+typeOSADialectInfo = FOUR_CHAR_CODE('difo')
+keyOSADialectName = FOUR_CHAR_CODE('dnam')
+keyOSADialectCode = FOUR_CHAR_CODE('dcod')
+keyOSADialectLangCode = FOUR_CHAR_CODE('dlcd')
+keyOSADialectScriptCode = FOUR_CHAR_CODE('dscd') 
+kOSANullScript = 0L
+kOSANullMode = 0
+kOSAModeNull = 0     
+kOSASupportsCompiling = 0x0002
+kOSASupportsGetSource = 0x0004
+kOSASupportsAECoercion = 0x0008
+kOSASupportsAESending = 0x0010
+kOSASupportsRecording = 0x0020
+kOSASupportsConvenience = 0x0040
+kOSASupportsDialects = 0x0080
+kOSASupportsEventHandling = 0x0100
+kOSASelectLoad = 0x0001
+kOSASelectStore = 0x0002
+kOSASelectExecute = 0x0003
+kOSASelectDisplay = 0x0004
+kOSASelectScriptError = 0x0005
+kOSASelectDispose = 0x0006
+kOSASelectSetScriptInfo = 0x0007
+kOSASelectGetScriptInfo = 0x0008
+kOSASelectSetActiveProc = 0x0009
+kOSASelectGetActiveProc = 0x000A
+kOSASelectScriptingComponentName = 0x0102
+kOSASelectCompile = 0x0103
+kOSASelectCopyID = 0x0104
+kOSASelectCopyScript = 0x0105
+kOSASelectGetSource = 0x0201
+kOSASelectCoerceFromDesc = 0x0301
+kOSASelectCoerceToDesc = 0x0302
+kOSASelectSetSendProc = 0x0401
+kOSASelectGetSendProc = 0x0402
+kOSASelectSetCreateProc = 0x0403
+kOSASelectGetCreateProc = 0x0404
+kOSASelectSetDefaultTarget = 0x0405
+kOSASelectStartRecording = 0x0501
+kOSASelectStopRecording = 0x0502
+kOSASelectLoadExecute = 0x0601
+kOSASelectCompileExecute = 0x0602
+kOSASelectDoScript = 0x0603
+kOSASelectSetCurrentDialect = 0x0701
+kOSASelectGetCurrentDialect = 0x0702
+kOSASelectAvailableDialects = 0x0703
+kOSASelectGetDialectInfo = 0x0704
+kOSASelectAvailableDialectCodeList = 0x0705
+kOSASelectSetResumeDispatchProc = 0x0801
+kOSASelectGetResumeDispatchProc = 0x0802
+kOSASelectExecuteEvent = 0x0803
+kOSASelectDoEvent = 0x0804
+kOSASelectMakeContext = 0x0805
+kOSADebuggerCreateSession = 0x0901
+kOSADebuggerGetSessionState = 0x0902
+kOSADebuggerSessionStep = 0x0903
+kOSADebuggerDisposeSession = 0x0904
+kOSADebuggerGetStatementRanges = 0x0905
+kOSADebuggerGetBreakpoint = 0x0910
+kOSADebuggerSetBreakpoint = 0x0911
+kOSADebuggerGetDefaultBreakpoint = 0x0912
+kOSADebuggerGetCurrentCallFrame = 0x0906
+kOSADebuggerGetCallFrameState = 0x0907
+kOSADebuggerGetVariable = 0x0908
+kOSADebuggerSetVariable = 0x0909
+kOSADebuggerGetPreviousCallFrame = 0x090A
+kOSADebuggerDisposeCallFrame = 0x090B
+kOSASelectComponentSpecificStart = 0x1001
+kOSAModePreventGetSource = 0x00000001
+kOSAModeNeverInteract = kAENeverInteract
+kOSAModeCanInteract = kAECanInteract
+kOSAModeAlwaysInteract = kAEAlwaysInteract
+kOSAModeDontReconnect = kAEDontReconnect
+kOSAModeCantSwitchLayer = 0x00000040
+kOSAModeDoRecord = 0x00001000
+kOSAModeCompileIntoContext = 0x00000002
+kOSAModeAugmentContext = 0x00000004
+kOSAModeDisplayForHumans = 0x00000008
+kOSAModeDontStoreParent = 0x00010000
+kOSAModeDispatchToDirectObject = 0x00020000
+kOSAModeDontGetDataForArguments = 0x00040000
+kOSAScriptResourceType = kOSAGenericScriptingComponentSubtype
+typeOSAGenericStorage = kOSAScriptResourceType
+kOSAErrorNumber = keyErrorNumber
+kOSAErrorMessage = keyErrorString
+kOSAErrorBriefMessage = FOUR_CHAR_CODE('errb')
+kOSAErrorApp = FOUR_CHAR_CODE('erap')
+kOSAErrorPartialResult = FOUR_CHAR_CODE('ptlr')
+kOSAErrorOffendingObject = FOUR_CHAR_CODE('erob')
+kOSAErrorExpectedType = FOUR_CHAR_CODE('errt')
+kOSAErrorRange = FOUR_CHAR_CODE('erng')
+typeOSAErrorRange = FOUR_CHAR_CODE('erng')
+keyOSASourceStart = FOUR_CHAR_CODE('srcs')
+keyOSASourceEnd = FOUR_CHAR_CODE('srce')
+kOSAUseStandardDispatch = kAEUseStandardDispatch
+kOSANoDispatch = kAENoDispatch
+kOSADontUsePhac = 0x0001
+eNotStarted = 0
+eRunnable = 1
+eRunning = 2
+eStopped = 3
+eTerminated = 4
+eStepOver = 0
+eStepIn = 1
+eStepOut = 2
+eRun = 3
+keyProgramState = FOUR_CHAR_CODE('dsps')
+typeStatementRange = FOUR_CHAR_CODE('srng')
+keyProcedureName = FOUR_CHAR_CODE('dfnm')
+keyStatementRange = FOUR_CHAR_CODE('dfsr')
+keyLocalsNames = FOUR_CHAR_CODE('dfln')
+keyGlobalsNames = FOUR_CHAR_CODE('dfgn')
+keyParamsNames = FOUR_CHAR_CODE('dfpn') 
index dc7390532cbe58756e1fa8cd197c9a9d7d0d5a24..f674e6081d155ef5763f8159a1b39c636ceefbfe 100644 (file)
@@ -51,6 +51,7 @@ kLeadingEdge = -1
 kTrailingEdge = 0
 kObjectEdge = 2
 weFAutoScroll = 0
+weFAutoIdle = 1
 weFOutlineHilite = 2
 weFReadOnly = 5
 weFUndo = 6
@@ -62,10 +63,13 @@ weFDrawOffscreen = 11
 weFInhibitRedraw = 12
 weFMonoStyled = 13
 weFMultipleUndo = 14
+weFLeftMarginClick = 16
+weFNoAutoTabForHangingIndent = 28
 weFNoKeyboardSync = 29
 weFInhibitICSupport = 30
 weFInhibitColor = 31
 # weDoAutoScroll = 1UL << weFAutoScroll
+weDoAutoIdle = 1UL << weFAutoIdle
 # weDoOutlineHilite = 1UL << weFOutlineHilite
 # weDoReadOnly = 1UL << weFReadOnly
 # weDoUndo = 1UL << weFUndo
@@ -77,6 +81,8 @@ weFInhibitColor = 31
 # weDoInhibitRedraw = 1UL << weFInhibitRedraw
 # weDoMonoStyled = 1UL << weFMonoStyled
 # weDoMultipleUndo = 1UL << weFMultipleUndo
+weDoLeftMarginClick = 1UL << weFLeftMarginClick
+weDoNoAutoTabForHangingIndent = 1UL << weFNoAutoTabForHangingIndent
 # weDoNoKeyboardSync = 1UL << weFNoKeyboardSync
 # weDoInhibitICSupport = 1UL << weFInhibitICSupport
 # weDoInhibitColor = 1UL << weFInhibitColor
@@ -86,6 +92,9 @@ weBitClear = 0
 weBitSet = 1
 weLowerCase = 0
 weUpperCase = 1
+weRedWigglyUnderline = 29303
+weGreenWigglyUnderline = 26487
+weOrangeWigglyUnderline = 28535
 weFindWholeWords = 0x00000001
 weFindCaseInsensitive = 0x00000002
 weFindDiacriticalInsensitive = 0x00000004
@@ -94,8 +103,13 @@ wePutAddToTypingSequence = 0x00000002
 wePutDetectUnicodeBOM = 0x00000200
 weStreamDestinationKindMask = 0x000000FF
 weStreamIncludeObjects = 0x00000100
+weCopyPromiseFlavors = 0x00000001
 weGetAddUnicodeBOM = 0x00000200
 weGetLittleEndian = 0x00000400
+weSaveAddResources = 0x00000001
+weSaveCompatibilityResources = 0x00000002
+weSaveLittleEndian = 0x00000004
+kWASTECreator = FOUR_CHAR_CODE('OEDE')
 weTagFontFamily = FOUR_CHAR_CODE('font')
 weTagFontSize = FOUR_CHAR_CODE('ptsz')
 weTagPlain = FOUR_CHAR_CODE('plan')
@@ -107,10 +121,19 @@ weTagShadow = FOUR_CHAR_CODE('shad')
 weTagCondensed = FOUR_CHAR_CODE('cond')
 weTagExtended = FOUR_CHAR_CODE('pexp')
 weTagStrikethrough = FOUR_CHAR_CODE('strk')
+weTagHidden = FOUR_CHAR_CODE('hidn')
+weTagAllCaps = FOUR_CHAR_CODE('alcp')
+weTagAllLowercase = FOUR_CHAR_CODE('lowc')
 weTagTextColor = FOUR_CHAR_CODE('colr')
 weTagBackgroundColor = FOUR_CHAR_CODE('pbcl')
 weTagTransferMode = FOUR_CHAR_CODE('pptm')
 weTagVerticalShift = FOUR_CHAR_CODE('xshf')
+weTagLanguage = FOUR_CHAR_CODE('lang')
+weTagUnderlineStyle = FOUR_CHAR_CODE('unds')
+weTagSmallCaps = FOUR_CHAR_CODE('smcp')
+weTagDoubleStrikethrough = FOUR_CHAR_CODE('dstr')
+weTagEmbossed = FOUR_CHAR_CODE('embo')
+weTagEngraved = FOUR_CHAR_CODE('engr')
 weTagAlignment = FOUR_CHAR_CODE('pjst')
 weTagDirection = FOUR_CHAR_CODE('LDIR')
 weTagLineSpacing = FOUR_CHAR_CODE('ledg')
@@ -119,28 +142,66 @@ weTagRightIndent = FOUR_CHAR_CODE('riin')
 weTagFirstLineIndent = FOUR_CHAR_CODE('fidt')
 weTagSpaceBefore = FOUR_CHAR_CODE('spbe')
 weTagSpaceAfter = FOUR_CHAR_CODE('spaf')
+weTagTabList = FOUR_CHAR_CODE('tabs')
 weTagBottomBorderStyle = FOUR_CHAR_CODE('BBRD')
+weTagKeepTogether = FOUR_CHAR_CODE('keep')
+weTagKeepWithNext = FOUR_CHAR_CODE('kepn')
+weTagPageBreakBefore = FOUR_CHAR_CODE('pbrb')
+weTagWidowOrphanOverride = FOUR_CHAR_CODE('wdov')
+weTagWidowOrphanControl = FOUR_CHAR_CODE('wido')
+weTagNoLineNumbering = FOUR_CHAR_CODE('!ln#')
+weTagNoHyphenation = FOUR_CHAR_CODE('!hyp')
+weTagParagraphUserData = FOUR_CHAR_CODE('pusr')
 weTagForceFontFamily = FOUR_CHAR_CODE('ffnt')
 weTagAddFontSize = FOUR_CHAR_CODE('+siz')
 weTagAddVerticalShift = FOUR_CHAR_CODE('+shf')
+weTagAddLeftIndent = FOUR_CHAR_CODE('+lei')
+weTagAddRightIndent = FOUR_CHAR_CODE('+rii')
+weTagAddFirstLineIndent = FOUR_CHAR_CODE('+fid')
+weTagAddSpaceBefore = FOUR_CHAR_CODE('+spb')
+weTagAddSpaceAfter = FOUR_CHAR_CODE('+spa')
+weTagAddLineSpacing = FOUR_CHAR_CODE('+led')
 weTagTextEncoding = FOUR_CHAR_CODE('ptxe')
 weTagQDStyles = FOUR_CHAR_CODE('qdst')
 weTagTETextStyle = FOUR_CHAR_CODE('tets')
+weTagRunDirection = FOUR_CHAR_CODE('rdir')
+weTagUnderlineDefault = FOUR_CHAR_CODE('deft')
+weTagUnderlineWord = FOUR_CHAR_CODE('word')
+weTagUnderlineDouble = FOUR_CHAR_CODE('dubl')
+weTagUnderlineThick = FOUR_CHAR_CODE('thck')
+weTagUnderlineDash = FOUR_CHAR_CODE('-   ')
+weTagUnderlineDot = FOUR_CHAR_CODE('.   ')
+weTagUnderlineDotDash = FOUR_CHAR_CODE('.-  ')
+weTagUnderlineDotDotDash = FOUR_CHAR_CODE('..- ')
+weTagUnderlineWave = FOUR_CHAR_CODE('wave')
 weTagAlignmentDefault = FOUR_CHAR_CODE('deft')
 weTagAlignmentLeft = FOUR_CHAR_CODE('left')
 weTagAlignmentCenter = FOUR_CHAR_CODE('cent')
 weTagAlignmentRight = FOUR_CHAR_CODE('rght')
 weTagAlignmentFull = FOUR_CHAR_CODE('full')
+weTagAlignmentDecimal = FOUR_CHAR_CODE('decm')
 weTagDirectionDefault = FOUR_CHAR_CODE('deft')
 weTagDirectionLeftToRight = FOUR_CHAR_CODE('L->R')
 weTagDirectionRightToLeft = FOUR_CHAR_CODE('R->L')
+weTagLeaderNone = FOUR_CHAR_CODE('NONE')
+weTagLeaderDots = FOUR_CHAR_CODE('DOTS')
+weTagLeaderHyphens = FOUR_CHAR_CODE('HYPH')
+weTagLeaderUnderline = FOUR_CHAR_CODE('UNDL')
+weTagLeaderThickLine = FOUR_CHAR_CODE('THKL')
+weTagLeaderEqualSigns = FOUR_CHAR_CODE('=   ')
 weTagBorderStyleNone = FOUR_CHAR_CODE('NONE')
 weTagBorderStyleThin = FOUR_CHAR_CODE('SLDL')
 weTagBorderStyleDotted = FOUR_CHAR_CODE('DTDL')
 weTagBorderStyleThick = FOUR_CHAR_CODE('THKL')
+weTagLineSpacingAbsolute = FOUR_CHAR_CODE('abso')
+weTagLineSpacingAtLeast = FOUR_CHAR_CODE('atle')
+weTagLineSpacingRelative = FOUR_CHAR_CODE('rele')
 weLineSpacingSingle = 0x00000000
 weLineSpacingOneAndHalf = 0x00008000
 weLineSpacingDouble = 0x00010000
+weAutoScrollDelay = FOUR_CHAR_CODE('ausd')
+weBusyProc = FOUR_CHAR_CODE('busy')
+weBusyInterval = FOUR_CHAR_CODE('bzin')
 weCharByteHook = FOUR_CHAR_CODE('cbyt')
 weCharToPixelHook = FOUR_CHAR_CODE('c2p ')
 weCharTypeHook = FOUR_CHAR_CODE('ctyp')
@@ -165,6 +226,7 @@ weTranslucencyThreshold = FOUR_CHAR_CODE('tluc')
 weTSMDocumentID = FOUR_CHAR_CODE('tsmd')
 weTSMPreUpdate = FOUR_CHAR_CODE('pre ')
 weTSMPostUpdate = FOUR_CHAR_CODE('post')
+weUndoProc = FOUR_CHAR_CODE('undo')
 weURLHint = FOUR_CHAR_CODE('urlh')
 weWordBreakHook = FOUR_CHAR_CODE('wbrk')
 weNewHandler = FOUR_CHAR_CODE('new ')
@@ -184,6 +246,8 @@ kTypeStyleScrap = FOUR_CHAR_CODE('WEst')
 kTypeUnicodeText = FOUR_CHAR_CODE('utxt')
 kTypeUTF8Text = FOUR_CHAR_CODE('UTF8')
 kTypeStyledText = FOUR_CHAR_CODE('STXT')
+kTypeRTF = FOUR_CHAR_CODE('RTF ')
+kTypeRTFD = FOUR_CHAR_CODE('RTFD')
 weAKNone = 0
 weAKUnspecified = 1
 weAKTyping = 2
@@ -197,11 +261,30 @@ weAKBackspace = 9
 weAKFwdDelete = 10
 weAKCaseChange = 11
 weAKObjectChange = 12
+weUndoNewAction = 0
+weUndoNewSubAction = 1
+weUndoBeginSequence = 2
 weToScrap = 0
 weToDrag = 1
 weToSoup = 2
 weMouseEnter = 0
 weMouseWithin = 1
 weMouseLeave = 2
+weBusyRecalBreaks = 0
+weCreatorDocumentInfo = FOUR_CHAR_CODE('Info')
+weTagDocumentTitle = FOUR_CHAR_CODE('Titl')
+weTagDocumentSubject = FOUR_CHAR_CODE('Subj')
+weTagDocumentAuthor = FOUR_CHAR_CODE('Auth')
+weTagDocumentManager = FOUR_CHAR_CODE('Mngr')
+weTagDocumentCompany = FOUR_CHAR_CODE('Cmpy')
+weTagDocumentCategory = FOUR_CHAR_CODE('Ctgy')
+weTagDocumentKeywords = FOUR_CHAR_CODE('Keyw')
+weTagDocumentComments = FOUR_CHAR_CODE('Cmnt')
+weTagDocumentOperator = FOUR_CHAR_CODE('Oper')
+weTagDocumentBaseAddress = FOUR_CHAR_CODE('Hlnk')
+weTagPageInfo = FOUR_CHAR_CODE('Page')
+weTagMacPrintRecord = FOUR_CHAR_CODE('PRec')
 kCurrentSelection = -1
 kNullStyle = -2
+kMaxTabCount = 20
+kMaxLanguageTagSize = 32
diff --git a/Mac/Modules/osa/_OSAmodule.c b/Mac/Modules/osa/_OSAmodule.c
new file mode 100644 (file)
index 0000000..aceded4
--- /dev/null
@@ -0,0 +1,1226 @@
+
+/* ========================== Module _OSA =========================== */
+
+#include "Python.h"
+
+
+
+#include "pymactoolbox.h"
+
+/* Macro to test whether a weak-loaded CFM function exists */
+#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
+        PyErr_SetString(PyExc_NotImplementedError, \
+        "Not available in this shared library/OS version"); \
+        return NULL; \
+    }} while(0)
+
+
+#include <Carbon/Carbon.h>
+
+#ifdef USE_TOOLBOX_OBJECT_GLUE
+extern PyObject *_OSAObj_New(ComponentInstance);
+extern int _OSAObj_Convert(PyObject *, ComponentInstance *);
+
+#define OSAObj_New _OSAObj_New
+#define OSAObj_Convert _OSAObj_Convert
+#endif
+
+static PyObject *OSA_Error;
+
+/* ----------------- Object type ComponentInstance ------------------ */
+
+PyTypeObject ComponentInstance_Type;
+
+#define OSAObj_Check(x) ((x)->ob_type == &ComponentInstance_Type || PyObject_TypeCheck((x), &ComponentInstance_Type))
+
+typedef struct ComponentInstanceObject {
+       PyObject_HEAD
+       ComponentInstance ob_itself;
+} ComponentInstanceObject;
+
+PyObject *OSAObj_New(ComponentInstance itself)
+{
+       ComponentInstanceObject *it;
+       if (itself == NULL) {
+                                               PyErr_SetString(OSA_Error,"NULL ComponentInstance");
+                                               return NULL;
+                                       }
+       it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type);
+       if (it == NULL) return NULL;
+       it->ob_itself = itself;
+       return (PyObject *)it;
+}
+int OSAObj_Convert(PyObject *v, ComponentInstance *p_itself)
+{
+       if (!OSAObj_Check(v))
+       {
+               PyErr_SetString(PyExc_TypeError, "ComponentInstance required");
+               return 0;
+       }
+       *p_itself = ((ComponentInstanceObject *)v)->ob_itself;
+       return 1;
+}
+
+static void OSAObj_dealloc(ComponentInstanceObject *self)
+{
+       /* Cleanup of self->ob_itself goes here */
+       self->ob_type->tp_free((PyObject *)self);
+}
+
+static PyObject *OSAObj_OSALoad(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc scriptData;
+       long modeFlags;
+       OSAID resultingScriptID;
+#ifndef OSALoad
+       PyMac_PRECHECK(OSALoad);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&l",
+                             AEDesc_Convert, &scriptData,
+                             &modeFlags))
+               return NULL;
+       _err = OSALoad(_self->ob_itself,
+                      &scriptData,
+                      modeFlags,
+                      &resultingScriptID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            resultingScriptID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAStore(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID scriptID;
+       DescType desiredType;
+       long modeFlags;
+       AEDesc resultingScriptData;
+#ifndef OSAStore
+       PyMac_PRECHECK(OSAStore);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&l",
+                             &scriptID,
+                             PyMac_GetOSType, &desiredType,
+                             &modeFlags))
+               return NULL;
+       _err = OSAStore(_self->ob_itself,
+                       scriptID,
+                       desiredType,
+                       modeFlags,
+                       &resultingScriptData);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingScriptData);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAExecute(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID compiledScriptID;
+       OSAID contextID;
+       long modeFlags;
+       OSAID resultingScriptValueID;
+#ifndef OSAExecute
+       PyMac_PRECHECK(OSAExecute);
+#endif
+       if (!PyArg_ParseTuple(_args, "lll",
+                             &compiledScriptID,
+                             &contextID,
+                             &modeFlags))
+               return NULL;
+       _err = OSAExecute(_self->ob_itself,
+                         compiledScriptID,
+                         contextID,
+                         modeFlags,
+                         &resultingScriptValueID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            resultingScriptValueID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADisplay(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID scriptValueID;
+       DescType desiredType;
+       long modeFlags;
+       AEDesc resultingText;
+#ifndef OSADisplay
+       PyMac_PRECHECK(OSADisplay);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&l",
+                             &scriptValueID,
+                             PyMac_GetOSType, &desiredType,
+                             &modeFlags))
+               return NULL;
+       _err = OSADisplay(_self->ob_itself,
+                         scriptValueID,
+                         desiredType,
+                         modeFlags,
+                         &resultingText);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingText);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAScriptError(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSType selector;
+       DescType desiredType;
+       AEDesc resultingErrorDescription;
+#ifndef OSAScriptError
+       PyMac_PRECHECK(OSAScriptError);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&O&",
+                             PyMac_GetOSType, &selector,
+                             PyMac_GetOSType, &desiredType))
+               return NULL;
+       _err = OSAScriptError(_self->ob_itself,
+                             selector,
+                             desiredType,
+                             &resultingErrorDescription);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingErrorDescription);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADispose(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID scriptID;
+#ifndef OSADispose
+       PyMac_PRECHECK(OSADispose);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &scriptID))
+               return NULL;
+       _err = OSADispose(_self->ob_itself,
+                         scriptID);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSASetScriptInfo(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID scriptID;
+       OSType selector;
+       long value;
+#ifndef OSASetScriptInfo
+       PyMac_PRECHECK(OSASetScriptInfo);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&l",
+                             &scriptID,
+                             PyMac_GetOSType, &selector,
+                             &value))
+               return NULL;
+       _err = OSASetScriptInfo(_self->ob_itself,
+                               scriptID,
+                               selector,
+                               value);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSAGetScriptInfo(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID scriptID;
+       OSType selector;
+       long result;
+#ifndef OSAGetScriptInfo
+       PyMac_PRECHECK(OSAGetScriptInfo);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&",
+                             &scriptID,
+                             PyMac_GetOSType, &selector))
+               return NULL;
+       _err = OSAGetScriptInfo(_self->ob_itself,
+                               scriptID,
+                               selector,
+                               &result);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            result);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAScriptingComponentName(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc resultingScriptingComponentName;
+#ifndef OSAScriptingComponentName
+       PyMac_PRECHECK(OSAScriptingComponentName);
+#endif
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _err = OSAScriptingComponentName(_self->ob_itself,
+                                        &resultingScriptingComponentName);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingScriptingComponentName);
+       return _res;
+}
+
+static PyObject *OSAObj_OSACompile(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc sourceData;
+       long modeFlags;
+       OSAID previousAndResultingScriptID;
+#ifndef OSACompile
+       PyMac_PRECHECK(OSACompile);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&l",
+                             AEDesc_Convert, &sourceData,
+                             &modeFlags))
+               return NULL;
+       _err = OSACompile(_self->ob_itself,
+                         &sourceData,
+                         modeFlags,
+                         &previousAndResultingScriptID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            previousAndResultingScriptID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSACopyID(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID fromID;
+       OSAID toID;
+#ifndef OSACopyID
+       PyMac_PRECHECK(OSACopyID);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &fromID))
+               return NULL;
+       _err = OSACopyID(_self->ob_itself,
+                        fromID,
+                        &toID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            toID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAGetSource(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID scriptID;
+       DescType desiredType;
+       AEDesc resultingSourceData;
+#ifndef OSAGetSource
+       PyMac_PRECHECK(OSAGetSource);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&",
+                             &scriptID,
+                             PyMac_GetOSType, &desiredType))
+               return NULL;
+       _err = OSAGetSource(_self->ob_itself,
+                           scriptID,
+                           desiredType,
+                           &resultingSourceData);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingSourceData);
+       return _res;
+}
+
+static PyObject *OSAObj_OSACoerceFromDesc(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc scriptData;
+       long modeFlags;
+       OSAID resultingScriptID;
+#ifndef OSACoerceFromDesc
+       PyMac_PRECHECK(OSACoerceFromDesc);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&l",
+                             AEDesc_Convert, &scriptData,
+                             &modeFlags))
+               return NULL;
+       _err = OSACoerceFromDesc(_self->ob_itself,
+                                &scriptData,
+                                modeFlags,
+                                &resultingScriptID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            resultingScriptID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSACoerceToDesc(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID scriptID;
+       DescType desiredType;
+       long modeFlags;
+       AEDesc result;
+#ifndef OSACoerceToDesc
+       PyMac_PRECHECK(OSACoerceToDesc);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&l",
+                             &scriptID,
+                             PyMac_GetOSType, &desiredType,
+                             &modeFlags))
+               return NULL;
+       _err = OSACoerceToDesc(_self->ob_itself,
+                              scriptID,
+                              desiredType,
+                              modeFlags,
+                              &result);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &result);
+       return _res;
+}
+
+static PyObject *OSAObj_OSASetDefaultTarget(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEAddressDesc target;
+#ifndef OSASetDefaultTarget
+       PyMac_PRECHECK(OSASetDefaultTarget);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&",
+                             AEDesc_Convert, &target))
+               return NULL;
+       _err = OSASetDefaultTarget(_self->ob_itself,
+                                  &target);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSAStartRecording(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID compiledScriptToModifyID;
+#ifndef OSAStartRecording
+       PyMac_PRECHECK(OSAStartRecording);
+#endif
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _err = OSAStartRecording(_self->ob_itself,
+                                &compiledScriptToModifyID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            compiledScriptToModifyID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAStopRecording(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID compiledScriptID;
+#ifndef OSAStopRecording
+       PyMac_PRECHECK(OSAStopRecording);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &compiledScriptID))
+               return NULL;
+       _err = OSAStopRecording(_self->ob_itself,
+                               compiledScriptID);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSALoadExecute(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc scriptData;
+       OSAID contextID;
+       long modeFlags;
+       OSAID resultingScriptValueID;
+#ifndef OSALoadExecute
+       PyMac_PRECHECK(OSALoadExecute);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&ll",
+                             AEDesc_Convert, &scriptData,
+                             &contextID,
+                             &modeFlags))
+               return NULL;
+       _err = OSALoadExecute(_self->ob_itself,
+                             &scriptData,
+                             contextID,
+                             modeFlags,
+                             &resultingScriptValueID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            resultingScriptValueID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSACompileExecute(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc sourceData;
+       OSAID contextID;
+       long modeFlags;
+       OSAID resultingScriptValueID;
+#ifndef OSACompileExecute
+       PyMac_PRECHECK(OSACompileExecute);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&ll",
+                             AEDesc_Convert, &sourceData,
+                             &contextID,
+                             &modeFlags))
+               return NULL;
+       _err = OSACompileExecute(_self->ob_itself,
+                                &sourceData,
+                                contextID,
+                                modeFlags,
+                                &resultingScriptValueID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            resultingScriptValueID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADoScript(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc sourceData;
+       OSAID contextID;
+       DescType desiredType;
+       long modeFlags;
+       AEDesc resultingText;
+#ifndef OSADoScript
+       PyMac_PRECHECK(OSADoScript);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&lO&l",
+                             AEDesc_Convert, &sourceData,
+                             &contextID,
+                             PyMac_GetOSType, &desiredType,
+                             &modeFlags))
+               return NULL;
+       _err = OSADoScript(_self->ob_itself,
+                          &sourceData,
+                          contextID,
+                          desiredType,
+                          modeFlags,
+                          &resultingText);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingText);
+       return _res;
+}
+
+static PyObject *OSAObj_OSASetCurrentDialect(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       short dialectCode;
+#ifndef OSASetCurrentDialect
+       PyMac_PRECHECK(OSASetCurrentDialect);
+#endif
+       if (!PyArg_ParseTuple(_args, "h",
+                             &dialectCode))
+               return NULL;
+       _err = OSASetCurrentDialect(_self->ob_itself,
+                                   dialectCode);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSAGetCurrentDialect(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       short resultingDialectCode;
+#ifndef OSAGetCurrentDialect
+       PyMac_PRECHECK(OSAGetCurrentDialect);
+#endif
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _err = OSAGetCurrentDialect(_self->ob_itself,
+                                   &resultingDialectCode);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("h",
+                            resultingDialectCode);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAAvailableDialects(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc resultingDialectInfoList;
+#ifndef OSAAvailableDialects
+       PyMac_PRECHECK(OSAAvailableDialects);
+#endif
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _err = OSAAvailableDialects(_self->ob_itself,
+                                   &resultingDialectInfoList);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingDialectInfoList);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAGetDialectInfo(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       short dialectCode;
+       OSType selector;
+       AEDesc resultingDialectInfo;
+#ifndef OSAGetDialectInfo
+       PyMac_PRECHECK(OSAGetDialectInfo);
+#endif
+       if (!PyArg_ParseTuple(_args, "hO&",
+                             &dialectCode,
+                             PyMac_GetOSType, &selector))
+               return NULL;
+       _err = OSAGetDialectInfo(_self->ob_itself,
+                                dialectCode,
+                                selector,
+                                &resultingDialectInfo);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingDialectInfo);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAAvailableDialectCodeList(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc resultingDialectCodeList;
+#ifndef OSAAvailableDialectCodeList
+       PyMac_PRECHECK(OSAAvailableDialectCodeList);
+#endif
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _err = OSAAvailableDialectCodeList(_self->ob_itself,
+                                          &resultingDialectCodeList);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &resultingDialectCodeList);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAExecuteEvent(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AppleEvent theAppleEvent;
+       OSAID contextID;
+       long modeFlags;
+       OSAID resultingScriptValueID;
+#ifndef OSAExecuteEvent
+       PyMac_PRECHECK(OSAExecuteEvent);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&ll",
+                             AEDesc_Convert, &theAppleEvent,
+                             &contextID,
+                             &modeFlags))
+               return NULL;
+       _err = OSAExecuteEvent(_self->ob_itself,
+                              &theAppleEvent,
+                              contextID,
+                              modeFlags,
+                              &resultingScriptValueID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            resultingScriptValueID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADoEvent(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AppleEvent theAppleEvent;
+       OSAID contextID;
+       long modeFlags;
+       AppleEvent reply;
+#ifndef OSADoEvent
+       PyMac_PRECHECK(OSADoEvent);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&ll",
+                             AEDesc_Convert, &theAppleEvent,
+                             &contextID,
+                             &modeFlags))
+               return NULL;
+       _err = OSADoEvent(_self->ob_itself,
+                         &theAppleEvent,
+                         contextID,
+                         modeFlags,
+                         &reply);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &reply);
+       return _res;
+}
+
+static PyObject *OSAObj_OSAMakeContext(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       AEDesc contextName;
+       OSAID parentContext;
+       OSAID resultingContextID;
+#ifndef OSAMakeContext
+       PyMac_PRECHECK(OSAMakeContext);
+#endif
+       if (!PyArg_ParseTuple(_args, "O&l",
+                             AEDesc_Convert, &contextName,
+                             &parentContext))
+               return NULL;
+       _err = OSAMakeContext(_self->ob_itself,
+                             &contextName,
+                             parentContext,
+                             &resultingContextID);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            resultingContextID);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerCreateSession(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSAID inScript;
+       OSAID inContext;
+       OSADebugSessionRef outSession;
+#ifndef OSADebuggerCreateSession
+       PyMac_PRECHECK(OSADebuggerCreateSession);
+#endif
+       if (!PyArg_ParseTuple(_args, "ll",
+                             &inScript,
+                             &inContext))
+               return NULL;
+       _err = OSADebuggerCreateSession(_self->ob_itself,
+                                       inScript,
+                                       inContext,
+                                       &outSession);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            outSession);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetSessionState(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+       AERecord outState;
+#ifndef OSADebuggerGetSessionState
+       PyMac_PRECHECK(OSADebuggerGetSessionState);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inSession))
+               return NULL;
+       _err = OSADebuggerGetSessionState(_self->ob_itself,
+                                         inSession,
+                                         &outState);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &outState);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerSessionStep(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+       OSADebugStepKind inKind;
+#ifndef OSADebuggerSessionStep
+       PyMac_PRECHECK(OSADebuggerSessionStep);
+#endif
+       if (!PyArg_ParseTuple(_args, "ll",
+                             &inSession,
+                             &inKind))
+               return NULL;
+       _err = OSADebuggerSessionStep(_self->ob_itself,
+                                     inSession,
+                                     inKind);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerDisposeSession(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+#ifndef OSADebuggerDisposeSession
+       PyMac_PRECHECK(OSADebuggerDisposeSession);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inSession))
+               return NULL;
+       _err = OSADebuggerDisposeSession(_self->ob_itself,
+                                        inSession);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetStatementRanges(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+       AEDescList outStatementRangeArray;
+#ifndef OSADebuggerGetStatementRanges
+       PyMac_PRECHECK(OSADebuggerGetStatementRanges);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inSession))
+               return NULL;
+       _err = OSADebuggerGetStatementRanges(_self->ob_itself,
+                                            inSession,
+                                            &outStatementRangeArray);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &outStatementRangeArray);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetBreakpoint(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+       UInt32 inSrcOffset;
+       OSAID outBreakpoint;
+#ifndef OSADebuggerGetBreakpoint
+       PyMac_PRECHECK(OSADebuggerGetBreakpoint);
+#endif
+       if (!PyArg_ParseTuple(_args, "ll",
+                             &inSession,
+                             &inSrcOffset))
+               return NULL;
+       _err = OSADebuggerGetBreakpoint(_self->ob_itself,
+                                       inSession,
+                                       inSrcOffset,
+                                       &outBreakpoint);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            outBreakpoint);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerSetBreakpoint(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+       UInt32 inSrcOffset;
+       OSAID inBreakpoint;
+#ifndef OSADebuggerSetBreakpoint
+       PyMac_PRECHECK(OSADebuggerSetBreakpoint);
+#endif
+       if (!PyArg_ParseTuple(_args, "lll",
+                             &inSession,
+                             &inSrcOffset,
+                             &inBreakpoint))
+               return NULL;
+       _err = OSADebuggerSetBreakpoint(_self->ob_itself,
+                                       inSession,
+                                       inSrcOffset,
+                                       inBreakpoint);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetDefaultBreakpoint(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+       OSAID outBreakpoint;
+#ifndef OSADebuggerGetDefaultBreakpoint
+       PyMac_PRECHECK(OSADebuggerGetDefaultBreakpoint);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inSession))
+               return NULL;
+       _err = OSADebuggerGetDefaultBreakpoint(_self->ob_itself,
+                                              inSession,
+                                              &outBreakpoint);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            outBreakpoint);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetCurrentCallFrame(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugSessionRef inSession;
+       OSADebugCallFrameRef outCallFrame;
+#ifndef OSADebuggerGetCurrentCallFrame
+       PyMac_PRECHECK(OSADebuggerGetCurrentCallFrame);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inSession))
+               return NULL;
+       _err = OSADebuggerGetCurrentCallFrame(_self->ob_itself,
+                                             inSession,
+                                             &outCallFrame);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            outCallFrame);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetCallFrameState(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugCallFrameRef inCallFrame;
+       AERecord outState;
+#ifndef OSADebuggerGetCallFrameState
+       PyMac_PRECHECK(OSADebuggerGetCallFrameState);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inCallFrame))
+               return NULL;
+       _err = OSADebuggerGetCallFrameState(_self->ob_itself,
+                                           inCallFrame,
+                                           &outState);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("O&",
+                            AEDesc_New, &outState);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetVariable(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugCallFrameRef inCallFrame;
+       AEDesc inVariableName;
+       OSAID outVariable;
+#ifndef OSADebuggerGetVariable
+       PyMac_PRECHECK(OSADebuggerGetVariable);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&",
+                             &inCallFrame,
+                             AEDesc_Convert, &inVariableName))
+               return NULL;
+       _err = OSADebuggerGetVariable(_self->ob_itself,
+                                     inCallFrame,
+                                     &inVariableName,
+                                     &outVariable);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            outVariable);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerSetVariable(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugCallFrameRef inCallFrame;
+       AEDesc inVariableName;
+       OSAID inVariable;
+#ifndef OSADebuggerSetVariable
+       PyMac_PRECHECK(OSADebuggerSetVariable);
+#endif
+       if (!PyArg_ParseTuple(_args, "lO&l",
+                             &inCallFrame,
+                             AEDesc_Convert, &inVariableName,
+                             &inVariable))
+               return NULL;
+       _err = OSADebuggerSetVariable(_self->ob_itself,
+                                     inCallFrame,
+                                     &inVariableName,
+                                     inVariable);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerGetPreviousCallFrame(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugCallFrameRef inCurrentFrame;
+       OSADebugCallFrameRef outPrevFrame;
+#ifndef OSADebuggerGetPreviousCallFrame
+       PyMac_PRECHECK(OSADebuggerGetPreviousCallFrame);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inCurrentFrame))
+               return NULL;
+       _err = OSADebuggerGetPreviousCallFrame(_self->ob_itself,
+                                              inCurrentFrame,
+                                              &outPrevFrame);
+       if (_err != noErr) return PyMac_Error(_err);
+       _res = Py_BuildValue("l",
+                            outPrevFrame);
+       return _res;
+}
+
+static PyObject *OSAObj_OSADebuggerDisposeCallFrame(ComponentInstanceObject *_self, PyObject *_args)
+{
+       PyObject *_res = NULL;
+       OSAError _err;
+       OSADebugCallFrameRef inCallFrame;
+#ifndef OSADebuggerDisposeCallFrame
+       PyMac_PRECHECK(OSADebuggerDisposeCallFrame);
+#endif
+       if (!PyArg_ParseTuple(_args, "l",
+                             &inCallFrame))
+               return NULL;
+       _err = OSADebuggerDisposeCallFrame(_self->ob_itself,
+                                          inCallFrame);
+       if (_err != noErr) return PyMac_Error(_err);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyMethodDef OSAObj_methods[] = {
+       {"OSALoad", (PyCFunction)OSAObj_OSALoad, 1,
+        PyDoc_STR("(AEDesc scriptData, long modeFlags) -> (OSAID resultingScriptID)")},
+       {"OSAStore", (PyCFunction)OSAObj_OSAStore, 1,
+        PyDoc_STR("(OSAID scriptID, DescType desiredType, long modeFlags) -> (AEDesc resultingScriptData)")},
+       {"OSAExecute", (PyCFunction)OSAObj_OSAExecute, 1,
+        PyDoc_STR("(OSAID compiledScriptID, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")},
+       {"OSADisplay", (PyCFunction)OSAObj_OSADisplay, 1,
+        PyDoc_STR("(OSAID scriptValueID, DescType desiredType, long modeFlags) -> (AEDesc resultingText)")},
+       {"OSAScriptError", (PyCFunction)OSAObj_OSAScriptError, 1,
+        PyDoc_STR("(OSType selector, DescType desiredType) -> (AEDesc resultingErrorDescription)")},
+       {"OSADispose", (PyCFunction)OSAObj_OSADispose, 1,
+        PyDoc_STR("(OSAID scriptID) -> None")},
+       {"OSASetScriptInfo", (PyCFunction)OSAObj_OSASetScriptInfo, 1,
+        PyDoc_STR("(OSAID scriptID, OSType selector, long value) -> None")},
+       {"OSAGetScriptInfo", (PyCFunction)OSAObj_OSAGetScriptInfo, 1,
+        PyDoc_STR("(OSAID scriptID, OSType selector) -> (long result)")},
+       {"OSAScriptingComponentName", (PyCFunction)OSAObj_OSAScriptingComponentName, 1,
+        PyDoc_STR("() -> (AEDesc resultingScriptingComponentName)")},
+       {"OSACompile", (PyCFunction)OSAObj_OSACompile, 1,
+        PyDoc_STR("(AEDesc sourceData, long modeFlags) -> (OSAID previousAndResultingScriptID)")},
+       {"OSACopyID", (PyCFunction)OSAObj_OSACopyID, 1,
+        PyDoc_STR("(OSAID fromID) -> (OSAID toID)")},
+       {"OSAGetSource", (PyCFunction)OSAObj_OSAGetSource, 1,
+        PyDoc_STR("(OSAID scriptID, DescType desiredType) -> (AEDesc resultingSourceData)")},
+       {"OSACoerceFromDesc", (PyCFunction)OSAObj_OSACoerceFromDesc, 1,
+        PyDoc_STR("(AEDesc scriptData, long modeFlags) -> (OSAID resultingScriptID)")},
+       {"OSACoerceToDesc", (PyCFunction)OSAObj_OSACoerceToDesc, 1,
+        PyDoc_STR("(OSAID scriptID, DescType desiredType, long modeFlags) -> (AEDesc result)")},
+       {"OSASetDefaultTarget", (PyCFunction)OSAObj_OSASetDefaultTarget, 1,
+        PyDoc_STR("(AEAddressDesc target) -> None")},
+       {"OSAStartRecording", (PyCFunction)OSAObj_OSAStartRecording, 1,
+        PyDoc_STR("() -> (OSAID compiledScriptToModifyID)")},
+       {"OSAStopRecording", (PyCFunction)OSAObj_OSAStopRecording, 1,
+        PyDoc_STR("(OSAID compiledScriptID) -> None")},
+       {"OSALoadExecute", (PyCFunction)OSAObj_OSALoadExecute, 1,
+        PyDoc_STR("(AEDesc scriptData, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")},
+       {"OSACompileExecute", (PyCFunction)OSAObj_OSACompileExecute, 1,
+        PyDoc_STR("(AEDesc sourceData, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")},
+       {"OSADoScript", (PyCFunction)OSAObj_OSADoScript, 1,
+        PyDoc_STR("(AEDesc sourceData, OSAID contextID, DescType desiredType, long modeFlags) -> (AEDesc resultingText)")},
+       {"OSASetCurrentDialect", (PyCFunction)OSAObj_OSASetCurrentDialect, 1,
+        PyDoc_STR("(short dialectCode) -> None")},
+       {"OSAGetCurrentDialect", (PyCFunction)OSAObj_OSAGetCurrentDialect, 1,
+        PyDoc_STR("() -> (short resultingDialectCode)")},
+       {"OSAAvailableDialects", (PyCFunction)OSAObj_OSAAvailableDialects, 1,
+        PyDoc_STR("() -> (AEDesc resultingDialectInfoList)")},
+       {"OSAGetDialectInfo", (PyCFunction)OSAObj_OSAGetDialectInfo, 1,
+        PyDoc_STR("(short dialectCode, OSType selector) -> (AEDesc resultingDialectInfo)")},
+       {"OSAAvailableDialectCodeList", (PyCFunction)OSAObj_OSAAvailableDialectCodeList, 1,
+        PyDoc_STR("() -> (AEDesc resultingDialectCodeList)")},
+       {"OSAExecuteEvent", (PyCFunction)OSAObj_OSAExecuteEvent, 1,
+        PyDoc_STR("(AppleEvent theAppleEvent, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")},
+       {"OSADoEvent", (PyCFunction)OSAObj_OSADoEvent, 1,
+        PyDoc_STR("(AppleEvent theAppleEvent, OSAID contextID, long modeFlags) -> (AppleEvent reply)")},
+       {"OSAMakeContext", (PyCFunction)OSAObj_OSAMakeContext, 1,
+        PyDoc_STR("(AEDesc contextName, OSAID parentContext) -> (OSAID resultingContextID)")},
+       {"OSADebuggerCreateSession", (PyCFunction)OSAObj_OSADebuggerCreateSession, 1,
+        PyDoc_STR("(OSAID inScript, OSAID inContext) -> (OSADebugSessionRef outSession)")},
+       {"OSADebuggerGetSessionState", (PyCFunction)OSAObj_OSADebuggerGetSessionState, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession) -> (AERecord outState)")},
+       {"OSADebuggerSessionStep", (PyCFunction)OSAObj_OSADebuggerSessionStep, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession, OSADebugStepKind inKind) -> None")},
+       {"OSADebuggerDisposeSession", (PyCFunction)OSAObj_OSADebuggerDisposeSession, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession) -> None")},
+       {"OSADebuggerGetStatementRanges", (PyCFunction)OSAObj_OSADebuggerGetStatementRanges, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession) -> (AEDescList outStatementRangeArray)")},
+       {"OSADebuggerGetBreakpoint", (PyCFunction)OSAObj_OSADebuggerGetBreakpoint, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession, UInt32 inSrcOffset) -> (OSAID outBreakpoint)")},
+       {"OSADebuggerSetBreakpoint", (PyCFunction)OSAObj_OSADebuggerSetBreakpoint, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession, UInt32 inSrcOffset, OSAID inBreakpoint) -> None")},
+       {"OSADebuggerGetDefaultBreakpoint", (PyCFunction)OSAObj_OSADebuggerGetDefaultBreakpoint, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession) -> (OSAID outBreakpoint)")},
+       {"OSADebuggerGetCurrentCallFrame", (PyCFunction)OSAObj_OSADebuggerGetCurrentCallFrame, 1,
+        PyDoc_STR("(OSADebugSessionRef inSession) -> (OSADebugCallFrameRef outCallFrame)")},
+       {"OSADebuggerGetCallFrameState", (PyCFunction)OSAObj_OSADebuggerGetCallFrameState, 1,
+        PyDoc_STR("(OSADebugCallFrameRef inCallFrame) -> (AERecord outState)")},
+       {"OSADebuggerGetVariable", (PyCFunction)OSAObj_OSADebuggerGetVariable, 1,
+        PyDoc_STR("(OSADebugCallFrameRef inCallFrame, AEDesc inVariableName) -> (OSAID outVariable)")},
+       {"OSADebuggerSetVariable", (PyCFunction)OSAObj_OSADebuggerSetVariable, 1,
+        PyDoc_STR("(OSADebugCallFrameRef inCallFrame, AEDesc inVariableName, OSAID inVariable) -> None")},
+       {"OSADebuggerGetPreviousCallFrame", (PyCFunction)OSAObj_OSADebuggerGetPreviousCallFrame, 1,
+        PyDoc_STR("(OSADebugCallFrameRef inCurrentFrame) -> (OSADebugCallFrameRef outPrevFrame)")},
+       {"OSADebuggerDisposeCallFrame", (PyCFunction)OSAObj_OSADebuggerDisposeCallFrame, 1,
+        PyDoc_STR("(OSADebugCallFrameRef inCallFrame) -> None")},
+       {NULL, NULL, 0}
+};
+
+#define OSAObj_getsetlist NULL
+
+
+#define OSAObj_compare NULL
+
+#define OSAObj_repr NULL
+
+#define OSAObj_hash NULL
+#define OSAObj_tp_init 0
+
+#define OSAObj_tp_alloc PyType_GenericAlloc
+
+static PyObject *OSAObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+       PyObject *self;
+       ComponentInstance itself;
+       char *kw[] = {"itself", 0};
+
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, OSAObj_Convert, &itself)) return NULL;
+       if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+       ((ComponentInstanceObject *)self)->ob_itself = itself;
+       return self;
+}
+
+#define OSAObj_tp_free PyObject_Del
+
+
+PyTypeObject ComponentInstance_Type = {
+       PyObject_HEAD_INIT(NULL)
+       0, /*ob_size*/
+       "_OSA.ComponentInstance", /*tp_name*/
+       sizeof(ComponentInstanceObject), /*tp_basicsize*/
+       0, /*tp_itemsize*/
+       /* methods */
+       (destructor) OSAObj_dealloc, /*tp_dealloc*/
+       0, /*tp_print*/
+       (getattrfunc)0, /*tp_getattr*/
+       (setattrfunc)0, /*tp_setattr*/
+       (cmpfunc) OSAObj_compare, /*tp_compare*/
+       (reprfunc) OSAObj_repr, /*tp_repr*/
+       (PyNumberMethods *)0, /* tp_as_number */
+       (PySequenceMethods *)0, /* tp_as_sequence */
+       (PyMappingMethods *)0, /* tp_as_mapping */
+       (hashfunc) OSAObj_hash, /*tp_hash*/
+       0, /*tp_call*/
+       0, /*tp_str*/
+       PyObject_GenericGetAttr, /*tp_getattro*/
+       PyObject_GenericSetAttr, /*tp_setattro */
+       0, /*tp_as_buffer*/
+       Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
+       0, /*tp_doc*/
+       0, /*tp_traverse*/
+       0, /*tp_clear*/
+       0, /*tp_richcompare*/
+       0, /*tp_weaklistoffset*/
+       0, /*tp_iter*/
+       0, /*tp_iternext*/
+       OSAObj_methods, /* tp_methods */
+       0, /*tp_members*/
+       OSAObj_getsetlist, /*tp_getset*/
+       0, /*tp_base*/
+       0, /*tp_dict*/
+       0, /*tp_descr_get*/
+       0, /*tp_descr_set*/
+       0, /*tp_dictoffset*/
+       OSAObj_tp_init, /* tp_init */
+       OSAObj_tp_alloc, /* tp_alloc */
+       OSAObj_tp_new, /* tp_new */
+       OSAObj_tp_free, /* tp_free */
+};
+
+/* --------------- End object type ComponentInstance ---------------- */
+
+
+static PyMethodDef OSA_methods[] = {
+       {NULL, NULL, 0}
+};
+
+
+
+
+void init_OSA(void)
+{
+       PyObject *m;
+       PyObject *d;
+
+
+
+       /*
+               PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New);
+               PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert);
+       */
+
+
+       m = Py_InitModule("_OSA", OSA_methods);
+       d = PyModule_GetDict(m);
+       OSA_Error = PyMac_GetOSErrException();
+       if (OSA_Error == NULL ||
+           PyDict_SetItemString(d, "Error", OSA_Error) != 0)
+               return;
+       ComponentInstance_Type.ob_type = &PyType_Type;
+       if (PyType_Ready(&ComponentInstance_Type) < 0) return;
+       Py_INCREF(&ComponentInstance_Type);
+       PyModule_AddObject(m, "ComponentInstance", (PyObject *)&ComponentInstance_Type);
+       /* Backward-compatible name */
+       Py_INCREF(&ComponentInstance_Type);
+       PyModule_AddObject(m, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type);
+}
+
+/* ======================== End module _OSA ========================= */
+
diff --git a/Mac/Modules/osa/osascan.py b/Mac/Modules/osa/osascan.py
new file mode 100644 (file)
index 0000000..ed58fc8
--- /dev/null
@@ -0,0 +1,61 @@
+# Scan an Apple header file, generating a Python file of generator calls.
+
+import sys
+import os
+from bgenlocations import TOOLBOXDIR, BGENDIR
+sys.path.append(BGENDIR)
+from scantools import Scanner
+
+LONG = "OSAconst"
+SHORT = "osa"
+
+def main():
+       input = "OSA.h"
+       output = SHORT + "gen.py"
+       defsoutput = TOOLBOXDIR + LONG + ".py"
+       scanner = MyScanner(input, output, defsoutput)
+       scanner.scan()
+       scanner.close()
+       scanner.gentypetest(SHORT+"typetest.py")
+       print "=== Testing definitions output code ==="
+       execfile(defsoutput, {}, {})
+       print "=== Done scanning and generating, now importing the generated code... ==="
+       exec "import " + SHORT + "support"
+       print "=== Done.  It's up to you to compile it now! ==="
+
+class MyScanner(Scanner):
+
+       def destination(self, type, name, arglist):
+               classname = "Function"
+               listname = "functions"
+               if arglist:
+                       t, n, m = arglist[0]
+                       if t == "ComponentInstance" and m == "InMode":
+                               classname = "Method"
+                               listname = "methods"
+               return classname, listname
+
+       def writeinitialdefs(self):
+               self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+               self.defsfile.write("from Carbon.AppleEvents import *\n")
+               self.defsfile.write("kAEUseStandardDispatch = -1\n")
+
+       def makeblacklistnames(self):
+               return [
+                       "OSACopyScript",
+                       ]
+
+       def makeblacklisttypes(self):
+               return [
+                       "OSACreateAppleEventUPP",
+                       "OSAActiveUPP",
+                       "AEEventHandlerUPP",
+                       "OSASendUPP",
+                       ]
+
+       def makerepairinstructions(self):
+               return [
+                       ]
+                       
+if __name__ == "__main__":
+       main()
diff --git a/Mac/Modules/osa/osasupport.py b/Mac/Modules/osa/osasupport.py
new file mode 100644 (file)
index 0000000..fe687b4
--- /dev/null
@@ -0,0 +1,94 @@
+# This script generates a Python interface for an Apple Macintosh Manager.
+# It uses the "bgen" package to generate C code.
+# The function specifications are generated by scanning the mamager's header file,
+# using the "scantools" package (customized for this particular manager).
+
+import string
+
+# Declarations that change for each manager
+MACHEADERFILE = 'OSA.h'                # The Apple header file
+MODNAME = '_OSA'                               # The name of the module
+
+# The following is *usually* unchanged but may still require tuning
+MODPREFIX = 'OSA'                      # The prefix for module-wide routines
+OBJECTPREFIX = 'OSAObj'        # The prefix for object methods
+INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
+OUTPUTFILE = MODNAME + "module.c"      # The file generated by this program
+
+from macsupport import *
+
+# Create the type objects
+
+includestuff = includestuff + """
+#include <Carbon/Carbon.h>
+
+#ifdef USE_TOOLBOX_OBJECT_GLUE
+extern PyObject *_OSAObj_New(ComponentInstance);
+extern int _OSAObj_Convert(PyObject *, ComponentInstance *);
+
+#define OSAObj_New _OSAObj_New
+#define OSAObj_Convert _OSAObj_Convert
+#endif
+"""
+
+initstuff = initstuff + """
+/*
+       PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New);
+       PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert);
+*/
+"""
+
+ComponentInstance = OpaqueByValueType('ComponentInstance', OBJECTPREFIX)
+OSAError = OSErrType("OSAError", "l")
+OSAID = Type("OSAID", "l")
+OSADebugCallFrameRef = Type("OSADebugCallFrameRef", "l")
+OSADebugSessionRef = Type("OSADebugSessionRef", "l")
+OSADebugStepKind = Type("OSADebugStepKind", "l")
+DescType = OSTypeType("DescType")
+AEDesc = OpaqueType('AEDesc')
+AEDesc_ptr = OpaqueType('AEDesc')
+AEAddressDesc = OpaqueType('AEAddressDesc', 'AEDesc')
+AEAddressDesc_ptr = OpaqueType('AEAddressDesc', 'AEDesc')
+AEDescList = OpaqueType('AEDescList', 'AEDesc')
+AEDescList_ptr = OpaqueType('AEDescList', 'AEDesc')
+AERecord = OpaqueType('AERecord', 'AEDesc')
+AERecord_ptr = OpaqueType('AERecord', 'AEDesc')
+AppleEvent = OpaqueType('AppleEvent', 'AEDesc')
+AppleEvent_ptr = OpaqueType('AppleEvent', 'AEDesc')
+
+# NOTE: at the moment OSA.ComponentInstance is not a subclass
+# of Cm.ComponentInstance. If this is a problem it can be fixed.
+class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
+       def outputCheckNewArg(self):
+               Output("""if (itself == NULL) {
+                                       PyErr_SetString(OSA_Error,"NULL ComponentInstance");
+                                       return NULL;
+                               }""")
+
+# Create the generator groups and link them
+module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
+object = MyObjectDefinition('ComponentInstance', OBJECTPREFIX,
+               'ComponentInstance')
+module.addobject(object)
+
+# Create the generator classes used to populate the lists
+Function = OSErrWeakLinkFunctionGenerator
+Method = OSErrWeakLinkMethodGenerator
+
+# Test which types we are still missing.
+execfile(string.lower(MODPREFIX) + 'typetest.py')
+
+# Create and populate the lists
+functions = []
+methods = []
+execfile(INPUTFILE)
+
+# add the populated lists to the generator groups
+# (in a different wordl the scan program would generate this)
+for f in functions: module.add(f)
+for f in methods: object.add(f)
+
+# generate output (open the output file as late as possible)
+SetOutputFileName(OUTPUTFILE)
+module.generate()
+
index 8c75ddc52c9d3746f280b9403f6da143e9a371cd..2c3eae6873a2a0af8d8446cf11bf5b2e1ed4644b 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -836,6 +836,8 @@ class PyBuildExt(build_ext):
                     extra_link_args=['-framework', 'Carbon']) )
             exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'],
                     extra_link_args=['-framework', 'Carbon']) )
+            exts.append( Extension('_OSA', ['osa/_OSAmodule.c'],
+                    extra_link_args=['-framework', 'Carbon']) )
             exts.append( Extension('_Qd', ['qd/_Qdmodule.c'],
                     extra_link_args=['-framework', 'Carbon']) )
             exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'],