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.
9 BGENDIR
=os
.path
.join(sys
.prefix
, ':Tools:bgen:bgen')
11 BGENDIR
="../../../Tools/bgen/bgen"
12 sys
.path
.append(BGENDIR
)
13 from scantools
import Scanner
14 from bgenlocations
import TOOLBOXDIR
21 output
= SHORT
+ "gen.py"
22 defsoutput
= "@Scrap.py"
23 scanner
= MyScanner(input, output
, defsoutput
)
26 print "=== Done scanning and generating, now importing the generated code... ==="
27 exec "import " + SHORT
+ "support"
28 print "=== Done. It's up to you to compile it now! ==="
30 class MyScanner(Scanner
):
32 def destination(self
, type, name
, arglist
):
33 classname
= "Function"
34 listname
= "functions"
37 if t
== 'ScrapRef' and m
== "InMode":
40 return classname
, listname
42 def makeblacklistnames(self
):
44 "GetScrapFlavorInfoList",
47 def makegreylist(self
):
49 ('#if !TARGET_API_MAC_CARBON', [
55 ('#if TARGET_API_MAC_CARBON', [
56 'CallInScrapPromises',
60 def makeblacklisttypes(self
):
62 'ScrapPromiseKeeperUPP',
65 def makerepairinstructions(self
):
67 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
68 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
71 if __name__
== "__main__":