| 1 |
|
| 2 |
import sys |
| 3 |
from bgenlocations import TOOLBOXDIR, BGENDIR |
| 4 |
sys.path.append(BGENDIR) |
| 5 |
|
| 6 |
from scantools import Scanner |
| 7 |
|
| 8 |
def main(): |
| 9 |
|
| 10 |
input = ["Controls.h", "ControlDefinitions.h"] |
| 11 |
output = "ctlgen.py" |
| 12 |
defsoutput = TOOLBOXDIR + "Controls.py" |
| 13 |
scanner = MyScanner(input, output, defsoutput) |
| 14 |
scanner.scan() |
| 15 |
scanner.close() |
| 16 |
print "=== Testing definitions output code ===" |
| 17 |
execfile(defsoutput, {}, {}) |
| 18 |
print "=== Done scanning and generating, now doing 'import ctlsupport' ===" |
| 19 |
import ctlsupport |
| 20 |
print "=== Done. It's up to you to compile Ctlmodule.c ===" |
| 21 |
|
| 22 |
class MyScanner(Scanner): |
| 23 |
|
| 24 |
def destination(self, type, name, arglist): |
| 25 |
classname = "Function" |
| 26 |
listname = "functions" |
| 27 |
if arglist: |
| 28 |
t, n, m = arglist[0] |
| 29 |
if t in ("ControlHandle", "ControlRef") and m == "InMode": |
| 30 |
classname = "Method" |
| 31 |
listname = "methods" |
| 32 |
return classname, listname |
| 33 |
|
| 34 |
def writeinitialdefs(self): |
| 35 |
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 36 |
self.defsfile.write("from Carbon.TextEdit import *\n") |
| 37 |
self.defsfile.write("from Carbon.QuickDraw import *\n") |
| 38 |
self.defsfile.write("from Carbon.Dragconst import *\n") |
| 39 |
self.defsfile.write("from Carbon.CarbonEvents import *\n") |
| 40 |
self.defsfile.write("from Carbon.Appearance import *\n") |
| 41 |
self.defsfile.write("kDataBrowserItemAnyState = -1\n") |
| 42 |
self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n") |
| 43 |
self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n") |
| 44 |
self.defsfile.write("\n") |
| 45 |
|
| 46 |
def makeblacklistnames(self): |
| 47 |
return [ |
| 48 |
'FindControlUnderMouse', |
| 49 |
'DisposeControl', |
| 50 |
'KillControls', |
| 51 |
'SetCtlAction', |
| 52 |
'TrackControl', |
| 53 |
'HandleControlClick', |
| 54 |
'SetControlData', |
| 55 |
'GetControlData', |
| 56 |
'kControlBevelButtonCenterPopupGlyphTag', |
| 57 |
'kDataBrowserClientPropertyFlagsMask', |
| 58 |
'kDataBrowserItemAnyState', |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
'SetBevelButtonGraphicAlignment', |
| 65 |
'SetBevelButtonTextAlignment', |
| 66 |
'SetBevelButtonTextPlacement', |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
'GetControlProperty', |
| 87 |
'SetControlProperty', |
| 88 |
'GetControlPropertySize', |
| 89 |
'SendControlMessage', |
| 90 |
'CreateTabsControl', |
| 91 |
'GetControlAction', |
| 92 |
|
| 93 |
|
| 94 |
'GetImageWellContentInfo', |
| 95 |
'GetBevelButtonContentInfo', |
| 96 |
|
| 97 |
'GetAuxiliaryControlRecord', |
| 98 |
'SetControlColor', |
| 99 |
] |
| 100 |
|
| 101 |
def makeblacklisttypes(self): |
| 102 |
return [ |
| 103 |
'ProcPtr', |
| 104 |
|
| 105 |
'Ptr', |
| 106 |
'ControlDefSpec', |
| 107 |
'ControlDefSpec_ptr', |
| 108 |
'Collection', |
| 109 |
|
| 110 |
'ControlColorUPP', |
| 111 |
'ControlKind', |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
'ListDefSpec_ptr', |
| 117 |
'DataBrowserItemID_ptr', |
| 118 |
'DataBrowserItemUPP', |
| 119 |
'DataBrowserItemDataRef', |
| 120 |
'DataBrowserCallbacks', |
| 121 |
'DataBrowserCallbacks_ptr', |
| 122 |
'DataBrowserCustomCallbacks', |
| 123 |
'DataBrowserCustomCallbacks_ptr', |
| 124 |
|
| 125 |
|
| 126 |
'CFDataRef', |
| 127 |
'DataBrowserListViewHeaderDesc', |
| 128 |
] |
| 129 |
|
| 130 |
def makerepairinstructions(self): |
| 131 |
return [ |
| 132 |
([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 133 |
[("InBuffer", "*", "*")]), |
| 134 |
|
| 135 |
([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 136 |
("long", "*", "OutMode")], |
| 137 |
[("VarVarOutBuffer", "*", "InOutMode")]), |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
([('Str255', 'title', 'InMode')], |
| 147 |
[('Str255', 'title', 'OutMode')]), |
| 148 |
|
| 149 |
([("ControlHandle", "*", "OutMode")], |
| 150 |
[("ExistingControlHandle", "*", "*")]), |
| 151 |
([("ControlRef", "*", "OutMode")], |
| 152 |
[("ExistingControlHandle", "*", "*")]), |
| 153 |
|
| 154 |
([("Rect_ptr", "*", "ReturnMode")], |
| 155 |
[("void", "*", "ReturnMode")]), |
| 156 |
|
| 157 |
([("DataBrowserListViewColumnDesc", "*", "OutMode")], |
| 158 |
[("DataBrowserListViewColumnDesc", "*", "InMode")]), |
| 159 |
|
| 160 |
([("ControlButtonContentInfoPtr", 'outContent', "InMode")], |
| 161 |
[("ControlButtonContentInfoPtr", '*', "OutMode")]), |
| 162 |
|
| 163 |
([("ControlButtonContentInfo", '*', "OutMode")], |
| 164 |
[("ControlButtonContentInfo", '*', "InMode")]), |
| 165 |
|
| 166 |
([("ControlActionUPP", 'liveTrackingProc', "InMode")], |
| 167 |
[("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]), |
| 168 |
] |
| 169 |
|
| 170 |
if __name__ == "__main__": |
| 171 |
main() |