| 1 | # Scan <Controls.h>, generating ctlgen.py.
|
|---|
| 2 | import sys
|
|---|
| 3 | import os
|
|---|
| 4 | from bgenlocations import TOOLBOXDIR, BGENDIR
|
|---|
| 5 | sys.path.append(BGENDIR)
|
|---|
| 6 |
|
|---|
| 7 | from scantools import Scanner
|
|---|
| 8 |
|
|---|
| 9 | def main():
|
|---|
| 10 | # input = "Controls.h" # Universal Headers < 3.3
|
|---|
| 11 | input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
|
|---|
| 12 | output = "ctlgen.py"
|
|---|
| 13 | defsoutput = TOOLBOXDIR + "Controls.py"
|
|---|
| 14 | scanner = MyScanner(input, output, defsoutput)
|
|---|
| 15 | scanner.scan()
|
|---|
| 16 | scanner.close()
|
|---|
| 17 | print "=== Testing definitions output code ==="
|
|---|
| 18 | execfile(defsoutput, {}, {})
|
|---|
| 19 | print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
|
|---|
| 20 | import ctlsupport
|
|---|
| 21 | print "=== Done. It's up to you to compile Ctlmodule.c ==="
|
|---|
| 22 |
|
|---|
| 23 | class MyScanner(Scanner):
|
|---|
| 24 |
|
|---|
| 25 | def destination(self, type, name, arglist):
|
|---|
| 26 | classname = "Function"
|
|---|
| 27 | listname = "functions"
|
|---|
| 28 | if arglist:
|
|---|
| 29 | t, n, m = arglist[0]
|
|---|
| 30 | if t in ("ControlHandle", "ControlRef") and m == "InMode":
|
|---|
| 31 | classname = "Method"
|
|---|
| 32 | listname = "methods"
|
|---|
| 33 | return classname, listname
|
|---|
| 34 |
|
|---|
| 35 | def writeinitialdefs(self):
|
|---|
| 36 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
|---|
| 37 | self.defsfile.write("from Carbon.TextEdit import *\n")
|
|---|
| 38 | self.defsfile.write("from Carbon.QuickDraw import *\n")
|
|---|
| 39 | self.defsfile.write("from Carbon.Dragconst import *\n")
|
|---|
| 40 | self.defsfile.write("from Carbon.CarbonEvents import *\n")
|
|---|
| 41 | self.defsfile.write("from Carbon.Appearance import *\n")
|
|---|
| 42 | self.defsfile.write("kDataBrowserItemAnyState = -1\n")
|
|---|
| 43 | self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n")
|
|---|
| 44 | self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n")
|
|---|
| 45 | self.defsfile.write("\n")
|
|---|
| 46 |
|
|---|
| 47 | def makeblacklistnames(self):
|
|---|
| 48 | return [
|
|---|
| 49 | 'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
|
|---|
| 50 | 'DisposeControl', # Generated manually
|
|---|
| 51 | 'KillControls', # Implied by close of dialog
|
|---|
| 52 | 'SetCtlAction',
|
|---|
| 53 | 'TrackControl', # Generated manually
|
|---|
| 54 | 'HandleControlClick', # Generated manually
|
|---|
| 55 | 'SetControlData', # Generated manually
|
|---|
| 56 | 'GetControlData', # Generated manually
|
|---|
| 57 | 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
|
|---|
| 58 | 'kDataBrowserClientPropertyFlagsMask', # ditto
|
|---|
| 59 | 'kDataBrowserItemAnyState', # and ditto
|
|---|
| 60 | # The following are unavailable for static 68k (appearance manager)
|
|---|
| 61 | ## 'GetBevelButtonMenuValue',
|
|---|
| 62 | ## 'SetBevelButtonMenuValue',
|
|---|
| 63 | ## 'GetBevelButtonMenuHandle',
|
|---|
| 64 | ## 'SetBevelButtonTransform',
|
|---|
| 65 | 'SetBevelButtonGraphicAlignment',
|
|---|
| 66 | 'SetBevelButtonTextAlignment',
|
|---|
| 67 | 'SetBevelButtonTextPlacement',
|
|---|
| 68 | ## 'SetImageWellTransform',
|
|---|
| 69 | ## 'GetTabContentRect',
|
|---|
| 70 | ## 'SetTabEnabled',
|
|---|
| 71 | ## 'SetDisclosureTriangleLastValue',
|
|---|
| 72 | ## # Unavailable in CW Pro 3 libraries
|
|---|
| 73 | ## 'SetUpControlTextColor',
|
|---|
| 74 | ## # Unavailable in Jack's CW Pro 5.1 libraries
|
|---|
| 75 | ## 'GetControlRegion',
|
|---|
| 76 | ## 'RemoveControlProperty',
|
|---|
| 77 | ## 'IsValidControlHandle',
|
|---|
| 78 | ## 'SetControl32BitMinimum',
|
|---|
| 79 | ## 'GetControl32BitMinimum',
|
|---|
| 80 | ## 'SetControl32BitMaximum',
|
|---|
| 81 | ## 'GetControl32BitMaximum',
|
|---|
| 82 | ## 'SetControl32BitValue',
|
|---|
| 83 | ## 'GetControl32BitValue',
|
|---|
| 84 | ## 'SetControlViewSize',
|
|---|
| 85 | ## 'GetControlViewSize',
|
|---|
| 86 | # Generally Bad News
|
|---|
| 87 | 'GetControlProperty',
|
|---|
| 88 | 'SetControlProperty',
|
|---|
| 89 | 'GetControlPropertySize',
|
|---|
| 90 | 'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
|
|---|
| 91 | 'CreateTabsControl', # wrote manually
|
|---|
| 92 | 'GetControlAction', # too much effort for too little usefulness
|
|---|
| 93 |
|
|---|
| 94 | # too lazy for now
|
|---|
| 95 | 'GetImageWellContentInfo',
|
|---|
| 96 | 'GetBevelButtonContentInfo',
|
|---|
| 97 | # OS8 only
|
|---|
| 98 | 'GetAuxiliaryControlRecord',
|
|---|
| 99 | 'SetControlColor',
|
|---|
| 100 | ]
|
|---|
| 101 |
|
|---|
| 102 | def makeblacklisttypes(self):
|
|---|
| 103 | return [
|
|---|
| 104 | 'ProcPtr',
|
|---|
| 105 | # 'ControlActionUPP',
|
|---|
| 106 | 'Ptr',
|
|---|
| 107 | 'ControlDefSpec', # Don't know how to do this yet
|
|---|
| 108 | 'ControlDefSpec_ptr', # ditto
|
|---|
| 109 | 'Collection', # Ditto
|
|---|
| 110 | # not-yet-supported stuff in Universal Headers 3.4:
|
|---|
| 111 | 'ControlColorUPP',
|
|---|
| 112 | 'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
|
|---|
| 113 | # 'ControlTabEntry_ptr', # XXX needed for tabs
|
|---|
| 114 | # 'ControlButtonContentInfoPtr',
|
|---|
| 115 | # 'ControlButtonContentInfo', # XXX ugh: a union
|
|---|
| 116 | # 'ControlButtonContentInfo_ptr', # XXX ugh: a union
|
|---|
| 117 | 'ListDefSpec_ptr', # XXX see _Listmodule.c, tricky but possible
|
|---|
| 118 | 'DataBrowserItemID_ptr', # XXX array of UInt32, for BrowserView
|
|---|
| 119 | 'DataBrowserItemUPP',
|
|---|
| 120 | 'DataBrowserItemDataRef', # XXX void *
|
|---|
| 121 | 'DataBrowserCallbacks', # difficult struct
|
|---|
| 122 | 'DataBrowserCallbacks_ptr',
|
|---|
| 123 | 'DataBrowserCustomCallbacks',
|
|---|
| 124 | 'DataBrowserCustomCallbacks_ptr',
|
|---|
| 125 | ## 'DataBrowserTableViewColumnDesc',
|
|---|
| 126 | ## 'DataBrowserListViewColumnDesc',
|
|---|
| 127 | 'CFDataRef',
|
|---|
| 128 | 'DataBrowserListViewHeaderDesc', # difficult struct
|
|---|
| 129 | ]
|
|---|
| 130 |
|
|---|
| 131 | def makerepairinstructions(self):
|
|---|
| 132 | return [
|
|---|
| 133 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
|
|---|
| 134 | [("InBuffer", "*", "*")]),
|
|---|
| 135 |
|
|---|
| 136 | ([("void", "*", "OutMode"), ("long", "*", "InMode"),
|
|---|
| 137 | ("long", "*", "OutMode")],
|
|---|
| 138 | [("VarVarOutBuffer", "*", "InOutMode")]),
|
|---|
| 139 |
|
|---|
| 140 | ## # For TrackControl
|
|---|
| 141 | ## ([("ProcPtr", "actionProc", "InMode")],
|
|---|
| 142 | ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
|
|---|
| 143 | ## ([("ControlActionUPP", "actionProc", "InMode")],
|
|---|
| 144 | ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
|
|---|
| 145 |
|
|---|
| 146 | # For GetControlTitle
|
|---|
| 147 | ([('Str255', 'title', 'InMode')],
|
|---|
| 148 | [('Str255', 'title', 'OutMode')]),
|
|---|
| 149 |
|
|---|
| 150 | ([("ControlHandle", "*", "OutMode")],
|
|---|
| 151 | [("ExistingControlHandle", "*", "*")]),
|
|---|
| 152 | ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
|
|---|
| 153 | [("ExistingControlHandle", "*", "*")]),
|
|---|
| 154 |
|
|---|
| 155 | ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
|
|---|
| 156 | [("void", "*", "ReturnMode")]),
|
|---|
| 157 |
|
|---|
| 158 | ([("DataBrowserListViewColumnDesc", "*", "OutMode")],
|
|---|
| 159 | [("DataBrowserListViewColumnDesc", "*", "InMode")]),
|
|---|
| 160 |
|
|---|
| 161 | ([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
|
|---|
| 162 | [("ControlButtonContentInfoPtr", '*', "OutMode")]),
|
|---|
| 163 |
|
|---|
| 164 | ([("ControlButtonContentInfo", '*', "OutMode")],
|
|---|
| 165 | [("ControlButtonContentInfo", '*', "InMode")]),
|
|---|
| 166 |
|
|---|
| 167 | ([("ControlActionUPP", 'liveTrackingProc', "InMode")],
|
|---|
| 168 | [("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
|
|---|
| 169 | ]
|
|---|
| 170 |
|
|---|
| 171 | if __name__ == "__main__":
|
|---|
| 172 | main()
|
|---|