Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | # Scan <Controls.h>, generating ctlgen.py. |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 2 | import sys |
| 3 | import os |
| 4 | BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') |
| 5 | sys.path.append(BGENDIR) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 6 | |
| 7 | from scantools import Scanner |
Jack Jansen | c574b43 | 1996-04-12 16:26:59 +0000 | [diff] [blame] | 8 | from bgenlocations import TOOLBOXDIR |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 9 | |
| 10 | def main(): |
| 11 | input = "Controls.h" |
| 12 | output = "ctlgen.py" |
Jack Jansen | c574b43 | 1996-04-12 16:26:59 +0000 | [diff] [blame] | 13 | defsoutput = TOOLBOXDIR + "Controls.py" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 14 | scanner = MyScanner(input, output, defsoutput) |
| 15 | scanner.scan() |
| 16 | scanner.close() |
| 17 | print "=== Done scanning and generating, now doing 'import ctlsupport' ===" |
| 18 | import ctlsupport |
| 19 | print "=== Done. It's up to you to compile Ctlmodule.c ===" |
| 20 | |
| 21 | class MyScanner(Scanner): |
| 22 | |
| 23 | def destination(self, type, name, arglist): |
| 24 | classname = "Function" |
| 25 | listname = "functions" |
| 26 | if arglist: |
| 27 | t, n, m = arglist[0] |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 28 | if t in ("ControlHandle", "ControlRef") and m == "InMode": |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 29 | classname = "Method" |
| 30 | listname = "methods" |
| 31 | return classname, listname |
| 32 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 33 | def writeinitialdefs(self): |
| 34 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 35 | self.defsfile.write("from TextEdit import *\n") |
| 36 | self.defsfile.write("from QuickDraw import *\n") |
| 37 | self.defsfile.write("\n") |
| 38 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 39 | def makeblacklistnames(self): |
| 40 | return [ |
Jack Jansen | cfb60ee | 1996-10-01 10:46:46 +0000 | [diff] [blame] | 41 | 'DisposeControl', # Generated manually |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 42 | 'KillControls', # Implied by close of dialog |
| 43 | 'SetCtlAction', |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 44 | 'TrackControl', # Generated manually |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 45 | 'HandleControlClick', # Generated manually |
| 46 | 'SetControlData', # Generated manually |
| 47 | 'GetControlData', # Generated manually |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 48 | 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition |
| 49 | 'kControlProgressBarIndeterminateTag', # ditto |
| 50 | # The following are unavailable for static 68k (appearance manager) |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 51 | ## 'GetBevelButtonMenuValue', |
| 52 | ## 'SetBevelButtonMenuValue', |
| 53 | ## 'GetBevelButtonMenuHandle', |
| 54 | ## 'SetBevelButtonTransform', |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 55 | 'SetBevelButtonGraphicAlignment', |
| 56 | 'SetBevelButtonTextAlignment', |
| 57 | 'SetBevelButtonTextPlacement', |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 58 | ## 'SetImageWellTransform', |
| 59 | ## 'GetTabContentRect', |
| 60 | ## 'SetTabEnabled', |
| 61 | ## 'SetDisclosureTriangleLastValue', |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 62 | ## # Unavailable in CW Pro 3 libraries |
| 63 | ## 'SetUpControlTextColor', |
| 64 | ## # Unavailable in Jack's CW Pro 5.1 libraries |
| 65 | ## 'GetControlRegion', |
| 66 | ## 'RemoveControlProperty', |
| 67 | ## 'IsValidControlHandle', |
| 68 | ## 'SetControl32BitMinimum', |
| 69 | ## 'GetControl32BitMinimum', |
| 70 | ## 'SetControl32BitMaximum', |
| 71 | ## 'GetControl32BitMaximum', |
| 72 | ## 'SetControl32BitValue', |
| 73 | ## 'GetControl32BitValue', |
| 74 | ## 'SetControlViewSize', |
| 75 | ## 'GetControlViewSize', |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 76 | # Generally Bad News |
| 77 | 'GetControlProperty', |
| 78 | 'SetControlProperty', |
| 79 | 'GetControlPropertySize', |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 80 | ] |
| 81 | |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 82 | def makegreylist(self): |
| 83 | return [ |
| 84 | ('#ifndef TARGET_API_MAC_CARBON', [ |
| 85 | 'GetAuxiliaryControlRecord', |
| 86 | 'SetControlColor', |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame^] | 87 | # These have suddenly disappeared in UH 3.3.2... |
| 88 | 'GetBevelButtonMenuValue', |
| 89 | 'SetBevelButtonMenuValue', |
| 90 | 'GetBevelButtonMenuHandle', |
| 91 | 'SetBevelButtonTransform', |
| 92 | 'SetImageWellTransform', |
| 93 | 'GetTabContentRect', |
| 94 | 'SetTabEnabled', |
| 95 | 'SetDisclosureTriangleLastValue', |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 96 | ])] |
| 97 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 98 | def makeblacklisttypes(self): |
| 99 | return [ |
| 100 | 'ProcPtr', |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 101 | 'ControlActionUPP', |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 102 | 'ControlButtonContentInfoPtr', |
| 103 | 'Ptr', |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 104 | ] |
| 105 | |
| 106 | def makerepairinstructions(self): |
| 107 | return [ |
| 108 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 109 | [("InBuffer", "*", "*")]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 110 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 111 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 112 | ("long", "*", "OutMode")], |
| 113 | [("VarVarOutBuffer", "*", "InOutMode")]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 114 | |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 115 | ## # For TrackControl |
| 116 | ## ([("ProcPtr", "actionProc", "InMode")], |
| 117 | ## [("FakeType('(ControlActionUPP)0')", "*", "*")]), |
| 118 | ## ([("ControlActionUPP", "actionProc", "InMode")], |
| 119 | ## [("FakeType('(ControlActionUPP)0')", "*", "*")]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 120 | |
Jack Jansen | 4100900 | 1999-03-07 20:05:20 +0000 | [diff] [blame] | 121 | # For GetControlTitle |
| 122 | ([('Str255', 'title', 'InMode')], |
| 123 | [('Str255', 'title', 'OutMode')]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 124 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 125 | ([("ControlHandle", "*", "OutMode")], |
| 126 | [("ExistingControlHandle", "*", "*")]), |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 127 | ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers |
| 128 | [("ExistingControlHandle", "*", "*")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 129 | ] |
| 130 | |
| 131 | if __name__ == "__main__": |
| 132 | main() |