diff options
-rw-r--r-- | Mac/Lib/test/echo.py | 48 | ||||
-rw-r--r-- | Mac/Lib/toolbox/AppleEvents.py | 1 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Controls.py | 1 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Dialogs.py | 1 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Events.py | 1 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Resources.py | 1 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Sound.py | 1 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Windows.py | 1 | ||||
-rw-r--r-- | Mac/Modules/ae/aegen.py | 1 | ||||
-rw-r--r-- | Mac/Modules/ctl/ctlgen.py | 1 | ||||
-rw-r--r-- | Mac/Modules/evt/evtgen.py | 3 | ||||
-rw-r--r-- | Mac/Modules/menu/Menumodule.c | 2 | ||||
-rw-r--r-- | Mac/Modules/menu/menugen.py | 1 | ||||
-rw-r--r-- | Mac/Modules/res/Resmodule.c | 2 | ||||
-rw-r--r-- | Mac/Modules/res/resgen.py | 1 | ||||
-rw-r--r-- | Mac/Modules/res/resscan.py | 3 | ||||
-rw-r--r-- | Mac/Modules/snd/sndgen.py | 1 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenBuffer.py | 24 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenHeapBuffer.py | 12 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenStackBuffer.py | 4 |
20 files changed, 83 insertions, 27 deletions
diff --git a/Mac/Lib/test/echo.py b/Mac/Lib/test/echo.py index 616f712..20b1d77 100644 --- a/Mac/Lib/test/echo.py +++ b/Mac/Lib/test/echo.py @@ -11,6 +11,8 @@ addpack.addpack('Demo') addpack.addpack('bgen') addpack.addpack('ae') addpack.addpack('evt') +#addpack.addpack('menu') +addpack.addpack('win') import sys sys.stdout = sys.stderr @@ -20,18 +22,25 @@ import AE from AppleEvents import * import Evt from Events import * +import Menu +import Dlg +import Win +from Windows import * +import Qd + import aetools +import EasyDialogs kHighLevelEvent = 23 # Not defined anywhere for Python yet? def main(): echo = EchoServer() - MacOS.EnableAppswitch(0) # Disable Python's own "event handling" + yield = MacOS.EnableAppswitch(-1) # Disable Python's own "event handling" try: - echo.mainloop() + echo.mainloop(everyEvent, 0) finally: - MacOS.EnableAppswitch(1) # Let Python have a go at events + MacOS.EnableAppswitch(yield) # Let Python have a go at events echo.close() @@ -44,6 +53,13 @@ class EchoServer: for suite in self.suites: AE.AEInstallEventHandler(suite, typeWildCard, self.aehandler) self.active = 1 + self.appleid = 1 + Menu.ClearMenuBar() + self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024") + applemenu.AppendMenu("All about echo...;(-") + applemenu.AddResMenu('DRVR') + applemenu.InsertMenu(0) + Menu.DrawMenuBar() def __del__(self): self.close() @@ -64,22 +80,38 @@ class EchoServer: self.lowlevelhandler(event) def lowlevelhandler(self, event): - what, message, when, (h, v), modifiers = event + what, message, when, where, modifiers = event + h, v = where if what == kHighLevelEvent: - print "High Level Event:", `code(message)`, `code(h | (v<<16))` + msg = "High Level Event: %s %s" % \ + (`code(message)`, `code(h | (v<<16))`) try: AE.AEProcessAppleEvent(event) - except AE.Error, msg: - print "AEProcessAppleEvent error:" + except AE.Error, err: + EasyDialogs.Message(msg + "\015AEProcessAppleEvent error: %s" % str(err)) traceback.print_exc() + else: + EasyDialogs.Message(msg + "\015OK!") elif what == keyDown: c = chr(message & charCodeMask) if c == '.' and modifiers & cmdKey: raise KeyboardInterrupt, "Command-period" MacOS.HandleEvent(event) + elif what == mouseDown: + partcode, window = Win.FindWindow(where) + if partcode == inMenuBar: + result = Menu.MenuSelect(where) + id = (result>>16) & 0xffff # Hi word + item = result & 0xffff # Lo word + if id == self.appleid: + if item == 1: + EasyDialogs.Message("Echo -- echo AppleEvents") + elif item > 1: + name = self.applemenu.GetItem(item) + Qd.OpenDeskAcc(name) elif what <> autoKey: print "Event:", (eventname(what), message, when, (h, v), modifiers) - MacOS.HandleEvent(event) +## MacOS.HandleEvent(event) def aehandler(self, request, reply): print "Apple Event", diff --git a/Mac/Lib/toolbox/AppleEvents.py b/Mac/Lib/toolbox/AppleEvents.py index b3780d0..0e1e069 100644 --- a/Mac/Lib/toolbox/AppleEvents.py +++ b/Mac/Lib/toolbox/AppleEvents.py @@ -1,4 +1,5 @@ # Generated from 'D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h' + typeBoolean = 'bool' typeChar = 'TEXT' typeSMInt = 'shor' diff --git a/Mac/Lib/toolbox/Controls.py b/Mac/Lib/toolbox/Controls.py index c95ea11..0686580 100644 --- a/Mac/Lib/toolbox/Controls.py +++ b/Mac/Lib/toolbox/Controls.py @@ -1,4 +1,5 @@ # Generated from 'D:Development:THINK C:Mac #includes:Apple #includes:Controls.h' + pushButProc = 0 checkBoxProc = 1 radioButProc = 2 diff --git a/Mac/Lib/toolbox/Dialogs.py b/Mac/Lib/toolbox/Dialogs.py index 297568c..c31bfbe 100644 --- a/Mac/Lib/toolbox/Dialogs.py +++ b/Mac/Lib/toolbox/Dialogs.py @@ -1,4 +1,5 @@ # Generated from 'D:Development:THINK C:Mac #includes:Apple #includes:Dialogs.h' + ctrlItem = 4 btnCtrl = 0 chkCtrl = 1 diff --git a/Mac/Lib/toolbox/Events.py b/Mac/Lib/toolbox/Events.py index ac32c3f..943c9e5 100644 --- a/Mac/Lib/toolbox/Events.py +++ b/Mac/Lib/toolbox/Events.py @@ -1,4 +1,5 @@ # Generated from 'D:Development:THINK C:Mac #includes:Apple #includes:Events.h' + nullEvent = 0 mouseDown = 1 mouseUp = 2 diff --git a/Mac/Lib/toolbox/Resources.py b/Mac/Lib/toolbox/Resources.py index 743c656..e2ed97a 100644 --- a/Mac/Lib/toolbox/Resources.py +++ b/Mac/Lib/toolbox/Resources.py @@ -1,4 +1,5 @@ # Generated from 'D:Development:THINK C:Mac #includes:Apple #includes:Resources.h' + resSysHeap = 64 resPurgeable = 32 resLocked = 16 diff --git a/Mac/Lib/toolbox/Sound.py b/Mac/Lib/toolbox/Sound.py index 600adcd..a65c652 100644 --- a/Mac/Lib/toolbox/Sound.py +++ b/Mac/Lib/toolbox/Sound.py @@ -1,4 +1,5 @@ # Generated from 'D:Development:THINK C:Mac #includes:Apple #includes:Sound.h' + swMode = -1 ftMode = 1 ffMode = 0 diff --git a/Mac/Lib/toolbox/Windows.py b/Mac/Lib/toolbox/Windows.py index 5d5bd7a..037000f 100644 --- a/Mac/Lib/toolbox/Windows.py +++ b/Mac/Lib/toolbox/Windows.py @@ -1,4 +1,5 @@ # Generated from 'D:Development:THINK C:Mac #includes:Apple #includes:Windows.h' + documentProc = 0 dBoxProc = 1 plainDBox = 2 diff --git a/Mac/Modules/ae/aegen.py b/Mac/Modules/ae/aegen.py index ea9b3b6..221ef97 100644 --- a/Mac/Modules/ae/aegen.py +++ b/Mac/Modules/ae/aegen.py @@ -312,3 +312,4 @@ f = AEFunction(OSErr, 'AEManagerInfo', (long, 'result', OutMode), ) functions.append(f) + diff --git a/Mac/Modules/ctl/ctlgen.py b/Mac/Modules/ctl/ctlgen.py index fcbf0f4..0a355cf 100644 --- a/Mac/Modules/ctl/ctlgen.py +++ b/Mac/Modules/ctl/ctlgen.py @@ -170,3 +170,4 @@ f = Method(short, 'GetCVariant', (ControlHandle, 'theControl', InMode), ) methods.append(f) + diff --git a/Mac/Modules/evt/evtgen.py b/Mac/Modules/evt/evtgen.py index ff30b8d..fd61c4d 100644 --- a/Mac/Modules/evt/evtgen.py +++ b/Mac/Modules/evt/evtgen.py @@ -42,6 +42,3 @@ f = Function(void, 'GetKeys', ) functions.append(f) -f = Function(long, 'TickCount', -) -functions.append(f) diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c index 78c4f60..a1308f9 100644 --- a/Mac/Modules/menu/Menumodule.c +++ b/Mac/Modules/menu/Menumodule.c @@ -50,7 +50,7 @@ typedef struct MenuObject { } MenuObject; PyObject *MenuObj_New(itself) - const MenuHandle itself; + MenuHandle itself; { MenuObject *it; it = PyObject_NEW(MenuObject, &Menu_Type); diff --git a/Mac/Modules/menu/menugen.py b/Mac/Modules/menu/menugen.py index 30315b8..2be4504 100644 --- a/Mac/Modules/menu/menugen.py +++ b/Mac/Modules/menu/menugen.py @@ -240,3 +240,4 @@ f = Function(void, 'DelMCEntries', (short, 'menuItem', InMode), ) functions.append(f) + diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c index a0e487c..aeb7958 100644 --- a/Mac/Modules/res/Resmodule.c +++ b/Mac/Modules/res/Resmodule.c @@ -50,7 +50,7 @@ typedef struct ResourceObject { } ResourceObject; PyObject *ResObj_New(itself) - const Handle itself; + Handle itself; { ResourceObject *it; if (itself == NULL) return PyMac_Error(resNotFound); diff --git a/Mac/Modules/res/resgen.py b/Mac/Modules/res/resgen.py index 3716e9e..9d817a3 100644 --- a/Mac/Modules/res/resgen.py +++ b/Mac/Modules/res/resgen.py @@ -269,3 +269,4 @@ f = ResMethod(void, 'SetResourceSize', (long, 'newSize', InMode), ) resmethods.append(f) + diff --git a/Mac/Modules/res/resscan.py b/Mac/Modules/res/resscan.py index 42bb389..d45d69e 100644 --- a/Mac/Modules/res/resscan.py +++ b/Mac/Modules/res/resscan.py @@ -38,6 +38,9 @@ class ResourcesScanner(Scanner): return [ "ReadPartialResource", "WritePartialResource", +## "RmveResource", # RemoveResource +## "SizeResource", # GetResourceSizeOnDisk +## "MaxSizeRsrc", # GetMaxResourceSize ] def makerepairinstructions(self): diff --git a/Mac/Modules/snd/sndgen.py b/Mac/Modules/snd/sndgen.py index 2c77a1f..8e02f29 100644 --- a/Mac/Modules/snd/sndgen.py +++ b/Mac/Modules/snd/sndgen.py @@ -129,3 +129,4 @@ f = SndFunction(void, 'Exp1to6', (unsigned_long, 'whichChannel', InMode), ) functions.append(f) + diff --git a/Tools/bgen/bgen/bgenBuffer.py b/Tools/bgen/bgen/bgenBuffer.py index 925b937..46f3db4 100644 --- a/Tools/bgen/bgen/bgenBuffer.py +++ b/Tools/bgen/bgen/bgenBuffer.py @@ -53,21 +53,22 @@ class FixedInputOutputBufferType(InputOnlyType): def declareSize(self, name): Output("%s %s__len__;", self.sizetype, name) + Output("int %s__in_len__;", name) def getargsFormat(self): - # XXX This only works if the size is int-sized!!! return "s#" def getargsArgs(self, name): - return "&%s__in__, &%s__len__" % (name, name) + return "&%s__in__, &%s__in_len__" % (name, name) def getargsCheck(self, name): - Output("if (%s__len__ != %s)", name, self.size) + Output("if (%s__in_len__ != %s)", name, self.size) OutLbrace() Output('PyErr_SetString(PyExc_TypeError, "buffer length should be %s");', self.size) Output("goto %s__error__;", name) OutRbrace() + Output("%s__len__ = %s__in_len__;", name, name) def passOutput(self, name): return "%s__in__, %s__out__" % (name, name) @@ -76,7 +77,7 @@ class FixedInputOutputBufferType(InputOnlyType): return "s#" def mkvalueArgs(self, name): - return "%s__out__, %s" % (name, self.size) + return "%s__out__, (int)%s" % (name, self.size) def cleanup(self, name): DedentLevel() @@ -138,7 +139,7 @@ class VarInputBufferType(FixedInputBufferType): FixedInputBufferType.__init__(self, "0", datatype, sizetype, sizeformat) def getargsCheck(self, name): - pass + Output("%s__len__ = %s__in_len__;", name, name) def passInput(self, name): return "%s__in__, %s__len__" % (name, name) @@ -161,11 +162,14 @@ class StructInputOutputBufferType(FixedInputOutputBufferType): def declareInputBuffer(self, name): Output("%s *%s__in__;", self.type, name) + def declareSize(self, name): + Output("int %s__in_len__;", name) + def declareOutputBuffer(self, name): Output("%s %s__out__;", self.type, name) def getargsArgs(self, name): - return "(char **)&%s__in__, &%s__len__" % (name, name) + return "(char **)&%s__in__, &%s__in_len__" % (name, name) def passInput(self, name): return "%s__in__" % name @@ -174,7 +178,7 @@ class StructInputOutputBufferType(FixedInputOutputBufferType): return "%s__in__, &%s__out__" % (name, name) def mkvalueArgs(self, name): - return "(char *)&%s__out__, %s" % (name, self.size) + return "(char *)&%s__out__, (int)%s" % (name, self.size) class StructCombinedInputOutputBufferType(StructInputOutputBufferType): @@ -211,6 +215,9 @@ class StructOutputBufferType(OutputOnlyBufferMixIn, StructInputOutputBufferType) Instantiate with the struct type as parameter. """ + + def declareSize(self, name): + pass def passOutput(self, name): return "&%s__out__" % name @@ -222,6 +229,9 @@ class ArrayOutputBufferType(OutputOnlyBufferMixIn, StructInputOutputBufferType): Instantiate with the struct type as parameter. """ + + def declareSize(self, name): + pass def passOutput(self, name): return "%s__out__" % name diff --git a/Tools/bgen/bgen/bgenHeapBuffer.py b/Tools/bgen/bgen/bgenHeapBuffer.py index 2c51695..c6160ba 100644 --- a/Tools/bgen/bgen/bgenHeapBuffer.py +++ b/Tools/bgen/bgen/bgenHeapBuffer.py @@ -20,17 +20,19 @@ class HeapInputOutputBufferType(FixedInputOutputBufferType): Output("%s *%s__out__;", self.datatype, name) def getargsCheck(self, name): - Output("if ((%s__out__ = malloc(%s__len__)) == NULL)", name, name) + Output("if ((%s__out__ = malloc(%s__in_len__)) == NULL)", name, name) OutLbrace() Output('PyErr_NoMemory();') Output("goto %s__error__;", name) OutRbrace() + Output("%s__len__ = %s__in_len__;", name, name) def passOutput(self, name): - return "%s__in__, %s__out__, %s__len__" % (name, name, name) + return "%s__in__, %s__out__, (%s)%s__len__" % \ + (name, name, self.sizetype, name) def mkvalueArgs(self, name): - return "%s__out__, %s__len__" % (name, name) + return "%s__out__, (int)%s__len__" % (name, name) def cleanup(self, name): Output("free(%s__out__);", name) @@ -75,10 +77,10 @@ class HeapOutputBufferType(OutputOnlyMixIn, HeapInputOutputBufferType): pass def getargsFormat(self): - return self.sizeformat + return "i" def getargsArgs(self, name): - return "&%s__len__" % name + return "&%s__in_len__" % name def passOutput(self, name): return "%s__out__, %s__len__" % (name, name) diff --git a/Tools/bgen/bgen/bgenStackBuffer.py b/Tools/bgen/bgen/bgenStackBuffer.py index b7df5bd..1b6350a 100644 --- a/Tools/bgen/bgen/bgenStackBuffer.py +++ b/Tools/bgen/bgen/bgenStackBuffer.py @@ -29,7 +29,7 @@ class VarStackOutputBufferType(StackOutputBufferType): return "%s__out__, &%s__len__" % (name, name) def mkvalueArgs(self, name): - return "%s__out__, %s__len__" % (name, name) + return "%s__out__, (int)%s__len__" % (name, name) class VarVarStackOutputBufferType(VarStackOutputBufferType): @@ -56,4 +56,4 @@ class ReturnVarStackOutputBufferType(VarStackOutputBufferType): return "%s__out__, %s__len__" % (name, name) def mkvalueArgs(self, name): - return "%s__out__, _rv" % name + return "%s__out__, (int)_rv" % name |