blob: 776af5ba4ceaf075d09fd377084a4b03627246ea [file] [log] [blame]
Jack Jansen686f9c32001-06-26 21:51:18 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
5BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
6sys.path.append(BGENDIR)
7from scantools import Scanner_OSX
8from bgenlocations import TOOLBOXDIR
9
10LONG = "CoreFoundation"
11SHORT = "cf"
12OBJECTS = ("CFTypeRef", "CFStringRef")
13
14def main():
15 input = [
16 "CFBase.h",
17### "CFArray.h",
18## "CFBag.h",
19## "CFBundle.h",
20## "CFCharacterSet.h",
21### "CFData.h",
22## "CFDate.h",
23### "CFDictionary.h",
24## "CFNumber.h",
25## "CFPlugIn.h",
26## "CFPreferences.h",
27## "CFPropertyList.h",
28## "CFSet.h",
29### "CFString.h",
30## "CFStringEncodingExt.h",
31## "CFTimeZone.h",
32## "CFURL.h",
33 ]
34 output = SHORT + "gen.py"
35 defsoutput = TOOLBOXDIR + LONG + ".py"
36 scanner = MyScanner(input, output, defsoutput)
37 scanner.scan()
38 scanner.gentypetest(SHORT+"typetest.py")
39 scanner.close()
40 print "=== Done scanning and generating, now importing the generated code... ==="
41 exec "import " + SHORT + "support"
42 print "=== Done. It's up to you to compile it now! ==="
43
44class MyScanner(Scanner_OSX):
45
46 def destination(self, type, name, arglist):
47 classname = "Function"
48 listname = "functions"
49 if arglist:
50 t, n, m = arglist[0]
51 if t in OBJECTS and m == "InMode":
52 classname = "Method"
53 listname = t + "_methods"
54 return classname, listname
55
56 def writeinitialdefs(self):
57 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
58
59 def makeblacklistnames(self):
60 return [
61 # Memory allocator functions
62 "CFAllocatorGetDefault",
63 "CFAllocatorSetDefault",
64 "CFAllocatorAllocate",
65 "CFAllocatorReallocate",
66 "CFAllocatorDeallocate",
67 "CFGetAllocator",
68 ]
69
70 def makegreylist(self):
71 return []
72
73 def makeblacklisttypes(self):
74 return [
75 "CFAllocatorContext",
76 ]
77
78 def makerepairinstructions(self):
79 return [
80 ]
81
82if __name__ == "__main__":
83 main()