1 # Scan an Apple header file, generating a Python file of generator calls.
4 from bgenlocations
import TOOLBOXDIR
, BGENDIR
5 sys
.path
.append(BGENDIR
)
6 from scantools
import Scanner
8 LONG
= "LaunchServices"
14 output
= SHORT
+ "gen.py"
15 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
16 scanner
= MyScanner(input, output
, defsoutput
)
19 scanner
.gentypetest(SHORT
+"typetest.py")
20 print "=== Testing definitions output code ==="
21 execfile(defsoutput
, {}, {})
22 print "=== Done scanning and generating, now importing the generated code... ==="
23 exec "import " + SHORT
+ "support"
24 print "=== Done. It's up to you to compile it now! ==="
26 class MyScanner(Scanner
):
28 def destination(self
, type, name
, arglist
):
29 classname
= "Function"
30 listname
= "functions"
33 # This is non-functional today
34 if t
== OBJECT
and m
== "InMode":
37 return classname
, listname
39 def writeinitialdefs(self
):
40 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
41 self
.defsfile
.write("from Carbon.Files import *\n")
42 self
.defsfile
.write("kLSRequestAllInfo = -1\n")
43 self
.defsfile
.write("kLSRolesAll = -1\n")
44 self
.defsfile
.write("kLSUnknownType = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
45 self
.defsfile
.write("kLSUnknownCreator = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
46 self
.defsfile
.write("kLSInvalidExtensionIndex = -1\n")
48 def makeblacklistnames(self
):
54 "kLSInvalidExtensionIndex",
59 def makeblacklisttypes(self
):
61 "LSLaunchFSRefSpec_ptr",
62 "LSLaunchURLSpec_ptr",
65 def makerepairinstructions(self
):
67 # LSGetApplicationForInfo
68 ([('CFStringRef', 'inExtension', 'InMode')],
69 [('OptCFStringRef', 'inExtension', 'InMode')]),
71 # LSFindApplicationForInfo
72 ([('CFStringRef', 'inBundleID', 'InMode')],
73 [('OptCFStringRef', 'inBundleID', 'InMode')]),
74 ([('CFStringRef', 'inName', 'InMode')],
75 [('OptCFStringRef', 'inName', 'InMode')]),
77 # Unicode filenames passed as length, buffer. LSGetExtensionInfo
78 ([('UniCharCount', '*', 'InMode'),
79 ('UniChar_ptr', '*', 'InMode')],
80 [('UnicodeReverseInBuffer', '*', 'InMode')]
84 if __name__
== "__main__":