source: trunk/essentials/dev-lang/python/Mac/Modules/scrap/scrapscan.py@ 3390

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

Python 2.5

File size: 1.7 KB
Line 
1# Scan an Apple header file, generating a Python file of generator calls.
2#
3# Note that the scrap-manager include file is so weird that this
4# generates a boilerplate to be edited by hand.
5
6import sys
7import os
8from bgenlocations import TOOLBOXDIR, BGENDIR
9sys.path.append(BGENDIR)
10from scantools import Scanner
11
12LONG = "Scrap"
13SHORT = "scrap"
14
15def main():
16 input = "Scrap.h"
17 output = SHORT + "gen.py"
18 defsoutput = "@Scrap.py"
19 scanner = MyScanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.close()
22## print "=== Testing definitions output code ==="
23## execfile(defsoutput, {}, {})
24 print "=== Done scanning and generating, now importing the generated code... ==="
25 exec "import " + SHORT + "support"
26 print "=== Done. It's up to you to compile it now! ==="
27
28class MyScanner(Scanner):
29
30 def destination(self, type, name, arglist):
31 classname = "Function"
32 listname = "functions"
33 if arglist:
34 t, n, m = arglist[0]
35 if t == 'ScrapRef' and m == "InMode":
36 classname = "Method"
37 listname = "methods"
38 return classname, listname
39
40 def makeblacklistnames(self):
41 return [
42 "GetScrapFlavorInfoList",
43 'InfoScrap',
44 'GetScrap',
45 'ZeroScrap',
46 'PutScrap',
47 ]
48
49 def makeblacklisttypes(self):
50 return [
51 'ScrapPromiseKeeperUPP',
52 ]
53
54 def makerepairinstructions(self):
55 return [
56 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
57 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
58 ]
59
60if __name__ == "__main__":
61 main()
Note: See TracBrowser for help on using the repository browser.