summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/osa
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Modules/osa')
-rw-r--r--Mac/Modules/osa/osascan.py92
-rw-r--r--Mac/Modules/osa/osasupport.py43
-rw-r--r--Mac/Modules/osa/setup.py14
3 files changed, 74 insertions, 75 deletions
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'}
+ )