source: trunk/essentials/dev-lang/python/Mac/Modules/cf/cfscan.py@ 3609

Last change on this file since 3609 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 5.4 KB
Line 
1# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
5from bgenlocations import TOOLBOXDIR, BGENDIR
6sys.path.append(BGENDIR)
7from scantools import Scanner_OSX
8
9LONG = "CoreFoundation"
10SHORT = "cf"
11OBJECTS = ("CFTypeRef",
12 "CFArrayRef", "CFMutableArrayRef",
13 "CFDataRef", "CFMutableDataRef",
14 "CFDictionaryRef", "CFMutableDictionaryRef",
15 "CFStringRef", "CFMutableStringRef",
16 "CFURLRef",
17## "CFPropertyListRef",
18 )
19# ADD object typenames here
20
21def main():
22 input = [
23 "CFBase.h",
24 "CFArray.h",
25## "CFBag.h",
26## "CFBundle.h",
27## "CFCharacterSet.h",
28 "CFData.h",
29## "CFDate.h",
30 "CFDictionary.h",
31## "CFNumber.h",
32## "CFPlugIn.h",
33 "CFPreferences.h",
34 "CFPropertyList.h",
35## "CFSet.h",
36 "CFString.h",
37## "CFStringEncodingExt.h",
38## "CFTimeZone.h",
39 "CFURL.h",
40 ]
41 output = SHORT + "gen.py"
42 defsoutput = TOOLBOXDIR + LONG + ".py"
43 scanner = MyScanner(input, output, defsoutput)
44 scanner.scan()
45 scanner.gentypetest(SHORT+"typetest.py")
46 scanner.close()
47 print "=== Testing definitions output code ==="
48 execfile(defsoutput, {}, {})
49 print "=== Done scanning and generating, now importing the generated code... ==="
50 exec "import " + SHORT + "support"
51 print "=== Done. It's up to you to compile it now! ==="
52
53class MyScanner(Scanner_OSX):
54
55 def destination(self, type, name, arglist):
56 classname = "Function"
57 listname = "functions"
58 if arglist and name[:13] != 'CFPreferences':
59 t, n, m = arglist[0]
60 if t in OBJECTS and m == "InMode":
61 classname = "Method"
62 listname = t + "_methods"
63 # Special case for the silly first AllocatorRef argument