Add better error reporting for MemoryErrors caused by str->float conversions.
[python.git] / Mac / Modules / scrap / scrapscan.py
blob25a683ca96a418c4c1376998727ce96360900f63
1 # Scan an Apple header file, generating a Python file of generator calls.
3 # Note that the scrap-manager include file is so weird that this
4 # generates a boilerplate to be edited by hand.
6 import sys
7 from bgenlocations import TOOLBOXDIR, BGENDIR
8 sys.path.append(BGENDIR)
9 from scantools import Scanner
11 LONG = "Scrap"
12 SHORT = "scrap"
14 def main():
15 input = "Scrap.h"
16 output = SHORT + "gen.py"
17 defsoutput = "@Scrap.py"
18 scanner = MyScanner(input, output, defsoutput)
19 scanner.scan()
20 scanner.close()
21 ## print "=== Testing definitions output code ==="
22 ## execfile(defsoutput, {}, {})
23 print "=== Done scanning and generating, now importing the generated code... ==="
24 exec "import " + SHORT + "support"
25 print "=== Done. It's up to you to compile it now! ==="
27 class MyScanner(Scanner):
29 def destination(self, type, name, arglist):
30 classname = "Function"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[0]
34 if t == 'ScrapRef' and m == "InMode":
35 classname = "Method"
36 listname = "methods"
37 return classname, listname
39 def makeblacklistnames(self):
40 return [
41 "GetScrapFlavorInfoList",
42 'InfoScrap',
43 'GetScrap',
44 'ZeroScrap',
45 'PutScrap',
48 def makeblacklisttypes(self):
49 return [
50 'ScrapPromiseKeeperUPP',
53 def makerepairinstructions(self):
54 return [
55 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
56 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
59 if __name__ == "__main__":
60 main()