summaryrefslogtreecommitdiffstats
path: root/Mac/Modules
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
commit182b5aca27d376b08a2904bed42b751496f932f3 (patch)
treedf13115820dbc879c0fe2eae488c9f8c0215a7da /Mac/Modules
parente6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff)
downloadcpython-182b5aca27d376b08a2904bed42b751496f932f3.zip
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Mac/Modules')
-rw-r--r--Mac/Modules/ae/aescan.py158
-rw-r--r--Mac/Modules/ae/aesupport.py206
-rw-r--r--Mac/Modules/ah/ahscan.py70
-rw-r--r--Mac/Modules/ah/ahsupport.py9
-rw-r--r--Mac/Modules/app/appscan.py120
-rw-r--r--Mac/Modules/app/appsupport.py43
-rw-r--r--Mac/Modules/carbonevt/CarbonEvtscan.py186
-rw-r--r--Mac/Modules/carbonevt/CarbonEvtsupport.py176
-rw-r--r--Mac/Modules/cf/cfscan.py238
-rw-r--r--Mac/Modules/cf/cfsupport.py577
-rwxr-xr-xMac/Modules/cg/cgscan.py124
-rwxr-xr-xMac/Modules/cg/cgsupport.py99
-rw-r--r--Mac/Modules/cm/cmscan.py138
-rw-r--r--Mac/Modules/cm/cmsupport.py75
-rw-r--r--Mac/Modules/ctl/ctledit.py30
-rw-r--r--Mac/Modules/ctl/ctlscan.py316
-rw-r--r--Mac/Modules/ctl/ctlsupport.py584
-rw-r--r--Mac/Modules/dlg/dlgscan.py192
-rw-r--r--Mac/Modules/dlg/dlgsupport.py288
-rw-r--r--Mac/Modules/drag/dragscan.py114
-rw-r--r--Mac/Modules/drag/dragsupport.py246
-rw-r--r--Mac/Modules/evt/evtedit.py1
-rw-r--r--Mac/Modules/evt/evtscan.py122
-rw-r--r--Mac/Modules/evt/evtsupport.py19
-rw-r--r--Mac/Modules/file/filescan.py366
-rw-r--r--Mac/Modules/file/filesupport.py1151
-rw-r--r--Mac/Modules/fm/fmscan.py104
-rw-r--r--Mac/Modules/fm/fmsupport.py37
-rw-r--r--Mac/Modules/folder/folderscan.py96
-rw-r--r--Mac/Modules/folder/foldersupport.py9
-rw-r--r--Mac/Modules/help/helpscan.py92
-rw-r--r--Mac/Modules/help/helpsupport.py37
-rw-r--r--Mac/Modules/ibcarbon/IBCarbonscan.py62
-rw-r--r--Mac/Modules/ibcarbon/IBCarbonsupport.py8
-rw-r--r--Mac/Modules/icn/icnscan.py102
-rw-r--r--Mac/Modules/icn/icnsupport.py39
-rw-r--r--Mac/Modules/launch/launchscan.py128
-rw-r--r--Mac/Modules/launch/launchsupport.py49
-rw-r--r--Mac/Modules/launch/setup.py14
-rw-r--r--Mac/Modules/list/listscan.py142
-rw-r--r--Mac/Modules/list/listsupport.py183
-rw-r--r--Mac/Modules/menu/menuedit.py1
-rw-r--r--Mac/Modules/menu/menuscan.py158
-rw-r--r--Mac/Modules/menu/menusupport.py42
-rw-r--r--Mac/Modules/mlte/mltescan.py218
-rw-r--r--Mac/Modules/mlte/mltesupport.py67
-rw-r--r--Mac/Modules/osa/osascan.py92
-rw-r--r--Mac/Modules/osa/osasupport.py43
-rw-r--r--Mac/Modules/osa/setup.py14
-rw-r--r--Mac/Modules/qd/qdedit.py3
-rw-r--r--Mac/Modules/qd/qdscan.py434
-rw-r--r--Mac/Modules/qd/qdsupport.py284
-rw-r--r--Mac/Modules/qdoffs/qdoffsscan.py97
-rw-r--r--Mac/Modules/qdoffs/qdoffssupport.py56
-rw-r--r--Mac/Modules/qt/qtscan.py604
-rw-r--r--Mac/Modules/qt/qtsupport.py177
-rwxr-xr-xMac/Modules/qt/setup.py14
-rw-r--r--Mac/Modules/res/resedit.py28
-rw-r--r--Mac/Modules/res/resscan.py130
-rw-r--r--Mac/Modules/res/ressupport.py296
-rw-r--r--Mac/Modules/scrap/scrapscan.py84
-rw-r--r--Mac/Modules/scrap/scrapsupport.py25
-rw-r--r--Mac/Modules/snd/sndscan.py222
-rw-r--r--Mac/Modules/snd/sndsupport.py356
-rw-r--r--Mac/Modules/te/tescan.py94
-rw-r--r--Mac/Modules/te/tesupport.py245
-rw-r--r--Mac/Modules/waste/wastescan.py260
-rw-r--r--Mac/Modules/waste/wastesupport.py441
-rw-r--r--Mac/Modules/win/winedit.py24
-rw-r--r--Mac/Modules/win/winscan.py233
-rw-r--r--Mac/Modules/win/winsupport.py180
71 files changed, 5823 insertions, 5849 deletions
diff --git a/Mac/Modules/ae/aescan.py b/Mac/Modules/ae/aescan.py
index 80c198c..1283c1d 100644
--- a/Mac/Modules/ae/aescan.py
+++ b/Mac/Modules/ae/aescan.py
@@ -13,87 +13,87 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
- input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
- output = "aegen.py"
- defsoutput = TOOLBOXDIR + "AppleEvents.py"
- scanner = AppleEventsScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
- import aesupport
- print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
+ print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
+ input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
+ output = "aegen.py"
+ defsoutput = TOOLBOXDIR + "AppleEvents.py"
+ scanner = AppleEventsScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
+ import aesupport
+ print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
class AppleEventsScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "AEFunction"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t[-4:] == "_ptr" and m == "InMode" and \
- t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
- "AERecord", "AppleEvent"):
- classname = "AEMethod"
- listname = "aedescmethods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- "AEDisposeDesc",
-# "AEGetEventHandler",
- "AEGetDescData", # Use object.data
- "AEGetSpecialHandler",
- # Constants with funny definitions
- "kAEDontDisposeOnResume",
- "kAEUseStandardDispatch",
- ]
-
- def makeblacklisttypes(self):
- return [
- "ProcPtr",
- "AEArrayType",
- "AECoercionHandlerUPP",
- "UniversalProcPtr",
- "OSLCompareUPP",
- "OSLAccessorUPP",
- ]
-
- def makerepairinstructions(self):
- return [
- ([("Boolean", "isSysHandler", "InMode")],
- [("AlwaysFalse", "*", "*")]),
-
- ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
- [("EventHandler", "*", "*")]),
-
- ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
- [("EventHandler", "*", "*")]),
-
- ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
- [("EventHandler", "*", "*")]),
-
- ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
- [("EventHandler", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
- ("Size", "*", "OutMode")],
- [("VarVarOutBuffer", "*", "InOutMode")]),
-
- ([("AppleEvent", "theAppleEvent", "OutMode")],
- [("AppleEvent_ptr", "*", "InMode")]),
-
- ([("AEDescList", "theAEDescList", "OutMode")],
- [("AEDescList_ptr", "*", "InMode")]),
- ]
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def destination(self, type, name, arglist):
+ classname = "AEFunction"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t[-4:] == "_ptr" and m == "InMode" and \
+ t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
+ "AERecord", "AppleEvent"):
+ classname = "AEMethod"
+ listname = "aedescmethods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ "AEDisposeDesc",
+# "AEGetEventHandler",
+ "AEGetDescData", # Use object.data
+ "AEGetSpecialHandler",
+ # Constants with funny definitions
+ "kAEDontDisposeOnResume",
+ "kAEUseStandardDispatch",
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "ProcPtr",
+ "AEArrayType",
+ "AECoercionHandlerUPP",
+ "UniversalProcPtr",
+ "OSLCompareUPP",
+ "OSLAccessorUPP",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("Boolean", "isSysHandler", "InMode")],
+ [("AlwaysFalse", "*", "*")]),
+
+ ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
+ [("EventHandler", "*", "*")]),
+
+ ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
+ [("EventHandler", "*", "*")]),
+
+ ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
+ [("EventHandler", "*", "*")]),
+
+ ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
+ [("EventHandler", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
+ ("Size", "*", "OutMode")],
+ [("VarVarOutBuffer", "*", "InOutMode")]),
+
+ ([("AppleEvent", "theAppleEvent", "OutMode")],
+ [("AppleEvent_ptr", "*", "InMode")]),
+
+ ([("AEDescList", "theAEDescList", "OutMode")],
+ [("AEDescList_ptr", "*", "InMode")]),
+ ]
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/ae/aesupport.py b/Mac/Modules/ae/aesupport.py
index 17184db..91c5b82 100644
--- a/Mac/Modules/ae/aesupport.py
+++ b/Mac/Modules/ae/aesupport.py
@@ -39,29 +39,29 @@ AppleEvent_ptr = OpaqueType('AppleEvent', 'AEDesc')
class EHType(Type):
- def __init__(self, name = 'EventHandler', format = ''):
- Type.__init__(self, name, format)
- def declare(self, name):
- Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name)
- Output("PyObject *%s;", name)
- def getargsFormat(self):
- return "O"
- def getargsArgs(self, name):
- return "&%s" % name
- def passInput(self, name):
- return "%s__proc__, (long)%s" % (name, name)
- def passOutput(self, name):
- return "&%s__proc__, (long *)&%s" % (name, name)
- def mkvalueFormat(self):
- return "O"
- def mkvalueArgs(self, name):
- return name
- def cleanup(self, name):
- Output("Py_INCREF(%s); /* XXX leak, but needed */", name)
+ def __init__(self, name = 'EventHandler', format = ''):
+ Type.__init__(self, name, format)
+ def declare(self, name):
+ Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name)
+ Output("PyObject *%s;", name)
+ def getargsFormat(self):
+ return "O"
+ def getargsArgs(self, name):
+ return "&%s" % name
+ def passInput(self, name):
+ return "%s__proc__, (long)%s" % (name, name)
+ def passOutput(self, name):
+ return "&%s__proc__, (long *)&%s" % (name, name)
+ def mkvalueFormat(self):
+ return "O"
+ def mkvalueArgs(self, name):
+ return name
+ def cleanup(self, name):
+ Output("Py_INCREF(%s); /* XXX leak, but needed */", name)
class EHNoRefConType(EHType):
- def passInput(self, name):
- return "upp_GenericEventHandler"
+ def passInput(self, name):
+ return "upp_GenericEventHandler"
EventHandler = EHType()
EventHandlerNoRefCon = EHNoRefConType()
@@ -101,9 +101,9 @@ AEEventHandlerUPP upp_GenericEventHandler;
static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn)
{
- if ( PyOS_InterruptOccurred() )
- return 1;
- return 0;
+ if ( PyOS_InterruptOccurred() )
+ return 1;
+ return 0;
}
AEIdleUPP upp_AEIdleProc;
@@ -113,99 +113,99 @@ finalstuff = finalstuff + """
static pascal OSErr
GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon)
{
- PyObject *handler = (PyObject *)refcon;
- AEDescObject *requestObject, *replyObject;
- PyObject *args, *res;
- if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) {
- return -1;
- }
- if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) {
- Py_DECREF(requestObject);
- return -1;
- }
- if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) {
- Py_DECREF(requestObject);
- Py_DECREF(replyObject);
- return -1;
- }
- res = PyEval_CallObject(handler, args);
- requestObject->ob_itself.descriptorType = 'null';
- requestObject->ob_itself.dataHandle = NULL;
- replyObject->ob_itself.descriptorType = 'null';
- replyObject->ob_itself.dataHandle = NULL;
- Py_DECREF(args);
- if (res == NULL) {
- PySys_WriteStderr("Exception in AE event handler function\\n");
- PyErr_Print();
- return -1;
- }
- Py_DECREF(res);
- return noErr;
+ PyObject *handler = (PyObject *)refcon;
+ AEDescObject *requestObject, *replyObject;
+ PyObject *args, *res;
+ if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) {
+ return -1;
+ }
+ if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) {
+ Py_DECREF(requestObject);
+ return -1;
+ }
+ if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) {
+ Py_DECREF(requestObject);
+ Py_DECREF(replyObject);
+ return -1;
+ }
+ res = PyEval_CallObject(handler, args);
+ requestObject->ob_itself.descriptorType = 'null';
+ requestObject->ob_itself.dataHandle = NULL;
+ replyObject->ob_itself.descriptorType = 'null';
+ replyObject->ob_itself.dataHandle = NULL;
+ Py_DECREF(args);
+ if (res == NULL) {
+ PySys_WriteStderr("Exception in AE event handler function\\n");
+ PyErr_Print();
+ return -1;
+ }
+ Py_DECREF(res);
+ return noErr;
}
PyObject *AEDesc_NewBorrowed(AEDesc *itself)
{
- PyObject *it;
-
- it = AEDesc_New(itself);
- if (it)
- ((AEDescObject *)it)->ob_owned = 0;
- return (PyObject *)it;
+ PyObject *it;
+
+ it = AEDesc_New(itself);
+ if (it)
+ ((AEDescObject *)it)->ob_owned = 0;
+ return (PyObject *)it;
}
"""
initstuff = initstuff + """
- upp_AEIdleProc = NewAEIdleUPP(AEIdleProc);
- upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert);
+ upp_AEIdleProc = NewAEIdleUPP(AEIdleProc);
+ upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert);
"""
module = MacModule('_AE', 'AE', includestuff, finalstuff, initstuff)
class AEDescDefinition(PEP253Mixin, GlobalObjectDefinition):
- getsetlist = [(
- 'type',
- 'return PyMac_BuildOSType(self->ob_itself.descriptorType);',
- None,
- 'Type of this AEDesc'
- ), (
- 'data',
- """
- PyObject *res;
- Size size;
- char *ptr;
- OSErr err;
-
- size = AEGetDescDataSize(&self->ob_itself);
- if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
- return NULL;
- if ( (ptr = PyString_AsString(res)) == NULL )
- return NULL;
- if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
- return PyMac_Error(err);
- return res;
- """,
- None,
- 'The raw data in this AEDesc'
- )]
-
- def __init__(self, name, prefix = None, itselftype = None):
- GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name)
- self.argref = "*"
-
- def outputStructMembers(self):
- GlobalObjectDefinition.outputStructMembers(self)
- Output("int ob_owned;")
-
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("it->ob_owned = 1;")
-
- def outputCleanupStructMembers(self):
- Output("if (self->ob_owned) AEDisposeDesc(&self->ob_itself);")
+ getsetlist = [(
+ 'type',
+ 'return PyMac_BuildOSType(self->ob_itself.descriptorType);',
+ None,
+ 'Type of this AEDesc'
+ ), (
+ 'data',
+ """
+ PyObject *res;
+ Size size;
+ char *ptr;
+ OSErr err;
+
+ size = AEGetDescDataSize(&self->ob_itself);
+ if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
+ return NULL;
+ if ( (ptr = PyString_AsString(res)) == NULL )
+ return NULL;
+ if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
+ return PyMac_Error(err);
+ return res;
+ """,
+ None,
+ 'The raw data in this AEDesc'
+ )]
+
+ def __init__(self, name, prefix = None, itselftype = None):
+ GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name)
+ self.argref = "*"
+
+ def outputStructMembers(self):
+ GlobalObjectDefinition.outputStructMembers(self)
+ Output("int ob_owned;")
+
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_owned = 1;")
+
+ def outputCleanupStructMembers(self):
+ Output("if (self->ob_owned) AEDisposeDesc(&self->ob_itself);")
aedescobject = AEDescDefinition('AEDesc')
module.addobject(aedescobject)
diff --git a/Mac/Modules/ah/ahscan.py b/Mac/Modules/ah/ahscan.py
index cced19f..0b7fe08 100644
--- a/Mac/Modules/ah/ahscan.py
+++ b/Mac/Modules/ah/ahscan.py
@@ -11,42 +11,42 @@ SHORT = "ah"
OBJECT = "NOTUSED"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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_OSX):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- ]
-
- def makeblacklisttypes(self):
- return [
- ]
-
- def makerepairinstructions(self):
- return [
- ]
-
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ]
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/ah/ahsupport.py b/Mac/Modules/ah/ahsupport.py
index c91c298..c5f24be 100644
--- a/Mac/Modules/ah/ahsupport.py
+++ b/Mac/Modules/ah/ahsupport.py
@@ -6,13 +6,13 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'AppleHelp.h' # The Apple header file
-MODNAME = '_AH' # The name of the module
+MACHEADERFILE = 'AppleHelp.h' # The Apple header file
+MODNAME = '_AH' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Ah' # The prefix for module-wide routines
+MODPREFIX = 'Ah' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -43,4 +43,3 @@ for f in functions: module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/app/appscan.py b/Mac/Modules/app/appscan.py
index 822651d..1b04859 100644
--- a/Mac/Modules/app/appscan.py
+++ b/Mac/Modules/app/appscan.py
@@ -11,71 +11,71 @@ SHORT = "app"
OBJECT = "ThemeDrawingState"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- def makeblacklistnames(self):
- return [
- "GetThemeFont", # Funny stringbuffer in/out parameter, I think...
- # Constants with funny definitions
- "appearanceBadBrushIndexErr",
- "appearanceProcessRegisteredErr",
- "appearanceProcessNotRegisteredErr",
- "appearanceBadTextColorIndexErr",
- "appearanceThemeHasNoAccents",
- "appearanceBadCursorIndexErr",
- ]
+ def makeblacklistnames(self):
+ return [
+ "GetThemeFont", # Funny stringbuffer in/out parameter, I think...
+ # Constants with funny definitions
+ "appearanceBadBrushIndexErr",
+ "appearanceProcessRegisteredErr",
+ "appearanceProcessNotRegisteredErr",
+ "appearanceBadTextColorIndexErr",
+ "appearanceThemeHasNoAccents",
+ "appearanceBadCursorIndexErr",
+ ]
- def makeblacklisttypes(self):
- return [
- "MenuTitleDrawingUPP",
- "MenuItemDrawingUPP",
- "ThemeIteratorUPP",
- "ThemeTabTitleDrawUPP",
-# "ThemeEraseUPP",
-# "ThemeButtonDrawUPP",
- "WindowTitleDrawingUPP",
- "ProcessSerialNumber_ptr", # Too much work for now.
- "ThemeTrackDrawInfo_ptr", # Too much work
-# "ThemeButtonDrawInfo_ptr", # ditto
- "ThemeWindowMetrics_ptr", # ditto
-# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
- "Collection", # No interface to collection mgr yet.
- "BytePtr", # Not yet.
- ]
+ def makeblacklisttypes(self):
+ return [
+ "MenuTitleDrawingUPP",
+ "MenuItemDrawingUPP",
+ "ThemeIteratorUPP",
+ "ThemeTabTitleDrawUPP",
+# "ThemeEraseUPP",
+# "ThemeButtonDrawUPP",
+ "WindowTitleDrawingUPP",
+ "ProcessSerialNumber_ptr", # Too much work for now.
+ "ThemeTrackDrawInfo_ptr", # Too much work
+# "ThemeButtonDrawInfo_ptr", # ditto
+ "ThemeWindowMetrics_ptr", # ditto
+# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
+ "Collection", # No interface to collection mgr yet.
+ "BytePtr", # Not yet.
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("void", 'inContext', "OutMode")],
+ [("NULL", 'inContext', "InMode")]),
+ ([("Point", 'ioBounds', "OutMode")],
+ [("Point", 'ioBounds', "InOutMode")]),
+ ]
- def makerepairinstructions(self):
- return [
- ([("void", 'inContext', "OutMode")],
- [("NULL", 'inContext', "InMode")]),
- ([("Point", 'ioBounds', "OutMode")],
- [("Point", 'ioBounds', "InOutMode")]),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/app/appsupport.py b/Mac/Modules/app/appsupport.py
index a9d8768..177dfd5 100644
--- a/Mac/Modules/app/appsupport.py
+++ b/Mac/Modules/app/appsupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Appearance.h' # The Apple header file
-MODNAME = '_App' # The name of the module
-OBJECTNAME = 'ThemeDrawingState' # The basic name of the objects used here
-KIND = '' # Usually 'Ptr' or 'Handle'
+MACHEADERFILE = 'Appearance.h' # The Apple header file
+MODNAME = '_App' # The name of the module
+OBJECTNAME = 'ThemeDrawingState' # The basic name of the objects used here
+KIND = '' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'App' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
-OBJECTPREFIX = OBJECTNAME + 'Obj' # The prefix for object methods
+MODPREFIX = 'App' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
+OBJECTPREFIX = OBJECTNAME + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -84,24 +84,24 @@ includestuff = includestuff + """
int ThemeButtonDrawInfo_Convert(PyObject *v, ThemeButtonDrawInfo *p_itself)
{
- return PyArg_Parse(v, "(iHH)", &p_itself->state, &p_itself->value, &p_itself->adornment);
+ return PyArg_Parse(v, "(iHH)", &p_itself->state, &p_itself->value, &p_itself->adornment);
}
"""
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- pass
-## def outputCheckNewArg(self):
-## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-## def outputCheckConvertArg(self):
-## OutLbrace("if (DlgObj_Check(v))")
-## Output("*p_itself = ((WindowObject *)v)->ob_itself;")
-## Output("return 1;")
-## OutRbrace()
-## Out("""
-## if (v == Py_None) { *p_itself = NULL; return 1; }
-## if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
-## """)
+ pass
+## def outputCheckNewArg(self):
+## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+## def outputCheckConvertArg(self):
+## OutLbrace("if (DlgObj_Check(v))")
+## Output("*p_itself = ((WindowObject *)v)->ob_itself;")
+## Output("return 1;")
+## OutRbrace()
+## Out("""
+## if (v == Py_None) { *p_itself = NULL; return 1; }
+## if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
+## """)
# From here on it's basically all boiler plate...
@@ -131,4 +131,3 @@ for f in methods: object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/carbonevt/CarbonEvtscan.py b/Mac/Modules/carbonevt/CarbonEvtscan.py
index c6bf93f..e3c72ae 100644
--- a/Mac/Modules/carbonevt/CarbonEvtscan.py
+++ b/Mac/Modules/carbonevt/CarbonEvtscan.py
@@ -12,106 +12,106 @@ sys.path.append(BGENDIR)
from scantools import Scanner, Scanner_OSX
def main():
- print "---Scanning CarbonEvents.h---"
- input = ["CarbonEvents.h"]
- output = "CarbonEventsgen.py"
- defsoutput = TOOLBOXDIR + "CarbonEvents.py"
- scanner = CarbonEvents_Scanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "--done scanning, importing--"
- import CarbonEvtsupport
- print "done"
+ print "---Scanning CarbonEvents.h---"
+ input = ["CarbonEvents.h"]
+ output = "CarbonEventsgen.py"
+ defsoutput = TOOLBOXDIR + "CarbonEvents.py"
+ scanner = CarbonEvents_Scanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "--done scanning, importing--"
+ import CarbonEvtsupport
+ print "done"
-RefObjectTypes = ["EventRef",
- "EventQueueRef",
- "EventLoopRef",
- "EventLoopTimerRef",
- "EventHandlerRef",
- "EventHandlerCallRef",
- "EventTargetRef",
- "EventHotKeyRef",
- ]
+RefObjectTypes = ["EventRef",
+ "EventQueueRef",
+ "EventLoopRef",
+ "EventLoopTimerRef",
+ "EventHandlerRef",
+ "EventHandlerCallRef",
+ "EventTargetRef",
+ "EventHotKeyRef",
+ ]
class CarbonEvents_Scanner(Scanner_OSX):
- def destination(self, type, name, arglist):
- classname = "CarbonEventsFunction"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t in RefObjectTypes and m == "InMode":
- if t == "EventHandlerRef":
- classname = "EventHandlerRefMethod"
- else:
- classname = "CarbonEventsMethod"
- listname = t + "methods"
- #else:
- # print "not method"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "CarbonEventsFunction"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in RefObjectTypes and m == "InMode":
+ if t == "EventHandlerRef":
+ classname = "EventHandlerRefMethod"
+ else:
+ classname = "CarbonEventsMethod"
+ listname = t + "methods"
+ #else:
+ # print "not method"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- self.defsfile.write("false = 0\n")
- self.defsfile.write("true = 1\n")
- self.defsfile.write("keyAEEventClass = FOUR_CHAR_CODE('evcl')\n")
- self.defsfile.write("keyAEEventID = FOUR_CHAR_CODE('evti')\n")
-
- def makeblacklistnames(self):
- return [
- "sHandler",
- "MacCreateEvent",
-# "TrackMouseLocationWithOptions",
-# "TrackMouseLocation",
-# "TrackMouseRegion",
- "RegisterToolboxObjectClass",
- "UnregisterToolboxObjectClass",
- "ProcessHICommand",
- "GetCFRunLoopFromEventLoop",
-
- "InvokeEventHandlerUPP",
- "InvokeEventComparatorUPP",
- "InvokeEventLoopTimerUPP",
- "NewEventComparatorUPP",
- "NewEventLoopTimerUPP",
- "NewEventHandlerUPP",
- "DisposeEventComparatorUPP",
- "DisposeEventLoopTimerUPP",
- "DisposeEventHandlerUPP",
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("false = 0\n")
+ self.defsfile.write("true = 1\n")
+ self.defsfile.write("keyAEEventClass = FOUR_CHAR_CODE('evcl')\n")
+ self.defsfile.write("keyAEEventID = FOUR_CHAR_CODE('evti')\n")
- # Wrote by hand
- "InstallEventHandler",
- "RemoveEventHandler",
-
- # Write by hand?
- "GetEventParameter",
- "FlushSpecificEventsFromQueue",
- "FindSpecificEventInQueue",
- "InstallEventLoopTimer",
+ def makeblacklistnames(self):
+ return [
+ "sHandler",
+ "MacCreateEvent",
+# "TrackMouseLocationWithOptions",
+# "TrackMouseLocation",
+# "TrackMouseRegion",
+ "RegisterToolboxObjectClass",
+ "UnregisterToolboxObjectClass",
+ "ProcessHICommand",
+ "GetCFRunLoopFromEventLoop",
- # Don't do these because they require a CFRelease
- "CreateTypeStringWithOSType",
- "CopyEvent",
- ]
+ "InvokeEventHandlerUPP",
+ "InvokeEventComparatorUPP",
+ "InvokeEventLoopTimerUPP",
+ "NewEventComparatorUPP",
+ "NewEventLoopTimerUPP",
+ "NewEventHandlerUPP",
+ "DisposeEventComparatorUPP",
+ "DisposeEventLoopTimerUPP",
+ "DisposeEventHandlerUPP",
-# def makeblacklisttypes(self):
-# return ["EventComparatorUPP",
-# "EventLoopTimerUPP",
-# #"EventHandlerUPP",
-# "EventComparatorProcPtr",
-# "EventLoopTimerProcPtr",
-# "EventHandlerProcPtr",
-# ]
+ # Wrote by hand
+ "InstallEventHandler",
+ "RemoveEventHandler",
- def makerepairinstructions(self):
- return [
- ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")],
- [("MyInBuffer", 'inDataPtr', "InMode")]),
- ([("Boolean", 'ioWasInRgn', "OutMode")],
- [("Boolean", 'ioWasInRgn', "InOutMode")]),
- ]
+ # Write by hand?
+ "GetEventParameter",
+ "FlushSpecificEventsFromQueue",
+ "FindSpecificEventInQueue",
+ "InstallEventLoopTimer",
+
+ # Don't do these because they require a CFRelease
+ "CreateTypeStringWithOSType",
+ "CopyEvent",
+ ]
+
+# def makeblacklisttypes(self):
+# return ["EventComparatorUPP",
+# "EventLoopTimerUPP",
+# #"EventHandlerUPP",
+# "EventComparatorProcPtr",
+# "EventLoopTimerProcPtr",
+# "EventHandlerProcPtr",
+# ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")],
+ [("MyInBuffer", 'inDataPtr', "InMode")]),
+ ([("Boolean", 'ioWasInRgn', "OutMode")],
+ [("Boolean", 'ioWasInRgn', "InOutMode")]),
+ ]
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/carbonevt/CarbonEvtsupport.py b/Mac/Modules/carbonevt/CarbonEvtsupport.py
index 3cc1672..77d12b6 100644
--- a/Mac/Modules/carbonevt/CarbonEvtsupport.py
+++ b/Mac/Modules/carbonevt/CarbonEvtsupport.py
@@ -8,23 +8,23 @@ from CarbonEvtscan import RefObjectTypes
CFStringRef = OpaqueByValueType('CFStringRef')
for typ in RefObjectTypes:
- execstr = "%(name)s = OpaqueByValueType('%(name)s')" % {"name": typ}
- exec execstr
+ execstr = "%(name)s = OpaqueByValueType('%(name)s')" % {"name": typ}
+ exec execstr
if 0:
- # these types will have no methods and will merely be opaque blobs
- # should write getattr and setattr for them?
+ # these types will have no methods and will merely be opaque blobs
+ # should write getattr and setattr for them?
- StructObjectTypes = ["EventTypeSpec",
- "HIPoint",
- "HICommand",
- "EventHotKeyID",
- ]
+ StructObjectTypes = ["EventTypeSpec",
+ "HIPoint",
+ "HICommand",
+ "EventHotKeyID",
+ ]
- for typ in StructObjectTypes:
- execstr = "%(name)s = OpaqueType('%(name)s')" % {"name": typ}
- exec execstr
+ for typ in StructObjectTypes:
+ execstr = "%(name)s = OpaqueType('%(name)s')" % {"name": typ}
+ exec execstr
EventHotKeyID = OpaqueByValueType("EventHotKeyID", "EventHotKeyID")
EventTypeSpec_ptr = OpaqueType("EventTypeSpec", "EventTypeSpec")
@@ -35,10 +35,10 @@ void_ptr = stringptr
# here are some types that are really other types
class MyVarInputBufferType(VarInputBufferType):
- def passInput(self, name):
- return "%s__len__, %s__in__" % (name, name)
+ def passInput(self, name):
+ return "%s__len__, %s__in__" % (name, name)
-MyInBuffer = MyVarInputBufferType('char', 'long', 'l') # (buf, len)
+MyInBuffer = MyVarInputBufferType('char', 'long', 'l') # (buf, len)
EventTime = double
EventTimeout = EventTime
@@ -61,11 +61,11 @@ CarbonEventsFunction = OSErrFunctionGenerator
CarbonEventsMethod = OSErrMethodGenerator
class EventHandlerRefMethod(OSErrMethodGenerator):
- def precheck(self):
- OutLbrace('if (_self->ob_itself == NULL)')
- Output('PyErr_SetString(CarbonEvents_Error, "Handler has been removed");')
- Output('return NULL;')
- OutRbrace()
+ def precheck(self):
+ OutLbrace('if (_self->ob_itself == NULL)')
+ Output('PyErr_SetString(CarbonEvents_Error, "Handler has been removed");')
+ Output('return NULL;')
+ OutRbrace()
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
@@ -89,17 +89,17 @@ PyObject *EventRef_New(EventRef itself);
static PyObject*
EventTypeSpec_New(EventTypeSpec *in)
{
- return Py_BuildValue("ll", in->eventClass, in->eventKind);
+ return Py_BuildValue("ll", in->eventClass, in->eventKind);
}
static int
EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out)
{
- if (PyArg_Parse(v, "(O&l)",
- PyMac_GetOSType, &(out->eventClass),
- &(out->eventKind)))
- return 1;
- return NULL;
+ if (PyArg_Parse(v, "(O&l)",
+ PyMac_GetOSType, &(out->eventClass),
+ &(out->eventKind)))
+ return 1;
+ return NULL;
}
/********** end EventTypeSpec *******/
@@ -110,15 +110,15 @@ EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out)
static PyObject*
HIPoint_New(HIPoint *in)
{
- return Py_BuildValue("ff", in->x, in->y);
+ return Py_BuildValue("ff", in->x, in->y);
}
static int
HIPoint_Convert(PyObject *v, HIPoint *out)
{
- if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y)))
- return 1;
- return NULL;
+ if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y)))
+ return 1;
+ return NULL;
}
#endif
@@ -129,15 +129,15 @@ HIPoint_Convert(PyObject *v, HIPoint *out)
static PyObject*
EventHotKeyID_New(EventHotKeyID *in)
{
- return Py_BuildValue("ll", in->signature, in->id);
+ return Py_BuildValue("ll", in->signature, in->id);
}
static int
EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out)
{
- if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id))
- return 1;
- return NULL;
+ if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id))
+ return 1;
+ return NULL;
}
/********** end EventHotKeyID *******/
@@ -148,27 +148,27 @@ static EventHandlerUPP myEventHandlerUPP;
static pascal OSStatus
myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
- PyObject *retValue;
- int status;
-
- retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
- EventHandlerCallRef_New, handlerRef,
- EventRef_New, event);
- if (retValue == NULL) {
- PySys_WriteStderr("Error in event handler callback:\n");
- PyErr_Print(); /* this also clears the error */
- status = noErr; /* complain? how? */
- } else {
- if (retValue == Py_None)
- status = noErr;
- else if (PyInt_Check(retValue)) {
- status = PyInt_AsLong(retValue);
- } else
- status = noErr; /* wrong object type, complain? */
- Py_DECREF(retValue);
- }
-
- return status;
+ PyObject *retValue;
+ int status;
+
+ retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
+ EventHandlerCallRef_New, handlerRef,
+ EventRef_New, event);
+ if (retValue == NULL) {
+ PySys_WriteStderr("Error in event handler callback:\n");
+ PyErr_Print(); /* this also clears the error */
+ status = noErr; /* complain? how? */
+ } else {
+ if (retValue == Py_None)
+ status = noErr;
+ else if (PyInt_Check(retValue)) {
+ status = PyInt_AsLong(retValue);
+ } else
+ status = noErr; /* wrong object type, complain? */
+ Py_DECREF(retValue);
+ }
+
+ return status;
}
/******** end myEventHandler ***********/
@@ -184,56 +184,56 @@ module = MacModule('_CarbonEvt', 'CarbonEvents', includestuff, finalstuff, inits
class EventHandlerRefObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputStructMembers(self):
- Output("%s ob_itself;", self.itselftype)
- Output("PyObject *ob_callback;")
- def outputInitStructMembers(self):
- Output("it->ob_itself = %sitself;", self.argref)
- Output("it->ob_callback = NULL;")
- def outputFreeIt(self, name):
- OutLbrace("if (self->ob_itself != NULL)")
- Output("RemoveEventHandler(self->ob_itself);")
- Output("Py_DECREF(self->ob_callback);")
- OutRbrace()
-
+ def outputStructMembers(self):
+ Output("%s ob_itself;", self.itselftype)
+ Output("PyObject *ob_callback;")
+ def outputInitStructMembers(self):
+ Output("it->ob_itself = %sitself;", self.argref)
+ Output("it->ob_callback = NULL;")
+ def outputFreeIt(self, name):
+ OutLbrace("if (self->ob_itself != NULL)")
+ Output("RemoveEventHandler(self->ob_itself);")
+ Output("Py_DECREF(self->ob_callback);")
+ OutRbrace()
+
class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- pass
+ pass
for typ in RefObjectTypes:
- if typ == 'EventHandlerRef':
- EventHandlerRefobject = EventHandlerRefObjectDefinition('EventHandlerRef')
- else:
- execstr = typ + 'object = MyGlobalObjectDefinition(typ)'
- exec execstr
- module.addobject(eval(typ + 'object'))
+ if typ == 'EventHandlerRef':
+ EventHandlerRefobject = EventHandlerRefObjectDefinition('EventHandlerRef')
+ else:
+ execstr = typ + 'object = MyGlobalObjectDefinition(typ)'
+ exec execstr
+ module.addobject(eval(typ + 'object'))
functions = []
for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py
- # initialize the lists for carbongen to fill
- execstr = typ + 'methods = []'
- exec execstr
+ # initialize the lists for carbongen to fill
+ execstr = typ + 'methods = []'
+ exec execstr
execfile('CarbonEventsgen.py')
-for f in functions: module.add(f) # add all the functions carboneventsgen put in the list
+for f in functions: module.add(f) # add all the functions carboneventsgen put in the list
-for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py
- methods = eval(typ + 'methods') ## get a reference to the method list from the main namespace
- obj = eval(typ + 'object') ## get a reference to the object
- for m in methods: obj.add(m) ## add each method in the list to the object
+for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py
+ methods = eval(typ + 'methods') ## get a reference to the method list from the main namespace
+ obj = eval(typ + 'object') ## get a reference to the object
+ for m in methods: obj.add(m) ## add each method in the list to the object
removeeventhandler = """
OSStatus _err;
if (_self->ob_itself == NULL) {
- PyErr_SetString(CarbonEvents_Error, "Handler has been removed");
- return NULL;
+ PyErr_SetString(CarbonEvents_Error, "Handler has been removed");
+ return NULL;
}
if (!PyArg_ParseTuple(_args, ""))
- return NULL;
+ return NULL;
_err = RemoveEventHandler(_self->ob_itself);
if (_err != noErr) return PyMac_Error(_err);
_self->ob_itself = NULL;
@@ -255,15 +255,15 @@ EventHandlerRef outRef;
OSStatus _err;
if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback))
- return NULL;
+ return NULL;
_err = InstallEventHandler(_self->ob_itself, myEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef);
if (_err != noErr) return PyMac_Error(_err);
_res = EventHandlerRef_New(outRef);
if (_res != NULL) {
- ((EventHandlerRefObject*)_res)->ob_callback = callback;
- Py_INCREF(callback);
+ ((EventHandlerRefObject*)_res)->ob_callback = callback;
+ Py_INCREF(callback);
}
return _res;"""
diff --git a/Mac/Modules/cf/cfscan.py b/Mac/Modules/cf/cfscan.py
index aa0ea3d..d2de92e 100644
--- a/Mac/Modules/cf/cfscan.py
+++ b/Mac/Modules/cf/cfscan.py
@@ -8,135 +8,135 @@ from scantools import Scanner_OSX
LONG = "CoreFoundation"
SHORT = "cf"
-OBJECTS = ("CFTypeRef",
- "CFArrayRef", "CFMutableArrayRef",
- "CFDataRef", "CFMutableDataRef",
- "CFDictionaryRef", "CFMutableDictionaryRef",
- "CFStringRef", "CFMutableStringRef",
- "CFURLRef",
-## "CFPropertyListRef",
- )
+OBJECTS = ("CFTypeRef",
+ "CFArrayRef", "CFMutableArrayRef",
+ "CFDataRef", "CFMutableDataRef",
+ "CFDictionaryRef", "CFMutableDictionaryRef",
+ "CFStringRef", "CFMutableStringRef",
+ "CFURLRef",
+## "CFPropertyListRef",
+ )
# ADD object typenames here
def main():
- input = [
- "CFBase.h",
- "CFArray.h",
-## "CFBag.h",
-## "CFBundle.h",
-## "CFCharacterSet.h",
- "CFData.h",
-## "CFDate.h",
- "CFDictionary.h",
-## "CFNumber.h",
-## "CFPlugIn.h",
- "CFPreferences.h",
- "CFPropertyList.h",
-## "CFSet.h",
- "CFString.h",
-## "CFStringEncodingExt.h",
-## "CFTimeZone.h",
- "CFURL.h",
- ]
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.gentypetest(SHORT+"typetest.py")
- scanner.close()
- 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! ==="
+ input = [
+ "CFBase.h",
+ "CFArray.h",
+## "CFBag.h",
+## "CFBundle.h",
+## "CFCharacterSet.h",
+ "CFData.h",
+## "CFDate.h",
+ "CFDictionary.h",
+## "CFNumber.h",
+## "CFPlugIn.h",
+ "CFPreferences.h",
+ "CFPropertyList.h",
+## "CFSet.h",
+ "CFString.h",
+## "CFStringEncodingExt.h",
+## "CFTimeZone.h",
+ "CFURL.h",
+ ]
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.gentypetest(SHORT+"typetest.py")
+ scanner.close()
+ 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_OSX):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist and name[:13] != 'CFPreferences':
- t, n, m = arglist[0]
- if t in OBJECTS and m == "InMode":
- classname = "Method"
- listname = t + "_methods"
- # Special case for the silly first AllocatorRef argument
- if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1:
- t, n, m = arglist[1]
- if t in OBJECTS and m == "InMode":
- classname = "MethodSkipArg1"
- listname = t + "_methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist and name[:13] != 'CFPreferences':
+ t, n, m = arglist[0]
+ if t in OBJECTS and m == "InMode":
+ classname = "Method"
+ listname = t + "_methods"
+ # Special case for the silly first AllocatorRef argument
+ if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1:
+ t, n, m = arglist[1]
+ if t in OBJECTS and m == "InMode":
+ classname = "MethodSkipArg1"
+ listname = t + "_methods"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- def makeblacklistnames(self):
- return [
- # Memory allocator functions
- "CFAllocatorGetDefault",
- "CFAllocatorSetDefault",
- "CFAllocatorAllocate",
- "CFAllocatorReallocate",
- "CFAllocatorDeallocate",
- "CFGetAllocator",
- # Array functions we skip for now.
- "CFArrayGetValueAtIndex",
- # Data pointer functions. Skip for now.
- "CFDataGetBytePtr",
- "CFDataGetMutableBytePtr",
- "CFDataGetBytes", # XXXX Should support this one
- # String functions
- "CFStringGetPascalString", # Use the C-string methods.
- "CFStringGetPascalStringPtr", # TBD automatically
- "CFStringGetCStringPtr",
- "CFStringGetCharactersPtr",
- "CFStringGetCString",
- "CFStringGetCharacters",
- "CFURLCreateStringWithFileSystemPath", # Gone in later releases
- "CFStringCreateMutableWithExternalCharactersNoCopy", # Not a clue...
- "CFStringSetExternalCharactersNoCopy",
- "CFStringGetCharacterAtIndex", # No format for single unichars yet.
- "kCFStringEncodingInvalidId", # incompatible constant declaration
- "CFPropertyListCreateFromXMLData", # Manually generated
- ]
+ def makeblacklistnames(self):
+ return [
+ # Memory allocator functions
+ "CFAllocatorGetDefault",
+ "CFAllocatorSetDefault",
+ "CFAllocatorAllocate",
+ "CFAllocatorReallocate",
+ "CFAllocatorDeallocate",
+ "CFGetAllocator",
+ # Array functions we skip for now.
+ "CFArrayGetValueAtIndex",
+ # Data pointer functions. Skip for now.
+ "CFDataGetBytePtr",
+ "CFDataGetMutableBytePtr",
+ "CFDataGetBytes", # XXXX Should support this one
+ # String functions
+ "CFStringGetPascalString", # Use the C-string methods.
+ "CFStringGetPascalStringPtr", # TBD automatically
+ "CFStringGetCStringPtr",
+ "CFStringGetCharactersPtr",
+ "CFStringGetCString",
+ "CFStringGetCharacters",
+ "CFURLCreateStringWithFileSystemPath", # Gone in later releases
+ "CFStringCreateMutableWithExternalCharactersNoCopy", # Not a clue...
+ "CFStringSetExternalCharactersNoCopy",
+ "CFStringGetCharacterAtIndex", # No format for single unichars yet.
+ "kCFStringEncodingInvalidId", # incompatible constant declaration
+ "CFPropertyListCreateFromXMLData", # Manually generated
+ ]
- def makegreylist(self):
- return []
+ def makegreylist(self):
+ return []
- def makeblacklisttypes(self):
- return [
- "CFComparatorFunction", # Callback function pointer
- "CFAllocatorContext", # Not interested in providing our own allocator
- "void_ptr_ptr", # Tricky. This is the initializer for arrays...
- "void_ptr", # Ditto for various array lookup methods
- "CFArrayApplierFunction", # Callback function pointer
- "CFDictionaryApplierFunction", # Callback function pointer
- "va_list", # For printf-to-a-cfstring. Use Python.
- "const_CFStringEncoding_ptr", # To be done, I guess
- ]
+ def makeblacklisttypes(self):
+ return [
+ "CFComparatorFunction", # Callback function pointer
+ "CFAllocatorContext", # Not interested in providing our own allocator
+ "void_ptr_ptr", # Tricky. This is the initializer for arrays...
+ "void_ptr", # Ditto for various array lookup methods
+ "CFArrayApplierFunction", # Callback function pointer
+ "CFDictionaryApplierFunction", # Callback function pointer
+ "va_list", # For printf-to-a-cfstring. Use Python.
+ "const_CFStringEncoding_ptr", # To be done, I guess
+ ]
- def makerepairinstructions(self):
- return [
- # Buffers in CF seem to be passed as UInt8 * normally.
- ([("UInt8_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")],
- [("UcharInBuffer", "*", "*")]),
-
- ([("UniChar_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")],
- [("UnicodeInBuffer", "*", "*")]),
+ def makerepairinstructions(self):
+ return [
+ # Buffers in CF seem to be passed as UInt8 * normally.
+ ([("UInt8_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")],
+ [("UcharInBuffer", "*", "*")]),
+
+ ([("UniChar_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")],
+ [("UnicodeInBuffer", "*", "*")]),
+
+ # Some functions return a const char *. Don't worry, we won't modify it.
+ ([("const_char_ptr", "*", "ReturnMode")],
+ [("return_stringptr", "*", "*")]),
+
+ # base URLs are optional (pass None for NULL)
+ ([("CFURLRef", "baseURL", "InMode")],
+ [("OptionalCFURLRef", "*", "*")]),
+
+ # We handle CFPropertyListRef objects as plain CFTypeRef
+ ([("CFPropertyListRef", "*", "*")],
+ [("CFTypeRef", "*", "*")]),
+ ]
- # Some functions return a const char *. Don't worry, we won't modify it.
- ([("const_char_ptr", "*", "ReturnMode")],
- [("return_stringptr", "*", "*")]),
-
- # base URLs are optional (pass None for NULL)
- ([("CFURLRef", "baseURL", "InMode")],
- [("OptionalCFURLRef", "*", "*")]),
-
- # We handle CFPropertyListRef objects as plain CFTypeRef
- ([("CFPropertyListRef", "*", "*")],
- [("CFTypeRef", "*", "*")]),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py
index 95aeaa7..87b9a6f 100644
--- a/Mac/Modules/cf/cfsupport.py
+++ b/Mac/Modules/cf/cfsupport.py
@@ -8,35 +8,35 @@
import string
# Declarations that change for each manager
-MODNAME = '_CF' # The name of the module
+MODNAME = '_CF' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'CF' # The prefix for module-wide routines
+MODPREFIX = 'CF' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
# Special case generator for the functions that have an AllocatorRef first argument,
# which we skip anyway, and the object as the second arg.
class MethodSkipArg1(MethodGenerator):
- """Similar to MethodGenerator, but has self as last argument"""
-
- def parseArgumentList(self, args):
- if len(args) < 2:
- raise ValueError, "MethodSkipArg1 expects at least 2 args"
- a0, a1, args = args[0], args[1], args[2:]
- t0, n0, m0 = a0
- if t0 != "CFAllocatorRef" and m0 != InMode:
- raise ValueError, "MethodSkipArg1 should have dummy AllocatorRef first arg"
- t1, n1, m1 = a1
- if m1 != InMode:
- raise ValueError, "method's 'self' must be 'InMode'"
- dummy = Variable(t0, n0, m0)
- self.argumentList.append(dummy)
- self.itself = Variable(t1, "_self->ob_itself", SelfMode)
- self.argumentList.append(self.itself)
- FunctionGenerator.parseArgumentList(self, args)
+ """Similar to MethodGenerator, but has self as last argument"""
+
+ def parseArgumentList(self, args):
+ if len(args) < 2:
+ raise ValueError, "MethodSkipArg1 expects at least 2 args"
+ a0, a1, args = args[0], args[1], args[2:]
+ t0, n0, m0 = a0
+ if t0 != "CFAllocatorRef" and m0 != InMode:
+ raise ValueError, "MethodSkipArg1 should have dummy AllocatorRef first arg"
+ t1, n1, m1 = a1
+ if m1 != InMode:
+ raise ValueError, "method's 'self' must be 'InMode'"
+ dummy = Variable(t0, n0, m0)
+ self.argumentList.append(dummy)
+ self.itself = Variable(t1, "_self->ob_itself", SelfMode)
+ self.argumentList.append(self.itself)
+ FunctionGenerator.parseArgumentList(self, args)
# Create the type objects
@@ -111,19 +111,19 @@ extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
PyObject *CFRange_New(CFRange *itself)
{
- return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
+ return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
}
int
CFRange_Convert(PyObject *v, CFRange *p_itself)
{
- long location, length;
-
- if( !PyArg_ParseTuple(v, "ll", &location, &length) )
- return 0;
- p_itself->location = (CFIndex)location;
- p_itself->length = (CFIndex)length;
- return 1;
+ long location, length;
+
+ if( !PyArg_ParseTuple(v, "ll", &location, &length) )
+ return 0;
+ p_itself->location = (CFIndex)location;
+ p_itself->length = (CFIndex)length;
+ return 1;
}
/* Optional CFURL argument or None (passed as NULL) */
@@ -131,8 +131,8 @@ int
OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
{
if ( v == Py_None ) {
- p_itself = NULL;
- return 1;
+ p_itself = NULL;
+ return 1;
}
return CFURLRefObj_Convert(v, p_itself);
}
@@ -143,42 +143,42 @@ finalstuff = finalstuff + """
/* Routines to convert any CF type to/from the corresponding CFxxxObj */
PyObject *CFObj_New(CFTypeRef itself)
{
- if (itself == NULL)
- {
- PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
- return NULL;
- }
- if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself);
- if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself);
- if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself);
- if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself);
- if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself);
- /* XXXX Or should we use PyCF_CF2Python here?? */
- return CFTypeRefObj_New(itself);
+ if (itself == NULL)
+ {
+ PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
+ return NULL;
+ }
+ if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself);
+ if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself);
+ if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself);
+ if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself);
+ if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself);
+ /* XXXX Or should we use PyCF_CF2Python here?? */
+ return CFTypeRefObj_New(itself);
}
int CFObj_Convert(PyObject *v, CFTypeRef *p_itself)
{
- if (v == Py_None) { *p_itself = NULL; return 1; }
- /* Check for other CF objects here */
-
- if (!CFTypeRefObj_Check(v) &&
- !CFArrayRefObj_Check(v) &&
- !CFMutableArrayRefObj_Check(v) &&
- !CFDictionaryRefObj_Check(v) &&
- !CFMutableDictionaryRefObj_Check(v) &&
- !CFDataRefObj_Check(v) &&
- !CFMutableDataRefObj_Check(v) &&
- !CFStringRefObj_Check(v) &&
- !CFMutableStringRefObj_Check(v) &&
- !CFURLRefObj_Check(v) )
- {
- /* XXXX Or should we use PyCF_Python2CF here?? */
- PyErr_SetString(PyExc_TypeError, "CF object required");
- return 0;
- }
- *p_itself = ((CFTypeRefObject *)v)->ob_itself;
- return 1;
+ if (v == Py_None) { *p_itself = NULL; return 1; }
+ /* Check for other CF objects here */
+
+ if (!CFTypeRefObj_Check(v) &&
+ !CFArrayRefObj_Check(v) &&
+ !CFMutableArrayRefObj_Check(v) &&
+ !CFDictionaryRefObj_Check(v) &&
+ !CFMutableDictionaryRefObj_Check(v) &&
+ !CFDataRefObj_Check(v) &&
+ !CFMutableDataRefObj_Check(v) &&
+ !CFStringRefObj_Check(v) &&
+ !CFMutableStringRefObj_Check(v) &&
+ !CFURLRefObj_Check(v) )
+ {
+ /* XXXX Or should we use PyCF_Python2CF here?? */
+ PyErr_SetString(PyExc_TypeError, "CF object required");
+ return 0;
+ }
+ *p_itself = ((CFTypeRefObject *)v)->ob_itself;
+ return 1;
}
"""
@@ -225,7 +225,7 @@ CFComparisonResult = Type("CFComparisonResult", "l") # a bit dangerous, it's an
CFURLPathStyle = Type("CFURLPathStyle", "l") # a bit dangerous, it's an enum
char_ptr = stringptr
-return_stringptr = Type("char *", "s") # ONLY FOR RETURN VALUES!!
+return_stringptr = Type("char *", "s") # ONLY FOR RETURN VALUES!!
CFAllocatorRef = FakeType("(CFAllocatorRef)NULL")
CFArrayCallBacks_ptr = FakeType("&kCFTypeArrayCallBacks")
@@ -251,233 +251,233 @@ OptionalCFURLRef = OpaqueByValueType("CFURLRef", "OptionalCFURLRefObj")
# Our (opaque) objects
class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output('if (itself == NULL)')
- OutLbrace()
- Output('PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");')
- Output('return NULL;')
- OutRbrace()
- def outputStructMembers(self):
- GlobalObjectDefinition.outputStructMembers(self)
- Output("void (*ob_freeit)(CFTypeRef ptr);")
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
-## Output("it->ob_freeit = NULL;")
- Output("it->ob_freeit = CFRelease;")
- def outputCheckConvertArg(self):
- Out("""
- if (v == Py_None) { *p_itself = NULL; return 1; }
- /* Check for other CF objects here */
- """)
- def outputCleanupStructMembers(self):
- Output("if (self->ob_freeit && self->ob_itself)")
- OutLbrace()
- Output("self->ob_freeit((CFTypeRef)self->ob_itself);")
- Output("self->ob_itself = NULL;")
- OutRbrace()
-
- def outputCompare(self):
- Output()
- Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype)
- OutLbrace()
- Output("/* XXXX Or should we use CFEqual?? */")
- Output("if ( self->ob_itself > other->ob_itself ) return 1;")
- Output("if ( self->ob_itself < other->ob_itself ) return -1;")
- Output("return 0;")
- OutRbrace()
-
- def outputHash(self):
- Output()
- Output("static int %s_hash(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("/* XXXX Or should we use CFHash?? */")
- Output("return (int)self->ob_itself;")
- OutRbrace()
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFTypeRef type-%%d object at 0x%%8.8x for 0x%%8.8x>", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
- def output_tp_newBody(self):
- Output("PyObject *self;")
- Output
- Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
- Output("((%s *)self)->ob_itself = NULL;", self.objecttype)
- Output("((%s *)self)->ob_freeit = CFRelease;", self.objecttype)
- Output("return self;")
-
- def output_tp_initBody(self):
- Output("%s itself;", self.itselftype)
- Output("char *kw[] = {\"itself\", 0};")
- Output()
- Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))",
- self.prefix)
- OutLbrace()
- Output("((%s *)self)->ob_itself = itself;", self.objecttype)
- Output("return 0;")
- OutRbrace()
- if self.prefix != 'CFTypeRefObj':
- Output()
- Output("/* Any CFTypeRef descendent is allowed as initializer too */")
- Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))")
- OutLbrace()
- Output("((%s *)self)->ob_itself = itself;", self.objecttype)
- Output("return 0;")
- OutRbrace()
- Output("return -1;")
+ def outputCheckNewArg(self):
+ Output('if (itself == NULL)')
+ OutLbrace()
+ Output('PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");')
+ Output('return NULL;')
+ OutRbrace()
+ def outputStructMembers(self):
+ GlobalObjectDefinition.outputStructMembers(self)
+ Output("void (*ob_freeit)(CFTypeRef ptr);")
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+## Output("it->ob_freeit = NULL;")
+ Output("it->ob_freeit = CFRelease;")
+ def outputCheckConvertArg(self):
+ Out("""
+ if (v == Py_None) { *p_itself = NULL; return 1; }
+ /* Check for other CF objects here */
+ """)
+ def outputCleanupStructMembers(self):
+ Output("if (self->ob_freeit && self->ob_itself)")
+ OutLbrace()
+ Output("self->ob_freeit((CFTypeRef)self->ob_itself);")
+ Output("self->ob_itself = NULL;")
+ OutRbrace()
+
+ def outputCompare(self):
+ Output()
+ Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype)
+ OutLbrace()
+ Output("/* XXXX Or should we use CFEqual?? */")
+ Output("if ( self->ob_itself > other->ob_itself ) return 1;")
+ Output("if ( self->ob_itself < other->ob_itself ) return -1;")
+ Output("return 0;")
+ OutRbrace()
+
+ def outputHash(self):
+ Output()
+ Output("static int %s_hash(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("/* XXXX Or should we use CFHash?? */")
+ Output("return (int)self->ob_itself;")
+ OutRbrace()
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFTypeRef type-%%d object at 0x%%8.8x for 0x%%8.8x>", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;")
+ Output
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("((%s *)self)->ob_itself = NULL;", self.objecttype)
+ Output("((%s *)self)->ob_freeit = CFRelease;", self.objecttype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("%s itself;", self.itselftype)
+ Output("char *kw[] = {\"itself\", 0};")
+ Output()
+ Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))",
+ self.prefix)
+ OutLbrace()
+ Output("((%s *)self)->ob_itself = itself;", self.objecttype)
+ Output("return 0;")
+ OutRbrace()
+ if self.prefix != 'CFTypeRefObj':
+ Output()
+ Output("/* Any CFTypeRef descendent is allowed as initializer too */")
+ Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))")
+ OutLbrace()
+ Output("((%s *)self)->ob_itself = itself;", self.objecttype)
+ Output("return 0;")
+ OutRbrace()
+ Output("return -1;")
class CFTypeRefObjectDefinition(MyGlobalObjectDefinition):
- pass
-
+ pass
+
class CFArrayRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFTypeRef_Type"
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFArrayRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
+ basetype = "CFTypeRef_Type"
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFArrayRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFArrayRef_Type"
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFMutableArrayRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
+ basetype = "CFArrayRef_Type"
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFMutableArrayRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFTypeRef_Type"
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFDictionaryRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
+ basetype = "CFTypeRef_Type"
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFDictionaryRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFDictionaryRef_Type"
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFMutableDictionaryRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
+ basetype = "CFDictionaryRef_Type"
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFMutableDictionaryRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
class CFDataRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFTypeRef_Type"
-
- def outputCheckConvertArg(self):
- Out("""
- if (v == Py_None) { *p_itself = NULL; return 1; }
- if (PyString_Check(v)) {
- char *cStr;
- int cLen;
- if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
- *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
- return 1;
- }
- """)
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFDataRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
+ basetype = "CFTypeRef_Type"
+
+ def outputCheckConvertArg(self):
+ Out("""
+ if (v == Py_None) { *p_itself = NULL; return 1; }
+ if (PyString_Check(v)) {
+ char *cStr;
+ int cLen;
+ if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
+ *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
+ return 1;
+ }
+ """)
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFDataRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFDataRef_Type"
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFMutableDataRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
+ basetype = "CFDataRef_Type"
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFMutableDataRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
class CFStringRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFTypeRef_Type"
-
- def outputCheckConvertArg(self):
- Out("""
- if (v == Py_None) { *p_itself = NULL; return 1; }
- if (PyString_Check(v)) {
- char *cStr;
- if (!PyArg_Parse(v, "es", "ascii", &cStr))
- return NULL;
- *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII);
- return 1;
- }
- if (PyUnicode_Check(v)) {
- /* We use the CF types here, if Python was configured differently that will give an error */
- CFIndex size = PyUnicode_GetSize(v);
- UniChar *unichars = PyUnicode_AsUnicode(v);
- if (!unichars) return 0;
- *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
- return 1;
- }
-
- """)
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFStringRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
+ basetype = "CFTypeRef_Type"
+
+ def outputCheckConvertArg(self):
+ Out("""
+ if (v == Py_None) { *p_itself = NULL; return 1; }
+ if (PyString_Check(v)) {
+ char *cStr;
+ if (!PyArg_Parse(v, "es", "ascii", &cStr))
+ return NULL;
+ *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII);
+ return 1;
+ }
+ if (PyUnicode_Check(v)) {
+ /* We use the CF types here, if Python was configured differently that will give an error */
+ CFIndex size = PyUnicode_GetSize(v);
+ UniChar *unichars = PyUnicode_AsUnicode(v);
+ if (!unichars) return 0;
+ *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
+ return 1;
+ }
+
+ """)
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFStringRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition):
- basetype = "CFStringRef_Type"
-
- def outputCheckConvertArg(self):
- # Mutable, don't allow Python strings
- return MyGlobalObjectDefinition.outputCheckConvertArg(self)
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFMutableStringRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
+ basetype = "CFStringRef_Type"
+
+ def outputCheckConvertArg(self):
+ # Mutable, don't allow Python strings
+ return MyGlobalObjectDefinition.outputCheckConvertArg(self)
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFMutableStringRef object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
class CFURLRefObjectDefinition(MyGlobalObjectDefinition):
- basetype = "CFTypeRef_Type"
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<CFURL object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
+ basetype = "CFTypeRef_Type"
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<CFURL object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
# ADD object class here
@@ -554,10 +554,10 @@ char *data = malloc(size);
if( data == NULL ) return PyErr_NoMemory();
if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) {
- _res = (PyObject *)PyString_FromString(data);
+ _res = (PyObject *)PyString_FromString(data);
} else {
- PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
- _res = NULL;
+ PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
+ _res = NULL;
}
free(data);
return _res;
@@ -605,16 +605,16 @@ CFOptionFlags mutabilityOption;
CFStringRef errorString;
if (!PyArg_ParseTuple(_args, "l",
&mutabilityOption))
- return NULL;
+ return NULL;
_rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL,
_self->ob_itself,
mutabilityOption,
&errorString);
if (errorString)
- CFRelease(errorString);
+ CFRelease(errorString);
if (_rv == NULL) {
- PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data");
- return NULL;
+ PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data");
+ return NULL;
}
_res = Py_BuildValue("O&",
CFTypeRefObj_New, _rv);
@@ -639,17 +639,17 @@ CFTypeRef rv;
CFTypeID typeid;
if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv))
- return NULL;
+ return NULL;
typeid = CFGetTypeID(rv);
if (typeid == CFStringGetTypeID())
- return Py_BuildValue("O&", CFStringRefObj_New, rv);
+ return Py_BuildValue("O&", CFStringRefObj_New, rv);
if (typeid == CFArrayGetTypeID())
- return Py_BuildValue("O&", CFArrayRefObj_New, rv);
+ return Py_BuildValue("O&", CFArrayRefObj_New, rv);
if (typeid == CFDictionaryGetTypeID())
- return Py_BuildValue("O&", CFDictionaryRefObj_New, rv);
+ return Py_BuildValue("O&", CFDictionaryRefObj_New, rv);
if (typeid == CFURLGetTypeID())
- return Py_BuildValue("O&", CFURLRefObj_New, rv);
+ return Py_BuildValue("O&", CFURLRefObj_New, rv);
_res = Py_BuildValue("O&", CFTypeRefObj_New, rv);
return _res;
@@ -663,4 +663,3 @@ module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/cg/cgscan.py b/Mac/Modules/cg/cgscan.py
index 5d84500..b2e7946 100755
--- a/Mac/Modules/cg/cgscan.py
+++ b/Mac/Modules/cg/cgscan.py
@@ -8,77 +8,77 @@ from scantools import Scanner_OSX
LONG = "CoreGraphics"
SHORT = "cg"
-OBJECTS = ("CGContextRef",
- )
+OBJECTS = ("CGContextRef",
+ )
# ADD object typenames here
def main():
- input = [
- "CGContext.h",
- ]
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.gentypetest(SHORT+"typetest.py")
- scanner.close()
- 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! ==="
+ input = [
+ "CGContext.h",
+ ]
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.gentypetest(SHORT+"typetest.py")
+ scanner.close()
+ 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_OSX):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t in OBJECTS and m == "InMode":
- classname = "Method"
- listname = t + "_methods"
- # Special case for the silly first AllocatorRef argument
- if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1:
- t, n, m = arglist[1]
- if t in OBJECTS and m == "InMode":
- classname = "MethodSkipArg1"
- listname = t + "_methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in OBJECTS and m == "InMode":
+ classname = "Method"
+ listname = t + "_methods"
+ # Special case for the silly first AllocatorRef argument
+ if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1:
+ t, n, m = arglist[1]
+ if t in OBJECTS and m == "InMode":
+ classname = "MethodSkipArg1"
+ listname = t + "_methods"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- def makeblacklistnames(self):
- return [
- "CGContextRetain",
- "CGContextRelease",
- ]
+ def makeblacklistnames(self):
+ return [
+ "CGContextRetain",
+ "CGContextRelease",
+ ]
- def makegreylist(self):
- return []
+ def makegreylist(self):
+ return []
- def makeblacklisttypes(self):
- return [
- "float_ptr",
- "CGRect_ptr",
- "CGPoint_ptr",
- "CGColorSpaceRef",
- "CGColorRenderingIntent",
- "CGFontRef",
-# "char_ptr",
- "CGGlyph_ptr",
- "CGImageRef",
- "CGPDFDocumentRef",
- ]
+ def makeblacklisttypes(self):
+ return [
+ "float_ptr",
+ "CGRect_ptr",
+ "CGPoint_ptr",
+ "CGColorSpaceRef",
+ "CGColorRenderingIntent",
+ "CGFontRef",
+# "char_ptr",
+ "CGGlyph_ptr",
+ "CGImageRef",
+ "CGPDFDocumentRef",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("char_ptr", "cstring", "InMode"), ("size_t", "length", "InMode")],
+ [("InBuffer", "*", "*")]),
+# ([("char_ptr", "name", "InMode"),],
+# [("CCCCC", "*", "*")]),
+ ]
- def makerepairinstructions(self):
- return [
- ([("char_ptr", "cstring", "InMode"), ("size_t", "length", "InMode")],
- [("InBuffer", "*", "*")]),
-# ([("char_ptr", "name", "InMode"),],
-# [("CCCCC", "*", "*")]),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/cg/cgsupport.py b/Mac/Modules/cg/cgsupport.py
index 7dc2d54..6eedfbe 100755
--- a/Mac/Modules/cg/cgsupport.py
+++ b/Mac/Modules/cg/cgsupport.py
@@ -8,12 +8,12 @@
import string
# Declarations that change for each manager
-MODNAME = '_CG' # The name of the module
+MODNAME = '_CG' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'CG' # The prefix for module-wide routines
+MODPREFIX = 'CG' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -34,74 +34,74 @@ extern int GrafObj_Convert(PyObject *, GrafPtr *);
PyObject *CGPoint_New(CGPoint *itself)
{
- return Py_BuildValue("(ff)",
- itself->x,
- itself->y);
+ return Py_BuildValue("(ff)",
+ itself->x,
+ itself->y);
}
int
CGPoint_Convert(PyObject *v, CGPoint *p_itself)
{
- if( !PyArg_Parse(v, "(ff)",
- &p_itself->x,
- &p_itself->y) )
- return 0;
- return 1;
+ if( !PyArg_Parse(v, "(ff)",
+ &p_itself->x,
+ &p_itself->y) )
+ return 0;
+ return 1;
}
PyObject *CGRect_New(CGRect *itself)
{
- return Py_BuildValue("(ffff)",
- itself->origin.x,
- itself->origin.y,
- itself->size.width,
- itself->size.height);
+ return Py_BuildValue("(ffff)",
+ itself->origin.x,
+ itself->origin.y,
+ itself->size.width,
+ itself->size.height);
}
int
CGRect_Convert(PyObject *v, CGRect *p_itself)
{
- if( !PyArg_Parse(v, "(ffff)",
- &p_itself->origin.x,
- &p_itself->origin.y,
- &p_itself->size.width,
- &p_itself->size.height) )
- return 0;
- return 1;
+ if( !PyArg_Parse(v, "(ffff)",
+ &p_itself->origin.x,
+ &p_itself->origin.y,
+ &p_itself->size.width,
+ &p_itself->size.height) )
+ return 0;
+ return 1;
}
PyObject *CGAffineTransform_New(CGAffineTransform *itself)
{
- return Py_BuildValue("(ffffff)",
- itself->a,
- itself->b,
- itself->c,
- itself->d,
- itself->tx,
- itself->ty);
+ return Py_BuildValue("(ffffff)",
+ itself->a,
+ itself->b,
+ itself->c,
+ itself->d,
+ itself->tx,
+ itself->ty);
}
int
CGAffineTransform_Convert(PyObject *v, CGAffineTransform *p_itself)
{
- if( !PyArg_Parse(v, "(ffffff)",
- &p_itself->a,
- &p_itself->b,
- &p_itself->c,
- &p_itself->d,
- &p_itself->tx,
- &p_itself->ty) )
- return 0;
- return 1;
+ if( !PyArg_Parse(v, "(ffffff)",
+ &p_itself->a,
+ &p_itself->b,
+ &p_itself->c,
+ &p_itself->d,
+ &p_itself->tx,
+ &p_itself->ty) )
+ return 0;
+ return 1;
}
"""
class MyOpaqueByValueType(OpaqueByValueType):
- """Sort of a mix between OpaqueByValueType and OpaqueType."""
- def mkvalueArgs(self, name):
- return "%s, &%s" % (self.new, name)
+ """Sort of a mix between OpaqueByValueType and OpaqueType."""
+ def mkvalueArgs(self, name):
+ return "%s, &%s" % (self.new, name)
CGPoint = MyOpaqueByValueType('CGPoint', 'CGPoint')
CGRect = MyOpaqueByValueType('CGRect', 'CGRect')
@@ -121,10 +121,10 @@ CGContextRef = OpaqueByValueType("CGContextRef", "CGContextRefObj")
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputStructMembers(self):
- ObjectDefinition.outputStructMembers(self)
- def outputCleanupStructMembers(self):
- Output("CGContextRelease(self->ob_itself);")
+ def outputStructMembers(self):
+ ObjectDefinition.outputStructMembers(self)
+ def outputCleanupStructMembers(self):
+ Output("CGContextRelease(self->ob_itself);")
# Create the generator groups and link them
@@ -169,11 +169,11 @@ CGContextRef ctx;
OSStatus _err;
if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port))
- return NULL;
+ return NULL;
_err = CreateCGContextForPort(port, &ctx);
if (_err != noErr)
- if (_err != noErr) return PyMac_Error(_err);
+ if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&", CGContextRefObj_New, ctx);
return _res;
"""
@@ -185,9 +185,8 @@ module.add(f)
# ADD add forloop here
for f in CGContextRef_methods:
- CGContextRef_object.add(f)
+ CGContextRef_object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/cm/cmscan.py b/Mac/Modules/cm/cmscan.py
index 6e56cb2..087f239 100644
--- a/Mac/Modules/cm/cmscan.py
+++ b/Mac/Modules/cm/cmscan.py
@@ -10,80 +10,80 @@ LONG = "Components"
SHORT = "cm"
def main():
- input = "Components.h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = "Components.h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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]
- #
- # FindNextComponent is a special case, since it call also be called
- # with None as the argument. Hence, we make it a function
- #
- if t == "Component" and m == "InMode" and name != "FindNextComponent":
- classname = "Method"
- listname = "c_methods"
- elif t == "ComponentInstance" and m == "InMode":
- classname = "Method"
- listname = "ci_methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ #
+ # FindNextComponent is a special case, since it call also be called
+ # with None as the argument. Hence, we make it a function
+ #
+ if t == "Component" and m == "InMode" and name != "FindNextComponent":
+ classname = "Method"
+ listname = "c_methods"
+ elif t == "ComponentInstance" and m == "InMode":
+ classname = "Method"
+ listname = "ci_methods"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- def makeblacklistnames(self):
- return [
- "OpenADefaultComponent",
- "GetComponentTypeModSeed",
- "OpenAComponentResFile",
- "CallComponentUnregister",
- "CallComponentTarget",
- "CallComponentRegister",
- "CallComponentVersion",
- "CallComponentCanDo",
- "CallComponentClose",
- "CallComponentOpen",
- "OpenAComponent",
- "GetComponentPublicResource", # Missing in CW Pro 6
- "CallComponentGetPublicResource", # Missing in CW Pro 6
- 'SetComponentInstanceA5',
- 'GetComponentInstanceA5',
- ]
+ def makeblacklistnames(self):
+ return [
+ "OpenADefaultComponent",
+ "GetComponentTypeModSeed",
+ "OpenAComponentResFile",
+ "CallComponentUnregister",
+ "CallComponentTarget",
+ "CallComponentRegister",
+ "CallComponentVersion",
+ "CallComponentCanDo",
+ "CallComponentClose",
+ "CallComponentOpen",
+ "OpenAComponent",
+ "GetComponentPublicResource", # Missing in CW Pro 6
+ "CallComponentGetPublicResource", # Missing in CW Pro 6
+ 'SetComponentInstanceA5',
+ 'GetComponentInstanceA5',
+ ]
- def makeblacklisttypes(self):
- return [
- "ResourceSpec",
- "ComponentResource",
- "ComponentPlatformInfo",
- "ComponentResourceExtension",
- "ComponentPlatformInfoArray",
- "ExtComponentResource",
- "ComponentParameters",
-
- "ComponentRoutineUPP",
- "ComponentMPWorkFunctionUPP",
- "ComponentFunctionUPP",
- "GetMissingComponentResourceUPP",
- ]
+ def makeblacklisttypes(self):
+ return [
+ "ResourceSpec",
+ "ComponentResource",
+ "ComponentPlatformInfo",
+ "ComponentResourceExtension",
+ "ComponentPlatformInfoArray",
+ "ExtComponentResource",
+ "ComponentParameters",
+
+ "ComponentRoutineUPP",
+ "ComponentMPWorkFunctionUPP",
+ "ComponentFunctionUPP",
+ "GetMissingComponentResourceUPP",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([('ComponentDescription', 'looking', 'OutMode')],
+ [('ComponentDescription', '*', 'InMode')]),
+ ]
- def makerepairinstructions(self):
- return [
- ([('ComponentDescription', 'looking', 'OutMode')],
- [('ComponentDescription', '*', 'InMode')]),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/cm/cmsupport.py b/Mac/Modules/cm/cmsupport.py
index 98018c4..4109dba 100644
--- a/Mac/Modules/cm/cmsupport.py
+++ b/Mac/Modules/cm/cmsupport.py
@@ -6,15 +6,15 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Components.h' # The Apple header file
-MODNAME = '_Cm' # The name of the module
+MACHEADERFILE = 'Components.h' # The Apple header file
+MODNAME = '_Cm' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Cm' # The prefix for module-wide routines
-C_OBJECTPREFIX = 'CmpObj' # The prefix for object methods
+MODPREFIX = 'Cm' # The prefix for module-wide routines
+C_OBJECTPREFIX = 'CmpObj' # The prefix for object methods
CI_OBJECTPREFIX = 'CmpInstObj'
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -42,30 +42,30 @@ static PyObject *
CmpDesc_New(ComponentDescription *itself)
{
- return Py_BuildValue("O&O&O&ll",
- PyMac_BuildOSType, itself->componentType,
- PyMac_BuildOSType, itself->componentSubType,
- PyMac_BuildOSType, itself->componentManufacturer,
- itself->componentFlags, itself->componentFlagsMask);
+ return Py_BuildValue("O&O&O&ll",
+ PyMac_BuildOSType, itself->componentType,
+ PyMac_BuildOSType, itself->componentSubType,
+ PyMac_BuildOSType, itself->componentManufacturer,
+ itself->componentFlags, itself->componentFlagsMask);
}
static int
CmpDesc_Convert(PyObject *v, ComponentDescription *p_itself)
{
- return PyArg_ParseTuple(v, "O&O&O&ll",
- PyMac_GetOSType, &p_itself->componentType,
- PyMac_GetOSType, &p_itself->componentSubType,
- PyMac_GetOSType, &p_itself->componentManufacturer,
- &p_itself->componentFlags, &p_itself->componentFlagsMask);
+ return PyArg_ParseTuple(v, "O&O&O&ll",
+ PyMac_GetOSType, &p_itself->componentType,
+ PyMac_GetOSType, &p_itself->componentSubType,
+ PyMac_GetOSType, &p_itself->componentManufacturer,
+ &p_itself->componentFlags, &p_itself->componentFlagsMask);
}
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert);
"""
ComponentDescription = OpaqueType('ComponentDescription', 'CmpDesc')
@@ -76,30 +76,30 @@ ComponentResult = Type("ComponentResult", "l")
ComponentResourceHandle = OpaqueByValueType("ComponentResourceHandle", "ResObj")
class MyCIObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- PyErr_SetString(Cm_Error,"NULL ComponentInstance");
- return NULL;
- }""")
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ PyErr_SetString(Cm_Error,"NULL ComponentInstance");
+ return NULL;
+ }""")
class MyCObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- /* XXXX Or should we return None? */
- PyErr_SetString(Cm_Error,"No such component");
- return NULL;
- }""")
-
- def outputCheckConvertArg(self):
- Output("""if ( v == Py_None ) {
- *p_itself = 0;
- return 1;
- }""")
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ /* XXXX Or should we return None? */
+ PyErr_SetString(Cm_Error,"No such component");
+ return NULL;
+ }""")
+
+ def outputCheckConvertArg(self):
+ Output("""if ( v == Py_None ) {
+ *p_itself = 0;
+ return 1;
+ }""")
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
ci_object = MyCIObjectDefinition('ComponentInstance', CI_OBJECTPREFIX,
- 'ComponentInstance')
+ 'ComponentInstance')
c_object = MyCObjectDefinition('Component', C_OBJECTPREFIX, 'Component')
module.addobject(ci_object)
module.addobject(c_object)
@@ -123,4 +123,3 @@ for f in ci_methods: ci_object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/ctl/ctledit.py b/Mac/Modules/ctl/ctledit.py
index 6ba024b..fdd9712 100644
--- a/Mac/Modules/ctl/ctledit.py
+++ b/Mac/Modules/ctl/ctledit.py
@@ -8,7 +8,7 @@ f = Function(ExistingControlHandle, 'FindControlUnderMouse',
functions.append(f)
f = Function(ControlHandle, 'as_Control',
- (Handle, 'h', InMode))
+ (Handle, 'h', InMode))
functions.append(f)
f = Method(Handle, 'as_Resource', (ControlHandle, 'ctl', InMode))
@@ -18,16 +18,16 @@ f = Method(void, 'GetControlRect', (ControlHandle, 'ctl', InMode), (Rect, 'rect'
methods.append(f)
DisposeControl_body = """
- if (!PyArg_ParseTuple(_args, ""))
- return NULL;
- if ( _self->ob_itself ) {
- SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */
- DisposeControl(_self->ob_itself);
- _self->ob_itself = NULL;
- }
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ if ( _self->ob_itself ) {
+ SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */
+ DisposeControl(_self->ob_itself);
+ _self->ob_itself = NULL;
+ }
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
"""
f = ManualGenerator("DisposeControl", DisposeControl_body)
@@ -39,7 +39,7 @@ methods.append(f)
# parameter; these should however be managed by us (we're creating them
# after all), so set the type to ControlRef.
for f in functions:
- if f.name.startswith("Create"):
- v = f.argumentList[-1]
- if v.type == ExistingControlHandle:
- v.type = ControlRef
+ if f.name.startswith("Create"):
+ v = f.argumentList[-1]
+ if v.type == ExistingControlHandle:
+ v.type = ControlRef
diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py
index 818541e..25333f1 100644
--- a/Mac/Modules/ctl/ctlscan.py
+++ b/Mac/Modules/ctl/ctlscan.py
@@ -7,166 +7,166 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
-# input = "Controls.h" # Universal Headers < 3.3
- input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
- output = "ctlgen.py"
- defsoutput = TOOLBOXDIR + "Controls.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
- import ctlsupport
- print "=== Done. It's up to you to compile Ctlmodule.c ==="
+# input = "Controls.h" # Universal Headers < 3.3
+ input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
+ output = "ctlgen.py"
+ defsoutput = TOOLBOXDIR + "Controls.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
+ import ctlsupport
+ print "=== Done. It's up to you to compile Ctlmodule.c ==="
class MyScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t in ("ControlHandle", "ControlRef") 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.TextEdit import *\n")
- self.defsfile.write("from Carbon.QuickDraw import *\n")
- self.defsfile.write("from Carbon.Dragconst import *\n")
- self.defsfile.write("from Carbon.CarbonEvents import *\n")
- self.defsfile.write("from Carbon.Appearance import *\n")
- self.defsfile.write("kDataBrowserItemAnyState = -1\n")
- self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n")
- self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n")
- self.defsfile.write("\n")
-
- def makeblacklistnames(self):
- return [
- 'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
- 'DisposeControl', # Generated manually
- 'KillControls', # Implied by close of dialog
- 'SetCtlAction',
- 'TrackControl', # Generated manually
- 'HandleControlClick', # Generated manually
- 'SetControlData', # Generated manually
- 'GetControlData', # Generated manually
- 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
- 'kDataBrowserClientPropertyFlagsMask', # ditto
- 'kDataBrowserItemAnyState', # and ditto
- # The following are unavailable for static 68k (appearance manager)
-## 'GetBevelButtonMenuValue',
-## 'SetBevelButtonMenuValue',
-## 'GetBevelButtonMenuHandle',
-## 'SetBevelButtonTransform',
- 'SetBevelButtonGraphicAlignment',
- 'SetBevelButtonTextAlignment',
- 'SetBevelButtonTextPlacement',
-## 'SetImageWellTransform',
-## 'GetTabContentRect',
-## 'SetTabEnabled',
-## 'SetDisclosureTriangleLastValue',
-## # Unavailable in CW Pro 3 libraries
-## 'SetUpControlTextColor',
-## # Unavailable in Jack's CW Pro 5.1 libraries
-## 'GetControlRegion',
-## 'RemoveControlProperty',
-## 'IsValidControlHandle',
-## 'SetControl32BitMinimum',
-## 'GetControl32BitMinimum',
-## 'SetControl32BitMaximum',
-## 'GetControl32BitMaximum',
-## 'SetControl32BitValue',
-## 'GetControl32BitValue',
-## 'SetControlViewSize',
-## 'GetControlViewSize',
- # Generally Bad News
- 'GetControlProperty',
- 'SetControlProperty',
- 'GetControlPropertySize',
- 'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
- 'CreateTabsControl', # wrote manually
- 'GetControlAction', # too much effort for too little usefulness
-
- # too lazy for now
- 'GetImageWellContentInfo',
- 'GetBevelButtonContentInfo',
- # OS8 only
- 'GetAuxiliaryControlRecord',
- 'SetControlColor',
- ]
-
- def makeblacklisttypes(self):
- return [
- 'ProcPtr',
-# 'ControlActionUPP',
- 'Ptr',
- 'ControlDefSpec', # Don't know how to do this yet
- 'ControlDefSpec_ptr', # ditto
- 'Collection', # Ditto
- # not-yet-supported stuff in Universal Headers 3.4:
- 'ControlColorUPP',
- 'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
-# 'ControlTabEntry_ptr', # XXX needed for tabs
-# 'ControlButtonContentInfoPtr',
-# 'ControlButtonContentInfo', # XXX ugh: a union
-# 'ControlButtonContentInfo_ptr', # XXX ugh: a union
- 'ListDefSpec_ptr', # XXX see _Listmodule.c, tricky but possible
- 'DataBrowserItemID_ptr', # XXX array of UInt32, for BrowserView
- 'DataBrowserItemUPP',
- 'DataBrowserItemDataRef', # XXX void *
- 'DataBrowserCallbacks', # difficult struct
- 'DataBrowserCallbacks_ptr',
- 'DataBrowserCustomCallbacks',
- 'DataBrowserCustomCallbacks_ptr',
-## 'DataBrowserTableViewColumnDesc',
-## 'DataBrowserListViewColumnDesc',
- 'CFDataRef',
- 'DataBrowserListViewHeaderDesc', # difficult struct
- ]
-
- def makerepairinstructions(self):
- return [
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode"),
- ("long", "*", "OutMode")],
- [("VarVarOutBuffer", "*", "InOutMode")]),
-
-## # For TrackControl
-## ([("ProcPtr", "actionProc", "InMode")],
-## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
-## ([("ControlActionUPP", "actionProc", "InMode")],
-## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
-
- # For GetControlTitle
- ([('Str255', 'title', 'InMode')],
- [('Str255', 'title', 'OutMode')]),
-
- ([("ControlHandle", "*", "OutMode")],
- [("ExistingControlHandle", "*", "*")]),
- ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
- [("ExistingControlHandle", "*", "*")]),
-
- ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
- [("void", "*", "ReturnMode")]),
-
- ([("DataBrowserListViewColumnDesc", "*", "OutMode")],
- [("DataBrowserListViewColumnDesc", "*", "InMode")]),
-
- ([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
- [("ControlButtonContentInfoPtr", '*', "OutMode")]),
-
- ([("ControlButtonContentInfo", '*', "OutMode")],
- [("ControlButtonContentInfo", '*', "InMode")]),
-
- ([("ControlActionUPP", 'liveTrackingProc', "InMode")],
- [("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
- ]
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in ("ControlHandle", "ControlRef") 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.TextEdit import *\n")
+ self.defsfile.write("from Carbon.QuickDraw import *\n")
+ self.defsfile.write("from Carbon.Dragconst import *\n")
+ self.defsfile.write("from Carbon.CarbonEvents import *\n")
+ self.defsfile.write("from Carbon.Appearance import *\n")
+ self.defsfile.write("kDataBrowserItemAnyState = -1\n")
+ self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n")
+ self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n")
+ self.defsfile.write("\n")
+
+ def makeblacklistnames(self):
+ return [
+ 'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
+ 'DisposeControl', # Generated manually
+ 'KillControls', # Implied by close of dialog
+ 'SetCtlAction',
+ 'TrackControl', # Generated manually
+ 'HandleControlClick', # Generated manually
+ 'SetControlData', # Generated manually
+ 'GetControlData', # Generated manually
+ 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
+ 'kDataBrowserClientPropertyFlagsMask', # ditto
+ 'kDataBrowserItemAnyState', # and ditto
+ # The following are unavailable for static 68k (appearance manager)
+## 'GetBevelButtonMenuValue',
+## 'SetBevelButtonMenuValue',
+## 'GetBevelButtonMenuHandle',
+## 'SetBevelButtonTransform',
+ 'SetBevelButtonGraphicAlignment',
+ 'SetBevelButtonTextAlignment',
+ 'SetBevelButtonTextPlacement',
+## 'SetImageWellTransform',
+## 'GetTabContentRect',
+## 'SetTabEnabled',
+## 'SetDisclosureTriangleLastValue',
+## # Unavailable in CW Pro 3 libraries
+## 'SetUpControlTextColor',
+## # Unavailable in Jack's CW Pro 5.1 libraries
+## 'GetControlRegion',
+## 'RemoveControlProperty',
+## 'IsValidControlHandle',
+## 'SetControl32BitMinimum',
+## 'GetControl32BitMinimum',
+## 'SetControl32BitMaximum',
+## 'GetControl32BitMaximum',
+## 'SetControl32BitValue',
+## 'GetControl32BitValue',
+## 'SetControlViewSize',
+## 'GetControlViewSize',
+ # Generally Bad News
+ 'GetControlProperty',
+ 'SetControlProperty',
+ 'GetControlPropertySize',
+ 'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
+ 'CreateTabsControl', # wrote manually
+ 'GetControlAction', # too much effort for too little usefulness
+
+ # too lazy for now
+ 'GetImageWellContentInfo',
+ 'GetBevelButtonContentInfo',
+ # OS8 only
+ 'GetAuxiliaryControlRecord',
+ 'SetControlColor',
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ 'ProcPtr',
+# 'ControlActionUPP',
+ 'Ptr',
+ 'ControlDefSpec', # Don't know how to do this yet
+ 'ControlDefSpec_ptr', # ditto
+ 'Collection', # Ditto
+ # not-yet-supported stuff in Universal Headers 3.4:
+ 'ControlColorUPP',
+ 'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
+# 'ControlTabEntry_ptr', # XXX needed for tabs
+# 'ControlButtonContentInfoPtr',
+# 'ControlButtonContentInfo', # XXX ugh: a union
+# 'ControlButtonContentInfo_ptr', # XXX ugh: a union
+ 'ListDefSpec_ptr', # XXX see _Listmodule.c, tricky but possible
+ 'DataBrowserItemID_ptr', # XXX array of UInt32, for BrowserView
+ 'DataBrowserItemUPP',
+ 'DataBrowserItemDataRef', # XXX void *
+ 'DataBrowserCallbacks', # difficult struct
+ 'DataBrowserCallbacks_ptr',
+ 'DataBrowserCustomCallbacks',
+ 'DataBrowserCustomCallbacks_ptr',
+## 'DataBrowserTableViewColumnDesc',
+## 'DataBrowserListViewColumnDesc',
+ 'CFDataRef',
+ 'DataBrowserListViewHeaderDesc', # difficult struct
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode"),
+ ("long", "*", "OutMode")],
+ [("VarVarOutBuffer", "*", "InOutMode")]),
+
+## # For TrackControl
+## ([("ProcPtr", "actionProc", "InMode")],
+## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
+## ([("ControlActionUPP", "actionProc", "InMode")],
+## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
+
+ # For GetControlTitle
+ ([('Str255', 'title', 'InMode')],
+ [('Str255', 'title', 'OutMode')]),
+
+ ([("ControlHandle", "*", "OutMode")],
+ [("ExistingControlHandle", "*", "*")]),
+ ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
+ [("ExistingControlHandle", "*", "*")]),
+
+ ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
+ [("void", "*", "ReturnMode")]),
+
+ ([("DataBrowserListViewColumnDesc", "*", "OutMode")],
+ [("DataBrowserListViewColumnDesc", "*", "InMode")]),
+
+ ([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
+ [("ControlButtonContentInfoPtr", '*', "OutMode")]),
+
+ ([("ControlButtonContentInfo", '*', "OutMode")],
+ [("ControlButtonContentInfo", '*', "InMode")]),
+
+ ([("ControlActionUPP", 'liveTrackingProc', "InMode")],
+ [("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
+ ]
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py
index b2d9ad5..d354d94 100644
--- a/Mac/Modules/ctl/ctlsupport.py
+++ b/Mac/Modules/ctl/ctlsupport.py
@@ -6,16 +6,16 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Controls.h' # The Apple header file
-MODNAME = '_Ctl' # The name of the module
-OBJECTNAME = 'Control' # The basic name of the objects used here
+MACHEADERFILE = 'Controls.h' # The Apple header file
+MODNAME = '_Ctl' # The name of the module
+OBJECTNAME = 'Control' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Ctl' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Ctl' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -79,11 +79,11 @@ DataBrowserPropertyType = OSType
ControlDisclosureTriangleOrientation = UInt16
DataBrowserTableViewColumnDesc = OpaqueType("DataBrowserTableViewColumnDesc",
- "DataBrowserTableViewColumnDesc")
+ "DataBrowserTableViewColumnDesc")
DataBrowserListViewColumnDesc = OpaqueType("DataBrowserListViewColumnDesc",
- "DataBrowserListViewColumnDesc")
+ "DataBrowserListViewColumnDesc")
ControlButtonContentInfo = OpaqueType("ControlButtonContentInfo",
- "ControlButtonContentInfo")
+ "ControlButtonContentInfo")
ControlButtonContentInfoPtr = ControlButtonContentInfo_ptr = ControlButtonContentInfo
ControlTabEntry_ptr = OpaqueType("ControlTabEntry", "ControlTabEntry")
@@ -95,17 +95,17 @@ ControlBevelButtonMenuPlacement = UInt16
ControlPushButtonIconAlignment = UInt16
class ControlActionDefinition(Type):
- def declare(self, name):
- Output("%s %s;", self.typeName, name)
- Output("UniversalProcPtr c_callback;")
- def passInput(self, name):
- return "myactionproc_upp"
- def cleanup(self, name):
- Output("setcallback((PyObject*)_self, kMyControlActionProcTag, actionProc, &c_callback);")
+ def declare(self, name):
+ Output("%s %s;", self.typeName, name)
+ Output("UniversalProcPtr c_callback;")
+ def passInput(self, name):
+ return "myactionproc_upp"
+ def cleanup(self, name):
+ Output("setcallback((PyObject*)_self, kMyControlActionProcTag, actionProc, &c_callback);")
class ControlActionDefinitionNewControl(ControlActionDefinition):
- def cleanup(self, name):
- Output("setcallback(_res, kMyControlActionProcTag, liveTrackingProc, &c_callback);")
+ def cleanup(self, name):
+ Output("setcallback(_res, kMyControlActionProcTag, liveTrackingProc, &c_callback);")
ControlActionUPP = ControlActionDefinition("PyObject*", "O")
ControlActionUPPNewControl = ControlActionDefinitionNewControl("PyObject*", "O")
@@ -138,19 +138,19 @@ static PyObject *
ControlFontStyle_New(ControlFontStyleRec *itself)
{
- return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font,
- itself->size, itself->style, itself->mode, itself->just,
- QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor);
+ return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font,
+ itself->size, itself->style, itself->mode, itself->just,
+ QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor);
}
#endif
static int
ControlFontStyle_Convert(PyObject *v, ControlFontStyleRec *itself)
{
- return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags,
- &itself->font, &itself->size, &itself->style, &itself->mode,
- &itself->just, QdRGB_Convert, &itself->foreColor,
- QdRGB_Convert, &itself->backColor);
+ return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags,
+ &itself->font, &itself->size, &itself->style, &itself->mode,
+ &itself->just, QdRGB_Convert, &itself->foreColor,
+ QdRGB_Convert, &itself->backColor);
}
/*
@@ -160,13 +160,13 @@ static PyObject *
PyControlID_New(ControlID *itself)
{
- return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id);
+ return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id);
}
static int
PyControlID_Convert(PyObject *v, ControlID *itself)
{
- return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id);
+ return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id);
}
/*
@@ -175,40 +175,40 @@ PyControlID_Convert(PyObject *v, ControlID *itself)
static int
DataBrowserTableViewColumnDesc_Convert(PyObject *v, DataBrowserTableViewColumnDesc *itself)
{
- return PyArg_Parse(v, "(lO&l)",
- &itself->propertyID,
- PyMac_GetOSType, &itself->propertyType,
- &itself->propertyFlags);
+ return PyArg_Parse(v, "(lO&l)",
+ &itself->propertyID,
+ PyMac_GetOSType, &itself->propertyType,
+ &itself->propertyFlags);
}
static int
ControlButtonContentInfo_Convert(PyObject *v, ControlButtonContentInfo *itself)
{
- return PyArg_Parse(v, "(hO&)",
- &itself->contentType,
- OptResObj_Convert, &itself->u.iconSuite);
+ return PyArg_Parse(v, "(hO&)",
+ &itself->contentType,
+ OptResObj_Convert, &itself->u.iconSuite);
}
static int
DataBrowserListViewHeaderDesc_Convert(PyObject *v, DataBrowserListViewHeaderDesc *itself)
{
- itself->version = kDataBrowserListViewLatestHeaderDesc;
- return PyArg_Parse(v, "(HHhO&HO&O&)",
- &itself->minimumWidth,
- &itself->maximumWidth,
- &itself->titleOffset,
- CFStringRefObj_Convert, &itself->titleString,
- &itself->initialOrder,
- ControlFontStyle_Convert, &itself->btnFontStyle,
- ControlButtonContentInfo_Convert, &itself->btnContentInfo);
+ itself->version = kDataBrowserListViewLatestHeaderDesc;
+ return PyArg_Parse(v, "(HHhO&HO&O&)",
+ &itself->minimumWidth,
+ &itself->maximumWidth,
+ &itself->titleOffset,
+ CFStringRefObj_Convert, &itself->titleString,
+ &itself->initialOrder,
+ ControlFontStyle_Convert, &itself->btnFontStyle,
+ ControlButtonContentInfo_Convert, &itself->btnContentInfo);
}
static int
DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc *itself)
{
- return PyArg_Parse(v, "(O&O&)",
- DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc,
- DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc);
+ return PyArg_Parse(v, "(O&O&)",
+ DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc,
+ DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc);
}
/* TrackControl and HandleControlClick callback support */
@@ -223,8 +223,8 @@ static ControlUserPaneIdleUPP myidleproc_upp;
static ControlUserPaneHitTestUPP myhittestproc_upp;
static ControlUserPaneTrackingUPP mytrackingproc_upp;
-static int settrackfunc(PyObject *); /* forward */
-static void clrtrackfunc(void); /* forward */
+static int settrackfunc(PyObject *); /* forward */
+static void clrtrackfunc(void); /* forward */
static int setcallback(PyObject *, OSType, PyObject *, UniversalProcPtr *);
"""
@@ -232,239 +232,239 @@ finalstuff = finalstuff + """
static PyObject *
CtlObj_NewUnmanaged(ControlHandle itself)
{
- ControlObject *it;
- if (itself == NULL) return PyMac_Error(resNotFound);
- it = PyObject_NEW(ControlObject, &Control_Type);
- if (it == NULL) return NULL;
- it->ob_itself = itself;
- it->ob_callbackdict = NULL;
- return (PyObject *)it;
+ ControlObject *it;
+ if (itself == NULL) return PyMac_Error(resNotFound);
+ it = PyObject_NEW(ControlObject, &Control_Type);
+ if (it == NULL) return NULL;
+ it->ob_itself = itself;
+ it->ob_callbackdict = NULL;
+ return (PyObject *)it;
}
static PyObject *
CtlObj_WhichControl(ControlHandle c)
{
- PyObject *it;
-
- if (c == NULL)
- it = Py_None;
- else {
- it = (PyObject *) GetControlReference(c);
- /*
- ** If the refcon is zero or doesn't point back to the Python object
- ** the control is not ours. Return a temporary object.
- */
- if (it == NULL || ((ControlObject *)it)->ob_itself != c)
- return CtlObj_NewUnmanaged(c);
- }
- Py_INCREF(it);
- return it;
+ PyObject *it;
+
+ if (c == NULL)
+ it = Py_None;
+ else {
+ it = (PyObject *) GetControlReference(c);
+ /*
+ ** If the refcon is zero or doesn't point back to the Python object
+ ** the control is not ours. Return a temporary object.
+ */
+ if (it == NULL || ((ControlObject *)it)->ob_itself != c)
+ return CtlObj_NewUnmanaged(c);
+ }
+ Py_INCREF(it);
+ return it;
}
static int
settrackfunc(PyObject *obj)
{
- if (tracker) {
- PyErr_SetString(Ctl_Error, "Tracker function in use");
- return 0;
- }
- tracker = obj;
- Py_INCREF(tracker);
- return 1;
+ if (tracker) {
+ PyErr_SetString(Ctl_Error, "Tracker function in use");
+ return 0;
+ }
+ tracker = obj;
+ Py_INCREF(tracker);
+ return 1;
}
static void
clrtrackfunc(void)
{
- Py_XDECREF(tracker);
- tracker = 0;
+ Py_XDECREF(tracker);
+ tracker = 0;
}
static pascal void
mytracker(ControlHandle ctl, short part)
{
- PyObject *args, *rv=0;
-
- args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
- if (args && tracker) {
- rv = PyEval_CallObject(tracker, args);
- Py_DECREF(args);
- }
- if (rv)
- Py_DECREF(rv);
- else {
- PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n");
- PyErr_Print();
- }
+ PyObject *args, *rv=0;
+
+ args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
+ if (args && tracker) {
+ rv = PyEval_CallObject(tracker, args);
+ Py_DECREF(args);
+ }
+ if (rv)
+ Py_DECREF(rv);
+ else {
+ PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n");
+ PyErr_Print();
+ }
}
static int
setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr *uppp)
{
- ControlObject *self = (ControlObject *)myself;
- char keybuf[9];
-
- if ( which == kMyControlActionProcTag )
- *uppp = (UniversalProcPtr)myactionproc_upp;
- else if ( which == kControlUserPaneKeyDownProcTag )
- *uppp = (UniversalProcPtr)mykeydownproc_upp;
- else if ( which == kControlUserPaneFocusProcTag )
- *uppp = (UniversalProcPtr)myfocusproc_upp;
- else if ( which == kControlUserPaneDrawProcTag )
- *uppp = (UniversalProcPtr)mydrawproc_upp;
- else if ( which == kControlUserPaneIdleProcTag )
- *uppp = (UniversalProcPtr)myidleproc_upp;
- else if ( which == kControlUserPaneHitTestProcTag )
- *uppp = (UniversalProcPtr)myhittestproc_upp;
- else if ( which == kControlUserPaneTrackingProcTag )
- *uppp = (UniversalProcPtr)mytrackingproc_upp;
- else
- return -1;
- /* Only now do we test for clearing of the callback: */
- if ( callback == Py_None )
- *uppp = NULL;
- /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */
- if ( self->ob_callbackdict == NULL )
- if ( (self->ob_callbackdict = PyDict_New()) == NULL )
- return -1;
- /* And store the Python callback */
- sprintf(keybuf, "%x", (unsigned)which);
- if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0)
- return -1;
- return 0;
+ ControlObject *self = (ControlObject *)myself;
+ char keybuf[9];
+
+ if ( which == kMyControlActionProcTag )
+ *uppp = (UniversalProcPtr)myactionproc_upp;
+ else if ( which == kControlUserPaneKeyDownProcTag )
+ *uppp = (UniversalProcPtr)mykeydownproc_upp;
+ else if ( which == kControlUserPaneFocusProcTag )
+ *uppp = (UniversalProcPtr)myfocusproc_upp;
+ else if ( which == kControlUserPaneDrawProcTag )
+ *uppp = (UniversalProcPtr)mydrawproc_upp;
+ else if ( which == kControlUserPaneIdleProcTag )
+ *uppp = (UniversalProcPtr)myidleproc_upp;
+ else if ( which == kControlUserPaneHitTestProcTag )
+ *uppp = (UniversalProcPtr)myhittestproc_upp;
+ else if ( which == kControlUserPaneTrackingProcTag )
+ *uppp = (UniversalProcPtr)mytrackingproc_upp;
+ else
+ return -1;
+ /* Only now do we test for clearing of the callback: */
+ if ( callback == Py_None )
+ *uppp = NULL;
+ /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */
+ if ( self->ob_callbackdict == NULL )
+ if ( (self->ob_callbackdict = PyDict_New()) == NULL )
+ return -1;
+ /* And store the Python callback */
+ sprintf(keybuf, "%x", (unsigned)which);
+ if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0)
+ return -1;
+ return 0;
}
static PyObject *
callcallback(ControlObject *self, OSType which, PyObject *arglist)
{
- char keybuf[9];
- PyObject *func, *rv;
-
- sprintf(keybuf, "%x", (unsigned)which);
- if ( self->ob_callbackdict == NULL ||
- (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) {
- PySys_WriteStderr("Control callback %x without callback object\\n", (unsigned)which);
- return NULL;
- }
- rv = PyEval_CallObject(func, arglist);
- if ( rv == NULL ) {
- PySys_WriteStderr("Exception in control callback %x handler\\n", (unsigned)which);
- PyErr_Print();
- }
- return rv;
+ char keybuf[9];
+ PyObject *func, *rv;
+
+ sprintf(keybuf, "%x", (unsigned)which);
+ if ( self->ob_callbackdict == NULL ||
+ (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) {
+ PySys_WriteStderr("Control callback %x without callback object\\n", (unsigned)which);
+ return NULL;
+ }
+ rv = PyEval_CallObject(func, arglist);
+ if ( rv == NULL ) {
+ PySys_WriteStderr("Exception in control callback %x handler\\n", (unsigned)which);
+ PyErr_Print();
+ }
+ return rv;
}
static pascal void
myactionproc(ControlHandle control, SInt16 part)
{
- ControlObject *ctl_obj;
- PyObject *arglist, *rv;
-
- ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
- arglist = Py_BuildValue("Oh", ctl_obj, part);
- rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist);
- Py_XDECREF(arglist);
- Py_XDECREF(rv);
+ ControlObject *ctl_obj;
+ PyObject *arglist, *rv;
+
+ ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
+ arglist = Py_BuildValue("Oh", ctl_obj, part);
+ rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist);
+ Py_XDECREF(arglist);
+ Py_XDECREF(rv);
}
static pascal ControlPartCode
mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
{
- ControlObject *ctl_obj;
- PyObject *arglist, *rv;
- short c_rv = 0;
-
- ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
- arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
- rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
- Py_XDECREF(arglist);
- if ( rv )
- if (!PyArg_Parse(rv, "h", &c_rv))
- PyErr_Clear();
- Py_XDECREF(rv);
- return (ControlPartCode)c_rv;
+ ControlObject *ctl_obj;
+ PyObject *arglist, *rv;
+ short c_rv = 0;
+
+ ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
+ arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
+ rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
+ Py_XDECREF(arglist);
+ if ( rv )
+ if (!PyArg_Parse(rv, "h", &c_rv))
+ PyErr_Clear();
+ Py_XDECREF(rv);
+ return (ControlPartCode)c_rv;
}
static pascal ControlPartCode
myfocusproc(ControlHandle control, ControlPartCode part)
{
- ControlObject *ctl_obj;
- PyObject *arglist, *rv;
- short c_rv = kControlFocusNoPart;
-
- ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
- arglist = Py_BuildValue("Oh", ctl_obj, part);
- rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
- Py_XDECREF(arglist);
- if ( rv )
- if (!PyArg_Parse(rv, "h", &c_rv))
- PyErr_Clear();
- Py_XDECREF(rv);
- return (ControlPartCode)c_rv;
+ ControlObject *ctl_obj;
+ PyObject *arglist, *rv;
+ short c_rv = kControlFocusNoPart;
+
+ ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
+ arglist = Py_BuildValue("Oh", ctl_obj, part);
+ rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
+ Py_XDECREF(arglist);
+ if ( rv )
+ if (!PyArg_Parse(rv, "h", &c_rv))
+ PyErr_Clear();
+ Py_XDECREF(rv);
+ return (ControlPartCode)c_rv;
}
static pascal void
mydrawproc(ControlHandle control, SInt16 part)
{
- ControlObject *ctl_obj;
- PyObject *arglist, *rv;
-
- ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
- arglist = Py_BuildValue("Oh", ctl_obj, part);
- rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist);
- Py_XDECREF(arglist);
- Py_XDECREF(rv);
+ ControlObject *ctl_obj;
+ PyObject *arglist, *rv;
+
+ ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
+ arglist = Py_BuildValue("Oh", ctl_obj, part);
+ rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist);
+ Py_XDECREF(arglist);
+ Py_XDECREF(rv);
}
static pascal void
myidleproc(ControlHandle control)
{
- ControlObject *ctl_obj;
- PyObject *arglist, *rv;
-
- ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
- arglist = Py_BuildValue("O", ctl_obj);
- rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist);
- Py_XDECREF(arglist);
- Py_XDECREF(rv);
+ ControlObject *ctl_obj;
+ PyObject *arglist, *rv;
+
+ ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
+ arglist = Py_BuildValue("O", ctl_obj);
+ rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist);
+ Py_XDECREF(arglist);
+ Py_XDECREF(rv);
}
static pascal ControlPartCode
myhittestproc(ControlHandle control, Point where)
{
- ControlObject *ctl_obj;
- PyObject *arglist, *rv;
- short c_rv = -1;
-
- ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
- arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where);
- rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist);
- Py_XDECREF(arglist);
- /* Ignore errors, nothing we can do about them */
- if ( rv )
- if (!PyArg_Parse(rv, "h", &c_rv))
- PyErr_Clear();
- Py_XDECREF(rv);
- return (ControlPartCode)c_rv;
+ ControlObject *ctl_obj;
+ PyObject *arglist, *rv;
+ short c_rv = -1;
+
+ ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
+ arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where);
+ rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist);
+ Py_XDECREF(arglist);
+ /* Ignore errors, nothing we can do about them */
+ if ( rv )
+ if (!PyArg_Parse(rv, "h", &c_rv))
+ PyErr_Clear();
+ Py_XDECREF(rv);
+ return (ControlPartCode)c_rv;
}
static pascal ControlPartCode
mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc)
{
- ControlObject *ctl_obj;
- PyObject *arglist, *rv;
- short c_rv = -1;
-
- ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
- /* We cannot pass the actionProc without lots of work */
- arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt);
- rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
- Py_XDECREF(arglist);
- if ( rv )
- if (!PyArg_Parse(rv, "h", &c_rv))
- PyErr_Clear();
- Py_XDECREF(rv);
- return (ControlPartCode)c_rv;
+ ControlObject *ctl_obj;
+ PyObject *arglist, *rv;
+ short c_rv = -1;
+
+ ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
+ /* We cannot pass the actionProc without lots of work */
+ arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt);
+ rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
+ Py_XDECREF(arglist);
+ if ( rv )
+ if (!PyArg_Parse(rv, "h", &c_rv))
+ PyErr_Clear();
+ Py_XDECREF(rv);
+ return (ControlPartCode)c_rv;
}
"""
@@ -482,18 +482,18 @@ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ControlHandle, CtlObj_Convert);
"""
class MyObjectDefinition(PEP253Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
- def outputStructMembers(self):
- GlobalObjectDefinition.outputStructMembers(self)
- Output("PyObject *ob_callbackdict;")
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("SetControlReference(itself, (long)it);")
- Output("it->ob_callbackdict = NULL;")
- def outputCleanupStructMembers(self):
- Output("Py_XDECREF(self->ob_callbackdict);")
- Output("if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */")
+ def outputStructMembers(self):
+ GlobalObjectDefinition.outputStructMembers(self)
+ Output("PyObject *ob_callbackdict;")
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("SetControlReference(itself, (long)it);")
+ Output("it->ob_callbackdict = NULL;")
+ def outputCleanupStructMembers(self):
+ Output("Py_XDECREF(self->ob_callbackdict);")
+ Output("if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */")
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
@@ -523,14 +523,14 @@ PyObject *callback = 0;
if (!PyArg_ParseTuple(_args, "O&|O",
PyMac_GetPoint, &startPoint, &callback))
- return NULL;
+ return NULL;
if (callback && callback != Py_None) {
- if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
- upp = (ControlActionUPP)-1;
- else {
- settrackfunc(callback);
- upp = mytracker_upp;
- }
+ if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
+ upp = (ControlActionUPP)-1;
+ else {
+ settrackfunc(callback);
+ upp = mytracker_upp;
+ }
}
_rv = TrackControl(_self->ob_itself,
startPoint,
@@ -558,14 +558,14 @@ if (!PyArg_ParseTuple(_args, "O&h|O",
PyMac_GetPoint, &startPoint,
&modifiers,
&callback))
- return NULL;
+ return NULL;
if (callback && callback != Py_None) {
- if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
- upp = (ControlActionUPP)-1;
- else {
- settrackfunc(callback);
- upp = mytracker_upp;
- }
+ if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
+ upp = (ControlActionUPP)-1;
+ else {
+ settrackfunc(callback);
+ upp = mytracker_upp;
+ }
}
_rv = HandleControlClick(_self->ob_itself,
startPoint,
@@ -593,16 +593,16 @@ if (!PyArg_ParseTuple(_args, "hO&s#",
&inPart,
PyMac_GetOSType, &inTagName,
&buffer, &bufferSize))
- return NULL;
+ return NULL;
_err = SetControlData(_self->ob_itself,
- inPart,
- inTagName,
- bufferSize,
+ inPart,
+ inTagName,
+ bufferSize,
buffer);
if (_err != noErr)
- return PyMac_Error(_err);
+ return PyMac_Error(_err);
_res = Py_None;
return _res;
"""
@@ -623,29 +623,29 @@ Size outSize;
if (!PyArg_ParseTuple(_args, "hO&",
&inPart,
PyMac_GetOSType, &inTagName))
- return NULL;
+ return NULL;
/* allocate a buffer for the data */
_err = GetControlDataSize(_self->ob_itself,
- inPart,
- inTagName,
+ inPart,
+ inTagName,
&bufferSize);
if (_err != noErr)
- return PyMac_Error(_err);
+ return PyMac_Error(_err);
buffer = PyMem_NEW(char, bufferSize);
if (buffer == NULL)
- return PyErr_NoMemory();
+ return PyErr_NoMemory();
_err = GetControlData(_self->ob_itself,
- inPart,
- inTagName,
- bufferSize,
+ inPart,
+ inTagName,
+ bufferSize,
buffer,
&outSize);
if (_err != noErr) {
- PyMem_DEL(buffer);
- return PyMac_Error(_err);
+ PyMem_DEL(buffer);
+ return PyMac_Error(_err);
}
_res = Py_BuildValue("s#", buffer, outSize);
PyMem_DEL(buffer);
@@ -667,16 +667,16 @@ if (!PyArg_ParseTuple(_args, "hO&O&",
&inPart,
PyMac_GetOSType, &inTagName,
OptResObj_Convert, &buffer))
- return NULL;
+ return NULL;
_err = SetControlData(_self->ob_itself,
- inPart,
- inTagName,
- sizeof(buffer),
+ inPart,
+ inTagName,
+ sizeof(buffer),
(Ptr)&buffer);
if (_err != noErr)
- return PyMac_Error(_err);
+ return PyMac_Error(_err);
_res = Py_None;
return _res;
"""
@@ -696,29 +696,29 @@ Handle hdl;
if (!PyArg_ParseTuple(_args, "hO&",
&inPart,
PyMac_GetOSType, &inTagName))
- return NULL;
+ return NULL;
/* Check it is handle-sized */
_err = GetControlDataSize(_self->ob_itself,
- inPart,
- inTagName,
+ inPart,
+ inTagName,
&bufferSize);
if (_err != noErr)
- return PyMac_Error(_err);
+ return PyMac_Error(_err);
if (bufferSize != sizeof(Handle)) {
- PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
- return NULL;
+ PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
+ return NULL;
}
_err = GetControlData(_self->ob_itself,
- inPart,
- inTagName,
- sizeof(Handle),
+ inPart,
+ inTagName,
+ sizeof(Handle),
(Ptr)&hdl,
&bufferSize);
if (_err != noErr) {
- return PyMac_Error(_err);
+ return PyMac_Error(_err);
}
_res = Py_BuildValue("O&", OptResObj_New, hdl);
return _res;
@@ -740,18 +740,18 @@ if (!PyArg_ParseTuple(_args, "hO&O",
&inPart,
PyMac_GetOSType, &inTagName,
&callback))
- return NULL;
+ return NULL;
if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 )
- return NULL;
+ return NULL;
_err = SetControlData(_self->ob_itself,
- inPart,
- inTagName,
- sizeof(c_callback),
+ inPart,
+ inTagName,
+ sizeof(c_callback),
(Ptr)&c_callback);
if (_err != noErr)
- return PyMac_Error(_err);
+ return PyMac_Error(_err);
_res = Py_None;
return _res;
"""
@@ -783,26 +783,26 @@ if (!PyArg_ParseTuple(_args, "O&O&HHO",
&size,
&direction,
&tabArrayObj))
- return NULL;
+ return NULL;
i = PySequence_Length(tabArrayObj);
if (i == -1)
- return NULL;
+ return NULL;
if (i > MAXTABS) {
- PyErr_SetString(Ctl_Error, "Too many tabs");
- return NULL;
+ PyErr_SetString(Ctl_Error, "Too many tabs");
+ return NULL;
}
numTabs = i;
for (i=0; i<numTabs; i++) {
- tabEntry = PySequence_GetItem(tabArrayObj, i);
- if (tabEntry == NULL)
- return NULL;
- if (!PyArg_Parse(tabEntry, "(O&O&B)",
- ControlButtonContentInfo_Convert, &tabArray[i].icon,
- CFStringRefObj_Convert, &tabArray[i].name,
- &tabArray[i].enabled
- ))
- return NULL;
+ tabEntry = PySequence_GetItem(tabArrayObj, i);
+ if (tabEntry == NULL)
+ return NULL;
+ if (!PyArg_Parse(tabEntry, "(O&O&B)",
+ ControlButtonContentInfo_Convert, &tabArray[i].icon,
+ CFStringRefObj_Convert, &tabArray[i].name,
+ &tabArray[i].enabled
+ ))
+ return NULL;
}
_err = CreateTabsControl(window,
diff --git a/Mac/Modules/dlg/dlgscan.py b/Mac/Modules/dlg/dlgscan.py
index 3710d5d..7fb68f7 100644
--- a/Mac/Modules/dlg/dlgscan.py
+++ b/Mac/Modules/dlg/dlgscan.py
@@ -12,105 +12,105 @@ SHORT = "dlg"
OBJECT = "DialogPtr"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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 in ("DialogPtr", "DialogRef") and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- 'InitDialogs',
- 'ErrorSound',
- # Dialogs are disposed when the object is deleted
- 'CloseDialog',
- 'DisposDialog',
- 'DisposeDialog',
- 'UpdtDialog',
- 'CouldAlert',
- 'FreeAlert',
- 'CouldDialog',
- 'FreeDialog',
- 'GetStdFilterProc',
- 'GetDialogParent',
-## # Can't find these in the CW Pro 3 libraries
- 'SetDialogMovableModal',
- 'GetDialogControlNotificationProc',
- 'SetGrafPortOfDialog', # Funny, and probably not useful
- # Can't find these:
- 'CloseStandardSheet',
- 'RunStandardAlert',
- ]
-
- def makeblacklisttypes(self):
- return [
- "AlertStdAlertParamPtr", # Too much work, for now
- "AlertStdAlertParamRec", # ditto
- "AlertStdAlertParamRec_ptr", # ditto
- "AlertStdCFStringAlertParamPtr", # ditto
- "AlertStdCFStringAlertParamRec",
- "AlertStdCFStringAlertParamRec_ptr",
- "QTModelessCallbackProcPtr",
- ]
-
- def makerepairinstructions(self):
- return [
- ([("Str255", "*", "InMode")],
- [("*", "*", "OutMode")]),
-
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode"),
- ("long", "*", "OutMode")],
- [("VarVarOutBuffer", "*", "InOutMode")]),
-
- # GetDialogItem return handle is optional
- ([("Handle", "item", "OutMode")],
- [("OptHandle", "item", "OutMode")]),
-
- # NewDialog ETC.
- ([("void", "*", "OutMode")],
- [("NullStorage", "*", "InMode")]),
-
- ([("DialogPtr", "*", "OutMode")],
- [("ExistingDialogPtr", "*", "*")]),
- ([("DialogRef", "*", "OutMode")],
- [("ExistingDialogPtr", "*", "*")]),
- ([("WindowPtr", "*", "OutMode")],
- [("ExistingWindowPtr", "*", "*")]),
- ([("WindowPtr", "*", "ReturnMode")],
- [("ExistingWindowPtr", "*", "*")]),
-
- # StdFilterProc
- ([('EventRecord', 'event', 'OutMode'),
- ('DialogItemIndex', 'itemHit', 'OutMode')],
- [('EventRecord', 'event', 'InOutMode'),
- ('DialogItemIndex', 'itemHit', 'InOutMode')])
-
- ]
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in ("DialogPtr", "DialogRef") and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ 'InitDialogs',
+ 'ErrorSound',
+ # Dialogs are disposed when the object is deleted
+ 'CloseDialog',
+ 'DisposDialog',
+ 'DisposeDialog',
+ 'UpdtDialog',
+ 'CouldAlert',
+ 'FreeAlert',
+ 'CouldDialog',
+ 'FreeDialog',
+ 'GetStdFilterProc',
+ 'GetDialogParent',
+## # Can't find these in the CW Pro 3 libraries
+ 'SetDialogMovableModal',
+ 'GetDialogControlNotificationProc',
+ 'SetGrafPortOfDialog', # Funny, and probably not useful
+ # Can't find these:
+ 'CloseStandardSheet',
+ 'RunStandardAlert',
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "AlertStdAlertParamPtr", # Too much work, for now
+ "AlertStdAlertParamRec", # ditto
+ "AlertStdAlertParamRec_ptr", # ditto
+ "AlertStdCFStringAlertParamPtr", # ditto
+ "AlertStdCFStringAlertParamRec",
+ "AlertStdCFStringAlertParamRec_ptr",
+ "QTModelessCallbackProcPtr",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("Str255", "*", "InMode")],
+ [("*", "*", "OutMode")]),
+
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode"),
+ ("long", "*", "OutMode")],
+ [("VarVarOutBuffer", "*", "InOutMode")]),
+
+ # GetDialogItem return handle is optional
+ ([("Handle", "item", "OutMode")],
+ [("OptHandle", "item", "OutMode")]),
+
+ # NewDialog ETC.
+ ([("void", "*", "OutMode")],
+ [("NullStorage", "*", "InMode")]),
+
+ ([("DialogPtr", "*", "OutMode")],
+ [("ExistingDialogPtr", "*", "*")]),
+ ([("DialogRef", "*", "OutMode")],
+ [("ExistingDialogPtr", "*", "*")]),
+ ([("WindowPtr", "*", "OutMode")],
+ [("ExistingWindowPtr", "*", "*")]),
+ ([("WindowPtr", "*", "ReturnMode")],
+ [("ExistingWindowPtr", "*", "*")]),
+
+ # StdFilterProc
+ ([('EventRecord', 'event', 'OutMode'),
+ ('DialogItemIndex', 'itemHit', 'OutMode')],
+ [('EventRecord', 'event', 'InOutMode'),
+ ('DialogItemIndex', 'itemHit', 'InOutMode')])
+
+ ]
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py
index 85bc607..1c0cc6a 100644
--- a/Mac/Modules/dlg/dlgsupport.py
+++ b/Mac/Modules/dlg/dlgsupport.py
@@ -50,55 +50,55 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
EventRecord *event,
short *itemHit)
{
- Boolean rv;
- PyObject *args, *res;
- PyObject *callback = Dlg_FilterProc_callback;
- if (callback == NULL)
- return 0; /* Default behavior */
- Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
- args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event);
- if (args == NULL)
- res = NULL;
- else {
- res = PyEval_CallObject(callback, args);
- Py_DECREF(args);
- }
- if (res == NULL) {
- PySys_WriteStderr("Exception in Dialog Filter\\n");
- PyErr_Print();
- *itemHit = -1; /* Fake return item */
- return 1; /* We handled it */
- }
- else {
- Dlg_FilterProc_callback = callback;
- if (PyInt_Check(res)) {
- *itemHit = PyInt_AsLong(res);
- rv = 1;
- }
- else
- rv = PyObject_IsTrue(res);
- }
- Py_DECREF(res);
- return rv;
+ Boolean rv;
+ PyObject *args, *res;
+ PyObject *callback = Dlg_FilterProc_callback;
+ if (callback == NULL)
+ return 0; /* Default behavior */
+ Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
+ args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event);
+ if (args == NULL)
+ res = NULL;
+ else {
+ res = PyEval_CallObject(callback, args);
+ Py_DECREF(args);
+ }
+ if (res == NULL) {
+ PySys_WriteStderr("Exception in Dialog Filter\\n");
+ PyErr_Print();
+ *itemHit = -1; /* Fake return item */
+ return 1; /* We handled it */
+ }
+ else {
+ Dlg_FilterProc_callback = callback;
+ if (PyInt_Check(res)) {
+ *itemHit = PyInt_AsLong(res);
+ rv = 1;
+ }
+ else
+ rv = PyObject_IsTrue(res);
+ }
+ Py_DECREF(res);
+ return rv;
}
static ModalFilterUPP
Dlg_PassFilterProc(PyObject *callback)
{
- PyObject *tmp = Dlg_FilterProc_callback;
- static ModalFilterUPP UnivFilterUpp = NULL;
-
- Dlg_FilterProc_callback = NULL;
- if (callback == Py_None) {
- Py_XDECREF(tmp);
- return NULL;
- }
- Py_INCREF(callback);
- Dlg_FilterProc_callback = callback;
- Py_XDECREF(tmp);
- if ( UnivFilterUpp == NULL )
- UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
- return UnivFilterUpp;
+ PyObject *tmp = Dlg_FilterProc_callback;
+ static ModalFilterUPP UnivFilterUpp = NULL;
+
+ Dlg_FilterProc_callback = NULL;
+ if (callback == Py_None) {
+ Py_XDECREF(tmp);
+ return NULL;
+ }
+ Py_INCREF(callback);
+ Dlg_FilterProc_callback = callback;
+ Py_XDECREF(tmp);
+ if ( UnivFilterUpp == NULL )
+ UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
+ return UnivFilterUpp;
}
static PyObject *Dlg_UserItemProc_callback = NULL;
@@ -106,24 +106,24 @@ static PyObject *Dlg_UserItemProc_callback = NULL;
static pascal void Dlg_UnivUserItemProc(DialogPtr dialog,
short item)
{
- PyObject *args, *res;
-
- if (Dlg_UserItemProc_callback == NULL)
- return; /* Default behavior */
- Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
- args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item);
- if (args == NULL)
- res = NULL;
- else {
- res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
- Py_DECREF(args);
- }
- if (res == NULL) {
- PySys_WriteStderr("Exception in Dialog UserItem proc\\n");
- PyErr_Print();
- }
- Py_XDECREF(res);
- return;
+ PyObject *args, *res;
+
+ if (Dlg_UserItemProc_callback == NULL)
+ return; /* Default behavior */
+ Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
+ args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item);
+ if (args == NULL)
+ res = NULL;
+ else {
+ res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
+ Py_DECREF(args);
+ }
+ if (res == NULL) {
+ PySys_WriteStderr("Exception in Dialog UserItem proc\\n");
+ PyErr_Print();
+ }
+ Py_XDECREF(res);
+ return;
}
#if 0
@@ -146,9 +146,9 @@ finalstuff = finalstuff + """
WindowPtr
DlgObj_ConvertToWindow(PyObject *self)
{
- if ( DlgObj_Check(self) )
- return GetDialogWindow(((DialogObject *)self)->ob_itself);
- return NULL;
+ if ( DlgObj_Check(self) )
+ return GetDialogWindow(((DialogObject *)self)->ob_itself);
+ return NULL;
}
#endif
/* Return the object corresponding to the dialog, or None */
@@ -156,77 +156,77 @@ DlgObj_ConvertToWindow(PyObject *self)
PyObject *
DlgObj_WhichDialog(DialogPtr d)
{
- PyObject *it;
-
- if (d == NULL) {
- it = Py_None;
- Py_INCREF(it);
- } else {
- WindowPtr w = GetDialogWindow(d);
-
- it = (PyObject *) GetWRefCon(w);
- if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) {
+ PyObject *it;
+
+ if (d == NULL) {
+ it = Py_None;
+ Py_INCREF(it);
+ } else {
+ WindowPtr w = GetDialogWindow(d);
+
+ it = (PyObject *) GetWRefCon(w);
+ if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) {
#if 0
- /* Should do this, but we don't have an ob_freeit for dialogs yet. */
- it = WinObj_New(w);
- ((WindowObject *)it)->ob_freeit = NULL;
+ /* Should do this, but we don't have an ob_freeit for dialogs yet. */
+ it = WinObj_New(w);
+ ((WindowObject *)it)->ob_freeit = NULL;
#else
- it = Py_None;
- Py_INCREF(it);
+ it = Py_None;
+ Py_INCREF(it);
#endif
- } else {
- Py_INCREF(it);
- }
- }
- return it;
+ } else {
+ Py_INCREF(it);
+ }
+ }
+ return it;
}
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert);
"""
# Define a class which specializes our object definition
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def __init__(self, name, prefix = None, itselftype = None):
- GlobalObjectDefinition.__init__(self, name, prefix, itselftype)
+ def __init__(self, name, prefix = None, itselftype = None):
+ GlobalObjectDefinition.__init__(self, name, prefix, itselftype)
## This won't work in Carbon, so we disable it for all MacPythons:-(
## But see the comment above:-((
-## self.basechain = "&WinObj_chain"
-
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("SetWRefCon(GetDialogWindow(itself), (long)it);")
-
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return Py_None;")
-
- def outputCheckConvertArg(self):
- Output("if (v == Py_None) { *p_itself = NULL; return 1; }")
- Output("if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);")
- Output(" return 1; }")
-
- def outputCompare(self):
- Output()
- Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype)
- OutLbrace()
- Output("if ( self->ob_itself > other->ob_itself ) return 1;")
- Output("if ( self->ob_itself < other->ob_itself ) return -1;")
- Output("return 0;")
- OutRbrace()
-
- def outputHash(self):
- Output()
- Output("static int %s_hash(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("return (int)self->ob_itself;")
- OutRbrace()
-
- def outputFreeIt(self, itselfname):
- Output("DisposeDialog(%s);", itselfname)
+## self.basechain = "&WinObj_chain"
+
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("SetWRefCon(GetDialogWindow(itself), (long)it);")
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return Py_None;")
+
+ def outputCheckConvertArg(self):
+ Output("if (v == Py_None) { *p_itself = NULL; return 1; }")
+ Output("if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);")
+ Output(" return 1; }")
+
+ def outputCompare(self):
+ Output()
+ Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype)
+ OutLbrace()
+ Output("if ( self->ob_itself > other->ob_itself ) return 1;")
+ Output("if ( self->ob_itself < other->ob_itself ) return -1;")
+ Output("return 0;")
+ OutRbrace()
+
+ def outputHash(self):
+ Output()
+ Output("static int %s_hash(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("return (int)self->ob_itself;")
+ OutRbrace()
+
+ def outputFreeIt(self, itselfname):
+ Output("DisposeDialog(%s);", itselfname)
# Create the generator groups and link them
module = MacModule('_Dlg', 'Dlg', includestuff, finalstuff, initstuff)
@@ -247,28 +247,28 @@ for f in functions: module.add(f)
for f in methods: object.add(f)
setuseritembody = """
- PyObject *new = NULL;
-
-
- if (!PyArg_ParseTuple(_args, "|O", &new))
- return NULL;
-
- if (Dlg_UserItemProc_callback && new && new != Py_None) {
- PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
- return NULL;
- }
-
- if (new == NULL || new == Py_None) {
- new = NULL;
- _res = Py_None;
- Py_INCREF(Py_None);
- } else {
- Py_INCREF(new);
- _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc));
- }
-
- Dlg_UserItemProc_callback = new;
- return _res;
+ PyObject *new = NULL;
+
+
+ if (!PyArg_ParseTuple(_args, "|O", &new))
+ return NULL;
+
+ if (Dlg_UserItemProc_callback && new && new != Py_None) {
+ PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
+ return NULL;
+ }
+
+ if (new == NULL || new == Py_None) {
+ new = NULL;
+ _res = Py_None;
+ Py_INCREF(Py_None);
+ } else {
+ Py_INCREF(new);
+ _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc));
+ }
+
+ Dlg_UserItemProc_callback = new;
+ return _res;
"""
f = ManualGenerator("SetUserItemHandler", setuseritembody)
module.add(f)
diff --git a/Mac/Modules/drag/dragscan.py b/Mac/Modules/drag/dragscan.py
index 282728e..923a56b 100644
--- a/Mac/Modules/drag/dragscan.py
+++ b/Mac/Modules/drag/dragscan.py
@@ -7,74 +7,74 @@ sys.path.append(BGENDIR)
from scantools import Scanner
MISSING_DEFINES="""
-kDragHasLeftSenderWindow = (1 << 0)
+kDragHasLeftSenderWindow = (1 << 0)
kDragInsideSenderApplication = (1 << 1)
-kDragInsideSenderWindow = (1 << 2)
-kDragRegionAndImage = (1 << 4)
-flavorSenderOnly = (1 << 0)
-flavorSenderTranslated = (1 << 1)
-flavorNotSaved = (1 << 2)
-flavorSystemTranslated = (1 << 8)
+kDragInsideSenderWindow = (1 << 2)
+kDragRegionAndImage = (1 << 4)
+flavorSenderOnly = (1 << 0)
+flavorSenderTranslated = (1 << 1)
+flavorNotSaved = (1 << 2)
+flavorSystemTranslated = (1 << 8)
"""
def main():
- input = INCLUDEDIR + "Drag.h"
- output = "draggen.py"
- defsoutput = TOOLBOXDIR + "Dragconst.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now doing 'import dragsupport' ==="
- import dragsupport
- print "=== Done. It's up to you to compile Dragmodule.c ==="
+ input = INCLUDEDIR + "Drag.h"
+ output = "draggen.py"
+ defsoutput = TOOLBOXDIR + "Dragconst.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now doing 'import dragsupport' ==="
+ import dragsupport
+ print "=== Done. It's up to you to compile Dragmodule.c ==="
class MyScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t in ('DragReference', 'DragRef') and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in ('DragReference', 'DragRef') 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.TextEdit import *\n")
- self.defsfile.write("from Carbon.QuickDraw import *\n")
- self.defsfile.write("fkDragActionAll = -1\n")
- self.defsfile.write("\n")
- # Defines unparseable in Drag.h
- self.defsfile.write(MISSING_DEFINES)
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("from Carbon.TextEdit import *\n")
+ self.defsfile.write("from Carbon.QuickDraw import *\n")
+ self.defsfile.write("fkDragActionAll = -1\n")
+ self.defsfile.write("\n")
+ # Defines unparseable in Drag.h
+ self.defsfile.write(MISSING_DEFINES)
- def makeblacklistnames(self):
- return [
- "kDragActionAll",
- ]
+ def makeblacklistnames(self):
+ return [
+ "kDragActionAll",
+ ]
- def makeblacklisttypes(self):
- return [
- "DragTrackingHandlerUPP",
- "DragReceiveHandlerUPP",
- "DragSendDataUPP",
- "DragInputUPP",
- "DragDrawingUPP",
- ]
+ def makeblacklisttypes(self):
+ return [
+ "DragTrackingHandlerUPP",
+ "DragReceiveHandlerUPP",
+ "DragSendDataUPP",
+ "DragInputUPP",
+ "DragDrawingUPP",
+ ]
- def makerepairinstructions(self):
- return [
- ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
- [("OptionalInBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("Size", "*", "OutMode")],
- [("VarOutBuffer", "*", "InOutMode")]),
-
- ]
+ def makerepairinstructions(self):
+ return [
+ ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
+ [("OptionalInBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("Size", "*", "OutMode")],
+ [("VarOutBuffer", "*", "InOutMode")]),
+
+ ]
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/drag/dragsupport.py b/Mac/Modules/drag/dragsupport.py
index c200950..45838ef 100644
--- a/Mac/Modules/drag/dragsupport.py
+++ b/Mac/Modules/drag/dragsupport.py
@@ -6,16 +6,16 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Drag.h' # The Apple header file
-MODNAME = '_Drag' # The name of the module
-OBJECTNAME = 'DragObj' # The basic name of the objects used here
+MACHEADERFILE = 'Drag.h' # The Apple header file
+MODNAME = '_Drag' # The name of the module
+OBJECTNAME = 'DragObj' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Drag' # The prefix for module-wide routines
-OBJECTTYPE = 'DragRef' # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Drag' # The prefix for module-wide routines
+OBJECTTYPE = 'DragRef' # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -69,81 +69,81 @@ static pascal OSErr
dragglue_TrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
void *handlerRefCon, DragReference theDrag)
{
- PyObject *args, *rv;
- int i;
-
- args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
- if ( args == NULL )
- return -1;
- rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
- Py_DECREF(args);
- if ( rv == NULL ) {
- PySys_WriteStderr("Drag: Exception in TrackingHandler\\n");
- PyErr_Print();
- return -1;
- }
- i = -1;
- if ( rv == Py_None )
- i = 0;
- else
- PyArg_Parse(rv, "l", &i);
- Py_DECREF(rv);
- return i;
+ PyObject *args, *rv;
+ int i;
+
+ args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
+ if ( args == NULL )
+ return -1;
+ rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
+ Py_DECREF(args);
+ if ( rv == NULL ) {
+ PySys_WriteStderr("Drag: Exception in TrackingHandler\\n");
+ PyErr_Print();
+ return -1;
+ }
+ i = -1;
+ if ( rv == Py_None )
+ i = 0;
+ else
+ PyArg_Parse(rv, "l", &i);
+ Py_DECREF(rv);
+ return i;
}
static pascal OSErr
dragglue_ReceiveHandler(WindowPtr theWindow, void *handlerRefCon,
DragReference theDrag)
{
- PyObject *args, *rv;
- int i;
-
- args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
- if ( args == NULL )
- return -1;
- rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
- Py_DECREF(args);
- if ( rv == NULL ) {
- PySys_WriteStderr("Drag: Exception in ReceiveHandler\\n");
- PyErr_Print();
- return -1;
- }
- i = -1;
- if ( rv == Py_None )
- i = 0;
- else
- PyArg_Parse(rv, "l", &i);
- Py_DECREF(rv);
- return i;
+ PyObject *args, *rv;
+ int i;
+
+ args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
+ if ( args == NULL )
+ return -1;
+ rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
+ Py_DECREF(args);
+ if ( rv == NULL ) {
+ PySys_WriteStderr("Drag: Exception in ReceiveHandler\\n");
+ PyErr_Print();
+ return -1;
+ }
+ i = -1;
+ if ( rv == Py_None )
+ i = 0;
+ else
+ PyArg_Parse(rv, "l", &i);
+ Py_DECREF(rv);
+ return i;
}
static pascal OSErr
dragglue_SendData(FlavorType theType, void *dragSendRefCon,
ItemReference theItem, DragReference theDrag)
{
- DragObjObject *self = (DragObjObject *)dragSendRefCon;
- PyObject *args, *rv;
- int i;
-
- if ( self->sendproc == NULL )
- return -1;
- args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem);
- if ( args == NULL )
- return -1;
- rv = PyEval_CallObject(self->sendproc, args);
- Py_DECREF(args);
- if ( rv == NULL ) {
- PySys_WriteStderr("Drag: Exception in SendDataHandler\\n");
- PyErr_Print();
- return -1;
- }
- i = -1;
- if ( rv == Py_None )
- i = 0;
- else
- PyArg_Parse(rv, "l", &i);
- Py_DECREF(rv);
- return i;
+ DragObjObject *self = (DragObjObject *)dragSendRefCon;
+ PyObject *args, *rv;
+ int i;
+
+ if ( self->sendproc == NULL )
+ return -1;
+ args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem);
+ if ( args == NULL )
+ return -1;
+ rv = PyEval_CallObject(self->sendproc, args);
+ Py_DECREF(args);
+ if ( rv == NULL ) {
+ PySys_WriteStderr("Drag: Exception in SendDataHandler\\n");
+ PyErr_Print();
+ return -1;
+ }
+ i = -1;
+ if ( rv == Py_None )
+ i = 0;
+ else
+ PyArg_Parse(rv, "l", &i);
+ Py_DECREF(rv);
+ return i;
}
#if 0
@@ -165,8 +165,8 @@ dragglue_Drawing(xxxx
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert);
"""
variablestuff = """
@@ -177,33 +177,33 @@ dragglue_SendDataUPP = NewDragSendDataUPP(dragglue_SendData);
dragglue_InputUPP = NewDragInputUPP(dragglue_Input);
dragglue_DrawingUPP = NewDragDrawingUPP(dragglue_Drawing);
#endif
-"""
+"""
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- PyErr_SetString(Drag_Error,"Cannot create null Drag");
- return NULL;
- }""")
- def outputFreeIt(self, itselfname):
- ## Output("DisposeDrag(%s);", itselfname)
- Output("Py_XDECREF(self->sendproc);")
- ## Output("Py_XDECREF(self->inputproc);")
- ## Output("Py_XDECREF(self->drawingproc);")
-
- def outputStructMembers(self):
- GlobalObjectDefinition.outputStructMembers(self)
- Output("PyObject *sendproc;")
- ## Output("PyObject *inputproc;")
- ## Output("PyObject *drawingproc;")
-
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("it->sendproc = NULL;")
- ## Output("it->inputproc = NULL;")
- ## Output("it->drawingproc = NULL;")
-
-
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ PyErr_SetString(Drag_Error,"Cannot create null Drag");
+ return NULL;
+ }""")
+ def outputFreeIt(self, itselfname):
+ ## Output("DisposeDrag(%s);", itselfname)
+ Output("Py_XDECREF(self->sendproc);")
+ ## Output("Py_XDECREF(self->inputproc);")
+ ## Output("Py_XDECREF(self->drawingproc);")
+
+ def outputStructMembers(self):
+ GlobalObjectDefinition.outputStructMembers(self)
+ Output("PyObject *sendproc;")
+ ## Output("PyObject *inputproc;")
+ ## Output("PyObject *drawingproc;")
+
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("it->sendproc = NULL;")
+ ## Output("it->inputproc = NULL;")
+ ## Output("it->drawingproc = NULL;")
+
+
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff)
object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
@@ -228,15 +228,15 @@ installtracking_body = """
PyObject *callback;
WindowPtr theWindow = NULL;
OSErr _err;
-
+
if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) )
- return NULL;
- Py_INCREF(callback); /* Cannot decref later, too bad */
+ return NULL;
+ Py_INCREF(callback); /* Cannot decref later, too bad */
_err = InstallTrackingHandler(dragglue_TrackingHandlerUPP, theWindow, (void *)callback);
- if (_err != noErr) return PyMac_Error(_err);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
+ if (_err != noErr) return PyMac_Error(_err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
"""
installtracking = ManualGenerator("InstallTrackingHandler", installtracking_body)
module.add(installtracking)
@@ -245,15 +245,15 @@ installreceive_body = """
PyObject *callback;
WindowPtr theWindow = NULL;
OSErr _err;
-
+
if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) )
- return NULL;
- Py_INCREF(callback); /* Cannot decref later, too bad */
+ return NULL;
+ Py_INCREF(callback); /* Cannot decref later, too bad */
_err = InstallReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow, (void *)callback);
- if (_err != noErr) return PyMac_Error(_err);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
+ if (_err != noErr) return PyMac_Error(_err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
"""
installreceive = ManualGenerator("InstallReceiveHandler", installreceive_body)
module.add(installreceive)
@@ -261,14 +261,14 @@ module.add(installreceive)
removetracking_body = """
WindowPtr theWindow = NULL;
OSErr _err;
-
+
if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) )
- return NULL;
+ return NULL;
_err = RemoveTrackingHandler(dragglue_TrackingHandlerUPP, theWindow);
- if (_err != noErr) return PyMac_Error(_err);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
+ if (_err != noErr) return PyMac_Error(_err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
"""
removetracking = ManualGenerator("RemoveTrackingHandler", removetracking_body)
module.add(removetracking)
@@ -276,14 +276,14 @@ module.add(removetracking)
removereceive_body = """
WindowPtr theWindow = NULL;
OSErr _err;
-
+
if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) )
- return NULL;
+ return NULL;
_err = RemoveReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow);
- if (_err != noErr) return PyMac_Error(_err);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
+ if (_err != noErr) return PyMac_Error(_err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
"""
removereceive = ManualGenerator("RemoveReceiveHandler", removereceive_body)
module.add(removereceive)
diff --git a/Mac/Modules/evt/evtedit.py b/Mac/Modules/evt/evtedit.py
index 3426b70..02087e1 100644
--- a/Mac/Modules/evt/evtedit.py
+++ b/Mac/Modules/evt/evtedit.py
@@ -7,4 +7,3 @@ functions.append(f)
f = Function(UInt32, 'TickCount',
)
functions.append(f)
-
diff --git a/Mac/Modules/evt/evtscan.py b/Mac/Modules/evt/evtscan.py
index e5762d9..0d0c9ec 100644
--- a/Mac/Modules/evt/evtscan.py
+++ b/Mac/Modules/evt/evtscan.py
@@ -11,71 +11,71 @@ SHORT = "evt"
OBJECT = "NOTUSED"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def makeblacklistnames(self):
- return [
- "KeyTranslate",
- "GetEventMask", # I cannot seem to find this routine...
- "WaitNextEvent", # Manually generated because of optional region
- # Constants with funny definitions
- "osEvtMessageMask",
- # OS8 calls
- 'SystemEvent',
- 'SystemTask',
- 'SystemClick',
- 'GetOSEvent',
- 'OSEventAvail',
- ]
+ def makeblacklistnames(self):
+ return [
+ "KeyTranslate",
+ "GetEventMask", # I cannot seem to find this routine...
+ "WaitNextEvent", # Manually generated because of optional region
+ # Constants with funny definitions
+ "osEvtMessageMask",
+ # OS8 calls
+ 'SystemEvent',
+ 'SystemTask',
+ 'SystemClick',
+ 'GetOSEvent',
+ 'OSEventAvail',
+ ]
- def makeblacklisttypes(self):
- return [
- "EvQElPtr", "QHdrPtr"
- ]
+ def makeblacklisttypes(self):
+ return [
+ "EvQElPtr", "QHdrPtr"
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode"),
+ ("long", "*", "OutMode")],
+ [("VarVarOutBuffer", "*", "InOutMode")]),
+
+ ([("void", "wStorage", "OutMode")],
+ [("NullStorage", "*", "InMode")]),
+
+ # GetKeys
+ ([('KeyMap', 'theKeys', 'InMode')],
+ [('*', '*', 'OutMode')]),
+
+ # GetTicker
+ ([('unsigned long', '*', '*')],
+ [('unsigned_long', '*', '*')]),
+ ]
- def makerepairinstructions(self):
- return [
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode"),
- ("long", "*", "OutMode")],
- [("VarVarOutBuffer", "*", "InOutMode")]),
-
- ([("void", "wStorage", "OutMode")],
- [("NullStorage", "*", "InMode")]),
-
- # GetKeys
- ([('KeyMap', 'theKeys', 'InMode')],
- [('*', '*', 'OutMode')]),
-
- # GetTicker
- ([('unsigned long', '*', '*')],
- [('unsigned_long', '*', '*')]),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/evt/evtsupport.py b/Mac/Modules/evt/evtsupport.py
index ccdc1c5..f58da14 100644
--- a/Mac/Modules/evt/evtsupport.py
+++ b/Mac/Modules/evt/evtsupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Events.h' # The Apple header file
-MODNAME = '_Evt' # The name of the module
-OBJECTNAME = 'Event' # The basic name of the objects used here
-KIND = 'Record' # Usually 'Ptr' or 'Handle'
+MACHEADERFILE = 'Events.h' # The Apple header file
+MODNAME = '_Evt' # The name of the module
+OBJECTNAME = 'Event' # The basic name of the objects used here
+KIND = 'Record' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Evt' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Evt' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -72,7 +72,7 @@ if (!PyArg_ParseTuple(_args, "Hl|O&",
&eventMask,
&sleep,
OptResObj_Convert, &mouseregion))
- return NULL;
+ return NULL;
_rv = WaitNextEvent(eventMask,
&theEvent,
sleep,
@@ -90,4 +90,3 @@ module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/file/filescan.py b/Mac/Modules/file/filescan.py
index f8b5ba2..8ebc69f 100644
--- a/Mac/Modules/file/filescan.py
+++ b/Mac/Modules/file/filescan.py
@@ -10,190 +10,190 @@ LONG = "Files"
SHORT = "file"
def main():
- input = ["Files.h", "Aliases.h", "Finder.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! ==="
+ input = ["Files.h", "Aliases.h", "Finder.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_OSX):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- # Funny special case
- if len(arglist) > 2:
- t, n, m = arglist[1]
- if t == "AliasHandle" and m == "InMode":
- classname = "Arg2MethodGenerator"
- listname = "alias_methods"
- return classname, listname
- # Normal cases
- t, n, m = arglist[0]
- if t == "AliasHandle" and m == "InMode":
- classname = "Method"
- listname = "alias_methods"
- if t == "FSSpec_ptr" and m == "InMode":
- classname = "Method"
- listname = "fsspec_methods"
- if t == "FSRef_ptr" and m == "InMode":
- classname = "Method"
- listname = "fsref_methods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- # Constants with incompatible definitions
- "kioACAccessOwnerMask",
- "kFSCatInfoReserved",
- "kFSIterateReserved",
- "kSystemFolderType",
-
- "FSRefMakePath", # Do this manually
-# "ResolveAlias", # Do this manually
-# "ResolveAliasWithMountFlags", # Do this manually
-# "FollowFinderAlias", # Do this manually
-
- "FSRead", # Couldn't be bothered
- "FSWrite", # ditto
- "FSReadFork", # ditto
- "FSWriteFork", # ditto
-
- # Old routines:
- "GetWDInfo",
- "OpenWD",
- "CloseWD",
- "FInitQueue",
- "rstflock",
- "setflock",
- "setfinfo",
- "fsrename",
- "fsdelete",
- "create",
- "flushvol",
- "eject",
- "umountvol",
- "setvol",
- "getvol",
- "getfinfo",
- "getvinfo",
- "fsopen",
- "RstFLock",
- "SetFLock",
- "SetFInfo",
- "Rename",
- "OpenRF",
- "FSDelete",
- "Create",
- "GetVol",
- "GetFInfo",
- "GetVInfo",
- "FSOpen",
- "Eject",
- "SetVol",
- "openrf",
- "unmountvol",
- "OpenDF",
-
- ]
-
- def makeblacklisttypes(self):
- return [
- "CInfoPBPtr", # Old stuff
- "CMovePBPtr", # Old stuff
- "ParmBlkPtr", # Old stuff
- "HParmBlkPtr", # Old stuff
- "DTPBPtr", # Old stuff
- "FCBPBPtr", # Old stuff
- "QHdrPtr", # Old stuff
- "CSParamPtr", # Old stuff
- "FSCatalogBulkParam", # old stuff
- "FSForkCBInfoParam", # old stuff
- "FSForkIOParam", # old stuff
- "FSRefParam", # old stuff
- "FSVolumeInfoParam", # old stuff
- "WDPBPtr", # old stuff
- "XCInfoPBPtr", # old stuff
- "XVolumeParamPtr", # old stuff
-
-
- "CatPositionRec", # State variable, not too difficult
- "FSIterator", # Should become an object
- "FSForkInfo", # Lots of fields, difficult struct
- "FSSearchParams", # Also catsearch stuff
- "FSVolumeInfo", # big struct
- "FSVolumeInfo_ptr", # big struct
-
- "IOCompletionProcPtr", # proc pointer
- "IOCompletionUPP", # Proc pointer
- "AliasFilterProcPtr",
- "AliasFilterUPP",
- "FNSubscriptionUPP",
-
- "FNSubscriptionRef", # Lazy, for now.
- ]
-
- def makerepairinstructions(self):
- return [
- # Various ways to give pathnames
- ([('char_ptr', '*', 'InMode')],
- [('stringptr', '*', 'InMode')]
- ),
-
- # Unicode filenames passed as length, buffer
- ([('UniCharCount', '*', 'InMode'),
- ('UniChar_ptr', '*', 'InMode')],
- [('UnicodeReverseInBuffer', '*', 'InMode')]
- ),
- # Wrong guess
- ([('Str63', 'theString', 'InMode')],
- [('Str63', 'theString', 'OutMode')]),
-
- # Yet another way to give a pathname:-)
- ([('short', 'fullPathLength', 'InMode'),
- ('void_ptr', 'fullPath', 'InMode')],
- [('FullPathName', 'fullPath', 'InMode')]),
-
- # Various ResolveAliasFileXXXX functions
- ([('FSSpec', 'theSpec', 'OutMode')],
- [('FSSpec_ptr', 'theSpec', 'InOutMode')]),
-
- ([('FSRef', 'theRef', 'OutMode')],
- [('FSRef_ptr', 'theRef', 'InOutMode')]),
-
- # The optional FSSpec to all ResolveAlias and NewAlias methods
- ([('FSSpec_ptr', 'fromFile', 'InMode')],
- [('OptFSSpecPtr', 'fromFile', 'InMode')]),
-
- ([('FSRef_ptr', 'fromFile', 'InMode')],
- [('OptFSRefPtr', 'fromFile', 'InMode')]),
-
-## # FSCatalogInfo input handling
-## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
-## ('FSCatalogInfo_ptr', 'catalogInfo', 'InMode')],
-## [('FSCatalogInfoAndBitmap_in', 'catalogInfo', 'InMode')]),
-##
-## # FSCatalogInfo output handling
-## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
-## ('FSCatalogInfo', 'catalogInfo', 'OutMode')],
-## [('FSCatalogInfoAndBitmap_out', 'catalogInfo', 'InOutMode')]),
-##
-
- ]
-
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- self.defsfile.write("true = True\n")
- self.defsfile.write("false = False\n")
-
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ # Funny special case
+ if len(arglist) > 2:
+ t, n, m = arglist[1]
+ if t == "AliasHandle" and m == "InMode":
+ classname = "Arg2MethodGenerator"
+ listname = "alias_methods"
+ return classname, listname
+ # Normal cases
+ t, n, m = arglist[0]
+ if t == "AliasHandle" and m == "InMode":
+ classname = "Method"
+ listname = "alias_methods"
+ if t == "FSSpec_ptr" and m == "InMode":
+ classname = "Method"
+ listname = "fsspec_methods"
+ if t == "FSRef_ptr" and m == "InMode":
+ classname = "Method"
+ listname = "fsref_methods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ # Constants with incompatible definitions
+ "kioACAccessOwnerMask",
+ "kFSCatInfoReserved",
+ "kFSIterateReserved",
+ "kSystemFolderType",
+
+ "FSRefMakePath", # Do this manually
+# "ResolveAlias", # Do this manually
+# "ResolveAliasWithMountFlags", # Do this manually
+# "FollowFinderAlias", # Do this manually
+
+ "FSRead", # Couldn't be bothered
+ "FSWrite", # ditto
+ "FSReadFork", # ditto
+ "FSWriteFork", # ditto
+
+ # Old routines:
+ "GetWDInfo",
+ "OpenWD",
+ "CloseWD",
+ "FInitQueue",
+ "rstflock",
+ "setflock",
+ "setfinfo",
+ "fsrename",
+ "fsdelete",
+ "create",
+ "flushvol",
+ "eject",
+ "umountvol",
+ "setvol",
+ "getvol",
+ "getfinfo",
+ "getvinfo",
+ "fsopen",
+ "RstFLock",
+ "SetFLock",
+ "SetFInfo",
+ "Rename",
+ "OpenRF",
+ "FSDelete",
+ "Create",
+ "GetVol",
+ "GetFInfo",
+ "GetVInfo",
+ "FSOpen",
+ "Eject",
+ "SetVol",
+ "openrf",
+ "unmountvol",
+ "OpenDF",
+
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "CInfoPBPtr", # Old stuff
+ "CMovePBPtr", # Old stuff
+ "ParmBlkPtr", # Old stuff
+ "HParmBlkPtr", # Old stuff
+ "DTPBPtr", # Old stuff
+ "FCBPBPtr", # Old stuff
+ "QHdrPtr", # Old stuff
+ "CSParamPtr", # Old stuff
+ "FSCatalogBulkParam", # old stuff
+ "FSForkCBInfoParam", # old stuff
+ "FSForkIOParam", # old stuff
+ "FSRefParam", # old stuff
+ "FSVolumeInfoParam", # old stuff
+ "WDPBPtr", # old stuff
+ "XCInfoPBPtr", # old stuff
+ "XVolumeParamPtr", # old stuff
+
+
+ "CatPositionRec", # State variable, not too difficult
+ "FSIterator", # Should become an object
+ "FSForkInfo", # Lots of fields, difficult struct
+ "FSSearchParams", # Also catsearch stuff
+ "FSVolumeInfo", # big struct
+ "FSVolumeInfo_ptr", # big struct
+
+ "IOCompletionProcPtr", # proc pointer
+ "IOCompletionUPP", # Proc pointer
+ "AliasFilterProcPtr",
+ "AliasFilterUPP",
+ "FNSubscriptionUPP",
+
+ "FNSubscriptionRef", # Lazy, for now.
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ # Various ways to give pathnames
+ ([('char_ptr', '*', 'InMode')],
+ [('stringptr', '*', 'InMode')]
+ ),
+
+ # Unicode filenames passed as length, buffer
+ ([('UniCharCount', '*', 'InMode'),
+ ('UniChar_ptr', '*', 'InMode')],
+ [('UnicodeReverseInBuffer', '*', 'InMode')]
+ ),
+ # Wrong guess
+ ([('Str63', 'theString', 'InMode')],
+ [('Str63', 'theString', 'OutMode')]),
+
+ # Yet another way to give a pathname:-)
+ ([('short', 'fullPathLength', 'InMode'),
+ ('void_ptr', 'fullPath', 'InMode')],
+ [('FullPathName', 'fullPath', 'InMode')]),
+
+ # Various ResolveAliasFileXXXX functions
+ ([('FSSpec', 'theSpec', 'OutMode')],
+ [('FSSpec_ptr', 'theSpec', 'InOutMode')]),
+
+ ([('FSRef', 'theRef', 'OutMode')],
+ [('FSRef_ptr', 'theRef', 'InOutMode')]),
+
+ # The optional FSSpec to all ResolveAlias and NewAlias methods
+ ([('FSSpec_ptr', 'fromFile', 'InMode')],
+ [('OptFSSpecPtr', 'fromFile', 'InMode')]),
+
+ ([('FSRef_ptr', 'fromFile', 'InMode')],
+ [('OptFSRefPtr', 'fromFile', 'InMode')]),
+
+## # FSCatalogInfo input handling
+## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
+## ('FSCatalogInfo_ptr', 'catalogInfo', 'InMode')],
+## [('FSCatalogInfoAndBitmap_in', 'catalogInfo', 'InMode')]),
+##
+## # FSCatalogInfo output handling
+## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
+## ('FSCatalogInfo', 'catalogInfo', 'OutMode')],
+## [('FSCatalogInfoAndBitmap_out', 'catalogInfo', 'InOutMode')]),
+##
+
+ ]
+
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("true = True\n")
+ self.defsfile.write("false = False\n")
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/file/filesupport.py b/Mac/Modules/file/filesupport.py
index f06bbb8..dac706d 100644
--- a/Mac/Modules/file/filesupport.py
+++ b/Mac/Modules/file/filesupport.py
@@ -10,14 +10,14 @@
import string
# Declarations that change for each manager
-#MACHEADERFILE = 'Files.h' # The Apple header file
-MODNAME = '_File' # The name of the module
-LONGMODNAME = 'Carbon.File' # The "normal" external name of the module
+#MACHEADERFILE = 'Files.h' # The Apple header file
+MODNAME = '_File' # The name of the module
+LONGMODNAME = 'Carbon.File' # The "normal" external name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'File' # The prefix for module-wide routines
+MODPREFIX = 'File' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -33,9 +33,9 @@ AliasInfoType = Type("AliasInfoType", "h")
# Various types of strings:
#class UniCharCountBuffer(InputOnlyType):
-# pass
+# pass
class VarReverseInputBufferType(ReverseInputBufferMixin, VarInputBufferType):
- pass
+ pass
FullPathName = VarReverseInputBufferType()
ConstStr31Param = OpaqueArrayType("Str31", "PyMac_BuildStr255", "PyMac_GetStr255")
ConstStr32Param = OpaqueArrayType("Str32", "PyMac_BuildStr255", "PyMac_GetStr255")
@@ -47,60 +47,60 @@ UInt8_ptr = InputOnlyType("UInt8 *", "s")
# Other types:
class OptionalFSxxxType(OpaqueByValueType):
- def declare(self, name):
- Output("%s %s__buf__;", self.typeName, name)
- Output("%s *%s = &%s__buf__;", self.typeName, name, name)
+ def declare(self, name):
+ Output("%s %s__buf__;", self.typeName, name)
+ Output("%s *%s = &%s__buf__;", self.typeName, name, name)
class FSCatalogInfoAndBitmapType(InputOnlyType):
-
- def __init__(self):
- InputOnlyType.__init__(self, "BUG", "BUG")
-
- def declare(self, name):
- Output("PyObject *%s__object = NULL;", name)
- Output("FSCatalogInfoBitmap %s__bitmap = 0;", name)
- Output("FSCatalogInfo %s;", name)
-
- def getargsFormat(self):
- return "lO"
-
- def getargsArgs(self, name):
- return "%s__bitmap, %s__object"%(name, name)
-
- def getargsCheck(self, name):
- Output("if (!convert_FSCatalogInfo(%s__object, %s__bitmap, &%s)) return NULL;", name, name, name)
-
- def passInput(self, name):
- return "%s__bitmap, &%s"% (name, name)
-
- def passOutput(self, name):
- return "%s__bitmap, &%s"% (name, name)
-
- def mkvalueFormat(self):
- return "O"
-
- def mkvalueArgs(self, name):
- return "%s__object" % (name)
-
- def xxxxmkvalueCheck(self, name):
- Output("if ((%s__object = new_FSCatalogInfo(%s__bitmap, &%s)) == NULL) return NULL;", name, name)
-
+
+ def __init__(self):
+ InputOnlyType.__init__(self, "BUG", "BUG")
+
+ def declare(self, name):
+ Output("PyObject *%s__object = NULL;", name)
+ Output("FSCatalogInfoBitmap %s__bitmap = 0;", name)
+ Output("FSCatalogInfo %s;", name)
+
+ def getargsFormat(self):
+ return "lO"
+
+ def getargsArgs(self, name):
+ return "%s__bitmap, %s__object"%(name, name)
+
+ def getargsCheck(self, name):
+ Output("if (!convert_FSCatalogInfo(%s__object, %s__bitmap, &%s)) return NULL;", name, name, name)
+
+ def passInput(self, name):
+ return "%s__bitmap, &%s"% (name, name)
+
+ def passOutput(self, name):
+ return "%s__bitmap, &%s"% (name, name)
+
+ def mkvalueFormat(self):
+ return "O"
+
+ def mkvalueArgs(self, name):
+ return "%s__object" % (name)
+
+ def xxxxmkvalueCheck(self, name):
+ Output("if ((%s__object = new_FSCatalogInfo(%s__bitmap, &%s)) == NULL) return NULL;", name, name)
+
class FSCatalogInfoAndBitmap_inType(FSCatalogInfoAndBitmapType, InputOnlyMixIn):
-
- def xxxxmkvalueCheck(self, name):
- pass
-
+
+ def xxxxmkvalueCheck(self, name):
+ pass
+
class FSCatalogInfoAndBitmap_outType(FSCatalogInfoAndBitmapType):
- def getargsFormat(self):
- return "l"
-
- def getargsArgs(self, name):
- return "%s__bitmap" % name
-
- def getargsCheck(self, name):
- pass
-
+ def getargsFormat(self):
+ return "l"
+
+ def getargsArgs(self, name):
+ return "%s__bitmap" % name
+
+ def getargsCheck(self, name):
+ pass
+
FInfo = OpaqueType("FInfo", "FInfo")
FInfo_ptr = OpaqueType("FInfo", "FInfo")
AliasHandle = OpaqueByValueType("AliasHandle", "Alias")
@@ -157,13 +157,13 @@ static int Alias_Convert(PyObject *v, AliasHandle *p_itself);
static int
UTCDateTime_Convert(PyObject *v, UTCDateTime *ptr)
{
- return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction);
+ return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction);
}
static PyObject *
UTCDateTime_New(UTCDateTime *ptr)
{
- return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction);
+ return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction);
}
/*
@@ -172,21 +172,21 @@ UTCDateTime_New(UTCDateTime *ptr)
static int
myPyMac_GetOptFSSpecPtr(PyObject *v, FSSpec **spec)
{
- if (v == Py_None) {
- *spec = NULL;
- return 1;
- }
- return PyMac_GetFSSpec(v, *spec);
+ if (v == Py_None) {
+ *spec = NULL;
+ return 1;
+ }
+ return PyMac_GetFSSpec(v, *spec);
}
static int
myPyMac_GetOptFSRefPtr(PyObject *v, FSRef **ref)
{
- if (v == Py_None) {
- *ref = NULL;
- return 1;
- }
- return PyMac_GetFSRef(v, *ref);
+ if (v == Py_None) {
+ *ref = NULL;
+ return 1;
+ }
+ return PyMac_GetFSRef(v, *ref);
}
/*
@@ -196,7 +196,7 @@ static PyObject *
PyMac_BuildHFSUniStr255(HFSUniStr255 *itself)
{
- return Py_BuildValue("u#", itself->unicode, itself->length);
+ return Py_BuildValue("u#", itself->unicode, itself->length);
}
"""
@@ -204,86 +204,86 @@ finalstuff = finalstuff + """
int
PyMac_GetFSSpec(PyObject *v, FSSpec *spec)
{
- Str255 path;
- short refnum;
- long parid;
- OSErr err;
- FSRef fsr;
-
- if (FSSpec_Check(v)) {
- *spec = ((FSSpecObject *)v)->ob_itself;
- return 1;
- }
-
- if (PyArg_Parse(v, "(hlO&)",
- &refnum, &parid, PyMac_GetStr255, &path)) {
- err = FSMakeFSSpec(refnum, parid, path, spec);
- if ( err && err != fnfErr ) {
- PyMac_Error(err);
- return 0;
- }
- return 1;
- }
- PyErr_Clear();
- /* Otherwise we try to go via an FSRef. On OSX we go all the way,
- ** on OS9 we accept only a real FSRef object
- */
- if ( PyMac_GetFSRef(v, &fsr) ) {
- err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL);
- if (err != noErr) {
- PyMac_Error(err);
- return 0;
- }
- return 1;
- }
- return 0;
+ Str255 path;
+ short refnum;
+ long parid;
+ OSErr err;
+ FSRef fsr;
+
+ if (FSSpec_Check(v)) {
+ *spec = ((FSSpecObject *)v)->ob_itself;
+ return 1;
+ }
+
+ if (PyArg_Parse(v, "(hlO&)",
+ &refnum, &parid, PyMac_GetStr255, &path)) {
+ err = FSMakeFSSpec(refnum, parid, path, spec);
+ if ( err && err != fnfErr ) {
+ PyMac_Error(err);
+ return 0;
+ }
+ return 1;
+ }
+ PyErr_Clear();
+ /* Otherwise we try to go via an FSRef. On OSX we go all the way,
+ ** on OS9 we accept only a real FSRef object
+ */
+ if ( PyMac_GetFSRef(v, &fsr) ) {
+ err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL);
+ if (err != noErr) {
+ PyMac_Error(err);
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
}
int
PyMac_GetFSRef(PyObject *v, FSRef *fsr)
{
- OSStatus err;
- FSSpec fss;
-
- if (FSRef_Check(v)) {
- *fsr = ((FSRefObject *)v)->ob_itself;
- return 1;
- }
-
- /* On OSX we now try a pathname */
- if ( PyString_Check(v) || PyUnicode_Check(v)) {
- char *path = NULL;
- if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path))
- return NULL;
- if ( (err=FSPathMakeRef(path, fsr, NULL)) ) {
- PyMac_Error(err);
- return 0;
- }
- return 1;
- }
- /* XXXX Should try unicode here too */
- /* Otherwise we try to go via an FSSpec */
- if (FSSpec_Check(v)) {
- fss = ((FSSpecObject *)v)->ob_itself;
- if ((err=FSpMakeFSRef(&fss, fsr)) == 0)
- return 1;
- PyMac_Error(err);
- return 0;
- }
- PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required");
- return 0;
+ OSStatus err;
+ FSSpec fss;
+
+ if (FSRef_Check(v)) {
+ *fsr = ((FSRefObject *)v)->ob_itself;
+ return 1;
+ }
+
+ /* On OSX we now try a pathname */
+ if ( PyString_Check(v) || PyUnicode_Check(v)) {
+ char *path = NULL;
+ if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path))
+ return NULL;
+ if ( (err=FSPathMakeRef(path, fsr, NULL)) ) {
+ PyMac_Error(err);
+ return 0;
+ }
+ return 1;
+ }
+ /* XXXX Should try unicode here too */
+ /* Otherwise we try to go via an FSSpec */
+ if (FSSpec_Check(v)) {
+ fss = ((FSSpecObject *)v)->ob_itself;
+ if ((err=FSpMakeFSRef(&fss, fsr)) == 0)
+ return 1;
+ PyMac_Error(err);
+ return 0;
+ }
+ PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required");
+ return 0;
}
extern PyObject *
PyMac_BuildFSSpec(FSSpec *spec)
{
- return FSSpec_New(spec);
+ return FSSpec_New(spec);
}
extern PyObject *
PyMac_BuildFSRef(FSRef *spec)
{
- return FSRef_New(spec);
+ return FSRef_New(spec);
}
"""
@@ -298,446 +298,446 @@ execfile(string.lower(MODPREFIX) + 'typetest.py')
# Our object types:
class FSCatalogInfoDefinition(PEP253Mixin, ObjectDefinition):
- getsetlist = [
- ("nodeFlags",
- "return Py_BuildValue(\"H\", self->ob_itself.nodeFlags);",
- "return PyArg_Parse(v, \"H\", &self->ob_itself.nodeFlags)-1;",
- None
- ),
- ("volume",
- "return Py_BuildValue(\"h\", self->ob_itself.volume);",
- "return PyArg_Parse(v, \"h\", &self->ob_itself.volume)-1;",
- None
- ),
- ("parentDirID",
- "return Py_BuildValue(\"l\", self->ob_itself.parentDirID);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.parentDirID)-1;",
- None
- ),
- ("nodeID",
- "return Py_BuildValue(\"l\", self->ob_itself.nodeID);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.nodeID)-1;",
- None
- ),
- ("createDate",
- "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.createDate);",
- "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.createDate)-1;",
- None
- ),
- ("contentModDate",
- "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.contentModDate);",
- "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.contentModDate)-1;",
- None
- ),
- ("attributeModDate",
- "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.attributeModDate);",
- "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.attributeModDate)-1;",
- None
- ),
- ("accessDate",
- "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.accessDate);",
- "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.accessDate)-1;",
- None
- ),
- ("backupDate",
- "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.backupDate);",
- "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.backupDate)-1;",
- None
- ),
- ("permissions",
- "return Py_BuildValue(\"(llll)\", self->ob_itself.permissions[0], self->ob_itself.permissions[1], self->ob_itself.permissions[2], self->ob_itself.permissions[3]);",
- "return PyArg_Parse(v, \"(llll)\", &self->ob_itself.permissions[0], &self->ob_itself.permissions[1], &self->ob_itself.permissions[2], &self->ob_itself.permissions[3])-1;",
- None
- ),
- # XXXX FinderInfo TBD
- # XXXX FinderXInfo TBD
- ("valence",
- "return Py_BuildValue(\"l\", self->ob_itself.valence);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.valence)-1;",
- None
- ),
- ("dataLogicalSize",
- "return Py_BuildValue(\"l\", self->ob_itself.dataLogicalSize);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.dataLogicalSize)-1;",
- None
- ),
- ("dataPhysicalSize",
- "return Py_BuildValue(\"l\", self->ob_itself.dataPhysicalSize);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.dataPhysicalSize)-1;",
- None
- ),
- ("rsrcLogicalSize",
- "return Py_BuildValue(\"l\", self->ob_itself.rsrcLogicalSize);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.rsrcLogicalSize)-1;",
- None
- ),
- ("rsrcPhysicalSize",
- "return Py_BuildValue(\"l\", self->ob_itself.rsrcPhysicalSize);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.rsrcPhysicalSize)-1;",
- None
- ),
- ("sharingFlags",
- "return Py_BuildValue(\"l\", self->ob_itself.sharingFlags);",
- "return PyArg_Parse(v, \"l\", &self->ob_itself.sharingFlags)-1;",
- None
- ),
- ("userPrivileges",
- "return Py_BuildValue(\"b\", self->ob_itself.userPrivileges);",
- "return PyArg_Parse(v, \"b\", &self->ob_itself.userPrivileges)-1;",
- None
- ),
- ]
- # The same info, but in a different form
- INITFORMAT = "HhllO&O&O&O&O&llllllb"
- INITARGS = """&((FSCatalogInfoObject *)self)->ob_itself.nodeFlags,
- &((FSCatalogInfoObject *)self)->ob_itself.volume,
- &((FSCatalogInfoObject *)self)->ob_itself.parentDirID,
- &((FSCatalogInfoObject *)self)->ob_itself.nodeID,
- UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.createDate,
- UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.contentModDate,
- UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.attributeModDate,
- UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.accessDate,
- UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.backupDate,
- &((FSCatalogInfoObject *)self)->ob_itself.valence,
- &((FSCatalogInfoObject *)self)->ob_itself.dataLogicalSize,
- &((FSCatalogInfoObject *)self)->ob_itself.dataPhysicalSize,
- &((FSCatalogInfoObject *)self)->ob_itself.rsrcLogicalSize,
- &((FSCatalogInfoObject *)self)->ob_itself.rsrcPhysicalSize,
- &((FSCatalogInfoObject *)self)->ob_itself.sharingFlags,
- &((FSCatalogInfoObject *)self)->ob_itself.userPrivileges"""
- INITNAMES = """
- "nodeFlags",
- "volume",
- "parentDirID",
- "nodeID",
- "createDate",
- "contentModDate",
- "atributeModDate",
- "accessDate",
- "backupDate",
- "valence",
- "dataLogicalSize",
- "dataPhysicalSize",
- "rsrcLogicalSize",
- "rsrcPhysicalSize",
- "sharingFlags",
- "userPrivileges"
- """
-
- def __init__(self, name, prefix, itselftype):
- ObjectDefinition.__init__(self, name, prefix, itselftype)
- self.argref = "*" # Store FSSpecs, but pass them by address
-
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return Py_None;")
-
- def output_tp_newBody(self):
- Output("PyObject *self;");
- Output()
- Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
- Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
- self.objecttype, self.itselftype)
- Output("return self;")
-
- def output_tp_initBody(self):
- Output("static char *kw[] = {%s, 0};", self.INITNAMES)
- Output()
- Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|%s\", kw, %s))",
- self.INITFORMAT, self.INITARGS)
- OutLbrace()
- Output("return -1;")
- OutRbrace()
- Output("return 0;")
-
+ getsetlist = [
+ ("nodeFlags",
+ "return Py_BuildValue(\"H\", self->ob_itself.nodeFlags);",
+ "return PyArg_Parse(v, \"H\", &self->ob_itself.nodeFlags)-1;",
+ None
+ ),
+ ("volume",
+ "return Py_BuildValue(\"h\", self->ob_itself.volume);",
+ "return PyArg_Parse(v, \"h\", &self->ob_itself.volume)-1;",
+ None
+ ),
+ ("parentDirID",
+ "return Py_BuildValue(\"l\", self->ob_itself.parentDirID);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.parentDirID)-1;",
+ None
+ ),
+ ("nodeID",
+ "return Py_BuildValue(\"l\", self->ob_itself.nodeID);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.nodeID)-1;",
+ None
+ ),
+ ("createDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.createDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.createDate)-1;",
+ None
+ ),
+ ("contentModDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.contentModDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.contentModDate)-1;",
+ None
+ ),
+ ("attributeModDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.attributeModDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.attributeModDate)-1;",
+ None
+ ),
+ ("accessDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.accessDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.accessDate)-1;",
+ None
+ ),
+ ("backupDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.backupDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.backupDate)-1;",
+ None
+ ),
+ ("permissions",
+ "return Py_BuildValue(\"(llll)\", self->ob_itself.permissions[0], self->ob_itself.permissions[1], self->ob_itself.permissions[2], self->ob_itself.permissions[3]);",
+ "return PyArg_Parse(v, \"(llll)\", &self->ob_itself.permissions[0], &self->ob_itself.permissions[1], &self->ob_itself.permissions[2], &self->ob_itself.permissions[3])-1;",
+ None
+ ),
+ # XXXX FinderInfo TBD
+ # XXXX FinderXInfo TBD
+ ("valence",
+ "return Py_BuildValue(\"l\", self->ob_itself.valence);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.valence)-1;",
+ None
+ ),
+ ("dataLogicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.dataLogicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.dataLogicalSize)-1;",
+ None
+ ),
+ ("dataPhysicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.dataPhysicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.dataPhysicalSize)-1;",
+ None
+ ),
+ ("rsrcLogicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.rsrcLogicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.rsrcLogicalSize)-1;",
+ None
+ ),
+ ("rsrcPhysicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.rsrcPhysicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.rsrcPhysicalSize)-1;",
+ None
+ ),
+ ("sharingFlags",
+ "return Py_BuildValue(\"l\", self->ob_itself.sharingFlags);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.sharingFlags)-1;",
+ None
+ ),
+ ("userPrivileges",
+ "return Py_BuildValue(\"b\", self->ob_itself.userPrivileges);",
+ "return PyArg_Parse(v, \"b\", &self->ob_itself.userPrivileges)-1;",
+ None
+ ),
+ ]
+ # The same info, but in a different form
+ INITFORMAT = "HhllO&O&O&O&O&llllllb"
+ INITARGS = """&((FSCatalogInfoObject *)self)->ob_itself.nodeFlags,
+ &((FSCatalogInfoObject *)self)->ob_itself.volume,
+ &((FSCatalogInfoObject *)self)->ob_itself.parentDirID,
+ &((FSCatalogInfoObject *)self)->ob_itself.nodeID,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.createDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.contentModDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.attributeModDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.accessDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.backupDate,
+ &((FSCatalogInfoObject *)self)->ob_itself.valence,
+ &((FSCatalogInfoObject *)self)->ob_itself.dataLogicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.dataPhysicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.rsrcLogicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.rsrcPhysicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.sharingFlags,
+ &((FSCatalogInfoObject *)self)->ob_itself.userPrivileges"""
+ INITNAMES = """
+ "nodeFlags",
+ "volume",
+ "parentDirID",
+ "nodeID",
+ "createDate",
+ "contentModDate",
+ "atributeModDate",
+ "accessDate",
+ "backupDate",
+ "valence",
+ "dataLogicalSize",
+ "dataPhysicalSize",
+ "rsrcLogicalSize",
+ "rsrcPhysicalSize",
+ "sharingFlags",
+ "userPrivileges"
+ """
+
+ def __init__(self, name, prefix, itselftype):
+ ObjectDefinition.__init__(self, name, prefix, itselftype)
+ self.argref = "*" # Store FSSpecs, but pass them by address
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return Py_None;")
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;");
+ Output()
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
+ self.objecttype, self.itselftype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("static char *kw[] = {%s, 0};", self.INITNAMES)
+ Output()
+ Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|%s\", kw, %s))",
+ self.INITFORMAT, self.INITARGS)
+ OutLbrace()
+ Output("return -1;")
+ OutRbrace()
+ Output("return 0;")
+
class FInfoDefinition(PEP253Mixin, ObjectDefinition):
- getsetlist = [
- ("Type",
- "return Py_BuildValue(\"O&\", PyMac_BuildOSType, self->ob_itself.fdType);",
- "return PyArg_Parse(v, \"O&\", PyMac_GetOSType, &self->ob_itself.fdType)-1;",
- "4-char file type"
- ),
- ("Creator",
- "return Py_BuildValue(\"O&\", PyMac_BuildOSType, self->ob_itself.fdCreator);",
- "return PyArg_Parse(v, \"O&\", PyMac_GetOSType, &self->ob_itself.fdCreator)-1;",
- "4-char file creator"
- ),
- ("Flags",
- "return Py_BuildValue(\"H\", self->ob_itself.fdFlags);",
- "return PyArg_Parse(v, \"H\", &self->ob_itself.fdFlags)-1;",
- "Finder flag bits"
- ),
- ("Location",
- "return Py_BuildValue(\"O&\", PyMac_BuildPoint, self->ob_itself.fdLocation);",
- "return PyArg_Parse(v, \"O&\", PyMac_GetPoint, &self->ob_itself.fdLocation)-1;",
- "(x, y) location of the file's icon in its parent finder window"
- ),
- ("Fldr",
- "return Py_BuildValue(\"h\", self->ob_itself.fdFldr);",
- "return PyArg_Parse(v, \"h\", &self->ob_itself.fdFldr)-1;",
- "Original folder, for 'put away'"
- ),
-
- ]
-
- def __init__(self, name, prefix, itselftype):
- ObjectDefinition.__init__(self, name, prefix, itselftype)
- self.argref = "*" # Store FSSpecs, but pass them by address
-
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-
- def output_tp_newBody(self):
- Output("PyObject *self;");
- Output()
- Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
- Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
- self.objecttype, self.itselftype)
- Output("return self;")
-
- def output_tp_initBody(self):
- Output("%s *itself = NULL;", self.itselftype)
- Output("static char *kw[] = {\"itself\", 0};")
- Output()
- Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kw, FInfo_Convert, &itself))")
- OutLbrace()
- Output("if (itself) memcpy(&((%s *)self)->ob_itself, itself, sizeof(%s));",
- self.objecttype, self.itselftype)
- Output("return 0;")
- OutRbrace()
- Output("return -1;")
+ getsetlist = [
+ ("Type",
+ "return Py_BuildValue(\"O&\", PyMac_BuildOSType, self->ob_itself.fdType);",
+ "return PyArg_Parse(v, \"O&\", PyMac_GetOSType, &self->ob_itself.fdType)-1;",
+ "4-char file type"
+ ),
+ ("Creator",
+ "return Py_BuildValue(\"O&\", PyMac_BuildOSType, self->ob_itself.fdCreator);",
+ "return PyArg_Parse(v, \"O&\", PyMac_GetOSType, &self->ob_itself.fdCreator)-1;",
+ "4-char file creator"
+ ),
+ ("Flags",
+ "return Py_BuildValue(\"H\", self->ob_itself.fdFlags);",
+ "return PyArg_Parse(v, \"H\", &self->ob_itself.fdFlags)-1;",
+ "Finder flag bits"
+ ),
+ ("Location",
+ "return Py_BuildValue(\"O&\", PyMac_BuildPoint, self->ob_itself.fdLocation);",
+ "return PyArg_Parse(v, \"O&\", PyMac_GetPoint, &self->ob_itself.fdLocation)-1;",
+ "(x, y) location of the file's icon in its parent finder window"
+ ),
+ ("Fldr",
+ "return Py_BuildValue(\"h\", self->ob_itself.fdFldr);",
+ "return PyArg_Parse(v, \"h\", &self->ob_itself.fdFldr)-1;",
+ "Original folder, for 'put away'"
+ ),
+
+ ]
+
+ def __init__(self, name, prefix, itselftype):
+ ObjectDefinition.__init__(self, name, prefix, itselftype)
+ self.argref = "*" # Store FSSpecs, but pass them by address
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;");
+ Output()
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
+ self.objecttype, self.itselftype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("%s *itself = NULL;", self.itselftype)
+ Output("static char *kw[] = {\"itself\", 0};")
+ Output()
+ Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kw, FInfo_Convert, &itself))")
+ OutLbrace()
+ Output("if (itself) memcpy(&((%s *)self)->ob_itself, itself, sizeof(%s));",
+ self.objecttype, self.itselftype)
+ Output("return 0;")
+ OutRbrace()
+ Output("return -1;")
class FSSpecDefinition(PEP253Mixin, ObjectDefinition):
- getsetlist = [
- ("data",
- "return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));",
- None,
- "Raw data of the FSSpec object"
- )
- ]
-
- def __init__(self, name, prefix, itselftype):
- ObjectDefinition.__init__(self, name, prefix, itselftype)
- self.argref = "*" # Store FSSpecs, but pass them by address
-
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-
- # We do Convert ourselves (with PyMac_GetFSxxx)
- def outputConvert(self):
- pass
-
- def output_tp_newBody(self):
- Output("PyObject *self;");
- Output()
- Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
- Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
- self.objecttype, self.itselftype)
- Output("return self;")
-
- def output_tp_initBody(self):
- Output("PyObject *v = NULL;")
- Output("char *rawdata = NULL;")
- Output("int rawdatalen = 0;")
- Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
- Output()
- Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
- Output("return -1;")
- Output("if (v && rawdata)")
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"Only one of itself or rawdata may be specified\");")
- Output("return -1;")
- OutRbrace()
- Output("if (!v && !rawdata)")
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"One of itself or rawdata must be specified\");")
- Output("return -1;")
- OutRbrace()
- Output("if (rawdata)")
- OutLbrace()
- Output("if (rawdatalen != sizeof(%s))", self.itselftype)
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"%s rawdata incorrect size\");",
- self.itselftype)
- Output("return -1;")
- OutRbrace()
- Output("memcpy(&((%s *)self)->ob_itself, rawdata, rawdatalen);", self.objecttype)
- Output("return 0;")
- OutRbrace()
- Output("if (PyMac_GetFSSpec(v, &((%s *)self)->ob_itself)) return 0;", self.objecttype)
- Output("return -1;")
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[512];")
- Output("""PyOS_snprintf(buf, sizeof(buf), \"%%s((%%d, %%ld, '%%.*s'))\",
- self->ob_type->tp_name,
- self->ob_itself.vRefNum,
- self->ob_itself.parID,
- self->ob_itself.name[0], self->ob_itself.name+1);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
+ getsetlist = [
+ ("data",
+ "return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));",
+ None,
+ "Raw data of the FSSpec object"
+ )
+ ]
+
+ def __init__(self, name, prefix, itselftype):
+ ObjectDefinition.__init__(self, name, prefix, itselftype)
+ self.argref = "*" # Store FSSpecs, but pass them by address
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+
+ # We do Convert ourselves (with PyMac_GetFSxxx)
+ def outputConvert(self):
+ pass
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;");
+ Output()
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
+ self.objecttype, self.itselftype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("PyObject *v = NULL;")
+ Output("char *rawdata = NULL;")
+ Output("int rawdatalen = 0;")
+ Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
+ Output()
+ Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
+ Output("return -1;")
+ Output("if (v && rawdata)")
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"Only one of itself or rawdata may be specified\");")
+ Output("return -1;")
+ OutRbrace()
+ Output("if (!v && !rawdata)")
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"One of itself or rawdata must be specified\");")
+ Output("return -1;")
+ OutRbrace()
+ Output("if (rawdata)")
+ OutLbrace()
+ Output("if (rawdatalen != sizeof(%s))", self.itselftype)
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"%s rawdata incorrect size\");",
+ self.itselftype)
+ Output("return -1;")
+ OutRbrace()
+ Output("memcpy(&((%s *)self)->ob_itself, rawdata, rawdatalen);", self.objecttype)
+ Output("return 0;")
+ OutRbrace()
+ Output("if (PyMac_GetFSSpec(v, &((%s *)self)->ob_itself)) return 0;", self.objecttype)
+ Output("return -1;")
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[512];")
+ Output("""PyOS_snprintf(buf, sizeof(buf), \"%%s((%%d, %%ld, '%%.*s'))\",
+ self->ob_type->tp_name,
+ self->ob_itself.vRefNum,
+ self->ob_itself.parID,
+ self->ob_itself.name[0], self->ob_itself.name+1);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
class FSRefDefinition(PEP253Mixin, ObjectDefinition):
- getsetlist = [
- ("data",
- "return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));",
- None,
- "Raw data of the FSRef object"
- )
- ]
-
- def __init__(self, name, prefix, itselftype):
- ObjectDefinition.__init__(self, name, prefix, itselftype)
- self.argref = "*" # Store FSRefs, but pass them by address
-
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-
- # We do Convert ourselves (with PyMac_GetFSxxx)
- def outputConvert(self):
- pass
-
- def output_tp_newBody(self):
- Output("PyObject *self;");
- Output()
- Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
- Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
- self.objecttype, self.itselftype)
- Output("return self;")
-
- def output_tp_initBody(self):
- Output("PyObject *v = NULL;")
- Output("char *rawdata = NULL;")
- Output("int rawdatalen = 0;")
- Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
- Output()
- Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
- Output("return -1;")
- Output("if (v && rawdata)")
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"Only one of itself or rawdata may be specified\");")
- Output("return -1;")
- OutRbrace()
- Output("if (!v && !rawdata)")
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"One of itself or rawdata must be specified\");")
- Output("return -1;")
- OutRbrace()
- Output("if (rawdata)")
- OutLbrace()
- Output("if (rawdatalen != sizeof(%s))", self.itselftype)
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"%s rawdata incorrect size\");",
- self.itselftype)
- Output("return -1;")
- OutRbrace()
- Output("memcpy(&((%s *)self)->ob_itself, rawdata, rawdatalen);", self.objecttype)
- Output("return 0;")
- OutRbrace()
- Output("if (PyMac_GetFSRef(v, &((%s *)self)->ob_itself)) return 0;", self.objecttype)
- Output("return -1;")
-
+ getsetlist = [
+ ("data",
+ "return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));",
+ None,
+ "Raw data of the FSRef object"
+ )
+ ]
+
+ def __init__(self, name, prefix, itselftype):
+ ObjectDefinition.__init__(self, name, prefix, itselftype)
+ self.argref = "*" # Store FSRefs, but pass them by address
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+
+ # We do Convert ourselves (with PyMac_GetFSxxx)
+ def outputConvert(self):
+ pass
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;");
+ Output()
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
+ self.objecttype, self.itselftype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("PyObject *v = NULL;")
+ Output("char *rawdata = NULL;")
+ Output("int rawdatalen = 0;")
+ Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
+ Output()
+ Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
+ Output("return -1;")
+ Output("if (v && rawdata)")
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"Only one of itself or rawdata may be specified\");")
+ Output("return -1;")
+ OutRbrace()
+ Output("if (!v && !rawdata)")
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"One of itself or rawdata must be specified\");")
+ Output("return -1;")
+ OutRbrace()
+ Output("if (rawdata)")
+ OutLbrace()
+ Output("if (rawdatalen != sizeof(%s))", self.itselftype)
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"%s rawdata incorrect size\");",
+ self.itselftype)
+ Output("return -1;")
+ OutRbrace()
+ Output("memcpy(&((%s *)self)->ob_itself, rawdata, rawdatalen);", self.objecttype)
+ Output("return 0;")
+ OutRbrace()
+ Output("if (PyMac_GetFSRef(v, &((%s *)self)->ob_itself)) return 0;", self.objecttype)
+ Output("return -1;")
+
class AliasDefinition(PEP253Mixin, ObjectDefinition):
- # XXXX Should inherit from resource?
- getsetlist = [
- ("data",
- """int size;
- PyObject *rv;
-
- size = GetHandleSize((Handle)self->ob_itself);
- HLock((Handle)self->ob_itself);
- rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size);
- HUnlock((Handle)self->ob_itself);
- return rv;
- """,
- None,
- "Raw data of the alias object"
- )
- ]
-
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-
- def outputStructMembers(self):
- ObjectDefinition.outputStructMembers(self)
- Output("void (*ob_freeit)(%s ptr);", self.itselftype)
-
- def outputInitStructMembers(self):
- ObjectDefinition.outputInitStructMembers(self)
- Output("it->ob_freeit = NULL;")
-
- def outputCleanupStructMembers(self):
- Output("if (self->ob_freeit && self->ob_itself)")
- OutLbrace()
- Output("self->ob_freeit(self->ob_itself);")
- OutRbrace()
- Output("self->ob_itself = NULL;")
-
- def output_tp_newBody(self):
- Output("PyObject *self;");
- Output()
- Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
- Output("((%s *)self)->ob_itself = NULL;", self.objecttype)
- Output("return self;")
-
- def output_tp_initBody(self):
- Output("%s itself = NULL;", self.itselftype)
- Output("char *rawdata = NULL;")
- Output("int rawdatalen = 0;")
- Output("Handle h;")
- Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
- Output()
- Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&s#\", kw, %s_Convert, &itself, &rawdata, &rawdatalen))",
- self.prefix)
- Output("return -1;")
- Output("if (itself && rawdata)")
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"Only one of itself or rawdata may be specified\");")
- Output("return -1;")
- OutRbrace()
- Output("if (!itself && !rawdata)")
- OutLbrace()
- Output("PyErr_SetString(PyExc_TypeError, \"One of itself or rawdata must be specified\");")
- Output("return -1;")
- OutRbrace()
- Output("if (rawdata)")
- OutLbrace()
- Output("if ((h = NewHandle(rawdatalen)) == NULL)")
- OutLbrace()
- Output("PyErr_NoMemory();")
- Output("return -1;")
- OutRbrace()
- Output("HLock(h);")
- Output("memcpy((char *)*h, rawdata, rawdatalen);")
- Output("HUnlock(h);")
- Output("((%s *)self)->ob_itself = (%s)h;", self.objecttype, self.itselftype)
- Output("return 0;")
- OutRbrace()
- Output("((%s *)self)->ob_itself = itself;", self.objecttype)
- Output("return 0;")
-
+ # XXXX Should inherit from resource?
+ getsetlist = [
+ ("data",
+ """int size;
+ PyObject *rv;
+
+ size = GetHandleSize((Handle)self->ob_itself);
+ HLock((Handle)self->ob_itself);
+ rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size);
+ HUnlock((Handle)self->ob_itself);
+ return rv;
+ """,
+ None,
+ "Raw data of the alias object"
+ )
+ ]
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+
+ def outputStructMembers(self):
+ ObjectDefinition.outputStructMembers(self)
+ Output("void (*ob_freeit)(%s ptr);", self.itselftype)
+
+ def outputInitStructMembers(self):
+ ObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_freeit = NULL;")
+
+ def outputCleanupStructMembers(self):
+ Output("if (self->ob_freeit && self->ob_itself)")
+ OutLbrace()
+ Output("self->ob_freeit(self->ob_itself);")
+ OutRbrace()
+ Output("self->ob_itself = NULL;")
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;");
+ Output()
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("((%s *)self)->ob_itself = NULL;", self.objecttype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("%s itself = NULL;", self.itselftype)
+ Output("char *rawdata = NULL;")
+ Output("int rawdatalen = 0;")
+ Output("Handle h;")
+ Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
+ Output()
+ Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&s#\", kw, %s_Convert, &itself, &rawdata, &rawdatalen))",
+ self.prefix)
+ Output("return -1;")
+ Output("if (itself && rawdata)")
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"Only one of itself or rawdata may be specified\");")
+ Output("return -1;")
+ OutRbrace()
+ Output("if (!itself && !rawdata)")
+ OutLbrace()
+ Output("PyErr_SetString(PyExc_TypeError, \"One of itself or rawdata must be specified\");")
+ Output("return -1;")
+ OutRbrace()
+ Output("if (rawdata)")
+ OutLbrace()
+ Output("if ((h = NewHandle(rawdatalen)) == NULL)")
+ OutLbrace()
+ Output("PyErr_NoMemory();")
+ Output("return -1;")
+ OutRbrace()
+ Output("HLock(h);")
+ Output("memcpy((char *)*h, rawdata, rawdatalen);")
+ Output("HUnlock(h);")
+ Output("((%s *)self)->ob_itself = (%s)h;", self.objecttype, self.itselftype)
+ Output("return 0;")
+ OutRbrace()
+ Output("((%s *)self)->ob_itself = itself;", self.objecttype)
+ Output("return 0;")
+
# Alias methods come in two flavors: those with the alias as arg1 and
# those with the alias as arg 2.
class Arg2MethodGenerator(OSErrMethodGenerator):
- """Similar to MethodGenerator, but has self as second argument"""
-
- def parseArgumentList(self, args):
- args0, arg1, argsrest = args[:1], args[1], args[2:]
- t0, n0, m0 = arg1
- args = args0 + argsrest
- if m0 != InMode:
- raise ValueError, "method's 'self' must be 'InMode'"
- self.itself = Variable(t0, "_self->ob_itself", SelfMode)
- FunctionGenerator.parseArgumentList(self, args)
- self.argumentList.insert(2, self.itself)
+ """Similar to MethodGenerator, but has self as second argument"""
+
+ def parseArgumentList(self, args):
+ args0, arg1, argsrest = args[:1], args[1], args[2:]
+ t0, n0, m0 = arg1
+ args = args0 + argsrest
+ if m0 != InMode:
+ raise ValueError, "method's 'self' must be 'InMode'"
+ self.itself = Variable(t0, "_self->ob_itself", SelfMode)
+ FunctionGenerator.parseArgumentList(self, args)
+ self.argumentList.insert(2, self.itself)
# From here on it's basically all boiler plate...
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff,
- longname=LONGMODNAME)
+ longname=LONGMODNAME)
fscataloginfoobject = FSCatalogInfoDefinition('FSCatalogInfo', 'FSCatalogInfo', 'FSCatalogInfo')
finfoobject = FInfoDefinition('FInfo', 'FInfo', 'FInfo')
@@ -770,10 +770,10 @@ UInt8 path[MAXPATHNAME];
UInt32 maxPathSize = MAXPATHNAME;
if (!PyArg_ParseTuple(_args, ""))
- return NULL;
+ return NULL;
_err = FSRefMakePath(&_self->ob_itself,
- path,
- maxPathSize);
+ path,
+ maxPathSize);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("s", path);
return _res;
@@ -784,7 +784,7 @@ fsref_methods.append(f)
FSRef_as_pathname_body = """
if (!PyArg_ParseTuple(_args, ""))
- return NULL;
+ return NULL;
_res = FSRef_FSRefMakePath(_self, _args);
return _res;
"""
@@ -797,11 +797,11 @@ char strbuf[1024];
OSErr err;
if (!PyArg_ParseTuple(_args, ""))
- return NULL;
+ return NULL;
err = PyMac_GetFullPathname(&_self->ob_itself, strbuf, sizeof(strbuf));
if ( err ) {
- PyMac_Error(err);
- return NULL;
+ PyMac_Error(err);
+ return NULL;
}
_res = PyString_FromString(strbuf);
return _res;
@@ -812,9 +812,9 @@ fsspec_methods.append(f)
FSSpec_as_tuple_body = """
if (!PyArg_ParseTuple(_args, ""))
- return NULL;
-_res = Py_BuildValue("(iis#)", _self->ob_itself.vRefNum, _self->ob_itself.parID,
- &_self->ob_itself.name[1], _self->ob_itself.name[0]);
+ return NULL;
+_res = Py_BuildValue("(iis#)", _self->ob_itself.vRefNum, _self->ob_itself.parID,
+ &_self->ob_itself.name[1], _self->ob_itself.name[0]);
return _res;
"""
f = ManualGenerator("as_tuple", FSSpec_as_tuple_body)
@@ -825,13 +825,13 @@ pathname_body = """
PyObject *obj;
if (!PyArg_ParseTuple(_args, "O", &obj))
- return NULL;
+ return NULL;
if (PyString_Check(obj)) {
- Py_INCREF(obj);
- return obj;
+ Py_INCREF(obj);
+ return obj;
}
if (PyUnicode_Check(obj))
- return PyUnicode_AsEncodedString(obj, "utf8", "strict");
+ return PyUnicode_AsEncodedString(obj, "utf8", "strict");
_res = PyObject_CallMethod(obj, "as_pathname", NULL);
return _res;
"""
@@ -849,4 +849,3 @@ for f in fsref_methods: fsrefobject.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/fm/fmscan.py b/Mac/Modules/fm/fmscan.py
index 73aad3e..334d5ec 100644
--- a/Mac/Modules/fm/fmscan.py
+++ b/Mac/Modules/fm/fmscan.py
@@ -10,63 +10,63 @@ LONG = "Fonts"
SHORT = "fm"
def main():
- input = "Fonts.h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = "Fonts.h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ return classname, listname
- def makeblacklistnames(self):
- return [
- "OutlineMetrics", # Too complicated
- "AntiTextIsAntiAliased", # XXXX Missing from library...
- "AntiTextGetEnabled",
- "AntiTextSetEnabled",
- "AntiTextGetApplicationAware",
- "AntiTextSetApplicationAware",
- # These are tricky: they're not Carbon dependent or anything, but they
- # exist only on 8.6 or later (both in Carbon and Classic).
- # Disabling them is the easiest path.
- 'SetAntiAliasedTextEnabled',
- 'IsAntiAliasedTextEnabled',
- # OS8-only
- 'InitFonts',
- 'SetFontLock',
- 'FlushFonts',
- ]
+ def makeblacklistnames(self):
+ return [
+ "OutlineMetrics", # Too complicated
+ "AntiTextIsAntiAliased", # XXXX Missing from library...
+ "AntiTextGetEnabled",
+ "AntiTextSetEnabled",
+ "AntiTextGetApplicationAware",
+ "AntiTextSetApplicationAware",
+ # These are tricky: they're not Carbon dependent or anything, but they
+ # exist only on 8.6 or later (both in Carbon and Classic).
+ # Disabling them is the easiest path.
+ 'SetAntiAliasedTextEnabled',
+ 'IsAntiAliasedTextEnabled',
+ # OS8-only
+ 'InitFonts',
+ 'SetFontLock',
+ 'FlushFonts',
+ ]
- def makeblacklisttypes(self):
- return [
- "FMInput_ptr", # Not needed for now
- "FMOutPtr", # Ditto
-## "void_ptr", # Don't know how to do this right now
- "FontInfo", # Ditto
- ]
+ def makeblacklisttypes(self):
+ return [
+ "FMInput_ptr", # Not needed for now
+ "FMOutPtr", # Ditto
+## "void_ptr", # Don't know how to do this right now
+ "FontInfo", # Ditto
+ ]
- def makerepairinstructions(self):
- return [
- ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
- ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
- ([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),],
- [('TextBuffer', 'inText', 'InMode')]),
- ]
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- self.defsfile.write("kNilOptions = 0\n")
+ def makerepairinstructions(self):
+ return [
+ ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
+ ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
+ ([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),],
+ [('TextBuffer', 'inText', 'InMode')]),
+ ]
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("kNilOptions = 0\n")
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/fm/fmsupport.py b/Mac/Modules/fm/fmsupport.py
index 07b944e..e692053 100644
--- a/Mac/Modules/fm/fmsupport.py
+++ b/Mac/Modules/fm/fmsupport.py
@@ -6,21 +6,21 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Fonts.h' # The Apple header file
-MODNAME = '_Fm' # The name of the module
+MACHEADERFILE = 'Fonts.h' # The Apple header file
+MODNAME = '_Fm' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Fm' # The prefix for module-wide routines
+MODPREFIX = 'Fm' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
# Create the type objects
class RevVarInputBufferType(VarInputBufferType):
- def passInput(self, name):
- return "%s__len__, %s__in__" % (name, name)
+ def passInput(self, name):
+ return "%s__len__, %s__in__" % (name, name)
TextBuffer = RevVarInputBufferType()
@@ -36,12 +36,12 @@ static PyObject *
FMRec_New(FMetricRec *itself)
{
- return Py_BuildValue("O&O&O&O&O&",
- PyMac_BuildFixed, itself->ascent,
- PyMac_BuildFixed, itself->descent,
- PyMac_BuildFixed, itself->leading,
- PyMac_BuildFixed, itself->widMax,
- ResObj_New, itself->wTabHandle);
+ return Py_BuildValue("O&O&O&O&O&",
+ PyMac_BuildFixed, itself->ascent,
+ PyMac_BuildFixed, itself->descent,
+ PyMac_BuildFixed, itself->leading,
+ PyMac_BuildFixed, itself->widMax,
+ ResObj_New, itself->wTabHandle);
}
#if 0
@@ -49,12 +49,12 @@ FMRec_New(FMetricRec *itself)
static int
FMRec_Convert(PyObject *v, FMetricRec *p_itself)
{
- return PyArg_ParseTuple(v, "O&O&O&O&O&",
- PyMac_GetFixed, &itself->ascent,
- PyMac_GetFixed, &itself->descent,
- PyMac_GetFixed, &itself->leading,
- PyMac_GetFixed, &itself->widMax,
- ResObj_Convert, &itself->wTabHandle);
+ return PyArg_ParseTuple(v, "O&O&O&O&O&",
+ PyMac_GetFixed, &itself->ascent,
+ PyMac_GetFixed, &itself->descent,
+ PyMac_GetFixed, &itself->leading,
+ PyMac_GetFixed, &itself->widMax,
+ ResObj_Convert, &itself->wTabHandle);
}
#endif
@@ -79,4 +79,3 @@ for f in functions: module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/folder/folderscan.py b/Mac/Modules/folder/folderscan.py
index 39b5a05..8c94893 100644
--- a/Mac/Modules/folder/folderscan.py
+++ b/Mac/Modules/folder/folderscan.py
@@ -11,58 +11,58 @@ SHORT = "folder"
OBJECT = "NOTUSED"
def main():
- input = LONG + ".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! ==="
+ input = LONG + ".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_OSX):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def makeblacklistnames(self):
- return [
- "FindFolderExtended", # Has funny void* argument
- "FSFindFolderExtended", # ditto
- "FolderManagerRegisterCallNotificationProcs", # ditto
-
- "FindFolderEx", # Non-MacOS routine
- ]
+ def makeblacklistnames(self):
+ return [
+ "FindFolderExtended", # Has funny void* argument
+ "FSFindFolderExtended", # ditto
+ "FolderManagerRegisterCallNotificationProcs", # ditto
- def makeblacklisttypes(self):
- return [
- "FolderManagerNotificationProcPtr",
- "FolderManagerNotificationUPP",
- "FolderRouting", # To be done, not difficult
- "FolderDesc", # To be done, not difficult
-
- ]
+ "FindFolderEx", # Non-MacOS routine
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "FolderManagerNotificationProcPtr",
+ "FolderManagerNotificationUPP",
+ "FolderRouting", # To be done, not difficult
+ "FolderDesc", # To be done, not difficult
+
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ]
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("true = True\n")
+ self.defsfile.write("false = False\n")
- def makerepairinstructions(self):
- return [
- ]
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- self.defsfile.write("true = True\n")
- self.defsfile.write("false = False\n")
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/folder/foldersupport.py b/Mac/Modules/folder/foldersupport.py
index b924615..b9b64bf 100644
--- a/Mac/Modules/folder/foldersupport.py
+++ b/Mac/Modules/folder/foldersupport.py
@@ -6,13 +6,13 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Folders.h' # The Apple header file
-MODNAME = '_Folder' # The name of the module
+MACHEADERFILE = 'Folders.h' # The Apple header file
+MODNAME = '_Folder' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Folder' # The prefix for module-wide routines
+MODPREFIX = 'Folder' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -54,4 +54,3 @@ for f in functions: module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/help/helpscan.py b/Mac/Modules/help/helpscan.py
index 32a759a..50e0919 100644
--- a/Mac/Modules/help/helpscan.py
+++ b/Mac/Modules/help/helpscan.py
@@ -11,57 +11,57 @@ SHORT = "help"
OBJECT = "NOTUSED"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- def makeblacklistnames(self):
- return [
- ]
+ def makeblacklistnames(self):
+ return [
+ ]
- def makeblacklisttypes(self):
- return [
-## "TipFunctionUPP",
-## "HMMessageRecord",
-## "HMMessageRecord_ptr",
- "HMWindowContentUPP",
- "HMMenuTitleContentUPP",
- "HMControlContentUPP",
- "HMMenuItemContentUPP",
- # For the moment
- "HMHelpContentRec",
- "HMHelpContentRec_ptr",
- ]
+ def makeblacklisttypes(self):
+ return [
+## "TipFunctionUPP",
+## "HMMessageRecord",
+## "HMMessageRecord_ptr",
+ "HMWindowContentUPP",
+ "HMMenuTitleContentUPP",
+ "HMControlContentUPP",
+ "HMMenuItemContentUPP",
+ # For the moment
+ "HMHelpContentRec",
+ "HMHelpContentRec_ptr",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+## ([("WindowPtr", "*", "OutMode")],
+## [("ExistingWindowPtr", "*", "*")]),
+ ]
- def makerepairinstructions(self):
- return [
-## ([("WindowPtr", "*", "OutMode")],
-## [("ExistingWindowPtr", "*", "*")]),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/help/helpsupport.py b/Mac/Modules/help/helpsupport.py
index a630603..77f5c2e 100644
--- a/Mac/Modules/help/helpsupport.py
+++ b/Mac/Modules/help/helpsupport.py
@@ -6,16 +6,16 @@
import string
# Declarations that change for each manager
-MODNAME = '_Help' # The name of the module
-OBJECTNAME = 'UNUSED' # The basic name of the objects used here
-KIND = 'Record' # Usually 'Ptr' or 'Handle'
+MODNAME = '_Help' # The name of the module
+OBJECTNAME = 'UNUSED' # The basic name of the objects used here
+KIND = 'Record' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Help' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Help' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -40,17 +40,17 @@ includestuff = includestuff + """
"""
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- def outputCheckConvertArg(self):
- OutLbrace("if (DlgObj_Check(v))")
- Output("*p_itself = ((WindowObject *)v)->ob_itself;")
- Output("return 1;")
- OutRbrace()
- Out("""
- if (v == Py_None) { *p_itself = NULL; return 1; }
- if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
- """)
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputCheckConvertArg(self):
+ OutLbrace("if (DlgObj_Check(v))")
+ Output("*p_itself = ((WindowObject *)v)->ob_itself;")
+ Output("return 1;")
+ OutRbrace()
+ Out("""
+ if (v == Py_None) { *p_itself = NULL; return 1; }
+ if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
+ """)
# From here on it's basically all boiler plate...
@@ -76,4 +76,3 @@ for f in functions: module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/ibcarbon/IBCarbonscan.py b/Mac/Modules/ibcarbon/IBCarbonscan.py
index 1f05217..84e4f1e 100644
--- a/Mac/Modules/ibcarbon/IBCarbonscan.py
+++ b/Mac/Modules/ibcarbon/IBCarbonscan.py
@@ -10,40 +10,40 @@ sys.path.append(BGENDIR)
from scantools import Scanner_OSX
def main():
- print "---Scanning IBCarbonRuntime.h---"
- input = ["IBCarbonRuntime.h"]
- output = "IBCarbongen.py"
- defsoutput = TOOLBOXDIR + "IBCarbonRuntime.py"
- scanner = IBCarbon_Scanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "--done scanning, importing--"
- import IBCarbonsupport
- print "done"
+ print "---Scanning IBCarbonRuntime.h---"
+ input = ["IBCarbonRuntime.h"]
+ output = "IBCarbongen.py"
+ defsoutput = TOOLBOXDIR + "IBCarbonRuntime.py"
+ scanner = IBCarbon_Scanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "--done scanning, importing--"
+ import IBCarbonsupport
+ print "done"
class IBCarbon_Scanner(Scanner_OSX):
- def destination(self, type, name, arglist):
- classname = "IBCarbonFunction"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t == "IBNibRef" and m == "InMode":
- classname = "IBCarbonMethod"
- listname = "methods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- "DisposeNibReference", # taken care of by destructor
- "CreateNibReferenceWithCFBundle", ## need to wrap CFBundle.h properly first
- ]
-
- def makerepairinstructions(self):
- return []
+ def destination(self, type, name, arglist):
+ classname = "IBCarbonFunction"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t == "IBNibRef" and m == "InMode":
+ classname = "IBCarbonMethod"
+ listname = "methods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ "DisposeNibReference", # taken care of by destructor
+ "CreateNibReferenceWithCFBundle", ## need to wrap CFBundle.h properly first
+ ]
+
+ def makerepairinstructions(self):
+ return []
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/ibcarbon/IBCarbonsupport.py b/Mac/Modules/ibcarbon/IBCarbonsupport.py
index 5d07be1..5f41328 100644
--- a/Mac/Modules/ibcarbon/IBCarbonsupport.py
+++ b/Mac/Modules/ibcarbon/IBCarbonsupport.py
@@ -25,12 +25,12 @@ initstuff = """
module = MacModule('_IBCarbon', 'IBCarbon', includestuff, finalstuff, initstuff)
class CFReleaserObject(PEP253Mixin, GlobalObjectDefinition):
- def outputFreeIt(self, name):
- Output("CFRelease(%s);" % name)
+ def outputFreeIt(self, name):
+ Output("CFRelease(%s);" % name)
class CFNibDesc(PEP253Mixin, GlobalObjectDefinition):
- def outputFreeIt(self, name):
- Output("DisposeNibReference(%s);" % name)
+ def outputFreeIt(self, name):
+ Output("DisposeNibReference(%s);" % name)
#cfstringobject = CFReleaserObject("CFStringRef")
#module.addobject(cfstringobject)
diff --git a/Mac/Modules/icn/icnscan.py b/Mac/Modules/icn/icnscan.py
index c6a39f3..bdc3b84 100644
--- a/Mac/Modules/icn/icnscan.py
+++ b/Mac/Modules/icn/icnscan.py
@@ -11,62 +11,62 @@ SHORT = "icn"
OBJECT = "NOTUSED"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def makeblacklistnames(self):
- return [
- "GetIconCacheData",
- "SetIconCacheData",
- # Constants with funny definitions
- "kSelectorAllHugeData",
- "kSelectorAllAvailableData",
- "svAllAvailableData",
- # Something in a comment accidentally seen as a const definition
- "err",
- # OS8 only
- 'IconServicesTerminate',
- # Lazy, right now.
- "GetIconRefFromFileInfo"
- ]
+ def makeblacklistnames(self):
+ return [
+ "GetIconCacheData",
+ "SetIconCacheData",
+ # Constants with funny definitions
+ "kSelectorAllHugeData",
+ "kSelectorAllAvailableData",
+ "svAllAvailableData",
+ # Something in a comment accidentally seen as a const definition
+ "err",
+ # OS8 only
+ 'IconServicesTerminate',
+ # Lazy, right now.
+ "GetIconRefFromFileInfo"
+ ]
- def makeblacklisttypes(self):
- return [
- "IconActionUPP",
- "IconGetterUPP",
- "CFragInitBlockPtr",
- "CGRect_ptr",
- ]
+ def makeblacklisttypes(self):
+ return [
+ "IconActionUPP",
+ "IconGetterUPP",
+ "CFragInitBlockPtr",
+ "CGRect_ptr",
+ ]
- def makerepairinstructions(self):
- return [
- ]
+ def makerepairinstructions(self):
+ return [
+ ]
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("from Carbon.Files import *\n")
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- self.defsfile.write("from Carbon.Files import *\n")
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/icn/icnsupport.py b/Mac/Modules/icn/icnsupport.py
index ef1dbf3..1b15385 100644
--- a/Mac/Modules/icn/icnsupport.py
+++ b/Mac/Modules/icn/icnsupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Icons.h' # The Apple header file
-MODNAME = '_Icn' # The name of the module
-OBJECTNAME = 'Icon' # The basic name of the objects used here
-KIND = 'Handle' # Usually 'Ptr' or 'Handle'
+MACHEADERFILE = 'Icons.h' # The Apple header file
+MODNAME = '_Icn' # The name of the module
+OBJECTNAME = 'Icon' # The basic name of the objects used here
+KIND = 'Handle' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Icn' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Icn' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -52,17 +52,17 @@ includestuff = includestuff + """
"""
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- def outputCheckConvertArg(self):
- OutLbrace("if (DlgObj_Check(v))")
- Output("*p_itself = ((WindowObject *)v)->ob_itself;")
- Output("return 1;")
- OutRbrace()
- Out("""
- if (v == Py_None) { *p_itself = NULL; return 1; }
- if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
- """)
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputCheckConvertArg(self):
+ OutLbrace("if (DlgObj_Check(v))")
+ Output("*p_itself = ((WindowObject *)v)->ob_itself;")
+ Output("return 1;")
+ OutRbrace()
+ Out("""
+ if (v == Py_None) { *p_itself = NULL; return 1; }
+ if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
+ """)
# From here on it's basically all boiler plate...
@@ -88,4 +88,3 @@ for f in functions: module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/launch/launchscan.py b/Mac/Modules/launch/launchscan.py
index bdda1de..621033b 100644
--- a/Mac/Modules/launch/launchscan.py
+++ b/Mac/Modules/launch/launchscan.py
@@ -11,76 +11,76 @@ SHORT = "launch"
OBJECT = "NOTUSED"
def main():
- input = LONG + ".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! ==="
+ input = LONG + ".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]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ # This is non-functional today
+ if t == OBJECT 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.Files import *\n")
- self.defsfile.write("kLSRequestAllInfo = -1\n")
- self.defsfile.write("kLSRolesAll = -1\n")
- self.defsfile.write("kLSUnknownType = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
- self.defsfile.write("kLSUnknownCreator = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
- self.defsfile.write("kLSInvalidExtensionIndex = -1\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("from Carbon.Files import *\n")
+ self.defsfile.write("kLSRequestAllInfo = -1\n")
+ self.defsfile.write("kLSRolesAll = -1\n")
+ self.defsfile.write("kLSUnknownType = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
+ self.defsfile.write("kLSUnknownCreator = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
+ self.defsfile.write("kLSInvalidExtensionIndex = -1\n")
- def makeblacklistnames(self):
- return [
- "LSInit",
- "LSTerm",
- "kLSRequestAllInfo",
- "kLSRolesAll",
- "kLSInvalidExtensionIndex",
- "kLSUnknownType",
- "kLSUnknownCreator"
- ]
+ def makeblacklistnames(self):
+ return [
+ "LSInit",
+ "LSTerm",
+ "kLSRequestAllInfo",
+ "kLSRolesAll",
+ "kLSInvalidExtensionIndex",
+ "kLSUnknownType",
+ "kLSUnknownCreator"
+ ]
- def makeblacklisttypes(self):
- return [
- "LSLaunchFSRefSpec_ptr",
- "LSLaunchURLSpec_ptr",
- ]
+ def makeblacklisttypes(self):
+ return [
+ "LSLaunchFSRefSpec_ptr",
+ "LSLaunchURLSpec_ptr",
+ ]
- def makerepairinstructions(self):
- return [
- # LSGetApplicationForInfo
- ([('CFStringRef', 'inExtension', 'InMode')],
- [('OptCFStringRef', 'inExtension', 'InMode')]),
-
- # LSFindApplicationForInfo
- ([('CFStringRef', 'inBundleID', 'InMode')],
- [('OptCFStringRef', 'inBundleID', 'InMode')]),
- ([('CFStringRef', 'inName', 'InMode')],
- [('OptCFStringRef', 'inName', 'InMode')]),
+ def makerepairinstructions(self):
+ return [
+ # LSGetApplicationForInfo
+ ([('CFStringRef', 'inExtension', 'InMode')],
+ [('OptCFStringRef', 'inExtension', 'InMode')]),
+
+ # LSFindApplicationForInfo
+ ([('CFStringRef', 'inBundleID', 'InMode')],
+ [('OptCFStringRef', 'inBundleID', 'InMode')]),
+ ([('CFStringRef', 'inName', 'InMode')],
+ [('OptCFStringRef', 'inName', 'InMode')]),
+
+ # Unicode filenames passed as length, buffer. LSGetExtensionInfo
+ ([('UniCharCount', '*', 'InMode'),
+ ('UniChar_ptr', '*', 'InMode')],
+ [('UnicodeReverseInBuffer', '*', 'InMode')]
+ ),
+ ]
- # Unicode filenames passed as length, buffer. LSGetExtensionInfo
- ([('UniCharCount', '*', 'InMode'),
- ('UniChar_ptr', '*', 'InMode')],
- [('UnicodeReverseInBuffer', '*', 'InMode')]
- ),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/launch/launchsupport.py b/Mac/Modules/launch/launchsupport.py
index 122278c..34c2efb 100644
--- a/Mac/Modules/launch/launchsupport.py
+++ b/Mac/Modules/launch/launchsupport.py
@@ -6,16 +6,16 @@
import string
# Declarations that change for each manager
-MODNAME = '_Launch' # The name of the module
-OBJECTNAME = 'UNUSED' # The basic name of the objects used here
-KIND = 'Record' # Usually 'Ptr' or 'Handle'
+MODNAME = '_Launch' # The name of the module
+OBJECTNAME = 'UNUSED' # The basic name of the objects used here
+KIND = 'Record' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Launch' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Launch' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -41,21 +41,21 @@ PyObject *PyMac_GetOSErrException(void);
static int
OptCFStringRefObj_Convert(PyObject *v, CFStringRef *spec)
{
- if (v == Py_None) {
- *spec = NULL;
- return 1;
- }
- return CFStringRefObj_Convert(v, spec);
+ if (v == Py_None) {
+ *spec = NULL;
+ return 1;
+ }
+ return CFStringRefObj_Convert(v, spec);
}
PyObject *
OptCFStringRefObj_New(CFStringRef it)
{
- if (it == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- return CFStringRefObj_New(it);
+ if (it == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ return CFStringRefObj_New(it);
}
/*
@@ -64,13 +64,13 @@ OptCFStringRefObj_New(CFStringRef it)
PyObject *
LSItemInfoRecord_New(LSItemInfoRecord *it)
{
- return Py_BuildValue("{s:is:O&s:O&s:O&s:O&s:i}",
- "flags", it->flags,
- "filetype", PyMac_BuildOSType, it->filetype,
- "creator", PyMac_BuildOSType, it->creator,
- "extension", OptCFStringRefObj_New, it->extension,
- "iconFileName", OptCFStringRefObj_New, it->iconFileName,
- "kindID", it->kindID);
+ return Py_BuildValue("{s:is:O&s:O&s:O&s:O&s:i}",
+ "flags", it->flags,
+ "filetype", PyMac_BuildOSType, it->filetype,
+ "creator", PyMac_BuildOSType, it->creator,
+ "extension", OptCFStringRefObj_New, it->extension,
+ "iconFileName", OptCFStringRefObj_New, it->iconFileName,
+ "kindID", it->kindID);
}
"""
@@ -99,4 +99,3 @@ for f in functions: module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/launch/setup.py b/Mac/Modules/launch/setup.py
index ccf8ee7..2054195 100644
--- a/Mac/Modules/launch/setup.py
+++ b/Mac/Modules/launch/setup.py
@@ -4,10 +4,10 @@
from distutils.core import Extension, setup
setup(name="LaunchServices", version="0.2",
- ext_modules=[
- Extension('_Launch', ['_Launchmodule.c'],
- extra_link_args=['-framework', 'ApplicationServices'])
- ],
- py_modules=['LaunchServices.Launch', 'LaunchServices.LaunchServices'],
- package_dir={'LaunchServices':'../../../Lib/plat-mac/Carbon'}
- )
+ ext_modules=[
+ Extension('_Launch', ['_Launchmodule.c'],
+ extra_link_args=['-framework', 'ApplicationServices'])
+ ],
+ py_modules=['LaunchServices.Launch', 'LaunchServices.LaunchServices'],
+ package_dir={'LaunchServices':'../../../Lib/plat-mac/Carbon'}
+ )
diff --git a/Mac/Modules/list/listscan.py b/Mac/Modules/list/listscan.py
index 66cb2ad..877f6cb 100644
--- a/Mac/Modules/list/listscan.py
+++ b/Mac/Modules/list/listscan.py
@@ -11,78 +11,78 @@ SHORT = "list"
OBJECT = "ListHandle"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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[-1]
- # This is non-functional today
- if t in ('ListHandle', 'ListRef') and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- "LDispose", # Done by removing the object
- "LSearch", # We don't want to handle procs just yet
- "CreateCustomList", # done manually
- "SetListDefinitionProc",
-
- # These have funny argument/return values
- "GetListViewBounds",
- "GetListCellIndent",
- "GetListCellSize",
- "GetListVisibleCells",
- "GetListClickLocation",
- "GetListMouseLocation",
- "GetListDataBounds",
- "SetListLastClick",
- ]
-
- def makeblacklisttypes(self):
- return [
- "ListClickLoopUPP", # Too difficult for now
- "ListDefSpecPtr", # later
- ]
-
- def makerepairinstructions(self):
- return [
- ([('ListBounds_ptr', '*', 'InMode')],
- [('Rect_ptr', '*', 'InMode')]),
-
- ([("Cell", "theCell", "OutMode")],
- [("Cell", "theCell", "InOutMode")]),
-
- ([("void_ptr", "*", "InMode"), ("short", "*", "InMode")],
- [("InBufferShortsize", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("short", "*", "OutMode")],
- [("VarOutBufferShortsize", "*", "InOutMode")]),
-
- # SetListCellIndent doesn't have const
- ([("Point", "indent", "OutMode")],
- [("Point_ptr", "indent", "InMode")]),
-
- ]
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
-
-
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[-1]
+ # This is non-functional today
+ if t in ('ListHandle', 'ListRef') and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ "LDispose", # Done by removing the object
+ "LSearch", # We don't want to handle procs just yet
+ "CreateCustomList", # done manually
+ "SetListDefinitionProc",
+
+ # These have funny argument/return values
+ "GetListViewBounds",
+ "GetListCellIndent",
+ "GetListCellSize",
+ "GetListVisibleCells",
+ "GetListClickLocation",
+ "GetListMouseLocation",
+ "GetListDataBounds",
+ "SetListLastClick",
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "ListClickLoopUPP", # Too difficult for now
+ "ListDefSpecPtr", # later
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([('ListBounds_ptr', '*', 'InMode')],
+ [('Rect_ptr', '*', 'InMode')]),
+
+ ([("Cell", "theCell", "OutMode")],
+ [("Cell", "theCell", "InOutMode")]),
+
+ ([("void_ptr", "*", "InMode"), ("short", "*", "InMode")],
+ [("InBufferShortsize", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("short", "*", "OutMode")],
+ [("VarOutBufferShortsize", "*", "InOutMode")]),
+
+ # SetListCellIndent doesn't have const
+ ([("Point", "indent", "OutMode")],
+ [("Point_ptr", "indent", "InMode")]),
+
+ ]
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/list/listsupport.py b/Mac/Modules/list/listsupport.py
index e44317a..93baede 100644
--- a/Mac/Modules/list/listsupport.py
+++ b/Mac/Modules/list/listsupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Lists.h' # The Apple header file
-MODNAME = '_List' # The name of the module
-OBJECTNAME = 'List' # The basic name of the objects used here
-KIND = 'Handle' # Usually 'Ptr' or 'Handle'
+MACHEADERFILE = 'Lists.h' # The Apple header file
+MODNAME = '_List' # The name of the module
+OBJECTNAME = 'List' # The basic name of the objects used here
+KIND = 'Handle' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'List' # The prefix for module-wide routines
-OBJECTTYPE = "ListHandle" # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'List' # The prefix for module-wide routines
+OBJECTTYPE = "ListHandle" # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -29,8 +29,8 @@ ListBounds_ptr = Rect_ptr
ListDefSpec = ListDefSpec_ptr = OpaqueType("ListDefSpec", "PyMac_BuildListDefSpec", "PyMac_GetListDefSpec")
-VarOutBufferShortsize = VarHeapOutputBufferType('char', 'short', 's') # (buf, &len)
-InBufferShortsize = VarInputBufferType('char', 'short', 's') # (buf, len)
+VarOutBufferShortsize = VarHeapOutputBufferType('char', 'short', 's') # (buf, &len)
+InBufferShortsize = VarInputBufferType('char', 'short', 's') # (buf, len)
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
DataHandle = OpaqueByValueType("DataHandle", "ResObj")
@@ -64,59 +64,59 @@ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ListHandle, ListObj_Convert);
"""
class ListMethodGenerator(MethodGenerator):
- """Similar to MethodGenerator, but has self as last argument"""
+ """Similar to MethodGenerator, but has self as last argument"""
- def parseArgumentList(self, args):
- args, a0 = args[:-1], args[-1]
- t0, n0, m0 = a0
- if m0 != InMode:
- raise ValueError, "method's 'self' must be 'InMode'"
- self.itself = Variable(t0, "_self->ob_itself", SelfMode)
- FunctionGenerator.parseArgumentList(self, args)
- self.argumentList.append(self.itself)
+ def parseArgumentList(self, args):
+ args, a0 = args[:-1], args[-1]
+ t0, n0, m0 = a0
+ if m0 != InMode:
+ raise ValueError, "method's 'self' must be 'InMode'"
+ self.itself = Variable(t0, "_self->ob_itself", SelfMode)
+ FunctionGenerator.parseArgumentList(self, args)
+ self.argumentList.append(self.itself)
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- # XXXX Should inherit from Resource
- getsetlist = [(
- 'listFlags',
- 'return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);',
- 'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->listFlags)) return -1;',
- None,
- ), (
- 'selFlags',
- 'return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);',
- 'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->selFlags)) return -1;',
- None,
- ), (
- 'cellSize',
- 'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);',
- 'if (!PyArg_Parse(v, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize)) return -1;',
- None
- )]
-
- def outputStructMembers(self):
- ObjectDefinition.outputStructMembers(self)
- Output("PyObject *ob_ldef_func;")
- Output("int ob_must_be_disposed;")
-
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- PyErr_SetString(List_Error,"Cannot create null List");
- return NULL;
- }""")
-
- def outputInitStructMembers(self):
- ObjectDefinition.outputInitStructMembers(self)
- Output("it->ob_ldef_func = NULL;")
- Output("it->ob_must_be_disposed = 1;")
- Output("SetListRefCon(itself, (long)it);")
-
- def outputFreeIt(self, itselfname):
- Output("Py_XDECREF(self->ob_ldef_func);")
- Output("self->ob_ldef_func = NULL;")
- Output("SetListRefCon(self->ob_itself, (long)0);")
- Output("if (self->ob_must_be_disposed && %s) LDispose(%s);", itselfname, itselfname)
-
+ # XXXX Should inherit from Resource
+ getsetlist = [(
+ 'listFlags',
+ 'return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);',
+ 'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->listFlags)) return -1;',
+ None,
+ ), (
+ 'selFlags',
+ 'return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);',
+ 'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->selFlags)) return -1;',
+ None,
+ ), (
+ 'cellSize',
+ 'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);',
+ 'if (!PyArg_Parse(v, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize)) return -1;',
+ None
+ )]
+
+ def outputStructMembers(self):
+ ObjectDefinition.outputStructMembers(self)
+ Output("PyObject *ob_ldef_func;")
+ Output("int ob_must_be_disposed;")
+
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ PyErr_SetString(List_Error,"Cannot create null List");
+ return NULL;
+ }""")
+
+ def outputInitStructMembers(self):
+ ObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_ldef_func = NULL;")
+ Output("it->ob_must_be_disposed = 1;")
+ Output("SetListRefCon(itself, (long)it);")
+
+ def outputFreeIt(self, itselfname):
+ Output("Py_XDECREF(self->ob_ldef_func);")
+ Output("self->ob_ldef_func = NULL;")
+ Output("SetListRefCon(self->ob_itself, (long)0);")
+ Output("if (self->ob_must_be_disposed && %s) LDispose(%s);", itselfname, itselfname)
+
# From here on it's basically all boiler plate...
finalstuff = finalstuff + """
@@ -126,34 +126,34 @@ static void myListDefFunction(SInt16 message,
Cell theCell,
SInt16 dataOffset,
SInt16 dataLen,
- ListHandle theList)
+ ListHandle theList)
{
- PyObject *listDefFunc, *args, *rv=NULL;
- ListObject *self;
-
- self = (ListObject*)GetListRefCon(theList);
- if (self == NULL || self->ob_itself != theList)
- return; /* nothing we can do */
- listDefFunc = self->ob_ldef_func;
- if (listDefFunc == NULL)
- return; /* nothing we can do */
- args = Py_BuildValue("hbO&O&hhO", message,
- selected,
- PyMac_BuildRect, cellRect,
- PyMac_BuildPoint, theCell,
- dataOffset,
- dataLen,
- self);
- if (args != NULL) {
- rv = PyEval_CallObject(listDefFunc, args);
- Py_DECREF(args);
- }
- if (rv == NULL) {
- PySys_WriteStderr("error in list definition callback:\\n");
- PyErr_Print();
- } else {
- Py_DECREF(rv);
- }
+ PyObject *listDefFunc, *args, *rv=NULL;
+ ListObject *self;
+
+ self = (ListObject*)GetListRefCon(theList);
+ if (self == NULL || self->ob_itself != theList)
+ return; /* nothing we can do */
+ listDefFunc = self->ob_ldef_func;
+ if (listDefFunc == NULL)
+ return; /* nothing we can do */
+ args = Py_BuildValue("hbO&O&hhO", message,
+ selected,
+ PyMac_BuildRect, cellRect,
+ PyMac_BuildPoint, theCell,
+ dataOffset,
+ dataLen,
+ self);
+ if (args != NULL) {
+ rv = PyEval_CallObject(listDefFunc, args);
+ Py_DECREF(args);
+ }
+ if (rv == NULL) {
+ PySys_WriteStderr("error in list definition callback:\\n");
+ PyErr_Print();
+ } else {
+ Py_DECREF(rv);
+ }
}
"""
@@ -177,7 +177,7 @@ as_List_body = """
Handle h;
ListObject *l;
if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &h))
- return NULL;
+ return NULL;
l = (ListObject *)ListObj_New(as_List(h));
l->ob_must_be_disposed = 0;
_res = Py_BuildValue("O", l);
@@ -215,10 +215,10 @@ if (!PyArg_ParseTuple(_args, "O&O&O&(iO)O&bbbb",
&hasGrow,
&scrollHoriz,
&scrollVert))
- return NULL;
+ return NULL;
-/* Carbon applications use the CreateCustomList API */
+/* Carbon applications use the CreateCustomList API */
theSpec.u.userProc = myListDefFunctionUPP;
CreateCustomList(&rView,
&dataBounds,
@@ -234,7 +234,7 @@ CreateCustomList(&rView,
_res = ListObj_New(outList);
if (_res == NULL)
- return NULL;
+ return NULL;
Py_INCREF(listDefFunc);
((ListObject*)_res)->ob_ldef_func = listDefFunc;
return _res;\
@@ -253,4 +253,3 @@ for f in methods: object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/menu/menuedit.py b/Mac/Modules/menu/menuedit.py
index f613d8b..b74301d 100644
--- a/Mac/Modules/menu/menuedit.py
+++ b/Mac/Modules/menu/menuedit.py
@@ -121,4 +121,3 @@ f = Function(OSStatus, 'RemoveMenuCommandProperty',
(OSType, 'inPropertyTag', InMode),
)
functions.append(f)
-
diff --git a/Mac/Modules/menu/menuscan.py b/Mac/Modules/menu/menuscan.py
index 281cc86..ae9465e 100644
--- a/Mac/Modules/menu/menuscan.py
+++ b/Mac/Modules/menu/menuscan.py
@@ -7,91 +7,91 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- input = "Menus.h"
- output = "menugen.py"
- defsoutput = TOOLBOXDIR + "Menus.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now doing 'import menusupport' ==="
- import menusupport
- print "=== Done. It's up to you to compile Menumodule.c ==="
+ input = "Menus.h"
+ output = "menugen.py"
+ defsoutput = TOOLBOXDIR + "Menus.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now doing 'import menusupport' ==="
+ import menusupport
+ print "=== Done. It's up to you to compile Menumodule.c ==="
class MyScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t in ("MenuHandle", "MenuRef") and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in ("MenuHandle", "MenuRef") and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def makeblacklistnames(self):
- return [
-## "IsShowContextualMenuClick", # Can't find it in the library
-## "InitContextualMenus", # ditto
- "GetMenuItemProperty", # difficult for the moment
- "GetMenuItemPropertySize",
- "SetMenuItemProperty",
- "RemoveMenuItemProperty",
- "SetMenuCommandProperty",
- "GetMenuCommandProperty",
- "GetMenuTitle", # Funny arg/returnvalue
- "SetMenuTitle",
- "SetMenuTitleIcon", # void*
- # OS8 calls:
- 'GetMenuItemRefCon2',
- 'SetMenuItemRefCon2',
- 'EnableItem',
- 'DisableItem',
- 'CheckItem',
- 'CountMItems',
- 'OpenDeskAcc',
- 'SystemEdit',
- 'SystemMenu',
- 'SetMenuFlash',
- 'InitMenus',
- 'InitProcMenu',
- ]
+ def makeblacklistnames(self):
+ return [
+## "IsShowContextualMenuClick", # Can't find it in the library
+## "InitContextualMenus", # ditto
+ "GetMenuItemProperty", # difficult for the moment
+ "GetMenuItemPropertySize",
+ "SetMenuItemProperty",
+ "RemoveMenuItemProperty",
+ "SetMenuCommandProperty",
+ "GetMenuCommandProperty",
+ "GetMenuTitle", # Funny arg/returnvalue
+ "SetMenuTitle",
+ "SetMenuTitleIcon", # void*
+ # OS8 calls:
+ 'GetMenuItemRefCon2',
+ 'SetMenuItemRefCon2',
+ 'EnableItem',
+ 'DisableItem',
+ 'CheckItem',
+ 'CountMItems',
+ 'OpenDeskAcc',
+ 'SystemEdit',
+ 'SystemMenu',
+ 'SetMenuFlash',
+ 'InitMenus',
+ 'InitProcMenu',
+ ]
- def makeblacklisttypes(self):
- return [
- 'MCTableHandle',
- 'MCEntryPtr',
- 'MCTablePtr',
- 'AEDesc_ptr', # For now: doable, but not easy
- 'ProcessSerialNumber', # ditto
- "MenuDefSpecPtr", # Too difficult for now
- "MenuDefSpec_ptr", # ditto
- "MenuTrackingData",
- "void_ptr", # Don't know yet.
- "EventRef", # For now, not exported yet.
- "MenuItemDataPtr", # Not yet.
- "MenuItemDataRec_ptr",
- ]
+ def makeblacklisttypes(self):
+ return [
+ 'MCTableHandle',
+ 'MCEntryPtr',
+ 'MCTablePtr',
+ 'AEDesc_ptr', # For now: doable, but not easy
+ 'ProcessSerialNumber', # ditto
+ "MenuDefSpecPtr", # Too difficult for now
+ "MenuDefSpec_ptr", # ditto
+ "MenuTrackingData",
+ "void_ptr", # Don't know yet.
+ "EventRef", # For now, not exported yet.
+ "MenuItemDataPtr", # Not yet.
+ "MenuItemDataRec_ptr",
+ ]
- def makerepairinstructions(self):
- return [
- ([("Str255", "itemString", "InMode")],
- [("*", "*", "OutMode")]),
-
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode"),
- ("long", "*", "OutMode")],
- [("VarVarOutBuffer", "*", "InOutMode")]),
- ([("MenuRef", 'outHierMenu', "OutMode")],
- [("OptMenuRef", 'outHierMenu', "OutMode")]),
- ]
+ def makerepairinstructions(self):
+ return [
+ ([("Str255", "itemString", "InMode")],
+ [("*", "*", "OutMode")]),
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode"),
+ ("long", "*", "OutMode")],
+ [("VarVarOutBuffer", "*", "InOutMode")]),
+ ([("MenuRef", 'outHierMenu', "OutMode")],
+ [("OptMenuRef", 'outHierMenu', "OutMode")]),
+ ]
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/menu/menusupport.py b/Mac/Modules/menu/menusupport.py
index 7c4ae0d..a04b755 100644
--- a/Mac/Modules/menu/menusupport.py
+++ b/Mac/Modules/menu/menusupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Menus.h' # The Apple header file
-MODNAME = '_Menu' # The name of the module
-OBJECTNAME = 'Menu' # The basic name of the objects used here
+MACHEADERFILE = 'Menus.h' # The Apple header file
+MODNAME = '_Menu' # The name of the module
+OBJECTNAME = 'Menu' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Menu' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Menu' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
EXTRAFILE = string.lower(MODPREFIX) + 'edit.py' # A similar file but hand-made
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -48,7 +48,7 @@ extern PyObject *_MenuObj_New(MenuHandle);
extern int _MenuObj_Convert(PyObject *, MenuHandle *);
#define MenuObj_New _MenuObj_New
-#define MenuObj_Convert _MenuObj_Convert
+#define MenuObj_Convert _MenuObj_Convert
#endif
#define as_Menu(h) ((MenuHandle)h)
@@ -58,31 +58,31 @@ extern int _MenuObj_Convert(PyObject *, MenuHandle *);
/* Alternative version of MenuObj_New, which returns None for NULL argument */
PyObject *OptMenuObj_New(MenuRef itself)
{
- if (itself == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- return MenuObj_New(itself);
+ if (itself == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ return MenuObj_New(itself);
}
/* Alternative version of MenuObj_Convert, which returns NULL for a None argument */
int OptMenuObj_Convert(PyObject *v, MenuRef *p_itself)
{
- if ( v == Py_None ) {
- *p_itself = NULL;
- return 1;
- }
- return MenuObj_Convert(v, p_itself);
+ if ( v == Py_None ) {
+ *p_itself = NULL;
+ return 1;
+ }
+ return MenuObj_Convert(v, p_itself);
}
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle, MenuObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle, MenuObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert);
"""
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- pass
+ pass
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
diff --git a/Mac/Modules/mlte/mltescan.py b/Mac/Modules/mlte/mltescan.py
index 134bffa..adecb4f 100644
--- a/Mac/Modules/mlte/mltescan.py
+++ b/Mac/Modules/mlte/mltescan.py
@@ -12,33 +12,33 @@ OBJECTS = ("TXNObject", "TXNFontMenuObject")
# ADD object typenames here
def main():
- input = "MacTextEditor.h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.gentypetest(SHORT+"typetest.py")
- scanner.close()
- 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! ==="
+ input = "MacTextEditor.h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.gentypetest(SHORT+"typetest.py")
+ scanner.close()
+ 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_OSX):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t in OBJECTS and m == "InMode":
- classname = "Method"
- listname = t + "_methods"
- return classname, listname
-
- def writeinitialdefs(self):
- self.defsfile.write("""
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in OBJECTS and m == "InMode":
+ classname = "Method"
+ listname = t + "_methods"
+ return classname, listname
+
+ def writeinitialdefs(self):
+ self.defsfile.write("""
def FOUR_CHAR_CODE(x): return x
false = 0
true = 1
@@ -55,89 +55,89 @@ kTXNFontSizeAttributeSize = 4
normal = 0
""")
- def makeblacklistnames(self):
- return [
- "TXNGetFontDefaults", # Arg is too difficult
- "TXNSetFontDefaults", # Arg is too difficult
- "TXNInitTextension", # done manually
-
- # Constants with funny definitions
- "kTXNClearThisControl",
- "kTXNClearTheseFontFeatures",
- "kTXNDontCareTypeSize",
- "kTXNDecrementTypeSize",
- "kTXNUseCurrentSelection",
- "kTXNStartOffset",
- "kTXNEndOffset",
- "kTXNQDFontNameAttributeSize",
- "kTXNQDFontFamilyIDAttributeSize",
- "kTXNQDFontSizeAttributeSize",
- "kTXNQDFontStyleAttributeSize",
- "kTXNQDFontColorAttributeSize",
- "kTXNTextEncodingAttributeSize",
- "kTXNUseEncodingWordRulesMask",
- "kTXNFontSizeAttributeSize",
- "status",
- "justification",
- 'TXNTSMCheck', # OS8
- ]
-
- def makeblacklisttypes(self):
- return [
- "TXNTab", # TBD
- "TXNMargins", # TBD
- "TXNControlData", #TBD
- "TXNATSUIFeatures", #TBD
- "TXNATSUIVariations", #TBD
- "TXNAttributeData", #TBD
- "TXNTypeAttributes", #TBD
- "TXNMatchTextRecord", #TBD
- "TXNBackground", #TBD
- "TXNFindUPP",
- "ATSUStyle", #TBD
- "TXNBackground_ptr", #TBD
- "TXNControlData_ptr", #TBD
- "TXNControlTag_ptr", #TBD
- "TXNLongRect", #TBD
- "TXNLongRect_ptr", #TBD
- "TXNTypeAttributes_ptr", #TBD
-
- "TXNActionKeyMapperProcPtr",
- "TXNActionKeyMapperUPP",
- "TXNTextBoxOptionsData",
- "TXNCountOptions",
- "void_ptr",
- ]
-
- def makerepairinstructions(self):
- return [
- # TXNNewObject has a lot of optional parameters
- ([("FSSpec_ptr", "iFileSpec", "InMode")],
- [("OptFSSpecPtr", "*", "*")]),
- ([("Rect", "iFrame", "OutMode")],
- [("OptRectPtr", "*", "InMode")]),
-
- # In UH 332 some of the "const" are missing for input parameters passed
- # by reference. We fix that up here.
- ([("EventRecord", "iEvent", "OutMode")],
- [("EventRecord_ptr", "*", "InMode")]),
- ([("FSSpec", "iFileSpecification", "OutMode")],
- [("FSSpec_ptr", "*", "InMode")]),
- ([("TXNMacOSPreferredFontDescription", "iFontDefaults", "OutMode")],
- [("TXNMacOSPreferredFontDescription_ptr", "*", "InMode")]),
-
- # In buffers are passed as void *
- ([("void", "*", "OutMode"), ("ByteCount", "*", "InMode")],
- [("MlteInBuffer", "*", "InMode")]),
-
- # The AdjustCursor region handle is optional
- ([("RgnHandle", "ioCursorRgn", "InMode")],
- [("OptRgnHandle", "*", "*")]),
-
- # The GWorld for TXNDraw is optional
- ([('GWorldPtr', 'iDrawPort', 'InMode')],
- [('OptGWorldPtr', '*', '*')]),
- ]
-
+ def makeblacklistnames(self):
+ return [
+ "TXNGetFontDefaults", # Arg is too difficult
+ "TXNSetFontDefaults", # Arg is too difficult
+ "TXNInitTextension", # done manually
+
+ # Constants with funny definitions
+ "kTXNClearThisControl",
+ "kTXNClearTheseFontFeatures",
+ "kTXNDontCareTypeSize",
+ "kTXNDecrementTypeSize",
+ "kTXNUseCurrentSelection",
+ "kTXNStartOffset",
+ "kTXNEndOffset",
+ "kTXNQDFontNameAttributeSize",
+ "kTXNQDFontFamilyIDAttributeSize",
+ "kTXNQDFontSizeAttributeSize",
+ "kTXNQDFontStyleAttributeSize",
+ "kTXNQDFontColorAttributeSize",
+ "kTXNTextEncodingAttributeSize",
+ "kTXNUseEncodingWordRulesMask",
+ "kTXNFontSizeAttributeSize",
+ "status",
+ "justification",
+ 'TXNTSMCheck', # OS8
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "TXNTab", # TBD
+ "TXNMargins", # TBD
+ "TXNControlData", #TBD
+ "TXNATSUIFeatures", #TBD
+ "TXNATSUIVariations", #TBD
+ "TXNAttributeData", #TBD
+ "TXNTypeAttributes", #TBD
+ "TXNMatchTextRecord", #TBD
+ "TXNBackground", #TBD
+ "TXNFindUPP",
+ "ATSUStyle", #TBD
+ "TXNBackground_ptr", #TBD
+ "TXNControlData_ptr", #TBD
+ "TXNControlTag_ptr", #TBD
+ "TXNLongRect", #TBD
+ "TXNLongRect_ptr", #TBD
+ "TXNTypeAttributes_ptr", #TBD
+
+ "TXNActionKeyMapperProcPtr",
+ "TXNActionKeyMapperUPP",
+ "TXNTextBoxOptionsData",
+ "TXNCountOptions",
+ "void_ptr",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ # TXNNewObject has a lot of optional parameters
+ ([("FSSpec_ptr", "iFileSpec", "InMode")],
+ [("OptFSSpecPtr", "*", "*")]),
+ ([("Rect", "iFrame", "OutMode")],
+ [("OptRectPtr", "*", "InMode")]),
+
+ # In UH 332 some of the "const" are missing for input parameters passed
+ # by reference. We fix that up here.
+ ([("EventRecord", "iEvent", "OutMode")],
+ [("EventRecord_ptr", "*", "InMode")]),
+ ([("FSSpec", "iFileSpecification", "OutMode")],
+ [("FSSpec_ptr", "*", "InMode")]),
+ ([("TXNMacOSPreferredFontDescription", "iFontDefaults", "OutMode")],
+ [("TXNMacOSPreferredFontDescription_ptr", "*", "InMode")]),
+
+ # In buffers are passed as void *
+ ([("void", "*", "OutMode"), ("ByteCount", "*", "InMode")],
+ [("MlteInBuffer", "*", "InMode")]),
+
+ # The AdjustCursor region handle is optional
+ ([("RgnHandle", "ioCursorRgn", "InMode")],
+ [("OptRgnHandle", "*", "*")]),
+
+ # The GWorld for TXNDraw is optional
+ ([('GWorldPtr', 'iDrawPort', 'InMode')],
+ [('OptGWorldPtr', '*', '*')]),
+ ]
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/mlte/mltesupport.py b/Mac/Modules/mlte/mltesupport.py
index 862d0bc..8dcbed5 100644
--- a/Mac/Modules/mlte/mltesupport.py
+++ b/Mac/Modules/mlte/mltesupport.py
@@ -8,12 +8,12 @@
import string
# Declarations that change for each manager
-MODNAME = '_Mlte' # The name of the module
+MODNAME = '_Mlte' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Mlte' # The prefix for module-wide routines
+MODPREFIX = 'Mlte' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -43,14 +43,14 @@ static int TXNFontMenuObj_Convert(PyObject *, TXNFontMenuObject *);
static int
OptFSSpecPtr_Convert(PyObject *v, FSSpec **p_itself)
{
- static FSSpec fss;
- if (v == Py_None)
- {
- *p_itself = NULL;
- return 1;
- }
- *p_itself = &fss;
- return PyMac_GetFSSpec(v, *p_itself);
+ static FSSpec fss;
+ if (v == Py_None)
+ {
+ *p_itself = NULL;
+ return 1;
+ }
+ *p_itself = &fss;
+ return PyMac_GetFSSpec(v, *p_itself);
}
/*
@@ -59,15 +59,15 @@ OptFSSpecPtr_Convert(PyObject *v, FSSpec **p_itself)
static int
OptRectPtr_Convert(PyObject *v, Rect **p_itself)
{
- static Rect r;
-
- if (v == Py_None)
- {
- *p_itself = NULL;
- return 1;
- }
- *p_itself = &r;
- return PyMac_GetRect(v, *p_itself);
+ static Rect r;
+
+ if (v == Py_None)
+ {
+ *p_itself = NULL;
+ return 1;
+ }
+ *p_itself = &r;
+ return PyMac_GetRect(v, *p_itself);
}
/*
@@ -75,19 +75,19 @@ OptRectPtr_Convert(PyObject *v, Rect **p_itself)
*/
static int
OptGWorldObj_Convert(PyObject *v, GWorldPtr *p_itself)
-{
- if (v == Py_None)
- {
- *p_itself = NULL;
- return 1;
- }
- return GWorldObj_Convert(v, p_itself);
+{
+ if (v == Py_None)
+ {
+ *p_itself = NULL;
+ return 1;
+ }
+ return GWorldObj_Convert(v, p_itself);
}
"""
initstuff = initstuff + """
-// PyMac_INIT_TOOLBOX_OBJECT_NEW(xxxx);
+// PyMac_INIT_TOOLBOX_OBJECT_NEW(xxxx);
"""
TXNObject = OpaqueByValueType("TXNObject", "TXNObj")
TXNFontMenuObject = OpaqueByValueType("TXNFontMenuObject", "TXNFontMenuObj")
@@ -133,12 +133,12 @@ execfile("mltetypetest.py")
# Our (opaque) objects
class TXNObjDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
class TXNFontMenuObjDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
# ADD object class here
@@ -183,7 +183,7 @@ ItemCount iCountDefaultFonts = 0;
TXNInitOptions iUsageFlags;
PyMac_PRECHECK(TXNInitTextension);
if (!PyArg_ParseTuple(_args, "l", &iUsageFlags))
- return NULL;
+ return NULL;
_err = TXNInitTextension(iDefaultFonts,
iCountDefaultFonts,
iUsageFlags);
@@ -200,4 +200,3 @@ module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/osa/osascan.py b/Mac/Modules/osa/osascan.py
index 75e1a08..fb8196f 100644
--- a/Mac/Modules/osa/osascan.py
+++ b/Mac/Modules/osa/osascan.py
@@ -10,53 +10,53 @@ 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! ==="
+ 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 [
- "OSALocalOrGlobal",
- "OSACreateAppleEventUPP",
- "OSAActiveUPP",
- "AEEventHandlerUPP",
- "OSASendUPP",
- ]
-
- def makerepairinstructions(self):
- return [
- ]
-
+ 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 [
+ "OSALocalOrGlobal",
+ "OSACreateAppleEventUPP",
+ "OSAActiveUPP",
+ "AEEventHandlerUPP",
+ "OSASendUPP",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ]
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/osa/osasupport.py b/Mac/Modules/osa/osasupport.py
index b0e7f4c..8369932 100644
--- a/Mac/Modules/osa/osasupport.py
+++ b/Mac/Modules/osa/osasupport.py
@@ -6,14 +6,14 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'OSA.h' # The Apple header file
-MODNAME = '_OSA' # The name of the module
+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
+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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -36,8 +36,8 @@ extern int _OSAObj_Convert(PyObject *, ComponentInstance *);
initstuff = initstuff + """
/*
- PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert);
*/
"""
@@ -63,24 +63,24 @@ 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;
- }""")
-
- def outputCheckConvertArg(self):
- Output("""
- if (CmpInstObj_Convert(v, p_itself))
- return 1;
- PyErr_Clear();
- """)
-
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ PyErr_SetString(OSA_Error,"NULL ComponentInstance");
+ return NULL;
+ }""")
+
+ def outputCheckConvertArg(self):
+ Output("""
+ if (CmpInstObj_Convert(v, p_itself))
+ return 1;
+ PyErr_Clear();
+ """)
+
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
object = MyObjectDefinition('OSAComponentInstance', OBJECTPREFIX,
- 'ComponentInstance')
+ 'ComponentInstance')
module.addobject(object)
# Create the generator classes used to populate the lists
@@ -103,4 +103,3 @@ for f in methods: object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/osa/setup.py b/Mac/Modules/osa/setup.py
index 82e7742..635114e 100644
--- a/Mac/Modules/osa/setup.py
+++ b/Mac/Modules/osa/setup.py
@@ -4,10 +4,10 @@
from distutils.core import Extension, setup
setup(name="OSA", version="0.1",
- ext_modules=[
- Extension('_OSA', ['_OSAmodule.c'],
- extra_link_args=['-framework', 'Carbon'])
- ],
- py_modules=['OSA.OSA', 'OSA.OSAconst'],
- package_dir={'OSA':'../../../Lib/plat-mac/Carbon'}
- )
+ ext_modules=[
+ Extension('_OSA', ['_OSAmodule.c'],
+ extra_link_args=['-framework', 'Carbon'])
+ ],
+ py_modules=['OSA.OSA', 'OSA.OSAconst'],
+ package_dir={'OSA':'../../../Lib/plat-mac/Carbon'}
+ )
diff --git a/Mac/Modules/qd/qdedit.py b/Mac/Modules/qd/qdedit.py
index d9e4a15..83d81ed 100644
--- a/Mac/Modules/qd/qdedit.py
+++ b/Mac/Modules/qd/qdedit.py
@@ -1,5 +1,5 @@
f = Function(void, 'SetPort',
- (GrafPtr, 'thePort', InMode),
+ (GrafPtr, 'thePort', InMode),
)
functions.append(f)
@@ -156,4 +156,3 @@ f = Function(void, 'DrawText',
(short, 'byteCount', InMode),
)
functions.append(f)
-
diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py
index f58bb22..85a8cdc 100644
--- a/Mac/Modules/qd/qdscan.py
+++ b/Mac/Modules/qd/qdscan.py
@@ -8,228 +8,228 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- input = "QuickDraw.h"
- output = "qdgen.py"
- defsoutput = TOOLBOXDIR + "QuickDraw.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
-
- # Grmpf. Universal Headers have Text-stuff in a different include file...
- input = "QuickDrawText.h"
- output = "@qdgentext.py"
- defsoutput = "@QuickDrawText.py"
- have_extra = 0
- try:
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- have_extra = 1
- except IOError:
- pass
- if have_extra:
- print "=== Copying QuickDrawText stuff into main files... ==="
- ifp = open("@qdgentext.py")
- ofp = open("qdgen.py", "a")
- ofp.write(ifp.read())
- ifp.close()
- ofp.close()
- ifp = open("@QuickDrawText.py")
- ofp = open(TOOLBOXDIR + "QuickDraw.py", "a")
- ofp.write(ifp.read())
- ifp.close()
- ofp.close()
-
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now importing the generated code... ==="
- import qdsupport
- print "=== Done. It's up to you to compile it now! ==="
+ input = "QuickDraw.h"
+ output = "qdgen.py"
+ defsoutput = TOOLBOXDIR + "QuickDraw.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+
+ # Grmpf. Universal Headers have Text-stuff in a different include file...
+ input = "QuickDrawText.h"
+ output = "@qdgentext.py"
+ defsoutput = "@QuickDrawText.py"
+ have_extra = 0
+ try:
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ have_extra = 1
+ except IOError:
+ pass
+ if have_extra:
+ print "=== Copying QuickDrawText stuff into main files... ==="
+ ifp = open("@qdgentext.py")
+ ofp = open("qdgen.py", "a")
+ ofp.write(ifp.read())
+ ifp.close()
+ ofp.close()
+ ifp = open("@QuickDrawText.py")
+ ofp = open(TOOLBOXDIR + "QuickDraw.py", "a")
+ ofp.write(ifp.read())
+ ifp.close()
+ ofp.close()
+
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now importing the generated code... ==="
+ import qdsupport
+ 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 in ('GrafPtr', 'CGrafPtr') and m == 'InMode':
- classname = "Method"
- listname = "gr_methods"
- elif t == 'BitMapPtr' and m == 'InMode':
- classname = "Method"
- listname = "bm_methods"
-## elif t == "PolyHandle" and m == "InMode":
-## classname = "Method"
-## listname = "p_methods"
-## elif t == "RgnHandle" and m == "InMode":
-## classname = "Method"
-## listname = "r_methods"
- return classname, listname
-
-
- def writeinitialdefs(self):
- self.defsfile.write("""
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in ('GrafPtr', 'CGrafPtr') and m == 'InMode':
+ classname = "Method"
+ listname = "gr_methods"
+ elif t == 'BitMapPtr' and m == 'InMode':
+ classname = "Method"
+ listname = "bm_methods"
+## elif t == "PolyHandle" and m == "InMode":
+## classname = "Method"
+## listname = "p_methods"
+## elif t == "RgnHandle" and m == "InMode":
+## classname = "Method"
+## listname = "r_methods"
+ return classname, listname
+
+
+ def writeinitialdefs(self):
+ self.defsfile.write("""
def FOUR_CHAR_CODE(x): return x
-normal = 0
-bold = 1
-italic = 2
-underline = 4
-outline = 8
-shadow = 0x10
-condense = 0x20
-extend = 0x40
+normal = 0
+bold = 1
+italic = 2
+underline = 4
+outline = 8
+shadow = 0x10
+condense = 0x20
+extend = 0x40
""")
- def makeblacklistnames(self):
- return [
- 'InitGraf',
- 'StuffHex',
- 'StdLine',
- 'StdComment',
- 'StdGetPic',
- 'OpenPort',
- 'InitPort',
- 'ClosePort',
- 'OpenCPort',
- 'InitCPort',
- 'CloseCPort',
- 'BitMapToRegionGlue',
- 'StdOpcode', # XXXX Missing from library...
- # The following are for non-macos use:
- 'LockPortBits',
- 'UnlockPortBits',
- 'UpdatePort',
- 'GetPortNativeWindow',
- 'GetNativeWindowPort',
- 'NativeRegionToMacRegion',
- 'MacRegionToNativeRegion',
- 'GetPortHWND',
- 'GetHWNDPort',
- 'GetPICTFromDIB',
-
- 'HandleToRgn', # Funny signature
-
- # Need Cm, which we don't want to drag in just yet
- 'OpenCursorComponent',
- 'CloseCursorComponent',
- 'SetCursorComponent',
- 'CursorComponentChanged',
- 'CursorComponentSetData',
- ]
-
- def makeblacklisttypes(self):
- return [
- "QDRegionBitsRef", # Should do this, but too lazy now.
- 'CIconHandle', # Obsolete
- 'CQDProcs',
- 'CQDProcsPtr',
- 'CSpecArray',
- 'ColorComplementProcPtr',
- 'ColorComplementUPP',
- 'ColorSearchProcPtr',
- 'ColorSearchUPP',
- 'ConstPatternParam',
- 'DeviceLoopDrawingProcPtr',
- 'DeviceLoopFlags',
- 'GrafVerb',
- 'OpenCPicParams_ptr',
- 'Ptr',
- 'QDProcs',
- 'ReqListRec',
- 'void_ptr',
- 'CustomXFerProcPtr',
- ]
-
- def makerepairinstructions(self):
- return [
- ([('void_ptr', 'textBuf', 'InMode'),
- ('short', 'firstByte', 'InMode'),
- ('short', 'byteCount', 'InMode')],
- [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
-
- # GetPen and SetPt use a point-pointer as output-only:
- ('GetPen', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
- ('SetPt', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
-
- # All others use it as input/output:
- ([('Point', '*', 'OutMode')],
- [('*', '*', 'InOutMode')]),
-
- # InsetRect, OffsetRect
- ([('Rect', 'r', 'OutMode'),
- ('short', 'dh', 'InMode'),
- ('short', 'dv', 'InMode')],
- [('Rect', 'r', 'InOutMode'),
- ('short', 'dh', 'InMode'),
- ('short', 'dv', 'InMode')]),
-
- # MapRect
- ([('Rect', 'r', 'OutMode'),
- ('Rect_ptr', 'srcRect', 'InMode'),
- ('Rect_ptr', 'dstRect', 'InMode')],
- [('Rect', 'r', 'InOutMode'),
- ('Rect_ptr', 'srcRect', 'InMode'),
- ('Rect_ptr', 'dstRect', 'InMode')]),
-
- # CopyBits and friends
- ([('RgnHandle', 'maskRgn', 'InMode')],
- [('OptRgnHandle', 'maskRgn', 'InMode')]),
-
- ('QDFlushPortBuffer',
- [('RgnHandle', '*', 'InMode')],
- [('OptRgnHandle', '*', 'InMode')]),
-
- # Accessors with reference argument also returned.
- ([('Rect_ptr', 'GetPortBounds', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('RGBColor_ptr', 'GetPortForeColor', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('RGBColor_ptr', 'GetPortBackColor', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('RGBColor_ptr', 'GetPortOpColor', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('RGBColor_ptr', 'GetPortHiliteColor', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Point_ptr', 'GetPortPenSize', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Point_ptr', 'GetPortPenLocation', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Rect_ptr', 'GetPixBounds', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('BitMap_ptr', 'GetQDGlobalsScreenBits', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Cursor_ptr', 'GetQDGlobalsArrow', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Rect_ptr', 'GetRegionBounds', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Pattern_ptr', '*', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Point_ptr', 'QDLocalToGlobalPoint', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Rect_ptr', 'QDLocalToGlobalRect', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Point_ptr', 'QDGlobalToLocalPoint', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Rect_ptr', 'QDGlobalToLocalRect', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ]
+ def makeblacklistnames(self):
+ return [
+ 'InitGraf',
+ 'StuffHex',
+ 'StdLine',
+ 'StdComment',
+ 'StdGetPic',
+ 'OpenPort',
+ 'InitPort',
+ 'ClosePort',
+ 'OpenCPort',
+ 'InitCPort',
+ 'CloseCPort',
+ 'BitMapToRegionGlue',
+ 'StdOpcode', # XXXX Missing from library...
+ # The following are for non-macos use:
+ 'LockPortBits',
+ 'UnlockPortBits',
+ 'UpdatePort',
+ 'GetPortNativeWindow',
+ 'GetNativeWindowPort',
+ 'NativeRegionToMacRegion',
+ 'MacRegionToNativeRegion',
+ 'GetPortHWND',
+ 'GetHWNDPort',
+ 'GetPICTFromDIB',
+
+ 'HandleToRgn', # Funny signature
+
+ # Need Cm, which we don't want to drag in just yet
+ 'OpenCursorComponent',
+ 'CloseCursorComponent',
+ 'SetCursorComponent',
+ 'CursorComponentChanged',
+ 'CursorComponentSetData',
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "QDRegionBitsRef", # Should do this, but too lazy now.
+ 'CIconHandle', # Obsolete
+ 'CQDProcs',
+ 'CQDProcsPtr',
+ 'CSpecArray',
+ 'ColorComplementProcPtr',
+ 'ColorComplementUPP',
+ 'ColorSearchProcPtr',
+ 'ColorSearchUPP',
+ 'ConstPatternParam',
+ 'DeviceLoopDrawingProcPtr',
+ 'DeviceLoopFlags',
+ 'GrafVerb',
+ 'OpenCPicParams_ptr',
+ 'Ptr',
+ 'QDProcs',
+ 'ReqListRec',
+ 'void_ptr',
+ 'CustomXFerProcPtr',
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([('void_ptr', 'textBuf', 'InMode'),
+ ('short', 'firstByte', 'InMode'),
+ ('short', 'byteCount', 'InMode')],
+ [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
+
+ # GetPen and SetPt use a point-pointer as output-only:
+ ('GetPen', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
+ ('SetPt', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
+
+ # All others use it as input/output:
+ ([('Point', '*', 'OutMode')],
+ [('*', '*', 'InOutMode')]),
+
+ # InsetRect, OffsetRect
+ ([('Rect', 'r', 'OutMode'),
+ ('short', 'dh', 'InMode'),
+ ('short', 'dv', 'InMode')],
+ [('Rect', 'r', 'InOutMode'),
+ ('short', 'dh', 'InMode'),
+ ('short', 'dv', 'InMode')]),
+
+ # MapRect
+ ([('Rect', 'r', 'OutMode'),
+ ('Rect_ptr', 'srcRect', 'InMode'),
+ ('Rect_ptr', 'dstRect', 'InMode')],
+ [('Rect', 'r', 'InOutMode'),
+ ('Rect_ptr', 'srcRect', 'InMode'),
+ ('Rect_ptr', 'dstRect', 'InMode')]),
+
+ # CopyBits and friends
+ ([('RgnHandle', 'maskRgn', 'InMode')],
+ [('OptRgnHandle', 'maskRgn', 'InMode')]),
+
+ ('QDFlushPortBuffer',
+ [('RgnHandle', '*', 'InMode')],
+ [('OptRgnHandle', '*', 'InMode')]),
+
+ # Accessors with reference argument also returned.
+ ([('Rect_ptr', 'GetPortBounds', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('RGBColor_ptr', 'GetPortForeColor', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('RGBColor_ptr', 'GetPortBackColor', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('RGBColor_ptr', 'GetPortOpColor', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('RGBColor_ptr', 'GetPortHiliteColor', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Point_ptr', 'GetPortPenSize', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Point_ptr', 'GetPortPenLocation', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Rect_ptr', 'GetPixBounds', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('BitMap_ptr', 'GetQDGlobalsScreenBits', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Cursor_ptr', 'GetQDGlobalsArrow', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Rect_ptr', 'GetRegionBounds', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Pattern_ptr', '*', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Point_ptr', 'QDLocalToGlobalPoint', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Rect_ptr', 'QDLocalToGlobalRect', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Point_ptr', 'QDGlobalToLocalPoint', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Rect_ptr', 'QDGlobalToLocalRect', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ]
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py
index e361c01..d078ac6 100644
--- a/Mac/Modules/qd/qdsupport.py
+++ b/Mac/Modules/qd/qdsupport.py
@@ -6,29 +6,29 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'QuickDraw.h' # The Apple header file
-MODNAME = '_Qd' # The name of the module
-OBJECTNAME = 'Graf' # The basic name of the objects used here
+MACHEADERFILE = 'QuickDraw.h' # The Apple header file
+MODNAME = '_Qd' # The name of the module
+OBJECTNAME = 'Graf' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Qd' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Qd' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
EXTRAFILE = string.lower(MODPREFIX) + 'edit.py' # A similar file but hand-made
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
# Create the type objects
class TextThingieClass(FixedInputBufferType):
- def getargsCheck(self, name):
- Output("/* Fool compiler warnings */")
- Output("%s__in_len__ = %s__in_len__;", name, name)
+ def getargsCheck(self, name):
+ Output("/* Fool compiler warnings */")
+ Output("%s__in_len__ = %s__in_len__;", name, name)
- def declareSize(self, name):
- Output("int %s__in_len__;", name)
+ def declareSize(self, name):
+ Output("int %s__in_len__;", name)
TextThingie = TextThingieClass(None)
@@ -92,19 +92,19 @@ static PyObject *BMObj_NewCopied(BitMapPtr);
PyObject *QdRGB_New(RGBColorPtr itself)
{
- return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue);
+ return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue);
}
int QdRGB_Convert(PyObject *v, RGBColorPtr p_itself)
{
- long red, green, blue;
-
- if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) )
- return 0;
- p_itself->red = (unsigned short)red;
- p_itself->green = (unsigned short)green;
- p_itself->blue = (unsigned short)blue;
- return 1;
+ long red, green, blue;
+
+ if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) )
+ return 0;
+ p_itself->red = (unsigned short)red;
+ p_itself->green = (unsigned short)green;
+ p_itself->blue = (unsigned short)blue;
+ return 1;
}
/*
@@ -114,8 +114,8 @@ static
PyObject *QdFI_New(FontInfo *itself)
{
- return Py_BuildValue("hhhh", itself->ascent, itself->descent,
- itself->widMax, itself->leading);
+ return Py_BuildValue("hhhh", itself->ascent, itself->descent,
+ itself->widMax, itself->leading);
}
"""
@@ -125,15 +125,15 @@ finalstuff = finalstuff + """
*/
PyObject *BMObj_NewCopied(BitMapPtr itself)
{
- BitMapObject *it;
- BitMapPtr itself_copy;
-
- if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL)
- return PyErr_NoMemory();
- *itself_copy = *itself;
- it = (BitMapObject *)BMObj_New(itself_copy);
- it->referred_bitmap = itself_copy;
- return (PyObject *)it;
+ BitMapObject *it;
+ BitMapPtr itself_copy;
+
+ if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL)
+ return PyErr_NoMemory();
+ *itself_copy = *itself;
+ it = (BitMapObject *)BMObj_New(itself_copy);
+ it->referred_bitmap = itself_copy;
+ return (PyObject *)it;
}
"""
@@ -141,112 +141,112 @@ PyObject *BMObj_NewCopied(BitMapPtr itself)
variablestuff = ""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert);
"""
## not yet...
##
##class Region_ObjectDefinition(GlobalObjectDefinition):
-## def outputCheckNewArg(self):
-## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-## def outputFreeIt(self, itselfname):
-## Output("DisposeRegion(%s);", itselfname)
+## def outputCheckNewArg(self):
+## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+## def outputFreeIt(self, itselfname):
+## Output("DisposeRegion(%s);", itselfname)
##
##class Polygon_ObjectDefinition(GlobalObjectDefinition):
-## def outputCheckNewArg(self):
-## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-## def outputFreeIt(self, itselfname):
-## Output("KillPoly(%s);", itselfname)
+## def outputCheckNewArg(self):
+## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+## def outputFreeIt(self, itselfname):
+## Output("KillPoly(%s);", itselfname)
class MyGRObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- getsetlist = [
- ('visRgn',
- """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
- return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h));
- """,
- None,
- "Convenience attribute: return a copy of the visible region"
- ), (
- 'clipRgn',
- """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
- return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h));
- """,
- None,
- "Convenience attribute: return a copy of the clipping region"
- )]
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- def outputCheckConvertArg(self):
- Output("#if 1")
- OutLbrace()
- Output("WindowRef win;")
- OutLbrace("if (WinObj_Convert(v, &win) && v)")
- Output("*p_itself = (GrafPtr)GetWindowPort(win);")
- Output("return 1;")
- OutRbrace()
- Output("PyErr_Clear();")
- OutRbrace()
- Output("#else")
- OutLbrace("if (DlgObj_Check(v))")
- Output("DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;")
- Output("*p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));")
- Output("return 1;")
- OutRbrace()
- OutLbrace("if (WinObj_Check(v))")
- Output("WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;")
- Output("*p_itself = (GrafPtr)GetWindowPort(win);")
- Output("return 1;")
- OutRbrace()
- Output("#endif")
+ getsetlist = [
+ ('visRgn',
+ """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
+ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h));
+ """,
+ None,
+ "Convenience attribute: return a copy of the visible region"
+ ), (
+ 'clipRgn',
+ """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
+ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h));
+ """,
+ None,
+ "Convenience attribute: return a copy of the clipping region"
+ )]
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputCheckConvertArg(self):
+ Output("#if 1")
+ OutLbrace()
+ Output("WindowRef win;")
+ OutLbrace("if (WinObj_Convert(v, &win) && v)")
+ Output("*p_itself = (GrafPtr)GetWindowPort(win);")
+ Output("return 1;")
+ OutRbrace()
+ Output("PyErr_Clear();")
+ OutRbrace()
+ Output("#else")
+ OutLbrace("if (DlgObj_Check(v))")
+ Output("DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;")
+ Output("*p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));")
+ Output("return 1;")
+ OutRbrace()
+ OutLbrace("if (WinObj_Check(v))")
+ Output("WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;")
+ Output("*p_itself = (GrafPtr)GetWindowPort(win);")
+ Output("return 1;")
+ OutRbrace()
+ Output("#endif")
class MyBMObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- getsetlist = [
- (
- 'baseAddr',
- 'return PyInt_FromLong((long)self->ob_itself->baseAddr);',
- None,
- None
- ), (
- 'rowBytes',
- 'return PyInt_FromLong((long)self->ob_itself->rowBytes);',
- None,
- None
- ), (
- 'bounds',
- 'return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);',
- None,
- None
- ), (
- 'bitmap_data',
- 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));',
- None,
- None
- ), (
- 'pixmap_data',
- 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));',
- None,
- None
- )]
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- def outputStructMembers(self):
- # We need to more items: a pointer to privately allocated data
- # and a python object we're referring to.
- Output("%s ob_itself;", self.itselftype)
- Output("PyObject *referred_object;")
- Output("BitMap *referred_bitmap;")
- def outputInitStructMembers(self):
- Output("it->ob_itself = %sitself;", self.argref)
- Output("it->referred_object = NULL;")
- Output("it->referred_bitmap = NULL;")
- def outputCleanupStructMembers(self):
- Output("Py_XDECREF(self->referred_object);")
- Output("if (self->referred_bitmap) free(self->referred_bitmap);")
+ getsetlist = [
+ (
+ 'baseAddr',
+ 'return PyInt_FromLong((long)self->ob_itself->baseAddr);',
+ None,
+ None
+ ), (
+ 'rowBytes',
+ 'return PyInt_FromLong((long)self->ob_itself->rowBytes);',
+ None,
+ None
+ ), (
+ 'bounds',
+ 'return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);',
+ None,
+ None
+ ), (
+ 'bitmap_data',
+ 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));',
+ None,
+ None
+ ), (
+ 'pixmap_data',
+ 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));',
+ None,
+ None
+ )]
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputStructMembers(self):
+ # We need to more items: a pointer to privately allocated data
+ # and a python object we're referring to.
+ Output("%s ob_itself;", self.itselftype)
+ Output("PyObject *referred_object;")
+ Output("BitMap *referred_bitmap;")
+ def outputInitStructMembers(self):
+ Output("it->ob_itself = %sitself;", self.argref)
+ Output("it->referred_object = NULL;")
+ Output("it->referred_bitmap = NULL;")
+ def outputCleanupStructMembers(self):
+ Output("Py_XDECREF(self->referred_object);")
+ Output("if (self->referred_bitmap) free(self->referred_bitmap);")
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff)
@@ -284,7 +284,7 @@ int from, length;
char *cp;
if ( !PyArg_ParseTuple(_args, "ii", &from, &length) )
- return NULL;
+ return NULL;
cp = _self->ob_itself->baseAddr+from;
_res = PyString_FromStringAndSize(cp, length);
return _res;
@@ -299,7 +299,7 @@ int from, length;
char *cp, *icp;
if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) )
- return NULL;
+ return NULL;
cp = _self->ob_itself->baseAddr+from;
memcpy(cp, icp, length);
Py_INCREF(Py_None);
@@ -321,24 +321,24 @@ int rowbytes;
char *data;
if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
- &bounds) )
- return NULL;
+ &bounds) )
+ return NULL;
data = PyString_AsString(source);
if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
- return PyErr_NoMemory();
+ return PyErr_NoMemory();
ptr->baseAddr = (Ptr)data;
ptr->rowBytes = rowbytes;
ptr->bounds = bounds;
if ( (_res = BMObj_New(ptr)) == NULL ) {
- free(ptr);
- return NULL;
+ free(ptr);
+ return NULL;
}
((BitMapObject *)_res)->referred_object = source;
Py_INCREF(source);
((BitMapObject *)_res)->referred_bitmap = ptr;
return _res;
"""
-
+
f = ManualGenerator("BitMap", BitMap_body)
f.docstring = lambda: """Take (string, int, Rect) argument and create BitMap"""
module.add(f)
@@ -351,22 +351,22 @@ BitMap *ptr;
PyObject *source;
if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
- return NULL;
+ return NULL;
if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
- PyErr_Format(PyExc_TypeError,
- "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)",
- PyString_Size(source), sizeof(BitMap), sizeof(PixMap));
- return NULL;
+ PyErr_Format(PyExc_TypeError,
+ "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)",
+ PyString_Size(source), sizeof(BitMap), sizeof(PixMap));
+ return NULL;
}
ptr = (BitMapPtr)PyString_AsString(source);
if ( (_res = BMObj_New(ptr)) == NULL ) {
- return NULL;
+ return NULL;
}
((BitMapObject *)_res)->referred_object = source;
Py_INCREF(source);
return _res;
"""
-
+
f = ManualGenerator("RawBitMap", RawBitMap_body)
f.docstring = lambda: """Take string BitMap and turn into BitMap object"""
module.add(f)
diff --git a/Mac/Modules/qdoffs/qdoffsscan.py b/Mac/Modules/qdoffs/qdoffsscan.py
index ae70707..d456e00 100644
--- a/Mac/Modules/qdoffs/qdoffsscan.py
+++ b/Mac/Modules/qdoffs/qdoffsscan.py
@@ -7,61 +7,60 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- input = "QDOffscreen.h"
- output = "qdoffsgen.py"
- defsoutput = TOOLBOXDIR + "QDOffscreen.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now importing the generated code... ==="
- import qdoffssupport
- print "=== Done. It's up to you to compile it now! ==="
+ input = "QDOffscreen.h"
+ output = "qdoffsgen.py"
+ defsoutput = TOOLBOXDIR + "QDOffscreen.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now importing the generated code... ==="
+ import qdoffssupport
+ 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 == "GWorldPtr" and m in ("InMode", "InOutMode"):
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t == "GWorldPtr" and m in ("InMode", "InOutMode"):
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- def makeblacklistnames(self):
- return [
- 'DisposeGWorld', # Implied when the object is deleted
- 'NewGWorldFromHBITMAP', # Don't know what the args do
- 'GetGDeviceAttributes', # Windows-only
- ]
+ def makeblacklistnames(self):
+ return [
+ 'DisposeGWorld', # Implied when the object is deleted
+ 'NewGWorldFromHBITMAP', # Don't know what the args do
+ 'GetGDeviceAttributes', # Windows-only
+ ]
- def makeblacklisttypes(self):
- return [
- "void_ptr", # GetGDeviceSurface, blacklisted for now
- "Ptr", # Again, for now (array is probably ok here)
- ]
+ def makeblacklisttypes(self):
+ return [
+ "void_ptr", # GetGDeviceSurface, blacklisted for now
+ "Ptr", # Again, for now (array is probably ok here)
+ ]
- def makerepairinstructions(self):
- return [
-
-## ("UpdateGWorld",
-## [("GWorldPtr", "*", "OutMode")],
-## [("*", "*", "InOutMode")]),
-
- # This one is incorrect: we say that all input gdevices are
- # optional, but some are not. Most are, however, so users passing
- # None for non-optional gdevices will get a qd error, I guess, in
- # stead of a python argument error.
- ([("GDHandle", "*", "InMode")],
- [("OptGDHandle", "*", "InMode")]),
- ]
+ def makerepairinstructions(self):
+ return [
-if __name__ == "__main__":
- main()
+## ("UpdateGWorld",
+## [("GWorldPtr", "*", "OutMode")],
+## [("*", "*", "InOutMode")]),
+
+ # This one is incorrect: we say that all input gdevices are
+ # optional, but some are not. Most are, however, so users passing
+ # None for non-optional gdevices will get a qd error, I guess, in
+ # stead of a python argument error.
+ ([("GDHandle", "*", "InMode")],
+ [("OptGDHandle", "*", "InMode")]),
+ ]
+if __name__ == "__main__":
+ main()
diff --git a/Mac/Modules/qdoffs/qdoffssupport.py b/Mac/Modules/qdoffs/qdoffssupport.py
index 1bd8f5a..1617773 100644
--- a/Mac/Modules/qdoffs/qdoffssupport.py
+++ b/Mac/Modules/qdoffs/qdoffssupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'QDOffscreen.h' # The Apple header file
-MODNAME = '_Qdoffs' # The name of the module
-OBJECTNAME = 'GWorld' # The basic name of the objects used here
+MACHEADERFILE = 'QDOffscreen.h' # The Apple header file
+MODNAME = '_Qdoffs' # The name of the module
+OBJECTNAME = 'GWorld' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Qdoffs' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
-OBJECTPREFIX = OBJECTNAME + 'Obj' # The prefix for object methods
+MODPREFIX = 'Qdoffs' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
+OBJECTPREFIX = OBJECTNAME + 'Obj' # The prefix for object methods
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
#EDITFILE = string.lower(MODPREFIX) + 'edit.py' # The manual definitions
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -49,28 +49,28 @@ extern int _GWorldObj_Convert(PyObject *, GWorldPtr *);
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);
"""
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- # XXXX Should inherit from GrafPtr?
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-## def outputInitStructMembers(self):
-## GlobalObjectDefinition.outputInitStructMembers(self)
-## Output("SetWRefCon(itself, (long)it);")
-## def outputCheckConvertArg(self):
-## OutLbrace("if (DlgObj_Check(v))")
-## Output("*p_itself = ((WindowObject *)v)->ob_itself;")
-## Output("return 1;")
-## OutRbrace()
-## Out("""
-## if (v == Py_None) { *p_itself = NULL; return 1; }
-## if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
-## """)
- def outputFreeIt(self, itselfname):
- Output("DisposeGWorld(%s);", itselfname)
+ # XXXX Should inherit from GrafPtr?
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+## def outputInitStructMembers(self):
+## GlobalObjectDefinition.outputInitStructMembers(self)
+## Output("SetWRefCon(itself, (long)it);")
+## def outputCheckConvertArg(self):
+## OutLbrace("if (DlgObj_Check(v))")
+## Output("*p_itself = ((WindowObject *)v)->ob_itself;")
+## Output("return 1;")
+## OutRbrace()
+## Out("""
+## if (v == Py_None) { *p_itself = NULL; return 1; }
+## if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
+## """)
+ def outputFreeIt(self, itselfname):
+ Output("DisposeGWorld(%s);", itselfname)
# From here on it's basically all boiler plate...
# Create the generator groups and link them
@@ -100,7 +100,7 @@ int from, length;
char *cp;
if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
- return NULL;
+ return NULL;
cp = GetPixBaseAddr(pm)+from;
_res = PyString_FromStringAndSize(cp, length);
return _res;
@@ -116,7 +116,7 @@ int from, length;
char *cp, *icp;
if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) )
- return NULL;
+ return NULL;
cp = GetPixBaseAddr(pm)+from;
memcpy(cp, icp, length);
Py_INCREF(Py_None);
diff --git a/Mac/Modules/qt/qtscan.py b/Mac/Modules/qt/qtscan.py
index b756bfe..a2dba15 100644
--- a/Mac/Modules/qt/qtscan.py
+++ b/Mac/Modules/qt/qtscan.py
@@ -9,311 +9,311 @@ from scantools import Scanner
LONG = "QuickTime"
SHORT = "qt"
HEADERFILES= (
-# "Components.h" -- In Carbon.Cm
- "Movies.h",
- "ImageCompression.h",
- "QuickTimeComponents.h",
-# "ImageCodec.h" -- seems not too useful, and difficult.
-# "IsochronousDataHandlers.h" -- Is this useful?
- "MediaHandlers.h",
-# "QTML.h", -- Windows only, needs separate module
-# "QuickTimeStreaming.h", -- Difficult
-# "QTStreamingComponents.h", -- Needs QTStreaming
- "QuickTimeMusic.h",
-# "QuickTimeVR.h", -- Not done yet
-# "Sound.h", -- In Carbon.Snd
- )
-OBJECTS = ("Movie", "Track", "Media", "UserData", "TimeBase", "MovieController",
- "IdleManager", "SGOutput")
+# "Components.h" -- In Carbon.Cm
+ "Movies.h",
+ "ImageCompression.h",
+ "QuickTimeComponents.h",
+# "ImageCodec.h" -- seems not too useful, and difficult.
+# "IsochronousDataHandlers.h" -- Is this useful?
+ "MediaHandlers.h",
+# "QTML.h", -- Windows only, needs separate module
+# "QuickTimeStreaming.h", -- Difficult
+# "QTStreamingComponents.h", -- Needs QTStreaming
+ "QuickTimeMusic.h",
+# "QuickTimeVR.h", -- Not done yet
+# "Sound.h", -- In Carbon.Snd
+ )
+OBJECTS = ("Movie", "Track", "Media", "UserData", "TimeBase", "MovieController",
+ "IdleManager", "SGOutput")
def main():
- input = HEADERFILES
- 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! ==="
+ input = HEADERFILES
+ 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 in OBJECTS and m == "InMode":
- classname = "Method"
- listname = t + "_methods"
- return classname, listname
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- self.defsfile.write("xmlIdentifierUnrecognized = -1\n")
- self.defsfile.write("kControllerMinimum = -0xf777\n")
- self.defsfile.write("notImplementedMusicOSErr = -2071\n")
- self.defsfile.write("cantSendToSynthesizerOSErr = -2072\n")
- self.defsfile.write("cantReceiveFromSynthesizerOSErr = -2073\n")
- self.defsfile.write("illegalVoiceAllocationOSErr = -2074\n")
- self.defsfile.write("illegalPartOSErr = -2075\n")
- self.defsfile.write("illegalChannelOSErr = -2076\n")
- self.defsfile.write("illegalKnobOSErr = -2077\n")
- self.defsfile.write("illegalKnobValueOSErr = -2078\n")
- self.defsfile.write("illegalInstrumentOSErr = -2079\n")
- self.defsfile.write("illegalControllerOSErr = -2080\n")
- self.defsfile.write("midiManagerAbsentOSErr = -2081\n")
- self.defsfile.write("synthesizerNotRespondingOSErr = -2082\n")
- self.defsfile.write("synthesizerOSErr = -2083\n")
- self.defsfile.write("illegalNoteChannelOSErr = -2084\n")
- self.defsfile.write("noteChannelNotAllocatedOSErr = -2085\n")
- self.defsfile.write("tunePlayerFullOSErr = -2086\n")
- self.defsfile.write("tuneParseOSErr = -2087\n")
-
- def makeblacklistnames(self):
- return [
- "xmlIdentifierUnrecognized", # const with incompatible definition
- "DisposeMovie", # Done on python-object disposal
- "DisposeMovieTrack", # ditto
- "DisposeTrackMedia", # ditto
- "DisposeUserData", # ditto
-# "DisposeTimeBase", # ditto
- "DisposeMovieController", # ditto
-
- # The following 4 use 'void *' in an uncontrolled way
- # TBD when I've read the manual...
- "GetUserDataItem",
- "SetUserDataItem",
- "SetTextSampleData",
- "BeginFullScreen",
- # bgen gets the argument in/out wrong..
- "AddTextSample",
- "AddTESample",
- "AddHiliteSample",
- "HiliteTextSample",
-
- "MakeTrackTimeTable", # Uses long * return?
- "MakeMediaTimeTable", # ditto
-## "VideoMediaGetStallCount", # Undefined in CW Pro 3 library
- # OS8 only:
- 'SpriteMediaGetIndImageProperty', # XXXX Why isn't this in carbon?
- 'CheckQuickTimeRegistration',
- 'SetMovieAnchorDataRef',
- 'GetMovieAnchorDataRef',
- 'GetMovieLoadState',
- 'OpenADataHandler',
- 'MovieMediaGetCurrentMovieProperty',
- 'MovieMediaGetCurrentTrackProperty',
- 'MovieMediaGetChildMovieDataReference',
- 'MovieMediaSetChildMovieDataReference',
- 'MovieMediaLoadChildMovieFromDataReference',
- 'Media3DGetViewObject',
-
- # these are ImageCompression blacklists
- "GraphicsExportGetInputPtr",
-
- # QuickTimeComponents
- # These two need some help: the first returns a point to a databuffer that
- # the second disposes. Generate manually?
- "VDCompressDone",
- "VDReleaseCompressBuffer",
- "QTVideoOutputGetGWorldParameters", # How useful is this?
-
- # MediaHandlers
- "MediaMakeMediaTimeTable", # just lazy
- "MediaGetSampleDataPointer", # funny output pointer
-
- # QuickTimeMusic
- "kControllerMinimum",
- # These are artefacts of a macro definition
- "ulen",
- "_ext",
- "x",
- "w1",
- "w2",
- ]
-
- def makeblacklisttypes(self):
- return [
- # I don't think we want to do these
- "QTSyncTaskPtr",
- # We dont do callbacks yet, so no need for these
- "QTCallBack",
- # Skipped for now, due to laziness
- "TrackEditState",
- "MovieEditState",
- "MatrixRecord",
- "MatrixRecord_ptr",
- "SampleReferencePtr",
- "QTTweener",
- "QTErrorReplacementPtr",
- "QTRestrictionSet",
- "QTUUID",
- "QTUUID_ptr",
-
- # Routine pointers, not yet.
- "MoviesErrorUPP",
- "MoviePreviewCallOutUPP",
- "MovieDrawingCompleteUPP",
- "QTCallBackUPP",
- "TextMediaUPP",
- "MovieProgressUPP",
- "MovieRgnCoverUPP",
- "MCActionFilterUPP",
- "MCActionFilterWithRefConUPP",
- "GetMovieUPP",
- "ModalFilterUPP",
- "TrackTransferUPP",
- "MoviePrePrerollCompleteUPP",
- "MovieExecuteWiredActionsUPP",
- "QTBandwidthNotificationUPP",
- "DoMCActionUPP",
- "QTNextTaskNeededSoonerCallbackUPP",
-
- "SampleReference64Ptr", # Don't know what this does, yet
- "QTRuntimeSpriteDescPtr",
- "QTBandwidthReference",
- "QTScheduledBandwidthReference",
- "QTAtomContainer",
- "SpriteWorld",
- "Sprite",
-
- # these are ImageCompression blacklists
- "ICMDataUPP",
- "ICMFlushUPP",
- "ICMCompletionUPP",
- "ICMProgressUPP",
- "StdPixUPP",
- "QDPixUPP",
- "ICMAlignmentUPP",
- "ICMCursorShieldedUPP",
- "ICMMemoryDisposedUPP",
- "ICMConvertDataFormatUPP",
- "ModalFilterYDUPP",
- "FileFilterUPP",
-
- "CodecNameSpecListPtr",
- "CodecInfo",
- "ImageSequence",
- "MatrixRecordPtr",
- "ICMDataProcRecordPtr",
- "OpenCPicParams",
- "ICMProgressProcRecordPtr",
- "ICMAlignmentProcRecordPtr",
- "ICMPixelFormatInfoPtr",
- "ImageSequenceDataSource",
- "ConstStrFileNameParam",
- "ImageTranscodeSequence",
- "ImageFieldSequence",
- "Fract",
- "PixMapPtr",
- "GWorldFlags",
- "void_ptr", # XXX Being lazy, this one is doable.
-
- # These are from QuickTimeComponents
- "CDataHandlerUPP",
- "CharDataHandlerUPP",
- "CommentHandlerUPP",
- "DataHCompletionUPP",
- "'MovieExportGetDataUPP",
- "MovieExportGetPropertyUPP",
- "PreprocessInstructionHandlerUPP",
- "SGModalFilterUPP",
- "StartDocumentHandlerUPP",
- "StartElementHandlerUPP",
- "VdigIntUPP",
- "SGDataUPP",
- "EndDocumentHandlerUPP",
- "EndElementHandlerUPP",
- "VideoBottles", # Record full of UPPs
-
- "SCParams",
- "ICMCompletionProcRecordPtr",
- "DataHVolumeList",
- "DigitizerInfo",
- "SGCompressInfo",
- "SeqGrabExtendedFrameInfoPtr",
- "SeqGrabFrameInfoPtr",
- "TCTextOptionsPtr",
- "SGCompressInfo_ptr",
- "SGDeviceList",
- "TextDisplayData",
- "TimeCodeDef",
- "TimeCodeRecord",
- "TweenRecord",
- "VDGamRecPtr",
- "ToneDescription", # XXXX Just lazy: this one is easy.
- "XMLDoc",
- "UInt64", # XXXX lazy
- "UInt64_ptr", # XXXX lazy
-
- # From MediaHandlers
- "ActionsUPP",
- "PrePrerollCompleteUPP",
- "CodecComponentHandle", # Difficult: handle containing list of components.
- "GetMovieCompleteParams", # Immense struct
- "LevelMeterInfoPtr", # Lazy. Also: can be an output parameter!!
- "MediaEQSpectrumBandsRecordPtr", # ditto
-
- # From QuickTimeMusic
- "MusicMIDISendUPP",
- "MusicOfflineDataUPP",
- "TuneCallBackUPP",
- "TunePlayCallBackUPP",
- "GCPart", # Struct with lots of fields
- "GCPart_ptr",
- "GenericKnobDescription", # Struct with lots of fields
- "KnobDescription", # Struct with lots of fields
- "InstrumentAboutInfo", # Struct, not too difficult
- "NoteChannel", # XXXX Lazy. Could be opaque, I think
- "NoteRequest", # XXXX Lazy. Not-too-difficult struct
- "SynthesizerConnections", # Struct with lots of fields
- "SynthesizerDescription", # Struct with lots of fields
- "TuneStatus", # Struct with lots of fields
-
- ]
-
- def makerepairinstructions(self):
- return [
- ([('FSSpec', '*', 'OutMode')], [('FSSpec_ptr', '*', 'InMode')]),
-
- # Movie controller creation
- ([('ComponentInstance', 'NewMovieController', 'ReturnMode')],
- [('MovieController', '*', 'ReturnMode')]),
-
- # NewMovieFromFile
- ([('short', 'resId', 'OutMode'), ('StringPtr', 'resName', 'InMode')],
- [('short', 'resId', 'InOutMode'), ('dummyStringPtr', 'resName', 'InMode')]),
-
- # MCDoAction and more
- ([('void', '*', 'OutMode')], [('mcactionparams', '*', 'InMode')]),
-
- # SetTimeBaseZero. Does not handle NULLs, unfortunately
- ([('TimeRecord', 'zero', 'OutMode')], [('TimeRecord', 'zero', 'InMode')]),
-
- # ConvertTime and ConvertTimeScale
- ([('TimeRecord', 'inout', 'OutMode')], [('TimeRecord', 'inout', 'InOutMode')]),
- ([('TimeRecord', 'theTime', 'OutMode')], [('TimeRecord', 'theTime', 'InOutMode')]),
-
- # AddTime and SubtractTime
- ([('TimeRecord', 'dst', 'OutMode')], [('TimeRecord', 'dst', 'InOutMode')]),
-
- # Funny definitions
- ([('char_ptr', '*', 'InMode')], [('stringptr', '*', 'InMode')]),
- ([('FSSpecPtr', '*', 'InMode')], [('FSSpec_ptr', '*', 'InMode')]),
- ([('unsigned_char', 'swfVersion', 'OutMode')], [('UInt8', 'swfVersion', 'OutMode')]),
-
- # It seems MusicMIDIPacket if never flagged with const but always used
- # for sending only. If that ever changes this needs to be fixed.
- ([('MusicMIDIPacket', '*', 'OutMode')], [('MusicMIDIPacket_ptr', '*', 'InMode')]),
-
- # QTMusic const-less input parameters
- ([('unsigned_long', 'header', 'OutMode')], [('UnsignedLongPtr', 'header', 'InMode')]),
- ]
-
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in OBJECTS and m == "InMode":
+ classname = "Method"
+ listname = t + "_methods"
+ return classname, listname
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("xmlIdentifierUnrecognized = -1\n")
+ self.defsfile.write("kControllerMinimum = -0xf777\n")
+ self.defsfile.write("notImplementedMusicOSErr = -2071\n")
+ self.defsfile.write("cantSendToSynthesizerOSErr = -2072\n")
+ self.defsfile.write("cantReceiveFromSynthesizerOSErr = -2073\n")
+ self.defsfile.write("illegalVoiceAllocationOSErr = -2074\n")
+ self.defsfile.write("illegalPartOSErr = -2075\n")
+ self.defsfile.write("illegalChannelOSErr = -2076\n")
+ self.defsfile.write("illegalKnobOSErr = -2077\n")
+ self.defsfile.write("illegalKnobValueOSErr = -2078\n")
+ self.defsfile.write("illegalInstrumentOSErr = -2079\n")
+ self.defsfile.write("illegalControllerOSErr = -2080\n")
+ self.defsfile.write("midiManagerAbsentOSErr = -2081\n")
+ self.defsfile.write("synthesizerNotRespondingOSErr = -2082\n")
+ self.defsfile.write("synthesizerOSErr = -2083\n")
+ self.defsfile.write("illegalNoteChannelOSErr = -2084\n")
+ self.defsfile.write("noteChannelNotAllocatedOSErr = -2085\n")
+ self.defsfile.write("tunePlayerFullOSErr = -2086\n")
+ self.defsfile.write("tuneParseOSErr = -2087\n")
+
+ def makeblacklistnames(self):
+ return [
+ "xmlIdentifierUnrecognized", # const with incompatible definition
+ "DisposeMovie", # Done on python-object disposal
+ "DisposeMovieTrack", # ditto
+ "DisposeTrackMedia", # ditto
+ "DisposeUserData", # ditto
+# "DisposeTimeBase", # ditto
+ "DisposeMovieController", # ditto
+
+ # The following 4 use 'void *' in an uncontrolled way
+ # TBD when I've read the manual...
+ "GetUserDataItem",
+ "SetUserDataItem",
+ "SetTextSampleData",
+ "BeginFullScreen",
+ # bgen gets the argument in/out wrong..
+ "AddTextSample",
+ "AddTESample",
+ "AddHiliteSample",
+ "HiliteTextSample",
+
+ "MakeTrackTimeTable", # Uses long * return?
+ "MakeMediaTimeTable", # ditto
+## "VideoMediaGetStallCount", # Undefined in CW Pro 3 library
+ # OS8 only:
+ 'SpriteMediaGetIndImageProperty', # XXXX Why isn't this in carbon?
+ 'CheckQuickTimeRegistration',
+ 'SetMovieAnchorDataRef',
+ 'GetMovieAnchorDataRef',
+ 'GetMovieLoadState',
+ 'OpenADataHandler',
+ 'MovieMediaGetCurrentMovieProperty',
+ 'MovieMediaGetCurrentTrackProperty',
+ 'MovieMediaGetChildMovieDataReference',
+ 'MovieMediaSetChildMovieDataReference',
+ 'MovieMediaLoadChildMovieFromDataReference',
+ 'Media3DGetViewObject',
+
+ # these are ImageCompression blacklists
+ "GraphicsExportGetInputPtr",
+
+ # QuickTimeComponents
+ # These two need some help: the first returns a point to a databuffer that
+ # the second disposes. Generate manually?
+ "VDCompressDone",
+ "VDReleaseCompressBuffer",
+ "QTVideoOutputGetGWorldParameters", # How useful is this?
+
+ # MediaHandlers
+ "MediaMakeMediaTimeTable", # just lazy
+ "MediaGetSampleDataPointer", # funny output pointer
+
+ # QuickTimeMusic
+ "kControllerMinimum",
+ # These are artefacts of a macro definition
+ "ulen",
+ "_ext",
+ "x",
+ "w1",
+ "w2",
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ # I don't think we want to do these
+ "QTSyncTaskPtr",
+ # We dont do callbacks yet, so no need for these
+ "QTCallBack",
+ # Skipped for now, due to laziness
+ "TrackEditState",
+ "MovieEditState",
+ "MatrixRecord",
+ "MatrixRecord_ptr",
+ "SampleReferencePtr",
+ "QTTweener",
+ "QTErrorReplacementPtr",
+ "QTRestrictionSet",
+ "QTUUID",
+ "QTUUID_ptr",
+
+ # Routine pointers, not yet.
+ "MoviesErrorUPP",
+ "MoviePreviewCallOutUPP",
+ "MovieDrawingCompleteUPP",
+ "QTCallBackUPP",
+ "TextMediaUPP",
+ "MovieProgressUPP",
+ "MovieRgnCoverUPP",
+ "MCActionFilterUPP",
+ "MCActionFilterWithRefConUPP",
+ "GetMovieUPP",
+ "ModalFilterUPP",
+ "TrackTransferUPP",
+ "MoviePrePrerollCompleteUPP",
+ "MovieExecuteWiredActionsUPP",
+ "QTBandwidthNotificationUPP",
+ "DoMCActionUPP",
+ "QTNextTaskNeededSoonerCallbackUPP",
+
+ "SampleReference64Ptr", # Don't know what this does, yet
+ "QTRuntimeSpriteDescPtr",
+ "QTBandwidthReference",
+ "QTScheduledBandwidthReference",
+ "QTAtomContainer",
+ "SpriteWorld",
+ "Sprite",
+
+ # these are ImageCompression blacklists
+ "ICMDataUPP",
+ "ICMFlushUPP",
+ "ICMCompletionUPP",
+ "ICMProgressUPP",
+ "StdPixUPP",
+ "QDPixUPP",
+ "ICMAlignmentUPP",
+ "ICMCursorShieldedUPP",
+ "ICMMemoryDisposedUPP",
+ "ICMConvertDataFormatUPP",
+ "ModalFilterYDUPP",
+ "FileFilterUPP",
+
+ "CodecNameSpecListPtr",
+ "CodecInfo",
+ "ImageSequence",
+ "MatrixRecordPtr",
+ "ICMDataProcRecordPtr",
+ "OpenCPicParams",
+ "ICMProgressProcRecordPtr",
+ "ICMAlignmentProcRecordPtr",
+ "ICMPixelFormatInfoPtr",
+ "ImageSequenceDataSource",
+ "ConstStrFileNameParam",
+ "ImageTranscodeSequence",
+ "ImageFieldSequence",
+ "Fract",
+ "PixMapPtr",
+ "GWorldFlags",
+ "void_ptr", # XXX Being lazy, this one is doable.
+
+ # These are from QuickTimeComponents
+ "CDataHandlerUPP",
+ "CharDataHandlerUPP",
+ "CommentHandlerUPP",
+ "DataHCompletionUPP",
+ "'MovieExportGetDataUPP",
+ "MovieExportGetPropertyUPP",
+ "PreprocessInstructionHandlerUPP",
+ "SGModalFilterUPP",
+ "StartDocumentHandlerUPP",
+ "StartElementHandlerUPP",
+ "VdigIntUPP",
+ "SGDataUPP",
+ "EndDocumentHandlerUPP",
+ "EndElementHandlerUPP",
+ "VideoBottles", # Record full of UPPs
+
+ "SCParams",
+ "ICMCompletionProcRecordPtr",
+ "DataHVolumeList",
+ "DigitizerInfo",
+ "SGCompressInfo",
+ "SeqGrabExtendedFrameInfoPtr",
+ "SeqGrabFrameInfoPtr",
+ "TCTextOptionsPtr",
+ "SGCompressInfo_ptr",
+ "SGDeviceList",
+ "TextDisplayData",
+ "TimeCodeDef",
+ "TimeCodeRecord",
+ "TweenRecord",
+ "VDGamRecPtr",
+ "ToneDescription", # XXXX Just lazy: this one is easy.
+ "XMLDoc",
+ "UInt64", # XXXX lazy
+ "UInt64_ptr", # XXXX lazy
+
+ # From MediaHandlers
+ "ActionsUPP",
+ "PrePrerollCompleteUPP",
+ "CodecComponentHandle", # Difficult: handle containing list of components.
+ "GetMovieCompleteParams", # Immense struct
+ "LevelMeterInfoPtr", # Lazy. Also: can be an output parameter!!
+ "MediaEQSpectrumBandsRecordPtr", # ditto
+
+ # From QuickTimeMusic
+ "MusicMIDISendUPP",
+ "MusicOfflineDataUPP",
+ "TuneCallBackUPP",
+ "TunePlayCallBackUPP",
+ "GCPart", # Struct with lots of fields
+ "GCPart_ptr",
+ "GenericKnobDescription", # Struct with lots of fields
+ "KnobDescription", # Struct with lots of fields
+ "InstrumentAboutInfo", # Struct, not too difficult
+ "NoteChannel", # XXXX Lazy. Could be opaque, I think
+ "NoteRequest", # XXXX Lazy. Not-too-difficult struct
+ "SynthesizerConnections", # Struct with lots of fields
+ "SynthesizerDescription", # Struct with lots of fields
+ "TuneStatus", # Struct with lots of fields
+
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([('FSSpec', '*', 'OutMode')], [('FSSpec_ptr', '*', 'InMode')]),
+
+ # Movie controller creation
+ ([('ComponentInstance', 'NewMovieController', 'ReturnMode')],
+ [('MovieController', '*', 'ReturnMode')]),
+
+ # NewMovieFromFile
+ ([('short', 'resId', 'OutMode'), ('StringPtr', 'resName', 'InMode')],
+ [('short', 'resId', 'InOutMode'), ('dummyStringPtr', 'resName', 'InMode')]),
+
+ # MCDoAction and more
+ ([('void', '*', 'OutMode')], [('mcactionparams', '*', 'InMode')]),
+
+ # SetTimeBaseZero. Does not handle NULLs, unfortunately
+ ([('TimeRecord', 'zero', 'OutMode')], [('TimeRecord', 'zero', 'InMode')]),
+
+ # ConvertTime and ConvertTimeScale
+ ([('TimeRecord', 'inout', 'OutMode')], [('TimeRecord', 'inout', 'InOutMode')]),
+ ([('TimeRecord', 'theTime', 'OutMode')], [('TimeRecord', 'theTime', 'InOutMode')]),
+
+ # AddTime and SubtractTime
+ ([('TimeRecord', 'dst', 'OutMode')], [('TimeRecord', 'dst', 'InOutMode')]),
+
+ # Funny definitions
+ ([('char_ptr', '*', 'InMode')], [('stringptr', '*', 'InMode')]),
+ ([('FSSpecPtr', '*', 'InMode')], [('FSSpec_ptr', '*', 'InMode')]),
+ ([('unsigned_char', 'swfVersion', 'OutMode')], [('UInt8', 'swfVersion', 'OutMode')]),
+
+ # It seems MusicMIDIPacket if never flagged with const but always used
+ # for sending only. If that ever changes this needs to be fixed.
+ ([('MusicMIDIPacket', '*', 'OutMode')], [('MusicMIDIPacket_ptr', '*', 'InMode')]),
+
+ # QTMusic const-less input parameters
+ ([('unsigned_long', 'header', 'OutMode')], [('UnsignedLongPtr', 'header', 'InMode')]),
+ ]
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/qt/qtsupport.py b/Mac/Modules/qt/qtsupport.py
index 20304c9..132c2b4 100644
--- a/Mac/Modules/qt/qtsupport.py
+++ b/Mac/Modules/qt/qtsupport.py
@@ -8,16 +8,16 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Movies.h' # The Apple header file
-MODNAME = '_Qt' # The name of the module
-OBJECTNAME = 'Movie' # The basic name of the objects used here
+MACHEADERFILE = 'Movies.h' # The Apple header file
+MODNAME = '_Qt' # The name of the module
+OBJECTNAME = 'Movie' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Qt' # The prefix for module-wide routines
-OBJECTTYPE = "Movie" # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Qt' # The prefix for module-wide routines
+OBJECTTYPE = "Movie" # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -57,45 +57,45 @@ extern int _MediaObj_Convert(PyObject *, Media *);
/* Macro to allow us to GetNextInterestingTime without duration */
#define GetMediaNextInterestingTimeOnly(media, flags, time, rate, rv) \
- GetMediaNextInterestingTime(media, flags, time, rate, rv, NULL)
-
+ GetMediaNextInterestingTime(media, flags, time, rate, rv, NULL)
+
/*
** Parse/generate time records
*/
static PyObject *
QtTimeRecord_New(TimeRecord *itself)
{
- if (itself->base)
- return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale,
- TimeBaseObj_New, itself->base);
- else
- return Py_BuildValue("O&lO", PyMac_Buildwide, &itself->value, itself->scale,
- Py_None);
+ if (itself->base)
+ return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale,
+ TimeBaseObj_New, itself->base);
+ else
+ return Py_BuildValue("O&lO", PyMac_Buildwide, &itself->value, itself->scale,
+ Py_None);
}
static int
QtTimeRecord_Convert(PyObject *v, TimeRecord *p_itself)
{
- PyObject *base = NULL;
- if( !PyArg_ParseTuple(v, "O&l|O", PyMac_Getwide, &p_itself->value, &p_itself->scale,
- &base) )
- return 0;
- if ( base == NULL || base == Py_None )
- p_itself->base = NULL;
- else
- if ( !TimeBaseObj_Convert(base, &p_itself->base) )
- return 0;
- return 1;
+ PyObject *base = NULL;
+ if( !PyArg_ParseTuple(v, "O&l|O", PyMac_Getwide, &p_itself->value, &p_itself->scale,
+ &base) )
+ return 0;
+ if ( base == NULL || base == Py_None )
+ p_itself->base = NULL;
+ else
+ if ( !TimeBaseObj_Convert(base, &p_itself->base) )
+ return 0;
+ return 1;
}
static int
QtMusicMIDIPacket_Convert(PyObject *v, MusicMIDIPacket *p_itself)
{
- int dummy;
-
- if( !PyArg_ParseTuple(v, "hls#", &p_itself->length, &p_itself->reserved, p_itself->data, dummy) )
- return 0;
- return 1;
+ int dummy;
+
+ if( !PyArg_ParseTuple(v, "hls#", &p_itself->length, &p_itself->reserved, p_itself->data, dummy) )
+ return 0;
+ return 1;
}
@@ -103,18 +103,18 @@ QtMusicMIDIPacket_Convert(PyObject *v, MusicMIDIPacket *p_itself)
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(Movie, MovieObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Movie, MovieObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(MovieController, MovieCtlObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MovieController, MovieCtlObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(TimeBase, TimeBaseObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TimeBase, TimeBaseObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(UserData, UserDataObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(UserData, UserDataObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(Media, MediaObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Media, MediaObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(Movie, MovieObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Movie, MovieObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(MovieController, MovieCtlObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MovieController, MovieCtlObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(TimeBase, TimeBaseObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TimeBase, TimeBaseObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(UserData, UserDataObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(UserData, UserDataObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(Media, MediaObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Media, MediaObj_Convert);
"""
# Our (opaque) objects
@@ -232,56 +232,56 @@ AtomicInstrumentPtr = InputOnlyType("AtomicInstrumentPtr", "s")
# XXXX Need to override output_tp_newBody() to allow for None initializer.
class QtGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- # We don't allow NULL pointers to be returned by QuickTime API calls,
- # in stead we raise an exception
- Output("""if (itself == NULL) {
- PyErr_SetString(Qt_Error,"Cannot create %s from NULL pointer");
- return NULL;
- }""", self.name)
-
- def outputCheckConvertArg(self):
- # But what we do allow is passing None whereever a quicktime object is
- # expected, and pass this as NULL to the API routines. Note you can
- # call methods too by creating an object with None as the initializer.
- Output("if (v == Py_None)")
- OutLbrace()
- Output("*p_itself = NULL;")
- Output("return 1;")
- OutRbrace()
-
+ def outputCheckNewArg(self):
+ # We don't allow NULL pointers to be returned by QuickTime API calls,
+ # in stead we raise an exception
+ Output("""if (itself == NULL) {
+ PyErr_SetString(Qt_Error,"Cannot create %s from NULL pointer");
+ return NULL;
+ }""", self.name)
+
+ def outputCheckConvertArg(self):
+ # But what we do allow is passing None whereever a quicktime object is
+ # expected, and pass this as NULL to the API routines. Note you can
+ # call methods too by creating an object with None as the initializer.
+ Output("if (v == Py_None)")
+ OutLbrace()
+ Output("*p_itself = NULL;")
+ Output("return 1;")
+ OutRbrace()
+
class MovieObjectDefinition(QtGlobalObjectDefinition):
- def outputFreeIt(self, itselfname):
- Output("if (%s) DisposeMovie(%s);", itselfname, itselfname)
+ def outputFreeIt(self, itselfname):
+ Output("if (%s) DisposeMovie(%s);", itselfname, itselfname)
class TrackObjectDefinition(QtGlobalObjectDefinition):
- def outputFreeIt(self, itselfname):
- Output("if (%s) DisposeMovieTrack(%s);", itselfname, itselfname)
+ def outputFreeIt(self, itselfname):
+ Output("if (%s) DisposeMovieTrack(%s);", itselfname, itselfname)
class MediaObjectDefinition(QtGlobalObjectDefinition):
- def outputFreeIt(self, itselfname):
- Output("if (%s) DisposeTrackMedia(%s);", itselfname, itselfname)
+ def outputFreeIt(self, itselfname):
+ Output("if (%s) DisposeTrackMedia(%s);", itselfname, itselfname)
class UserDataObjectDefinition(QtGlobalObjectDefinition):
- def outputFreeIt(self, itselfname):
- Output("if (%s) DisposeUserData(%s);", itselfname, itselfname)
+ def outputFreeIt(self, itselfname):
+ Output("if (%s) DisposeUserData(%s);", itselfname, itselfname)
class TimeBaseObjectDefinition(QtGlobalObjectDefinition):
- pass
-
+ pass
+
class MovieCtlObjectDefinition(QtGlobalObjectDefinition):
- def outputFreeIt(self, itselfname):
- Output("if (%s) DisposeMovieController(%s);", itselfname, itselfname)
+ def outputFreeIt(self, itselfname):
+ Output("if (%s) DisposeMovieController(%s);", itselfname, itselfname)
class IdleManagerObjectDefinition(QtGlobalObjectDefinition):
- pass
-
+ pass
+
class SGOutputObjectDefinition(QtGlobalObjectDefinition):
- # XXXX I'm not sure I fully understand how SGOutput works. It seems it's always tied
- # to a specific SeqGrabComponent, but I'm not 100% sure. Also, I'm not sure all the
- # routines that return an SGOutput actually return a *new* SGOutput. Need to read up on
- # this.
- pass
+ # XXXX I'm not sure I fully understand how SGOutput works. It seems it's always tied
+ # to a specific SeqGrabComponent, but I'm not 100% sure. Also, I'm not sure all the
+ # routines that return an SGOutput actually return a *new* SGOutput. Need to read up on
+ # this.
+ pass
# From here on it's basically all boiler plate...
@@ -331,19 +331,19 @@ ICMAlignmentProcRecordPtr = FakeType('(ICMAlignmentProcRecordPtr)0')
dummyRect = FakeType('(Rect *)0')
f = Function(void, 'AlignWindow',
- (WindowPtr, 'wp', InMode),
- (Boolean, 'front', InMode),
- (dummyRect, 'alignmentRect', InMode),
- (ICMAlignmentProcRecordPtr, 'alignmentProc', InMode),
+ (WindowPtr, 'wp', InMode),
+ (Boolean, 'front', InMode),
+ (dummyRect, 'alignmentRect', InMode),
+ (ICMAlignmentProcRecordPtr, 'alignmentProc', InMode),
)
functions.append(f)
f = Function(void, 'DragAlignedWindow',
- (WindowPtr, 'wp', InMode),
- (Point, 'startPt', InMode),
- (Rect_ptr, 'boundsRect', InMode),
- (dummyRect, 'alignmentRect', InMode),
- (ICMAlignmentProcRecordPtr, 'alignmentProc', InMode),
+ (WindowPtr, 'wp', InMode),
+ (Point, 'startPt', InMode),
+ (Rect_ptr, 'boundsRect', InMode),
+ (dummyRect, 'alignmentRect', InMode),
+ (ICMAlignmentProcRecordPtr, 'alignmentProc', InMode),
)
functions.append(f)
@@ -377,4 +377,3 @@ for f in Movie_methods: Movie_object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/qt/setup.py b/Mac/Modules/qt/setup.py
index 98d836d..8442011 100755
--- a/Mac/Modules/qt/setup.py
+++ b/Mac/Modules/qt/setup.py
@@ -4,10 +4,10 @@
from distutils.core import Extension, setup
setup(name="QuickTime", version="0.2",
- ext_modules=[
- Extension('QuickTime._Qt', ['_Qtmodule.c'],
- extra_link_args=['-framework', 'Carbon', '-framework', 'QuickTime'])
- ],
- py_modules=['QuickTime.Qt', 'QuickTime.QuickTime'],
- package_dir={'QuickTime':'../../../Lib/plat-mac/Carbon'}
- )
+ ext_modules=[
+ Extension('QuickTime._Qt', ['_Qtmodule.c'],
+ extra_link_args=['-framework', 'Carbon', '-framework', 'QuickTime'])
+ ],
+ py_modules=['QuickTime.Qt', 'QuickTime.QuickTime'],
+ package_dir={'QuickTime':'../../../Lib/plat-mac/Carbon'}
+ )
diff --git a/Mac/Modules/res/resedit.py b/Mac/Modules/res/resedit.py
index ab60b34..b3ef790 100644
--- a/Mac/Modules/res/resedit.py
+++ b/Mac/Modules/res/resedit.py
@@ -4,11 +4,11 @@
##Handle h;
##
##if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
-## return NULL;
+## return NULL;
##h = NewHandle(len);
##if ( h == NULL ) {
-## PyErr_NoMemory();
-## return NULL;
+## PyErr_NoMemory();
+## return NULL;
##}
##HLock(h);
##memcpy(*h, buf, len);
@@ -33,11 +33,11 @@ Handle h;
ResourceObject *rv;
if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
- return NULL;
+ return NULL;
h = NewHandle(len);
if ( h == NULL ) {
- PyErr_NoMemory();
- return NULL;
+ PyErr_NoMemory();
+ return NULL;
}
HLock(h);
memcpy(*h, buf, len);
@@ -66,10 +66,10 @@ return _res;
def genresconverter(longname, shortname):
- f = ManualGenerator("as_%s"%longname, as_xxx_body%(shortname, longname))
- docstring = "Return this resource/handle as a %s"%longname
- f.docstring = lambda docstring=docstring: docstring
- return f
+ f = ManualGenerator("as_%s"%longname, as_xxx_body%(shortname, longname))
+ docstring = "Return this resource/handle as a %s"%longname
+ f.docstring = lambda docstring=docstring: docstring
+ return f
resmethods.append(genresconverter("Control", "Ctl"))
resmethods.append(genresconverter("Menu", "Menu"))
@@ -87,13 +87,13 @@ resmethods.append(f)
AutoDispose_body = """
int onoff, old = 0;
if (!PyArg_ParseTuple(_args, "i", &onoff))
- return NULL;
+ return NULL;
if ( _self->ob_freeit )
- old = 1;
+ old = 1;
if ( onoff )
- _self->ob_freeit = PyMac_AutoDisposeHandle;
+ _self->ob_freeit = PyMac_AutoDisposeHandle;
else
- _self->ob_freeit = NULL;
+ _self->ob_freeit = NULL;
_res = Py_BuildValue("i", old);
return _res;
"""
diff --git a/Mac/Modules/res/resscan.py b/Mac/Modules/res/resscan.py
index 47a19a6..47a97e4 100644
--- a/Mac/Modules/res/resscan.py
+++ b/Mac/Modules/res/resscan.py
@@ -13,73 +13,73 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- input = "Resources.h"
- output = "resgen.py"
- defsoutput = TOOLBOXDIR + "Resources.py"
- scanner = ResourcesScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now doing 'import ressupport' ==="
- import ressupport
- print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
+ input = "Resources.h"
+ output = "resgen.py"
+ defsoutput = TOOLBOXDIR + "Resources.py"
+ scanner = ResourcesScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now doing 'import ressupport' ==="
+ import ressupport
+ print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
class ResourcesScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "ResFunction"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t == "Handle" and m == "InMode":
- classname = "ResMethod"
- listname = "resmethods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- "ReadPartialResource",
- "WritePartialResource",
- "TempInsertROMMap",
-## "RmveResource", # RemoveResource
-## "SizeResource", # GetResourceSizeOnDisk
-## "MaxSizeRsrc", # GetMaxResourceSize
- # OS8 only
- 'RGetResource',
- 'OpenResFile',
- 'CreateResFile',
- 'RsrcZoneInit',
- 'InitResources',
- 'RsrcMapEntry',
- ]
-
- def makeblacklisttypes(self):
- return [
- ]
-
- def makerepairinstructions(self):
- return [
- ([("Str255", "*", "InMode")],
- [("*", "*", "OutMode")]),
-
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode")],
- [("InOutBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode"),
- ("long", "*", "OutMode")],
- [("OutBuffer", "*", "InOutMode")]),
-
- ([("SInt8", "*", "*")],
- [("SignedByte", "*", "*")]),
-
-
- ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
- [("UnicodeReverseInBuffer", "*", "*")]),
- ]
+ def destination(self, type, name, arglist):
+ classname = "ResFunction"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t == "Handle" and m == "InMode":
+ classname = "ResMethod"
+ listname = "resmethods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ "ReadPartialResource",
+ "WritePartialResource",
+ "TempInsertROMMap",
+## "RmveResource", # RemoveResource
+## "SizeResource", # GetResourceSizeOnDisk
+## "MaxSizeRsrc", # GetMaxResourceSize
+ # OS8 only
+ 'RGetResource',
+ 'OpenResFile',
+ 'CreateResFile',
+ 'RsrcZoneInit',
+ 'InitResources',
+ 'RsrcMapEntry',
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("Str255", "*", "InMode")],
+ [("*", "*", "OutMode")]),
+
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode")],
+ [("InOutBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode"),
+ ("long", "*", "OutMode")],
+ [("OutBuffer", "*", "InOutMode")]),
+
+ ([("SInt8", "*", "*")],
+ [("SignedByte", "*", "*")]),
+
+
+ ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
+ [("UnicodeReverseInBuffer", "*", "*")]),
+ ]
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py
index 6135560..04a1821 100644
--- a/Mac/Modules/res/ressupport.py
+++ b/Mac/Modules/res/ressupport.py
@@ -7,13 +7,13 @@ from macsupport import *
class ResMixIn:
- def checkit(self):
- if self.returntype.__class__ != OSErrType:
- OutLbrace()
- Output("OSErr _err = ResError();")
- Output("if (_err != noErr) return PyMac_Error(_err);")
- OutRbrace()
- FunctionGenerator.checkit(self) # XXX
+ def checkit(self):
+ if self.returntype.__class__ != OSErrType:
+ OutLbrace()
+ Output("OSErr _err = ResError();")
+ Output("if (_err != noErr) return PyMac_Error(_err);")
+ OutRbrace()
+ FunctionGenerator.checkit(self) # XXX
class ResFunction(ResMixIn, OSErrWeakLinkFunctionGenerator): pass
class ResMethod(ResMixIn, OSErrWeakLinkMethodGenerator): pass
@@ -42,7 +42,7 @@ extern int _OptResObj_Convert(PyObject *, Handle *);
static void
PyMac_AutoDisposeHandle(Handle h)
{
- DisposeHandle(h);
+ DisposeHandle(h);
}
"""
@@ -51,159 +51,159 @@ finalstuff = finalstuff + """
/* Alternative version of ResObj_New, which returns None for null argument */
PyObject *OptResObj_New(Handle itself)
{
- if (itself == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- return ResObj_New(itself);
+ if (itself == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ return ResObj_New(itself);
}
int OptResObj_Convert(PyObject *v, Handle *p_itself)
{
- PyObject *tmp;
-
- if ( v == Py_None ) {
- *p_itself = NULL;
- return 1;
- }
- if (ResObj_Check(v))
- {
- *p_itself = ((ResourceObject *)v)->ob_itself;
- return 1;
- }
- /* If it isn't a resource yet see whether it is convertible */
- if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) {
- *p_itself = ((ResourceObject *)tmp)->ob_itself;
- Py_DECREF(tmp);
- return 1;
- }
- PyErr_Clear();
- PyErr_SetString(PyExc_TypeError, "Resource required");
- return 0;
+ PyObject *tmp;
+
+ if ( v == Py_None ) {
+ *p_itself = NULL;
+ return 1;
+ }
+ if (ResObj_Check(v))
+ {
+ *p_itself = ((ResourceObject *)v)->ob_itself;
+ return 1;
+ }
+ /* If it isn't a resource yet see whether it is convertible */
+ if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) {
+ *p_itself = ((ResourceObject *)tmp)->ob_itself;
+ Py_DECREF(tmp);
+ return 1;
+ }
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "Resource required");
+ return 0;
}
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, ResObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, ResObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, OptResObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, OptResObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, ResObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, ResObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, OptResObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, OptResObj_Convert);
"""
module = MacModule('_Res', 'Res', includestuff, finalstuff, initstuff)
class ResDefinition(PEP253Mixin, GlobalObjectDefinition):
- getsetlist = [
- ('data',
- """
- PyObject *res;
- char state;
-
- state = HGetState(self->ob_itself);
- HLock(self->ob_itself);
- res = PyString_FromStringAndSize(
- *self->ob_itself,
- GetHandleSize(self->ob_itself));
- HUnlock(self->ob_itself);
- HSetState(self->ob_itself, state);
- return res;
- """,
- """
- char *data;
- long size;
-
- if ( v == NULL )
- return -1;
- if ( !PyString_Check(v) )
- return -1;
- size = PyString_Size(v);
- data = PyString_AsString(v);
- /* XXXX Do I need the GetState/SetState calls? */
- SetHandleSize(self->ob_itself, size);
- if ( MemError())
- return -1;
- HLock(self->ob_itself);
- memcpy((char *)*self->ob_itself, data, size);
- HUnlock(self->ob_itself);
- /* XXXX Should I do the Changed call immedeately? */
- return 0;
- """,
- 'The resource data'
- ), (
- 'size',
- 'return PyInt_FromLong(GetHandleSize(self->ob_itself));',
- None,
- 'The length of the resource data'
- )]
-
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-
- def outputCheckConvertArg(self):
- # if it isn't a resource we may be able to coerce it
- Output("if (!%s_Check(v))", self.prefix)
- OutLbrace()
- Output("PyObject *tmp;")
- Output('if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) )')
- OutLbrace()
- Output("*p_itself = ((ResourceObject *)tmp)->ob_itself;")
- Output("Py_DECREF(tmp);")
- Output("return 1;")
- OutRbrace()
- Output("PyErr_Clear();")
- OutRbrace()
-
- def outputStructMembers(self):
- GlobalObjectDefinition.outputStructMembers(self)
- Output("void (*ob_freeit)(%s ptr);", self.itselftype)
-
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("it->ob_freeit = NULL;")
-
- def outputCleanupStructMembers(self):
- Output("if (self->ob_freeit && self->ob_itself)")
- OutLbrace()
- Output("self->ob_freeit(self->ob_itself);")
- OutRbrace()
- Output("self->ob_itself = NULL;")
-
- def output_tp_newBody(self):
- Output("PyObject *self;")
- Output
- Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
- Output("((%s *)self)->ob_itself = NULL;", self.objecttype)
- Output("((%s *)self)->ob_freeit = NULL;", self.objecttype)
- Output("return self;")
-
- def output_tp_initBody(self):
- Output("char *srcdata = NULL;")
- Output("int srclen = 0;")
- Output("%s itself;", self.itselftype);
- Output("char *kw[] = {\"itself\", 0};")
- Output()
- Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))",
- self.prefix);
- OutLbrace()
- Output("((%s *)self)->ob_itself = itself;", self.objecttype)
- Output("return 0;")
- OutRbrace()
- Output("PyErr_Clear();")
- Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|s#\", kw, &srcdata, &srclen)) return -1;")
- Output("if ((itself = NewHandle(srclen)) == NULL)")
- OutLbrace()
- Output("PyErr_NoMemory();")
- Output("return 0;")
- OutRbrace()
- Output("((%s *)self)->ob_itself = itself;", self.objecttype)
-# XXXX Output("((%s *)self)->ob_freeit = PyMac_AutoDisposeHandle;")
- Output("if (srclen && srcdata)")
- OutLbrace()
- Output("HLock(itself);")
- Output("memcpy(*itself, srcdata, srclen);")
- Output("HUnlock(itself);")
- OutRbrace()
- Output("return 0;")
+ getsetlist = [
+ ('data',
+ """
+ PyObject *res;
+ char state;
+
+ state = HGetState(self->ob_itself);
+ HLock(self->ob_itself);
+ res = PyString_FromStringAndSize(
+ *self->ob_itself,
+ GetHandleSize(self->ob_itself));
+ HUnlock(self->ob_itself);
+ HSetState(self->ob_itself, state);
+ return res;
+ """,
+ """
+ char *data;
+ long size;
+
+ if ( v == NULL )
+ return -1;
+ if ( !PyString_Check(v) )
+ return -1;
+ size = PyString_Size(v);
+ data = PyString_AsString(v);
+ /* XXXX Do I need the GetState/SetState calls? */
+ SetHandleSize(self->ob_itself, size);
+ if ( MemError())
+ return -1;
+ HLock(self->ob_itself);
+ memcpy((char *)*self->ob_itself, data, size);
+ HUnlock(self->ob_itself);
+ /* XXXX Should I do the Changed call immedeately? */
+ return 0;
+ """,
+ 'The resource data'
+ ), (
+ 'size',
+ 'return PyInt_FromLong(GetHandleSize(self->ob_itself));',
+ None,
+ 'The length of the resource data'
+ )]
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+
+ def outputCheckConvertArg(self):
+ # if it isn't a resource we may be able to coerce it
+ Output("if (!%s_Check(v))", self.prefix)
+ OutLbrace()
+ Output("PyObject *tmp;")
+ Output('if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) )')
+ OutLbrace()
+ Output("*p_itself = ((ResourceObject *)tmp)->ob_itself;")
+ Output("Py_DECREF(tmp);")
+ Output("return 1;")
+ OutRbrace()
+ Output("PyErr_Clear();")
+ OutRbrace()
+
+ def outputStructMembers(self):
+ GlobalObjectDefinition.outputStructMembers(self)
+ Output("void (*ob_freeit)(%s ptr);", self.itselftype)
+
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_freeit = NULL;")
+
+ def outputCleanupStructMembers(self):
+ Output("if (self->ob_freeit && self->ob_itself)")
+ OutLbrace()
+ Output("self->ob_freeit(self->ob_itself);")
+ OutRbrace()
+ Output("self->ob_itself = NULL;")
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;")
+ Output
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("((%s *)self)->ob_itself = NULL;", self.objecttype)
+ Output("((%s *)self)->ob_freeit = NULL;", self.objecttype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("char *srcdata = NULL;")
+ Output("int srclen = 0;")
+ Output("%s itself;", self.itselftype);
+ Output("char *kw[] = {\"itself\", 0};")
+ Output()
+ Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))",
+ self.prefix);
+ OutLbrace()
+ Output("((%s *)self)->ob_itself = itself;", self.objecttype)
+ Output("return 0;")
+ OutRbrace()
+ Output("PyErr_Clear();")
+ Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|s#\", kw, &srcdata, &srclen)) return -1;")
+ Output("if ((itself = NewHandle(srclen)) == NULL)")
+ OutLbrace()
+ Output("PyErr_NoMemory();")
+ Output("return 0;")
+ OutRbrace()
+ Output("((%s *)self)->ob_itself = itself;", self.objecttype)
+# XXXX Output("((%s *)self)->ob_freeit = PyMac_AutoDisposeHandle;")
+ Output("if (srclen && srcdata)")
+ OutLbrace()
+ Output("HLock(itself);")
+ Output("memcpy(*itself, srcdata, srclen);")
+ Output("HUnlock(itself);")
+ OutRbrace()
+ Output("return 0;")
resobject = ResDefinition('Resource', 'ResObj', 'Handle')
module.addobject(resobject)
diff --git a/Mac/Modules/scrap/scrapscan.py b/Mac/Modules/scrap/scrapscan.py
index 0b173a4..1fc8191 100644
--- a/Mac/Modules/scrap/scrapscan.py
+++ b/Mac/Modules/scrap/scrapscan.py
@@ -13,49 +13,49 @@ LONG = "Scrap"
SHORT = "scrap"
def main():
- input = "Scrap.h"
- output = SHORT + "gen.py"
- defsoutput = "@Scrap.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
-## 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! ==="
+ input = "Scrap.h"
+ output = SHORT + "gen.py"
+ defsoutput = "@Scrap.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+## 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 == 'ScrapRef' and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
-
- def makeblacklistnames(self):
- return [
- "GetScrapFlavorInfoList",
- 'InfoScrap',
- 'GetScrap',
- 'ZeroScrap',
- 'PutScrap',
- ]
-
- def makeblacklisttypes(self):
- return [
- 'ScrapPromiseKeeperUPP',
- ]
-
- def makerepairinstructions(self):
- return [
- ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
- ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
- ]
-
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t == 'ScrapRef' and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
+
+ def makeblacklistnames(self):
+ return [
+ "GetScrapFlavorInfoList",
+ 'InfoScrap',
+ 'GetScrap',
+ 'ZeroScrap',
+ 'PutScrap',
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ 'ScrapPromiseKeeperUPP',
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
+ ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
+ ]
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/scrap/scrapsupport.py b/Mac/Modules/scrap/scrapsupport.py
index 634a439..84a75d2 100644
--- a/Mac/Modules/scrap/scrapsupport.py
+++ b/Mac/Modules/scrap/scrapsupport.py
@@ -9,16 +9,16 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Scrap.h' # The Apple header file
-MODNAME = '_Scrap' # The name of the module
-OBJECTNAME = 'Scrap' # The basic name of the objects used here
+MACHEADERFILE = 'Scrap.h' # The Apple header file
+MODNAME = '_Scrap' # The name of the module
+OBJECTNAME = 'Scrap' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Scrap' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + 'Ref' # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Scrap' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + 'Ref' # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = '@' + MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -33,12 +33,12 @@ includestuff = includestuff + """
*/
static PyObject *
SCRRec_New(itself)
- ScrapStuff *itself;
+ ScrapStuff *itself;
{
- return Py_BuildValue("lO&hhO&", itself->scrapSize,
- ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState,
- PyMac_BuildStr255, itself->scrapName);
+ return Py_BuildValue("lO&hhO&", itself->scrapSize,
+ ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState,
+ PyMac_BuildStr255, itself->scrapName);
}
"""
@@ -49,7 +49,7 @@ ScrapFlavorFlags = Type('ScrapFlavorFlags', 'l')
putscrapbuffer = FixedInputBufferType('void *')
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- pass
+ pass
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
@@ -73,4 +73,3 @@ for f in methods: object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/snd/sndscan.py b/Mac/Modules/snd/sndscan.py
index a287c73..c4a8266 100644
--- a/Mac/Modules/snd/sndscan.py
+++ b/Mac/Modules/snd/sndscan.py
@@ -10,119 +10,119 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- input = "Sound.h"
- output = "sndgen.py"
- defsoutput = TOOLBOXDIR + "Sound.py"
- scanner = SoundScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now doing 'import sndsupport' ==="
- import sndsupport
- print "=== Done. It's up to you to compile Sndmodule.c ==="
+ input = "Sound.h"
+ output = "sndgen.py"
+ defsoutput = TOOLBOXDIR + "Sound.py"
+ scanner = SoundScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now doing 'import sndsupport' ==="
+ import sndsupport
+ print "=== Done. It's up to you to compile Sndmodule.c ==="
class SoundScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "SndFunction"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t == "SndChannelPtr" and m == "InMode":
- classname = "SndMethod"
- listname = "sndmethods"
- return classname, listname
-
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
-
- def makeblacklistnames(self):
- return [
- 'SndDisposeChannel', # automatic on deallocation
- 'SndAddModifier', # for internal use only
- 'SndPlayDoubleBuffer', # very low level routine
- # Missing from libraries (UH332)
- 'SoundManagerSetInfo',
- 'SoundManagerGetInfo',
- # Constants with funny definitions
- 'rate48khz',
- 'rate44khz',
- 'kInvalidSource',
- # OS8 only:
- 'MACEVersion',
- 'SPBRecordToFile',
- 'Exp1to6',
- 'Comp6to1',
- 'Exp1to3',
- 'Comp3to1',
- 'SndControl',
- 'SndStopFilePlay',
- 'SndStartFilePlay',
- 'SndPauseFilePlay',
- 'SndRecordToFile',
-
- ]
-
- def makeblacklisttypes(self):
- return [
- "GetSoundVol",
- "SetSoundVol",
- "UnsignedFixed",
- # Don't have the time to dig into this...
- "Component",
- "ComponentInstance",
- "SoundComponentDataPtr",
- "SoundComponentData",
- "SoundComponentData_ptr",
- "SoundConverter",
- ]
-
- def makerepairinstructions(self):
- return [
- ([("Str255", "*", "InMode")],
- [("*", "*", "OutMode")]),
-
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode"),
- ("long", "*", "OutMode")],
- [("VarVarOutBuffer", "*", "InOutMode")]),
-
- ([("SCStatusPtr", "*", "InMode")],
- [("SCStatus", "*", "OutMode")]),
-
- ([("SMStatusPtr", "*", "InMode")],
- [("SMStatus", "*", "OutMode")]),
-
- ([("CompressionInfoPtr", "*", "InMode")],
- [("CompressionInfo", "*", "OutMode")]),
-
- # For SndPlay's SndListHandle argument
- ([("Handle", "sndHdl", "InMode")],
- [("SndListHandle", "*", "*")]),
-
- # For SndStartFilePlay
- ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
- [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
-
- # For Comp3to1 etc.
- ([("void_ptr", "inBuffer", "InMode"),
- ("void", "outBuffer", "OutMode"),
- ("unsigned_long", "cnt", "InMode")],
- [("InOutBuffer", "buffer", "InOutMode")]),
-
- # Ditto
-## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
-## [("InOutBuf128", "state", "InOutMode")]),
- ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
- [("StateBlock", "state", "InOutMode")]),
-
- # Catch-all for the last couple of void pointers
- ([("void", "*", "OutMode")],
- [("void_ptr", "*", "InMode")]),
- ]
+ def destination(self, type, name, arglist):
+ classname = "SndFunction"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t == "SndChannelPtr" and m == "InMode":
+ classname = "SndMethod"
+ listname = "sndmethods"
+ return classname, listname
+
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+
+ def makeblacklistnames(self):
+ return [
+ 'SndDisposeChannel', # automatic on deallocation
+ 'SndAddModifier', # for internal use only
+ 'SndPlayDoubleBuffer', # very low level routine
+ # Missing from libraries (UH332)
+ 'SoundManagerSetInfo',
+ 'SoundManagerGetInfo',
+ # Constants with funny definitions
+ 'rate48khz',
+ 'rate44khz',
+ 'kInvalidSource',
+ # OS8 only:
+ 'MACEVersion',
+ 'SPBRecordToFile',
+ 'Exp1to6',
+ 'Comp6to1',
+ 'Exp1to3',
+ 'Comp3to1',
+ 'SndControl',
+ 'SndStopFilePlay',
+ 'SndStartFilePlay',
+ 'SndPauseFilePlay',
+ 'SndRecordToFile',
+
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "GetSoundVol",
+ "SetSoundVol",
+ "UnsignedFixed",
+ # Don't have the time to dig into this...
+ "Component",
+ "ComponentInstance",
+ "SoundComponentDataPtr",
+ "SoundComponentData",
+ "SoundComponentData_ptr",
+ "SoundConverter",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("Str255", "*", "InMode")],
+ [("*", "*", "OutMode")]),
+
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode"),
+ ("long", "*", "OutMode")],
+ [("VarVarOutBuffer", "*", "InOutMode")]),
+
+ ([("SCStatusPtr", "*", "InMode")],
+ [("SCStatus", "*", "OutMode")]),
+
+ ([("SMStatusPtr", "*", "InMode")],
+ [("SMStatus", "*", "OutMode")]),
+
+ ([("CompressionInfoPtr", "*", "InMode")],
+ [("CompressionInfo", "*", "OutMode")]),
+
+ # For SndPlay's SndListHandle argument
+ ([("Handle", "sndHdl", "InMode")],
+ [("SndListHandle", "*", "*")]),
+
+ # For SndStartFilePlay
+ ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
+ [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
+
+ # For Comp3to1 etc.
+ ([("void_ptr", "inBuffer", "InMode"),
+ ("void", "outBuffer", "OutMode"),
+ ("unsigned_long", "cnt", "InMode")],
+ [("InOutBuffer", "buffer", "InOutMode")]),
+
+ # Ditto
+## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
+## [("InOutBuf128", "state", "InOutMode")]),
+ ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
+ [("StateBlock", "state", "InOutMode")]),
+
+ # Catch-all for the last couple of void pointers
+ ([("void", "*", "OutMode")],
+ [("void_ptr", "*", "InMode")]),
+ ]
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/snd/sndsupport.py b/Mac/Modules/snd/sndsupport.py
index 99df5be..cf0fa6c 100644
--- a/Mac/Modules/snd/sndsupport.py
+++ b/Mac/Modules/snd/sndsupport.py
@@ -27,12 +27,12 @@ initstuff = initstuff + """
# define types used for arguments (in addition to standard and macsupport types)
class SndChannelPtrType(OpaqueByValueType):
- def declare(self, name):
- # Initializing all SndChannelPtr objects to 0 saves
- # special-casing NewSndChannel(), where it is formally an
- # input-output parameter but we treat it as output-only
- # (since Python users are not supposed to allocate memory)
- Output("SndChannelPtr %s = 0;", name)
+ def declare(self, name):
+ # Initializing all SndChannelPtr objects to 0 saves
+ # special-casing NewSndChannel(), where it is formally an
+ # input-output parameter but we treat it as output-only
+ # (since Python users are not supposed to allocate memory)
+ Output("SndChannelPtr %s = 0;", name)
SndChannelPtr = SndChannelPtrType('SndChannelPtr', 'SndCh')
@@ -49,28 +49,28 @@ ModalFilterUPP = FakeType("(ModalFilterUPP)0")
void_ptr = Type("void *", "w")
class SndCallBackType(InputOnlyType):
- def __init__(self):
- Type.__init__(self, 'PyObject*', 'O')
- def getargsCheck(self, name):
- Output("if (%s != Py_None && !PyCallable_Check(%s))", name, name)
- OutLbrace()
- Output('PyErr_SetString(PyExc_TypeError, "callback must be callable");')
- Output("goto %s__error__;", name)
- OutRbrace()
- def passInput(self, name):
- return "NewSndCallBackUPP(SndCh_UserRoutine)"
- def cleanup(self, name):
- # XXX This knows it is executing inside the SndNewChannel wrapper
- Output("if (_res != NULL && %s != Py_None)", name)
- OutLbrace()
- Output("SndChannelObject *p = (SndChannelObject *)_res;")
- Output("p->ob_itself->userInfo = (long)p;")
- Output("Py_INCREF(%s);", name)
- Output("p->ob_callback = %s;", name)
- OutRbrace()
- DedentLevel()
- Output(" %s__error__: ;", name)
- IndentLevel()
+ def __init__(self):
+ Type.__init__(self, 'PyObject*', 'O')
+ def getargsCheck(self, name):
+ Output("if (%s != Py_None && !PyCallable_Check(%s))", name, name)
+ OutLbrace()
+ Output('PyErr_SetString(PyExc_TypeError, "callback must be callable");')
+ Output("goto %s__error__;", name)
+ OutRbrace()
+ def passInput(self, name):
+ return "NewSndCallBackUPP(SndCh_UserRoutine)"
+ def cleanup(self, name):
+ # XXX This knows it is executing inside the SndNewChannel wrapper
+ Output("if (_res != NULL && %s != Py_None)", name)
+ OutLbrace()
+ Output("SndChannelObject *p = (SndChannelObject *)_res;")
+ Output("p->ob_itself->userInfo = (long)p;")
+ Output("Py_INCREF(%s);", name)
+ Output("p->ob_callback = %s;", name)
+ OutRbrace()
+ DedentLevel()
+ Output(" %s__error__: ;", name)
+ IndentLevel()
SndCallBackProcPtr = SndCallBackType()
SndCallBackUPP = SndCallBackProcPtr
@@ -95,16 +95,16 @@ includestuff = includestuff + """
static int
SndCmd_Convert(PyObject *v, SndCommand *pc)
{
- int len;
- pc->param1 = 0;
- pc->param2 = 0;
- if (PyTuple_Check(v)) {
- if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2))
- return 1;
- PyErr_Clear();
- return PyArg_ParseTuple(v, "Hhs#", &pc->cmd, &pc->param1, &pc->param2, &len);
- }
- return PyArg_Parse(v, "H", &pc->cmd);
+ int len;
+ pc->param1 = 0;
+ pc->param2 = 0;
+ if (PyTuple_Check(v)) {
+ if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2))
+ return 1;
+ PyErr_Clear();
+ return PyArg_ParseTuple(v, "Hhs#", &pc->cmd, &pc->param1, &pc->param2, &len);
+ }
+ return PyArg_Parse(v, "H", &pc->cmd);
}
static pascal void SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd); /* Forward */
@@ -117,62 +117,62 @@ finalstuff = finalstuff + """
static int
SndCh_CallCallBack(void *arg)
{
- SndChannelObject *p = (SndChannelObject *)arg;
- PyObject *args;
- PyObject *res;
- args = Py_BuildValue("(O(hhl))",
- p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2);
- res = PyEval_CallObject(p->ob_callback, args);
- Py_DECREF(args);
- if (res == NULL)
- return -1;
- Py_DECREF(res);
- return 0;
+ SndChannelObject *p = (SndChannelObject *)arg;
+ PyObject *args;
+ PyObject *res;
+ args = Py_BuildValue("(O(hhl))",
+ p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2);
+ res = PyEval_CallObject(p->ob_callback, args);
+ Py_DECREF(args);
+ if (res == NULL)
+ return -1;
+ Py_DECREF(res);
+ return 0;
}
/* Routine passed to NewSndChannel -- schedule a call to SndCh_CallCallBack */
static pascal void
SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd)
{
- SndChannelObject *p = (SndChannelObject *)(chan->userInfo);
- if (p->ob_callback != NULL) {
- long A5 = SetA5(p->ob_A5);
- p->ob_cmd = *cmd;
- Py_AddPendingCall(SndCh_CallCallBack, (void *)p);
- SetA5(A5);
- }
+ SndChannelObject *p = (SndChannelObject *)(chan->userInfo);
+ if (p->ob_callback != NULL) {
+ long A5 = SetA5(p->ob_A5);
+ p->ob_cmd = *cmd;
+ Py_AddPendingCall(SndCh_CallCallBack, (void *)p);
+ SetA5(A5);
+ }
}
/* SPB callbacks - Schedule callbacks to Python */
static int
SPB_CallCallBack(void *arg)
{
- SPBObject *p = (SPBObject *)arg;
- PyObject *args;
- PyObject *res;
-
- if ( p->ob_thiscallback == 0 ) return 0;
- args = Py_BuildValue("(O)", p);
- res = PyEval_CallObject(p->ob_thiscallback, args);
- p->ob_thiscallback = 0;
- Py_DECREF(args);
- if (res == NULL)
- return -1;
- Py_DECREF(res);
- return 0;
+ SPBObject *p = (SPBObject *)arg;
+ PyObject *args;
+ PyObject *res;
+
+ if ( p->ob_thiscallback == 0 ) return 0;
+ args = Py_BuildValue("(O)", p);
+ res = PyEval_CallObject(p->ob_thiscallback, args);
+ p->ob_thiscallback = 0;
+ Py_DECREF(args);
+ if (res == NULL)
+ return -1;
+ Py_DECREF(res);
+ return 0;
}
static pascal void
SPB_completion(SPBPtr my_spb)
{
- SPBObject *p = (SPBObject *)(my_spb->userLong);
-
- if (p && p->ob_completion) {
- long A5 = SetA5(p->ob_A5);
- p->ob_thiscallback = p->ob_completion; /* Hope we cannot get two at the same time */
- Py_AddPendingCall(SPB_CallCallBack, (void *)p);
- SetA5(A5);
- }
+ SPBObject *p = (SPBObject *)(my_spb->userLong);
+
+ if (p && p->ob_completion) {
+ long A5 = SetA5(p->ob_A5);
+ p->ob_thiscallback = p->ob_completion; /* Hope we cannot get two at the same time */
+ Py_AddPendingCall(SPB_CallCallBack, (void *)p);
+ SetA5(A5);
+ }
}
"""
@@ -182,110 +182,110 @@ SPB_completion(SPBPtr my_spb)
class SndObjectDefinition(PEP252Mixin, ObjectDefinition):
- def outputStructMembers(self):
- ObjectDefinition.outputStructMembers(self)
- Output("/* Members used to implement callbacks: */")
- Output("PyObject *ob_callback;")
- Output("long ob_A5;");
- Output("SndCommand ob_cmd;")
-
- def outputInitStructMembers(self):
- ObjectDefinition.outputInitStructMembers(self)
- Output("it->ob_callback = NULL;")
- Output("it->ob_A5 = SetCurrentA5();");
-
- def outputCleanupStructMembers(self):
- ObjectDefinition.outputCleanupStructMembers(self)
- Output("Py_XDECREF(self->ob_callback);")
-
- def outputFreeIt(self, itselfname):
- Output("SndDisposeChannel(%s, 1);", itselfname)
-
- def outputConvert(self):
- pass # Not needed
-
+ def outputStructMembers(self):
+ ObjectDefinition.outputStructMembers(self)
+ Output("/* Members used to implement callbacks: */")
+ Output("PyObject *ob_callback;")
+ Output("long ob_A5;");
+ Output("SndCommand ob_cmd;")
+
+ def outputInitStructMembers(self):
+ ObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_callback = NULL;")
+ Output("it->ob_A5 = SetCurrentA5();");
+
+ def outputCleanupStructMembers(self):
+ ObjectDefinition.outputCleanupStructMembers(self)
+ Output("Py_XDECREF(self->ob_callback);")
+
+ def outputFreeIt(self, itselfname):
+ Output("SndDisposeChannel(%s, 1);", itselfname)
+
+ def outputConvert(self):
+ pass # Not needed
+
#
class SpbObjectDefinition(PEP252Mixin, ObjectDefinition):
- getsetlist = [
- (
- 'inRefNum',
- 'return Py_BuildValue("l", self->ob_spb.inRefNum);',
- 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum);',
- None,
- ), (
- 'count',
- 'return Py_BuildValue("l", self->ob_spb.count);',
- 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.count);',
- None
- ), (
- 'milliseconds',
- 'return Py_BuildValue("l", self->ob_spb.milliseconds);',
- 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds);',
- None,
- ), (
- 'error',
- 'return Py_BuildValue("h", self->ob_spb.error);',
- None,
- None
- ), (
- 'completionRoutine',
- None,
- """self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
- self->ob_completion = v;
- Py_INCREF(v);
- return 0;""",
- None,
- )]
-
- def outputStructMembers(self):
- Output("/* Members used to implement callbacks: */")
- Output("PyObject *ob_completion;")
- Output("PyObject *ob_interrupt;")
- Output("PyObject *ob_thiscallback;");
- Output("long ob_A5;")
- Output("SPB ob_spb;")
-
- def outputNew(self):
- Output()
- Output("%sPyObject *%s_New(void)", self.static, self.prefix)
- OutLbrace()
- Output("%s *it;", self.objecttype)
- self.outputCheckNewArg()
- Output("it = PyObject_NEW(%s, &%s);", self.objecttype, self.typename)
- Output("if (it == NULL) return NULL;")
- self.outputInitStructMembers()
- Output("return (PyObject *)it;")
- OutRbrace()
-
- def outputInitStructMembers(self):
- Output("it->ob_completion = NULL;")
- Output("it->ob_interrupt = NULL;")
- Output("it->ob_thiscallback = NULL;")
- Output("it->ob_A5 = SetCurrentA5();")
- Output("memset((char *)&it->ob_spb, 0, sizeof(it->ob_spb));")
- Output("it->ob_spb.userLong = (long)it;")
-
- def outputCleanupStructMembers(self):
- ObjectDefinition.outputCleanupStructMembers(self)
- Output("self->ob_spb.userLong = 0;")
- Output("self->ob_thiscallback = 0;")
- Output("Py_XDECREF(self->ob_completion);")
- Output("Py_XDECREF(self->ob_interrupt);")
-
- def outputConvert(self):
- Output("%sint %s_Convert(PyObject *v, %s *p_itself)", self.static, self.prefix, self.itselftype)
- OutLbrace()
- self.outputCheckConvertArg()
- Output("if (!%s_Check(v))", self.prefix)
- OutLbrace()
- Output('PyErr_SetString(PyExc_TypeError, "%s required");', self.name)
- Output("return 0;")
- OutRbrace()
- Output("*p_itself = &((%s *)v)->ob_spb;", self.objecttype)
- Output("return 1;")
- OutRbrace()
-
+ getsetlist = [
+ (
+ 'inRefNum',
+ 'return Py_BuildValue("l", self->ob_spb.inRefNum);',
+ 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum);',
+ None,
+ ), (
+ 'count',
+ 'return Py_BuildValue("l", self->ob_spb.count);',
+ 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.count);',
+ None
+ ), (
+ 'milliseconds',
+ 'return Py_BuildValue("l", self->ob_spb.milliseconds);',
+ 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds);',
+ None,
+ ), (
+ 'error',
+ 'return Py_BuildValue("h", self->ob_spb.error);',
+ None,
+ None
+ ), (
+ 'completionRoutine',
+ None,
+ """self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
+ self->ob_completion = v;
+ Py_INCREF(v);
+ return 0;""",
+ None,
+ )]
+
+ def outputStructMembers(self):
+ Output("/* Members used to implement callbacks: */")
+ Output("PyObject *ob_completion;")
+ Output("PyObject *ob_interrupt;")
+ Output("PyObject *ob_thiscallback;");
+ Output("long ob_A5;")
+ Output("SPB ob_spb;")
+
+ def outputNew(self):
+ Output()
+ Output("%sPyObject *%s_New(void)", self.static, self.prefix)
+ OutLbrace()
+ Output("%s *it;", self.objecttype)
+ self.outputCheckNewArg()
+ Output("it = PyObject_NEW(%s, &%s);", self.objecttype, self.typename)
+ Output("if (it == NULL) return NULL;")
+ self.outputInitStructMembers()
+ Output("return (PyObject *)it;")
+ OutRbrace()
+
+ def outputInitStructMembers(self):
+ Output("it->ob_completion = NULL;")
+ Output("it->ob_interrupt = NULL;")
+ Output("it->ob_thiscallback = NULL;")
+ Output("it->ob_A5 = SetCurrentA5();")
+ Output("memset((char *)&it->ob_spb, 0, sizeof(it->ob_spb));")
+ Output("it->ob_spb.userLong = (long)it;")
+
+ def outputCleanupStructMembers(self):
+ ObjectDefinition.outputCleanupStructMembers(self)
+ Output("self->ob_spb.userLong = 0;")
+ Output("self->ob_thiscallback = 0;")
+ Output("Py_XDECREF(self->ob_completion);")
+ Output("Py_XDECREF(self->ob_interrupt);")
+
+ def outputConvert(self):
+ Output("%sint %s_Convert(PyObject *v, %s *p_itself)", self.static, self.prefix, self.itselftype)
+ OutLbrace()
+ self.outputCheckConvertArg()
+ Output("if (!%s_Check(v))", self.prefix)
+ OutLbrace()
+ Output('PyErr_SetString(PyExc_TypeError, "%s required");', self.name)
+ Output("return 0;")
+ OutRbrace()
+ Output("*p_itself = &((%s *)v)->ob_spb;", self.objecttype)
+ Output("return 1;")
+ OutRbrace()
+
sndobject = SndObjectDefinition('SndChannel', 'SndCh', 'SndChannelPtr')
spbobject = SpbObjectDefinition('SPB', 'SPBObj', 'SPBPtr')
diff --git a/Mac/Modules/te/tescan.py b/Mac/Modules/te/tescan.py
index c81a8bf..f5b6fff 100644
--- a/Mac/Modules/te/tescan.py
+++ b/Mac/Modules/te/tescan.py
@@ -11,57 +11,57 @@ SHORT = "te"
OBJECT = "TEHandle"
def main():
- input = LONG + ".h"
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- 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! ==="
+ input = LONG + ".h"
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ 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[-1]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[-1]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
- def makeblacklistnames(self):
- return [
- "TEDispose",
- "TEInit",
-## "TEGetHiliteRgn",
- ]
+ def makeblacklistnames(self):
+ return [
+ "TEDispose",
+ "TEInit",
+## "TEGetHiliteRgn",
+ ]
- def makeblacklisttypes(self):
- return [
- "TEClickLoopUPP",
- "UniversalProcPtr",
- "WordBreakUPP",
- "TEDoTextUPP",
- "TERecalcUPP",
- "TEFindWordUPP",
- ]
+ def makeblacklisttypes(self):
+ return [
+ "TEClickLoopUPP",
+ "UniversalProcPtr",
+ "WordBreakUPP",
+ "TEDoTextUPP",
+ "TERecalcUPP",
+ "TEFindWordUPP",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ # TEContinuousStyle
+ ([("short", "mode", "OutMode"), ("TextStyle", "aStyle", "OutMode")],
+ [("short", "mode", "InOutMode"), ("TextStyle", "aStyle", "InOutMode")])
+ ]
- def makerepairinstructions(self):
- return [
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- # TEContinuousStyle
- ([("short", "mode", "OutMode"), ("TextStyle", "aStyle", "OutMode")],
- [("short", "mode", "InOutMode"), ("TextStyle", "aStyle", "InOutMode")])
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/te/tesupport.py b/Mac/Modules/te/tesupport.py
index 13f1b97..ad6c053 100644
--- a/Mac/Modules/te/tesupport.py
+++ b/Mac/Modules/te/tesupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'TextEdit.h' # The Apple header file
-MODNAME = '_TE' # The name of the module
-OBJECTNAME = 'TE' # The basic name of the objects used here
-KIND = 'Handle' # Usually 'Ptr' or 'Handle'
+MACHEADERFILE = 'TextEdit.h' # The Apple header file
+MODNAME = '_TE' # The name of the module
+OBJECTNAME = 'TE' # The basic name of the objects used here
+KIND = 'Handle' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'TE' # The prefix for module-wide routines
-OBJECTTYPE = "TEHandle" # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'TE' # The prefix for module-wide routines
+OBJECTTYPE = "TEHandle" # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # 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
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -52,137 +52,137 @@ static PyObject *
TextStyle_New(TextStylePtr itself)
{
- return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
- &itself->tsColor);
+ return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
+ &itself->tsColor);
}
static int
TextStyle_Convert(PyObject *v, TextStylePtr p_itself)
{
- long font, face, size;
-
- if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
- return 0;
- p_itself->tsFont = (short)font;
- p_itself->tsFace = (Style)face;
- p_itself->tsSize = (short)size;
- return 1;
+ long font, face, size;
+
+ if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
+ return 0;
+ p_itself->tsFont = (short)font;
+ p_itself->tsFace = (Style)face;
+ p_itself->tsSize = (short)size;
+ return 1;
}
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle, TEObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle, TEObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle, TEObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle, TEObj_Convert);
"""
class TEMethodGenerator(OSErrWeakLinkMethodGenerator):
- """Similar to MethodGenerator, but has self as last argument"""
+ """Similar to MethodGenerator, but has self as last argument"""
- def parseArgumentList(self, args):
- args, a0 = args[:-1], args[-1]
- t0, n0, m0 = a0
- if m0 != InMode:
- raise ValueError, "method's 'self' must be 'InMode'"
- self.itself = Variable(t0, "_self->ob_itself", SelfMode)
- FunctionGenerator.parseArgumentList(self, args)
- self.argumentList.append(self.itself)
+ def parseArgumentList(self, args):
+ args, a0 = args[:-1], args[-1]
+ t0, n0, m0 = a0
+ if m0 != InMode:
+ raise ValueError, "method's 'self' must be 'InMode'"
+ self.itself = Variable(t0, "_self->ob_itself", SelfMode)
+ FunctionGenerator.parseArgumentList(self, args)
+ self.argumentList.append(self.itself)
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- # XXXX Could be subtype of Resource
- # Attributes that can be set.
- getsetlist = [
- (
- 'destRect',
- 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->destRect);',
- None,
- 'Destination rectangle'
- ), (
- 'viewRect',
- 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->viewRect);',
- None,
- 'Viewing rectangle'
- ), (
- 'selRect',
- 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->selRect);',
- None,
- 'Selection rectangle'
- ), (
- 'lineHeight',
- 'return Py_BuildValue("h", (*self->ob_itself)->lineHeight);',
- None,
- 'Height of a line'
- ), (
- 'fontAscent',
- 'return Py_BuildValue("h", (*self->ob_itself)->fontAscent);',
- None,
- 'Ascent of a line'
- ), (
- "selPoint",
- 'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->selPoint);',
- None,
- 'Selection Point'
- ), (
- 'selStart',
- 'return Py_BuildValue("h", (*self->ob_itself)->selStart);',
- None,
- 'Start of selection'
- ), (
- 'selEnd',
- 'return Py_BuildValue("h", (*self->ob_itself)->selEnd);',
- None,
- 'End of selection'
- ), (
- 'active',
- 'return Py_BuildValue("h", (*self->ob_itself)->active);',
- None,
- 'TBD'
- ), (
- 'just',
- 'return Py_BuildValue("h", (*self->ob_itself)->just);',
- None,
- 'Justification'
- ), (
- 'teLength',
- 'return Py_BuildValue("h", (*self->ob_itself)->teLength);',
- None,
- 'TBD'
- ), (
- 'txFont',
- 'return Py_BuildValue("h", (*self->ob_itself)->txFont);',
- None,
- 'Current font'
- ), (
- 'txFace',
- 'return Py_BuildValue("h", (*self->ob_itself)->txFace);',
- None,
- 'Current font variant'
- ), (
- 'txMode',
- 'return Py_BuildValue("h", (*self->ob_itself)->txMode);',
- None,
- 'Current text-drawing mode'
- ), (
- 'txSize',
- 'return Py_BuildValue("h", (*self->ob_itself)->txSize);',
- None,
- 'Current font size'
- ), (
- 'nLines',
- 'return Py_BuildValue("h", (*self->ob_itself)->nLines);',
- None,
- 'TBD'
- )]
-
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- PyErr_SetString(TE_Error,"Cannot create null TE");
- return NULL;
- }""")
- def outputFreeIt(self, itselfname):
- Output("TEDispose(%s);", itselfname)
-
+ # XXXX Could be subtype of Resource
+ # Attributes that can be set.
+ getsetlist = [
+ (
+ 'destRect',
+ 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->destRect);',
+ None,
+ 'Destination rectangle'
+ ), (
+ 'viewRect',
+ 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->viewRect);',
+ None,
+ 'Viewing rectangle'
+ ), (
+ 'selRect',
+ 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->selRect);',
+ None,
+ 'Selection rectangle'
+ ), (
+ 'lineHeight',
+ 'return Py_BuildValue("h", (*self->ob_itself)->lineHeight);',
+ None,
+ 'Height of a line'
+ ), (
+ 'fontAscent',
+ 'return Py_BuildValue("h", (*self->ob_itself)->fontAscent);',
+ None,
+ 'Ascent of a line'
+ ), (
+ "selPoint",
+ 'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->selPoint);',
+ None,
+ 'Selection Point'
+ ), (
+ 'selStart',
+ 'return Py_BuildValue("h", (*self->ob_itself)->selStart);',
+ None,
+ 'Start of selection'
+ ), (
+ 'selEnd',
+ 'return Py_BuildValue("h", (*self->ob_itself)->selEnd);',
+ None,
+ 'End of selection'
+ ), (
+ 'active',
+ 'return Py_BuildValue("h", (*self->ob_itself)->active);',
+ None,
+ 'TBD'
+ ), (
+ 'just',
+ 'return Py_BuildValue("h", (*self->ob_itself)->just);',
+ None,
+ 'Justification'
+ ), (
+ 'teLength',
+ 'return Py_BuildValue("h", (*self->ob_itself)->teLength);',
+ None,
+ 'TBD'
+ ), (
+ 'txFont',
+ 'return Py_BuildValue("h", (*self->ob_itself)->txFont);',
+ None,
+ 'Current font'
+ ), (
+ 'txFace',
+ 'return Py_BuildValue("h", (*self->ob_itself)->txFace);',
+ None,
+ 'Current font variant'
+ ), (
+ 'txMode',
+ 'return Py_BuildValue("h", (*self->ob_itself)->txMode);',
+ None,
+ 'Current text-drawing mode'
+ ), (
+ 'txSize',
+ 'return Py_BuildValue("h", (*self->ob_itself)->txSize);',
+ None,
+ 'Current font size'
+ ), (
+ 'nLines',
+ 'return Py_BuildValue("h", (*self->ob_itself)->nLines);',
+ None,
+ 'TBD'
+ )]
+
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ PyErr_SetString(TE_Error,"Cannot create null TE");
+ return NULL;
+ }""")
+ def outputFreeIt(self, itselfname):
+ Output("TEDispose(%s);", itselfname)
+
# From here on it's basically all boiler plate...
@@ -214,4 +214,3 @@ for f in methods: object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/waste/wastescan.py b/Mac/Modules/waste/wastescan.py
index 8298f26..b5a2b43 100644
--- a/Mac/Modules/waste/wastescan.py
+++ b/Mac/Modules/waste/wastescan.py
@@ -7,9 +7,9 @@ sys.path.append(BGENDIR)
from scantools import Scanner
WASTEDIR='/Users/jack/src/waste/C_C++ Headers/'
-
+
if not os.path.exists(WASTEDIR):
- raise 'Error: not found: %s', WASTEDIR
+ raise 'Error: not found: %s', WASTEDIR
OBJECT = "TEHandle"
SHORT = "waste"
@@ -17,136 +17,136 @@ OBJECT = "WEReference"
OBJECT2 = "WEObjectReference"
def main():
- input = WASTEDIR + "WASTE.h"
- output = SHORT + "gen.py"
- defsoutput = os.path.join(os.path.split(TOOLBOXDIR)[0], "WASTEconst.py")
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
-## scanner.gentypetest(SHORT+"typetest.py")
- scanner.close()
- 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! ==="
+ input = WASTEDIR + "WASTE.h"
+ output = SHORT + "gen.py"
+ defsoutput = os.path.join(os.path.split(TOOLBOXDIR)[0], "WASTEconst.py")
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+## scanner.gentypetest(SHORT+"typetest.py")
+ scanner.close()
+ 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_PreUH3):
class MyScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[-1]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- else:
- t, n, m = arglist[0]
- if t == OBJECT2 and m == "InMode":
- classname = "Method2"
- listname = "methods2"
- return classname, listname
-
- def writeinitialdefs(self):
- self.defsfile.write("kPascalStackBased = None # workaround for header parsing\n")
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
-
- def makeblacklistnames(self):
- return [
- "WEDispose",
- "WESetInfo", # Argument type unknown...
- "WEGetInfo",
- "WEVersion", # Unfortunately...
- "WEPut", # XXXX TBD: needs array of flavortypes.
- "WEGetOneAttribute", # XXXX TBD: output buffer
- # Incompatible constant definitions
- "weDoAutoScroll",
- "weDoOutlineHilite",
- "weDoReadOnly",
- "weDoUndo",
- "weDoIntCutAndPaste",
- "weDoDragAndDrop",
- "weDoInhibitRecal",
- "weDoUseTempMem",
- "weDoDrawOffscreen",
- "weDoInhibitRedraw",
- "weDoMonoStyled",
- "weDoMultipleUndo",
- "weDoNoKeyboardSync",
- "weDoInhibitICSupport",
- "weDoInhibitColor",
- ]
-
- def makeblacklisttypes(self):
- return [
- "DragReference", # For now...
- "UniversalProcPtr",
- "WEFontIDToNameUPP",
- "WEFontNameToIDUPP",
- "WEClickLoopUPP",
- "WEScrollUPP",
- "WETSMPreUpdateUPP",
- "WETSMPostUpdateUPP",
- "WEPreTrackDragUPP",
- "WETranslateDragUPP",
- "WEHiliteDropAreaUPP",
- "WEDrawTextUPP",
- "WEDrawTSMHiliteUPP",
- "WEPixelToCharUPP",
- "WECharToPixelUPP",
- "WELineBreakUPP",
- "WEWordBreakUPP",
- "WECharByteUPP",
- "WECharTypeUPP",
- "WEEraseUPP",
- "WEFluxUPP",
- "WENewObjectUPP",
- "WEDisposeObjectUPP",
- "WEDrawObjectUPP",
- "WEClickObjectUPP",
- "WEStreamObjectUPP",
- "WEHoverObjectUPP",
- "WERuler", # XXXX To be done
- "WERuler_ptr", # ditto
- "WEParaInfo", # XXXX To be done
- "WEPrintSession", # XXXX To be done
- "WEPrintOptions_ptr", # XXXX To be done
- ]
-
- def makerepairinstructions(self):
- return [
- ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- # WEContinuousStyle
- ([("WEStyleMode", "ioMode", "OutMode"), ("TextStyle", "outTextStyle", "OutMode")],
- [("WEStyleMode", "*", "InOutMode"), ("TextStyle", "*", "*")]),
-
- # WECopyRange
- ([('Handle', 'outText', 'InMode'), ('StScrpHandle', 'outStyles', 'InMode'),
- ('WESoupHandle', 'outSoup', 'InMode')],
- [('OptHandle', '*', '*'), ('OptStScrpHandle', '*', '*'),
- ('OptSoupHandle', '*', '*')]),
-
- # WEInsert
- ([('StScrpHandle', 'inStyles', 'InMode'), ('WESoupHandle', 'inSoup', 'InMode')],
- [('OptStScrpHandle', '*', '*'), ('OptSoupHandle', '*', '*')]),
-
- # WEGetObjectOwner
- ("WEGetObjectOwner",
- [('WEReference', '*', 'ReturnMode')],
- [('ExistingWEReference', '*', 'ReturnMode')]),
-
- # WEFindParagraph
- ([("char_ptr", "inKey", "InMode")],
- [("stringptr", "*", "*")]),
-
- # WESetOneAttribute
- ([("void_ptr", "*", "InMode"), ("ByteCount", "*", "InMode")],
- [("InBuffer", "*", "*")]),
- ]
-
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[-1]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ else:
+ t, n, m = arglist[0]
+ if t == OBJECT2 and m == "InMode":
+ classname = "Method2"
+ listname = "methods2"
+ return classname, listname
+
+ def writeinitialdefs(self):
+ self.defsfile.write("kPascalStackBased = None # workaround for header parsing\n")
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+
+ def makeblacklistnames(self):
+ return [
+ "WEDispose",
+ "WESetInfo", # Argument type unknown...
+ "WEGetInfo",
+ "WEVersion", # Unfortunately...
+ "WEPut", # XXXX TBD: needs array of flavortypes.
+ "WEGetOneAttribute", # XXXX TBD: output buffer
+ # Incompatible constant definitions
+ "weDoAutoScroll",
+ "weDoOutlineHilite",
+ "weDoReadOnly",
+ "weDoUndo",
+ "weDoIntCutAndPaste",
+ "weDoDragAndDrop",
+ "weDoInhibitRecal",
+ "weDoUseTempMem",
+ "weDoDrawOffscreen",
+ "weDoInhibitRedraw",
+ "weDoMonoStyled",
+ "weDoMultipleUndo",
+ "weDoNoKeyboardSync",
+ "weDoInhibitICSupport",
+ "weDoInhibitColor",
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "DragReference", # For now...
+ "UniversalProcPtr",
+ "WEFontIDToNameUPP",
+ "WEFontNameToIDUPP",
+ "WEClickLoopUPP",
+ "WEScrollUPP",
+ "WETSMPreUpdateUPP",
+ "WETSMPostUpdateUPP",
+ "WEPreTrackDragUPP",
+ "WETranslateDragUPP",
+ "WEHiliteDropAreaUPP",
+ "WEDrawTextUPP",
+ "WEDrawTSMHiliteUPP",
+ "WEPixelToCharUPP",
+ "WECharToPixelUPP",
+ "WELineBreakUPP",
+ "WEWordBreakUPP",
+ "WECharByteUPP",
+ "WECharTypeUPP",
+ "WEEraseUPP",
+ "WEFluxUPP",
+ "WENewObjectUPP",
+ "WEDisposeObjectUPP",
+ "WEDrawObjectUPP",
+ "WEClickObjectUPP",
+ "WEStreamObjectUPP",
+ "WEHoverObjectUPP",
+ "WERuler", # XXXX To be done
+ "WERuler_ptr", # ditto
+ "WEParaInfo", # XXXX To be done
+ "WEPrintSession", # XXXX To be done
+ "WEPrintOptions_ptr", # XXXX To be done
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ # WEContinuousStyle
+ ([("WEStyleMode", "ioMode", "OutMode"), ("TextStyle", "outTextStyle", "OutMode")],
+ [("WEStyleMode", "*", "InOutMode"), ("TextStyle", "*", "*")]),
+
+ # WECopyRange
+ ([('Handle', 'outText', 'InMode'), ('StScrpHandle', 'outStyles', 'InMode'),
+ ('WESoupHandle', 'outSoup', 'InMode')],
+ [('OptHandle', '*', '*'), ('OptStScrpHandle', '*', '*'),
+ ('OptSoupHandle', '*', '*')]),
+
+ # WEInsert
+ ([('StScrpHandle', 'inStyles', 'InMode'), ('WESoupHandle', 'inSoup', 'InMode')],
+ [('OptStScrpHandle', '*', '*'), ('OptSoupHandle', '*', '*')]),
+
+ # WEGetObjectOwner
+ ("WEGetObjectOwner",
+ [('WEReference', '*', 'ReturnMode')],
+ [('ExistingWEReference', '*', 'ReturnMode')]),
+
+ # WEFindParagraph
+ ([("char_ptr", "inKey", "InMode")],
+ [("stringptr", "*", "*")]),
+
+ # WESetOneAttribute
+ ([("void_ptr", "*", "InMode"), ("ByteCount", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+ ]
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/waste/wastesupport.py b/Mac/Modules/waste/wastesupport.py
index c669fa1..13ddc40 100644
--- a/Mac/Modules/waste/wastesupport.py
+++ b/Mac/Modules/waste/wastesupport.py
@@ -6,18 +6,18 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'WASTE.h' # The Apple header file
-MODNAME = 'waste' # The name of the module
-OBJECTNAME = 'waste' # The basic name of the objects used here
-KIND = 'Ptr' # Usually 'Ptr' or 'Handle'
+MACHEADERFILE = 'WASTE.h' # The Apple header file
+MODNAME = 'waste' # The name of the module
+OBJECTNAME = 'waste' # The basic name of the objects used here
+KIND = 'Ptr' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = MODNAME # The prefix for module-wide routines
-OBJECTTYPE = "WEReference" # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = MODNAME # The prefix for module-wide routines
+OBJECTTYPE = "WEReference" # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
INPUTFILE = 'wastegen.py' # The file generated by the scanner
-TYPETESTFILE = 'wastetypetest.py' # Another file generated by the scanner
-OUTPUTFILE = "wastemodule.c" # The file generated by this program
+TYPETESTFILE = 'wastetypetest.py' # Another file generated by the scanner
+OUTPUTFILE = "wastemodule.c" # The file generated by this program
from macsupport import *
@@ -83,21 +83,21 @@ static PyObject *
TextStyle_New(TextStylePtr itself)
{
- return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
- &itself->tsColor);
+ return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
+ &itself->tsColor);
}
static int
TextStyle_Convert(PyObject *v, TextStylePtr p_itself)
{
- long font, face, size;
-
- if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
- return 0;
- p_itself->tsFont = (short)font;
- p_itself->tsFace = (Style)face;
- p_itself->tsSize = (short)size;
- return 1;
+ long font, face, size;
+
+ if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
+ return 0;
+ p_itself->tsFont = (short)font;
+ p_itself->tsFace = (Style)face;
+ p_itself->tsSize = (short)size;
+ return 1;
}
/*
@@ -107,33 +107,33 @@ static PyObject *
RunInfo_New(WERunInfo *itself)
{
- return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
- itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
+ return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
+ itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
}
/* Conversion of long points and rects */
int
LongRect_Convert(PyObject *v, LongRect *r)
{
- return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
+ return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
}
PyObject *
LongRect_New(LongRect *r)
{
- return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
+ return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
}
int
LongPt_Convert(PyObject *v, LongPt *p)
{
- return PyArg_Parse(v, "(ll)", &p->h, &p->v);
+ return PyArg_Parse(v, "(ll)", &p->h, &p->v);
}
PyObject *
LongPt_New(LongPt *p)
{
- return Py_BuildValue("(ll)", p->h, p->v);
+ return Py_BuildValue("(ll)", p->h, p->v);
}
/* Stuff for the callbacks: */
@@ -146,110 +146,110 @@ WEClickObjectUPP upp_click_handler;
static OSErr
any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
{
- FlavorType tp;
- PyObject *key, *func;
-
- if ( args == NULL ) return errAECorruptData;
-
- tp = WEGetObjectType(who);
-
- if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
- return errAECorruptData;
- if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
- Py_DECREF(key);
- return errAEHandlerNotFound;
- }
- Py_INCREF(func);
- *rv = PyEval_CallObject(func, args);
- Py_DECREF(func);
- Py_DECREF(key);
- if ( *rv == NULL ) {
- PySys_WriteStderr("--Exception in callback: ");
- PyErr_Print();
- return errAEReplyNotArrived;
- }
- return 0;
+ FlavorType tp;
+ PyObject *key, *func;
+
+ if ( args == NULL ) return errAECorruptData;
+
+ tp = WEGetObjectType(who);
+
+ if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
+ return errAECorruptData;
+ if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
+ Py_DECREF(key);
+ return errAEHandlerNotFound;
+ }
+ Py_INCREF(func);
+ *rv = PyEval_CallObject(func, args);
+ Py_DECREF(func);
+ Py_DECREF(key);
+ if ( *rv == NULL ) {
+ PySys_WriteStderr("--Exception in callback: ");
+ PyErr_Print();
+ return errAEReplyNotArrived;
+ }
+ return 0;
}
static pascal OSErr
my_new_handler(Point *objectSize, WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- OSErr err;
-
- args=Py_BuildValue("(O&)", WEOObj_New, objref);
- err = any_handler(weNewHandler, objref, args, &rv);
- if (!err) {
- if (!PyMac_GetPoint(rv, objectSize) )
- err = errAECoercionFail;
- }
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return err;
+ PyObject *args=NULL, *rv=NULL;
+ OSErr err;
+
+ args=Py_BuildValue("(O&)", WEOObj_New, objref);
+ err = any_handler(weNewHandler, objref, args, &rv);
+ if (!err) {
+ if (!PyMac_GetPoint(rv, objectSize) )
+ err = errAECoercionFail;
+ }
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return err;
}
static pascal OSErr
my_dispose_handler(WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- OSErr err;
-
- args=Py_BuildValue("(O&)", WEOObj_New, objref);
- err = any_handler(weDisposeHandler, objref, args, &rv);
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return err;
+ PyObject *args=NULL, *rv=NULL;
+ OSErr err;
+
+ args=Py_BuildValue("(O&)", WEOObj_New, objref);
+ err = any_handler(weDisposeHandler, objref, args, &rv);
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return err;
}
static pascal OSErr
my_draw_handler(const Rect *destRect, WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- OSErr err;
-
- args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
- err = any_handler(weDrawHandler, objref, args, &rv);
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return err;
+ PyObject *args=NULL, *rv=NULL;
+ OSErr err;
+
+ args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
+ err = any_handler(weDrawHandler, objref, args, &rv);
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return err;
}
static pascal Boolean
my_click_handler(Point hitPt, EventModifiers modifiers,
- unsigned long clickTime, WEObjectReference objref)
+ unsigned long clickTime, WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- int retvalue;
- OSErr err;
-
- args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
- (long)modifiers, (long)clickTime, WEOObj_New, objref);
- err = any_handler(weClickHandler, objref, args, &rv);
- if (!err)
- retvalue = PyInt_AsLong(rv);
- else
- retvalue = 0;
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return retvalue;
+ PyObject *args=NULL, *rv=NULL;
+ int retvalue;
+ OSErr err;
+
+ args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
+ (long)modifiers, (long)clickTime, WEOObj_New, objref);
+ err = any_handler(weClickHandler, objref, args, &rv);
+ if (!err)
+ retvalue = PyInt_AsLong(rv);
+ else
+ retvalue = 0;
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return retvalue;
}
-
+
"""
finalstuff = finalstuff + """
@@ -257,62 +257,62 @@ finalstuff = finalstuff + """
PyObject *
ExistingwasteObj_New(w)
- WEReference w;
+ WEReference w;
{
- PyObject *it = NULL;
-
- if (w == NULL)
- it = NULL;
- else
- WEGetInfo(weRefCon, (void *)&it, w);
- if (it == NULL || ((wasteObject *)it)->ob_itself != w)
- it = Py_None;
- Py_INCREF(it);
- return it;
+ PyObject *it = NULL;
+
+ if (w == NULL)
+ it = NULL;
+ else
+ WEGetInfo(weRefCon, (void *)&it, w);
+ if (it == NULL || ((wasteObject *)it)->ob_itself != w)
+ it = Py_None;
+ Py_INCREF(it);
+ return it;
}
"""
class WEMethodGenerator(OSErrMethodGenerator):
- """Similar to MethodGenerator, but has self as last argument"""
+ """Similar to MethodGenerator, but has self as last argument"""
- def parseArgumentList(self, args):
- args, a0 = args[:-1], args[-1]
- t0, n0, m0 = a0
- if m0 != InMode:
- raise ValueError, "method's 'self' must be 'InMode'"
- self.itself = Variable(t0, "_self->ob_itself", SelfMode)
- FunctionGenerator.parseArgumentList(self, args)
- self.argumentList.append(self.itself)
+ def parseArgumentList(self, args):
+ args, a0 = args[:-1], args[-1]
+ t0, n0, m0 = a0
+ if m0 != InMode:
+ raise ValueError, "method's 'self' must be 'InMode'"
+ self.itself = Variable(t0, "_self->ob_itself", SelfMode)
+ FunctionGenerator.parseArgumentList(self, args)
+ self.argumentList.append(self.itself)
class WEObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- PyErr_SetString(waste_Error,"Cannot create null WE");
- return NULL;
- }""")
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("WESetInfo(weRefCon, (void *)&it, itself);")
- def outputFreeIt(self, itselfname):
- Output("WEDispose(%s);", itselfname)
-
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ PyErr_SetString(waste_Error,"Cannot create null WE");
+ return NULL;
+ }""")
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("WESetInfo(weRefCon, (void *)&it, itself);")
+ def outputFreeIt(self, itselfname):
+ Output("WEDispose(%s);", itselfname)
+
class WEOObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }""")
-
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }""")
+
variablestuff = """
- callbackdict = PyDict_New();
- if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
- return;
- upp_new_handler = NewWENewObjectProc(my_new_handler);
- upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
- upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
- upp_click_handler = NewWEClickObjectProc(my_click_handler);
+ callbackdict = PyDict_New();
+ if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
+ return;
+ upp_new_handler = NewWENewObjectProc(my_new_handler);
+ upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
+ upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
+ upp_click_handler = NewWEClickObjectProc(my_click_handler);
"""
@@ -341,78 +341,78 @@ execfile(INPUTFILE)
# A function written by hand:
stdhandlers_body = """
- OSErr err;
- // install the sample object handlers for pictures and sounds
-#define kTypePicture 'PICT'
-#define kTypeSound 'snd '
-
- if ( !PyArg_ParseTuple(_args, "") ) return NULL;
-
- if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
- (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
- (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
- (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
- (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
- (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
- (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
- goto cleanup;
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
-
+ OSErr err;
+ // install the sample object handlers for pictures and sounds
+#define kTypePicture 'PICT'
+#define kTypeSound 'snd '
+
+ if ( !PyArg_ParseTuple(_args, "") ) return NULL;
+
+ if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
+ (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
+ (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
+ (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
+ (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
+ (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
+ (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
+ goto cleanup;
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+
cleanup:
- return PyMac_Error(err);
+ return PyMac_Error(err);
"""
inshandler_body = """
- OSErr err;
- FlavorType objectType;
- WESelector selector;
- PyObject *py_handler;
- UniversalProcPtr handler;
- WEReference we = NULL;
- PyObject *key;
-
-
- if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
- PyMac_GetOSType, &objectType,
- PyMac_GetOSType, &selector,
- &py_handler,
- WEOObj_Convert, &we) ) return NULL;
-
- if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
- else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
- else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
- else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
- else return PyMac_Error(weUndefinedSelectorErr);
-
- if ((key = Py_BuildValue("O&O&",
- PyMac_BuildOSType, objectType,
- PyMac_BuildOSType, selector)) == NULL )
- return NULL;
-
- PyDict_SetItem(callbackdict, key, py_handler);
-
- err = WEInstallObjectHandler(objectType, selector, handler, we);
- if ( err ) return PyMac_Error(err);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
+ OSErr err;
+ FlavorType objectType;
+ WESelector selector;
+ PyObject *py_handler;
+ UniversalProcPtr handler;
+ WEReference we = NULL;
+ PyObject *key;
+
+
+ if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
+ PyMac_GetOSType, &objectType,
+ PyMac_GetOSType, &selector,
+ &py_handler,
+ WEOObj_Convert, &we) ) return NULL;
+
+ if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
+ else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
+ else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
+ else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
+ else return PyMac_Error(weUndefinedSelectorErr);
+
+ if ((key = Py_BuildValue("O&O&",
+ PyMac_BuildOSType, objectType,
+ PyMac_BuildOSType, selector)) == NULL )
+ return NULL;
+
+ PyDict_SetItem(callbackdict, key, py_handler);
+
+ err = WEInstallObjectHandler(objectType, selector, handler, we);
+ if ( err ) return PyMac_Error(err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
"""
stdhand = ManualGenerator("STDObjectHandlers", stdhandlers_body)
@@ -442,4 +442,3 @@ for f in methods2: object2.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-
diff --git a/Mac/Modules/win/winedit.py b/Mac/Modules/win/winedit.py
index d79356f..01cfe86 100644
--- a/Mac/Modules/win/winedit.py
+++ b/Mac/Modules/win/winedit.py
@@ -7,25 +7,25 @@ f = Method(Boolean, 'IsWindowVisible',
methods.append(f)
f = Method(void, 'GetWindowStructureRgn',
- (WindowRef, 'theWindow', InMode),
- (RgnHandle, 'r', InMode),
+ (WindowRef, 'theWindow', InMode),
+ (RgnHandle, 'r', InMode),
)
methods.append(f)
f = Method(void, 'GetWindowContentRgn',
- (WindowRef, 'theWindow', InMode),
- (RgnHandle, 'r', InMode),
+ (WindowRef, 'theWindow', InMode),
+ (RgnHandle, 'r', InMode),
)
methods.append(f)
f = Method(void, 'GetWindowUpdateRgn',
- (WindowRef, 'theWindow', InMode),
- (RgnHandle, 'r', InMode),
+ (WindowRef, 'theWindow', InMode),
+ (RgnHandle, 'r', InMode),
)
methods.append(f)
f = Method(ExistingWindowPtr, 'GetNextWindow',
- (WindowRef, 'theWindow', InMode),
+ (WindowRef, 'theWindow', InMode),
)
methods.append(f)
@@ -54,18 +54,16 @@ methods.append(f)
AutoDispose_body = """
int onoff, old = 0;
if (!PyArg_ParseTuple(_args, "i", &onoff))
- return NULL;
+ return NULL;
if ( _self->ob_freeit )
- old = 1;
+ old = 1;
if ( onoff )
- _self->ob_freeit = PyMac_AutoDisposeWindow;
+ _self->ob_freeit = PyMac_AutoDisposeWindow;
else
- _self->ob_freeit = NULL;
+ _self->ob_freeit = NULL;
_res = Py_BuildValue("i", old);
return _res;
"""
f = ManualGenerator("AutoDispose", AutoDispose_body)
f.docstring = lambda: "(int)->int. Automatically DisposeHandle the object on Python object cleanup"
methods.append(f)
-
-
diff --git a/Mac/Modules/win/winscan.py b/Mac/Modules/win/winscan.py
index 6b08c00..f78935d 100644
--- a/Mac/Modules/win/winscan.py
+++ b/Mac/Modules/win/winscan.py
@@ -7,125 +7,124 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- input = "MacWindows.h"
- output = "wingen.py"
- defsoutput = TOOLBOXDIR + "Windows.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now importing the generated code... ==="
- import winsupport
- print "=== Done. It's up to you to compile it now! ==="
+ input = "MacWindows.h"
+ output = "wingen.py"
+ defsoutput = TOOLBOXDIR + "Windows.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now importing the generated code... ==="
+ import winsupport
+ 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 in ("WindowPtr", "WindowPeek", "WindowRef") 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("false = 0\n")
- self.defsfile.write("true = 1\n")
- self.defsfile.write("kWindowNoConstrainAttribute = 0x80000000\n")
-
- def makeblacklistnames(self):
- return [
- 'DisposeWindow', # Implied when the object is deleted
- 'CloseWindow',
- 'SetWindowProperty', # For the moment
- 'GetWindowProperty',
- 'GetWindowPropertySize',
- 'RemoveWindowProperty',
- 'MacCloseWindow',
- 'GetWindowList', # Don't know whether this is safe...
- # Constants with funny definitions
- 'kMouseUpOutOfSlop',
- 'kAllWindowClasses',
- 'kWindowNoConstrainAttribute',
- # OS8 only:
- 'GetAuxWin',
- 'GetWindowDataHandle',
- 'SaveOld',
- 'DrawNew',
- 'SetWinColor',
- 'SetDeskCPat',
- 'InitWindows',
- 'InitFloatingWindows',
- 'GetWMgrPort',
- 'GetCWMgrPort',
- 'ValidRgn', # Use versions with Window in their name
- 'ValidRect',
- 'InvalRgn',
- 'InvalRect',
- 'IsValidWindowPtr', # I think this is useless for Python, but not sure...
- 'GetWindowZoomFlag', # Not available in Carbon
- 'GetWindowTitleWidth', # Ditto
- 'GetWindowGoAwayFlag',
- 'GetWindowSpareFlag',
- ]
-
- def makeblacklisttypes(self):
- return [
- 'ProcPtr',
- 'DragGrayRgnUPP',
- 'WindowPaintUPP',
- 'Collection', # For now, to be done later
- 'WindowDefSpec', # Too difficult for now
- 'WindowDefSpec_ptr',
- 'EventRef', #TBD
- ]
-
- def makerepairinstructions(self):
- return [
-
- # GetWTitle
- ([("Str255", "*", "InMode")],
- [("*", "*", "OutMode")]),
-
- ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- ([("void", "*", "OutMode"), ("long", "*", "InMode"),
- ("long", "*", "OutMode")],
- [("VarVarOutBuffer", "*", "InOutMode")]),
-
- ([("void", "wStorage", "OutMode")],
- [("NullStorage", "*", "InMode")]),
-
- # match FindWindowOfClass
- ([("WindowRef", "outWindow", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")],
- [("ExistingWindowPtr", "*", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")]),
- # then match CreateNewWindow and CreateWindowFromResource
- ([("WindowRef", "outWindow", "OutMode")],
- [("WindowRef", "*", "*")]),
-
- ([("WindowPtr", "*", "OutMode")],
- [("ExistingWindowPtr", "*", "*")]),
- ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
- [("ExistingWindowPtr", "*", "*")]),
-
- ([("WindowPtr", "FrontWindow", "ReturnMode")],
- [("ExistingWindowPtr", "*", "*")]),
- ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
- [("ExistingWindowPtr", "*", "*")]),
- ([("WindowPtr", "FrontNonFloatingWindow", "ReturnMode")],
- [("ExistingWindowPtr", "*", "*")]),
- ([("WindowRef", "FrontNonFloatingWindow", "ReturnMode")], # Ditto
- [("ExistingWindowPtr", "*", "*")]),
-
- ([("Rect_ptr", "*", "ReturnMode")], # GetWindowXXXState accessors
- [("void", "*", "ReturnMode")]),
- ]
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ return classname, listname
-if __name__ == "__main__":
- main()
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ self.defsfile.write("false = 0\n")
+ self.defsfile.write("true = 1\n")
+ self.defsfile.write("kWindowNoConstrainAttribute = 0x80000000\n")
+
+ def makeblacklistnames(self):
+ return [
+ 'DisposeWindow', # Implied when the object is deleted
+ 'CloseWindow',
+ 'SetWindowProperty', # For the moment
+ 'GetWindowProperty',
+ 'GetWindowPropertySize',
+ 'RemoveWindowProperty',
+ 'MacCloseWindow',
+ 'GetWindowList', # Don't know whether this is safe...
+ # Constants with funny definitions
+ 'kMouseUpOutOfSlop',
+ 'kAllWindowClasses',
+ 'kWindowNoConstrainAttribute',
+ # OS8 only:
+ 'GetAuxWin',
+ 'GetWindowDataHandle',
+ 'SaveOld',
+ 'DrawNew',
+ 'SetWinColor',
+ 'SetDeskCPat',
+ 'InitWindows',
+ 'InitFloatingWindows',
+ 'GetWMgrPort',
+ 'GetCWMgrPort',
+ 'ValidRgn', # Use versions with Window in their name
+ 'ValidRect',
+ 'InvalRgn',
+ 'InvalRect',
+ 'IsValidWindowPtr', # I think this is useless for Python, but not sure...
+ 'GetWindowZoomFlag', # Not available in Carbon
+ 'GetWindowTitleWidth', # Ditto
+ 'GetWindowGoAwayFlag',
+ 'GetWindowSpareFlag',
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ 'ProcPtr',
+ 'DragGrayRgnUPP',
+ 'WindowPaintUPP',
+ 'Collection', # For now, to be done later
+ 'WindowDefSpec', # Too difficult for now
+ 'WindowDefSpec_ptr',
+ 'EventRef', #TBD
+ ]
+
+ def makerepairinstructions(self):
+ return [
+
+ # GetWTitle
+ ([("Str255", "*", "InMode")],
+ [("*", "*", "OutMode")]),
+
+ ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ ([("void", "*", "OutMode"), ("long", "*", "InMode"),
+ ("long", "*", "OutMode")],
+ [("VarVarOutBuffer", "*", "InOutMode")]),
+ ([("void", "wStorage", "OutMode")],
+ [("NullStorage", "*", "InMode")]),
+
+ # match FindWindowOfClass
+ ([("WindowRef", "outWindow", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")],
+ [("ExistingWindowPtr", "*", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")]),
+ # then match CreateNewWindow and CreateWindowFromResource
+ ([("WindowRef", "outWindow", "OutMode")],
+ [("WindowRef", "*", "*")]),
+
+ ([("WindowPtr", "*", "OutMode")],
+ [("ExistingWindowPtr", "*", "*")]),
+ ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
+ [("ExistingWindowPtr", "*", "*")]),
+
+ ([("WindowPtr", "FrontWindow", "ReturnMode")],
+ [("ExistingWindowPtr", "*", "*")]),
+ ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
+ [("ExistingWindowPtr", "*", "*")]),
+ ([("WindowPtr", "FrontNonFloatingWindow", "ReturnMode")],
+ [("ExistingWindowPtr", "*", "*")]),
+ ([("WindowRef", "FrontNonFloatingWindow", "ReturnMode")], # Ditto
+ [("ExistingWindowPtr", "*", "*")]),
+
+ ([("Rect_ptr", "*", "ReturnMode")], # GetWindowXXXState accessors
+ [("void", "*", "ReturnMode")]),
+ ]
+
+if __name__ == "__main__":
+ main()
diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py
index 640e33a..08a0379 100644
--- a/Mac/Modules/win/winsupport.py
+++ b/Mac/Modules/win/winsupport.py
@@ -6,17 +6,17 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Windows.h' # The Apple header file
-MODNAME = '_Win' # The name of the module
-OBJECTNAME = 'Window' # The basic name of the objects used here
+MACHEADERFILE = 'Windows.h' # The Apple header file
+MODNAME = '_Win' # The name of the module
+OBJECTNAME = 'Window' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Win' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Win' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
EDITFILE = string.lower(MODPREFIX) + 'edit.py' # The manual definitions
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -79,7 +79,7 @@ extern int _WinObj_Convert(PyObject *, WindowRef *);
static void
PyMac_AutoDisposeWindow(WindowPtr w)
{
- DisposeWindow(w);
+ DisposeWindow(w);
}
"""
@@ -89,94 +89,94 @@ finalstuff = finalstuff + """
PyObject *
WinObj_WhichWindow(WindowPtr w)
{
- PyObject *it;
-
- if (w == NULL) {
- it = Py_None;
- Py_INCREF(it);
- } else {
- it = (PyObject *) GetWRefCon(w);
- if (it == NULL || !IsPointerValid((Ptr)it) || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
- it = WinObj_New(w);
- ((WindowObject *)it)->ob_freeit = NULL;
- } else {
- Py_INCREF(it);
- }
- }
- return it;
+ PyObject *it;
+
+ if (w == NULL) {
+ it = Py_None;
+ Py_INCREF(it);
+ } else {
+ it = (PyObject *) GetWRefCon(w);
+ if (it == NULL || !IsPointerValid((Ptr)it) || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
+ it = WinObj_New(w);
+ ((WindowObject *)it)->ob_freeit = NULL;
+ } else {
+ Py_INCREF(it);
+ }
+ }
+ return it;
}
"""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_WhichWindow);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WindowPtr, WinObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_WhichWindow);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WindowPtr, WinObj_Convert);
"""
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- Output("/* XXXX Or should we use WhichWindow code here? */")
- def outputStructMembers(self):
- GlobalObjectDefinition.outputStructMembers(self)
- Output("void (*ob_freeit)(%s ptr);", self.itselftype)
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("it->ob_freeit = NULL;")
- Output("if (GetWRefCon(itself) == 0)")
- OutLbrace()
- Output("SetWRefCon(itself, (long)it);")
- Output("it->ob_freeit = PyMac_AutoDisposeWindow;")
- OutRbrace()
- def outputCheckConvertArg(self):
- Out("""
- if (v == Py_None) { *p_itself = NULL; return 1; }
- if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
- """)
- OutLbrace()
- Output("DialogRef dlg;")
- OutLbrace("if (DlgObj_Convert(v, &dlg) && dlg)")
- Output("*p_itself = GetDialogWindow(dlg);")
- Output("return 1;")
- OutRbrace()
- Output("PyErr_Clear();")
- OutRbrace()
- def outputCleanupStructMembers(self):
- Output("if (self->ob_freeit && self->ob_itself)")
- OutLbrace()
- Output("SetWRefCon(self->ob_itself, 0);")
- Output("self->ob_freeit(self->ob_itself);")
- OutRbrace()
- Output("self->ob_itself = NULL;")
- Output("self->ob_freeit = NULL;")
-
- def outputCompare(self):
- Output()
- Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype)
- OutLbrace()
- Output("if ( self->ob_itself > other->ob_itself ) return 1;")
- Output("if ( self->ob_itself < other->ob_itself ) return -1;")
- Output("return 0;")
- OutRbrace()
-
- def outputHash(self):
- Output()
- Output("static int %s_hash(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("return (int)self->ob_itself;")
- OutRbrace()
-
- def outputRepr(self):
- Output()
- Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
- OutLbrace()
- Output("char buf[100];")
- Output("""sprintf(buf, "<Window object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
- Output("return PyString_FromString(buf);")
- OutRbrace()
-
-## def outputFreeIt(self, itselfname):
-## Output("DisposeWindow(%s);", itselfname)
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ Output("/* XXXX Or should we use WhichWindow code here? */")
+ def outputStructMembers(self):
+ GlobalObjectDefinition.outputStructMembers(self)
+ Output("void (*ob_freeit)(%s ptr);", self.itselftype)
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_freeit = NULL;")
+ Output("if (GetWRefCon(itself) == 0)")
+ OutLbrace()
+ Output("SetWRefCon(itself, (long)it);")
+ Output("it->ob_freeit = PyMac_AutoDisposeWindow;")
+ OutRbrace()
+ def outputCheckConvertArg(self):
+ Out("""
+ if (v == Py_None) { *p_itself = NULL; return 1; }
+ if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
+ """)
+ OutLbrace()
+ Output("DialogRef dlg;")
+ OutLbrace("if (DlgObj_Convert(v, &dlg) && dlg)")
+ Output("*p_itself = GetDialogWindow(dlg);")
+ Output("return 1;")
+ OutRbrace()
+ Output("PyErr_Clear();")
+ OutRbrace()
+ def outputCleanupStructMembers(self):
+ Output("if (self->ob_freeit && self->ob_itself)")
+ OutLbrace()
+ Output("SetWRefCon(self->ob_itself, 0);")
+ Output("self->ob_freeit(self->ob_itself);")
+ OutRbrace()
+ Output("self->ob_itself = NULL;")
+ Output("self->ob_freeit = NULL;")
+
+ def outputCompare(self):
+ Output()
+ Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype, self.objecttype)
+ OutLbrace()
+ Output("if ( self->ob_itself > other->ob_itself ) return 1;")
+ Output("if ( self->ob_itself < other->ob_itself ) return -1;")
+ Output("return 0;")
+ OutRbrace()
+
+ def outputHash(self):
+ Output()
+ Output("static int %s_hash(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("return (int)self->ob_itself;")
+ OutRbrace()
+
+ def outputRepr(self):
+ Output()
+ Output("static PyObject * %s_repr(%s *self)", self.prefix, self.objecttype)
+ OutLbrace()
+ Output("char buf[100];")
+ Output("""sprintf(buf, "<Window object at 0x%%8.8x for 0x%%8.8x>", (unsigned)self, (unsigned)self->ob_itself);""")
+ Output("return PyString_FromString(buf);")
+ OutRbrace()
+
+## def outputFreeIt(self, itselfname):
+## Output("DisposeWindow(%s);", itselfname)
# From here on it's basically all boiler plate...
# Create the generator groups and link them
@@ -199,7 +199,7 @@ whichwin_body = """
long ptr;
if ( !PyArg_ParseTuple(_args, "i", &ptr) )
- return NULL;
+ return NULL;
_res = WinObj_WhichWindow((WindowPtr)ptr);
return _res;
"""