blob: 81f107c2b1b2d46e79e2680f236ea318f0329d7b [file] [log] [blame]
Jack Jansenebd01062000-05-14 22:05:36 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00005from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansenebd01062000-05-14 22:05:36 +00006sys.path.append(BGENDIR)
7
8from scantools import Scanner
Jack Jansenebd01062000-05-14 22:05:36 +00009
10LONG = "HtmlRendering"
11SHORT = "html"
12OBJECT = "HRReference"
13
14def main():
15## input = LONG + ".h"
Jack Jansend9c01a52000-05-15 15:36:52 +000016 input = "Macintosh HD:ufs:jack:SWdev:Universal:Interfaces:CIncludes:HTMLRendering.h"
Jack Jansenebd01062000-05-14 22:05:36 +000017 output = SHORT + "gen.py"
18 defsoutput = TOOLBOXDIR + LONG + ".py"
19 scanner = MyScanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.close()
Jack Jansen87eea882002-08-15 21:48:16 +000022 print "=== Testing definitions output code ==="
23 execfile(defsoutput, {}, {})
Jack Jansenebd01062000-05-14 22:05:36 +000024 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 == OBJECT and m == "InMode":
36 classname = "Method"
37 listname = "methods"
38 return classname, listname
39
40 def makeblacklistnames(self):
41 return [
Jack Jansend9c01a52000-05-15 15:36:52 +000042 "HRDisposeReference",
Jack Jansenebd01062000-05-14 22:05:36 +000043 ]
44
45 def makeblacklisttypes(self):
46 return [
47 "HRNewURLUPP",
48 "HRURLToFSSpecUPP",
49 "HRWasURLVisitedUPP",
50 ]
51
52 def makerepairinstructions(self):
53 return [
54 ([('char', '*', 'OutMode'), ('UInt32', '*', 'InMode')],
55 [('InBuffer', '*', 'InMode')]),
56 ]
57
58 def writeinitialdefs(self):
59 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
60
61
62if __name__ == "__main__":
63 main()