From 68bccc44f94f86317970498d9b26edb480cd9ebf Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@6015fed2-1504-0410-9fe1-9d1591cc4771> Date: Mon, 26 Aug 1996 18:33:32 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create tag 'r14beta3'. git-svn-id: http://svn.python.org/projects/python/tags/r14beta3@6631 6015fed2-1504-0410-9fe1-9d1591cc4771 --- Demo/pdist/new | 1 - Demo/scripts/freeze.py | 480 -- Demo/sgi/video/IN.py | 54 - Demo/sgi/video/Makefile | 7 - Demo/sgi/video/Vrecc.py | 281 - Demo/sgi/video/cam.py | 129 - Demo/sgi/video/camcorder.py | 266 - Demo/sgi/video/colorsys.py | 106 - Demo/sgi/video/i2v.c | 80 - Demo/sgi/video/makemovie.py | 218 - Demo/sgi/video/squash.c | 130 - Demo/sgi/video/squash2.c | 72 - Demo/sgi/video/statit.py | 115 - Demo/sgi/video/syncaudio.py | 94 - Demo/sgi/video/tomono.c | 165 - Demo/sgi/video/tv.py | 79 - Demo/sgi/video/v2i.c | 79 - Demo/sgi/video/vcopy.py | 134 - Demo/sgi/video/video.py | 218 - Demo/sgi/video/vinfo.py | 90 - Demo/sgi/video/vpregs.py | 28 - Demo/sgi/video/vtime.py | 106 - Demo/sockets/ChangeLog | 35 - Demo/tkinter/Tree.py | 23 - Doc/libmods.tex | 7 - Doc/libstd.tex | 7 - Doc/templates/module.tex | 122 - Include/config.h | 82 - Include/rename1.h | 360 -- Lib/builtin.py | 3 - Lib/lib-old/whatsound.py | 270 - Lib/macstat.py | 83 - Lib/newimp.py | 1570 ----- Lib/persist.py | 297 - Lib/urlopen.py | 410 -- Mac/Compat/chdir.c | 42 - Mac/Compat/dirent.h | 22 - Mac/Compat/getbootvol.c | 18 - Mac/Compat/getwd.c | 109 - Mac/Compat/macstat.c | 66 - Mac/Compat/macstat.h | 33 - Mac/Compat/mkdir.c | 28 - Mac/Compat/nfullpath.c | 75 - Mac/Compat/nfullpath.h | 1 - Mac/Compat/opendir.c | 104 - Mac/Compat/rmdir.c | 20 - Mac/Compat/sync.c | 17 - Mac/Demo/PICTbrowse/PICTbrowse.py | 165 - Mac/Demo/PICTbrowse/PICTbrowse.rsrc.hqx | 11 - Mac/Demo/PICTbrowse/PICTbrowse2.py | 187 - Mac/Demo/applescript.html | 168 - Mac/Demo/building.html | 468 -- Mac/Demo/example0.html | 75 - Mac/Demo/example0/checktext.py | 39 - Mac/Demo/example1.html | 211 - Mac/Demo/example1/InterslipControl-1.py | 92 - Mac/Demo/example1/InterslipControl-1.rsrc.hqx | 14 - Mac/Demo/example2.html | 178 - Mac/Demo/example2/InterslipControl-2.py | 116 - Mac/Demo/example2/InterslipControl-2.rsrc.hqx | 56 - Mac/Demo/imgbrowse/imgbrowse.py | 156 - Mac/Demo/index.html | 127 - Mac/Demo/interslip/InterslipLib.c | 97 - Mac/Demo/interslip/InterslipLib.h | 20 - Mac/Demo/interslip/interslipmodule.c | 225 - Mac/Demo/plugins.html | 363 -- Mac/Demo/quicktime/MovieInWindow.py | 66 - Mac/Demo/quicktime/VerySimplePlayer.py | 92 - Mac/Demo/resources/copyres.py | 57 - Mac/Demo/resources/listres.py | 60 - Mac/Demo/scripting/Eudora_Suite.py | 359 -- Mac/Demo/scripting/Standard_Suite.py | 273 - Mac/Demo/scripting/testeudora.py | 37 - Mac/Demo/sound/morse.py | 180 - Mac/Demo/sound/morselib.py | 188 - Mac/Demo/sound/playaiff.py | 45 - Mac/Demo/speech/SCRIPT | 1204 ---- Mac/Demo/speech/grail.py | 228 - Mac/Demo/speech/hum.py | 31 - Mac/Demo/textedit.html | 152 - Mac/Demo/textedit/ped.py | 345 -- Mac/Demo/using.html | 380 -- Mac/Demo/waste.html | 69 - Mac/Demo/waste/htmled.py | 826 --- Mac/Demo/waste/swed.py | 628 -- Mac/Demo/waste/wed.py | 421 -- Mac/Include/config.h | 345 -- Mac/Include/macdefs.h | 38 - Mac/Include/macglue.h | 91 - Mac/Include/pythonresources.h | 91 - Mac/Lib/Audio_mac.py | 121 - Mac/Lib/EasyDialogs.py | 173 - Mac/Lib/FrameWork.py | 857 --- Mac/Lib/MACFS.py | 30 - Mac/Lib/SoundMgr.py | 64 - Mac/Lib/audiodev.py | 241 - Mac/Lib/dbmac.py | 140 - Mac/Lib/maccache.py | 61 - Mac/Lib/macostools.py | 94 - Mac/Lib/py_resource.py | 76 - Mac/Lib/test/AEservertest.py | 211 - Mac/Lib/test/AEservertest.rsrc.hqx | 514 -- Mac/Lib/test/aete.py | 475 -- Mac/Lib/test/cmtest.py | 45 - Mac/Lib/test/ctbtest.py | 41 - Mac/Lib/test/echo.py | 159 - Mac/Lib/test/progressbar.py | 25 - Mac/Lib/test/tae.py | 112 - Mac/Lib/test/tctl.py | 20 - Mac/Lib/test/tdlg.py | 30 - Mac/Lib/test/tdlg_modeless.py | 42 - Mac/Lib/test/tell.py | 63 - Mac/Lib/test/test_finder_ae | 5 - Mac/Lib/test/test_suite.py | 25 - Mac/Lib/test/tlist.py | 92 - Mac/Lib/test/tlist_dialog.py | 79 - Mac/Lib/test/tlist_dialog.rsrc.hqx | 11 - Mac/Lib/test/tmenu.py | 68 - Mac/Lib/test/tscrollwin.py | 86 - Mac/Lib/test/tsnd.py | 18 - Mac/Lib/test/tte.py | 17 - Mac/Lib/test/ttedit.py | 81 - Mac/Lib/test/twedit.py | 86 - Mac/Lib/test/twin.py | 9 - Mac/Lib/toolbox/AEObjects.py | 61 - Mac/Lib/toolbox/AERegistry.py | 438 -- Mac/Lib/toolbox/AppleEvents.py | 104 - Mac/Lib/toolbox/AppleScript_Suite.py | 1051 ---- Mac/Lib/toolbox/Components.py | 23 - Mac/Lib/toolbox/Controls.py | 89 - Mac/Lib/toolbox/Dialogs.py | 21 - Mac/Lib/toolbox/Events.py | 63 - Mac/Lib/toolbox/Finder_Suite.py | 740 --- Mac/Lib/toolbox/Fonts.py | 32 - Mac/Lib/toolbox/Lists.py | 24 - Mac/Lib/toolbox/Menus.py | 14 - Mac/Lib/toolbox/Metrowerks_Shell_Suite.py | 747 --- Mac/Lib/toolbox/QuickDraw.py | 113 - Mac/Lib/toolbox/QuickTime.py | 234 - Mac/Lib/toolbox/Required_Suite.py | 92 - Mac/Lib/toolbox/Resources.py | 23 - Mac/Lib/toolbox/Sound.py | 102 - Mac/Lib/toolbox/Standard_Suite.py | 493 -- Mac/Lib/toolbox/Standard_URL_suite.py | 47 - Mac/Lib/toolbox/TextEdit.py | 56 - Mac/Lib/toolbox/WASTEconst.py | 87 - Mac/Lib/toolbox/WWW_Suite.py | 411 -- Mac/Lib/toolbox/Windows.py | 59 - Mac/Lib/toolbox/aepack.py | 356 -- Mac/Lib/toolbox/aetools.py | 204 - Mac/Lib/toolbox/aetypes.py | 452 -- Mac/MPW/Build | 3 - Mac/MPW/Makefile | 513 -- Mac/MPW/README | 122 - Mac/MPW/buildall | 29 - Mac/Modules/ae/AEmodule.c | 1181 ---- Mac/Modules/ae/README | 24 - Mac/Modules/ae/aescan.py | 106 - Mac/Modules/ae/aesupport.py | 202 - Mac/Modules/ae/nsremote.py | 76 - Mac/Modules/cm/Cmmodule.c | 767 --- Mac/Modules/cm/cmscan.py | 66 - Mac/Modules/cm/cmsupport.py | 108 - Mac/Modules/config.c | 243 - Mac/Modules/ctbmodule.c | 585 -- Mac/Modules/ctl/Ctlmodule.c | 713 --- Mac/Modules/ctl/ctledit.py | 8 - Mac/Modules/ctl/ctlscan.py | 68 - Mac/Modules/ctl/ctlsupport.py | 95 - Mac/Modules/dlg/Dlgmodule.c | 935 --- Mac/Modules/dlg/dlgscan.py | 83 - Mac/Modules/dlg/dlgsupport.py | 134 - Mac/Modules/evt/Evtmodule.c | 426 -- Mac/Modules/evt/evtedit.py | 6 - Mac/Modules/evt/evtscan.py | 69 - Mac/Modules/evt/evtsupport.py | 81 - Mac/Modules/fm/Fmmodule.c | 397 -- Mac/Modules/fm/fmscan.py | 47 - Mac/Modules/fm/fmsupport.py | 75 - Mac/Modules/gestaltmodule.c | 69 - Mac/Modules/list/Listmodule.c | 679 --- Mac/Modules/list/listscan.py | 74 - Mac/Modules/list/listsupport.py | 121 - Mac/Modules/macfsmodule.c | 856 --- Mac/Modules/macmodule.c | 604 -- Mac/Modules/macosmodule.c | 607 -- Mac/Modules/macspeech/README | 18 - Mac/Modules/macspeechmodule.c | 552 -- Mac/Modules/menu/Menumodule.c | 1045 ---- Mac/Modules/menu/menuedit.py | 13 - Mac/Modules/menu/menuscan.py | 56 - Mac/Modules/menu/menusupport.py | 65 - Mac/Modules/qd/Qdmodule.c | 3943 ------------- Mac/Modules/qd/qdedit.py | 29 - Mac/Modules/qd/qdscan.py | 139 - Mac/Modules/qd/qdsupport.py | 374 -- Mac/Modules/qt/Qtmodule.c | 6007 -------------------- Mac/Modules/qt/qtscan.py | 113 - Mac/Modules/qt/qtsupport.py | 224 - Mac/Modules/res/Resmodule.c | 1392 ----- Mac/Modules/res/resedit.py | 41 - Mac/Modules/res/resscan.py | 70 - Mac/Modules/res/ressupport.py | 141 - Mac/Modules/scrap/Scrapmodule.c | 202 - Mac/Modules/scrap/scrapscan.py | 46 - Mac/Modules/scrap/scrapsupport.py | 60 - Mac/Modules/snd/Sndmodule.c | 803 --- Mac/Modules/snd/sndscan.py | 109 - Mac/Modules/snd/sndsupport.py | 207 - Mac/Modules/te/TEmodule.c | 1040 ---- Mac/Modules/te/tescan.py | 61 - Mac/Modules/te/tesupport.py | 154 - Mac/Modules/waste/wastemodule.c | 1947 ------- Mac/Modules/waste/wastescan.py | 86 - Mac/Modules/waste/wastesupport.py | 403 -- Mac/Modules/win/Winmodule.c | 1354 ----- Mac/Modules/win/winedit.py | 98 - Mac/Modules/win/winscan.py | 76 - Mac/Modules/win/winsupport.py | 132 - Mac/Python/macapplet.c | 36 - Mac/Python/macapplication.c | 36 - Mac/Python/macgetargv.c | 313 - Mac/Python/macgetcompiler.c | 38 - Mac/Python/macgetmtime.c | 14 - Mac/Python/macgetpath.c | 340 -- Mac/Python/macgetplatform.c | 7 - Mac/Python/macglue.c | 834 --- Mac/Python/macguesstabsize.c | 29 - Mac/Python/macmain.c | 440 -- Mac/Python/macsetfiletype.c | 37 - Mac/Python/macshlglue.c | 66 - Mac/ReadMeOrSuffer | 130 - Mac/Relnotes-1.1 | 131 - Mac/Relnotes-1.2 | 169 - Mac/Relnotes-1.3 | 118 - Mac/Relnotes-1.3.3 | 125 - Mac/Relnotes-source | 81 - Mac/Resources/appletbundle.rsrc.hqx | 128 - Mac/Resources/bundle.rsrc.hqx | 252 - Mac/Resources/dialogs.rsrc.hqx | 60 - Mac/Resources/errors.rsrc.hqx | 596 -- Mac/Resources/gusiprefs.rsrc.hqx | 14 - Mac/Resources/pythonpath.rsrc.hqx | 17 - Mac/Resources/tkpython.rsrc.hqx | 3319 ----------- Mac/Unsupported/mactcp/MACTCPconst.py | 62 - Mac/Unsupported/mactcp/MacTCPerrors.py | 35 - Mac/Unsupported/mactcp/dnrglue.c | 301 - Mac/Unsupported/mactcp/macdnrmodule.c | 459 -- Mac/Unsupported/mactcp/mactcpmodule.c | 990 ---- Mac/Unsupported/mactcp/mactcpmodules.mu.exp | 2 - Mac/Unsupported/mactcp/mactcpmodules.mu.hqx | 210 - Mac/Unsupported/mactcp/socket.py | 304 - Mac/Unsupported/mactcp/tcpglue.c | 477 -- Mac/Unsupported/mactcp/tcpglue.h | 68 - Mac/Unsupported/stdwinmodule.mu.exp | 241 - Mac/Unsupported/stdwinmodule.mu.hqx | 180 - Mac/errno_unix.h | 18 - Mac/fopenRF.c | 336 -- Mac/mkapplet.py | 257 - Mac/mwerks/errno_unix.h | 18 - Mac/mwerks/macuseshlstart.c | 49 - Mac/mwerks/malloc/README | 80 - Mac/mwerks/malloc/calloc.c | 53 - Mac/mwerks/malloc/malloc.c | 415 -- Mac/mwerks/mwerks_applet_config.h | 4 - Mac/mwerks/mwerks_config.h | 2 - Mac/mwerks/mwerks_nonshared_config.h | 20 - Mac/mwerks/mwerks_plugin_config.h | 5 - Mac/mwerks/mwerks_shared_config.h | 21 - Mac/mwerks/mwerks_shlib_config.h | 3 - Mac/mwerks/mwerks_tkplugin_config.h | 7 - Mac/mwerks/mwfopenrf.c | 50 - Mac/mwerks/old/mwerks_cfm68k_config.h | 3 - Mac/mwerks/old/mwerks_nsgusi_config.h | 14 - Mac/mwerks/old/mwerks_nsgusitk_config.h | 9 - Mac/mwerks/old/mwerks_shgusi_config.h | 7 - Mac/mwerks/old/mwerks_tk_config.h | 5 - Mac/mwerks/projects/MWCPythonCoreRuntime.mu.hqx | 117 - Mac/mwerks/projects/PlugIns/_tkinter.CFM68K.mu.exp | 1 - Mac/mwerks/projects/PlugIns/_tkinter.CFM68K.mu.hqx | 199 - Mac/mwerks/projects/PlugIns/_tkinter.ppc.mu.exp | 1 - Mac/mwerks/projects/PlugIns/_tkinter.ppc.mu.hqx | 204 - Mac/mwerks/projects/PlugIns/ctb.CFM68K.mu.exp | 1 - Mac/mwerks/projects/PlugIns/ctb.CFM68K.mu.hqx | 183 - Mac/mwerks/projects/PlugIns/ctb.ppc.mu.exp | 1 - Mac/mwerks/projects/PlugIns/ctb.ppc.mu.hqx | 179 - .../projects/PlugIns/imgmodules.CFM68K.mu.exp | 10 - .../projects/PlugIns/imgmodules.CFM68K.mu.hqx | 288 - Mac/mwerks/projects/PlugIns/imgmodules.ppc.mu.exp | 10 - Mac/mwerks/projects/PlugIns/imgmodules.ppc.mu.hqx | 299 - Mac/mwerks/projects/PlugIns/macspeech.ppc.mu.exp | 5 - Mac/mwerks/projects/PlugIns/macspeech.ppc.mu.hqx | 175 - .../projects/PlugIns/qtmodules.CFM68K.mu.exp | 2 - .../projects/PlugIns/qtmodules.CFM68K.mu.hqx | 193 - Mac/mwerks/projects/PlugIns/qtmodules.ppc.mu.exp | 2 - Mac/mwerks/projects/PlugIns/qtmodules.ppc.mu.hqx | 206 - .../projects/PlugIns/toolboxmodules.CFM68K.mu.exp | 21 - .../projects/PlugIns/toolboxmodules.CFM68K.mu.hqx | 325 -- .../projects/PlugIns/toolboxmodules.ppc.mu.exp | 21 - .../projects/PlugIns/toolboxmodules.ppc.mu.hqx | 335 -- Mac/mwerks/projects/PlugIns/waste.CFM68K.mu.exp | 1 - Mac/mwerks/projects/PlugIns/waste.CFM68K.mu.hqx | 352 -- Mac/mwerks/projects/PlugIns/waste.ppc.mu.exp | 1 - Mac/mwerks/projects/PlugIns/waste.ppc.mu.hqx | 358 -- Mac/mwerks/projects/PlugIns/xx.CFM68K.mu.exp | 1 - Mac/mwerks/projects/PlugIns/xx.CFM68K.mu.hqx | 151 - Mac/mwerks/projects/PlugIns/xx.ppc.mu.exp | 1 - Mac/mwerks/projects/PlugIns/xx.ppc.mu.hqx | 162 - Mac/mwerks/projects/README-Projectfiles | 52 - .../MWRuntimeStaticCFM68K.mu.hqx | 138 - .../build.mac68k.shared/PythonAppletCFM68K.mu.hqx | 143 - .../build.mac68k.shared/PythonCFM68K.mu.hqx | 142 - .../build.mac68k.shared/PythonCoreCFM68K.mu.exp | 1606 ------ .../build.mac68k.shared/PythonCoreCFM68K.mu.hqx | 997 ---- .../projects/build.mac68k.stand/Python68K.mu.hqx | 1540 ----- .../build.macppc.shared/MWRuntimeStaticPPC.mu.hqx | 132 - .../build.macppc.shared/PythonAppletPPC.mu.hqx | 107 - .../build.macppc.shared/PythonCorePPC.mu.exp | 1487 ----- .../build.macppc.shared/PythonCorePPC.mu.hqx | 982 ---- .../projects/build.macppc.shared/PythonPPC.mu.hqx | 107 - .../build.macppc.stand/PythonStandalone.mu.hqx | 1556 ----- Mac/mwerks/projects/miniPythonCFM68K.mu.hqx | 862 --- Mac/mwerksglue.c | 43 - Mac/scripts/BuildApplet.py | 300 - Mac/scripts/BuildApplet.rsrc.hqx | 37 - Mac/scripts/ConfigurePython.py | 144 - Mac/scripts/ConfigurePython.rsrc.hqx | 44 - Mac/scripts/EditPythonPrefs.py | 339 -- Mac/scripts/EditPythonPrefs.rsrc.hqx | 60 - Mac/scripts/FixCreator.py | 34 - Mac/scripts/MkDistr.py | 280 - Mac/scripts/MkDistr.rsrc.hqx | 31 - Mac/scripts/MkDistr_ui.py | 347 -- Mac/scripts/PackLibDir.py | 49 - Mac/scripts/PackLibDir.rsrc.hqx | 38 - Mac/scripts/RunLibScript.py | 111 - Mac/scripts/RunLibScript.rsrc.hqx | 54 - Mac/scripts/binhextree.py | 209 - Mac/scripts/crlf.py | 29 - Mac/scripts/errors.txt | 592 -- Mac/scripts/fixfiletypes.py | 54 - Mac/scripts/fullbuild.py | 167 - Mac/scripts/gensuitemodule.py | 462 -- Mac/scripts/mkestrres.py | 62 - Mac/scripts/mkfrozenresources.py | 39 - Mac/scripts/run.py | 41 - Mac/scripts/unshar.py | 71 - Mac/think/fopenRF.c | 336 -- Mac/think/macconsole/macconsole.c | 437 -- Misc/python-mode.el | 2389 -------- Python/pythonmain.c | 211 - Tools/freeze/nfreeze.py | 312 + Tools/world/world | 143 - 353 files changed, 312 insertions(+), 90033 deletions(-) delete mode 100755 Demo/pdist/new delete mode 100755 Demo/scripts/freeze.py delete mode 100755 Demo/sgi/video/IN.py delete mode 100755 Demo/sgi/video/Makefile delete mode 100755 Demo/sgi/video/Vrecc.py delete mode 100755 Demo/sgi/video/cam.py delete mode 100755 Demo/sgi/video/camcorder.py delete mode 100755 Demo/sgi/video/colorsys.py delete mode 100755 Demo/sgi/video/i2v.c delete mode 100755 Demo/sgi/video/makemovie.py delete mode 100755 Demo/sgi/video/squash.c delete mode 100755 Demo/sgi/video/squash2.c delete mode 100755 Demo/sgi/video/statit.py delete mode 100755 Demo/sgi/video/syncaudio.py delete mode 100755 Demo/sgi/video/tomono.c delete mode 100755 Demo/sgi/video/tv.py delete mode 100755 Demo/sgi/video/v2i.c delete mode 100755 Demo/sgi/video/vcopy.py delete mode 100755 Demo/sgi/video/video.py delete mode 100755 Demo/sgi/video/vinfo.py delete mode 100755 Demo/sgi/video/vpregs.py delete mode 100755 Demo/sgi/video/vtime.py delete mode 100755 Demo/sockets/ChangeLog delete mode 100644 Demo/tkinter/Tree.py delete mode 100755 Doc/libmods.tex delete mode 100755 Doc/libstd.tex delete mode 100644 Doc/templates/module.tex delete mode 100755 Include/config.h delete mode 100755 Include/rename1.h delete mode 100755 Lib/builtin.py delete mode 100644 Lib/lib-old/whatsound.py delete mode 100755 Lib/macstat.py delete mode 100755 Lib/newimp.py delete mode 100755 Lib/persist.py delete mode 100755 Lib/urlopen.py delete mode 100644 Mac/Compat/chdir.c delete mode 100644 Mac/Compat/dirent.h delete mode 100644 Mac/Compat/getbootvol.c delete mode 100644 Mac/Compat/getwd.c delete mode 100644 Mac/Compat/macstat.c delete mode 100644 Mac/Compat/macstat.h delete mode 100644 Mac/Compat/mkdir.c delete mode 100644 Mac/Compat/nfullpath.c delete mode 100644 Mac/Compat/nfullpath.h delete mode 100644 Mac/Compat/opendir.c delete mode 100644 Mac/Compat/rmdir.c delete mode 100644 Mac/Compat/sync.c delete mode 100644 Mac/Demo/PICTbrowse/PICTbrowse.py delete mode 100644 Mac/Demo/PICTbrowse/PICTbrowse.rsrc.hqx delete mode 100644 Mac/Demo/PICTbrowse/PICTbrowse2.py delete mode 100644 Mac/Demo/applescript.html delete mode 100644 Mac/Demo/building.html delete mode 100644 Mac/Demo/example0.html delete mode 100644 Mac/Demo/example0/checktext.py delete mode 100644 Mac/Demo/example1.html delete mode 100644 Mac/Demo/example1/InterslipControl-1.py delete mode 100644 Mac/Demo/example1/InterslipControl-1.rsrc.hqx delete mode 100644 Mac/Demo/example2.html delete mode 100644 Mac/Demo/example2/InterslipControl-2.py delete mode 100644 Mac/Demo/example2/InterslipControl-2.rsrc.hqx delete mode 100644 Mac/Demo/imgbrowse/imgbrowse.py delete mode 100644 Mac/Demo/index.html delete mode 100644 Mac/Demo/interslip/InterslipLib.c delete mode 100644 Mac/Demo/interslip/InterslipLib.h delete mode 100644 Mac/Demo/interslip/interslipmodule.c delete mode 100644 Mac/Demo/plugins.html delete mode 100644 Mac/Demo/quicktime/MovieInWindow.py delete mode 100644 Mac/Demo/quicktime/VerySimplePlayer.py delete mode 100644 Mac/Demo/resources/copyres.py delete mode 100644 Mac/Demo/resources/listres.py delete mode 100644 Mac/Demo/scripting/Eudora_Suite.py delete mode 100644 Mac/Demo/scripting/Standard_Suite.py delete mode 100644 Mac/Demo/scripting/testeudora.py delete mode 100644 Mac/Demo/sound/morse.py delete mode 100644 Mac/Demo/sound/morselib.py delete mode 100644 Mac/Demo/sound/playaiff.py delete mode 100644 Mac/Demo/speech/SCRIPT delete mode 100644 Mac/Demo/speech/grail.py delete mode 100644 Mac/Demo/speech/hum.py delete mode 100644 Mac/Demo/textedit.html delete mode 100644 Mac/Demo/textedit/ped.py delete mode 100644 Mac/Demo/using.html delete mode 100644 Mac/Demo/waste.html delete mode 100644 Mac/Demo/waste/htmled.py delete mode 100644 Mac/Demo/waste/swed.py delete mode 100644 Mac/Demo/waste/wed.py delete mode 100644 Mac/Include/config.h delete mode 100644 Mac/Include/macdefs.h delete mode 100644 Mac/Include/macglue.h delete mode 100644 Mac/Include/pythonresources.h delete mode 100644 Mac/Lib/Audio_mac.py delete mode 100644 Mac/Lib/EasyDialogs.py delete mode 100644 Mac/Lib/FrameWork.py delete mode 100644 Mac/Lib/MACFS.py delete mode 100644 Mac/Lib/SoundMgr.py delete mode 100644 Mac/Lib/audiodev.py delete mode 100644 Mac/Lib/dbmac.py delete mode 100644 Mac/Lib/maccache.py delete mode 100644 Mac/Lib/macostools.py delete mode 100644 Mac/Lib/py_resource.py delete mode 100644 Mac/Lib/test/AEservertest.py delete mode 100644 Mac/Lib/test/AEservertest.rsrc.hqx delete mode 100644 Mac/Lib/test/aete.py delete mode 100644 Mac/Lib/test/cmtest.py delete mode 100644 Mac/Lib/test/ctbtest.py delete mode 100644 Mac/Lib/test/echo.py delete mode 100644 Mac/Lib/test/progressbar.py delete mode 100644 Mac/Lib/test/tae.py delete mode 100644 Mac/Lib/test/tctl.py delete mode 100644 Mac/Lib/test/tdlg.py delete mode 100644 Mac/Lib/test/tdlg_modeless.py delete mode 100644 Mac/Lib/test/tell.py delete mode 100644 Mac/Lib/test/test_finder_ae delete mode 100644 Mac/Lib/test/test_suite.py delete mode 100644 Mac/Lib/test/tlist.py delete mode 100644 Mac/Lib/test/tlist_dialog.py delete mode 100644 Mac/Lib/test/tlist_dialog.rsrc.hqx delete mode 100644 Mac/Lib/test/tmenu.py delete mode 100644 Mac/Lib/test/tscrollwin.py delete mode 100644 Mac/Lib/test/tsnd.py delete mode 100644 Mac/Lib/test/tte.py delete mode 100644 Mac/Lib/test/ttedit.py delete mode 100644 Mac/Lib/test/twedit.py delete mode 100644 Mac/Lib/test/twin.py delete mode 100644 Mac/Lib/toolbox/AEObjects.py delete mode 100644 Mac/Lib/toolbox/AERegistry.py delete mode 100644 Mac/Lib/toolbox/AppleEvents.py delete mode 100644 Mac/Lib/toolbox/AppleScript_Suite.py delete mode 100644 Mac/Lib/toolbox/Components.py delete mode 100644 Mac/Lib/toolbox/Controls.py delete mode 100644 Mac/Lib/toolbox/Dialogs.py delete mode 100644 Mac/Lib/toolbox/Events.py delete mode 100644 Mac/Lib/toolbox/Finder_Suite.py delete mode 100644 Mac/Lib/toolbox/Fonts.py delete mode 100644 Mac/Lib/toolbox/Lists.py delete mode 100644 Mac/Lib/toolbox/Menus.py delete mode 100644 Mac/Lib/toolbox/Metrowerks_Shell_Suite.py delete mode 100644 Mac/Lib/toolbox/QuickDraw.py delete mode 100644 Mac/Lib/toolbox/QuickTime.py delete mode 100644 Mac/Lib/toolbox/Required_Suite.py delete mode 100644 Mac/Lib/toolbox/Resources.py delete mode 100644 Mac/Lib/toolbox/Sound.py delete mode 100644 Mac/Lib/toolbox/Standard_Suite.py delete mode 100644 Mac/Lib/toolbox/Standard_URL_suite.py delete mode 100644 Mac/Lib/toolbox/TextEdit.py delete mode 100644 Mac/Lib/toolbox/WASTEconst.py delete mode 100644 Mac/Lib/toolbox/WWW_Suite.py delete mode 100644 Mac/Lib/toolbox/Windows.py delete mode 100644 Mac/Lib/toolbox/aepack.py delete mode 100644 Mac/Lib/toolbox/aetools.py delete mode 100644 Mac/Lib/toolbox/aetypes.py delete mode 100644 Mac/MPW/Build delete mode 100644 Mac/MPW/Makefile delete mode 100644 Mac/MPW/README delete mode 100644 Mac/MPW/buildall delete mode 100644 Mac/Modules/ae/AEmodule.c delete mode 100644 Mac/Modules/ae/README delete mode 100644 Mac/Modules/ae/aescan.py delete mode 100644 Mac/Modules/ae/aesupport.py delete mode 100644 Mac/Modules/ae/nsremote.py delete mode 100644 Mac/Modules/cm/Cmmodule.c delete mode 100644 Mac/Modules/cm/cmscan.py delete mode 100644 Mac/Modules/cm/cmsupport.py delete mode 100644 Mac/Modules/config.c delete mode 100644 Mac/Modules/ctbmodule.c delete mode 100644 Mac/Modules/ctl/Ctlmodule.c delete mode 100644 Mac/Modules/ctl/ctledit.py delete mode 100644 Mac/Modules/ctl/ctlscan.py delete mode 100644 Mac/Modules/ctl/ctlsupport.py delete mode 100644 Mac/Modules/dlg/Dlgmodule.c delete mode 100644 Mac/Modules/dlg/dlgscan.py delete mode 100644 Mac/Modules/dlg/dlgsupport.py delete mode 100644 Mac/Modules/evt/Evtmodule.c delete mode 100644 Mac/Modules/evt/evtedit.py delete mode 100644 Mac/Modules/evt/evtscan.py delete mode 100644 Mac/Modules/evt/evtsupport.py delete mode 100644 Mac/Modules/fm/Fmmodule.c delete mode 100644 Mac/Modules/fm/fmscan.py delete mode 100644 Mac/Modules/fm/fmsupport.py delete mode 100644 Mac/Modules/gestaltmodule.c delete mode 100644 Mac/Modules/list/Listmodule.c delete mode 100644 Mac/Modules/list/listscan.py delete mode 100644 Mac/Modules/list/listsupport.py delete mode 100644 Mac/Modules/macfsmodule.c delete mode 100644 Mac/Modules/macmodule.c delete mode 100644 Mac/Modules/macosmodule.c delete mode 100644 Mac/Modules/macspeech/README delete mode 100644 Mac/Modules/macspeechmodule.c delete mode 100644 Mac/Modules/menu/Menumodule.c delete mode 100644 Mac/Modules/menu/menuedit.py delete mode 100644 Mac/Modules/menu/menuscan.py delete mode 100644 Mac/Modules/menu/menusupport.py delete mode 100644 Mac/Modules/qd/Qdmodule.c delete mode 100644 Mac/Modules/qd/qdedit.py delete mode 100644 Mac/Modules/qd/qdscan.py delete mode 100644 Mac/Modules/qd/qdsupport.py delete mode 100644 Mac/Modules/qt/Qtmodule.c delete mode 100644 Mac/Modules/qt/qtscan.py delete mode 100644 Mac/Modules/qt/qtsupport.py delete mode 100644 Mac/Modules/res/Resmodule.c delete mode 100644 Mac/Modules/res/resedit.py delete mode 100644 Mac/Modules/res/resscan.py delete mode 100644 Mac/Modules/res/ressupport.py delete mode 100644 Mac/Modules/scrap/Scrapmodule.c delete mode 100644 Mac/Modules/scrap/scrapscan.py delete mode 100644 Mac/Modules/scrap/scrapsupport.py delete mode 100644 Mac/Modules/snd/Sndmodule.c delete mode 100644 Mac/Modules/snd/sndscan.py delete mode 100644 Mac/Modules/snd/sndsupport.py delete mode 100644 Mac/Modules/te/TEmodule.c delete mode 100644 Mac/Modules/te/tescan.py delete mode 100644 Mac/Modules/te/tesupport.py delete mode 100644 Mac/Modules/waste/wastemodule.c delete mode 100644 Mac/Modules/waste/wastescan.py delete mode 100644 Mac/Modules/waste/wastesupport.py delete mode 100644 Mac/Modules/win/Winmodule.c delete mode 100644 Mac/Modules/win/winedit.py delete mode 100644 Mac/Modules/win/winscan.py delete mode 100644 Mac/Modules/win/winsupport.py delete mode 100644 Mac/Python/macapplet.c delete mode 100644 Mac/Python/macapplication.c delete mode 100644 Mac/Python/macgetargv.c delete mode 100644 Mac/Python/macgetcompiler.c delete mode 100644 Mac/Python/macgetmtime.c delete mode 100644 Mac/Python/macgetpath.c delete mode 100644 Mac/Python/macgetplatform.c delete mode 100644 Mac/Python/macglue.c delete mode 100644 Mac/Python/macguesstabsize.c delete mode 100644 Mac/Python/macmain.c delete mode 100644 Mac/Python/macsetfiletype.c delete mode 100644 Mac/Python/macshlglue.c delete mode 100644 Mac/ReadMeOrSuffer delete mode 100644 Mac/Relnotes-1.1 delete mode 100644 Mac/Relnotes-1.2 delete mode 100644 Mac/Relnotes-1.3 delete mode 100644 Mac/Relnotes-1.3.3 delete mode 100644 Mac/Relnotes-source delete mode 100644 Mac/Resources/appletbundle.rsrc.hqx delete mode 100644 Mac/Resources/bundle.rsrc.hqx delete mode 100644 Mac/Resources/dialogs.rsrc.hqx delete mode 100644 Mac/Resources/errors.rsrc.hqx delete mode 100644 Mac/Resources/gusiprefs.rsrc.hqx delete mode 100644 Mac/Resources/pythonpath.rsrc.hqx delete mode 100644 Mac/Resources/tkpython.rsrc.hqx delete mode 100644 Mac/Unsupported/mactcp/MACTCPconst.py delete mode 100644 Mac/Unsupported/mactcp/MacTCPerrors.py delete mode 100644 Mac/Unsupported/mactcp/dnrglue.c delete mode 100644 Mac/Unsupported/mactcp/macdnrmodule.c delete mode 100644 Mac/Unsupported/mactcp/mactcpmodule.c delete mode 100644 Mac/Unsupported/mactcp/mactcpmodules.mu.exp delete mode 100644 Mac/Unsupported/mactcp/mactcpmodules.mu.hqx delete mode 100644 Mac/Unsupported/mactcp/socket.py delete mode 100644 Mac/Unsupported/mactcp/tcpglue.c delete mode 100644 Mac/Unsupported/mactcp/tcpglue.h delete mode 100644 Mac/Unsupported/stdwinmodule.mu.exp delete mode 100644 Mac/Unsupported/stdwinmodule.mu.hqx delete mode 100644 Mac/errno_unix.h delete mode 100644 Mac/fopenRF.c delete mode 100644 Mac/mkapplet.py delete mode 100644 Mac/mwerks/errno_unix.h delete mode 100644 Mac/mwerks/macuseshlstart.c delete mode 100644 Mac/mwerks/malloc/README delete mode 100644 Mac/mwerks/malloc/calloc.c delete mode 100644 Mac/mwerks/malloc/malloc.c delete mode 100644 Mac/mwerks/mwerks_applet_config.h delete mode 100644 Mac/mwerks/mwerks_config.h delete mode 100644 Mac/mwerks/mwerks_nonshared_config.h delete mode 100644 Mac/mwerks/mwerks_plugin_config.h delete mode 100644 Mac/mwerks/mwerks_shared_config.h delete mode 100644 Mac/mwerks/mwerks_shlib_config.h delete mode 100644 Mac/mwerks/mwerks_tkplugin_config.h delete mode 100644 Mac/mwerks/mwfopenrf.c delete mode 100644 Mac/mwerks/old/mwerks_cfm68k_config.h delete mode 100644 Mac/mwerks/old/mwerks_nsgusi_config.h delete mode 100644 Mac/mwerks/old/mwerks_nsgusitk_config.h delete mode 100644 Mac/mwerks/old/mwerks_shgusi_config.h delete mode 100644 Mac/mwerks/old/mwerks_tk_config.h delete mode 100644 Mac/mwerks/projects/MWCPythonCoreRuntime.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/_tkinter.CFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/_tkinter.CFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/_tkinter.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/_tkinter.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/ctb.CFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/ctb.CFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/ctb.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/ctb.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/imgmodules.CFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/imgmodules.CFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/imgmodules.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/imgmodules.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/macspeech.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/macspeech.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/qtmodules.CFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/qtmodules.CFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/qtmodules.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/qtmodules.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/toolboxmodules.CFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/toolboxmodules.CFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/toolboxmodules.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/toolboxmodules.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/waste.CFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/waste.CFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/waste.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/waste.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/xx.CFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/xx.CFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/xx.ppc.mu.exp delete mode 100644 Mac/mwerks/projects/PlugIns/xx.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/README-Projectfiles delete mode 100644 Mac/mwerks/projects/build.mac68k.shared/MWRuntimeStaticCFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/build.mac68k.shared/PythonAppletCFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/build.mac68k.shared/PythonCFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/build.mac68k.shared/PythonCoreCFM68K.mu.exp delete mode 100644 Mac/mwerks/projects/build.mac68k.shared/PythonCoreCFM68K.mu.hqx delete mode 100644 Mac/mwerks/projects/build.mac68k.stand/Python68K.mu.hqx delete mode 100644 Mac/mwerks/projects/build.macppc.shared/MWRuntimeStaticPPC.mu.hqx delete mode 100644 Mac/mwerks/projects/build.macppc.shared/PythonAppletPPC.mu.hqx delete mode 100644 Mac/mwerks/projects/build.macppc.shared/PythonCorePPC.mu.exp delete mode 100644 Mac/mwerks/projects/build.macppc.shared/PythonCorePPC.mu.hqx delete mode 100644 Mac/mwerks/projects/build.macppc.shared/PythonPPC.mu.hqx delete mode 100644 Mac/mwerks/projects/build.macppc.stand/PythonStandalone.mu.hqx delete mode 100644 Mac/mwerks/projects/miniPythonCFM68K.mu.hqx delete mode 100644 Mac/mwerksglue.c delete mode 100644 Mac/scripts/BuildApplet.py delete mode 100644 Mac/scripts/BuildApplet.rsrc.hqx delete mode 100644 Mac/scripts/ConfigurePython.py delete mode 100644 Mac/scripts/ConfigurePython.rsrc.hqx delete mode 100644 Mac/scripts/EditPythonPrefs.py delete mode 100644 Mac/scripts/EditPythonPrefs.rsrc.hqx delete mode 100644 Mac/scripts/FixCreator.py delete mode 100644 Mac/scripts/MkDistr.py delete mode 100644 Mac/scripts/MkDistr.rsrc.hqx delete mode 100644 Mac/scripts/MkDistr_ui.py delete mode 100644 Mac/scripts/PackLibDir.py delete mode 100644 Mac/scripts/PackLibDir.rsrc.hqx delete mode 100644 Mac/scripts/RunLibScript.py delete mode 100644 Mac/scripts/RunLibScript.rsrc.hqx delete mode 100644 Mac/scripts/binhextree.py delete mode 100755 Mac/scripts/crlf.py delete mode 100644 Mac/scripts/errors.txt delete mode 100644 Mac/scripts/fixfiletypes.py delete mode 100644 Mac/scripts/fullbuild.py delete mode 100644 Mac/scripts/gensuitemodule.py delete mode 100644 Mac/scripts/mkestrres.py delete mode 100644 Mac/scripts/mkfrozenresources.py delete mode 100644 Mac/scripts/run.py delete mode 100644 Mac/scripts/unshar.py delete mode 100644 Mac/think/fopenRF.c delete mode 100644 Mac/think/macconsole/macconsole.c delete mode 100644 Misc/python-mode.el delete mode 100644 Python/pythonmain.c create mode 100755 Tools/freeze/nfreeze.py delete mode 100755 Tools/world/world diff --git a/Demo/pdist/new b/Demo/pdist/new deleted file mode 100755 index 9daeafb986..0000000000 --- a/Demo/pdist/new +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/Demo/scripts/freeze.py b/Demo/scripts/freeze.py deleted file mode 100755 index be6d263584..0000000000 --- a/Demo/scripts/freeze.py +++ /dev/null @@ -1,480 +0,0 @@ -#! /usr/local/bin/python - -# Given a Python script, create a binary that runs the script. -# The binary is 100% independent of Python libraries and binaries. -# It will not contain any Python source code -- only "compiled" Python -# (as initialized static variables containing marshalled code objects). -# It even does the right thing for dynamically loaded modules! -# The module search path of the binary is set to the current directory. -# -# Some problems remain: -# - It's highly non-portable, since it knows about paths and libraries -# (there's a customization section though, and it knows how to -# distinguish an SGI from a Sun SPARC system -- adding knowledge -# about more systems is left as an exercise for the reader). -# - You need to have the Python source tree lying around as well as -# the "libpython.a" used to generate the Python binary. -# - For scripts that use many modules it generates absurdly large -# files (frozen.c and config.o as well as the final binary), -# and is consequently rather slow. -# -# Caveats: -# - The search for modules sometimes finds modules that are never -# actually imported since the code importing them is never executed. -# - If an imported module isn't found, you get a warning but the -# process of freezing continues. The binary will fail if it -# actually tries to import one of these modules. -# - This often happens with the module 'mac', which module 'os' tries -# to import (to determine whether it is running on a Macintosh). -# You can ignore the warning about this. -# - If the program dynamically reads or generates Python code and -# executes it, this code may reference built-in or library modules -# that aren't present in the frozen binary, and this will fail. -# - Your program may be using external data files, e.g. compiled -# forms definitions (*.fd). These aren't incorporated. Since -# sys.path in the resulting binary only contains '.', if your -# program searches its data files along sys.path (as the 'flp' -# modules does to find its forms definitions), you may need to -# change the program to extend the search path or instruct its users -# to set the environment variable PYTHONPATH to point to your data -# files. -# -# Usage hints: -# - If you have a bunch of scripts that you want to freeze, instead -# of freezing each of them separately, you might consider writing -# a tiny main script that looks at sys.argv[0] and then imports -# the corresponding module. You can then make links to the -# frozen binary named after the various scripts you support. -# Pass the additional scripts as arguments after the main script. -# A minimal script to do this is the following. -# import sys, posixpath -# exec('import ' + posixpath.basename(sys.argv[0]) + '\n') - - -import os -import sys -import regex -import getopt -import regsub -import string -import marshal - -# Function to join two pathnames with a slash in between -j = os.path.join - -################################## -# START OF CONFIGURATION SECTION # -################################## - -# Attempt to guess machine architecture -if os.path.exists('/usr/lib/libgl_s'): ARCH = 'sgi' -elif os.path.exists('/etc/issue'): ARCH = 'sequent' -else: ARCH = 'sun4' - -# Site parametrizations (change to match your site) -CC = 'cc' # C compiler -TOP = '/ufs/guido/src' # Parent of all source trees -PYTHON = j(TOP, 'python') # Top of the Python source tree -SRC = j(PYTHON, 'src') # Python source directory -BLD = j(PYTHON, 'build.' + ARCH) # Python build directory -#BLD = SRC # Use this if you build in SRC - -LIBINST = '/ufs/guido/src/python/irix4/tmp/lib/python/lib' # installed libraries -INCLINST = '/ufs/guido/src/python/irix4/tmp/include/Py' # installed include files - -# Other packages (change to match your site) -DL = j(TOP, 'dl') # Top of the dl source tree -DL_DLD = j(TOP, 'dl-dld') # The dl-dld source directory -DLD = j(TOP, 'dld-3.2.3') # The dld source directory -FORMS = j(TOP, 'forms') # Top of the FORMS source tree -STDWIN = j(TOP, 'stdwin') # Top of the STDWIN source tree -READLINE = j(TOP, 'readline.' + ARCH) # Top of the GNU Readline source tree -SUN_X11 = '/usr/local/X11R5/lib/libX11.a' - -# File names (usually no need to change) -LIBP = [ # Main Python libraries - j(LIBINST, 'libPython.a'), - j(LIBINST, 'libParser.a'), - j(LIBINST, 'libObjects.a'), - j(LIBINST, 'libModules.a') - ] -CONFIG_IN = j(LIBINST, 'config.c.in') # Configuration source file -FMAIN = j(LIBINST, 'frozenmain.c') # Special main source file - -# Libraries needed when linking. First tuple item is built-in module -# for which it is needed (or '*' for always), rest are ld arguments. -# There is a separate list per architecture. -libdeps_sgi = [ \ - ('stdwin', j(STDWIN, 'Build/' + ARCH + '/x11/lib/lib.a')), \ - ('fl', j(FORMS, 'FORMS/libforms.a'), '-lfm_s'), \ - ('*', j(READLINE, 'libreadline.a'), '-ltermcap'), \ - ('al', '-laudio'), \ - ('sv', '-lsvideo', '-lXext'), \ - ('cd', '-lcdaudio', '-lds'), \ - ('cl', '-lcl'), \ - ('imgfile', '-limage', '-lgutil', '-lm'), \ - ('mpz', '/ufs/guido/src/gmp/libgmp.a'), \ - ('*', '-lsun'), \ - ('*', j(DL, 'libdl.a'), '-lmld'), \ - ('*', '-lmpc'), \ - ('fm', '-lfm_s'), \ - ('gl', '-lgl_s', '-lX11_s'), \ - ('stdwin', '-lX11_s'), \ - ('*', '-lm'), \ - ('*', '-lc_s'), \ - ] -libdeps_sun4 = [ \ - ('*', '-Bstatic'), \ - ('stdwin', j(STDWIN, 'Build/' + ARCH + '/x11/lib/lib.a')), \ - ('*', j(READLINE, 'libreadline.a')), \ - ('*', '-lm'), \ - ('*', j(DL_DLD,'libdl.a'), j(DLD,'libdld.a')), \ - ('*', SUN_X11), \ - ('*', '-ltermcap'), \ - ('*', '-lc'), \ - ] -libdeps_sequent = [ \ - ('*', j(LIBINST, 'libreadline.a'), '-ltermcap'), \ - ('*', '-lsocket'), \ - ('*', '-linet'), \ - ('*', '-lnsl'), \ - ('*', '-lm'), \ - ('*', '-lc'), \ - ] -libdeps = eval('libdeps_' + ARCH) - -################################ -# END OF CONFIGURATION SECTION # -################################ - -# Exception used when scanfile fails -NoSuchFile = 'NoSuchFile' - -# Global options -quiet = 0 # -q -verbose = 0 # -v -noexec = 0 # -n -nowrite = 0 # -N -ofile = 'a.out' # -o file - -# Main program -- argument parsing etc. -def main(): - global quiet, verbose, noexec, nowrite, ofile - try: - opts, args = getopt.getopt(sys.argv[1:], 'nNo:qv') - except getopt.error, msg: - usage(str(msg)) - sys.exit(2) - for o, a in opts: - if o == '-n': noexec = 1 - if o == '-N': nowrite = 1 - if o == '-o': ofile = a - if o == '-q': verbose = 0; quiet = 1 - if o == '-v': verbose = verbose + 1; quiet = 0 - if len(args) < 1: - usage('please pass at least one file argument') - sys.exit(2) - process(args[0], args[1:]) - -# Print usage message to stderr -def usage(*msgs): - sys.stdout = sys.stderr - for msg in msgs: print msg - print 'Usage: freeze [options] scriptfile [modulefile ...]' - print '-n : generate the files but don\'t compile and link' - print '-N : don\'t write frozen.c (do compile unless -n given)' - print '-o file : binary output file (default a.out)' - print '-q : quiet (no messages at all except errors)' - print '-v : verbose (lots of extra messages)' - -# Process the script file -def process(filename, addmodules): - global noexec - # - if not quiet: print 'Computing needed modules ...' - todo = {} - todo['__main__'] = filename - for name in addmodules: - mod = os.path.basename(name) - if mod[-3:] == '.py': mod = mod[:-3] - todo[mod] = name - try: - dict = closure(todo) - except NoSuchFile, filename: - sys.stderr.write('Can\'t open file %s\n' % filename) - sys.exit(1) - # - mods = dict.keys() - mods.sort() - # - if verbose: - print '%-15s %s' % ('Module', 'Filename') - for mod in mods: - print '%-15s %s' % (`mod`, dict[mod]) - # - if not quiet: print 'Looking for dynamically linked modules ...' - dlmodules = [] - objs = [] - libs = [] - for mod in mods: - if dict[mod][-2:] == '.o': - if verbose: print 'Found', mod, dict[mod] - dlmodules.append(mod) - objs.append(dict[mod]) - libsname = dict[mod][:-2] + '.libs' - try: - f = open(libsname, 'r') - except IOError: - f = None - if f: - libtext = f.read() - f.close() - for lib in string.split(libtext): - if lib in libs: libs.remove(lib) - libs.append(lib) - # - if not nowrite: - if not quiet: print 'Writing frozen.c ...' - writefrozen('frozen.c', dict) - else: - if not quiet: print 'NOT writing frozen.c ...' - # -## if not dlmodules: - if 0: - config = CONFIG - if not quiet: print 'Using existing', config, '...' - else: - config = 'tmpconfig.c' - if nowrite: - if not quiet: print 'NOT writing config.c ...' - else: - if not quiet: - print 'Writing config.c with dl modules ...' - f = open(CONFIG_IN, 'r') - g = open(config, 'w') - m1 = regex.compile('-- ADDMODULE MARKER 1 --') - m2 = regex.compile('-- ADDMODULE MARKER 2 --') - builtinmodules = [] - stdmodules = ('sys', '__main__', '__builtin__', - 'marshal') - todomodules = builtinmodules + dlmodules - for mod in dict.keys(): - if dict[mod] == '' and \ - mod not in stdmodules: - builtinmodules.append(mod) - while 1: - line = f.readline() - if not line: break - g.write(line) - if m1.search(line) >= 0: - if verbose: print 'Marker 1 ...' - for mod in todomodules: - g.write('extern void init' + \ - mod + '();\n') - if m2.search(line) >= 0: - if verbose: print 'Marker 2 ...' - for mod in todomodules: - g.write('{"' + mod + \ - '", init' + mod + '},\n') - g.close() - # - if not quiet: - if noexec: print 'Generating compilation commands ...' - else: print 'Starting compilation ...' - defs = ['-DNO_MAIN', '-DUSE_FROZEN', '-DPYTHONPATH=\'"."\''] - # - incs = ['-I.', '-I' + INCLINST] - if dict.has_key('stdwin'): - incs.append('-I' + j(STDWIN, 'H')) - # - srcs = [config, FMAIN] - # - if type(LIBP) == type(''): - libs.append(LIBP) - else: - for lib in LIBP: - libs.append(lib) - for item in libdeps: - m = item[0] - if m == '*' or dict.has_key(m): - for l in item[1:]: - if l in libs: libs.remove(l) - libs.append(l) - # - sts = 0 - # - cmd = CC + ' -c' - cmd = cmd + ' ' + string.join(defs) - cmd = cmd + ' ' + string.join(incs) - cmd = cmd + ' ' + string.join(srcs) - print cmd - # - if not noexec: - sts = os.system(cmd) - if sts: - print 'Exit status', sts, '-- turning on -n' - noexec = 1 - # - for s in srcs: - s = os.path.basename(s) - if s[-2:] == '.c': s = s[:-2] - o = s + '.o' - objs.insert(0, o) - # - cmd = CC - cmd = cmd + ' ' + string.join(objs) - cmd = cmd + ' ' + string.join(libs) - cmd = cmd + ' -o ' + ofile - print cmd - # - if not noexec: - sts = os.system(cmd) - if sts: - print 'Exit status', sts - else: - print 'Done.' - # - if not quiet and not noexec and sts == 0: - print 'Note: consider this:'; print '\tstrip', ofile - # - sys.exit(sts) - - -# Generate code for a given module -def makecode(filename): - if filename[-2:] == '.o': - return None - try: - f = open(filename, 'r') - except IOError: - return None - if verbose: print 'Making code from', filename, '...' - text = f.read() - code = compile(text, filename, 'exec') - f.close() - return marshal.dumps(code) - - -# Write the C source file containing the frozen Python code -def writefrozen(filename, dict): - f = open(filename, 'w') - codelist = [] - for mod in dict.keys(): - codestring = makecode(dict[mod]) - if codestring is not None: - codelist.append((mod, codestring)) - write = sys.stdout.write - save_stdout = sys.stdout - try: - sys.stdout = f - for mod, codestring in codelist: - if verbose: - write('Writing initializer for %s\n'%mod) - print 'static unsigned char M_' + mod + '[' + \ - str(len(codestring)) + '+1] = {' - for i in range(0, len(codestring), 16): - for c in codestring[i:i+16]: - print str(ord(c)) + ',', - print - print '};' - print 'struct frozen {' - print ' char *name;' - print ' unsigned char *code;' - print ' int size;' - print '} frozen_modules[] = {' - for mod, codestring in codelist: - print ' {"' + mod + '",', - print 'M_' + mod + ',', - print str(len(codestring)) + '},' - print ' {0, 0, 0} /* sentinel */' - print '};' - finally: - sys.stdout = save_stdout - f.close() - - -# Determine the names and filenames of the modules imported by the -# script, recursively. This is done by scanning for lines containing -# import statements. (The scanning has only superficial knowledge of -# Python syntax and no knowledge of semantics, so in theory the result -# may be incorrect -- however this is quite unlikely if you don't -# intentionally obscure your Python code.) - -# Compute the closure of scanfile() -- special first file because of script -def closure(todo): - done = {} - while todo: - newtodo = {} - for modname in todo.keys(): - if not done.has_key(modname): - filename = todo[modname] - if filename is None: - filename = findmodule(modname) - done[modname] = filename - if filename in ('', ''): - continue - modules = scanfile(filename) - for m in modules: - if not done.has_key(m): - newtodo[m] = None - todo = newtodo - return done - -# Scan a file looking for import statements -importstr = '\(^\|:\)[ \t]*import[ \t]+\([a-zA-Z0-9_, \t]+\)' -fromstr = '\(^\|:\)[ \t]*from[ \t]+\([a-zA-Z0-9_]+\)[ \t]+import[ \t]+' -isimport = regex.compile(importstr) -isfrom = regex.compile(fromstr) -def scanfile(filename): - allmodules = {} - try: - f = open(filename, 'r') - except IOError, msg: - raise NoSuchFile, filename - while 1: - line = f.readline() - if not line: break # EOF - while line[-2:] == '\\\n': # Continuation line - line = line[:-2] + ' ' - line = line + f.readline() - if isimport.search(line) >= 0: - rawmodules = isimport.group(2) - modules = string.splitfields(rawmodules, ',') - for i in range(len(modules)): - modules[i] = string.strip(modules[i]) - elif isfrom.search(line) >= 0: - modules = [isfrom.group(2)] - else: - continue - for mod in modules: - allmodules[mod] = None - f.close() - return allmodules.keys() - -# Find the file containing a module, given its name; None if not found -builtins = sys.builtin_module_names + ['sys'] -def findmodule(modname): - if modname in builtins: return '' - for dirname in sys.path: - dlfullname = os.path.join(dirname, modname + 'module.o') - try: - f = open(dlfullname, 'r') - except IOError: - f = None - if f: - f.close() - return dlfullname - fullname = os.path.join(dirname, modname + '.py') - try: - f = open(fullname, 'r') - except IOError: - continue - f.close() - return fullname - if not quiet: - sys.stderr.write('Warning: module %s not found\n' % modname) - return '' - - -# Call the main program -main() diff --git a/Demo/sgi/video/IN.py b/Demo/sgi/video/IN.py deleted file mode 100755 index ffc2852596..0000000000 --- a/Demo/sgi/video/IN.py +++ /dev/null @@ -1,54 +0,0 @@ -IPPROTO_IP = 0 -IPPROTO_ICMP = 1 -IPPROTO_IGMP = 2 -IPPROTO_GGP = 3 -IPPROTO_TCP = 6 -IPPROTO_EGP = 8 -IPPROTO_PUP = 12 -IPPROTO_UDP = 17 -IPPROTO_IDP = 22 -IPPROTO_TP = 29 -IPPROTO_XTP = 36 -IPPROTO_EON = 80 -IPPROTO_RAW = 255 -IPPROTO_MAX = 256 -IPPORT_RESERVED = 1024 -IPPORT_USERRESERVED = 5000 -IN_CLASSA_NET = 0xff000000 -IN_CLASSA_NSHIFT = 24 -IN_CLASSA_HOST = 0x00ffffff -IN_CLASSA_MAX = 128 -IN_CLASSB_NET = 0xffff0000 -IN_CLASSB_NSHIFT = 16 -IN_CLASSB_HOST = 0x0000ffff -IN_CLASSB_MAX = 65536 -IN_CLASSC_NET = 0xffffff00 -IN_CLASSC_NSHIFT = 8 -IN_CLASSC_HOST = 0x000000ff -IN_CLASSD_NET = 0xf0000000 -IN_CLASSD_NSHIFT = 28 -IN_CLASSD_HOST = 0x0fffffff -INADDR_ANY = 0x00000000 -INADDR_BROADCAST = 0xffffffff -INADDR_LOOPBACK = 0x7F000001 -INADDR_UNSPEC_GROUP = 0xe0000000 -INADDR_ALLHOSTS_GROUP = 0xe0000001 -INADDR_MAX_LOCAL_GROUP = 0xe00000ff -INADDR_NONE = 0xffffffff -IN_LOOPBACKNET = 127 -IP_OPTIONS = 1 -IP_HDRINCL = 7 -IP_TOS = 8 -IP_TTL = 9 -IP_RECVOPTS = 10 -IP_RECVRETOPTS = 11 -IP_RECVDSTADDR = 12 -IP_RETOPTS = 13 -IP_MULTICAST_IF = 2 -IP_MULTICAST_TTL = 3 -IP_MULTICAST_LOOP = 4 -IP_ADD_MEMBERSHIP = 5 -IP_DROP_MEMBERSHIP = 6 -IP_DEFAULT_MULTICAST_TTL = 1 -IP_DEFAULT_MULTICAST_LOOP = 1 -IP_MAX_MEMBERSHIPS = 20 diff --git a/Demo/sgi/video/Makefile b/Demo/sgi/video/Makefile deleted file mode 100755 index 266ea52587..0000000000 --- a/Demo/sgi/video/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: v2i i2v - -v2i: v2i.o - $(CC) v2i.o -limage -o v2i - -i2v: i2v.o - $(CC) i2v.o -limage -o i2v diff --git a/Demo/sgi/video/Vrecc.py b/Demo/sgi/video/Vrecc.py deleted file mode 100755 index 6a539f8192..0000000000 --- a/Demo/sgi/video/Vrecc.py +++ /dev/null @@ -1,281 +0,0 @@ -#! /ufs/guido/bin/sgi/python-405 -#! /ufs/guido/bin/sgi/python - -# Capture a continuous CMIF movie using the Indigo video library and board - - -# Usage: -# -# makemovie [-r rate] [-w width] [moviefile] - - -# Options: -# -# -r rate : capture 1 out of every 'rate' frames (default 1) -# -w width : initial window width (default interactive placement) -# -d : drop fields if needed -# -g bits : greyscale (2, 4 or 8 bits) -# -G : 2-bit greyscale dithered -# -m : monochrome dithered -# -M value : monochrome tresholded with value -# -f : Capture fields (in stead of frames) -# -n number : Capture 'number' fields (default 60) -# -# moviefile : here goes the movie data (default film.video); -# the format is documented in cmif-film.ms - - -# User interface: -# -# Start the application. Resize the window to the desired movie size. -# Press the left mouse button to start recording, release it to end -# recording. You can record as many times as you wish, but each time -# you overwrite the output file(s), so only the last recording is -# kept. -# -# Press ESC or select the window manager Quit or Close window option -# to quit. If you quit before recording anything, the output file(s) -# are not touched. - - -import sys -sys.path.append('/ufs/guido/src/video') -import sv, SV -import VFile -import gl, GL, DEVICE -import al, AL -import time -import posix -import getopt -import string -import imageop -import sgi - -# Main program - -def main(): - format = SV.RGB8_FRAMES - rate = 1 - width = 0 - drop = 0 - mono = 0 - grey = 0 - greybits = 0 - monotreshold = -1 - fields = 0 - number = 60 - - opts, args = getopt.getopt(sys.argv[1:], 'r:w:dg:mM:Gfn:') - for opt, arg in opts: - if opt == '-r': - rate = string.atoi(arg) - if rate < 2: - sys.stderr.write('-r rate must be >= 2\n') - sys.exit(2) - elif opt == '-w': - width = string.atoi(arg) - elif opt == '-d': - drop = 1 - elif opt == '-g': - grey = 1 - greybits = string.atoi(arg) - if not greybits in (2,4,8): - print 'Only 2, 4 or 8 bit greyscale supported' - elif opt == '-G': - grey = 1 - greybits = -2 - elif opt == '-m': - mono = 1 - elif opt == '-M': - mono = 1 - monotreshold = string.atoi(arg) - elif opt == '-f': - fields = 1 - elif opt == '-n': - number = string.atoi(arg) - - if args[2:]: - sys.stderr.write('usage: Vrec [options] [file]\n') - sys.exit(2) - - if args: - filename = args[0] - else: - filename = 'film.video' - - v = sv.OpenVideo() - # Determine maximum window size based on signal standard - param = [SV.BROADCAST, 0] - v.GetParam(param) - if param[1] == SV.PAL: - x = SV.PAL_XMAX - y = SV.PAL_YMAX - elif param[1] == SV.NTSC: - x = SV.NTSC_XMAX - y = SV.NTSC_YMAX - else: - print 'Unknown video standard', param[1] - sys.exit(1) - - gl.foreground() - gl.maxsize(x, y) - gl.keepaspect(x, y) - gl.stepunit(8, 6) - if width: - gl.prefsize(width, width*3/4) - win = gl.winopen(filename) - if width: - gl.maxsize(x, y) - gl.keepaspect(x, y) - gl.stepunit(8, 6) - gl.winconstraints() - x, y = gl.getsize() - print x, 'x', y - - v.SetSize(x, y) - - if drop: - param = [SV.FIELDDROP, 1, SV.GENLOCK, SV.GENLOCK_OFF] - else: - param = [SV.FIELDDROP, 0, SV.GENLOCK, SV.GENLOCK_ON] - if mono or grey: - param = param+[SV.COLOR, SV.MONO, SV.INPUT_BYPASS, 1] - else: - param = param+[SV.COLOR, SV.DEFAULT_COLOR, SV.INPUT_BYPASS, 0] - v.SetParam(param) - - v.BindGLWindow(win, SV.IN_REPLACE) - - gl.qdevice(DEVICE.LEFTMOUSE) - gl.qdevice(DEVICE.WINQUIT) - gl.qdevice(DEVICE.WINSHUT) - gl.qdevice(DEVICE.ESCKEY) - - print 'Press left mouse to start recording' - - while 1: - dev, val = gl.qread() - if dev == DEVICE.LEFTMOUSE: - if val == 1: - info = format, x, y, number, rate - record(v, info, filename, mono, grey, \ - greybits, monotreshold, fields) - elif dev == DEVICE.REDRAW: - # Window resize (or move) - x, y = gl.getsize() - print x, 'x', y - v.SetSize(x, y) - v.BindGLWindow(win, SV.IN_REPLACE) - elif dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT): - # Quit - v.CloseVideo() - gl.winclose(win) - break - - -# Record until the mouse is released (or any other GL event) -# XXX audio not yet supported - -def record(v, info, filename, mono, grey, greybits, monotreshold, fields): - import thread - format, x, y, number, rate = info - fps = 59.64 # Fields per second - # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!) - tpf = 1000.0 / fps # Time per field in msec - # - # Go grab - # - gl.wintitle('(rec) ' + filename) - try: - ninfo, data, bitvec = v.CaptureBurst(info) - except sv.error, arg: - print 'CaptureBurst failed:', arg - print 'info:', info - gl.wintitle(filename) - return - gl.wintitle('(save) '+ filename) - # - # Check results - # - if info <> ninfo: - print 'Sorry, format changed.' - print 'Wanted:',info - print 'Got :',ninfo - gl.wintitle(filename) - return - # print bitvec - if x*y*number <> len(data): - print 'Funny data length: wanted',x,'*',y,'*', number,'=',\ - x*y*number,'got',len(data) - gl.wintitle(filename) - return - # - # Save - # - if filename: - # - # Construct header and write it - # - vout = VFile.VoutFile().init(filename) - if mono: - vout.format = 'mono' - elif grey and greybits == 8: - vout.format = 'grey' - elif grey: - vout.format = 'grey'+`abs(greybits)` - else: - vout.format = 'rgb8' - vout.width = x - vout.height = y - if fields: - vout.packfactor = (1,-2) - else: - print 'Sorry, can only save fields at the moment' - gl.wintitle(filename) - return - vout.writeheader() - # - # Compute convertor, if needed - # - convertor = None - if grey: - if greybits == 2: - convertor = imageop.grey2grey2 - elif greybits == 4: - convertor = imageop.grey2grey4 - elif greybits == -2: - convertor = imageop.dither2grey2 - fieldsize = x*y/2 - nskipped = 0 - realframeno = 0 - tpf = 1000 / 50.0 #XXXX - for frameno in range(0, number*2): - if frameno <> 0 and \ - bitvec[frameno] == bitvec[frameno-1]: - nskipped = nskipped + 1 - continue - # - # Save field. - # XXXX Works only for fields and top-to-bottom - # - start = frameno*fieldsize - field = data[start:start+fieldsize] - if convertor: - field = convertor(field, x, y) - elif mono and monotreshold >= 0: - field = imageop.grey2mono(field, x, y, \ - 1, monotreshold) - elif mono: - field = imageop.dither2mono(field, x, y) - vout.writeframe(int(realframeno*tpf), field, None) - print 'Skipped',nskipped,'duplicate frames' - vout.close() - - gl.wintitle('(done) ' + filename) - -# Don't forget to call the main program - -try: - main() -except KeyboardInterrupt: - print '[Interrupt]' diff --git a/Demo/sgi/video/cam.py b/Demo/sgi/video/cam.py deleted file mode 100755 index fa8966f8b3..0000000000 --- a/Demo/sgi/video/cam.py +++ /dev/null @@ -1,129 +0,0 @@ -import sys -from socket import * -from gl import * -from GL import * -from DEVICE import * -from time import millitimer - -HS = 40 # Header size (must be same as in tv.py) - -# Rely on UDP packet (de)fragmentation for smoother images -# (Changed for broadcast) -MAX = 16000 - -PF = 2 # Default packfactor - -# Default receiver station is voorn. -# Kwik has no yellow pages, so... -HOST = '192.16.201.121' -PORT = 5555 - -if sys.argv[1:]: - PF = eval(sys.argv[1]) - -if sys.argv[2:]: - HOST = sys.argv[2] - if HOST == 'all': - HOST = '' - MAX = 1400 - -PF2 = PF*PF - -def main(): - centerx, centery = 400, 300 - - foreground() - wid = winopen('cam') - RGBmode() - doublebuffer() - gconfig() - qdevice(ESCKEY) - - w, h = getsize() - ortho2(0, w, 0, h) - w = w/PF*PF - h = h/PF*PF - - readsource(SRC_FRAMEGRABBER) - - s = socket(AF_INET, SOCK_DGRAM) - if HOST == '': - s.allowbroadcast(1) - addr = HOST, PORT - - bytesperline = w/PF2 - linesperchunk = MAX/bytesperline - linesperchunk = linesperchunk/PF*PF - nchunks = (h+linesperchunk-1)/linesperchunk - - print 'MAX=', MAX, - print 'linesperchunk=', linesperchunk, - print 'nchunks=', nchunks, - print 'w=', w, 'h=', h - - x1, x2 = 0, w-1 - - t1 = millitimer() - nframes = 0 - fps = 0 - - msg = '' - - while 1: - while qtest(): - dev, val = qread() - if dev == REDRAW: - reshapeviewport() - w, h = getsize() - ortho2(0, w, 0, h) - w = w/PF*PF - h = h/PF*PF - - bytesperline = w/PF2 - linesperchunk = MAX/bytesperline - linesperchunk = linesperchunk/PF*PF - nchunks = (h+linesperchunk-1)/linesperchunk - - print 'MAX=', MAX, - print 'linesperchunk=', linesperchunk, - print 'nchunks=', nchunks, - print 'w=', w, 'h=', h - - x1, x2 = 0, w-1 - - fps = 0 - - elif dev == ESCKEY: - winclose(wid) - return - - readsource(SRC_FRAMEGRABBER) - - nframes = nframes+1 - if nframes >= fps: - t2 = millitimer() - if t2 <> t1: - fps = int(10000.0*nframes/(t2-t1)) * 0.1 - msg = `fps` + ' frames/sec' - t1 = t2 - nframes = 0 - - RGBcolor(255,255,255) - cmov2i(9,9) - charstr(msg) - - swapbuffers() - rectcopy(centerx-w/2, centery-w/2, centerx+w/2, centery+w/2, 0, 0) - - for i in range(nchunks): - y1 = i*linesperchunk - y2 = y1 + linesperchunk-1 - if y2 >= h: y2 = h-1 - data = lrectread(x1, y1, x2, y2) - data2 = packrect(x2-x1+1, y2-y1+1, PF, data) - prefix = `w, h, PF, x1, y1, x2, y2` - prefix = prefix + ' ' * (HS-len(prefix)) - data3 = prefix + data2 - s.sendto(data3, addr) - -main() diff --git a/Demo/sgi/video/camcorder.py b/Demo/sgi/video/camcorder.py deleted file mode 100755 index 9b7618c436..0000000000 --- a/Demo/sgi/video/camcorder.py +++ /dev/null @@ -1,266 +0,0 @@ -from gl import * -from GL import * -from DEVICE import * -import time -import sys -import getopt -import socket -import posix -import vtime - -# Preallocation parameter -PREALLOC = 4 # Megabyte - -# Sync audio parameters -SYNCPORT = 10000 -CTLPORT = 10001 - -from vpregs import * - -class Struct(): pass -epoch = Struct() - -def getvideosize(): - w = getvideo(VP_WIDTH) - h = getvideo(VP_HEIGHT) - print 'WIDTH,HEIGHT:', w, h - print 'GB{X,Y}ORG:', getvideo(VP_GBXORG), getvideo(VP_GBYORG) - print 'FB{X,Y}ORG:', getvideo(VP_FBXORG), getvideo(VP_FBYORG) - x = 0 - y = 0 - return x,y,w,h - -framelist = [] - -def prealloc(w, h): - nbytes = w*h*4 - limit = PREALLOC*1024*1024 - total = 0 - list = [] - print 'Prealloc to', PREALLOC, 'Megabytes...' - while total+nbytes <= limit: - list.append('x'*nbytes) - total = total + nbytes - print 'Done.' - -def grabframe(f,x,y,w,h,pf): - readsource(SRC_FRONT) - if pf: - w = w/pf*pf - h = h/pf*pf - data = lrectread(x,y,x+w-1,y+h-1) - t = time.millitimer()-epoch.epoch - framelist.append(data, t) - readsource(SRC_FRAMEGRABBER) - -def saveframes(f, w, h, pf): - for data, t in framelist: - if pf: - w = w/pf*pf - h = h/pf*pf - data = packrect(w,h,pf,data) - f.write(`t` + ',' + `len(data)` + '\n') - f.write(data) - framelist[:] = [] - -def saveframe(f,x,y,w,h,pf, notime): - readsource(SRC_FRONT) - if pf: - w = w/pf*pf - h = h/pf*pf - data = lrectread(x,y,x+w-1,y+h-1) - if pf: data = packrect(w,h,pf,data) - if notime: t = 0 - else: t = time.millitimer()-epoch.epoch - f.write(`t` + ',' + `len(data)` + '\n') - f.write(data) - readsource(SRC_FRAMEGRABBER) - -def drawframe(x,y,w,h,col): - drawmode(OVERDRAW) - color(col) - bgnline() - v2i(x-1,y-1) ; v2i(x+w,y-1); v2i(x+w,y+h); v2i(x-1,y+h); v2i(x-1,y-1) - endline() - drawmode(NORMALDRAW) - -def usage(): - sys.stderr.write('Usage: camcorder ' + \ - '[-c] [-p packfactor] [-a audiomachine [-s]] [outputfile]\n') - sys.exit(2) - -def wrheader(f, w, h, pf): - f.write('CMIF video 1.0\n') - f.write(`w,h,pf` + '\n') - print 'width,height,pf:', w, h, pf, - if pf == 0: pf = 4 - print '(i.e.,', w*h*pf, 'bytes/frame)' - -def main(): - foreground() - pf = 2 - ausync = 0 - austart = 0 - optlist, args = getopt.getopt(sys.argv[1:],'ca:sp:') - for opt, arg in optlist: - if opt == '-c': - pf = 0 - elif opt == '-a': - ausync = 1 - aumachine = arg - elif opt == '-s': - austart = 1 - elif opt == '-p': - pf = int(eval(arg)) - else: - usage() - if args: - if len(args) > 1: - print 'Too many arguments' - usage() - filename = args[0] - else: - filename = 'film.video' - if austart: - if not ausync: - print 'Cannot use -s without -a' - usage() - print 'Starting audio recorder...' - posix.system('rsh '+aumachine+' syncrecord '+socket.gethostname()+' &') - if ausync: - print 'Syncing to audio recorder...' - globtime = vtime.VTime().init(1,aumachine,SYNCPORT) - ctl = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) - ctl.bind((socket.gethostname(),CTLPORT)) - aua = (socket.gethostbyname(aumachine), CTLPORT) - print 'Done.' - vidx, vidy, w, h = getvideosize() - #prefsize(w,h) - winx, winy = 1280-w-10, 1024-h-30 - prefposition(winx,winx+w-1,winy,winy+h-1) - win = winopen(filename) - f = open(filename, 'w') - w, h = getsize() - realw, realh = w, h - ####doublebuffer() - RGBmode() - gconfig() - qdevice(LEFTMOUSE) - qdevice(RKEY) - qdevice(SKEY) - qdevice(CKEY) - qdevice(PKEY) - qdevice(ESCKEY) - qdevice(WINQUIT) - qdevice(WINSHUT) - inrunning = 1 - outrunning = 0 - stop = 'stop' - readsource(SRC_FRAMEGRABBER) - mousing = 0 - epoch.epoch = time.millitimer() - stoptime = epoch.epoch - sizewritten = 0 - x, y = realw/4, realh/4 - w, h = w/2, h/2 - prealloc(w, h) - try: - drawframe(x,y,w,h,1) - nframe = 0 - num = 0 - while 1: - insingle = 0 - outsingle = 0 - if mousing: - drawframe(x,y,w,h,0) - ox, oy = getorigin() - if sizewritten: - x = getvaluator(MOUSEX)-ox - y = getvaluator(MOUSEY)-oy - else: - w = getvaluator(MOUSEX)-x-ox - h = getvaluator(MOUSEY)-y-oy - drawframe(x,y,w,h,1) - if qtest() or \ - not (mousing or inrunning or insingle or outrunning or outsingle): - ev, val = qread() - if ev == LEFTMOUSE and val == 1: - drawframe(x,y,w,h,0) - mousing = 1 - ox, oy = getorigin() - x = getvaluator(MOUSEX)-ox - y = getvaluator(MOUSEY)-oy - elif ev == LEFTMOUSE and val == 0: - if h < 0: - y, h = y+h, -h - if w < 0: - x, w = x+w, -w - mousing = 0 - if not sizewritten: - wrheader(f, w, h, pf) - sizewritten = 1 - prealloc(w, h) - elif ev == RKEY and val == 1: - if not inrunning: - ringbell() - else: - outrunning = 1 - wasstopped = time.millitimer() - stoptime - epoch.epoch = epoch.epoch + wasstopped - nframe = 0 - starttime = time.millitimer() - if ausync: - ctl.sendto(`(1,starttime)`, aua) - elif ev == PKEY and val == 1 and outrunning: - outrunning = 0 - stoptime = time.millitimer() - if ausync: - ctl.sendto(`(0,stoptime)`, aua) - fps = nframe * 1000.0 / (time.millitimer()-starttime) - print 'Recorded', nframe, - print 'frames at', 0.1*int(fps*10),'frames/sec' - print 'Saving...' - saveframes(f, w, h, pf) - print 'Done.' - elif ev == PKEY and val == 1 and not outrunning: - outsingle = 1 - elif ev == CKEY and val == 1: - inrunning = 1 - elif ev == SKEY and val == 1: - if outrunning: - ringbell() - elif inrunning: - inrunning = 0 - else: - insingle = 1 - elif ev in (ESCKEY, WINQUIT, WINSHUT): - if ausync: - ctl.sendto(`(2,time.millitimer())`, aua) - raise stop - elif ev == REDRAW: - drawframe(x,y,w,h,0) - reshapeviewport() - drawframe(x,y,w,h,1) - if inrunning or insingle: - if outrunning: - rectcopy(vidx+x,vidy+y,vidx+x+w-1,vidy+y+h-1,x,y) - else: - rectcopy(vidx,vidy,vidx+realw-1,vidx+realh-1,0,0) - ####swapbuffers() - if outrunning or outsingle: - nframe = nframe + 1 - if not sizewritten: - wrheader(f, w, h, pf) - sizewritten = 1 - if outrunning: - grabframe(f, x, y, w, h, pf) - else: - saveframe(f, x, y, w, h, pf, outsingle) - except stop: - pass - finally: - drawmode(OVERDRAW) - color(0) - clear() - -main() diff --git a/Demo/sgi/video/colorsys.py b/Demo/sgi/video/colorsys.py deleted file mode 100755 index dd3a033b26..0000000000 --- a/Demo/sgi/video/colorsys.py +++ /dev/null @@ -1,106 +0,0 @@ -# -# Module color - do color conversions -# - -ONE_THIRD=1.0/3.0 -ONE_SIXTH=1.0/6.0 -TWO_THIRD=2.0/3.0 - -def rgb_to_yiq(r,g,b): - y = 0.3*r + 0.59*g + 0.11*b - i = 0.6*r - 0.28*g - 0.32*b - q = 0.21*r- 0.52*g + 0.31*b - return (y,i,q) -def yiq_to_rgb(y,i,q): - r = y + 0.948262*i + 0.624013*q - g = y - 0.276066*i - 0.639810*q - b = y - 1.105450*i + 1.729860*q - if r < 0.0: r = 0.0 - if g < 0.0: g = 0.0 - if b < 0.0: b = 0.0 - if r > 1.0: r = 1.0 - if g > 1.0: g = 1.0 - if b > 1.0: b = 1.0 - return (r,g,b) - -def _v(m1,m2,hue): - if hue >= 1.0: hue = hue - 1.0 - if hue < 0.0: hue = hue + 1.0 - if hue < ONE_SIXTH: - return m1 + (m2-m1)*hue*6.0 - if hue < 0.5: - return m2 - if hue < TWO_THIRD: - return m1 + (m2-m1)*(TWO_THIRD-hue)*6.0 - return m1 - -def rgb_to_hls(r,g,b): - maxc = max(r,g,b) - minc = min(r,g,b) - l = (minc+maxc)/2.0 - if minc == maxc: - return 0.0, l, 0.0 - if l <= 0.5: - s = (maxc-minc)/(maxc+minc) - else: - s = (maxc-minc)/(2-maxc-minc) - rc = (maxc-r)/(maxc-minc) - gc = (maxc-g)/(maxc-minc) - bc = (maxc-b)/(maxc-minc) - if r == maxc: - h = bc-gc - elif g == maxc: - h = 2.0+rc-bc - else: - h = 4.0+gc-rc - h = h/6.0 - if h < 0.0: - h = h + 1.0 - return h,l,s -def hls_to_rgb(h,l,s): - if s == 0.0: - return l,l,l - if l <= 0.5: - m2 = l * (1.0+s) - else: - m2 = l+s-(l*s) - m1 = 2.0*l - m2 - return (_v(m1,m2,h+ONE_THIRD), _v(m1,m2,h), _v(m1,m2,h-ONE_THIRD)) - -def rgb_to_hsv(r,g,b): - maxc = max(r,g,b) - minc = min(r,g,b) - v = maxc - if minc == maxc: - return 0.0, 0.0, v - s = (maxc-minc)/maxc - rc = (maxc-r)/(maxc-minc) - gc = (maxc-g)/(maxc-minc) - bc = (maxc-b)/(maxc-minc) - if r == maxc: - h = bc-gc - elif g == maxc: - h = 2.0+rc-bc - else: - h = 4.0+gc-rc - h = h/6.0 - if h < 0.0: - h = h + 1.0 - return h,s,v -def hsv_to_rgb(h,s,v): - if s == 0.0: - return v,v,v - i = int(h*6.0) - f = (h*6.0)-i - p = v*(1.0-s) - q = v*(1.0-s*f) - t = v*(1.0-s*(1.0-f)) - if i in (0,6): return v,t,p - if i == 1: return q,v,p - if i == 2: return p,v,t - if i == 3: return p,q,v - if i == 4: return t,p,v - if i == 5: return v,p,q - print i, h, f - print h, s, v - raise 'Bad color' diff --git a/Demo/sgi/video/i2v.c b/Demo/sgi/video/i2v.c deleted file mode 100755 index 21dfabe2b2..0000000000 --- a/Demo/sgi/video/i2v.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * i2v -- image-to-video. - * Convert an SGI image file to a format that is immediately usable - * by lrectwrite. - * The header of the file contains a description (in ASCII) - * padded to 8196 byte for fast access of the rest of the file. - * - * Based upon "showimg.c" by Paul Haeberli. - * --Guido van Rossum, CWI, Amsterdam - */ -#include -#include -#include -#include - -unsigned short rs[8192]; -unsigned short gs[8192]; -unsigned short bs[8192]; - -IMAGE *image; -int xsize, ysize, zsize; -FILE *fp; - -char header[100]; -char *progname = "i2v"; - -main(argc,argv) -int argc; -char **argv; -{ - int y; - if (argc > 0) progname = argv[0]; - if( argc != 3 ) { - fprintf(stderr, "usage: %s infile outfile\n", progname); - exit(2); - } - if( (image=iopen(argv[1],"r")) == NULL ) { - fprintf(stderr, "%s: can't open input file %s\n",progname, argv[1]); - exit(1); - } - xsize = image->xsize; - ysize = image->ysize; - zsize = image->zsize; - if ((fp = fopen(argv[2], "w")) == NULL) { - fprintf(stderr,"%s: can't open output file %s\n", progname, argv[2]); - exit(1); - } - fprintf(fp, "CMIF video 1.0\n"); - fprintf(fp, "(%d, %d, %d)\n", xsize, ysize, 0); - fprintf(fp, "0, %ld\n", (long)xsize * (long)ysize * sizeof(long)); - fflush(fp); - for(y = 0; y < ysize; y++) { - if(zsize<3) { - getrow(image, rs, y, 0); - writepacked(xsize, rs, rs, rs); - } else { - getrow(image, rs, y, 0); - getrow(image, gs, y, 1); - getrow(image, bs, y, 2); - writepacked(xsize, rs, gs, bs); - } - } - exit(0); -} - -writepacked(n, rsptr, gsptr, bsptr) - int n; - short *rsptr, *gsptr, *bsptr; -{ - long parray[8192]; - long *pptr = parray; - int i = n; - while (--i >= 0) { - *pptr++ = *rsptr++ | (*gsptr++<<8) | (*bsptr++<<16); - } - if (fwrite((char *) parray, sizeof(long), n, fp) != n) { - perror("fwrite"); - exit(1); - } -} diff --git a/Demo/sgi/video/makemovie.py b/Demo/sgi/video/makemovie.py deleted file mode 100755 index 5cb41cde2e..0000000000 --- a/Demo/sgi/video/makemovie.py +++ /dev/null @@ -1,218 +0,0 @@ -#! /ufs/guido/bin/sgi/python -#! /ufs/guido/src/video/py - -# Capture a CMIF movie using the Indigo video library and board - - -# Usage: -# -# makemovie [-q queuesize] [-t recordtime] [-a] [moviefile [audiofile]] - - -# Options: -# -# -q queuesize : set the capture queue size (default and max 16) -# -t recordtime : set the record time in seconds (default 5 seconds) -# -a : record audio as well -# moviefile : here goes the movie data (default film.video); -# the format is documented in cmif-film.ms -# audiofile : with -a, here goes the audio data (default film.aiff); -# audio data is recorded in AIFF format, using the -# input sampling rate, source and volume set by the -# audio panel, in mono, 8 bits/sample - - -# User interface: -# -# Start the application. Resize the window to the desired movie size. -# Click the left mouse button to start recording (recording starts -# when you release the mouse button). Recording time is specified by -# the -t option (XXX this should change). -# -# Press ESC or select the window manager Quit or Close window option -# to quit. (You can do this without recording -- then the output -# files are untouched.) -# -# (It is possible to record more than once; but this doesn't set the -# time stamps correctly yet, and doesn't work at all with audio. So -# don't use.) - - -# XXX To do: -# -# fix timestamps for second and further recordings -# fix audio " " " " " -# flush audio buffer when recording starts -# make code more readable - - -import sys -sys.path.append('/ufs/guido/src/video') -import sv, SV -import VFile -import gl, GL, DEVICE -import al, AL -import time -import posix -import getopt -import string - - -def main(): - QSIZE = 16 - TIME = 5 - audio = 0 - - opts, args = getopt.getopt(sys.argv[1:], 'aq:t:') - for opt, arg in opts: - if opt == '-a': - audio = 1 - elif opt == '-q': - QSIZE = string.atoi(arg) - elif opt == '-t': - TIME = string.atoi(arg) - - if args: - filename = args[0] - else: - filename = 'film.video' - - if audio: - if args[1:]: - audiofilename = args[1] - else: - audiofilename = 'film.aiff' - - gl.foreground() - - x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 - print x, 'x', y - - gl.minsize(40, 30) - gl.stepunit(8, 6) - gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) - gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) - win = gl.winopen(filename) - x, y = gl.getsize() - print x, 'x', y - - v = sv.OpenVideo() - v.BindGLWindow(win, SV.IN_REPLACE) - v.SetSize(x, y) - v.BindGLWindow(win, SV.IN_REPLACE) - - v.SetCaptureFormat(SV.RGB_FRAMES) - v.SetCaptureMode(SV.BLOCKING_CAPTURE) - v.SetQueueSize(QSIZE) - v.InitCapture() - if v.GetQueueSize() != QSIZE: - QSIZE = v.GetQueueSize() - print 'Warning: QSIZE reduced to', QSIZE - - gl.qdevice(DEVICE.LEFTMOUSE) - gl.qdevice(DEVICE.WINQUIT) - gl.qdevice(DEVICE.WINSHUT) - gl.qdevice(DEVICE.ESCKEY) - - print 'Click left mouse to start recording', TIME, 'seconds' - ofile = None - afile = None - # Mouse down opens the file & freezes window - # Mouse up starts recording frames - - while 1: - dev, val = gl.qread() - if dev == DEVICE.LEFTMOUSE: - # Start recording - if val == 1: - # Mouse down -- preparations - if ofile == None: - ofile = VFile.VoutFile().init(filename) - ofile.format = 'rgb8' - ofile.width = x - ofile.height = y - ofile.writeheader() - # XXX other format bits? - # The window can't be resized from now - gl.prefsize(x, y) - gl.winconstraints() - gl.wintitle('* ' + filename) - if audio: - afile = initaudio(audiofilename) - continue - # Mouse up -- start actual recording - global recording, stop_recording - if audio: - stop_recording = 0 - recording.release() - t0 = time.millitimer() - v.StartCapture() - while 1: - t = time.millitimer() - t0 - if t >= TIME*1000: - break - if v.GetCaptured() > 2: - doframe(v, ofile, x, y, t) - v.StopCapture() - stop_recording = 1 - while v.GetCaptured() > 0: - doframe(v, ofile, x, y, t) - t = time.millitimer() - t0 - gl.wintitle(filename) - elif dev == DEVICE.REDRAW: - # Window resize (or move) - x, y = gl.getsize() - print x, 'x', y - v.SetSize(x, y) - v.BindGLWindow(win, SV.IN_REPLACE) - elif dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT): - # Quit - if ofile: - ofile.close() - if afile: - afile.destroy() - posix._exit(0) - # EndCapture dumps core... - v.EndCapture() - v.CloseVideo() - gl.winclose(win) - -def doframe(v, ofile, x, y, t): - cd, start = v.GetCaptureData() - data = cd.interleave(x, y) - cd.UnlockCaptureData() - ofile.writeframe(t, data, None) - -AQSIZE = 16000 - -def initaudio(filename): - import thread, aiff - global recording, stop_recording - afile = aiff.Aiff().init(filename, 'w') - afile.nchannels = AL.MONO - afile.sampwidth = AL.SAMPLE_8 - params = [AL.INPUT_RATE, 0] - al.getparams(AL.DEFAULT_DEVICE, params) - print 'rate =', params[1] - afile.samprate = params[1] - c = al.newconfig() - c.setchannels(AL.MONO) - c.setqueuesize(AQSIZE) - c.setwidth(AL.SAMPLE_8) - aport = al.openport(filename, 'r', c) - recording = thread.allocate_lock() - recording.acquire() - stop_recording = 0 - thread.start_new_thread(recorder, (afile, aport)) - return afile - -def recorder(afile, aport): - # XXX recording more than one fragment doesn't work - # XXX (the thread never dies) - recording.acquire() - while not stop_recording: - data = aport.readsamps(AQSIZE/2) - afile.writesampsraw(data) - del data - -main() diff --git a/Demo/sgi/video/squash.c b/Demo/sgi/video/squash.c deleted file mode 100755 index d5ea946924..0000000000 --- a/Demo/sgi/video/squash.c +++ /dev/null @@ -1,130 +0,0 @@ -#include - -long *bm; -long h, w; -long factor; - -#define OC(x,xi) ((x)*factor+(xi)) -#define BM(x,xi,y,yi) bm[OC(y,yi)*w+OC(x,xi)] - -#define COMP(r,g,b) ((r) | ((g)<<8) | ((b) << 16)) - -#define R(comp) ((comp) & 0xff) -#define G(comp) (((comp)>>8) & 0xff) -#define B(comp) (((comp)>>16) & 0xff) - -main(argc, argv) - char **argv; -{ - char lbuf[100]; - int nh, nw; - int x, y, xi, yi; - int num; - int r, g, b; - long data; - long *nbm, *nbmp; - int i; - int bits, mask, roundbit, addbit; - int pf; - int newfmt = 0; - - if( argc != 2 && argc != 3) { - fprintf(stderr, "Usage: squash factor [bits]\n"); - exit(1); - } - factor = atoi(argv[1]); - if ( argc > 2 ) { - bits = atoi(argv[2]); - mask = (1 << bits) - 1; - mask <<= (8-bits); - roundbit = 1 << (7-bits); - addbit = 1 << (8-bits); - fprintf(stderr, "%x %x %x\n", mask, roundbit, addbit); - } else { - mask = 0xff; - roundbit = 0; - addbit = 0; - } - gets(lbuf); - if ( strncmp( lbuf, "CMIF", 4) == 0 ) { - newfmt = 1; - gets(lbuf); - if( sscanf(lbuf, "(%d,%d,%d)", &w, &h, &pf) != 3) { - fprintf(stderr, "%s: bad size spec: %s\n", argv[0], lbuf); - exit(1); - } - if ( pf != 0 ) { - fprintf(stderr, "%s: packed file\n", argv[0]); - exit(1); - } - } else { - if ( sscanf(lbuf, "(%d,%d)", &w, &h) != 2) { - fprintf(stderr, "%s: bad size spec: %s\n", argv[0], lbuf); - exit(1); - } - } - nh = h / factor; - nw = w / factor; - if ( newfmt ) - printf("CMIF video 1.0\n(%d,%d,%d)\n", nw, nh, 0); - else - printf("(%d,%d)\n", nw, nh); - if ( (bm = (long *)malloc(h*w*sizeof(long))) == 0) { - fprintf(stderr, "%s: No memory\n", argv[0]); - exit(1); - } - if ( (nbm = (long *)malloc(nh*nw*sizeof(long))) == 0) { - fprintf(stderr, "%s: No memory\n", argv[0]); - exit(1); - } - while( !feof(stdin) ) { - { int t, s; - gets(lbuf); - if ( feof(stdin) ) break; - if ( sscanf(lbuf, "%d,%d", &t,&s) == 2) { - if ( s != h*w*4 ) { - fprintf(stderr, "Size changed from %d to %d: %s\n",4*h*w,s, lbuf); - exit(1); - } - printf("%d, %d\n", t, nh*nw*4); - } else { - puts(lbuf); - } - } - fprintf(stderr, "Reading %d\n", h*w*sizeof(long)); - if ( (i=fread(bm, 1, h*w*sizeof(long), stdin)) != h*w*sizeof(long)) { - fprintf(stderr, "%s: short read, %d wanted %d\n", argv[0], - i, h*w*sizeof(long)); - exit(1); - } - nbmp = nbm; - for( y=0; y - -long *bm; -long h, w; -long factor; - -#define OC(x,xi) ((x)*factor+(xi)) -#define BM(x,xi,y,yi) bm[OC(y,yi)*w+OC(x,xi)] - -#define COMP(r,g,b) ((r) | ((g)<<8) | ((b) << 16)) - -#define R(comp) ((comp) & 0xff) -#define G(comp) (((comp)>>8) & 0xff) -#define B(comp) (((comp)>>16) & 0xff) - -main(argc, argv) - char **argv; -{ - char lbuf[100]; - int nh, nw; - int x, y, xi, yi; - int num; - int r, g, b; - long data; - long *nbm, *nbmp; - int i; - - if( argc != 2) { - fprintf(stderr, "Usage: squash factor\n"); - exit(1); - } - factor = atoi(argv[1]); - gets(lbuf); - if ( sscanf(lbuf, "(%d,%d)", &w, &h) != 2) { - fprintf(stderr, "%s: bad size spec: %s\n", argv[0], lbuf); - exit(1); - } - nh = h / factor; - nw = w / factor; - printf("(%d,%d)\n", nw, nh); - if ( (bm = (long *)malloc(h*w*sizeof(long))) == 0) { - fprintf(stderr, "%s: No memory\n", argv[0]); - exit(1); - } - if ( (nbm = (long *)malloc(nh*nw*sizeof(long))) == 0) { - fprintf(stderr, "%s: No memory\n", argv[0]); - exit(1); - } - while( !feof(stdin) ) { - gets(lbuf); - if ( feof(stdin) ) break; - puts(lbuf); - fprintf(stderr, "Reading %d\n", h*w*sizeof(long)); - if ( (i=fread(bm, 1, h*w*sizeof(long), stdin)) != h*w*sizeof(long)) { - fprintf(stderr, "%s: short read, %d wanted %d\n", argv[0], - i, h*w*sizeof(long)); - exit(1); - } - nbmp = nbm; - for( y=0; y size: - raise EOFError - dostat(w2, h2, data) - nframes = nframes+1 - t1 = millitimer() - - t = 0.001 * (t1-t0) - fps = 0.1 * int(10*nframes/t) - print nframes, 'frames in', t, 'sec. =', fps, 'frames/sec.' - -def dostat(w, h, data): - print - stat3(w, h, data) - -# Statistic op 1: frequencies of byte values -def stat1(w, h, data): - bins = [0]*256 - for c in data: - i = ord(c) - bins[i] = bins[i]+1 - prbins(bins) - -def prbins(bins): - import string - s = '' - tot = 0 - for i in range(256): - tot = tot + bins[i] - s = s + string.rjust(`bins[i]`, 4) - if len(s) >= 4*16: - print s, string.rjust(`tot`, 7) - s = '' - tot = 0 - -# Statistic op 2: run lengths -def stat2(w, h, data): - runs = [] - for y in range(h): - count, value = 0, ord(data[y*w]) - for c in data[y*w : y*w+w]: - i = ord(c) - if i <> value: - runs.append(count, value) - count, value = 0, i - count = count+1 - runs.append(count, value) - print len(runs), 'runs =', 0.1 * (10*w*h/len(runs)), 'bytes/run' - -# Statistic op 3: frequencies of byte differences -def stat3(w, h, data): - bins = [0]*256 - prev = 0 - for c in data: - i = ord(c) - delta = divmod(i-prev, 256)[1] - prev = i - bins[delta] = bins[delta]+1 - prbins(bins) - -# Try packing -def packblock(w, h, data): - res = '' - for y in range(h): - res = res + packline(data[y*w : y*w+w]) - return res - -def packline(line): - bytes = [] - for c in line: - bytes.append(ord(c)) - prev = bytes[0] - i, n = 1, len(bytes) - while i < n: - for pack in (0, 2, 4, 8): - if pack == 0: - lo, hi = 0, 0 - else: - hi = pow(2, pack-1)-1 - lo = -hi-1 - p = prev - j = i - count = 0 - while j < n: - x = bytes[j] - delta = byte(x-p) - if not lo <= delta <= hi: - break - p = x - j = j+1 - -def byte(x): return divmod(x, 256)[1] - -main() diff --git a/Demo/sgi/video/syncaudio.py b/Demo/sgi/video/syncaudio.py deleted file mode 100755 index fd09d2879c..0000000000 --- a/Demo/sgi/video/syncaudio.py +++ /dev/null @@ -1,94 +0,0 @@ -import AL -import al -import sys -import vtime -import socket -import time - - -SLEEPTIME = 500 # 500 ms sleeps -SAMPLEFREQ = 16000 # 16Khz samples -SAMPLERATE = AL.RATE_16000 -NEEDBUFFERED = SAMPLEFREQ # Buffer 1 second of sound -BUFFERSIZE = NEEDBUFFERED*4 # setqueuesize() par for 2 second sound - -AVSYNCPORT = 10000 # Port for time syncing -AVCTLPORT = 10001 # Port for record start/stop - -def main(): - if len(sys.argv) <> 3: - print 'Usage: ', sys.argv[0], 'videohostname soundfile' - sys.exit(1) - # - ofile = open(sys.argv[2], 'w') - # - globaltime = vtime.VTime().init(0,sys.argv[1],AVSYNCPORT) - # - ctl = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) - ctl.bind((socket.gethostname(),AVCTLPORT)) - # - inp = openmic() - # - out = 0 # Open aiff file - # - while 1: - if mainloop(None, ctl, inp, out, globaltime): - break - if mainloop(ofile, ctl, inp, out, globaltime): - break - pass # Close aiff file - sys.exit(0) -# -def openmic(): - conf = al.newconfig() - conf.setqueuesize(BUFFERSIZE) - conf.setwidth(AL.SAMPLE_16) - conf.setchannels(AL.MONO) - return al.openport('micr','r',conf) -# -def mainloop(ofile, ctl, inp, out, globaltime): - # - # Wait for sync packet, keeping 1-2 seconds of sound in the - # buffer - # - totsamps = 0 - totbytes = 0 - starttime = time.millitimer() - while 1: - time.millisleep(SLEEPTIME) - if ctl.avail(): - break - nsamples = inp.getfilled()-NEEDBUFFERED - if nsamples>0: - data = inp.readsamps(nsamples) - totsamps = totsamps + nsamples - totbytes = totbytes + len(data) - if ofile <> None: - ofile.write(data) - # - # Compute his starttime and the timestamp of the first byte in the - # buffer. Discard all buffered data upto his starttime - # - startstop,histime = eval(ctl.recv(100)) - if (ofile == None and startstop == 0) or \ - (ofile <> None and startstop == 1): - print 'Sync error: saving=',save,' request=',startstop - sys.exit(1) - filllevel = inp.getfilled() - filltime = time.millitimer() - filltime = filltime - filllevel / (SAMPLEFREQ/1000) - starttime = globaltime.his2mine(histime) - nsamples = starttime - filltime - if nsamples < 0: - print 'Start/stop signal came too late' - sys.exit(1) - nsamples = nsamples * (SAMPLEFREQ / 1000) - data = inp.readsamps(nsamples) - totsamps = totsamps + nsamples - totbytes = totbytes + len(data) - print 'Time: ', time.millitimer()-starttime, ', Bytes: ', totbytes, ', Samples: ', totsamps - if ofile <> None: - ofile.write(data) - return (startstop == 2) - -main() diff --git a/Demo/sgi/video/tomono.c b/Demo/sgi/video/tomono.c deleted file mode 100755 index 546af68afd..0000000000 --- a/Demo/sgi/video/tomono.c +++ /dev/null @@ -1,165 +0,0 @@ -#include - -long *bm; -long *nbm; -long h, w; -int nh, nw; -long factor; - -#define OC(x,xi) ((x)*factor+(xi)) -#define BM(x,xi,y,yi) bm[OC(y,yi)*w+OC(x,xi)] - -#define COMP(r,g,b) ((r) | ((g)<<8) | ((b) << 16)) - -#define R(comp) ((comp) & 0xff) -#define G(comp) (((comp)>>8) & 0xff) -#define B(comp) (((comp)>>16) & 0xff) - -#define CHOICEFUNC(np1, np2) ( random() & 1 ) - -int inlevels = 3*255; -int outlevels = 1; - -main(argc, argv) - char **argv; -{ - char lbuf[100]; - int x, y, xi, yi; - int num; - int r, g, b; - long data; - int i; - double greyness; - int inpixels, outpixels; - int resid; - - setvbuf(stdout, 0, _IOFBF, 1024*128); - if( argc != 2) { - fprintf(stderr, "Usage: tomono factor\n"); - exit(1); - } - factor = atoi(argv[1]); - gets(lbuf); - if ( sscanf(lbuf, "(%d,%d)", &w, &h) != 2) { - fprintf(stderr, "%s: bad size spec: %s\n", argv[0], lbuf); - exit(1); - } - nh = h / factor; - nw = w / factor; - printf("(%d,%d)\n", nw, nh); - if ( (bm = (long *)malloc(h*w*sizeof(long))) == 0) { - fprintf(stderr, "%s: No memory\n", argv[0]); - exit(1); - } - if ( (nbm = (long *)malloc(nh*nw*sizeof(long))) == 0) { - fprintf(stderr, "%s: No memory\n", argv[0]); - exit(1); - } - while( !feof(stdin) ) { - gets(lbuf); - if ( feof(stdin) ) break; - puts(lbuf); - fprintf(stderr, "Reading %d\n", h*w*sizeof(long)); - if ( (i=fread(bm, 1, h*w*sizeof(long), stdin)) != h*w*sizeof(long)) { - fprintf(stderr, "%s: short read, %d wanted %d\n", argv[0], - i, h*w*sizeof(long)); - exit(1); - } - /* - ** Compute picture blackness. - */ - inpixels = 0; - inpixels = countpixels(0,0,w,h); - greyness = (double)inpixels/(h*w*inlevels); - fprintf(stderr, "%3.1f%% grey\n", 100.0*greyness); - outpixels = (int)(greyness*outlevels*nh*nw); - fprintf(stderr, "Inpixels: %d (%d) Outpixels %d\n", inpixels, inpixels/inlevels, outpixels); - resid = fillpixels(0,0,nw,nh,0,0,w,h,outpixels); - if ( resid > 1 ) fprintf(stderr, "Residue: %d pixels\n", resid); - fprintf(stderr, "Writing %d\n", (nh*nw)*sizeof(long)); - fwrite(nbm, 1, (nh*nw)*sizeof(long), stdout); - } - exit(0); -} - -countpixels(x0,y0,x1,y1) -{ - int x, y, tot, data; - - tot = 0; - for( y=y0; y= x1 && y0+1 >= y1 ) { - if ( npixels ) { - nbm[y0*nw+x0] = 0xffffff; -/* fprintf(stderr, "->%d,%d\n", x0,y0); */ - return npixels - 1; - } - return 0; - } - if ( x1-x0 < y1-y0 ) { - if ( y1 - y0 <= 2 ) - m = y0 + 1; - else - m = y0+1+(random()%(y1-y0-1)); -/* fprintf(stderr,"%d,%d %d,%d Y %d\n", x0, x1, y0, y1, m); */ - /* om = (oy0+oy1)/2; */ om = m; - p1 = countpixels(ox0,oy0,ox1,om); - p2 = countpixels(ox0,om,ox1,oy1); - np1 = (int)(((float)p1/(p1+p2))*npixels); - np2 = (int)(((float)p2/(p1+p2))*npixels); - rp = npixels - np1 - np2; - if ( rp ) { - np1 += rp/2; - rp = rp - rp/2; - np2 += rp; - } - resid = 0; - if ( CHOICEFUNC(np1, np2) ) { - resid = fillpixels(x0,y0,x1,m,ox0,oy0,ox1,om,np1+resid); - resid = fillpixels(x0,m,x1,y1,ox0,om,ox1,oy1,np2+resid); - } else { - resid = fillpixels(x0,m,x1,y1,ox0,om,ox1,oy1,np2+resid); - resid = fillpixels(x0,y0,x1,m,ox0,oy0,ox1,om,np1+resid); - } - } else { - if ( x1 - x0 <= 2 ) - m = x0 + 1; - else - m = x0+1+(random()%(x1-x0-1)); -/* fprintf(stderr,"%d,%d %d,%d X %d\n", x0, x1, y0, y1, m); */ - /* om = (ox0+ox1)/2; */ om = m; - p1 = countpixels(ox0,oy0,om,oy1); - p2 = countpixels(om,oy0,ox1,oy1); - np1 = (int)(((float)p1/(p1+p2))*npixels); - np2 = (int)(((float)p2/(p1+p2))*npixels); - rp = npixels - np1 - np2; - if ( rp ) { - np1 += rp/2; - rp = rp - rp/2; - np2 += rp; - } - resid = 0; - if ( CHOICEFUNC(np1, np2) ) { - resid = fillpixels(x0,y0,m,y1,ox0,oy0,om,oy1,np1+resid); - resid = fillpixels(m,y0,x1,y1,om,oy0,ox1,oy1,np2+resid); - } else { - resid = fillpixels(m,y0,x1,y1,om,oy0,ox1,oy1,np2+resid); - resid = fillpixels(x0,y0,m,y1,ox0,oy0,om,oy1,np1+resid); - } - } - return resid; -} diff --git a/Demo/sgi/video/tv.py b/Demo/sgi/video/tv.py deleted file mode 100755 index da4bacbb63..0000000000 --- a/Demo/sgi/video/tv.py +++ /dev/null @@ -1,79 +0,0 @@ -import string - -from socket import * -from gl import * -from GL import * -from DEVICE import * -from time import millisleep, millitimer - -PORT = 5555 - -PF = 2 # packfactor -HS = 40 # Header size - -def testimage(): - RGBcolor(0, 0, 0) - clear() - RGBcolor(0, 255, 0) - cmov2i(10, 10) - charstr('Waiting...') - -def reshape(): - reshapeviewport() - w, h = getsize() - ortho2(0, w, 0, h) - testimage() - return w, h - -def main(): - s = socket(AF_INET, SOCK_DGRAM) - s.bind('', PORT) - - foreground() - wid = winopen('tv') - RGBmode() - gconfig() - qdevice(ESCKEY) - - oldw, oldh = getsize() - ortho2(0, oldw, 0, oldh) - testimage() - - t1 = millitimer() - - while 1: - if qtest(): - dev, val = qread() - if dev == ESCKEY: - winclose(wid) - return - elif dev == REDRAW: - oldw, oldh = reshape() - elif s.avail(): - data = s.recv(17000) - header = string.strip(data[:HS]) - w, h, pf, x1, y1, x2, y2 = eval(header) - if (w, h) <> (oldw, oldh): - x, y = getorigin() - x, y = x-1, y+21 # TWM correction - winposition(x, x+w-1, y+oldh-h, y+oldh-1) - oldw, oldh = reshape() - data2 = data[HS:] - dx = (x2-x1+1)/pf - dy = (y2-y1+1)/pf - data3 = unpackrect(dx, dy, 1, data2) - rectzoom(pf, pf) - lrectwrite(x1, y1, x1+dx-1, y1+dy-1, data3) - t1 = millitimer() - else: - t2 = millitimer() - if t2-t1 >= 5000: - testimage() - t1 = t2 - else: - millisleep(10) - - winclose(wid) - return data - -main() diff --git a/Demo/sgi/video/v2i.c b/Demo/sgi/video/v2i.c deleted file mode 100755 index 5f8f3b5dec..0000000000 --- a/Demo/sgi/video/v2i.c +++ /dev/null @@ -1,79 +0,0 @@ -/* Convert the first image of a CMIF video movie file to SGI .rgb format. - usage: v2i videofile imagefile [planemask] - link with -limage -*/ - -#include -#include - -long bm[1280]; -short rb[1280], gb[1280], bb[1280]; -long w, h, pf; - -#define R(comp) ((comp) & 0xff) -#define G(comp) (((comp)>>8) & 0xff) -#define B(comp) (((comp)>>16) & 0xff) - -main(argc, argv) - char **argv; -{ - char lbuf[100]; - int x, y; - int i; - IMAGE * of; - int pmask; - - if( argc != 3 && argc != 4) { - fprintf(stderr, "Usage: v2i videofile imgfile [planemask]\n"); - exit(2); - } - if ( argc == 4) - pmask = atoi(argv[3]); - else - pmask = 7; - if ( freopen(argv[1], "r", stdin) == NULL ) { - perror(argv[1]); - exit(1); - } - if (fgets(lbuf, sizeof lbuf, stdin) == NULL) { - fprintf(stderr, "Immediate EOF\n"); - exit(1); - } - if (strncmp(lbuf, "CMIF", 4) == 0) { - /* Skip optional header line */ - if (fgets(lbuf, sizeof lbuf, stdin) == NULL) { - fprintf(stderr, "Immediate EOF after header\n"); - exit(1); - } - } - pf = 2; /* Default */ - if ( sscanf(lbuf, "(%d,%d,%d)", &w, &h, &pf) < 2) { - fprintf(stderr, "%s: bad size spec: %s\n", argv[0], lbuf); - exit(1); - } - fgets(lbuf, sizeof lbuf, stdin); /* Skip time info */ - if ( w > 1280 ) { - fprintf(stderr, "%s: Sorry, too wide\n", argv[0]); - exit(1); - } - if ( (of=iopen(argv[2], "w", RLE(1), 3, w, h, 3)) == 0) { - perror(argv[2]); - exit(1); - } - for( y=0; y 2: - usage() - [ifile, ofile] = args - print 'open film ', ifile - ifilm = VFile.VinFile().init(ifile) - print 'open output ', ofile - ofilm = VFile.VoutFile().init(ofile) - - ofilm.setinfo(ifilm.getinfo()) - - use_grabber = 0 - continuous = 0 - tomono = 0 - tomonodither = 0 - for o, a in opts: - if o == '-t': - ofilm.format = a - use_grabber = 1 - if o == '-a': - continuous = 1 - if o == '-m': - if ifilm.format <> 'grey': - print '-m only supported for greyscale' - sys.exit(1) - tomono = 1 - treshold = string.atoi(a) - ofilm.format = 'mono' - if o == '-d': - if ifilm.format <> 'grey': - print '-m only supported for greyscale' - sys.exit(1) - tomonodither = 1 - ofilm.format = 'mono' - - ofilm.writeheader() - # - prefsize(ifilm.width, ifilm.height) - w = winopen(ifile) - qdevice(KEYBD) - qdevice(ESCKEY) - qdevice(WINQUIT) - qdevice(WINSHUT) - print 'qdevice calls done' - # - help() - # - time, data, cdata = ifilm.getnextframe() - ifilm.showframe(data, cdata) - iframe = 1 - report(time, iframe) - # - while 1: - if continuous: - dev = KEYBD - else: - dev, val = qread() - if dev in (ESCKEY, WINQUIT, WINSHUT): - break - if dev == REDRAW: - reshapeviewport() - elif dev == KEYBD: - if continuous: - c = '0' - else: - c = chr(val) - #XXX Debug - if c == 'R': - c3i(255,0,0) - clear() - if c == 'G': - c3i(0,255,0) - clear() - if c == 'B': - c3i(0,0,255) - clear() - if c == 'w' or continuous: - if use_grabber: - data, cdata = ofilm.grabframe() - if tomono: - data = imageop.grey2mono(data, \ - ifilm.width, ifilm.height, \ - treshold) - if tomonodither: - data = imageop.dither2mono(data, \ - ifilm.width, ifilm.height) - ofilm.writeframe(time, data, cdata) - print 'Frame', iframe, 'written.' - if c == 'n' or continuous: - try: - time,data,cdata = ifilm.getnextframe() - ifilm.showframe(data, cdata) - iframe = iframe+1 - report(time, iframe) - except EOFError: - print 'EOF' - if continuous: - break - ringbell() - elif dev == INPUTCHANGE: - pass - else: - print '(dev, val) =', (dev, val) - ofilm.close() - -main() diff --git a/Demo/sgi/video/video.py b/Demo/sgi/video/video.py deleted file mode 100755 index 1b81bd83f7..0000000000 --- a/Demo/sgi/video/video.py +++ /dev/null @@ -1,218 +0,0 @@ -import getopt -from gl import * -from GL import * -from DEVICE import * -import time -import sys -import al -import AL - -sys.path.append('/ufs/guido/src/video') # Increase chance to find colorsys -import colorsys - -BUFFERSIZE = 32000 - -class Struct(): pass -epoch = Struct() -epoch.correcttiming = 1 -EndOfFile = 'End of file' -bye = 'bye' - -def openspkr(): - conf = al.newconfig() - conf.setqueuesize(BUFFERSIZE) - conf.setwidth(AL.SAMPLE_16) - conf.setchannels(AL.MONO) - return al.openport('spkr','w',conf) - -def openvideo(name): - try: - f = open(name, 'r') - except: - sys.stderr.write(name + ': cannot open\n') - sys.exit(1) - line = f.readline() - if not line: raise EndOfFile - colorinfo = (8, 0, 0, 0) - if line[:4] == 'CMIF': - if line[:14] == 'CMIF video 2.0': - line = f.readline() - colorinfo = eval(line[:-1]) - line = f.readline() - x = eval(line[:-1]) - if len(x) == 3: w, h, pf = x - else: w, h = x; pf = 2 - if pf and w/pf % 4 <> 0: - sys.stderr.write( \ - 'warning: stride not a multiple of 4 -- may not work on Indigo XS\n') - return f, w, h, pf, colorinfo - -def loadframe(f,w,h,pf,af,spkr, (ybits,ibits,qbits,chrompack),mf): - line = f.readline() - if line == '': - raise EndOfFile - x = eval(line[:-1]) - if type(x) == type(0) or type(x) == type(0.0): - tijd = x - if pf == 0: - size = w*h*4 - else: - size = (w/pf) * (h/pf) - else: - tijd, size = x - data = f.read(size) - if len(data) <> size: - raise EndOfFile - if pf: - w = w/pf - h = h/pf - if chrompack: - cw = (w+chrompack-1)/chrompack - ch = (h+chrompack-1)/chrompack - chromdata = f.read(2*cw*ch) - rectzoom(pf*chrompack*mf,pf*chrompack*mf) - pixmode(PM_SIZE,16) - writemask(0x7ff - ((1< 1: - rectzoom(mf,mf) - lrectwrite(0,0,w-1,h-1,data) - # This is ugly here, but the only way to get the two - # channels started in sync - #if af <> None: - # playsound(af,spkr) - ct = time.millitimer() - epoch.epoch - if epoch.correcttiming and tijd > 0 and ct < tijd: - time.millisleep(tijd-ct) - #swapbuffers() - return tijd - -def initcmap(ybits,ibits,qbits,chrompack): - if ybits+ibits+qbits > 11: - raise 'Sorry, 11 bits max' - maxy = pow(2,ybits) - maxi = pow(2,ibits) - maxq = pow(2,qbits) - for i in range(2048,4096-256): - mapcolor(i, 0, 255, 0) - for y in range(maxy): - yv = float(y)/float(maxy-1) - for i in range(maxi): - if maxi == 1: iv = 0 - else: iv = (float(i)/float(maxi-1))-0.5 - for q in range(maxq): - if maxq == 1: qv = 0 - else: qv = (float(q)/float(maxq-1))-0.5 - index = 2048 + y + (i << ybits) + (q << (ybits+ibits)) - rv,gv,bv = colorsys.yiq_to_rgb(yv,iv,qv) - r,g,b = int(rv*255.0), int(gv*255.0), int(bv*255.0) - if index < 4096 - 256: - mapcolor(index, r,g,b) - -def playsound(af, spkr): - nsamp = spkr.getfillable() - data = af.read(nsamp*2) - spkr.writesamps(data) - -def main(): - looping = 0 - packfactor = 0 - magfactor = 1 - try: - opts, args = getopt.getopt(sys.argv[1:], 'm:p:lF') - except getopt.error: - sys.stderr.write('usage: video ' + \ - '[-l] [-p pf] [-m mag] [-F] [moviefile [soundfile [skipbytes]]]\n') - sys.exit(2) - for opt, arg in opts: - if opt == '-m': - magfactor = int(eval(arg)) - elif opt == '-p': - packfactor = int(eval(arg)) - elif opt == '-l': - looping = 1 - elif opt == '-F': - epoch.correcttiming = 0 - if args: - filename = args[0] - else: - filename = 'film.video' - f, w, h, pf, cinfo = openvideo(filename) - if 0 < packfactor <> pf: - w = w/pf*packfactor - h = h/pf*packfactor - pf = packfactor - if args[1:]: - audiofilename = args[1] - af = open(audiofilename, 'r') - spkr = openspkr() - afskip = 0 - if args[2:]: - afskip = eval(args[2]) - af.seek(afskip) - else: - af, spkr = None, None - foreground() - prefsize(w*magfactor,h*magfactor) - win = winopen(filename) - if pf: - #doublebuffer() - cmode() - else: - RGBmode() - #doublebuffer() - gconfig() - if pf: - initcmap(cinfo) - color(2048) - clear() - writemask(2047) - pixmode(PM_SIZE,8) # 8 bit pixels - qdevice(ESCKEY) - qdevice(WINSHUT) - qdevice(WINQUIT) - running = 1 - epoch.epoch = time.millitimer() - nframe = 0 - tijd = 1 - if looping: - looping = f.tell() - try: - while 1: - if running: - try: - tijd = loadframe(f, w, h, pf, af, spkr, cinfo,magfactor) - nframe = nframe + 1 - except EndOfFile: - running = 0 - t = time.millitimer() - if tijd > 0: - print 'Recorded at', - print 0.1 * int(nframe * 10000.0 / tijd), - print 'frames/sec' - print 'Played', nframe, 'frames at', - print 0.1 * int(nframe * 10000.0 / (t-epoch.epoch)), - print 'frames/sec' - if looping: - f.seek(looping) - epoch.epoch = time.millitimer() - nframe = 0 - running = 1 - if af <> None: - af.seek(afskip) - if af <> None: - playsound(af,spkr) - if not running or qtest(): - dev, val = qread() - if dev in (ESCKEY, WINSHUT, WINQUIT): - raise bye - elif dev == REDRAW: - reshapeviewport() - except bye: - pass - -main() diff --git a/Demo/sgi/video/vinfo.py b/Demo/sgi/video/vinfo.py deleted file mode 100755 index 7f98237a97..0000000000 --- a/Demo/sgi/video/vinfo.py +++ /dev/null @@ -1,90 +0,0 @@ -from gl import * -from GL import * -from DEVICE import * -import time -import sys -import getopt - -class Struct(): pass -epoch = Struct() -EndOfFile = 'End of file' -bye = 'bye' - -def openvideo(filename): - f = open(filename, 'r') - line = f.readline() - if not line: raise EndOfFile - if line[:4] == 'CMIF': line = f.readline() - x = eval(line[:-1]) - if len(x) == 3: w, h, pf = x - else: w, h = x; pf = 2 - return f, w, h, pf - -def loadframe(f, w, h, pf): - line = f.readline() - if line == '': - raise EndOfFile - x = eval(line[:-1]) - if type(x) == type(0) or type(x) == type(0.0): - tijd = x - if pf == 0: - size = w*h*4 - else: - size = (w/pf) * (h/pf) - else: - tijd, size = x - f.seek(size, 1) - return tijd - -def main(): - delta = 0 - short = 0 - try: - opts, names = getopt.getopt(sys.argv[1:], 'ds') - except getopt.error, msg: - sys.stderr.write(msg + '\n') - sys.stderr.write('usage: vinfo [-d] [-s] [file] ...\n') - sys.exit(2) - for opt, arg in opts: - if opt == '-d': delta = 1 # print delta between frames - elif opt == '-s': short = 1 # short: don't print times - if names == []: - names = ['film.video'] - for name in names: - try: - f, w, h, pf = openvideo(name) - except: - sys.stderr.write(name + ': cannot open\n') - continue - if pf == 0: - size = w*h*4 - else: - size = (w/pf) * (h/pf) - print name, ':', w, 'x', h, '; pf =', pf, ', size =', size, - if pf == 0: - print '(color)', - else: - print '(' + `(w/pf)` + 'x' + `(h/pf)` + ')', - if (w/pf)%4 <> 0: print '!!!', - print - num = 0 - try: - otijd = 0 - while not short: - try: - tijd = loadframe(f, w, h, pf) - if delta: print '\t' + `tijd-otijd`, - else: print '\t' + `tijd`, - otijd = tijd - num = num + 1 - if num % 8 == 0: - print - except EndOfFile: - raise bye - except bye: - pass - if num % 8 <> 0: - print - f.close() - -main() diff --git a/Demo/sgi/video/vpregs.py b/Demo/sgi/video/vpregs.py deleted file mode 100755 index d33f1fe93e..0000000000 --- a/Demo/sgi/video/vpregs.py +++ /dev/null @@ -1,28 +0,0 @@ -VID_VP = 0x1000000 - -# Set vp1 register tokens -VP_GBXORG = (VID_VP +0x01) -VP_GBYORG = (VID_VP +0x02) -VP_FBXORG = (VID_VP +0x03) -VP_FBYORG = (VID_VP +0x04) -VP_WIDTH = (VID_VP +0x05) -VP_HEIGHT = (VID_VP +0x06) -VP_PIXCNT = (VID_VP +0x07) -VP_HBLANK = (VID_VP +0x08) -VP_VBLANK = (VID_VP +0x09) -VP_BRITE = (VID_VP +0x0A) -VP_CONT = (VID_VP +0x0B) -VP_HUE = (VID_VP +0x0C) -VP_SAT = (VID_VP +0x0D) -VP_ALPHA = (VID_VP +0X0E) -VP_FGMODE = (VID_VP +0x0F) -VP_MAPSRC = (VID_VP +0x10) -VP_MAPADD = (VID_VP +0x11) -VP_MAPRED = (VID_VP +0x12) -VP_MAPGREEN = (VID_VP +0x13) -VP_MAPBLUE = (VID_VP +0x14) -VP_MAPSTROBE = (VID_VP +0x15) -VP_DIGVAL = (VID_VP +0x16) -VP_STATUS0 = (VID_VP +0x17) -VP_STATUS1 = (VID_VP +0x18) -VP_CMD = (VID_VP +0x19) diff --git a/Demo/sgi/video/vtime.py b/Demo/sgi/video/vtime.py deleted file mode 100755 index c333e57983..0000000000 --- a/Demo/sgi/video/vtime.py +++ /dev/null @@ -1,106 +0,0 @@ -# -# Module vtime - Keep virtual time between two nodes. -# -# We try for synchronised clocks by sending a packet of the for -# (1,mytime,0) to the other side, and waiting (at most) a second for -# a reply. This reply has the form (2,mytime,histime), and we can -# estimate the time difference by defining histime to be exactly half-way -# between the time we sent our message and got our reply. We send a -# final (3,mynewtime,histime) message to allow the other side to do the -# same computations. -# -# Note that the protocol suffers heavily from the 2-army problem. -# It'll have to do until I can read up on time-sync protocols, though. -# -from socket import * -import time - -MSGSIZE = 100 -MSGTIMEOUT = 1000 - -recv_timeout = 'receive timeout' -bad_connect = 'Bad connection' - -def timeavg(a,b): - return int((long(a)+b)/2L) -def tryrecv(s): - cnt = 0 - while 1: - if s.avail(): - return s.recvfrom(MSGSIZE) - time.millisleep(100) - cnt = cnt + 100 - if cnt > MSGTIMEOUT: - raise recv_timeout - -class VTime(): - def init(self,(client,host,port)): - s = socket(AF_INET, SOCK_DGRAM) - host = gethostbyname(host) - localhost = gethostbyname(gethostname()) - raddr = (host,port) - s.bind((localhost,port)) - if client: - # - # We loop here because we want the *second* measurement - # for accuracy - for loopct in (0,2): - curtijd = time.millitimer() - check = `(loopct,curtijd,0)` - s.sendto(check,raddr) - while 1: - try: - if loopct: - data, other = s.recvfrom(MSGSIZE) - else: - data, other = tryrecv(s) - newtijd = time.millitimer() - if other <> raddr: - print 'Someone else syncing to us: ', other - raise bad_connect - data = eval(data) - if data[:2] == (loopct+1,curtijd): - break - if data[0] <> 2: - print 'Illegal sync reply: ', data - raise bad_connect - except recv_timeout: - curtijd = time.millitimer() - check = `(loopct,curtijd,0)` - s.sendto(check,raddr) - histime = data[2] - s.sendto(`(4,newtijd,histime)`,raddr) - mytime = timeavg(curtijd,newtijd) - #mytime = curtijd - self.timediff = histime - mytime - else: - while 1: - data,other = s.recvfrom(MSGSIZE) - if other <> raddr: - print 'Someone else syncing to us: ', other, ' Wanted ', raddr - raise bad_connect - data = eval(data) - if data[0] in (0,2): - curtijd = time.millitimer() - s.sendto(`(data[0]+1,data[1],curtijd)`,raddr) - elif data[0] == 4: - newtijd = time.millitimer() - histime = data[1] - mytime = timeavg(curtijd,newtijd) - #mytime = curtijd - self.timediff = histime-mytime - break - else: - print 'Funny data: ', data - raise bad_connect - return self - # - def his2mine(self,tijd): - return tijd - self.timediff - # - def mine2his(self, tijd): - return tijd + self.timediff - -def test(clt, host, port): - xx = VTime().init(clt,host,port) - print 'Time diff: ', xx.his2mine(0) diff --git a/Demo/sockets/ChangeLog b/Demo/sockets/ChangeLog deleted file mode 100755 index c1d41b1f67..0000000000 --- a/Demo/sockets/ChangeLog +++ /dev/null @@ -1,35 +0,0 @@ -Mon Nov 16 17:55:30 1992 Guido van Rossum (guido@voorn.cwi.nl) - -* Restructured mcast. - -Tue Nov 3 13:08:41 1992 Guido van Rossum (guido@voorn.cwi.nl) - -* Fixed ftp.py to use 'global' instead of a hack - -25-Oct-1992 - -* Added gopher.py - -2-Oct-1992 - -* Changed /usr/local/python to /usr/local/bin/python - -Thu Sep 24 12:33:56 1992 Guido van Rossum (guido@voorn.cwi.nl) - -* Improved computation of mcast group bytes (use regsub.gsub()) - -Tue Sep 8 23:20:51 1992 Guido van Rossum (guido@voorn.cwi.nl) - -* Added mcast.py and IN.py. - -* Use setsockopt() instead of allowbroadcast() in broadcast.py. - -Mon Aug 10 12:45:43 1992 Guido van Rossum (guido@voorn.cwi.nl) - -* README: added broadcast.py, ftp.py, radio.py - -------------------------------------------------------------------------------- -^^^ Log entries after release of 0.9.6 ^^^ -------------------------------------------------------------------------------- - - diff --git a/Demo/tkinter/Tree.py b/Demo/tkinter/Tree.py deleted file mode 100644 index 010fbd4796..0000000000 --- a/Demo/tkinter/Tree.py +++ /dev/null @@ -1,23 +0,0 @@ -from Tkinter import * - -class Tree: - - def __init__(self, master, cnf = {}): - self.master = master - self.outerframe = Frame(self.master, - {'name': 'outerframe', - Pack: {}, - }) - self.innerframe = Frame(self.outerframe, - {'name': 'innerframe', - Pack: {'side': 'left', - 'fill': 'y'}, - }) - self.button = Menubutton(self.innerframe, - {'name': 'button', - Pack: {}, - }) - # menu? - - def addchild(self): - return Tree(self.outerframe, {}) diff --git a/Doc/libmods.tex b/Doc/libmods.tex deleted file mode 100755 index 5bc6ee21e3..0000000000 --- a/Doc/libmods.tex +++ /dev/null @@ -1,7 +0,0 @@ -\chapter{Built-in Modules} - -The modules described in this chapter are built into the interpreter -and considered part of Python's standard environment: they are always -available.\footnote{at least in theory --- it is possible to specify -at build time that one or more of these modules should be excluded, -but it would be antisocial to do so.} diff --git a/Doc/libstd.tex b/Doc/libstd.tex deleted file mode 100755 index e642a8d60b..0000000000 --- a/Doc/libstd.tex +++ /dev/null @@ -1,7 +0,0 @@ -\chapter{Standard Modules} - -The modules described in this chapter are implemented in Python, but -are considered to be a part of Python's standard environment: they are -always available.\footnote{at least in theory --- it is possible to -botch the library installation or to sabotage the module search path -so that these modules cannot be found.} diff --git a/Doc/templates/module.tex b/Doc/templates/module.tex deleted file mode 100644 index 4afb56b251..0000000000 --- a/Doc/templates/module.tex +++ /dev/null @@ -1,122 +0,0 @@ -% Template for a library manual section. -% PLEASE REMOVE THE COMMENTS AFTER USING THE TEMPLATE - - -% ==== 1. ==== -% Choose one of the following section headers and index entries; -% \section{} generates the section header, -% \bimodindex{} or \stmodundex{} generates an index entry for this module - -\section{Built-in Module \sectcode{spam}} % If implemented in C -\bimodindex{spam} - -\section{Standard module \sectcode{spam}} % If implemented in Python -\stmodindex{spam} - - -% ==== 2. ==== -% Give a short overview of what the module does. -% If it is platform specific, mention this. -% Mention other important restrictions or general operating principles. -% For example: - -The \code{spam} module defines operations for handling cans of Spam. -It knows the four generally available Spam varieties and understands -both can sizes. - -Because spamification requires UNIX process management, the module is -only available on genuine UNIX systems. - - -% ==== 3. ==== -% List the public functions defined by the module. Begin with a -% standard phrase. You may also list the exceptions and other data -% items defined in the module, insofar as they are important for the -% user. - -The \code{spam} module defines the following functions: - -% ---- 3.1. ---- -% Redefine the ``indexsubitem'' macro to point to this module -% (alternatively, you can put this at the top of the file): - -\renewcommand{\indexsubitem}{(in module spam)} - -% ---- 3.2. ---- -% For each function, use a ``funcdesc'' block. This has exactly two -% parameters (each parameters is contained in a set of curly braces): -% the first parameter is the function name (this automatically -% generates an index entry); the second parameter is the function's -% argument list. If there are no arguments, use an empty pair of -% curly braces. If there is more than one argument, separate the -% arguments with backslash-comma. Optional parts of the parameter -% list are contained in \optional{...} (this generates a set of square -% brackets around its parameter). Arguments are automatically set in -% italics in the parameter list. Each argument should be mentioned at -% least once in the description; each usage (even inside \code{...}) -% should be enclosed in \var{...}. - -\begin{funcdesc}{open}{filename\optional{\, mode\, buffersize}} -Open the file \var{filename} as a can of Spam. The optional -\var{mode} and \var{buffersize} arguments specify the read-write mode -(\code{'r'} (default) or \code{'w'}) and the buffer size (default: -system dependent). -\end{funcdesc} - -% ---- 3.3. ---- -% Data items are described using a ``datadesc'' block. This has only -% one parameter: the item's name. - -\begin{datadesc}{cansize} -The default can size, in ounces. Legal values are 7 and 12. The -default varies per supermarket. This variable should not be changed -once the \code{open()} function has been called. -\end{datadesc} - -% --- 3.4. --- -% Exceptions are described using a ``excdesc'' block. This has only -% one parameter: the exception name. - -\begin{excdesc}{error} -Exception raised when an operation fails for a Spam specific reason. -The exception argument is a string describing the reason of the -failure. -\end{excdesc} - -% ---- 3.5. ---- -% There is no standard block type for classes. I generally use -% ``funcdesc'' blocks, since class instantiation looks very much like -% a function call. - - -% ==== 4. ==== -% Now is probably a good time for a complete example. (Alternatively, -% an example giving the flavor of the module may be given before the -% detailed list of functions.) - -Example: - -\begin{verbatim} ->>> import spam ->>> can = spam.open('/etc/passwd') ->>> can.empty() ->>> can.close() -\end{verbatim} - -% ==== 5. ==== -% If your module defines new object types (for a built-in module) or -% classes (for a module written in Python), you should list the -% methods and instance variables (if any) of each type or class in a -% separate subsection. It is important to redefine ``indexsubitem'' -% for each subsection. - -\subsection{Spam Objects} - -Spam objects (returned by \code{open()} above) have the following -methods. - -\renewcommand{\indexsubitem}{(spam method)} - -\begin{funcdesc}{empty}{} -Empty the can into the trash. -\end{funcdesc} diff --git a/Include/config.h b/Include/config.h deleted file mode 100755 index 3f486fff58..0000000000 --- a/Include/config.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Include/config.h. Generated automatically by configure. */ -/* NOTE: config.h.in is converted into config.h by the configure - script in the toplevel directory. - - On non-UNIX systems, manually copy config.h.in to config.h, and - edit the latter to reflect the actual configuration of your system. - - Then arrange that the symbol HAVE_CONFIG_H is defined during - compilation (usually by passing an argument of the form - `-DHAVE_CONFIG_H' to the compiler, but this is necessarily - system-dependent). */ - - -/* Types which have no traditional name -- edit the definition if necessary */ - -#define RETSIGTYPE void /* int or void: return of signal handlers */ - - -/* Types which are often defined in -- either define as - some variant of int or leave undefined. Uncomment a definition if - your does not define the type */ - -/* #define mode_t int */ -/* #define off_t long */ -/* #define pid_t int */ -/* #define size_t unsigned */ -/* #define uid_t int */ -/* #define gid_t int */ - - -/* Feature test symbols -- either define as 1 or leave undefined */ - -/* symbol name: #define as 1 if: */ - -/* #undef STDC_HEADERS */ /* the standard C header files exist - (in particular, , - , and ) */ - -/* #undef HAVE_DLFCN_H */ /* exists */ -#define HAVE_SIGNAL_H 1 /* exists */ -#define HAVE_STDARG_H 1 /* exists (else need ) */ -#define HAVE_STDLIB_H 1 /* exists */ -#define HAVE_UNISTD_H 1 /* exists */ -#define HAVE_UTIME_H 1 /* exists */ - -#define HAVE_SYS_PARAM_H 1 /* exists */ -/* #undef HAVE_SYS_SELECT_H */ /* exists */ -#define HAVE_SYS_TIMES_H 1 /* exists */ -/* #undef HAVE_SYS_TIME_H */ /* exists */ -#define HAVE_SYS_UTSNAME_H 1 /* exists */ - -#define TIME_WITH_SYS_TIME 1 /* and can be included - together */ - -/* #undef HAVE_TM_ZONE */ /* struct tm has a tm_zone member */ -#define HAVE_TZNAME 1 /* extern char *tzname[] exists */ - -#define HAVE_CLOCK 1 /* clock() exists */ -/* #undef HAVE_FTIME */ /* ftime() exists */ -#define HAVE_GETPGRP 1 /* getpgrp() exists */ -#define HAVE_GETTIMEOFDAY 1 /* gettimeofday() exists */ -#define HAVE_LSTAT 1 /* lstat() exists */ -#define HAVE_PROTOTYPES 1 /* the compiler understands prototypes */ -#define HAVE_READLINK 1 /* readlink() exists */ -#define HAVE_SELECT 1 /* select() exists */ -#define HAVE_SETPGID 1 /* setpgid() exists */ -#define HAVE_SETPGRP 1 /* setpgrp() exists */ -#define HAVE_SETSID 1 /* setsid() exists */ -#define HAVE_SYMLINK 1 /* symlink() exists */ -/* #undef HAVE_SIGINTERRUPT */ /* siginterrupt() exists */ -#define HAVE_TCGETPGRP 1 /* tcgetpgrp() exists */ -#define HAVE_TCSETPGRP 1 /* tcsetpgrp() exists */ -#define HAVE_TIMES 1 /* times() exists */ -#define HAVE_UNAME 1 /* uname() exists */ -#define HAVE_WAITPID 1 /* waitpid() exists */ - -/* #undef GETPGRP_HAVE_ARG */ /* getpgrp() must be called as getpgrp(0) - (and setpgrp() as setpgrp(0, 0)) */ - -#define WITH_READLINE 1 /* GNU readline() should be used */ -/* #undef USE_THREAD */ /* Build in thread support */ -/* #undef SOLARIS */ /* This is SOLARIS 2.x */ diff --git a/Include/rename1.h b/Include/rename1.h deleted file mode 100755 index 90f129f1ab..0000000000 --- a/Include/rename1.h +++ /dev/null @@ -1,360 +0,0 @@ -#ifndef Py_RENAME1_H -#define Py_RENAME1_H -#ifdef __cplusplus -extern "C" { -#endif - -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* This file contains a bunch of #defines that make it possible to use - "new style" names (e.g. PyObject) with the old style Python source - distribution. */ - -/* Remove some symbols (these conflict with X11 symbols) */ -#undef True -#undef False -#undef None - -typedef ANY *PyUnivPtr; -typedef struct methodlist PyMethodDef; - -#define Py_NO_DEBUG NDEBUG -#define Py_TRACE_REFS TRACE_REFS -#define Py_REF_DEBUG REF_DEBUG -#define Py_HAVE_PROTOTYPES HAVE_PROTOTYPES -#define Py_HAVE_STDLIB HAVE_STDLIB -#define _Py_ZeroStruct FalseObject -#define _Py_NoneStruct NoObject -#define _Py_TrueStruct TrueObject -#define Py_DebugFlag debugging -#define _PyParser_Grammar gram -#define _PySys_ProfileFunc sys_profile -#define _PySys_TraceFunc sys_trace -#define _PyThread_Started threads_started -#define _PyParser_TokenNames tok_name -#define Py_VerboseFlag verbose -#define PyExc_AttributeError AttributeError -#define PyExc_EOFError EOFError -#define PyExc_IOError IOError -#define PyExc_ImportError ImportError -#define PyExc_IndexError IndexError -#define PyExc_KeyError KeyError -#define PyExc_MemoryError MemoryError -#define PyExc_NameError NameError -#define PyExc_OverflowError OverflowError -#define PyExc_RuntimeError RuntimeError -#define PyExc_SyntaxError SyntaxError -#define PyExc_SystemError SystemError -#define PyExc_TypeError TypeError -#define PyExc_ValueError ValueError -#define PyExc_ZeroDivisionError ZeroDivisionError -#define PyExc_KeyboardInterrupt KeyboardInterrupt -#define PyExc_SystemExit SystemExit -#define PyFloat_Type Floattype -#define PyInt_Type Inttype -#define PyLong_Type Longtype -#define PyNothing_Type Notype -#define PyString_Type Stringtype -#define PyType_Type Typetype -#define PyList_Type Listtype -#define PyDict_Type Dicttype -#define PyTuple_Type Tupletype -#define PyFile_Type Filetype -#define PyClass_Type Classtype -#define PyFunction_Type Functype -#define PyMethod_Type Instancemethodtype -#define PyInstance_Type Instancetype -#define PyCFunction_Type Methodtype -#define PyModule_Type Moduletype -#define PyCode_Type Codetype -#define PyFrame_Type Frametype -#define PyFloatObject floatobject -#define PyIntObject intobject -#define PyLongObject longobject -#define PyNothingObject noobject -#define PyObject object -#define PyStringObject stringobject -#define PyTypeObject typeobject -#define PyListObject listobject -#define PyDictObject dictobject -#define PyTupleObject tupleobject -#define PyFileObject fileobject -#define PyClassObject classobject -#define PyCodeObject codeobject -#define PyFrameObject frameobject -#define PyFunctionObject funcobject -#define PyMethodObject instancemethodobject -#define PyInstanceObject instanceobject -#define PyCFunctionObject methodobject -#define PyModuleObject moduleobject -#define PyNumberMethods number_methods -#define PySequenceMethods sequence_methods -#define PyMappingMethods mapping_methods -#define PyObject_HEAD OB_HEAD -#define PyObject_VAR_HEAD OB_VARHEAD -#define PyObject_HEAD_INIT(x) OB_HEAD_INIT(x) -#define PyObject_NEW NEWOBJ -#define PyObject_NEW_VAR NEWVAROBJ -#define Py_PROTO PROTO -#define PyMem_NEW NEW -#define PyMem_RESIZE RESIZE -#define PyMem_DEL DEL -#define PyMem_XDEL XDEL -#define Py_BEGIN_ALLOW_THREADS BGN_SAVE -#define Py_BLOCK_THREADS RET_SAVE -#define Py_UNBLOCK_THREADS RES_SAVE -#define Py_END_ALLOW_THREADS END_SAVE -#define PyFloat_Check is_floatobject -#define PyInt_Check is_intobject -#define PyLong_Check is_longobject -#define PyNothing_Check is_noobject -#define PyString_Check is_stringobject -#define PyType_Check is_typeobject -#define PyList_Check is_listobject -#define PyDict_Check is_dictobject -#define PyTuple_Check is_tupleobject -#define PyFile_Check is_fileobject -#define PyClass_Check is_classobject -#define PyCode_Check is_codeobject -#define PyFrame_Check is_frameobject -#define PyFunction_Check is_funcobject -#define PyMethod_Check is_instancemethodobject -#define PyInstance_Check is_instanceobject -#define PyCFunction_Check is_methodobject -#define PyModule_Check is_moduleobject -#define Py_INCREF INCREF -#define Py_DECREF DECREF -#define Py_XINCREF XINCREF -#define Py_XDECREF XDECREF -#define _Py_NewReference NEWREF -#define _Py_Dealloc DELREF -#define _Py_ForgetReference UNREF -#define Py_None (&_Py_NoneStruct) -#define Py_False ((object *) &_Py_ZeroStruct) -#define Py_True ((object *) &_Py_TrueStruct) -#define PyObject_Compare cmpobject -#define PyObject_GetAttrString getattr -#define PyObject_GetAttr getattro -#define PyObject_Hash hashobject -#define _PyObject_New newobject -#define _PyObject_NewVar newvarobject -#define PyObject_Print printobject -#define PyObject_Repr reprobject -#define PyObject_SetAttrString setattr -#define PyObject_SetAttr setattro -#define PyObject_IsTrue testbool -#define Py_PRINT_RAW PRINT_RAW -#define PyFloat_AsString float_buf_repr -#define PyFloat_AsDouble getfloatvalue -#define PyFloat_AS_DOUBLE GETFLOATVALUE -#define PyFloat_FromDouble newfloatobject -#define PyInt_AsLong getintvalue -#define PyInt_AS_LONG GETINTVALUE -#define PyInt_FromLong newintobject -#define _PyLong_New alloclongobject -#define PyLong_AsDouble dgetlongvalue -#define PyLong_FromDouble dnewlongobject -#define PyLong_AsLong getlongvalue -#define PyLong_FromString long_scan -#define PyLong_FromLong newlongobject -#define PyString_Format formatstring -#define PyString_Size getstringsize -#define PyString_AsString getstringvalue -#define PyString_AS_STRING GETSTRINGVALUE -#define PyString_Concat joinstring -#define PyString_FromStringAndSize newsizedstringobject -#define PyString_FromString newstringobject -#define _PyString_Resize resizestring -#define PyList_Append addlistitem -#define PyList_GetItem getlistitem -#define PyList_GET_ITEM GETLISTITEM -#define PyList_Size getlistsize -#define PyList_GetSlice getlistslice -#define PyList_Insert inslistitem -#define PyList_New newlistobject -#define PyList_SetItem setlistitem -#define PyList_SetSlice setlistslice -#define PyList_Sort sortlist -#define PyDict_SetItemString dictinsert -#define PyDict_GetItemString dictlookup -#define PyDict_DelItemString dictremove -#define PyDict_Items getmappingitems -#define PyDict_Keys getmappingkeys -#define PyDict_Values getmappingvalues -#define PyDict_Clear mappingclear -#define PyDict_Next mappinggetnext -#define PyDict_SetItem mappinginsert -#define PyDict_GetItem mappinglookup -#define PyDict_DelItem mappingremove -#define PyDict_New newmappingobject -#define PyTuple_GetItem gettupleitem -#define PyTuple_GET_ITEM GETTUPLEITEM -#define PyTuple_Size gettuplesize -#define PyTuple_GetSlice gettupleslice -#define PyTuple_New newtupleobject -#define PyTuple_SetItem settupleitem -#define PyFile_GetLine filegetline -#define PyFile_AsFile getfilefile -#define PyFile_FromString newfileobject -#define PyFile_FromFile newopenfileobject -#define PyFile_SoftSpace softspace -#define PyFile_WriteObject writeobject -#define PyFile_WriteString writestring -#define PyMethod_Class instancemethodgetclass -#define PyMethod_Function instancemethodgetfunc -#define PyMethod_Self instancemethodgetself -#define PyClass_IsSubclass issubclass -#define PyClass_New newclassobject -#define PyMethod_New newinstancemethodobject -#define PyInstance_New newinstanceobject -#define PyTryBlock block -#define PyFrame_ExtendStack extend_stack -#define PyFrame_New newframeobject -#define PyFrame_BlockPop pop_block -#define PyFrame_BlockSetup setup_block -#define PyFunction_GetCode getfunccode -#define PyFunction_GetGlobals getfuncglobals -#define PyFunction_New newfuncobject -#define PyCFunction method -#define Py_FindMethod findmethod -#define PyCFunction_GetFunction getmethod -#define PyCFunction_GetSelf getself -#define PyCFunction_IsVarArgs getvarargs -#define PyCFunction_New newmethodobject -#define PyModule_GetDict getmoduledict -#define PyModule_GetName getmodulename -#define PyModule_New newmoduleobject -#define PyGrammar_AddAccelerators addaccelerators -#define PyGrammar_FindDFA finddfa -#define PyGrammar_LabelRepr labelrepr -#define PyNode_ListTree listtree -#define PyNode_AddChild addchild -#define PyNode_Free freetree -#define PyNode_New newtree -#define PyParser_AddToken addtoken -#define PyParser_Delete delparser -#define PyParser_New newparser -#define PyParser_ParseFile parsefile -#define PyParser_ParseString parsestring -#define PyToken_OneChar tok_1char -#define PyToken_TwoChars tok_2char -#define PyTokenizer_Free tok_free -#define PyTokenizer_Get tok_get -#define PyTokenizer_FromFile tok_setupf -#define PyTokenizer_FromString tok_setups -#define PyNode_Compile compile -#define PyCode_New newcodeobject -#define PyEval_CallObject call_object -#define PyEval_EvalCode eval_code -#define Py_FlushLine flushline -#define PyEval_GetBuiltins getbuiltins -#define PyEval_GetGlobals getglobals -#define PyEval_GetLocals getlocals -#define PyEval_InitThreads init_save_thread -#define PyErr_PrintTraceBack printtraceback -#define PyEval_RestoreThread restore_thread -#define PyEval_SaveThread save_thread -#define PyTraceBack_Fetch tb_fetch -#define PyTraceBack_Here tb_here -#define PyTraceBack_Print tb_print -#define PyTraceBack_Store tb_store -#define PyImport_AddModule add_module -#define PyImport_Cleanup doneimport -#define PyImport_GetModuleDict get_modules -#define PyImport_ImportModule import_module -#define PyImport_ImportFrozenModule init_frozen -#define PyImport_Init initimport -#define PyImport_ReloadModule reload_module -#define PyNumber_Coerce coerce -#define PyBuiltin_GetDict getbuiltindict -#define PyBuiltin_Init initbuiltin -#define PyMarshal_Init initmarshal -#define PyMarshal_ReadLongFromFile rd_long -#define PyMarshal_ReadObjectFromFile rd_object -#define PyMarshal_ReadObjectFromString rds_object -#define PyMarshal_WriteLongToFile wr_long -#define PyMarshal_WriteObjectToFile wr_object -#define PySys_Init initsys -#define PySys_SetArgv setpythonargv -#define PySys_SetPath setpythonpath -#define PySys_GetObject sysget -#define PySys_GetFile sysgetfile -#define PySys_SetObject sysset -#define Py_CompileString compile_string -#define Py_FatalError fatal -#define Py_Exit goaway -#define Py_Initialize initall -#define PyErr_Print print_error -#define PyParser_SimpleParseFile parse_file -#define PyParser_SimpleParseString parse_string -#define PyRun_AnyFile run -#define PyRun_SimpleFile run_script -#define PyRun_SimpleString run_command -#define PyRun_File run_file -#define PyRun_String run_string -#define PyRun_InteractiveOne run_tty_1 -#define PyRun_InteractiveLoop run_tty_loop -#define PyMember_Get getmember -#define PyMember_Set setmember -#define Py_InitModule(name, methods) initmodule(name, methods) -#define Py_BuildValue mkvalue -#define Py_VaBuildValue vmkvalue -#define PyArg_Parse getargs -#define PyArg_ParseTuple newgetargs -#define PyArg_NoArgs(v) getargs(v, "") -#define PyArg_GetChar getichararg -#define PyArg_GetDoubleArray getidoublearray -#define PyArg_GetFloat getifloatarg -#define PyArg_GetFloatArray getifloatarray -#define PyArg_GetInt getintarg -#define PyArg_GetLong getilongarg -#define PyArg_GetLongArray getilongarray -#define PyArg_GetLongArraySize getilongarraysize -#define PyArg_GetObject getiobjectarg -#define PyArg_GetShort getishortarg -#define PyArg_GetShortArray getishortarray -#define PyArg_GetShortArraySize getishortarraysize -#define PyArg_GetString getistringarg -#define PyErr_BadArgument err_badarg -#define PyErr_BadInternalCall err_badcall -#define PyErr_Input err_input -#define PyErr_NoMemory err_nomem -#define PyErr_SetFromErrno err_errno -#define PyErr_SetNone err_set -#define PyErr_SetString err_setstr -#define PyErr_SetObject err_setval -#define PyErr_Occurred err_occurred -#define PyErr_Fetch err_fetch -#define PyErr_Restore err_restore -#define PyErr_Clear err_clear -#define PyOS_InterruptableGetString fgets_intr -#define PyOS_InitInterrupts initintr -#define PyOS_InterruptOccurred intrcheck -#define PyOS_GetLastModificationTime getmtime - -#ifdef __cplusplus -} -#endif -#endif /* !Py_RENAME1_H */ diff --git a/Lib/builtin.py b/Lib/builtin.py deleted file mode 100755 index 710d8253a2..0000000000 --- a/Lib/builtin.py +++ /dev/null @@ -1,3 +0,0 @@ -# B/W compat hack so code that says "import builtin" won't break after -# name change from builtin to __builtin__. -from __builtin__ import * diff --git a/Lib/lib-old/whatsound.py b/Lib/lib-old/whatsound.py deleted file mode 100644 index b7b349c5ba..0000000000 --- a/Lib/lib-old/whatsound.py +++ /dev/null @@ -1,270 +0,0 @@ -# This module contains several routines that help recognizing sound -# files. -# -# Function whathdr() recognizes various types of sound file headers. -# It understands almost all headers that SOX can decode. -# -# The return tuple contains the following items, in this order: -# - file type (as SOX understands it) -# - sampling rate (0 if unknown or hard to decode) -# - number of channels (0 if unknown or hard to decode) -# - number of frames in the file (-1 if unknown or hard to decode) -# - number of bits/sample, or 'U' for U-LAW, or 'A' for A-LAW -# -# If the file doesn't have a recognizable type, it returns None. -# If the file can't be opened, IOError is raised. -# -# To compute the total time, divide the number of frames by the -# sampling rate (a frame contains a sample for each channel). -# -# Function whatraw() calls the "whatsound" program and interprets its -# output. You'll have to guess the sampling rate by listening though! -# -# Function what() calls whathdr() and if it doesn't recognize the file -# then calls whatraw(). -# -# Finally, the function test() is a simple main program that calls -# what() for all files mentioned on the argument list. For directory -# arguments it calls what() for all files in that directory. Default -# argument is "." (testing all files in the current directory). The -# option -r tells it to recurse down directories found inside -# explicitly given directories. -# -# The file structure is top-down except that the test program and its -# subroutine come last. - - -#------------------------------------------------------# -# Guess the type of any sound file, raw or with header # -#------------------------------------------------------# - -def what(filename): - res = whathdr(filename) - if not res: - res = whatraw(filename) - return res - - -#-----------------------------# -# Guess the type of raw sound # -#-----------------------------# - -def whatraw(filename): - # Assume it's always 1 channel, byte-sized samples - # Don't assume anything about the rate - import os - from stat import ST_SIZE - # XXX "whatsound" should be part of the distribution somehow... - cmd = 'whatsound ' + filename + ' 2>/dev/null' - cmd = 'PATH=$PATH:/ufs/guido/bin/sgi\n' + cmd - pipe = os.popen(cmd, 'r') - data = pipe.read() - sts = pipe.close() - if sts: - return None - if data[:13] == '-t raw -b -s ': - type = 'sb' - sample_size = 8 - elif data[:13] == '-t raw -b -u ': - type = 'ub' - sample_size = 8 - elif data[:13] == '-t raw -b -U ': - type = 'ul' - sample_size = 'U' - else: - return None - try: - frame_count = os.stat(filename)[ST_SIZE] - except IOError: - frame_count = -1 - return type, 0, 1, frame_count, sample_size - - -#-------------------------# -# Recognize sound headers # -#-------------------------# - -def whathdr(filename): - f = open(filename, 'r') - h = f.read(512) - for tf in tests: - res = tf(h, f) - if res: - return res - return None - - -#-----------------------------------# -# Subroutines per sound header type # -#-----------------------------------# - -tests = [] - -def test_aifc(h, f): - import aifc - if h[:4] <> 'FORM': - return None - if h[8:12] == 'AIFC': - fmt = 'aifc' - elif h[8:12] == 'AIFF': - fmt = 'aiff' - else: - return None - f.seek(0) - try: - a = aifc.openfp(f, 'r') - except (EOFError, aifc.Error): - return None - return (fmt, a.getframerate(), a.getnchannels(), \ - a.getnframes(), 8*a.getsampwidth()) - -tests.append(test_aifc) - - -def test_au(h, f): - if h[:4] == '.snd': - f = get_long_be - elif h[:4] in ('\0ds.', 'dns.'): - f = get_long_le - else: - return None - type = 'au' - hdr_size = f(h[4:8]) - data_size = f(h[8:12]) - encoding = f(h[12:16]) - rate = f(h[16:20]) - nchannels = f(h[20:24]) - sample_size = 1 # default - if encoding == 1: - sample_bits = 'U' - elif encoding == 2: - sample_bits = 8 - elif encoding == 3: - sample_bits = 16 - sample_size = 2 - else: - sample_bits = '?' - frame_size = sample_size * nchannels - return type, rate, nchannels, data_size/frame_size, sample_bits - -tests.append(test_au) - - -def test_hcom(h, f): - if h[65:69] <> 'FSSD' or h[128:132] <> 'HCOM': - return None - divisor = get_long_be(h[128+16:128+20]) - return 'hcom', 22050/divisor, 1, -1, 8 - -tests.append(test_hcom) - - -def test_voc(h, f): - if h[:20] <> 'Creative Voice File\032': - return None - sbseek = get_short_le(h[20:22]) - rate = 0 - if 0 <= sbseek < 500 and h[sbseek] == '\1': - ratecode = ord(h[sbseek+4]) - rate = int(1000000.0 / (256 - ratecode)) - return 'voc', rate, 1, -1, 8 - -tests.append(test_voc) - - -def test_wav(h, f): - # 'RIFF' 'WAVE' 'fmt ' - if h[:4] <> 'RIFF' or h[8:12] <> 'WAVE' or h[12:16] <> 'fmt ': - return None - style = get_short_le(h[20:22]) - nchannels = get_short_le(h[22:24]) - rate = get_long_le(h[24:28]) - sample_bits = get_short_le(h[34:36]) - return 'wav', rate, nchannels, -1, sample_bits - -tests.append(test_wav) - - -def test_8svx(h, f): - if h[:4] <> 'FORM' or h[8:12] <> '8SVX': - return None - # Should decode it to get #channels -- assume always 1 - return '8svx', 0, 1, 0, 8 - -tests.append(test_8svx) - - -def test_sndt(h, f): - if h[:5] == 'SOUND': - nsamples = get_long_le(h[8:12]) - rate = get_short_le(h[20:22]) - return 'sndt', rate, 1, nsamples, 8 - -tests.append(test_sndt) - - -def test_sndr(h, f): - if h[:2] == '\0\0': - rate = get_short_le(h[2:4]) - if 4000 <= rate <= 25000: - return 'sndr', rate, 1, -1, 8 - -tests.append(test_sndr) - - -#---------------------------------------------# -# Subroutines to extract numbers from strings # -#---------------------------------------------# - -def get_long_be(s): - return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3]) - -def get_long_le(s): - return (ord(s[3])<<24) | (ord(s[2])<<16) | (ord(s[1])<<8) | ord(s[0]) - -def get_short_be(s): - return (ord(s[0])<<8) | ord(s[1]) - -def get_short_le(s): - return (ord(s[1])<<8) | ord(s[0]) - - -#--------------------# -# Small test program # -#--------------------# - -def test(): - import sys - recursive = 0 - if sys.argv[1:] and sys.argv[1] == '-r': - del sys.argv[1:2] - recursive = 1 - try: - if sys.argv[1:]: - testall(sys.argv[1:], recursive, 1) - else: - testall(['.'], recursive, 1) - except KeyboardInterrupt: - sys.stderr.write('\n[Interrupted]\n') - sys.exit(1) - -def testall(list, recursive, toplevel): - import sys - import os - for filename in list: - if os.path.isdir(filename): - print filename + '/:', - if recursive or toplevel: - print 'recursing down:' - import glob - names = glob.glob(os.path.join(filename, '*')) - testall(names, recursive, 0) - else: - print '*** directory (use -r) ***' - else: - print filename + ':', - sys.stdout.flush() - try: - print what(filename) - except IOError: - print '*** not found ***' diff --git a/Lib/macstat.py b/Lib/macstat.py deleted file mode 100755 index 4b53953634..0000000000 --- a/Lib/macstat.py +++ /dev/null @@ -1,83 +0,0 @@ -# Module 'stat' -# -# Defines constants and functions for interpreting stat/lstat struct -# as returned by os.stat() and os.lstat() (if it exists). -# -# Suggested usage: from stat import * -# -# XXX Strictly spoken, this module may have to be adapted for each POSIX -# implementation; in practice, however, the numeric constants used by -# stat() are almost universal (even for stat() emulations on non-UNIX -# systems like MS-DOS). - -# Indices for stat struct members in tuple returned by os.stat() - -ST_MODE = 0 -ST_INO = 1 -ST_DEV = 2 -ST_NLINK = 3 -ST_UID = 4 -ST_GID = 5 -ST_SIZE = 6 -ST_ATIME = 7 -ST_MTIME = 8 -ST_CTIME = 9 - -# Extract bits from the mode - -def S_IMODE(mode): - return 0 - -def S_IFMT(mode): - return mode & 0xFFFF - -# Constants used as S_IFMT() for various file types -# (not all are implemented on all systems) - -S_IFDIR = 0x0000 -S_IFREG = 0x0003 - -# Functions to test for each file type - -def S_ISDIR(mode): - return S_IFMT(mode) == S_IFDIR - -def S_ISCHR(mode): - return 0 - -def S_ISBLK(mode): - return 0 - -def S_ISREG(mode): - return S_IFMT(mode) == S_IFREG - -def S_ISFIFO(mode): - return 0 - -def S_ISLNK(mode): - return 0 - -def S_ISSOCK(mode): - return 0 - -# Names for permission bits - -S_ISUID = 04000 -S_ISGID = 02000 -S_ENFMT = S_ISGID -S_ISVTX = 01000 -S_IREAD = 00400 -S_IWRITE = 00200 -S_IEXEC = 00100 -S_IRWXU = 00700 -S_IRUSR = 00400 -S_IWUSR = 00200 -S_IXUSR = 00100 -S_IRWXG = 00070 -S_IRGRP = 00040 -S_IWGRP = 00020 -S_IXGRP = 00010 -S_IRWXO = 00007 -S_IROTH = 00004 -S_IWOTH = 00002 -S_IXOTH = 00001 diff --git a/Lib/newimp.py b/Lib/newimp.py deleted file mode 100755 index 231a33dcea..0000000000 --- a/Lib/newimp.py +++ /dev/null @@ -1,1570 +0,0 @@ -"""Prototype of 'import' functionality enhanced to implement packages. - -Why packages? Packages enable module nesting and sibling module -imports. 'Til now, the python module namespace was flat, which -means every module had to have a unique name, in order to not -conflict with names of other modules on the load path. Furthermore, -suites of modules could not be structurally affiliated with one -another. - -With packages, a suite of, eg, email-oriented modules can include a -module named 'mailbox', without conflicting with the, eg, 'mailbox' -module of a shared-memory suite - 'email.mailbox' vs -'shmem.mailbox'. Packages also enable modules within a suite to -load other modules within their package without having the package -name hard-coded. Similarly, package suites of modules can be loaded -as a unit, by loading the package that contains them. - -Usage: once installed (newimp.install(); newimp.revert() to revert to -the prior __import__ routine), 'import ...' and 'from ... import ...' -can be used to: - - - import modules from the search path, as before. - - - import modules from within other directory "packages" on the search - path using a '.' dot-delimited nesting syntax. The nesting is fully - recursive. - - For example, 'import test.test_types' will import the test_types - module within the 'test' package. The calling environment would - then access the module as 'test.test_types', which is the name of - the fully-loaded 'test_types' module. It is found contained within - the stub (ie, only partially loaded) 'test' module, hence accessed as - 'test.test_types'. - - - import siblings from modules within a package, using '__.' as a shorthand - prefix to refer to the parent package. This enables referential - transparency - package modules need not know their package name. - - The '__' package references are actually names assigned within - modules, to refer to their containing package. This means that - variable references can be made to imported modules, or to variables - defined via 'import ... from', also using the '__.var' shorthand - notation. This establishes a proper equivalence between the import - reference '__.sibling' and the var reference '__.sibling'. - - - import an entire package as a unit, by importing the package directory. - If there is a module named '__init__.py' in the package, it controls the - load. Otherwise, all the modules in the dir, including packages, are - inherently loaded into the package module's namespace. - - For example, 'import test' will load the modules of the entire 'test' - package, at least until a test failure is encountered. - - In a package, a module with the name '__init__' has a special role. - If present in a package directory, then it is loaded into the package - module, instead of loading the contents of the directory. This - enables the __init__ module to control the load, possibly loading - the entire directory deliberately (using 'import __', or even - 'from __ import *', to load all the module contents directly into the - package module). - - - perform any combination of the above - have a package that contains - packages, etc. - -Modules have a few new attributes in support of packages. As mentioned -above, '__' is a shorthand attribute denoting the modules' parent package, -also denoted in the module by '__package__'. Additionally, modules have -associated with them a '__pkgpath__', a path by which sibling modules are -found.""" - -__version__ = "$Revision$" - -# $Id$ First release: -# Ken.Manheimer@nist.gov, 5-Apr-1995, for python 1.2 - -# Issues (scattered in code - search for three asterisks) -# *** Despite my efforts, 'reload(newimp)' will foul things up. -# *** Normalize_pathname will only work for Unix - which we need to detect. -# *** when a module with the name of the platform (as indicated by -# to-be-created var sys.platform), the package path gets '.' and the -# platform dir. -# *** use sys.impadmin for things like an import load-hooks var -# *** Import-load-hook keying module name versus package path, which dictates -# additions to the default ('.' and os-specific dir) path -# *** Document that the __init__.py can set __.__pkgpath__, in which case that -# will be used for the package-relative loads. -# *** Add a 'recursive' option to reload, for reload of package constituent -# modules (including subpackages), as well. Or maybe that should be the -# default, and eg stub-completion should override that default. ??? - -# Developers Notes: -# -# - 'sys.stub_modules' registers "incidental" (partially loaded) modules. -# A stub module is promoted to the fully-loaded 'sys.modules' list when it is -# explicitly loaded as a unit. -# - One load nuance - the actual load of most module types goes into the -# already-generated stub module. HOWEVER, eg dynamically loaded modules -# generate a new module object, which must supplant the existing stub. One -# consequence is that the import process must use indirection through -# sys.stub_modules or sys.modules to track the actual modules across some of -# the phases. -# - The test routines are cool, including a transient directory -# hierarchy facility, and a means of skipping to later tests by giving -# the test routine a numeric arg. -# - There may still be some loose ends, not to mention bugs. But the full -# functionality should be there. -# - The ImportStack object is necessary to carry the list of in-process imports -# across very open-ended recursions, where the state cannot be passed -# explicitly via the import_module calls; for a primary example, via exec of -# an 'import' statement within a module. -# - Python's (current) handling of extension modules, via imp.load_dynamic, -# does too much, some of which needs to be undone. See comments in -# load_module. Among other things, we actually change the __name__ of the -# module, which conceivably may break something. - -try: - VERBOSE -except NameError: - VERBOSE = 0 # Will be reset by init(1), also. - -import sys, string, regex, types, os, marshal, traceback -import __main__, __builtin__ - -newimp_globals = vars() - -try: - import imp # Build on this recent addition -except ImportError: - raise ImportError, 'Pkg import module depends on optional "imp" module'#==X - -from imp import SEARCH_ERROR, PY_SOURCE, PY_COMPILED, C_EXTENSION - -def defvar(varNm, envDict, val, override=0): - """If VARNAME does not have value in DICT, assign VAL to it. Optional arg - OVERRIDE means force the assignment in any case.""" - if (not envDict.has_key(varNm)) or override: - envDict[varNm] = val - -def init(full_reset=0): - """Do environment initialization, including retrofitting sys.modules with - module attributes.""" - # Retrofit all existing modules with package attributes, under auspices of - # __root__: - - locals, globals = vars(), newimp_globals - - if full_reset: - global VERBOSE - VERBOSE = 0 - - # sys.stub_modules tracks modules partially loaded modules, ie loaded only - # incidental to load of nested components. Together with sys.modules and - # the import stack, it serves as part of the module registration mechanism. - defvar('stub_modules', sys.__dict__, {}, full_reset) - - # Environment setup - "root" module, '__root__' - # Establish root package '__root__' in __main__ and newimp envs. - - # Longhand for name of variable identifying module's containing package: - defvar('PKG_NM', globals, "__package__", full_reset) - # Shorthand for module's container: - defvar('PKG_SHORT_NM', globals, "__", full_reset) - defvar('PKG_SHORT_NM_LEN', globals, len(PKG_SHORT_NM), full_reset) - - # Name of controlling module for a package, if any: - defvar('INIT_MOD_NM', globals, "__init__", full_reset) - - # Paths eventually will be extended to accomodate non-filesystem media - - # eg, URLs, composite objects, who knows. - - # Name assigned in sys for general import administration: - defvar('IMP_SYS_NM', globals, "imp_admin", full_reset) - defvar('MOD_LOAD_HOOKS', globals, "mod_load_hooks", full_reset) - if full_reset: - defvar(IMP_SYS_NM, sys.__dict__, {MOD_LOAD_HOOKS: {}}, full_reset) - - - # Name assigned in each module to tuple describing module import attrs: - defvar('IMP_ADMIN', globals, "__impadmin__", full_reset) - # The load-path obtaining for this package. Not defined for non-packages. - # If not set, package directory is used. If no package directory - # registered, sys.path is used. - defvar('PKG_PATH', globals, 0, full_reset) - # File from which module was loaded - may be None, eg, for __root__: - defvar('MOD_TYPE', globals, 1, full_reset) - # Exact path from which the module was loaded: - defvar('MOD_PATHNAME', globals, 2, full_reset) - # Package within which the module was found: - defvar('MOD_PACKAGE', globals, 3, full_reset) - defvar('USE_PATH', globals, 'either PKG_PATH or my dir', full_reset) - - # We're aliasing the top-level __main__ module as '__root__': - defvar('__root__', globals, __main__, full_reset) - defvar('ROOT_MOD_NM', globals, "__root__", full_reset) - if not sys.modules.has_key('__root__') or full_reset: - # and register it as an imported module: - sys.modules[ROOT_MOD_NM] = __root__ - - # Register package information in all existing top-level modules - they'll - # the None's mean, among other things, that their USE_PATH's all defer to - # sys.path. - for aMod in sys.modules.values(): - if (not aMod.__dict__.has_key(PKG_NM)) or full_reset: - set_mod_attrs(aMod, None, __root__, None, None) - - try: - __builtin__.__import__ - defvar('origImportFunc', globals, __builtin__.__import__) - defvar('origReloadFunc', globals, __builtin__.reload) - except AttributeError: - pass - - defvar('PY_PACKAGE', globals, 4, full_reset) - defvar('PY_FROZEN', globals, 5, full_reset) - defvar('PY_BUILTIN', globals, 6, full_reset) - - # Establish lookup table from mod-type "constants" to names: - defvar('mod_types', globals, - {SEARCH_ERROR: 'SEARCH_ERROR', - PY_SOURCE: 'PY_SOURCE', - PY_COMPILED: 'PY_COMPILED', - C_EXTENSION: 'C_EXTENSION', - PY_PACKAGE: 'PY_PACKAGE', - PY_FROZEN: 'PY_FROZEN', - PY_BUILTIN: 'PY_BUILTIN'}, - full_reset) - - defvar('stack', globals, ImportStack(), full_reset) - -def install(): - """Install newimp import_module() routine, for package support. - - newimp.revert() reverts to __import__ routine that was superceded.""" - __builtin__.__import__ = import_module - __builtin__.reload = reload - __builtin__.unload = unload - __builtin__.bypass = bypass - return 'Enhanced import functionality in place.' -def revert(): - """Revert to original __builtin__.__import__ func, if newimp.install() has - been executed.""" - if not (origImportFunc and origReloadFunc): - raise SystemError, "Can't find original import and reload funcs." # ==X - __builtin__.__import__ = origImportFunc - __builtin__.reload = origReloadFunc - del __builtin__.unload, __builtin__.bypass - return 'Original import routines back in place.' - -def import_module(name, - envLocals=None, envGlobals=None, - froms=None, - inPkg=None): - """Primary service routine implementing 'import' with package nesting. - - NAME: name as specified to 'import NAME' or 'from NAME...' - LOCALS, GLOBALS: local and global dicts obtaining for import - FROMS: list of strings of "..." in 'import blat from ...' - INPKG: package to which the name search is restricted, for use - by recursive package loads (from import_module()). - - A subtle difference from the old import - modules that do fail - initialization will not be registered in sys.modules, ie will not, in - effect, be registered as being loaded. Note further that packages which - fail their overall load, but have successfully loaded constituent modules, - will be accessible in the importing namespace as stub modules. - - A new routine, 'newimp.bypass()', provides the means to circumvent - constituent modules that fail their load, in order to enable load of the - remainder of a package.""" - - rootMod = sys.modules[ROOT_MOD_NM] - - note("import_module: seeking '%s'" % name, 1) - - # We need callers environment dict for local path and resulting module - # binding. - if not envGlobals: - # This should not happen, but does for imports called from within - # functions. - envLocals, envGlobals = exterior() - - if inPkg: - pkg = inPkg - elif envGlobals.has_key(PKG_NM): - pkg = envGlobals[PKG_NM] - else: - # ** KLUDGE - cover for modules that lack package attributes: - pkg = rootMod - - if pkg != rootMod: - note(' - relative to package %s' % pkg) - - modList = theMod = absNm = nesting = None - - # Normalize - # - absNm is absolute w.r.t. __root__ - # - relNm is relative w.r.t. pkg. - if inPkg: - absNm, relNm = pkg.__name__ + '.' + name, name - else: - absNm, relNm, pkg = normalize_import_ref(name, pkg) - note("Normalized: %s%s" % (absNm, (((relNm != absNm) - and (" ('%s' in %s)" % (relNm, pkg))) - or '')), 3) - - pkgPath = get_mod_attrs(pkg, USE_PATH) - - try: # try...finally guards import stack integrity. - - if stack.push(absNm): - # We're nested inside a containing import of this module, perhaps - # indirectly. Avoid infinite recursion at this point by using the - # existing stub module, for now. Load of it will be completed by - # the superior import. - note('recursion on in-process module %s, punting with stub' % - absNm) - theMod = stack.mod(absNm) - - else: - - # Try to find already-imported: - if sys.modules.has_key(absNm): - note('found ' + absNm + ' already imported') - theMod = sys.modules[absNm] - stack.mod(absNm, theMod) - - else: # Actually do load, of one sort or another: - - # Seek builtin or frozen first: - theMod = imp.init_builtin(absNm) - if theMod: - set_mod_attrs(theMod, None, pkg, None, PY_BUILTIN) - stack.mod(absNm, theMod) - note('found builtin ' + absNm) - else: - theMod = imp.init_frozen(absNm) - if theMod: - set_mod_attrs(theMod, None, pkg, None, PY_FROZEN) - stack.mod(absNm, theMod) - note('found frozen ' + absNm) - - if not theMod: - # Not already-loaded, in-process, builtin, or frozen - - # we're seeking in the outside world (filesystem): - - if sys.stub_modules.has_key(absNm): - - # A package for which we have a stub: - theMod = reload(sys.stub_modules[absNm], inPkg) - - else: - - # Now we actually search the fs. - - if type(pkgPath) == types.StringType: - pkgPath = [pkgPath] - - # Find a path leading to the module: - modList = find_module(relNm, pkgPath, absNm) - if not modList: - raise ImportError, ("module '%s' not found" % #==X - absNm) - - # We have a list of successively nested dirs leading - # to the module, register with import admin, as stubs: - nesting = register_mod_nesting(modList, pkg) - - # Load from file if necessary and possible: - modNm, modf, path, ty = modList[-1] - note('found type %s - %s' % (mod_types[ty[2]], absNm)) - - # Establish the module object in question: - theMod = procure_module(absNm) - stack.mod(absNm, theMod) - - # Do the load: - theMod = load_module(theMod, ty[2], modf, inPkg) - - commit_mod_containment(absNm) - - # Successful load - promote to fully-imported status: - register_module(theMod, theMod.__name__) - - - # We have a loaded module (perhaps stub): situate specified components, - # and return appropriate thing. According to guido: - # - # "Note that for "from spam.ham import bacon" your function should - # return the object denoted by 'spam.ham', while for "import - # spam.ham" it should return the object denoted by 'spam' -- the - # STORE instructions following the import statement expect it this - # way." - # *** The above rationale should probably be reexamined, since newimp - # actually takes care of populating the caller's namespace. - - if not froms: - - # Return the outermost container, possibly stub: - if nesting: - return find_mod_registration(nesting[0][0]) - else: - return find_mod_registration(string.splitfields(absNm,'.')[0]) - else: - - return theMod - - finally: # Decrement stack registration: - stack.pop(absNm) - - -def reload(module, inPkg = None): - """Re-parse and re-initialize an already (or partially) imported MODULE. - - The argument can be an already loaded module object or a string name of a - loaded module or a "stub" module that was partially loaded package module - incidental to the full load of a contained module. - - This is useful if you have edited the module source file using an external - editor and want to try out the new version without leaving the Python - interpreter. The return value is the resulting module object. - - Contrary to the old 'reload', the load is sought from the same location - where the module was originally found. If you wish to do a fresh load from - a different module on the path, do an 'unload()' and then an import. - - When a module is reloaded, its dictionary (containing the module's - global variables) is retained. Redefinitions of names will - override the old definitions, so this is generally not a problem. - If the new version of a module does not define a name that was - defined by the old version, the old definition remains. This - feature can be used to the module's advantage if it maintains a - global table or cache of objects -- with a `try' statement it can - test for the table's presence and skip its initialization if - desired. - - It is legal though generally not very useful to reload built-in or - dynamically loaded modules, except for `sys', `__main__' and - `__builtin__'. In certain cases, however, extension modules are - not designed to be initialized more than once, and may fail in - arbitrary ways when reloaded. - - If a module imports objects from another module using `from' ... - `import' ..., calling `reload()' for the other module does not - redefine the objects imported from it -- one way around this is to - re-execute the `from' statement, another is to use `import' and - qualified names (MODULE.NAME) instead. - - If a module instantiates instances of a class, reloading the module - that defines the class does not affect the method definitions of - the instances, unless they are reinstantiated -- they continue to use the - old class definition. The same is true for derived classes.""" - - if type(module) == types.StringType: - theMod = find_mod_registration(module) - elif type(module) == types.ModuleType: - theMod = module - else: - raise ImportError, '%s not already imported' # ==X - - if theMod in [sys.modules[ROOT_MOD_NM], sys.modules['__builtin__']]: - raise ImportError, 'cannot re-init internal module' # ==X - - try: - thePath = get_mod_attrs(theMod, MOD_PATHNAME) - except KeyError: - thePath = None - - if not thePath: - # If we have no path for the module, we can only reload it from - # scratch: - note('no pathname registered for %s, doing full reload' % theMod) - unload(theMod) - envGlobals, envLocals = exterior() - return import_module(theMod.__name__, - envGlobals, envLocals, None, inPkg) - else: - - stack.mod(theMod.__name__, theMod) - ty = get_mod_attrs(theMod, MOD_TYPE) - if ty in [PY_SOURCE, PY_COMPILED]: - note('reload invoked for %s %s' % (mod_types[ty], theMod)) - thePath, ty, openFile = prefer_compiled(thePath, ty) - else: - openFile = open(thePath, get_suffixes(ty)[1]) - return load_module(theMod, # ==> - ty, - openFile, - inPkg) -def unload(module): - """Remove registration for a module, so import will do a fresh load. - - Returns the module registries (sys.modules and/or sys.stub_modules) where - it was found.""" - if type(module) == types.ModuleType: - module = module.__name__ - gotit = [] - for which in ['sys.modules', 'sys.stub_modules']: - m = eval(which) - try: - del m[module] - gotit.append(which) - except KeyError: - pass - if not gotit: - raise ValueError, '%s not a module or a stub' % module # ==X - else: return gotit -def bypass(modNm): - """Register MODULE-NAME so module will be skipped, eg in package load.""" - if sys.modules.has_key(modNm): - raise ImportError("'%s' already imported, cannot be bypassed." % modNm) - else: - sys.modules[modNm] = imp.new_module('bypass()ed module %s' % modNm) - commit_mod_containment(modNm) - - -def normalize_import_ref(name, pkg): - """Produce absolute and relative nm and relative pkg given MODNM and origin - PACKAGE, reducing out all '__'s in the process.""" - - # First reduce out all the '__' container-refs we can: - outwards, inwards = 0, [] - for nm in string.splitfields(name, '.'): - if nm == PKG_SHORT_NM: - if inwards: - # Pop a containing inwards: - del inwards[-1] - else: - # (Effectively) leading '__' - notch outwards: - outwards = outwards + 1 - else: - inwards.append(nm) - inwards = string.joinfields(inwards, '.') - - # Now identify the components: - - if not outwards: - pkg = sys.modules[ROOT_MOD_NM] - else: - while outwards > 1: - pkg = pkg.__dict__[PKG_NM] # We'll just loop at top - if pkg == __root__: - break # ==v - outwards = outwards - 1 - - if not inwards: # Entire package: - return pkg.__name__, pkg.__name__, pkg # ==> - else: # Name relative to package: - if pkg == __root__: - return inwards, inwards, pkg # ==> - else: - return pkg.__name__ + '.' + inwards, inwards, pkg # ==> - -class ImportStack: - """Provide judicious support for mutually recursive import loops. - - Mutually recursive imports, eg a module that imports the package that - contains it, which in turn imports the module, are not uncommon, and must - be supported judiciously. This class is used to track cycles, so a module - already in the process of being imported (via 'stack.push(module)', and - concluded via 'stack.release(module)') is not redundantly pursued; *except* - when a module master '__init__.py' loads the module, in which case it is - 'stack.relax(module)'ed, so the full import is pursued.""" - - def __init__(self): - self._cycles = {} - self._mods = {} - self._looped = [] - def in_process(self, modNm): - """1 if modNm load already in process, 0 otherwise.""" - return self._cycles.has_key(modNm) # ==> - def looped(self, modNm): - """1 if modNm load has looped once or more, 0 otherwise.""" - return modNm in self._looped - def push(self, modNm): - """1 if modNm already in process and not 'relax'ed, 0 otherwise. - (Note that the 'looped' status remains even when the cycle count - returns to 1. This is so error messages can indicate that it was, at - some point, looped during the import process.)""" - if self.in_process(modNm): - self._looped.append(modNm) - self._cycles[modNm] = self._cycles[modNm] + 1 - return 1 # ==> - else: - self._cycles[modNm] = 1 - return 0 # ==> - def mod(self, modNm, mod=None): - """Associate MOD-NAME with MODULE, for easy reference.""" - if mod: - self._mods[modNm] = mod - else: - try: - return self._mods[modNm] # ==> - except KeyError: - return None - def pop(self, modNm): - """Decrement stack count of MODNM""" - if self.in_process(modNm): - amt = self._cycles[modNm] = self._cycles[modNm] - 1 - if amt < 1: - del self._cycles[modNm] - if modNm in self._looped: - self._looped.remove(modNm) - if self._mods.has_key(modNm): - del self._mods[modNm] - def relax(self, modNm): - """Enable modNm load despite being registered as already in-process.""" - if self._cycles.has_key(modNm): - del self._cycles[modNm] - -def find_module(name, path, absNm=''): - """Locate module NAME on PATH. PATH is pathname string or a list of them. - - Note that up-to-date compiled versions of a module are preferred to plain - source, and compilation is automatically performed when necessary and - possible. - - Returns a list of the tuples returned by 'find_mod_file()', one for - each nested level, deepest last.""" - - checked = [] # For avoiding redundant dir lists. - - if not absNm: absNm = name - - # Parse name into list of nested components, - expNm = string.splitfields(name, '.') - - for curPath in path: - - if (type(curPath) != types.StringType) or (curPath in checked): - # Disregard bogus or already investigated path elements: - continue # ==^ - else: - # Register it for subsequent disregard. - checked.append(curPath) - - if len(expNm) == 1: - - # Non-nested module name: - - got = find_mod_file(curPath, absNm) - if got: - note('using %s' % got[2], 3) - return [got] # ==> - - else: - - # Composite name specifying nested module: - - gotList = []; nameAccume = expNm[0] - - got = find_mod_file(curPath, nameAccume) - if not got: # Continue to next prospective path. - continue # ==^ - else: - gotList.append(got) - nm, file, fullPath, ty = got - - # Work on successively nested components: - for component in expNm[1:]: - # 'ty'pe of containing component must be package: - if ty[2] != PY_PACKAGE: - gotList, got = [], None - break # ==v - if nameAccume: - nameAccume = nameAccume + '.' + component - else: - nameAccume = component - got = find_mod_file(fullPath, nameAccume) - if got: - gotList.append(got) - nm, file, fullPath, ty = got - else: - # Clear state vars: - gotList, got, nameAccume = [], None, '' - break # ==v - # Found nesting all the way to the specified tip: - if got: - return gotList # ==> - - # Failed. - return None - -def find_mod_file(pathNm, modname): - """Find right module file given DIR and module NAME, compiling if needed. - - If successful, returns quadruple consisting of: - - mod name, - - file object, - - full pathname for the found file, - - a description triple as contained in the list returned by get_suffixes. - - Otherwise, returns None. - - Note that up-to-date compiled versions of a module are preferred to plain - source, and compilation is automatically performed, when necessary and - possible.""" - - relNm = modname[1 + string.rfind(modname, '.'):] - - for suff, mode, ty in get_suffixes(): - fullPath = os.path.join(pathNm, relNm + suff) - note('trying ' + fullPath + '...', 4) - try: - modf = open(fullPath, mode) - except IOError: - # ** ?? Skip unreadable ones: - continue # ==^ - - if ty == PY_PACKAGE: - # Enforce directory characteristic: - if not os.path.isdir(fullPath): - note('Skipping non-dir match ' + fullPath, 3) - continue # ==^ - else: - return (modname, modf, fullPath, (suff, mode, ty)) # ==> - - - elif ty in [PY_SOURCE, PY_COMPILED]: - usePath, useTy, openFile = prefer_compiled(fullPath, ty) - return (modname, # ==> - openFile, - usePath, - get_suffixes(useTy)) - - elif ty == C_EXTENSION: - note('found C_EXTENSION ' + fullPath, 3) - return (modname, modf, fullPath, (suff, mode, ty)) # ==> - - else: - raise SystemError, 'Unanticipated module type encountered' # ==X - - return None - -def prefer_compiled(path, ty, modf=None): - """Given a path to a .py or .pyc file, attempt to return a path to a - current pyc file, compiling the .py in the process if necessary. Returns - the path to the most current version we can get.""" - - if ty == PY_SOURCE: - if not modf: - try: - modf = open(path, 'r') - except IOError: - pass - note('working from PY_SOURCE', 3) - # Try for a compiled version: - pyc = path + 'c' # Sadly, we're presuming '.py' suff. - if (not os.path.exists(pyc) or - (os.stat(path)[8] > os.stat(pyc)[8])): - # Try to compile: - pyc = compile_source(path, modf) - if pyc and not (os.stat(path)[8] > os.stat(pyc)[8]): - # Either pyc was already newer or we just made it so; in either - # case it's what we crave: - note('but got newer compiled, ' + pyc, 3) - try: - return (pyc, PY_COMPILED, open(pyc, 'rb')) # ==> - except IOError: - if modf: - return (path, PY_SOURCE, modf) # ==> - else: - raise ImportError, 'Failed acces to .py and .pyc' # ==X - else: - note("couldn't get newer compiled, using PY_SOURCE", 3) - if modf: - return (path, PY_SOURCE, modf) # ==> - else: - raise ImportError, 'Failed acces to .py and .pyc' # ==X - - elif ty == PY_COMPILED: - note('working from PY_COMPILED', 3) - if not modf: - try: - modf = open(path, 'rb') - except IOError: - return prefer_compiled(path[:-1], PY_SOURCE) - # Make sure it is current, trying to compile if necessary, and - # prefer source failing that: - note('found compiled ' + path, 3) - py = path[:-1] # ** Presuming '.pyc' suffix - if not os.path.exists(py): - note('pyc SANS py: ' + path, 3) - return (path, PY_COMPILED, open(py, 'r')) # ==> - elif (os.stat(py)[8] > os.stat(path)[8]): - note('Forced to compile: ' + py, 3) - pyc = compile_source(py, open(py, 'r')) - if pyc: - return (pyc, PY_COMPILED, modf) # ==> - else: - note('failed compile - must use more recent .py', 3) - return (py, PY_SOURCE, open(py, 'r')) # ==> - else: - return (path, PY_COMPILED, modf) # ==> - -def load_module(theMod, ty, theFile, fromMod): - """Load module NAME, of TYPE, from FILE, within MODULE. - - Optional arg fromMod indicates the module from which the load is being done - - necessary for detecting import of __ from a package's __init__ module. - - Return the populated module object.""" - - # Note: we mint and register intermediate package directories, as necessary - - name = theMod.__name__ - nameTail = name[1 + string.rfind(name, '.'):] - thePath = theFile.name - - if ty == PY_SOURCE: - exec_into(theFile, theMod, theFile.name) - - elif ty == PY_COMPILED: - pyc = open(theFile.name, 'rb').read() - if pyc[0:4] != imp.get_magic(): - raise ImportError, 'bad magic number: ' + theFile.name # ==X - code = marshal.loads(pyc[8:]) - exec_into(code, theMod, theFile.name) - - elif ty == C_EXTENSION: - # Dynamically loaded C_EXTENSION modules do too much import admin, - # themselves, which we need to *undo* in order to integrate them with - # the new import scheme. - # 1 They register themselves in sys.modules, registering themselves - # under their top-level names. Have to rectify that. - # 2 The produce their own module objects, *unless* they find an - # existing module already registered a la 1, above. We employ this - # quirk to make it use the already generated module. - try: - # Stash a ref to any module that is already registered under the - # dyamic module's simple name (nameTail), so we can reestablish it - # after the dynamic takes over its' slot: - protMod = None - if nameTail != name: - if sys.modules.has_key(nameTail): - protMod = sys.modules[nameTail] - # Trick the dynamic load, by registering the module we generated - # under the nameTail of the module we're loading, so the one we're - # loading will use that established module, rather than producing a - # new one: - sys.modules[nameTail] = theMod - theMod = imp.load_dynamic(nameTail, thePath, theFile) - theMod.__name__ = name - # Cleanup dynamic mod's bogus self-registration, if necessary: - if nameTail != name: - if protMod: - # ... reinstating the one that was already there... - sys.modules[nameTail] = protMod - else: - if sys.modules.has_key(nameTail): - # Certain, as long os dynamics continue to misbehave. - del sys.modules[nameTail] - stack.mod(name, theMod) - if sys.stub_modules.has_key(name): - sys.stub_modules[name] = theMod - elif sys.modules.has_key(name): - sys.modules[name] = theMod - except: - # Provide import-nesting info, including signs of circularity: - raise sys.exc_type, import_trail_msg(str(sys.exc_value),# ==X - sys.exc_traceback, - name) - elif ty == PY_PACKAGE: - # Load package constituents, doing the controlling module *if* it - # exists *and* it isn't already in process: - - init_mod_f = init_mod = None - if not stack.in_process(name + '.' + INIT_MOD_NM): - # Not already doing __init__ - check for it: - init_mod_f = find_mod_file(thePath, INIT_MOD_NM) - else: - note('skipping already-in-process %s.%s' % (theMod.__name__, - INIT_MOD_NM)) - got = {} - if init_mod_f: - note("Found package's __init__: " + init_mod_f[2]) - # Enable full continuance of containing-package-load from __init__: - if stack.in_process(theMod.__name__): - stack.relax(theMod.__name__) - init_mod = import_module(INIT_MOD_NM, - theMod.__dict__, theMod.__dict__, - None, - theMod) - else: - # ... or else recursively load all constituent modules, except - # __init__: - for prospect in mod_prospects(thePath): - if prospect != INIT_MOD_NM: - import_module(prospect, - theMod.__dict__, theMod.__dict__, - None, - theMod) - - else: - raise ImportError, 'Unimplemented import type: %s' % ty # ==X - - return theMod - -def exec_into(obj, module, path): - """Helper for load_module, execfile/exec path or code OBJ within MODULE.""" - - # This depends on ability of exec and execfile to mutilate, erhm, mutate - # the __dict__ of a module. It will not work if/when this becomes - # disallowed, as it is for normal assignments. - - try: - if type(obj) == types.FileType: - execfile(path, module.__dict__, module.__dict__) - elif type(obj) in [types.CodeType, types.StringType]: - exec obj in module.__dict__, module.__dict__ - except: - # Make the error message nicer? - raise sys.exc_type, import_trail_msg(str(sys.exc_value), # ==X - sys.exc_traceback, - module.__name__) - - -def mod_prospects(path): - """Return a list of prospective modules within directory PATH. - - We actually return the distinct names resulting from stripping the dir - entries (excluding os.curdir and os.pardir) of their suffixes (as - represented by 'get_suffixes'). - - (Note that matches for the PY_PACKAGE type with null suffix are - implicitly constrained to be directories.)""" - - # We actually strip the longest matching suffixes, so eg 'dbmmodule.so' - # mates with 'module.so' rather than '.so'. - - dirList = os.listdir(path) - excludes = [os.curdir, os.pardir] - sortedSuffs = sorted_suffixes() - entries = [] - for item in dirList: - if item in excludes: continue # ==^ - for suff in sortedSuffs: - # *** ?? maybe platform-specific: - sub = -1 * len(suff) - if sub == 0: - if os.path.isdir(os.path.join(path, item)): - entries.append(item) - elif item[sub:] == suff: - it = item[:sub] - if not it in entries: - entries.append(it) - break # ==v - return entries - - - -def procure_module(name): - """Return an established or else new module object having NAME. - - First checks sys.modules, then sys.stub_modules.""" - - if sys.modules.has_key(name): - return sys.modules[name] # ==> - elif sys.stub_modules.has_key(name): - return sys.stub_modules[name] # ==> - else: - return (stack.mod(name) or imp.new_module(name)) # ==> - -def commit_mod_containment(name): - """Bind a module object and its containers within their respective - containers.""" - cume, pkg = '', find_mod_registration(ROOT_MOD_NM) - for next in string.splitfields(name, '.'): - if cume: - cume = cume + '.' + next - else: - cume = next - cumeMod = find_mod_registration(cume) - pkg.__dict__[next] = cumeMod - pkg = cumeMod - -def register_mod_nesting(modList, pkg): - """Given find_module()-style NEST-LIST and parent PACKAGE, register new - package components as stub modules, and return list of nested - module/relative-name pairs. - - Note that the modules objects are not situated in their containing packages - here - that is left 'til after a successful load, and done by - commit_mod_nesting().""" - nesting = [] - - for modNm, modF, path, ty in modList: - - relNm = modNm[1 + string.rfind(modNm, '.'):] - - if sys.modules.has_key(modNm): - theMod = sys.modules[modNm] # Nestle in containing package - pkg = theMod # Set as parent for next in sequence. - elif sys.stub_modules.has_key(modNm): - # Similar to above... - theMod = sys.stub_modules[modNm] - pkg = theMod - else: - theMod = procure_module(modNm) - stack.mod(modNm, theMod) - # *** ??? Should we be using 'path' instead of modF.name? If not, - # should we get rid of the 'path' return val? - set_mod_attrs(theMod, normalize_pathname(modF.name), - pkg, None, ty[2]) - if ty[2] == PY_PACKAGE: - # Register as a stub: - register_module(theMod, modNm, 1) - pkg = theMod - nesting.append((theMod.__name__,relNm)) - - return nesting - -def register_module(theMod, name, stub=0): - """Properly register MODULE, NAME, and optional STUB qualification.""" - - if stub: - sys.stub_modules[name] = theMod - else: - sys.modules[name] = theMod - if sys.stub_modules.has_key(name): - del sys.stub_modules[name] - -def find_mod_registration(name): - """Find module named NAME sys.modules, .stub_modules, or on the stack.""" - if sys.stub_modules.has_key(name): - return sys.stub_modules[name] # ==> - elif sys.modules.has_key(name): - return sys.modules[name] # ==> - else: - if stack.in_process(name): - it = stack.mod(name) - if it: - return it # ==> - else: - raise ValueError, '%s %s in %s or %s' % (name, # ==X - 'not registered', - 'sys.modules', - 'sys.stub_modules') - -def get_mod_attrs(theMod, which = None): - """Get MODULE object's path, containing-package, and designated path. - - Virtual attribute USE_PATH is derived from PKG_PATH, MOD_PATHNAME, - and/or sys.path, depending on the module type and settings.""" - it = theMod.__dict__[IMP_ADMIN] - if which: - # Load path is either the explicitly designated load path for the - # package, or else the directory in which it resides: - if which == USE_PATH: - if it[PKG_PATH]: - # Return explicitly designated path: - return it[PKG_PATH] # ==> - if it[MOD_PATHNAME]: - if it[MOD_TYPE] == PY_PACKAGE: - # Return the package's directory path: - return [it[MOD_PATHNAME]] # ==> - else: - # Return the directory where the module resides: - return [os.path.split(it[MOD_PATHNAME])[0]] # ==> - # No explicitly designated path - use sys.path, eg for system - # modules, etc: - return sys.path - return it[which] # ==> - else: - return it # ==> - -def set_mod_attrs(theMod, path, pkg, pkgPath, ty): - """Register MOD import attrs PATH, PKG container, and PKGPATH, linking - the package container into the module along the way.""" - theDict = theMod.__dict__ - try: - # Get existing one, if any: - it = theDict[IMP_ADMIN] - except KeyError: - # None existing, gen a new one: - it = [None] * 4 - for fld, val in ((MOD_PATHNAME, path), (MOD_PACKAGE, pkg), - (PKG_PATH, pkgPath), (MOD_TYPE, ty)): - if val: - it[fld] = val - - theDict[IMP_ADMIN] = it - if pkg: - theDict[PKG_NM] = theDict[PKG_SHORT_NM] = pkg - return it # ==> - -def format_tb_msg(tb, recursive): - """This should be in traceback.py, and traceback.print_tb() should use it - and traceback.extract_tb(), instead of print_tb() and extract_tb() having - so much redundant code!""" - tb_lines, formed = traceback.extract_tb(tb), '' - for line in tb_lines: - f, lno, nm, ln = line - if f[-1 * (len(__name__) + 3):] == __name__ + '.py': - # Skip newimp notices - agregious hack, justified only by the fact - # that this functionality will be properly doable in new impending - # exception mechanism: - continue - formed = formed + ('\n%s File "%s", line %d, in %s%s' % - (((recursive and '*') or ' '), - f, lno, nm, - ((ln and '\n ' + string.strip(ln)) or ''))) - return formed - -def import_trail_msg(msg, tb, modNm): - """Doctor an error message to include the path of the current import, and - a sign that it is a circular import, if so.""" - return (msg + - format_tb_msg(tb, - (stack.looped(modNm) and stack.in_process(modNm)))) - -def compile_source(sourcePath, sourceFile): - """Given python code source path and file obj, Create a compiled version. - - Return path of compiled version, or None if file creation is not - successful. (Compilation errors themselves are passed without restraint.) - - This is an import-private interface, and not well-behaved for general use. - - In particular, we presume the validity of the sourcePath, and that it - includes a '.py' extension.""" - - compiledPath = sourcePath[:-3] + '.pyc' - try: - compiledFile = open(compiledPath, 'wb') - except IOError: - note("write permission denied to " + compiledPath, 3) - return None - mtime = os.stat(sourcePath)[8] - - try: - compiled = compile(sourceFile.read(), sourcePath, 'exec') - except SyntaxError: - # Doctor the exception a bit, to include the source file name in - # the report, and then reraise the doctored version. - os.unlink(compiledFile.name) - sys.exc_value = ((sys.exc_value[0] + ' in ' + sourceFile.name,) - + sys.exc_value[1:]) - raise sys.exc_type, sys.exc_value # ==X - - # Ok, we have a valid compilation. - try: - compiledFile.write(imp.get_magic()) # compiled magic number - compiledFile.seek(8, 0) # mtime space holder - marshal.dump(compiled, compiledFile) # write the code obj - compiledFile.seek(4, 0) # position for mtime - compiledFile.write(marshal.dumps(mtime)[1:]) # register mtime - compiledFile.flush() - compiledFile.close() - return compiledPath - except IOError: - return None # ==> - - -got_suffixes = None -got_suffixes_dict = {} -def get_suffixes(ty=None): - """Produce a list of triples, each describing a type of import file. - - Triples have the form '(SUFFIX, MODE, TYPE)', where: - - SUFFIX is a string found appended to a module name to make a filename for - that type of import file. - - MODE is the mode string to be passed to the built-in 'open' function - "r" - for text files, "rb" for binary. - - TYPE is the file type: - - PY_SOURCE: python source code, - PY_COMPILED: byte-compiled python source, - C_EXTENSION: compiled-code object file, - PY_PACKAGE: python library directory, or - SEARCH_ERROR: no module found. """ - - # Note: sorted_suffixes() depends on this function's value being invariant. - # sorted_suffixes() must be revised if this becomes untrue. - - global got_suffixes, got_suffixes_dict - - if not got_suffixes: - # Ensure that the .pyc suffix precedes the .py: - got_suffixes = [('', 'r', PY_PACKAGE)] - got_suffixes_dict[PY_PACKAGE] = ('', 'r', PY_PACKAGE) - py = pyc = None - for suff in imp.get_suffixes(): - got_suffixes_dict[suff[2]] = suff - if suff[0] == '.py': - py = suff - elif suff[0] == '.pyc': - pyc = suff - else: - got_suffixes.append(suff) - got_suffixes.append(pyc) - got_suffixes.append(py) - if ty: - return got_suffixes_dict[ty] # ==> - else: - return got_suffixes # ==> - - -sortedSuffs = [] # State vars for sorted_suffixes(). Go -def sorted_suffixes(): - """Helper function ~efficiently~ tracks sorted list of module suffixes.""" - - # Produce sortedSuffs once - this presumes that get_suffixes does not - # change from call to call during a python session. Needs to be - # corrected if that becomes no longer true. - - global sortedsuffs - if not sortedSuffs: # do compute only the "first" time - for item in get_suffixes(): - sortedSuffs.append(item[0]) - # Sort them in descending order: - sortedSuffs.sort(lambda x, y: (((len(x) > len(y)) and 1) or - ((len(x) < len(y)) and -1))) - sortedSuffs.reverse() - return sortedSuffs - - -def normalize_pathname(path): - """Given PATHNAME, return an absolute pathname relative to cwd, reducing - unnecessary components where convenient (eg, on Unix).""" - - # We do a lot more when we have posix-style paths, eg os.sep == '/'. - - if os.sep != '/': - return os.path.join(os.getcwd, path) # ==> - - outwards, inwards = 0, [] - for nm in string.splitfields(path, os.sep): - if nm != os.curdir: - if nm == os.pardir: - # Translate parent-dir entries to outward notches: - if inwards: - # Pop a containing inwards: - del inwards[-1] - else: - # Register leading outward notches: - outwards = outwards + 1 - else: - inwards.append(nm) - inwards = string.joinfields(inwards, os.sep) - - if (not inwards) or (inwards[0] != os.sep): - # Relative path - join with current working directory, (ascending - # outwards to account for leading parent-dir components): - cwd = os.getcwd() - if outwards: - cwd = string.splitfields(cwd, os.sep) - cwd = string.joinfields(cwd[:len(cwd) - outwards], os.sep) - if inwards: - return os.path.join(cwd, inwards) # ==> - else: - return cwd # ==> - else: - return inwards # ==> - - -# exterior(): Utility routine, obtain local and global dicts of environment -# containing/outside the callers environment, ie that of the -# caller's caller. Routines can use exterior() to determine the -# environment from which they were called. - -def exterior(): - """Return dyad containing locals and globals of caller's caller. - - Locals will be None if same as globals, ie env is global env.""" - - bogus = 'bogus' # A locally usable exception - try: raise bogus # Force an exception object - except bogus: - at = sys.exc_traceback.tb_frame.f_back # The external frame. - if at.f_back: at = at.f_back # And further, if any. - globals, locals = at.f_globals, at.f_locals - if locals == globals: # Exterior is global? - locals = None - return (locals, globals) - -######################################################################### -# TESTING FACILITIES # - -def note(msg, threshold=2): - if VERBOSE >= threshold: sys.stderr.write('(import: ' + msg + ')\n') - -class TestDirHier: - """Populate a transient directory hierarchy according to a definition - template - so we can create package/module hierarchies with which to - exercise the new import facilities...""" - - def __init__(self, template, where='/var/tmp'): - """Establish a dir hierarchy, according to TEMPLATE, that will be - deleted upon deletion of this object (or deliberate invocation of the - __del__ method).""" - self.PKG_NM = 'tdh_' - rev = 0 - while os.path.exists(os.path.join(where, self.PKG_NM+str(rev))): - rev = rev + 1 - sys.exc_traceback = None # Ensure Discard of try/except obj ref - self.PKG_NM = self.PKG_NM + str(rev) - self.root = os.path.join(where, self.PKG_NM) - self.createDir(self.root) - self.add(template) - - def __del__(self): - """Cleanup the test hierarchy.""" - self.remove() - def add(self, template, root=None): - """Populate directory according to template dictionary. - - Keys indicate file names, possibly directories themselves. - - String values dictate contents of flat files. - - Dictionary values dictate recursively embedded dictionary templates.""" - if root == None: root = self.root - for key, val in template.items(): - name = os.path.join(root, key) - if type(val) == types.StringType: # flat file - self.createFile(name, val) - elif type(val) == types.DictionaryType: # embedded dir - self.createDir(name) - self.add(val, name) - else: - raise ValueError, ('invalid file-value type, %s' % # ==X - type(val)) - def remove(self, name=''): - """Dispose of the NAME (or keys in dictionary), using 'rm -r'.""" - name = os.path.join(self.root, name) - sys.exc_traceback = None # Ensure Discard of try/except obj ref - if os.path.exists(name): - print '(TestDirHier: eradicating %s)' % name - os.system('rm -r ' + name) - else: - raise IOError, "can't remove non-existent " + name # ==X - def createFile(self, name, contents=None): - """Establish file NAME with CONTENTS. - - If no contents specfied, contents will be 'print NAME'.""" - f = open(name, 'w') - if not contents: - f.write("print '" + name + "'\n") - else: - f.write(contents) - f.close - def createDir(self, name): - """Create dir with NAME.""" - return os.mkdir(name, 0755) - -skipToTest = 0 -atTest = 1 -def testExec(msg, execList, locals, globals): - global skipToTest, atTest - print 'Import Test:', '(' + str(atTest) + ')', msg, '...' - atTest = atTest + 1 - if skipToTest > (atTest - 1): - print ' ... skipping til test', skipToTest - return - else: - print '' - for stmt in execList: - exec stmt in locals, globals - -def test(number=0, leaveHiers=0): - """Exercise import functionality, creating a transient dir hierarchy for - the purpose. - - We actually install the new import functionality, temporarily, resuming the - existing function on cleanup.""" - - import __builtin__ - - global skipToTest, atTest - skipToTest = number - hier = None - - def unloadFull(mod): - """Unload module and offspring submodules, if any.""" - modMod = '' - if type(mod) == types.StringType: - modNm = mod - elif type(mod) == types.ModuleType: - modNm = modMod.__name__ - for subj in sys.modules.keys() + sys.stub_modules.keys(): - if subj[0:len(modNm)] == modNm: - unload(subj) - - try: - __main__.testMods - except AttributeError: - __main__.testMods = [] - testMods = __main__.testMods - - - # Install the newimp routines, within a try/finally: - try: - sys.exc_traceback = None - wasImport = __builtin__.__import__ # Stash default - wasPath = sys.path - except AttributeError: - wasImport = None - try: - hiers = []; modules = [] - global VERBOSE - wasVerbose, VERBOSE = VERBOSE, 1 - __builtin__.__import__ = import_module # Install new version - - if testMods: # Clear out imports from previous tests - for m in testMods[:]: - unloadFull(m) - testMods.remove(m) - - # ------ - # Test 1 - testExec("already imported module: %s" % sys.modules.keys()[0], - ['import ' + sys.modules.keys()[0]], - vars(), newimp_globals) - no_sirree = 'no_sirree_does_not_exist' - # ------ - # Test 2 - testExec("non-existent module: %s" % no_sirree, - ['try: import ' + no_sirree + - '\nexcept ImportError: pass'], - vars(), newimp_globals) - got = None - - # ------ - # Test 3 - # Find a module that's not yet loaded, from a list of prospects: - for mod in ['Complex', 'UserDict', 'UserList', 'calendar', - 'cmd', 'dis', 'mailbox', 'profile', 'random', 'rfc822']: - if not (mod in sys.modules.keys()): - got = mod - break # ==v - if got: - testExec("not-yet loaded module: %s" % mod, - ['import ' + mod, 'modules.append(got)'], - vars(), newimp_globals) - else: - testExec("not-yet loaded module: list exhausted, never mind", - [], vars(), newimp_globals) - - # Now some package stuff. - - # ------ - # Test 4 - # First change the path to include our temp dir, copying so the - # addition can be revoked on cleanup in the finally, below: - sys.path = ['/var/tmp'] + sys.path[:] - # Now create a trivial package: - stmts = ["hier1 = TestDirHier({'a.py': 'print \"a.py executing\"'})", - "hiers.append(hier1)", - "base = hier1.PKG_NM", - "exec 'import ' + base", - "testMods.append(base)"] - testExec("trivial package, with one module, a.py", - stmts, vars(), newimp_globals) - - # ------ - # Test 5 - # Slightly less trivial package - reference to '__': - stmts = [("hier2 = TestDirHier({'ref.py': 'print \"Pkg __:\", __'})"), - "base = hier2.PKG_NM", - "hiers.append(hier2)", - "exec 'import ' + base", - "testMods.append(base)"] - testExec("trivial package, with module that has pkg shorthand ref", - stmts, vars(), newimp_globals) - - # ------ - # Test 6 - # Nested package, plus '__' references: - - complexTemplate = {'ref.py': 'print "ref.py loading..."', - 'suite': {'s1.py': 'print "s1.py, in pkg:", __', - 'subsuite': {'sub1.py': - 'print "sub1.py"'}}} - stmts = [('print """%s\n%s\n%s\n%s\n%s\n%s"""' % - ('.../', - ' ref.py\t\t\t"ref.py loading..."', - ' suite/', - ' s1.py \t\t"s1.py, in pkg: xxxx.suite"', - ' subsuite/', - ' sub1.py "sub1.py" ')), - "hier3 = TestDirHier(complexTemplate)", - "base = hier3.PKG_NM", - "hiers.append(hier3)", - "exec 'import ' + base", - "testMods.append(base)"] - testExec("Significantly nestled package:", - stmts, vars(), newimp_globals) - - # ------ - # Test 7 - # Try an elaborate hierarchy which includes an __init__ master in one - # one portion, a ref across packages within the hierarchies, and an - # indirect recursive import which cannot be satisfied (and hence, - # prevents load of part of the hierarchy). - complexTemplate = {'mid': - {'prime': - {'__init__.py': 'import __.easy, __.nother', - 'easy.py': 'print "easy.py:", __name__', - 'nother.py': ('%s\n%s\n%s\n' % - ('import __.easy', - 'print "nother got __.easy"', - # __.__.awry should be found but - # should not load successfully, - # disrupting nother, but not easy - 'import __.__.awry'))}, - # continuing dict 'mid': - 'awry': - {'__init__.py': - ('%s\n%s' % - ('print "got " + __name__', - 'from __ import *')), - # This mutual recursion (b->a, a->d->b) should be - # ok, since a.py sets ax before recursing. - 'a.py': 'ax = 1; from __.b import bx', - 'b.py': 'bx = 1; from __.a import ax'}}} - stmts = ["hier5 = TestDirHier(complexTemplate)", - "base = hier5.PKG_NM", - "testMods.append(base)", - "hiers.append(hier5)", - "exec 'import %s.mid.prime' % base", - "print eval(base)", # Verify the base was bound - "testMods.append(base)"] - testExec("Elaborate, clean hierarchy", - stmts, vars(), newimp_globals) - - # ------ - # test 8 - # Here we disrupt the mutual recursion in the mid.awry package, so the - # import should now fail. - complexTemplate['mid']['awry']['a.py'] = 'from __.b import bx; ax = 1' - complexTemplate['mid']['awry']['b.py'] = 'from __.a import ax; bx = 1' - stmts = ["hier6 = TestDirHier(complexTemplate)", - "base = hier6.PKG_NM", - "testMods.append(base)", - "hiers.append(hier6)", - "work = ('import %s.mid.prime' % base)", - ("try: exec work" + - "\nexcept ImportError: print ' -- import failed, as ought'" + - "\nelse: raise SystemError, sys.exc_value"), - "testMods.append(base)"] - testExec("Elaborate hier w/ deliberately flawed import recursion", - stmts, vars(), newimp_globals) - - sys.exc_traceback = None # Signify clean conclusion. - - finally: - skipToTest = 0 - atTest = 1 - sys.path = wasPath - VERBOSE = wasVerbose - if wasImport: # Resurrect prior routine - __builtin__.__import__ = wasImport - else: - del __builtin__.__import__ - if leaveHiers: - print 'Cleanup inhibited' - else: - if sys.exc_traceback: - print ' ** Import test FAILURE... cleanup.' - else: - print ' Import test SUCCESS... cleanup' - for h in hiers: h.remove(); del h # Dispose of test directories - -init() - -if __name__ == '__main__': - test() diff --git a/Lib/persist.py b/Lib/persist.py deleted file mode 100755 index 8f0f164bc6..0000000000 --- a/Lib/persist.py +++ /dev/null @@ -1,297 +0,0 @@ -# persist.py -# -# Implement limited persistence. -# -# Simple interface: -# persist.save() save __main__ module on file (overwrite) -# persist.load() load __main__ module from file (merge) -# -# These use the filename persist.defaultfile, initialized to 'wsrestore.py'. -# -# A raw interface also exists: -# persist.writedict(dict, fp) save dictionary to open file -# persist.readdict(dict, fp) read (merge) dictionary from open file -# -# Internally, the function dump() and a whole bunch of support of functions -# traverse a graph of objects and print them in a restorable form -# (which happens to be a Python module). -# -# XXX Limitations: -# - Volatile objects are dumped as strings: -# - open files, windows etc. -# - Other 'obscure' objects are dumped as strings: -# - classes, instances and methods -# - compiled regular expressions -# - anything else reasonably obscure (e.g., capabilities) -# - type objects for obscure objects -# - It's slow when there are many of lists or dictionaries -# (This could be fixed if there were a quick way to compute a hash -# function of any object, even if recursive) - -defaultfile = 'wsrestore.py' - -def save(): - import __main__ - import os - # XXX On SYSV, if len(defaultfile) >= 14, this is wrong! - backup = defaultfile + '~' - try: - os.unlink(backup) - except os.error: - pass - try: - os.rename(defaultfile, backup) - except os.error: - pass - fp = open(defaultfile, 'w') - writedict(__main__.__dict__, fp) - fp.close() - -def load(): - import __main__ - fp = open(defaultfile, 'r') - readdict(__main__.__dict__, fp) - -def writedict(dict, fp): - import sys - savestdout = sys.stdout - try: - sys.stdout = fp - dump(dict) # Writes to sys.stdout - finally: - sys.stdout = savestdout - -def readdict(dict, fp): - contents = fp.read() - globals = {} - exec(contents, globals) - top = globals['top'] - for key in top.keys(): - if dict.has_key(key): - print 'warning:', key, 'not overwritten' - else: - dict[key] = top[key] - - -# Function dump(x) prints (on sys.stdout!) a sequence of Python statements -# that, when executed in an empty environment, will reconstruct the -# contents of an arbitrary dictionary. - -import sys - -# Name used for objects dict on output. -# -FUNNYNAME = FN = 'A' - -# Top-level function. Call with the object you want to dump. -# -def dump(x): - types = {} - stack = [] # Used by test for recursive objects - print FN, '= {}' - topuid = dumpobject(x, types, stack) - print 'top =', FN, '[', `topuid`, ']' - -# Generic function to dump any object. -# -dumpswitch = {} -# -def dumpobject(x, types, stack): - typerepr = `type(x)` - if not types.has_key(typerepr): - types[typerepr] = {} - typedict = types[typerepr] - if dumpswitch.has_key(typerepr): - return dumpswitch[typerepr](x, typedict, types, stack) - else: - return dumpbadvalue(x, typedict, types, stack) - -# Generic function to dump unknown values. -# This assumes that the Python interpreter prints such values as -# . -# The object will be read back as a string: ''. -# In some cases it may be possible to fix the dump manually; -# to ease the editing, these cases are labeled with an XXX comment. -# -def dumpbadvalue(x, typedict, types, stack): - xrepr = `x` - if typedict.has_key(xrepr): - return typedict[xrepr] - uid = genuid() - typedict[xrepr] = uid - print FN, '[', `uid`, '] =', `xrepr`, '# XXX' - return uid - -# Generic function to dump pure, simple values, except strings -# -def dumpvalue(x, typedict, types, stack): - xrepr = `x` - if typedict.has_key(xrepr): - return typedict[xrepr] - uid = genuid() - typedict[xrepr] = uid - print FN, '[', `uid`, '] =', `x` - return uid - -# Functions to dump string objects -# -def dumpstring(x, typedict, types, stack): - # XXX This can break if strings have embedded '\0' bytes - # XXX because of a bug in the dictionary module - if typedict.has_key(x): - return typedict[x] - uid = genuid() - typedict[x] = uid - print FN, '[', `uid`, '] =', `x` - return uid - -# Function to dump type objects -# -typeswitch = {} -class some_class: - def method(self): pass -some_instance = some_class() -# -def dumptype(x, typedict, types, stack): - xrepr = `x` - if typedict.has_key(xrepr): - return typedict[xrepr] - uid = genuid() - typedict[xrepr] = uid - if typeswitch.has_key(xrepr): - print FN, '[', `uid`, '] =', typeswitch[xrepr] - elif x == type(sys): - print 'import sys' - print FN, '[', `uid`, '] = type(sys)' - elif x == type(sys.stderr): - print 'import sys' - print FN, '[', `uid`, '] = type(sys.stderr)' - elif x == type(dumptype): - print 'def some_function(): pass' - print FN, '[', `uid`, '] = type(some_function)' - elif x == type(some_class): - print 'class some_class: pass' - print FN, '[', `uid`, '] = type(some_class)' - elif x == type(some_instance): - print 'class another_class: pass' - print 'some_instance = another_class()' - print FN, '[', `uid`, '] = type(some_instance)' - elif x == type(some_instance.method): - print 'class yet_another_class:' - print ' def method(): pass' - print 'another_instance = yet_another_class()' - print FN, '[', `uid`, '] = type(another_instance.method)' - else: - # Unknown type - print FN, '[', `uid`, '] =', `xrepr`, '# XXX' - return uid - -# Initialize the typeswitch -# -for x in None, 0, 0.0, '', (), [], {}: - typeswitch[`type(x)`] = 'type(' + `x` + ')' -for s in 'type(0)', 'abs', '[].append': - typeswitch[`type(eval(s))`] = 'type(' + s + ')' - -# Dump a tuple object -# -def dumptuple(x, typedict, types, stack): - item_uids = [] - xrepr = '' - for item in x: - item_uid = dumpobject(item, types, stack) - item_uids.append(item_uid) - xrepr = xrepr + ' ' + item_uid - del stack[-1:] - if typedict.has_key(xrepr): - return typedict[xrepr] - uid = genuid() - typedict[xrepr] = uid - print FN, '[', `uid`, '] = (', - for item_uid in item_uids: - print FN, '[', `item_uid`, '],', - print ')' - return uid - -# Dump a list object -# -def dumplist(x, typedict, types, stack): - # Check for recursion - for x1, uid1 in stack: - if x is x1: return uid1 - # Check for occurrence elsewhere in the typedict - for uid1 in typedict.keys(): - if x is typedict[uid1]: return uid1 - # This uses typedict differently! - uid = genuid() - typedict[uid] = x - print FN, '[', `uid`, '] = []' - stack.append(x, uid) - item_uids = [] - for item in x: - item_uid = dumpobject(item, types, stack) - item_uids.append(item_uid) - del stack[-1:] - for item_uid in item_uids: - print FN, '[', `uid`, '].append(', FN, '[', `item_uid`, '])' - return uid - -# Dump a dictionary object -# -def dumpdict(x, typedict, types, stack): - # Check for recursion - for x1, uid1 in stack: - if x is x1: return uid1 - # Check for occurrence elsewhere in the typedict - for uid1 in typedict.keys(): - if x is typedict[uid1]: return uid1 - # This uses typedict differently! - uid = genuid() - typedict[uid] = x - print FN, '[', `uid`, '] = {}' - stack.append(x, uid) - item_uids = [] - for key in x.keys(): - val_uid = dumpobject(x[key], types, stack) - item_uids.append(key, val_uid) - del stack[-1:] - for key, val_uid in item_uids: - print FN, '[', `uid`, '][', `key`, '] =', - print FN, '[', `val_uid`, ']' - return uid - -# Dump a module object -# -def dumpmodule(x, typedict, types, stack): - xrepr = `x` - if typedict.has_key(xrepr): - return typedict[xrepr] - from string import split - # `x` has the form - name = xrepr[9:-2] - uid = genuid() - typedict[xrepr] = uid - print 'import', name - print FN, '[', `uid`, '] =', name - return uid - - -# Initialize dumpswitch, a table of functions to dump various objects, -# indexed by `type(x)`. -# -for x in None, 0, 0.0: - dumpswitch[`type(x)`] = dumpvalue -for x, f in ('', dumpstring), (type(0), dumptype), ((), dumptuple), \ - ([], dumplist), ({}, dumpdict), (sys, dumpmodule): - dumpswitch[`type(x)`] = f - - -# Generate the next unique id; a string consisting of digits. -# The seed is stored as seed[0]. -# -seed = [0] -# -def genuid(): - x = seed[0] - seed[0] = seed[0] + 1 - return `x` diff --git a/Lib/urlopen.py b/Lib/urlopen.py deleted file mode 100755 index c43b7f4f69..0000000000 --- a/Lib/urlopen.py +++ /dev/null @@ -1,410 +0,0 @@ -# Open an arbitrary URL -# -# See the following document for a tentative description of URLs: -# Uniform Resource Locators Tim Berners-Lee -# INTERNET DRAFT CERN -# IETF URL Working Group 14 July 1993 -# draft-ietf-uri-url-01.txt -# -# The object returned by URLopener().open(file) will differ per -# protocol. All you know is that is has methods read(), readline(), -# readlines(), fileno(), close() and info(). The read*(), fileno() -# and close() methods work like those of open files. -# The info() method returns an rfc822.Message object which can be -# used to query various info about the object, if available. -# (rfc822.Message objects are queried with the getheader() method.) - -import socket -import regex - - -# This really consists of two pieces: -# (1) a class which handles opening of all sorts of URLs -# (plus assorted utilities etc.) -# (2) a set of functions for parsing URLs -# XXX Should these be separated out into different modules? - - -# Shortcut for basic usage -_urlopener = None -def urlopen(url): - global _urlopener - if not _urlopener: - _urlopener = URLopener() - return _urlopener.open(url) -def urlretrieve(url): - global _urlopener - if not _urlopener: - _urlopener = URLopener() - return _urlopener.retrieve(url) -def urlcleanup(): - if _urlopener: - _urlopener.cleanup() - - -# Class to open URLs. -# This is a class rather than just a subroutine because we may need -# more than one set of global protocol-specific options. -ftpcache = {} -class URLopener: - - # Constructor - def __init__(self): - self.addheaders = [] - self.tempcache = {} - self.ftpcache = ftpcache - # Undocumented feature: you can use a different - # ftp cache by assigning to the .ftpcache member; - # in case you want logically independent URL openers - - def __del__(self): - self.close() - - def close(self): - self.cleanup() - - def cleanup(self): - import os - for url in self.tempcache.keys(): - try: - os.unlink(self.tempcache[url][0]) - except os.error: - pass - del self.tempcache[url] - - # Add a header to be used by the HTTP interface only - # e.g. u.addheader('Accept', 'sound/basic') - def addheader(self, *args): - self.addheaders.append(args) - - # External interface - # Use URLopener().open(file) instead of open(file, 'r') - def open(self, url): - type, url = splittype(unwrap(url)) - if not type: type = 'file' - name = 'open_' + type - if '-' in name: - import regsub - name = regsub.gsub('-', '_', name) - if not hasattr(self, name): - raise IOError, ('url error', 'unknown url type', type) - try: - return getattr(self, name)(url) - except socket.error, msg: - raise IOError, ('socket error', msg) - - # External interface - # retrieve(url) returns (filename, None) for a local object - # or (tempfilename, headers) for a remote object - def retrieve(self, url): - if self.tempcache.has_key(url): - return self.tempcache[url] - url1 = unwrap(url) - if self.tempcache.has_key(url1): - self.tempcache[url] = self.tempcache[url1] - return self.tempcache[url1] - type, url1 = splittype(url1) - if not type or type == 'file': - try: - fp = self.open_local_file(url1) - del fp - return splithost(url1)[1], None - except IOError, msg: - pass - fp = self.open(url) - headers = fp.info() - import tempfile - tfn = tempfile.mktemp() - self.tempcache[url] = result = tfn, headers - tfp = open(tfn, 'w') - bs = 1024*8 - block = fp.read(bs) - while block: - tfp.write(block) - block = fp.read(bs) - del fp - del tfp - return result - - # Each method named open_ knows how to open that type of URL - - # Use HTTP protocol - def open_http(self, url): - import httplib - host, selector = splithost(url) - h = httplib.HTTP(host) - h.putrequest('GET', selector) - for args in self.addheaders: apply(h.putheader, args) - errcode, errmsg, headers = h.getreply() - if errcode == 200: return addinfo(h.getfile(), headers) - else: raise IOError, ('http error', errcode, errmsg, headers) - - # Use Gopher protocol - def open_gopher(self, url): - import gopherlib - host, selector = splithost(url) - type, selector = splitgophertype(selector) - selector, query = splitquery(selector) - if query: fp = gopherlib.send_query(selector, query, host) - else: fp = gopherlib.send_selector(selector, host) - return addinfo(fp, noheaders()) - - # Use local file or FTP depending on form of URL - def open_file(self, url): - try: - return self.open_local_file(url) - except IOError: - return self.open_ftp(url) - - # Use local file - def open_local_file(self, url): - host, file = splithost(url) - if not host: return addinfo(open(file, 'r'), noheaders()) - host, port = splitport(host) - if not port and socket.gethostbyname(host) in ( - localhost(), thishost()): - return addinfo(open(file, 'r'), noheaders()) - raise IOError, ('local file error', 'not on local host') - - # Use FTP protocol - def open_ftp(self, url): - host, file = splithost(url) - if not host: raise IOError, ('ftp error', 'no host given') - host, port = splitport(host) - host = socket.gethostbyname(host) - if not port: - import ftplib - port = ftplib.FTP_PORT - key = (host, port) - try: - if not self.ftpcache.has_key(key): - self.ftpcache[key] = ftpwrapper(host, port) - return addinfo(self.ftpcache[key].retrfile(file), - noheaders()) - except ftperrors(), msg: - raise IOError, ('ftp error', msg) - - -# Utility functions - -# Return the IP address of the magic hostname 'localhost' -_localhost = None -def localhost(): - global _localhost - if not _localhost: - _localhost = socket.gethostbyname('localhost') - return _localhost - -# Return the IP address of the current host -_thishost = None -def thishost(): - global _thishost - if not _thishost: - _thishost = socket.gethostbyname(socket.gethostname()) - return _thishost - -# Return the set of errors raised by the FTP class -_ftperrors = None -def ftperrors(): - global _ftperrors - if not _ftperrors: - import ftplib - _ftperrors = (ftplib.error_reply, - ftplib.error_temp, - ftplib.error_perm, - ftplib.error_proto) - return _ftperrors - -# Return an empty rfc822.Message object -_noheaders = None -def noheaders(): - global _noheaders - if not _noheaders: - import rfc822 - _noheaders = rfc822.Message(open('/dev/null', 'r')) - _noheaders.fp.close() # Recycle file descriptor - return _noheaders - - -# Utility classes - -# Class used by open_ftp() for cache of open FTP connections -class ftpwrapper: - def __init__(self, host, port): - self.host = host - self.port = port - self.init() - def init(self): - import ftplib - self.ftp = ftplib.FTP() - self.ftp.connect(self.host, self.port) - self.ftp.login() - def retrfile(self, file): - import ftplib - try: - self.ftp.voidcmd('TYPE I') - except ftplib.all_errors: - self.init() - self.ftp.voidcmd('TYPE I') - conn = None - if file: - try: - cmd = 'RETR ' + file - conn = self.ftp.transfercmd(cmd) - except ftplib.error_perm, reason: - if reason[:3] != '550': - raise IOError, ('ftp error', reason) - if not conn: - # Try a directory listing - if file: cmd = 'LIST ' + file - else: cmd = 'LIST' - conn = self.ftp.transfercmd(cmd) - return addclosehook(conn.makefile('r'), self.ftp.voidresp) - -# Base class for addinfo and addclosehook -class addbase: - def __init__(self, fp): - self.fp = fp - self.read = self.fp.read - self.readline = self.fp.readline - self.readlines = self.fp.readlines - self.fileno = self.fp.fileno - def __repr__(self): - return '<%s at %s whose fp = %s>' % ( - self.__class__.__name__, `id(self)`, `self.fp`) - def __del__(self): - self.close() - def close(self): - self.read = None - self.readline = None - self.readlines = None - self.fileno = None - self.fp = None - -# Class to add a close hook to an open file -class addclosehook(addbase): - def __init__(self, fp, closehook, *hookargs): - addbase.__init__(self, fp) - self.closehook = closehook - self.hookargs = hookargs - def close(self): - if self.closehook: - apply(self.closehook, self.hookargs) - self.closehook = None - self.hookargs = None - addbase.close(self) - -# class to add an info() method to an open file -class addinfo(addbase): - def __init__(self, fp, headers): - addbase.__init__(self, fp) - self.headers = headers - def info(self): - return self.headers - - -# Utility to combine a URL with a base URL to form a new URL - -def basejoin(base, url): - type, path = splittype(url) - if type: return url - host, path = splithost(path) - basetype, basepath = splittype(base) - basehost, basepath = splithost(basepath) - basepath, basetag = splittag(basepath) - basepath, basequery = splitquery(basepath) - type = basetype or 'file' - if path[:1] != '/': - import string - i = string.rfind(basepath, '/') - if i < 0: basepath = '/' - else: basepath = basepath[:i+1] - path = basepath + path - if not host: host = basehost - if host: return type + '://' + host + path - else: return type + ':' + path - - -# Utilities to parse URLs: -# unwrap('') --> 'type//host/path' -# splittype('type:opaquestring') --> 'type', 'opaquestring' -# splithost('//host[:port]/path') --> 'host[:port]', '/path' -# splitport('host:port') --> 'host', 'port' -# splitquery('/path?query') --> '/path', 'query' -# splittag('/path#tag') --> '/path', 'tag' -# splitgophertype('/Xselector') --> 'X', 'selector' - -def unwrap(url): - import string - url = string.strip(url) - if url[:1] == '<' and url[-1:] == '>': - url = string.strip(url[1:-1]) - if url[:4] == 'URL:': url = string.strip(url[4:]) - return url - -_typeprog = regex.compile('^\([^/:]+\):\(.*\)$') -def splittype(url): - if _typeprog.match(url) >= 0: return _typeprog.group(1, 2) - return None, url - -_hostprog = regex.compile('^//\([^/]+\)\(.*\)$') -def splithost(url): - if _hostprog.match(url) >= 0: return _hostprog.group(1, 2) - return None, url - -_portprog = regex.compile('^\(.*\):\([0-9]+\)$') -def splitport(host): - if _portprog.match(host) >= 0: return _portprog.group(1, 2) - return host, None - -_queryprog = regex.compile('^\(.*\)\?\([^?]*\)$') -def splitquery(url): - if _queryprog.match(url) >= 0: return _queryprog.group(1, 2) - return url, None - -_tagprog = regex.compile('^\(.*\)#\([^#]*\)$') -def splittag(url): - if _tagprog.match(url) >= 0: return _tagprog.group(1, 2) - return url, None - -def splitgophertype(selector): - if selector[:1] == '/' and selector[1:2]: - return selector[1], selector[2:] - return None, selector - - -# Test program -def test(): - import sys - import regsub - args = sys.argv[1:] - if not args: - args = [ - '/etc/passwd', - 'file:/etc/passwd', - 'file://localhost/etc/passwd', - 'ftp://ftp.cwi.nl/etc/passwd', - 'gopher://gopher.cwi.nl/11/', - 'http://www.cwi.nl/index.html', - ] - try: - for url in args: - print '-'*10, url, '-'*10 - fn, h = urlretrieve(url) - print fn, h - if h: - print '======' - for k in h.keys(): print k + ':', h[k] - print '======' - fp = open(fn, 'r') - data = fp.read() - del fp - print regsub.gsub('\r', '', data) - fn, h = None, None - print '-'*40 - finally: - urlcleanup() - -# Run test program when run as a script -if __name__ == '__main__': - test() diff --git a/Mac/Compat/chdir.c b/Mac/Compat/chdir.c deleted file mode 100644 index 056080052f..0000000000 --- a/Mac/Compat/chdir.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Chdir for the Macintosh. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Pathnames must be Macintosh paths, with colons as separators. */ - -#include "macdefs.h" - -#ifdef __MWERKS__ -/* XXXX All compilers should use this, really */ -#include -#else -/* Last directory used by Standard File */ -#define SFSaveDisk (*(short *)0x214) -#define CurDirStore (*(long *)0x398) -#endif - -/* Change current directory. */ - -int -chdir(path) - char *path; -{ - WDPBRec pb; - - pb.ioNamePtr= (StringPtr) Pstring(path); - pb.ioVRefNum= 0; - pb.ioWDDirID= 0; - if (PBHSetVol(&pb, FALSE) != noErr) { - errno= ENOENT; - return -1; - } - if (PBHGetVol(&pb, FALSE) == noErr) { - /* Set the Standard File directory */ -#ifdef __MWERKS__ - LMSetSFSaveDisk(-pb.ioWDVRefNum); - LMSetCurDirStore(pb.ioWDDirID); -#else - SFSaveDisk= -pb.ioWDVRefNum; - CurDirStore= pb.ioWDDirID; -#endif - } - return 0; -} diff --git a/Mac/Compat/dirent.h b/Mac/Compat/dirent.h deleted file mode 100644 index 44cfc5a972..0000000000 --- a/Mac/Compat/dirent.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * "Dir.h" for the Macintosh. - * Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - */ - -#define MAXNAMLEN 31 -#define MAXPATH 256 - -#define DIR struct _dir - -struct _dir { - long dirid; - int nextfile; -}; - -struct dirent { - char d_name[MAXPATH]; -}; - -extern DIR *opendir(char *); -extern struct dirent *readdir(DIR *); -extern void closedir(DIR *); diff --git a/Mac/Compat/getbootvol.c b/Mac/Compat/getbootvol.c deleted file mode 100644 index 8f5d28c0b3..0000000000 --- a/Mac/Compat/getbootvol.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Return the name of the boot volume (not the current directory). - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). -*/ - -#include "macdefs.h" - -char * -getbootvol() -{ - short vrefnum; - static unsigned char name[32]; - - (void) GetVol(name, &vrefnum); - p2cstr(name); - /* Shouldn't fail; return ":" if it does */ - strcat((char *)name, ":"); - return (char *)name; -} diff --git a/Mac/Compat/getwd.c b/Mac/Compat/getwd.c deleted file mode 100644 index 23810d1c42..0000000000 --- a/Mac/Compat/getwd.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Get full pathname of current working directory. The pathname is - copied to the parameter array 'cwd', and a pointer to this array - is also returned as function result. If an error occurred, however, - the return value is NULL but 'cwd' is filled with an error message. - - BUG: expect spectacular crashes when called from a directory whose - path would be over MAXPATH bytes long (files in such directories are - not reachable by full pathname). - - Starting with the dir ID returned by PBHGetVol, we do successive - PBGetCatInfo's to get a component of the path until we reach the - root (recognized by a dir ID of 2). We move up along the path - using the dir ID of the parent directory returned by PBGetCatInfo. - - Then we catenate the components found in reverse order with the volume - name (already gotten from PBHGetVol), with intervening and trailing - colons - - The code works correctly on MFS disks (where it always returns the - volume name) by simply skipping the PBGetCatinfo calls in that case. - There is a 'bug' in PBGetCatInfo when called for an MFS disk (with - HFS running): it then seems to call PBHGetVInfo, which returns a - larger parameter block. But we won't run into this problem because - we never call PBGetCatInfo for the root (assuming that PBHGetVol - still sets the root ID in this case). - - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). -*/ - -#include "macdefs.h" -#if defined(MPW) || defined(__MWERKS__) -#include -#endif - -#define ROOTID 2 /* Root directory ID */ - -char * -getwd(cwd) - char *cwd; -{ - /* Universal parameter block. */ - union { -#ifdef THINK_C - HFileInfo f; - DirInfo d; - WDPBRec w; -#else /* MPW */ - struct HFileInfo f; - struct DirInfo d; - struct WDPBRec w; -#endif - } pb; - char buf[MAXPATH]; /* Buffer to store the name components */ - char *ecwd, *ebuf; /* Pointers to end of used part of cwd and buf */ - int err; /* Error code of last I/O call */ - - /* First, get the default volume name and working directory ID. */ - - pb.w.ioNamePtr= (unsigned char *)cwd; - err= PBHGetVol(&pb.w, FALSE); - if (err != noErr) { - sprintf(cwd, "I/O error %d in PBHGetVol", err); - return NULL; - } - ecwd= strchr((const char *)p2cstr((unsigned char*)cwd), EOS); - ebuf= buf; - *ebuf = EOS; - - /* Next, if at least we're running HFS, walk up the path. */ - - if (hfsrunning()) { - long dirid= pb.w.ioWDDirID; - pb.d.ioVRefNum= pb.w.ioWDVRefNum; - while (dirid != ROOTID) { - pb.d.ioNamePtr= (unsigned char *) ++ebuf; - pb.d.ioFDirIndex= -1; - pb.d.ioDrDirID= dirid; - err= PBGetCatInfo((CInfoPBPtr)&pb.d, FALSE); - if (err != noErr) { - sprintf(cwd, "I/O error %d in PBGetCatInfo", err); - return NULL; - } - dirid= pb.d.ioDrParID; - ebuf += strlen((const char *)p2cstr((unsigned char *)ebuf)); - /* Should check for buf overflow */ - } - } - - /* Finally, reverse the list of components and append it to cwd. - Ebuf points at the EOS after last component, - and there is an EOS before the first component. - If there are no components, ebuf equals buf (but there - is still an EOS where it points). - Ecwd points at the EOS after the path built up so far, - initially the volume name. - We break out of the loop in the middle, thus - appending a colon at the end in all cases. */ - - for (;;) { - *ecwd++ = ':'; - if (ebuf == buf) - break; - do { } while (*--ebuf != EOS); /* Find component start */ - strcpy(ecwd, ebuf+1); - ecwd= strchr(ecwd, EOS); - } - *ecwd= EOS; - return cwd; -} diff --git a/Mac/Compat/macstat.c b/Mac/Compat/macstat.c deleted file mode 100644 index a1265afbd7..0000000000 --- a/Mac/Compat/macstat.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Minimal 'stat' emulation: tells directories from files and - gives length and mtime. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Updated to give more info, August 1994. -*/ - -#include "macstat.h" -#include "macdefs.h" - -/* Bits in ioFlAttrib: */ -#define LOCKBIT (1<<0) /* File locked */ -#define DIRBIT (1<<4) /* It's a directory */ - -int -macstat(path, buf) - char *path; - struct macstat *buf; -{ - union { - DirInfo d; - FileParam f; - HFileInfo hf; - } pb; - short err; - - pb.d.ioNamePtr = (unsigned char *)Pstring(path); - pb.d.ioVRefNum = 0; - pb.d.ioFDirIndex = 0; - pb.d.ioDrDirID = 0; - pb.f.ioFVersNum = 0; /* Fix found by Timo! See Tech Note 102 */ - if (hfsrunning()) - err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE); - else - err = PBGetFInfo((ParmBlkPtr)&pb, FALSE); - if (err != noErr) { - errno = ENOENT; - return -1; - } - if (pb.d.ioFlAttrib & LOCKBIT) - buf->st_mode = 0444; - else - buf->st_mode = 0666; - if (pb.d.ioFlAttrib & DIRBIT) { - buf->st_mode |= 0111 | S_IFDIR; - buf->st_size = pb.d.ioDrNmFls; - buf->st_rsize = 0; - } - else { - buf->st_mode |= S_IFREG; - if (pb.f.ioFlFndrInfo.fdType == 'APPL') - buf->st_mode |= 0111; - } - buf->st_ino = pb.hf.ioDirID; - buf->st_nlink = 1; - buf->st_uid = 1; - buf->st_gid = 1; - buf->st_size = (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlLgLen; - buf->st_mtime = buf->st_atime = pb.f.ioFlMdDat; - buf->st_ctime = pb.f.ioFlCrDat; - buf->st_rsize = (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlRLgLen; - *(unsigned long *)buf->st_type = - (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlFndrInfo.fdType; - *(unsigned long *)buf->st_creator = - (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlFndrInfo.fdCreator; - return 0; -} diff --git a/Mac/Compat/macstat.h b/Mac/Compat/macstat.h deleted file mode 100644 index 64ace4e7f4..0000000000 --- a/Mac/Compat/macstat.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Include file belonging to stat emulator. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Updated August 1994. */ - -struct macstat { - unsigned short st_dev; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned short st_rdev; - unsigned long st_size; - unsigned long st_atime; - unsigned long st_mtime; - unsigned long st_ctime; - /* Non-standard additions */ - unsigned long st_rsize; /* Resource size */ - char st_type[4]; /* File type, e.g. 'APPL' or 'TEXT' */ - char st_creator[4]; /* File creator, e.g. 'PYTH' */ -}; - -#define S_IFMT 0170000L -#define S_IFDIR 0040000L -#define S_IFREG 0100000L -#define S_IREAD 0400 -#define S_IWRITE 0200 -#define S_IEXEC 0100 - -/* To stop inclusion of MWerks header: */ -#ifndef _STAT -#define _STAT -#endif diff --git a/Mac/Compat/mkdir.c b/Mac/Compat/mkdir.c deleted file mode 100644 index 3c35eb0ca8..0000000000 --- a/Mac/Compat/mkdir.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Mkdir for the Macintosh. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Pathnames must be Macintosh paths, with colons as separators. */ - -#include "macdefs.h" - -/* Create a directory. */ - -int -mkdir(path, mode) - char *path; - int mode; /* Ignored */ -{ - HFileParam pb; - - if (!hfsrunning()) { - errno= ENODEV; - return -1; - } - pb.ioNamePtr= (StringPtr) Pstring(path); - pb.ioVRefNum= 0; - pb.ioDirID= 0; - if (PBDirCreate((HParmBlkPtr)&pb, FALSE) != noErr) { - errno= EACCES; - return -1; - } - return 0; -} diff --git a/Mac/Compat/nfullpath.c b/Mac/Compat/nfullpath.c deleted file mode 100644 index ca027c8896..0000000000 --- a/Mac/Compat/nfullpath.c +++ /dev/null @@ -1,75 +0,0 @@ -/* GET FULL PATHNAME OF A FILE. -** Original by Guido, modified by Jack to handle FSSpecs -*/ - -#include - -#include - -#include "nfullpath.h" - -/* Mac file system parameters */ -#define MAXPATH 256 /* Max path name length+1 */ -#define SEP ':' /* Separator in path names */ - -/* Macro to find out whether we can do HFS-only calls: */ -#define FSFCBLen (* (short *) 0x3f6) -#define hfsrunning() (FSFCBLen > 0) - -int -nfullpath(fsp, retbuf) - FSSpec *fsp; - char *retbuf; -{ - union { - HFileInfo f; - DirInfo d; - WDPBRec w; - VolumeParam v; - } pb; - char cwd[2*MAXPATH]; - unsigned char namebuf[MAXPATH]; - short err; - int dir; - long dirid; - char *next = cwd + sizeof cwd - 1; - int len; - int need_sep = 1; - - if (!hfsrunning()) - return -1; - - dir = fsp->vRefNum; - dirid = fsp->parID; - /* Stuff the filename into the buffer */ - len = fsp->name[0]; - *next = '\0'; - next -= len; - memcpy(next, fsp->name+1, len); - - while (dirid != fsRtParID) { - pb.d.ioNamePtr = namebuf; - pb.d.ioVRefNum = dir; - pb.d.ioFDirIndex = -1; - pb.d.ioDrDirID = dirid; - err= PBGetCatInfo((CInfoPBPtr)&pb.d, 0); - if (err != noErr) - return err; - *--next = SEP; - len = namebuf[0]; - if ( len + strlen(next) >= MAXPATH ) - return -1; - next -= len; - memcpy(next, (char *)namebuf+1, len); - dirid = pb.d.ioDrParID; - need_sep = 0; - } - - strcpy(retbuf, next); - if (need_sep) { - next = strchr(retbuf, '\0'); - *next++ = SEP; - *next++ = '\0'; - } - return 0; -} diff --git a/Mac/Compat/nfullpath.h b/Mac/Compat/nfullpath.h deleted file mode 100644 index 65ae5f3740..0000000000 --- a/Mac/Compat/nfullpath.h +++ /dev/null @@ -1 +0,0 @@ -int nfullpath(FSSpec *, char *); /* Generate full path from fsspec */ diff --git a/Mac/Compat/opendir.c b/Mac/Compat/opendir.c deleted file mode 100644 index 74b89842ec..0000000000 --- a/Mac/Compat/opendir.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Macintosh version of UNIX directory access package - * (opendir, readdir, closedir). - * Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - */ - -#include "dirent.h" -#include "macdefs.h" - -static DIR opened; - -/* - * Open a directory. This means calling PBOpenWD. - * The value returned is always the address of opened, or NULL. - * (I have as yet no use for multiple open directories; this could - * be implemented by allocating memory dynamically.) - */ - -DIR * -opendir(path) - char *path; -{ - union { - WDPBRec d; - VolumeParam v; - } pb; - char ppath[MAXPATH]; - short err; - - if (opened.nextfile != 0) { - errno = EBUSY; - return NULL; /* A directory is already open. */ - } - strncpy(ppath+1, path, ppath[0]= strlen(path)); - pb.d.ioNamePtr= (unsigned char *)ppath; - pb.d.ioVRefNum= 0; - if (hfsrunning()) { - pb.d.ioWDProcID= 0; - pb.d.ioWDDirID= 0; - err= PBOpenWD((WDPBPtr)&pb, FALSE); - } - else { - pb.v.ioVolIndex= 0; - err= PBGetVInfo((ParmBlkPtr)&pb, FALSE); - } - if (err != noErr) { - errno = ENOENT; - return NULL; - } - opened.dirid= pb.d.ioVRefNum; - opened.nextfile= 1; - return &opened; -} - -/* - * Close a directory. - */ - -void -closedir(dirp) - DIR *dirp; -{ - if (hfsrunning()) { - WDPBRec pb; - - pb.ioVRefNum= dirp->dirid; - (void) PBCloseWD(&pb, FALSE); - } - dirp->dirid= 0; - dirp->nextfile= 0; -} - -/* - * Read the next directory entry. - */ - -struct dirent * -readdir(dp) - DIR *dp; -{ - union { - DirInfo d; - FileParam f; - HFileInfo hf; - } pb; - short err; - static struct dirent dir; - - dir.d_name[0]= 0; - pb.d.ioNamePtr= (unsigned char *)dir.d_name; - pb.d.ioVRefNum= dp->dirid; - pb.d.ioFDirIndex= dp->nextfile++; - pb.d.ioDrDirID= 0; - if (hfsrunning()) - err= PBGetCatInfo((CInfoPBPtr)&pb, FALSE); - else - err= PBGetFInfo((ParmBlkPtr)&pb, FALSE); - if (err != noErr) { - errno = EIO; - return NULL; - } - (void) p2cstr((unsigned char *)dir.d_name); - return &dir; -} diff --git a/Mac/Compat/rmdir.c b/Mac/Compat/rmdir.c deleted file mode 100644 index 2e406c280c..0000000000 --- a/Mac/Compat/rmdir.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Rmdir for the Macintosh. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Pathnames must be Macintosh paths, with colons as separators. */ - -#include "macdefs.h" - -int -rmdir(path) - char *path; -{ - IOParam pb; - - pb.ioNamePtr= (StringPtr) Pstring(path); - pb.ioVRefNum= 0; - if (PBDelete((ParmBlkPtr)&pb, FALSE) != noErr) { - errno= EACCES; - return -1; - } - return 0; -} diff --git a/Mac/Compat/sync.c b/Mac/Compat/sync.c deleted file mode 100644 index a6487e12ca..0000000000 --- a/Mac/Compat/sync.c +++ /dev/null @@ -1,17 +0,0 @@ -/* The equivalent of the Unix 'sync' system call: FlushVol. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - For now, we only flush the default volume - (since that's the only volume written to by MacB). */ - -#include "macdefs.h" - -int -sync() -{ - if (FlushVol((StringPtr)0, 0) == noErr) - return 0; - else { - errno= ENODEV; - return -1; - } -} diff --git a/Mac/Demo/PICTbrowse/PICTbrowse.py b/Mac/Demo/PICTbrowse/PICTbrowse.py deleted file mode 100644 index 4aabf67de7..0000000000 --- a/Mac/Demo/PICTbrowse/PICTbrowse.py +++ /dev/null @@ -1,165 +0,0 @@ -"""browsepict - Display all "PICT" resources found""" - -import FrameWork -import EasyDialogs -import Res -import Qd -import Win -import List -import sys -import struct - -# -# Resource definitions -ID_MAIN=512 -MAIN_LIST=1 -MAIN_SHOW=2 - -# Where is the picture window? -LEFT=200 -TOP=64 - -def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.OpenResFile("PICTbrowse.rsrc") - except Res.Error, arg: - EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1]) - sys.exit(1) - PICTbrowse() - -class PICTbrowse(FrameWork.Application): - def __init__(self): - # First init menus, etc. - FrameWork.Application.__init__(self) - # Next create our dialog - self.main_dialog = MyDialog(self) - # Now open the dialog - contents = self.findPICTresources() - self.main_dialog.open(ID_MAIN, contents) - # Finally, go into the event loop - self.mainloop() - - def makeusermenus(self): - self.filemenu = m = FrameWork.Menu(self.menubar, "File") - self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) - - def quit(self, *args): - raise self - - def showPICT(self, resid): - w = PICTwindow(self) - w.open(resid) - #EasyDialogs.Message('Show PICT '+`resid`) - - def findPICTresources(self): - num = Res.CountResources('PICT') - rv = [] - for i in range(1, num+1): - Res.SetResLoad(0) - try: - r = Res.GetIndResource('PICT', i) - finally: - Res.SetResLoad(1) - id, type, name = r.GetResInfo() - rv.append(id, name) - return rv - -class PICTwindow(FrameWork.Window): - def open(self, (resid, resname)): - if not resname: - resname = '#'+`resid` - self.resid = resid - picture = Qd.GetPicture(self.resid) - # Get rect for picture - print `picture.data[:16]` - sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10]) - print 'pict:', t, l, b, r - width = r-l - height = b-t - if width < 64: width = 64 - elif width > 480: width = 480 - if height < 64: height = 64 - elif height > 320: height = 320 - bounds = (LEFT, TOP, LEFT+width, TOP+height) - print 'bounds:', bounds - - self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) - self.wid.SetWindowPic(picture) - self.do_postopen() - -class MyDialog(FrameWork.DialogWindow): - "Main dialog window for PICTbrowse" - - def open(self, id, contents): - self.id = id - FrameWork.DialogWindow.open(self, ID_MAIN) - self.wid.SetDialogDefaultItem(MAIN_SHOW) - tp, h, rect = self.wid.GetDialogItem(MAIN_LIST) - rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space - self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid, - 0, 1, 1, 1) - self.contents = contents - self.setlist() - - def setlist(self): - self.list.LDelRow(0, 0) - self.list.LSetDrawingMode(0) - if self.contents: - self.list.LAddRow(len(self.contents), 0) - for i in range(len(self.contents)): - v = `self.contents[i][0]` - if self.contents[i][1]: - v = v + '"' + self.contents[i][1] + '"' - self.list.LSetCell(v, (0, i)) - self.list.LSetDrawingMode(1) - self.list.LUpdate(self.wid.GetWindowPort().visRgn) - - def do_listhit(self, event): - (what, message, when, where, modifiers) = event - Qd.SetPort(self.wid) - where = Qd.GlobalToLocal(where) - print 'LISTHIT', where - if self.list.LClick(where, modifiers): - self.do_show() - - def getselection(self): - items = [] - point = (0,0) - while 1: - ok, point = self.list.LGetSelect(1, point) - if not ok: - break - items.append(point[1]) - point = point[0], point[1]+1 - values = [] - for i in items: - values.append(self.contents[i]) - return values - - def do_show(self, *args): - selection = self.getselection() - for resid in selection: - self.parent.showPICT(resid) - - def do_rawupdate(self, window, event): - tp, h, rect = self.wid.GetDialogItem(MAIN_LIST) - Qd.SetPort(self.wid) - Qd.FrameRect(rect) - self.list.LUpdate(self.wid.GetWindowPort().visRgn) - - def do_activate(self, activate, event): - self.list.LActivate(activate) - - def do_close(self): - self.close() - - def do_itemhit(self, item, event): - if item == MAIN_LIST: - self.do_listhit(event) - if item == MAIN_SHOW: - self.do_show() - -main() diff --git a/Mac/Demo/PICTbrowse/PICTbrowse.rsrc.hqx b/Mac/Demo/PICTbrowse/PICTbrowse.rsrc.hqx deleted file mode 100644 index bdf3c77833..0000000000 --- a/Mac/Demo/PICTbrowse/PICTbrowse.rsrc.hqx +++ /dev/null @@ -1,11 +0,0 @@ -(This file must be converted with BinHex 4.0) - -:$e"*3e4LFQphFf8ZFR0bB`"bFh*M8P0&4!#3#!'8,V!!N!3"!!!!!6m!!!!r!!! -!9G'"(r!!q[m!!2Vr!!$kf!!!qYJ!!2VB!!$kf!!!q[qJ$e"*3e4LFQphFf8ZFR0 -bB`)!!!"bFh*M8P0&4!#3"R*cFQ058d9%!*!BVAAL!`#3"J'8r`!!q[m!!2VB!!$ -kf!!!qYJ!!2VB!!$krk!!q[mJm!$kr`!!q[m!!2VB&3!!qYJ!!2VB!!!6qYJ!!2V -r)!SJ#b!-!D!!)!Da%"6i!2Vr!!$kf!!!qYJ!!2VB!!$kf!!!qYJ!!2Vr!!$kr`! -!q[ri!2Vr%#B!!2Vr`!$krc$i!2Vr!*!%&3"!!"!"&!$&!!!"!!%!N!8#!*!&)J! -"!*!&"3!+!+-!V!#3"l3!2!$)!(B%"&0SEhF!!!%!!!!"2`!!!$m!!!"9!2!Xj"0 -i!!!!(!"'!!&%6%p(!!!!%N4*9%`!!!!H!J#3#`)!rrm!!!!C!*!%$N*bEhGcCA) -JGfPZC'phVc!: diff --git a/Mac/Demo/PICTbrowse/PICTbrowse2.py b/Mac/Demo/PICTbrowse/PICTbrowse2.py deleted file mode 100644 index 588cc0bc87..0000000000 --- a/Mac/Demo/PICTbrowse/PICTbrowse2.py +++ /dev/null @@ -1,187 +0,0 @@ -"""browsepict - Display all "PICT" resources found""" - -import FrameWork -import EasyDialogs -import Res -import Qd -import Win -import List -import sys -import struct - -# -# Resource definitions -ID_MAIN=512 -MAIN_LIST=1 -MAIN_SHOW=2 - -# Where is the picture window? -LEFT=200 -TOP=64 -MINWIDTH=64 -MINHEIGHT=64 -MAXWIDTH=320 -MAXHEIGHT=320 - -def main(): - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.OpenResFile("PICTbrowse.rsrc") - except Res.Error, arg: - EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1]) - sys.exit(1) - PICTbrowse() - -class PICTbrowse(FrameWork.Application): - def __init__(self): - # First init menus, etc. - FrameWork.Application.__init__(self) - # Next create our dialog - self.main_dialog = MyDialog(self) - # Now open the dialog - contents = self.findPICTresources() - self.main_dialog.open(ID_MAIN, contents) - # Finally, go into the event loop - self.mainloop() - - def makeusermenus(self): - self.filemenu = m = FrameWork.Menu(self.menubar, "File") - self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) - - def quit(self, *args): - raise self - - def showPICT(self, resid): - w = PICTwindow(self) - w.open(resid) - #EasyDialogs.Message('Show PICT '+`resid`) - - def findPICTresources(self): - num = Res.CountResources('PICT') - rv = [] - for i in range(1, num+1): - Res.SetResLoad(0) - try: - r = Res.GetIndResource('PICT', i) - finally: - Res.SetResLoad(1) - id, type, name = r.GetResInfo() - rv.append(id, name) - return rv - -class PICTwindow(FrameWork.Window): - def open(self, (resid, resname)): - if not resname: - resname = '#'+`resid` - self.resid = resid - self.picture = Qd.GetPicture(self.resid) - # Get rect for picture - sz, t, l, b, r = struct.unpack('hhhhh', self.picture.data[:10]) - self.pictrect = (l, t, r, b) - width = r-l - height = b-t - if width < MINWIDTH: width = MINWIDTH - elif width > MAXWIDTH: width = MAXWIDTH - if height < MINHEIGHT: height = MINHEIGHT - elif height > MAXHEIGHT: height = MAXHEIGHT - bounds = (LEFT, TOP, LEFT+width, TOP+height) - - self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) - self.do_postopen() - - def do_update(self, *args): - currect = self.fitrect() - Qd.DrawPicture(self.picture, currect) - - def fitrect(self): - """Return self.pictrect scaled to fit in window""" - graf = self.wid.GetWindowPort() - screenrect = graf.portRect - picwidth = self.pictrect[2] - self.pictrect[0] - picheight = self.pictrect[3] - self.pictrect[1] - if picwidth > screenrect[2] - screenrect[0]: - factor = float(picwidth) / float(screenrect[2]-screenrect[0]) - picwidth = picwidth / factor - picheight = picheight / factor - if picheight > screenrect[3] - screenrect[1]: - factor = float(picheight) / float(screenrect[3]-screenrect[1]) - picwidth = picwidth / factor - picheight = picheight / factor - return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), - screenrect[1]+int(picheight)) - -class MyDialog(FrameWork.DialogWindow): - "Main dialog window for PICTbrowse" - - def open(self, id, contents): - self.id = id - FrameWork.DialogWindow.open(self, ID_MAIN) - self.wid.SetDialogDefaultItem(MAIN_SHOW) - tp, h, rect = self.wid.GetDialogItem(MAIN_LIST) - rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space - self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid, - 0, 1, 1, 1) - self.contents = contents - self.setlist() - - def setlist(self): - self.list.LDelRow(0, 0) - self.list.LSetDrawingMode(0) - if self.contents: - self.list.LAddRow(len(self.contents), 0) - for i in range(len(self.contents)): - v = `self.contents[i][0]` - if self.contents[i][1]: - v = v + '"' + self.contents[i][1] + '"' - self.list.LSetCell(v, (0, i)) - self.list.LSetDrawingMode(1) - self.list.LUpdate(self.wid.GetWindowPort().visRgn) - - def do_listhit(self, event): - (what, message, when, where, modifiers) = event - Qd.SetPort(self.wid) - where = Qd.GlobalToLocal(where) - print 'LISTHIT', where - if self.list.LClick(where, modifiers): - self.do_show() - - def getselection(self): - items = [] - point = (0,0) - while 1: - ok, point = self.list.LGetSelect(1, point) - if not ok: - break - items.append(point[1]) - point = point[0], point[1]+1 - values = [] - for i in items: - values.append(self.contents[i]) - return values - - def do_show(self, *args): - selection = self.getselection() - for resid in selection: - self.parent.showPICT(resid) - - def do_rawupdate(self, window, event): - tp, h, rect = self.wid.GetDialogItem(MAIN_LIST) - Qd.SetPort(self.wid) - Qd.FrameRect(rect) - self.list.LUpdate(self.wid.GetWindowPort().visRgn) - - def do_activate(self, activate, event): - self.list.LActivate(activate) - - def do_close(self): - self.close() - - def do_itemhit(self, item, event): - if item == MAIN_LIST: - self.do_listhit(event) - if item == MAIN_SHOW: - self.do_show() - -main() diff --git a/Mac/Demo/applescript.html b/Mac/Demo/applescript.html deleted file mode 100644 index 7db5ba6020..0000000000 --- a/Mac/Demo/applescript.html +++ /dev/null @@ -1,168 +0,0 @@ -Using Open Scripting Extension from Python - -

Using Open Scripting Extension from Python

-
- -OSA support in Python is still far from complete, and what -support there is is likely to change in the forseeable future. Still, -there is already enough in place to allow you to do some nifty things -to other programs from your python program.

- - -Actually, when we say "AppleScript" in this document we actually mean -"the Open Scripting Architecture", there is nothing -AppleScript-specific in the Python implementation.

- - -In this example, we will look at a scriptable application, extract its -"AppleScript Dictionary" and generate a Python interface module from -that and use that module to control the application. Because we want -to concentrate on the OSA details we don't bother with a real -user-interface for our application.

- -The application we are going to script is Eudora Light, a free mail -program from QualComm. This is a -very versatile mail-reader, and QualComm has an accompanying -commercial version once your needs outgrow Eudora Light. Our program -will tell Eudora to send queued mail, retrieve mail or quit.

- -

Creating the Python interface module

- -There is a tool in the standard distribution that looks through a file -for an 'AETE' or 'AEUT' resource, the internal representation of the -AppleScript dictionary. This tool is called -gensuitemodule.py, and lives in -Mac:scripts. When we start it, it asks us for an input -file and we point it to the Eudora Light executable. It starts parsing -the AETE resource, and for each AppleEvent suite it finds it prompts -us for the filename of the resulting python module. Remember to change -folders for the first module, you don't want to clutter up the Eudora -folder with your python interfaces. If you want to skip a suite you -press cancel and the process continues with the next suite. In the -case of Eudora, you do not want to generate the Required -suite, because it will be empty. AppleScript understands that an empty -suite means "incorporate the whole standard suite by this name", -gensuitemodule does not currently understand this. Creating the empty -Required_Suite.py would hide the correct module of that -name from our application.

- -

-Time for a sidebar. If you want to re-create -Required_Suite.py or one of the other standard modules -you should look in System Folder:Extensions:Scripting -Additions:Dialects:English Dialect, that is where the core -AppleEvent dictionaries live. Also, if you are looking for the -Finder_Suite interface: don't look in the finder (it has -an old System 7.0 scripting suite), look at the extension Finder -Scripting Extension.

-

- -Let's glance at the Eudora_Suite.py just created. You -may want to open Script Editor alongside, and have a look at how it -interprets the dictionary. EudoraSuite.py starts with some -boilerplate, then come some dictionaries implementing the OSA -Enumerations, then a big class definition with methods for each -AppleScript Verb and finally some comments. The Enumerations we will -skip, it suffices to know that whenever you have to pass an enumerator -to a method you can pass the english name and don't have to bother -with the 4-letter type code. So, you can say -
-	eudora.notice(occurrence="mail_arrives")
-
-instead of the rather more cryptic -
-	eudora.notice(occurrence="wArv")
-
- -The Eudora_Suite class is the bulk of the code -generated. For each verb it contains a method. Each method knows what -arguments the verb expects, and it makes handy use of the keyword -argument scheme introduced in Python 1.3 to present a palatable -interface to the python programmer. You will see that each method -calls some routines from aetools, an auxiliary module -living in Lib:toolbox which contains some other nifty -AppleEvent tools as well. Have a look at it sometime, there is (of -course) no documentation yet.

- -The other thing you notice is that each method calls -self.send, but no such method is defined. You will have -to provide it by subclassing or multiple inheritance, as we shall see -later.

- -The module ends with some comments. Sadly, gensuitemodule is not yet -able to turn the Object Specifiers into reasonable Python code. For -now, if you need object specifiers, you will have to use the routines -defined in aetools.py (and aetypes.py, which -it incorporates). You use these in the form aetools.Word(10, -aetools.Document(1)) where the corresponding AppleScript -terminology would be word 10 of the first -document. Examine the two modules mentioned above along with -the comments at the end of your suite module if you need to create -more than the standard object specifiers.

- -

Using a Python suite module

- -Now that we have created the suite module we can use it in an -application. We do this by creating a class that inherits -Eudora_Suite and the TalkTo class from -aetools. The TalkTo class is basically a -container for the send method used by the methods from -the suite classes.

- -Actually, our class will also inherit Required_Suite, -because we also need functionality from that suite: the quit -command. Gensuitemodule could have created this completely derived -class for us, since it has access to all information needed to build -the class but unfortunately it does not do so at the moment. All in -all, the heart of our program looks like this: -

-	import Eudora_Suite, Required_Suite, aetools
-	
-	class Eudora(aetools.TalkTo, Required_Suite.Required_Suite, \
-				Eudora_Suite.Eudora_Suite):
-		pass
-
- -Yes, our class body is pass, all functionality is already -provided by the base classes, the only thing we have to do is glue it -together in the right way.

- -Looking at the sourcefile testeudora.py we see that it starts -with some imports. Then we get the class definition -for our main object and a constant giving the signature of Eudora.

- -This, again, needs a little explanation. There are various ways to -describe to AppleScript which program we want to talk to, but the -easiest one to use (from Python, at least) is creator -signature. Application name would be much nicer, but Python currently -does not have a module that interfaces to the Finder database (which -would allow us to map names to signatures). The other alternative, -ChooseApplication from the program-to-program toolbox, is -also not available from Python at the moment.

- -The main program itself is a wonder of simplicity. We create the -object that talks to Eudora (passing the signature as argument), ask -the user what she wants and call the appropriate method of the talker -object. The use of keyword arguments with the same names as used by -AppleScript make passing the parameters a breeze.

- -The exception handling does need a few comments, though. Since -AppleScript is basically a connectionless RPC protocol nothing happens -when we create to talker object. Hence, if the destination application -is not running we will not notice until we send our first -command. There is another thing to note about errors returned by -AppleScript calls: even though MacOS.Error is raised not -all of the errors are actually OSErr-type errors, some -are error codes returned by the server application. In that case, the -error message will be incorrect.

- -That concludes our simple example. Again, let me emphasize that -scripting support in Python is not very complete at the moment, and -the details of how to use AppleEvents will definitely change in the -near future. This will not only fix all the ideosyncracies noted in -this document but also break existing programs, since the current -suite organization will have to change to fix some of the problems. -Still, if you want to experiment with AppleEvents right now: go ahead! -

diff --git a/Mac/Demo/building.html b/Mac/Demo/building.html deleted file mode 100644 index 73e3d4e8c1..0000000000 --- a/Mac/Demo/building.html +++ /dev/null @@ -1,468 +0,0 @@ - - -Building Mac Python from source - - -

Building Mac Python from source

-
- -This document explains how to build MacPython from source. This is -necessary if you want to write extension modules for 68K Python, and -currently also probably the easiest way to build PPC extension -modules. Building Python is not something to be undertaken lightly, -the process is not very streamlined so you need a reasonable working -knowledge of the CodeWarrior development environment, a good net -connection and probably quite some time too.

- -The information density in this file is high, so you should probably -print it and read it at your leasure. Most things are explained only -once (and probably in the wrong place:-).

- -I am very interested in feedback on this document, contact me at <jack@cwi.nl> or send your -comments to the Mac Python Special -Interest Group. - -

What you need.

- -The following things you definitely need: - -
    - -
  • You need a MacPython source distribution, of course. You can -obtain one from ftp://ftp.cwi.nl/pub/jack/python/mac, -and possibly also from the standard python.org ftp -site. Everything you need is also included in the standard Python -source distribution, but the organization is different. Look in -directory Mac/mwerks/projects for the project files and -related stuff. - -
  • You need MetroWerks CodeWarrior. The current distribution has -been built with version 9 of CodeWarrior. Ordering information is -available on the MetroWerks -homepage. You might still be able to build Python with MPW or -Think/Symantec C but you are basically on your own. - -
  • You need GUSI, the Grand Unified Socket Interface, by Matthias -Neeracher. The current distribution has been built with CWGUSI 1.7.2, -obtainable from ftp://ftp.switch.ch/software/mac/src/mw_c. -It is possible to build a non-GUSI Python, see below. - -
- -The MacPython project files are configured to -include a plethora of optional modules, and these modules need a -number extra packages. To use the project files as-is you have to -download these packages too. PPC and CFM68K Python have all such modules as -dynamically loaded modules, so if you don't need a certain package it -suffices to just refrain from builing the extension module. For static 68K -Python things are a bit more complicated: you have to edit the -interpreter project file to remove the reference to the module (and -the libraries it uses), and edit the Mac:mwerks:mwerks_nonshared_config.h -file to remove the USE_... line. Here are the locations for the various things -you need: - -
    - -
  • Tcl and Tk can be obtained from ftp://ftp.smli.com/pub/tcl/mac/. -The current distributions, Tcl 7.5p1 and Tk 4.1p1 need a bit of work, -see the section on building Tcl/Tk Python -below. Get the "full source" distribution, which includes MoreFiles. - -
  • Waste, a TextEdit replacement written by Marco Piovanelli, <piovanel@kagi.com>. Python -was built using version 1.2, which you can obtain from <ftp://rhino.harvard.edu/pub/dan/WASTE> -and various other places. - -
  • JPEG library by the Independent JPEG Group. Python is still built -using an archaic version of the library, version 4. It can be obtained -from the -ftp://ftp.cwi.nl/pub/jack/python/mac directory, complete with CW8 -projects. If someone manages to build Python with the version 6 -library I would be grateful if they sent me the changes needed. The -most recent JPEG library can always be obtained from ftp://ftp.uu.net/graphics/jpeg/. - -
  • The netpbm/pbmplus and libtiff libraries. The netpbm distribution -(which includes libtiff) is generally available on Internet ftp -servers. For Python pbmplus, an older incarnation of netpbm, is -functionally identical to netpbm, since Python only uses the library -and not the complete applications. A distribution with correct -projects and library source only is available from, you guessed it, ftp://ftp.cwi.nl/pub/jack/python/mac. - -
- -

Setting Up

- -Now that you have collected everything you should start with building -the various parts. Everything is independent, with the single -exception that Tcl and Tk depend on CWGUSI. If you don't want to fix -access paths try to set things up as follows: - -
-Top-level-folder:
-	CWGUSI
-	imglibs
-		libjpeg
-		pbmplus
-			libtiff
-	MoreFiles 1.4.2 (not needed by Python, only by tcl/tk)
-	Python
-	Tcl 7.5
-	Tk 4.1
-	Waste 1.2 distribution (if you want waste)
-
- -Now build all the libraries. In CWGUSI you build the -projects GUSI.68K.µ, GUSI.CFM68K.µ -and GUSI.PPC.µ, in -MoreFiles, libjpeg, pbmplus -andlibtiff you build all projects. Tcl/tk is a special -case, see below. Of course, if you are only interested in one of -static 68K, CFM68K or PPC you can skip building the other libraries. - -

Building Tcl/Tk

- -You need to make a minor organizational change to the Tcl/Tk -distribution. The current instructions are for the -tcl7.5.1 and tk4.1.1 distribution: - -
    - -
  • Rename the compat folders to (compat) -in both the Tcl and Tk folders. - -
  • In the Tcl folder, move strncasecmp.c and -tclErrno.h from (compat) to the main Tcl -folder. - -
  • Fix dnr.c as provided by MetroWerks by inserting -
     #pragma ANSI_strict off 
    at the -beginning. The tcl library is built with strict ANSI on, and this file -uses C++ style comments. - -
  • If you want to build SimpleTcl and -SimpleTk you will probably have to remove the references -to libmoto from the project. - -
  • You are strongly advised to add a line -
    
    -#define USE_TCLALLOC 1
    -
    -somewhere at the beginning of MW_TclHeader.pch. -As distributed, tcl and tk assume that malloc calls always succeed and -use the resulting pointer without checking for NULL -values. Needless to say, this wreaks havoc on a Macintosh. - -
  • If you want to build for CFM68K you have to modify TclMacNotify.c -because there is an error in the Apple Universal headers (sic!). Read the -comments at the beginning of Mac:Python:macglue.c and copy the -code to TclMacNotify.c. If you get linker errors on GetEvQHdr -you have not done this correctly. - -
- -Build first the MoreFiles library, then the Tcl library, then -SimpleTcl (test it by typing ls -l in the window you get) -then the Tk library, then SimpleTk (which can again be tested with -ls -l). If this all worked you are all set to try -building Python. - -

Building Waste

- -You do not need to build the Waste libraries, as Python includes the -source modules themselves. You have to make one modification, -though. In file ICCFMGlue.c in folder Minimal IC -APIs, add the following lines: - -

-#include 
-#include 
-
- -

The organization of the Python source tree

- -Time for a short break, while we have a look at the organization of -the Python source tree. At the top level, we find the following -folders: - -
-
build.mac68k.stand -
This is where you will build static 68K interpreters. - -
build.mac68k.shared -
This is where you build the CFM68K shared library, interpreter -and applet framework. - -
build.macppc.shared -
This is where you build the PPC shared library, interpreter and -applet framework. You can also build the fat applet framework here. - -
build.macppc.stand -
This is where you build a nonshared PPC interpreter (optional). - -
Demo -
Demo programs that are not Mac-specific. Some of these may not -work, the file README-Mac has some details. - -
Extensions -
Extensions to the interpreter that are not Mac-specific. Contains -only the img extension in this distribution. Extensions -are not built here, as they are on Unix, but incorporated in -the core interpreter or built as plugin modules. - -
Grammar -
The Python grammar. Included for reference only, you cannot build -the parser on a Mac. - -
Include -
Machine-independent header files. - -
Modules -
Machine-independent optional modules. Not all of these will work -on the Mac. - -
Objects -
Machine-independent code for various objects. Most of these are -not really optional: the interpreter will not function without them. - -
Parser -
The Python parser (machine-independent). - -
PlugIns -
This is where you build the PPC and CFM68K dynamically-loaded plugin modules. - -
Python -
The core interpreter. Most files are machine-independent, some -are unix-specific and not used on the Mac. - -
Tools -
Tools for python developers. Contains modulator -which builds skeleton C extension modules and bgen which -generates complete interface modules from information in C header -files. There are some readme files, but more documentation is sorely -needed. - -
- -All the mac-specific stuff lives in the Mac folder: -
- -
Compat -
Unix-compatability routines. Some of these are not used anymore, -since CWGUSI provides a rather complete emulation, but you may need -these if you are trying to build a non-GUSI python. - -
Demo -
Mac-specific demo programs, some of them annotated. - -
Include -
Mac-specific but compiler-independent include files. - -
Lib -
Mac-specific standard modules. The toolbox folder -contains modules specifically needed with various MacOS toolbox -interface modules. - -
Modules -
Mac-specific builtin modules. Theoretically these are all -optional, but some are rather essential (like -macmodule). A lot of these modules are generated with -bgen, in which case the bgen input files are included so -you can attempt to regenerate them or extend them. - -
MPW -
MPW-specific files. These have not been used or kept up-to-date -for a long time, so use at your own risk. - -
mwerks -
Mwerks-specific sources and headers. Contains glue code for -Pythons shared-library architecture, a replacement for -malloc and a directory with various projects for building -variations on the Python interpreter. The mwerks_*.h -files here are the option-setting files for the various interpreters -and such, comparable to the unix command-line -D options -to the compiler. Each project uses the correct option file as its -"prefix file" in the "C/C++ language" settings. Disabling optional -modules (for the 68K interpreter), building non-GUSI interpreters and -various other things are accomplished by modifying these files (and -possibly changing the list of files included in the project window, of -course). - -
Python -
Mac-specific parts of the core interpreter. - -
Resources -
Resource files needed to build the interpreter. - -
Scripts -
A collection of various mac-specific Python scripts. Some are -essential, some are useful but few are documented, so you will have to -use your imagination to work them out. - -
Unsupported -
Modules that are not supported any longer but may still work with a little effort. -
- -

Building the 68K interpreter

- -If you have all the optional libraries mentioned
above loaded buildin Python for 68K macs is a -breeze: open the project in the folder build.mac68k.stand -and build it. Do not run it yet, this will possibly result -in a garbled preferences file.

- -First remove the Python preferences file from your -preference folder, only if you had an older version of Python -installed. (this is also what you do if you did not heed the last -sentence of the preceeding paragraph). Next, move the interpreter to -the main Python folder (up one level) and run it there. This will -create a correct initial preferences file. You are now all set, and -your tree should be completely compatible with a binary-only -distribution. Read the release notes -(Relnotes-somethingorother) and -ReadMeOrSuffer in the Mac folder. - -

Building the CFM68K interpreter

- -Building the CFM68K interpreter is as almost exactly the same as building -the PPC interpreter, with the exception that you should read "CFM68K" -for "PPC" every time. Continue reading with the next section. - -

Building the PPC interpreter

- -First you build the interpreter, core library and applet skeleton in -folder build.macppc.stand. The order to build things is -the following: - -
-
MWRuntimeStaticLib -
A modified version of the MetroWerks runtime library that is -suitable for Pythons' shared library architecture. The sources all -come from the MW distribution. - -
PythonCorePPC -
The shared library that contains the bulk of the interpreter and -its resources. It is a good idea to immedeately put an alias to this -shared library in the Extensions folder of your system -folder. Do exactly that: put an alias there, copying or -moving the file will cause you grief later. - -
PythonPPC -
The interpreter. This is basically a routine to call out to the -shared library. Because of the organization of GUSI it also contains -the Gusi settings resource (together with a ResEdit template, so you -can change the gusi settings should you feel like doing so). Do -not run it yet, this will possibly result in a garbled -preferences file.

- -

PythonApplet -
The applet skeleton application. Very similar to -PythonPPC, but it calls to a different entrypoint in the -core library. The mkapplet script will copy this complete -file, and add a 'PYC ' with the module to generate an -applet.

- -

- -After creating the alias to PythonCore you should move -PythonPPC to the main Python folder. Next you remove any -old Python Preferences file from the -Preferences folder (if you had python installed on your -system before) and run the interpreter once to create the correct -preferences file. You should also make an alias to -PythonApplet in the main Python folder. (again: making an -alias is preferrable to copying or moving the file, since this will -cause the correct file to be used if you ever rebuild -PythonApplet).

- -Next, you have to build the extension modules in the -PlugIns folder. Open each project with .ppc in the -name and build it. After all -the dynamically loaded modules are built you have to create a number -of aliases: some modules live together in a single dynamic -library. Run the MkPluginAliases.py script from -Mac:scripts to create the aliases.

- -Finally, you must build the standard applets: -EditPythonPrefs, mkapplet, etc. This is -easiest done with the fullbuild script from -Mac:scripts. Answer no to all questions except -when it asks whether to build the applets.

- -

-Actually, the fullbuild script can be used to build -everything, but you need a fully-functional interpreter before you can -use it (and one that isn't rebuilt in the process: you cannot rebuild -a running program). You could copy the 68K interpreter to a different -place and use that to run fullbuild, or use the standalone PPC python -for this. I tend to keep a standalone interpreter in a safe place for -this use only. -
- -You are all set now, and should read the release notes and -ReadMeOrSuffer file from the Mac folder. - -

Rebuilding .exp files for PPC and CFM68K

- -Occasionally it may be necessary to rebuild your PythonCore .exp -file, a file that controls which symbols are exported by your PythonCore -shared library. Rebuild it if you get unexpected undefined symbols when you -are building a plugin module.

- -Rebuilding the .exp file is done by first removing the file and removing the -reference to it in the project (in the "config" section). Next, build PythonCore. -This will create a new .exp file. Edit this file to remove the references to -the symbols __initialize, __terminate, setjmp, -longjmp and __ptmf_null. Next, add the .exp file to the project -again and rebuild PythonCore.

- -This rather convoluted procedure is needed to ensure that plugin modules don't -accidentally link with those entrypoints from PythonCore, which will not work because -those routines have to be in the same code fragment as they are used from. - -

Odds and ends

- -Some remarks that I could not fit in elsewhere: - -
    - -
  • It may be possible to use the PythonCore shared -library to embed Python in another program, if your program can live -with using GUSI for I/O. Use PythonCore in stead of your C library -(or, at the very least, link it before the normal C library). Let me -know whether this works. - -
  • It is possible to build PPC extension modules without building a -complete Python. Take the binary distribution, add folders -Include, Mac:Include and -Mac:mwerks from the source distribution and you should be -all set. A template for a dynamic module can be found in -xx.ppc.µ or xx.CFM68K.µ. - -
  • The Python shared library architecture is a variant of the architecture -described as "application with shared libraries and dropins" in the MetroWerks -"Targeting MacOS" documentation. The Python Application and applet-template use -the AppRuntime.Lib runtime library (with properly set CFM -initialization and termination routines). PythonCore uses ShlibRuntime.Lib -and MWRuntimeStaticLib.Lib, which is almost identical to the MW -standard MWRuntimeLib, but not dynamically loaded. This library contains -the part of the runtime that can (or must) be shared between all modules in the program. -It is linked statically into PythonCore (and exported to the applications and plugins) -so we do not have to distribute yet another shared library. Plugin modules use -ShlibRuntime.Lib and obtain the rest from PythonCore. PythonCore uses a -non-standard initialization entry point, __initialize_with_resources, to -be able to obtain resources from the library file lateron. Plugins can do the same or -use the standard __initialize entry point. - - -
      - - diff --git a/Mac/Demo/example0.html b/Mac/Demo/example0.html deleted file mode 100644 index c0336a56bf..0000000000 --- a/Mac/Demo/example0.html +++ /dev/null @@ -1,75 +0,0 @@ -Using python to create Macintosh applications, part zero - -

      Using python to create Macintosh applications, part zero

      -
      - -This document will show you how to create a simple mac-style -application using Python. We will glance at how to use file dialogs and -messages.

      - -Our example program checktext.py asks -the user for a text file and checks what style end-of-lines the file has. -This may need a little explanation: ASCII text files are almost identical -on different machines, with one exception: -

        -
      • Unix systems terminate lines with the "linefeed" character, 0x0a, -
      • Macintoshes terminate lines with the "carriage return" character, -0x0d and -
      • MSDOS systems terminate lines with first a carriage return and then a linefeed. -
      - -Let us have a look at the program. The first interesting statement in the main -program is the call to macfs.PromptGetFile. This is one of the routines -that allow you to ask the user to specify a file. You pass it one required -argument, the prompt string. There are up to four optional MacOS file type arguments -you can pass, as 4-byte strings. Specifying no file -type will allow the user to select any file, specifying one or more types restricts -the user to files of this type. File types are explained in most books on the Mac.

      - -PromptGetFile returns two values: an FSSpec object and a -success indicator. The FSSpec object is the "official" MacOS way of specifying a -file, more on it later. The success indicator tells you whether the user clicked OK -or Cancel. In the event of Cancel we simply exit back to the finder.

      - -PromptGetFile has a number of friends that do similar things: -

        -
      • StandardGetFile is identical to PromptGetFile but -without the prompt. It has up to four optional filetype arguments. -
      • StandardPutFile asks the user for an output file. It will -warn the user when she tries to overwrite an existing file. The routine has one -mandatory argument: a prompt string. Pass the empty string if you do not want a prompt. -
      • GetDirectory asks the user for a folder (or directory, in unix terms). -It has one optional argument: a prompt string. -
      -All routines return an FSSpec and a success indicator.

      - -There are many things you can do with FSSpec objects (see the -macfs section in the -Python Library Reference -for details), but passing them to open is not -one of them. For this, we first have to convert the FSSpec object to a pathname, with -the as_pathname method. This returns a standard MacOS-style pathname with -colon-separated components. This can then be passed to open. Note that -we call open with mode parameter 'rb': we want to read the file in binary -mode. Python, like C and C++, uses unix-style line endings internally and opening a -file in text mode ('r') would result in conversion of carriage-returns to -linefeeds upon reading. This is something that Mac and DOS programmers are usually aware -of but that never ceases to amaze unix buffs.

      - -After we open the file we attempt to read all data into memory. If this fails we use -EasyDialogs.Message to display a message in a standard dialog box and exit. -The EasyDialogs module has a few more useful simple dialog routines, more on that in -example 1.

      - -The rest of the code is pretty straightforward: we check that the file actually contains -data, count the number of linefeeds and returns and display a message with our guess of the -end-of-line convention used in the file.

      - -The example0 folder has three text files in Mac, Unix and DOS style -for you to try the program on. After that, you can continue with example 1 -or go back to the index to find another interesting topic.

      - -


      -Jack Jansen, -jack@cwi.nl, 18-July-1996. - diff --git a/Mac/Demo/example0/checktext.py b/Mac/Demo/example0/checktext.py deleted file mode 100644 index 93a814df04..0000000000 --- a/Mac/Demo/example0/checktext.py +++ /dev/null @@ -1,39 +0,0 @@ -"""checktext - Check that a text file has macintosh-style newlines""" - -import macfs -import sys -import EasyDialogs -import string - -def main(): - fsspec, ok = macfs.PromptGetFile('File to check end-of-lines in:', 'TEXT') - if not ok: - sys.exit(0) - pathname = fsspec.as_pathname() - fp = open(pathname, 'rb') - try: - data = fp.read() - except MemoryError: - EasyDialogs.Message('Sorry, file is too big.') - sys.exit(0) - if len(data) == 0: - EasyDialogs.Message('File is empty.') - sys.exit(0) - number_cr = string.count(data, '\r') - number_lf = string.count(data, '\n') - if number_cr == number_lf == 0: - EasyDialogs.Message('File contains no lines.') - if number_cr == 0: - EasyDialogs.Message('File has unix-style line endings') - elif number_lf == 0: - EasyDialogs.Message('File has mac-style line endings') - elif number_cr == number_lf: - EasyDialogs.Message('File probably has MSDOS-style line endings') - else: - EasyDialogs.Message('File has no recognizable line endings (binary file?)') - sys.exit(0) - -if __name__ == '__main__': - main() - - diff --git a/Mac/Demo/example1.html b/Mac/Demo/example1.html deleted file mode 100644 index ddb897c659..0000000000 --- a/Mac/Demo/example1.html +++ /dev/null @@ -1,211 +0,0 @@ -Using python to create Macintosh applications, part one - -

      Using python to create Macintosh applications, part one

      -
      - -This document will show you how to create a simple mac-style -application using Python. We will glance at how to use dialogs and -resources.

      - -The example application we look at will be a simple program with a -dialog that allows you to control and monitor InterSLIP, a device -driver that connects your mac to the Internet via a modem connection. -Source and resource file -(in binary and BinHex form for -downloading) for this application are available in the example1 folder (which you will have to download -if you are reading this document over the net and if you want to look -at the resources).

      - -We will use a C extension module module "interslip" that allows a -Python program to control and monitor the behaviour of the low-level -driver, and we will create the user interface around that. If you want -to actually run the code, you will obvously need InterSLIP and the -interslip module. The latter is available as a dynamically loadable -extension for PowerPC macs, and may be compiled in your Python -interpreter for 68K macs. As of this writing there is still a slight -problem with the Python interslip module causing it to say "file not -found" if the driver is not loaded yet. The workaround is to load the -driver by starting InterSLIP Control and quitting it.

      - - -If you are interested in building your own extensions to python you -should check out the companion document Creating Macintosh Python C extensions, -which tells you how to build your own C extension. Not completely -coincidental this document uses the interslip module that we will use -here as an example.

      - - -

      Creating dialog resources

      - -Let us start with the creative bit: building the dialogs and creating -an icon for our program. For this you need ResEdit, and a reasonable -working knowledge of how to use it. "Inside Mac" or various books on -macintosh programming will help here.

      - -There is one fine point that deserves to be mentioned here: resource numbering. Because often your -resources will be combined with those that the Python interpreter and -various standard modules need you should give your DLOG and DITL -resources numbers above 512. 128 and below are reserved for Apple, -128-255 for the Python interpreter and 256-511 for standard -modules. If you are writing a module that you will be distributing for -inclusion in other people's programs you may want to register a number -in the 256-511 range, contact Guido or myself or whoever you think is -"in charge" of Python for the Macintosh at the moment. Even though the -application we are writing at the moment will keep its resources in a -separate resource file it is still a good idea to make sure that no -conflicts arise: once you have opened your resource file any attempt -by the interpreter to open a dialog will also search your resource -file.

      - -Okay, let's have a look at InterslipControl-1.rsrc, our resource file. -The DLOG and accompanying DITL resource both have number 512. Since -ResEdit creates both with default ID=128 you should take care to -change the number on both. The dialog itself is pretty basic: four -buttons (connect, disconnect, update status and quit), two labels and -two status fields.

      - -

      An application with a modal dialog

      - -Next, we will have to write the actual application. For this example, -we will use a modal dialog. This means that we will put up the dialog -and go into a loop asking the dialog manager for events (buttons -pushed). We handle the actions requested by the user until the quit -button is pressed, upon which we exit our loop (and the program). This -way of structuring your program is actually rather antisocial, since -you force the user to do whatever you, the application writer, happen -to want. A modal dialog leaves no way of escape whatsoever (except -command-option-escape), and is usually not a good way to structure -anything but the most simple questions. Even then: how often have you -been confronted with a dialog asking a question that you could not -answer because the data you needed was obscured by the dialog itself? -In the next example we will look at an application that does pretty -much the same as this one but in a more user-friendly way.

      - -On to the code itself, in file InterslipControl-1.py. Have -a copy handy before you read on. The file starts off with a -textstring giving a short description. Not many tools do anything with -this as yet, but at some point in the future we will have all -sorts of nifty class browser that will display this string, so just -include it. Just put a short description at the start of each module, -class, method and function. After the initial description and some -comments, we import the modules we need.

      - -EasyDialogs is a handy standard -module that provides you with routines that put up common text-only -modal dialogs: -

        -
      • Message(str) -displays the message "str" and an OK button, -
      • AskString(prompt, default) -asks for a string, displays OK and Cancel buttons, -
      • AskYesNoCancel(question, default) -displays a question and Yes, No and Cancel buttons. -
      - -Res is a pretty complete interface to -the MacOS Resource Manager, described fully in Inside Mac. There is -currently no documentation of it, but the Apple documentation (or -Think Ref) will help you on your way if you remember two points: -
        -
      • Resources are implemented as Python objects, and each routine -with a resource first argument is implemented as a python method. -
      • When in doubt about the arguments examine the routines docstring, -as in print Res.OpenResFile.__doc__ -
      - -Similarly, Dlg is an interface to the -Dialog manager (with Dialogs being implemented as python objects and -routines with Dialog arguments being methods). The sys module you -know, I hope. Interslip, -finally, is the module with the interface to the InterSLIP driver. We -use four calls from it: -
        -
      • open() -opens the driver -
      • connect() -asks it to initiate a connection procedure (without waiting) -
      • disconnect() -asks it to initiate a disconnection procedure (without waiting) -
      • status() -returns the current connection status in the form of an integer state, -an integer "message sequence number" and a message string. -
      - -Next in the source file we get definitions for our dialog resource -number and for the item numbers in our dialog. These should match the -situation in our resource file InterslipControl-1.rsrc, -obviously. Then we get an array converting numeric state codes -returned by interslip.status() to textual messages.

      - -On to the main program. We start off with opening our resource file, -which should live in the same folder as the python source. If we -cannot open it we use EasyDialogs to print a message and -exit. You can try it: just move the resource file somewhere else for a -moment. Then, we try to open the interslip driver, again catching an -error. All modules that raise MacOS error -exceptions will pass a 2-tuple to the exception handler with the -first item being the numeric OSErr code and the second -one being an informative message. If no informative message is -available it will be the rather uninformative "MacOS Error --12345", but at least the second item will always be a -printable string. Finally we call do_dialog() to do the real work.

      - -Do_dialog() uses Dlg.GetNewDialog() to open -a dialog window initialized from 'DLOG' resource ID_MAIN and putting -it on screen in the frontmost position. Next, we go into a loop, -calling Dlg.ModalDialog() to wait for the next user -action. ModalDialog() will return us the item number that -the user has clicked on (or otherwise activated). It will handle a few -slightly more complicated things also, like the user typing into -simple textfields, but it will not do things like updating -the physical appearance of radio buttons, etc. See Inside Mac or -another programming guide for how to handle this -yourself. Fortunately, our simple application doesn't have to bother -with this, since buttons are the only active elements we have. So, we -do a simple switch on item number and call the appropriate routine to -implement the action requested. Upon the user pressing "quit" we -simply leave the loop and, hence, do_dialog(). This will -cause the python dialog object my_dlg to be deleted and -the on-screen dialog to disappear.

      - -Time for a warning: be very careful what -you do as long as a dialog is on-screen. Printing something, for -instance, may suddenly cause the standard output window to appear over -the dialog, and since we took no measures to redraw the dialog it will -become very difficult to get out of the dialog. Also, command-period -may or may not work in this situation. I have also seen crashes in -such a situation, probably due to the multiple event loops involved or -some oversight in the interpreter. You have been warned.

      - -The implementation of the "update status" command can use a bit more -explaining: we get the new information with do_status() -but now we have to update the on-screen dialog to present this -information to the user. The GetDialogItem() method of -the dialog returns three bits of information about the given item: its -type, its data handle and its rect (the on-screen x,y,w,h -coordinates). We are only interested in the data handle here, on which -we call SetDialogItemText() to set our new text. Note -here that python programmers need not bother with the C-string versus -pascal-string controversy: the python glue module knows what is needed -and converts the python string to the correct type.

      - -Finally, the three implementation routines do_connect(), -do_disconnect() and do_status() are simply -boring wrappers around the corresponding interslip methods that will -put up a dialog in case of an error.

      - -And that concludes our first example of the use of resources and -dialogs. Next, you could have a look at the source of EasyDialogs for -some examples of using input fields and filterprocs. Or, go on with -reading the second part of this document -to see how to implement a better version of this application. Not only -will it allow the user to go back to the finder (or other apps) when -your application is running, it will also free her of the RSI-inducing -chore of pressing "update status" continuously...

      - - diff --git a/Mac/Demo/example1/InterslipControl-1.py b/Mac/Demo/example1/InterslipControl-1.py deleted file mode 100644 index 14fc59c86c..0000000000 --- a/Mac/Demo/example1/InterslipControl-1.py +++ /dev/null @@ -1,92 +0,0 @@ -"""Sample program handling InterSLIP control and showing off EasyDialogs, -Res and Dlg in the process""" - -import EasyDialogs -import Res -import Dlg -import sys -import interslip -# -# Definitions for our resources -ID_MAIN=512 - -ITEM_CONNECT=1 -ITEM_DISCONNECT=2 -ITEM_UPDATE=3 -ITEM_QUIT=4 -ITEM_STATUS=5 -ITEM_MESSAGE=6 - -status2text = ["", "", "", "", - "", ""] - - -def main(): - """Main routine: open resourcefile, open interslip, call dialog handler""" - try: - Res.OpenResFile("InterslipControl-1.rsrc") - except Res.Error, arg: - EasyDialogs.Message("Cannot open resource file InterslipControl-1.rsrc: "+ - arg[1]) - sys.exit(1) - try: - interslip.open() - except interslip.error, arg: - EasyDialogs.Message("Cannot open interslip: "+arg[1]) - sys.exit(1) - do_dialog() - -def do_dialog(): - """Post dialog and handle user interaction until quit""" - my_dlg = Dlg.GetNewDialog(ID_MAIN, -1) - while 1: - n = Dlg.ModalDialog(None) - if n == ITEM_CONNECT: - do_connect() - elif n == ITEM_DISCONNECT: - do_disconnect() - elif n == ITEM_UPDATE: - status, msg = do_status() - - # Convert status number to a text string - try: - txt = status2text[status] - except IndexError: - txt = ""%status - - # Set the status text field - tp, h, rect = my_dlg.GetDialogItem(ITEM_STATUS) - Dlg.SetDialogItemText(h, txt) - - # Set the message text field - tp, h, rect = my_dlg.GetDialogItem(ITEM_MESSAGE) - Dlg.SetDialogItemText(h, msg) - elif n == ITEM_QUIT: - break - -def do_connect(): - """Connect, posting error message in case of failure""" - try: - interslip.connect() - except interslip.error, arg: - EasyDialogs.Message("Cannot connect: "+arg[1]) - -def do_disconnect(): - """Disconnect, posting error message in case of failure""" - try: - interslip.disconnect() - except interslip.error, arg: - EasyDialogs.Message("Cannot disconnect: "+arg[1]) - -def do_status(): - """Get status as (state_index, message), - posting error message in case of failure""" - try: - status, msgnum, msg = interslip.status() - except interslip.error, arg: - EasyDialogs.Message("Cannot get status: "+arg[1]) - return 0, '' - return status, msg - - -main() diff --git a/Mac/Demo/example1/InterslipControl-1.rsrc.hqx b/Mac/Demo/example1/InterslipControl-1.rsrc.hqx deleted file mode 100644 index 008bf7ebd8..0000000000 --- a/Mac/Demo/example1/InterslipControl-1.rsrc.hqx +++ /dev/null @@ -1,14 +0,0 @@ -(This file must be converted with BinHex 4.0) - -:&dPZG'9bFfaTF%0[ER4bEf`Y-5jbFh*M!(*cFQ058d9%!*!)!LIr03#3"!%!!!! -"``!!!--!!!"NCQBd4$9%-%3a4$*%-a*QCM-c0%8e46"&-88b46-5CQBA5@jdCA* -cE'P`3fpZG(*[E#da,R*cFQ-#!!!!FR0bB`!!FR0bBe*6483!N"LYGH)0!*!'!LF -cN!3d)!!e)!!`)!!a)!!b)!!c%M-c!!!d)!%e)!%`)!%a)!%b)!%c5b@U5bQU5bU -U5bZU5bbU5bfU5bkU5bp,0kT,1+T,1DT,1UT,1kT,2+T,2DT,2UT,2kT,3+T,3DT -,3UT,3kT,4+T,4DT,4UT,4kT,5+T,5DT,5UT,)!#U5b!!!!!9!'!!-J$!!C)!!3% -!!3#3"3)!N!@Q!!F!N!8m!!S!8!"@"!G$EfjZC@0d!*!'2!"D!&!!V`3+4'PcBfp -ZEQ9MG!#3"6`!Y!"3!4F%$99`C'&dC5"cG'&dGA-!N!Bm!5)!8!&@"!44G@Pd!*! -&#J"D!"S"9BJ!N!BH!&S!,J&@L!#3"JS!#J!D!&@)"e0dBA4eFcTK!*!&(J!+!#i -!9BJ)6@9cFf&RC6S!!!%!!!!"``!!!--!!!"N!2!Xe"2@!!!!(!"'!!&%6%p(!!! -!%N4*9%`!!!!H!J#3#2!VV!)!!!m!!!!C!2!VE!j$EfjdFQpX)%4TB@a[C`j$Efj -dFQpX)'4TB@a[Ca4+: diff --git a/Mac/Demo/example2.html b/Mac/Demo/example2.html deleted file mode 100644 index aebe73d293..0000000000 --- a/Mac/Demo/example2.html +++ /dev/null @@ -1,178 +0,0 @@ -Using python to create Macintosh applications, part two - -

      Using python to create Macintosh applications, part two

      -
      - -In this document we rewrite the application of the previous example to use modeless dialogs. We -will use an application framework, and we will have a look at creating -applets, standalone applications written in Python. Source and resource file (in -binary and BinHex -form for downloading) are available in the folder example2. If you want to run the program on your -machine and you have Python 1.3 or earlier you will also need a new copy of FrameWork.py, which has been -updated since the 1.3 release.

      - -Again, we start with ResEdit to create our dialogs. Not only do we -want a main dialog this time but also an "About" dialog, and we -provide the BNDL resource and related stuff that -an application cannot be without. (Actually, a python applet can be -without, see below). "Inside Mac" or various -books on macintosh programming will help here. Also, you can refer to -the resource files provided in the Python source distribution for some -of the python-specific points of BNDL programming: the -"appletbundle.rsrc" file is what is used for creating applets if you -don't provide your own resource file.

      - -Let's have a look at InterslipControl-2.rsrc, our resource file. First -off, there's the standard BNDL combo. I've picked 'PYTi' as signature -for the application. I tend to pick PYT plus one lower-case letter for -my signatures. The finder gets confused if you have two applications -with the same signature. This may be due to some incorrectness on the -side of "mkapplet", I am not sure. There is one case when you -definitely need a unique signature: when you create an applet that has -its own data files and you want the user to be able to start your -applet by double-clicking one of the datafiles.

      - -There's little to tell about the BNDL stuff: I basically copied the -generic Python applet icons and pasted in the symbol for -InterSLIP. The two dialogs are equally unexciting: dialog 512 is our -main window which has four static text fields (two of which we will be -modifying during runtime, to show the status of the connection) and -two buttons "connect" and "disconnect". The "quit" and "update status" -buttons have disappeared, because they are handled by a menu choice -and automatically, respectively.

      - -

      A modeless dialog application using FrameWork

      - -On to the source code in InterslipControl-2.py. The -start is similar to our previous example program InterSlipControl-1.py, with -one extra module being imported. To make life more simple we will use -the FrameWork module, a nifty piece of code that handles -all the gory mac details of event loop programming, menubar -installation and all the other code that is the same for every mac -program in the world. Like most standard modules, FrameWork will run -some sample test code when you invoke it as a main program, so try it -now. It will create a menu bar with an Apple menu with the about box -and a "File" menu with some pythonesque choices (which do nothing -interesting, by the way) and a "Quit" command that works.

      - -

      -If you have not used FrameWork before you may want to -first take a look at the Pathetic EDitor -example, which builds a minimal text editor using FrameWork and TextEdit. -On the other hand: we don't use many features of FrameWork, so you could -also continue with this document. -
      - -After the imports we get the definitions of resource-IDs in our -resource file, slightly changed from the previous version of our -program, and the state to string mapping. The main program is also -similar to our previous version, with one important exception: we -first check to see whether our resource is available before opening -the resource file. Why is this? Because later, when we will have -converted the script to an applet, our resources will be available in -the applet file and we don't need the separate resource file -anymore.

      - -Next comes the definition of our main class, -InterslipControl, which inherits -FrameWork.Application. The Application class handles the -menu bar and the main event loop and event dispatching. In the -__init__ routine we first let the base class initialize -itself, then we create our modeless dialog and finally we jump into -the main loop. The main loop continues until self is -raised, which we will do when the user selects "quit". When we create -the instance of MyDialog (which inherits -DialogWindow, which inherits Window) we pass -a reference to the application object, this reference is used to tell -Application about our new window. This enables the event loop to keep -track of all windows and dispatch things like update events and mouse -clicks.

      - -The makeusermenus() method (which is called sometime -during the Application __init__ routine) creates a File -menu with a Quit command (shortcut command-Q), which will callback to -our quit() method. Quit(), in turn, raises 'self' which -causes the mainloop to terminate.

      - -Application provides a standard about box, but we override this by -providing our own do_about() method which shows an about -box from a resource as a modal dialog. This piece of code should look -familiar to you from the previous example program. That do_about is -called when the user selects About from the Apple menu is, again, -taken care of by the __init__ routine of Application.

      - -Our main object finally overrides idle(), the method -called when no event is available. It passes the call on to our dialog -object to give it a chance to update the status fields, if needed.

      - -The MyDialog class is the container for our main -window. Initialization is again done by first calling the base class -__init__ function and finally setting two local variables -that are used by updatestatus() later.

      - -Do_itemhit() is called when an item is selected in this -dialog by the user. We are passed the item number (and the original -event structure, which we normally ignore). The code is similar to the -main loop of our previous example program: a switch depending on the -item selected. Connect() and disconnect() -are again quite similar to our previous example.

      - -Updatestatus() is different, however. It is now -potentially called many times per second instead of only when the -user presses a button we don't want to update the display every time -since that would cause some quite horrible flashing. Luckily, -interslip.status() not only provides us with a state and -a message but also with a message sequence number. If neither state -nor message sequence number has changed since the last call there is -no need to update the display, so we just return. For the rest, -nothing has changed.

      - -

      Creating applets

      - -Now, if you have a PowerPC Macintosh, let us try to turn the python -script into an applet, a standalone application. Actually, -"standalone" is probably not the correct term here, since an applet -does still depend on a lot of the python environment: the PythonCore -shared library, the Python Preferences file, the python Lib folder and -any other modules that the main module depends on. It is possible to -get rid of all these dependencies except for the dependency on -PythonCore, but at the moment that is still quite difficult so we will -ignore that possibility for now. By standalone we mean here that the -script has the look-and-feel of an application, including the ability -to have its own document types, be droppable, etc.

      - -The easiest way to create an applet is to take your source file and -drop it onto "mkapplet" (normally located in the Python home -folder). This will create an applet with the same name as your python -source with the ".py" stripped. Also, if a resource file with the same -name as your source but with ".rsrc" extension is available the -resources from that file will be copied to your applet too. If there -is no resource file for your script a set of default resources will be -used, and the applet will have the default creator 'PYTa'. The latter -also happens if you do have a resource file but without the BNDL -combo. Actually, for our example that would -have been the most logical solution, since our applet does not have -its own data files. It would have saved us hunting for an unused -creator code. The only reason for using the BNDL in this case is -having the custom icon, but that could have been done by pasting an -icon on the finder Info window, or by providing an custon icon in your -resource file and setting the "custom icon" finder bit.

      - -If you need slightly more control over the mkapplet process you can -double-click mkapplet, and you will get dialogs for source and -destination of the applet. The rest of the process, including locating -the resource file, remains the same.

      - -Note that though our example application completely bypasses the -normal python user interface this is by no means necessary. Any python -script can be turned into an applet, and all the usual features of the -interpreter still work.

      - -That's all for this example, you may now return to the -table of contents to pick another topic.

      diff --git a/Mac/Demo/example2/InterslipControl-2.py b/Mac/Demo/example2/InterslipControl-2.py deleted file mode 100644 index 4945864504..0000000000 --- a/Mac/Demo/example2/InterslipControl-2.py +++ /dev/null @@ -1,116 +0,0 @@ -import FrameWork -import EasyDialogs -import Res -import Dlg -import sys -import interslip -# -# Definitions for our resources -ID_MAIN=512 -ID_ABOUT=513 - -ITEM_CONNECT=1 -ITEM_DISCONNECT=2 -ITEM_STATUS=3 -ITEM_MESSAGE=4 - -status2text = ["", "", "", "", - "", ""] - -def main(): - try: - interslip.open() - except interslip.error, arg: - EasyDialogs.Message("Cannot open interslip: "+arg[1]) - sys.exit(1) - try: - dummy = Res.GetResource('DLOG', ID_MAIN) - except Res.Error: - try: - Res.OpenResFile("InterslipControl-2.rsrc") - except Res.error: - EasyDialogs.Message("Cannot open InterslipControl-2.rsrc: "+arg[1]) - sys.exit(1) - InterslipControl() - -class InterslipControl(FrameWork.Application): - "Application class for InterslipControl" - - def __init__(self): - # First init menus, etc. - FrameWork.Application.__init__(self) - # Next create our dialog - self.main_dialog = MyDialog(self) - # Now open the dialog - self.main_dialog.open(ID_MAIN) - # Finally, go into the event loop - self.mainloop() - - def makeusermenus(self): - self.filemenu = m = FrameWork.Menu(self.menubar, "File") - self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) - - def quit(self, *args): - raise self - - def do_about(self, *args): - f = Dlg.GetNewDialog(ID_ABOUT, -1) - while 1: - n = Dlg.ModalDialog(None) - if n == 1: - return - - def idle(self, event): - "Idle routine - update status" - self.main_dialog.updatestatus() - -class MyDialog(FrameWork.DialogWindow): - "Main dialog window for InterslipControl" - def __init__(self, parent): - FrameWork.DialogWindow.__init__(self, parent) - self.last_status = None - self.last_msgnum = None - - def do_itemhit(self, item, event): - if item == ITEM_DISCONNECT: - self.disconnect() - elif item == ITEM_CONNECT: - self.connect() - - def connect(self): - try: - interslip.connect() - except interslip.error, arg: - EasyDialogs.Message("Cannot connect: "+arg[1]) - - def disconnect(self): - try: - interslip.disconnect() - except interslip.error, arg: - EasyDialogs.Message("Cannot disconnect: "+arg[1]) - - def updatestatus(self): - try: - status, msgnum, msg = interslip.status() - except interslip.error, arg: - EasyDialogs.Message("Cannot get status: "+arg[1]) - sys.exit(1) - if status == self.last_status and msgnum == self.last_msgnum: - return - self.last_status = status - self.last_msgnum = msgnum - if msgnum == 0: - msg = '' - - try: - txt = status2text[status] - except IndexError: - txt = ""%status - - tp, h, rect = self.wid.GetDialogItem(ITEM_STATUS) - Dlg.SetDialogItemText(h, txt) - - tp, h, rect = self.wid.GetDialogItem(ITEM_MESSAGE) - Dlg.SetDialogItemText(h, msg) - -main() diff --git a/Mac/Demo/example2/InterslipControl-2.rsrc.hqx b/Mac/Demo/example2/InterslipControl-2.rsrc.hqx deleted file mode 100644 index f4ca24c10a..0000000000 --- a/Mac/Demo/example2/InterslipControl-2.rsrc.hqx +++ /dev/null @@ -1,56 +0,0 @@ -(This file must be converted with BinHex 4.0) - -:&dPZG'9bFfaTF%0[ER4bEf`Y-LjbFh*M!(*cFQ058d9%!*!)$2eid3#3"!%!!!! -,T!!!#U3!!!&CCQBd4$9%-%3a4$*%-a*QCM-c0%8e46"&-88b46-5CQBA5@jdCA* -cE'P`3fpZG(*[E#db,R*cFQ-#!!!!FR0bB`!!FR0bBe*6483!N"LYGH)3!*!'$2d -cN!3d)!!e)!!`)!!a)!!b)!!c%M-c!!!d)!%e)!%`)!%a)!%b)!%c5b@U5bQU5bU -U5bZU5bbU5bfU5bkU5bp,0kT,1+T,1DT,1UT,1kT,2+T,2DT,2UT,2kT,3+T,3DT -,3UT,3kT,4+T,4DT,4UT,4kT,5+T,5DT,5UT,)!#U5b!!!!!9!'B!KJ$&!GB!!!% -!!3#3"3)!N!89!'!!E!%@!AJ!!3%!!3#3"3)"!*!%(&"C9'N!!!!"4P*&4J#3"B" -*3diM!*!&J!!!!!G"8&"-!*!&!3!!!3!!%!+!!!3%3!"%##!!9I!3!&%J#!"3i!3 -!8-!#!"2`!3"6m!#!4rJ13%ri%5"Ar#U3!'rm3%K2r&9%crj!3Rrq+S&rrK%#(rm -1"#hr!)JVIbp3+b9HS'PPS%"T*B#!Irq"!!!J!J!!%!3!!!J)!!!%%!!!!L!!!!& -!!!!!J!!!!3!!%!1!!!3(`!"%$q!!9Ir`!&(rq!"3rr`!82rq!"2rr`"6rrq!4rr -r`%rrrq"Irrr`Irrrq(rrrrcrrrrqIrrrrhrrrriIrrrm2rrrq$rrrr!rrrrJIrr -r`(rrri"rrrm!!$rq!!!Ir!!!$rJ!!!I`!!!$i!!!!F!!!!#!!!!!"!#3%2m!N"2 -r!*!+r`$r!*!8r`#3"rm!+`$r!*!2r`!!!2m!N!Er!#XV+`$r!*!1r`$r!2m!X*! -%r`!VN!8!r`#3$Im!r`!!!,!!!,!VN!J!r`#3$2m!r`#3",#`q[Vk+j!(!2m!N![ -r!2m!N!5`X2VkqLZ3#!$r!*!-r`!!X*!'+j!+!2m!N!Rr!2m!!,#3"LZ3#`$r!*! -)r`!!!,#3#2SVN!Emrr`V!2m!N!Ir!!$rX*!)qLZ3"2Q*+bXVLIN!r`#3"[m!r`# -`N!MkqLXV+iNVL5Z*+r`V!2m!N!Arr`#`N!Vk+b[m+j!(r#X!r`#3"2m!+l#3#[S -V+rmVL5Z*+iNVrbXV!2m!!2rr+bZ`N!VkqL[m+j!(r#XV+`$r!!$rr,#3$2SV+r` -VL5Z*+iNVN!Er!2rrX*!-qLXVqBNV+bZ*q5Z3"2Vr!*!%X*!-q[SV+b[mrr`VN!A -kr`#3",!&X,!&X*!*qLZ3"rmV+rVr!*!&X!@`"E#`"E#3"rSVrb[rN!6jrrVr!*! -'X!@`"E#`"3@`"3@`"E$krrRrN!3VrrVr!*!'X,!&X!8&X!@`X!8&X!@`X#[r+j! -&q[m!N!H`X!@`"3@`"3@`"3@`"E#`qLZ3"IVr!*!)X*!3q[SV+b[kr`#3%[rkN!J -V+rVr!*!8rrU3"b[kr`#3&[rk+j!&q[m!N"MrqLXV+rVr!*!DrrSVq[m!N"crq[m -!N"lr!*!4!J#3#!m!N!N2!*!&m2!!N!N2!!!!$``2!*!($`!2!!!!m-c!m!#3"Jm -2$`99A`c-c!m!N!B2$`!&!&c-c-c!m!#3"3m2!!"9hGc-c-`2!*!&$`m!!&AGh-c --c-$`!*!&$`"999A-N!82!*!%$`m!9999c*!&`2!!!!!2!!99999Gc-c-lq`2!!! -!$`$e9999AFc-fXc+d2!!!!m2"99999hFc+bXV1`2!!!2m&@3"Gc1c-c-cX$`!!m --9C!&h-r+bXV2c!m!rma9N!AGcXc-c-l-`2!2j9@3"9h-l+bXV-c-c`re9C!&AFc -Dc-VFc-h`!!99N!9Gh-c[l-c-h`!!89899C!%h-c-c2c0m!!!89&9&9999Gcmrrr -Ih`!!!&&494&4&4AIhrrmrI!!!!9484898489A2c-c0m!!!!&89%9%9%9&9h-c-h -`!!!!"9@3"ehFc0m!N!RphGhGh-h`!*!*$phGhGcI!*!,rFc-cI!!N!X2h-cI!*! -0rFh`!*!0$pm!N!r`!*!*!3#3"Im!!!$r!*!*r`$r!!$r!2m!N!cr!#X!r`#3#[m -!+bXV!2m!N!Er!,#`X#Z3"!$r!*!&rrm!X2Rj+j!%!2m!N!6r!,#`X#XV+rQ*+`$ -r!!$rrbZ`X,$j+bZ*q5XV+rm!!2q`N!Aj+j!%qIm!N!5`N!Aj+rrrqIm!N!5`"E! -&X!@`q5[jr`#3"E#3"rRjr`#3#[rjqIRr!*!-rrRr!*!1r`#3'S!!!2!!m!#3"2$ -`$`m!N!E``2!!N!32$-`2!!!!m&9Fc-$`!!$r"Gh-c!m!!2"9A-cD`2!2r&9Gc+h --c`$e99AFc-h`!!999Gcrh`!!89&4AFh`!!"9999Gh`#3"IhGm!#3"3rI!*!(m!# -3$N!)J#P!!L!%%#i)0!3Z%QiK2`)I0#U)2j!!!L!"3!#!!!!)J#R!!q!(m#ri2r` -rrRrr2riIr$ri2r!$i!(!!)!!N!9i!!8!N!8m!!S!8!"@"!G$EfjZC@0d!*!'2!$ -`!&!"433+4'PcBfpZEQ9MG!#3"3S!@J!D!8D)!*!'(J"D!#i"4SJ!N!B+!!S!'J" -9L!G6G'&dGA-km!#3"4i!#J!Z!&@)#%ePFh0KCf8k!!!!CJ!$!*!&PJ"a!+S!U`3 -#6dX!N!8+!(%!5J#aS!)#!3#3"9!!9!"J!-Q)%8PZG'9bFfaTF#"$EfjdFQpXB3# -3"@i!2!#$!1')&NTKBfXJ5Q&ZFf9Z,#"$9dNX)$%j168!!!#!!!%!!"!#J!!%"%! -!4!JJ!&A`%!"4)!J!81!%!&$!!J!6m!%!8r!!J%Ii$N"2q"%J9r`UN!"[r%")6ra -94-rq3%*rrLU"Iri4!Krr$J3Yr`#)+hm[8#XPAU"TCD"!D5@!J(rrJ3!!)!)!!"! -%!!!)#!!!""!!!!)J!!!"3!!!!)!!N!3"!!!!!3!!!!ZN!!!+T!!!!9N!a!8%%Pi -!!!!F!5B!#d4-6dF!!3"L4%P86!!"!(T#6N4-!!!!NNC548B!!!#H5801)`!!!+T -TBf`i!!!!YQPME$3!!!$#D@0c1!!!!-jTBh-d!!!!fQPMFb-!!!$Q58026J!!!2* -3@94T!!!!rJ)!N!X#!3!2!!!!'3#3"!)!rrm!!!Ne!*!%!J(rr`!!#E%!N!@!rrm -!!!!b!-3$U!#!rrm!!!"5!-3#X!#!rrm!!!"G!-3#Y!#!rrm!!!&K!-3#1!#!rrm -!!!9P!-3$D!#!rrm!!!GT!-3#+!#!rrm!!!KY!-3#2!#!rrm!!!Ma!-3#3!)"!"N -!!!SE!*!(*!!!#Tm!a!)X$N0[ER4bEf`J4'PKE'pR#8&LEh9d)'*[H!T"BQpeG#" -*BfpZ$NphEQ9b)(*PFfpeFQ0P$#`: diff --git a/Mac/Demo/imgbrowse/imgbrowse.py b/Mac/Demo/imgbrowse/imgbrowse.py deleted file mode 100644 index 56d6d3128f..0000000000 --- a/Mac/Demo/imgbrowse/imgbrowse.py +++ /dev/null @@ -1,156 +0,0 @@ -"""imgbrowse - Display pictures using img""" - -import FrameWork -import EasyDialogs -import Res -import Qd -import QuickDraw -import Win -#import List -import sys -import struct -import img -import imgformat -import macfs -import struct - - -# Where is the picture window? -LEFT=200 -TOP=64 -MINWIDTH=64 -MINHEIGHT=64 -MAXWIDTH=320 -MAXHEIGHT=320 - -def dumppixmap(data): - baseAddr, \ - rowBytes, \ - t, l, b, r, \ - pmVersion, \ - packType, packSize, \ - hRes, vRes, \ - pixelType, pixelSize, \ - cmpCount, cmpSize, \ - planeBytes, pmTable, pmReserved \ - = struct.unpack("lhhhhhhhlllhhhhlll", data) - print 'Base: 0x%x'%baseAddr - print 'rowBytes: %d (0x%x)'%(rowBytes&0x3fff, rowBytes) - print 'rect: %d, %d, %d, %d'%(t, l, b, r) - print 'pmVersion: 0x%x'%pmVersion - print 'packing: %d %d'%(packType, packSize) - print 'resolution: %f x %f'%(float(hRes)/0x10000, float(vRes)/0x10000) - print 'pixeltype: %d, size %d'%(pixelType, pixelSize) - print 'components: %d, size %d'%(cmpCount, cmpSize) - print 'planeBytes: %d (0x%x)'%(planeBytes, planeBytes) - print 'pmTable: 0x%x'%pmTable - print 'pmReserved: 0x%x'%pmReserved - -def mk16pixmap(w, h, data): - """kludge a pixmap together""" - rv = struct.pack("lhhhhhhhlllhhhhlll", - id(data)+12, - w*2 + 0x8000, - 0, 0, h, w, - 0, - 0, 0, # XXXX? - 72<<16, 72<<16, - 16, 16, # XXXX - 3, 5, - 0, 0, 0) - print 'Our pixmap, size %d:'%len(rv) - dumppixmap(rv) - return Qd.RawBitMap(rv) - -def main(): - print 'hello world' - imgbrowse() - -class imgbrowse(FrameWork.Application): - def __init__(self): - # First init menus, etc. - FrameWork.Application.__init__(self) - self.lastwin = None - # Finally, go into the event loop - self.mainloop() - - def makeusermenus(self): - self.filemenu = m = FrameWork.Menu(self.menubar, "File") - self.openitem = FrameWork.MenuItem(m, "Open...", "O", self.opendoc) - self.infoitem = FrameWork.MenuItem(m, "Info", "I", self.info) - self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) - - def quit(self, *args): - raise self - - def opendoc(self, *args): - fss, ok = macfs.StandardGetFile() # Any file type - if not ok: - return - bar = EasyDialogs.ProgressBar('Reading and converting...') - pathname = fss.as_pathname() - try: - rdr = img.reader(imgformat.macrgb16, pathname) - except img.error, arg: - EasyDialogs.Message(`arg`) - return - w, h = rdr.width, rdr.height - bar.set(10) - data = rdr.read() - del bar - pixmap = mk16pixmap(w, h, data) - self.showimg(w, h, pixmap) - - def showimg(self, w, h, pixmap): - win = imgwindow(self) - win.open(w, h, pixmap) - self.lastwin = win - - def info(self, *args): - if self.lastwin: - self.lastwin.info() - -class imgwindow(FrameWork.Window): - def open(self, width, height, pixmap): - self.pixmap = pixmap - self.pictrect = (0, 0, width, height) - bounds = (LEFT, TOP, LEFT+width, TOP+height) - - self.wid = Win.NewCWindow(bounds, "Picture", 1, 0, -1, 1, 0) - self.do_postopen() - - def do_update(self, *args): - pass - currect = self.fitrect() - print 'PICT:', self.pictrect - print 'WIND:', currect - print 'ARGS:', (self.pixmap, self.wid.GetWindowPort().portBits, self.pictrect, - currect, QuickDraw.srcCopy, None) - self.info() - Qd.CopyBits(self.pixmap, self.wid.GetWindowPort().portBits, self.pictrect, - currect, QuickDraw.srcCopy+QuickDraw.ditherCopy, None) -## Qd.DrawPicture(self.picture, currect) - - def fitrect(self): - """Return self.pictrect scaled to fit in window""" - graf = self.wid.GetWindowPort() - screenrect = graf.portRect - picwidth = self.pictrect[2] - self.pictrect[0] - picheight = self.pictrect[3] - self.pictrect[1] - if picwidth > screenrect[2] - screenrect[0]: - factor = float(picwidth) / float(screenrect[2]-screenrect[0]) - picwidth = picwidth / factor - picheight = picheight / factor - if picheight > screenrect[3] - screenrect[1]: - factor = float(picheight) / float(screenrect[3]-screenrect[1]) - picwidth = picwidth / factor - picheight = picheight / factor - return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth), - screenrect[1]+int(picheight)) - - def info(self): - graf = self.wid.GetWindowPort() - bits = graf.portBits - dumppixmap(bits.pixmap_data) - -main() diff --git a/Mac/Demo/index.html b/Mac/Demo/index.html deleted file mode 100644 index ce92a9daf3..0000000000 --- a/Mac/Demo/index.html +++ /dev/null @@ -1,127 +0,0 @@ -Macintosh Python crash course - -

      Macintosh Python crash course

      -
      - -This set of documents provides an introduction to various aspects of -Python programming on the Mac. It is assumed that the reader is -already familiar with Python and, to some extent, with MacOS Toolbox -programming. Other readers may find something interesting here too, -your mileage may vary.

      - -There is a companion document Using Python on the Mac -which you should read before starting here: it explains the basics of using -python on the Macintosh.

      - -Another set of Macintosh-savvy examples, more aimed at beginners, is -maintained by Joseph Strout, at -http://www-acs.ucsd.edu/~jstrout/python/. -

      - -The Python Library Reference contains a section on -Macintosh-specific modules -that you should also read. Documentation is also available in PostScript and other -forms, see the documentation section -on the webserver.

      - -Some of these documents were actually written while I was working on a "real" -project: creating a single-button application that will allow my -girlfriend to read her mail (which actually pass thry my -mailbox, so I get to read it too, but don't tell her:-) without her -having to worry about internet connections, unix commands, etc. The -application, when finished, will connect to the net using InterSLIP, -start a (pseudo-)POP server on unix using rsh and use AppleScript to -tell Eudora to connect to that server and retrieve messages.

      - -These examples were all built using Python 1.3.3, which can be downloaded -from ftp.cwi.nl, directory -/pub/jack/python/mac, and possibly from the -ftp.python.org server and its mirrors as well. Some examples may work -with earlier versions of Python, some will definitely not. -

      Table of contents

      - - - -The Python distribution contains a few more examples, all unexplained: -
        -
      • -PICTbrowse is an application that locates PICT -resources and displays them, it demonstrates some quickdraw and the -resource and list managers. - -
      • -Imgbrowse displays image files in -many different formats (gif, tiff, pbm, etc). It shows how to use the -img modules on the mac. - -
      • -Quicktime has the standard MovieInWindow and -VerySimplePlayer examples, re-coded in Python. - -
      • -Resources, Sound and Speech have some examples -on using the respective managers. -
      - -At some point in the (possibly distant) future, I will add chapters on -how to use bgen to create modules completely automatic and how to make -your Python program scriptable, but that will have to wait.

      - -


      - -Please let me know if you miss critical information in this -document. I am quite sure that I will never find the time to turn it -into a complete MacPython programmers guide (which would probably be a -400-page book instead of 5 lousy html-files), but it should contain -at least the information that is neither in the standard Python -documentation nor in Inside Mac or other Mac programmers -documentation.

      - -


      -Jack Jansen, -jack@cwi.nl, 18-July-1996. - diff --git a/Mac/Demo/interslip/InterslipLib.c b/Mac/Demo/interslip/InterslipLib.c deleted file mode 100644 index 32c9717add..0000000000 --- a/Mac/Demo/interslip/InterslipLib.c +++ /dev/null @@ -1,97 +0,0 @@ -/* -** InterslipLib - Routines to talk to InterSLIP. Version 1.1, 31-Oct-1995. -** -** -** (c) Jack Jansen, CWI, 1995 -*/ - -#include - -#include "InterslipLib.h" - -static CntrlParam iopb; -static short refnum = -1; - -OSErr is_open() -{ - if ( refnum >= 0 ) return 0; - return OpenDriver("\p.InterSLIP", &refnum); -} - -OSErr is_connect() -{ - iopb.ioCRefNum = refnum; - iopb.ioVRefNum = refnum; - iopb.ioCompletion = (UniversalProcPtr) 0; - iopb.csCode = 2; - return PBControlImmed((ParmBlkPtr)&iopb); -} - -OSErr is_disconnect() -{ - iopb.ioCRefNum = refnum; - iopb.ioVRefNum = refnum; - iopb.ioCompletion = (UniversalProcPtr) 0; - iopb.csCode = 3; - return PBControlImmed((ParmBlkPtr)&iopb); -} - -OSErr is_status(long *status, long *msgseqnum, StringPtr *msg) -{ - long *csp; - OSErr err; - - iopb.ioCRefNum = refnum; - iopb.ioVRefNum = refnum; - iopb.ioCompletion = (UniversalProcPtr) 0; - iopb.csCode = 4; - if( err = PBControlImmed((ParmBlkPtr)&iopb) ) - return err; - csp = (long *)&iopb.csParam; - *status = csp[0]; - *msgseqnum = csp[1]; - *msg = (unsigned char *)csp[2]; - return 0; -} - -OSErr is_getconfig(long *baudrate, long *flags, - Str255 idrvnam, Str255 odrvnam, Str255 cfgnam) -{ - long *csp; - OSErr err; - - iopb.ioCRefNum = refnum; - iopb.ioVRefNum = refnum; - iopb.ioCompletion = (UniversalProcPtr) 0; - iopb.csCode = 6; - csp = (long *)&iopb.csParam; - csp[2] = (long)idrvnam; - csp[3] = (long)odrvnam; - csp[4] = (long)cfgnam; - if( err = PBControlImmed((ParmBlkPtr)&iopb) ) - return err; - *baudrate = csp[0]; - *flags = csp[1]; - return 0; -} - -OSErr is_setconfig(long baudrate, long flags, - Str255 idrvnam, Str255 odrvnam, Str255 cfgnam) -{ - long *csp; - OSErr err; - - iopb.ioCRefNum = refnum; - iopb.ioVRefNum = refnum; - iopb.ioCompletion = (UniversalProcPtr) 0; - iopb.csCode = 7; - csp = (long *)&iopb.csParam; - csp[0] = baudrate; - csp[1] = flags; - csp[2] = (long)idrvnam; - csp[3] = (long)odrvnam; - csp[4] = (long)cfgnam; - return PBControlImmed((ParmBlkPtr)&iopb); -} - - diff --git a/Mac/Demo/interslip/InterslipLib.h b/Mac/Demo/interslip/InterslipLib.h deleted file mode 100644 index 1ca2276d59..0000000000 --- a/Mac/Demo/interslip/InterslipLib.h +++ /dev/null @@ -1,20 +0,0 @@ -/* -** InterSLIP API. -*/ - -#include - -/* States */ -#define IS_IDLE 0 -#define IS_WMODEM 1 -#define IS_DIAL 2 -#define IS_LOGIN 3 -#define IS_RUN 4 -#define IS_DISC 5 - -OSErr is_open(); /* Open InterSLIP driver (optional) */ -OSErr is_connect();/* Connect */ -OSErr is_disconnect(); /* Disconnect */ -OSErr is_status(long *, long *, StringPtr *); /* Get status, msg seq#, msg pointer */ -OSErr is_getconfig(long *, long *, Str255 , Str255 , Str255 ); /* get config */ -OSErr is_setconfig(long , long , Str255 , Str255 , Str255 ); /* set config */ diff --git a/Mac/Demo/interslip/interslipmodule.c b/Mac/Demo/interslip/interslipmodule.c deleted file mode 100644 index dc2c7a8da8..0000000000 --- a/Mac/Demo/interslip/interslipmodule.c +++ /dev/null @@ -1,225 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#include "Python.h" -#include "InterslipLib.h" -#include "macglue.h" - -static PyObject *ErrorObject; - -/* ----------------------------------------------------- */ - -static char pyis_open__doc__[] = -"Load the interslip driver (optional)" -; - -static PyObject * -pyis_open(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - OSErr err; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - err = is_open(); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static char pyis_connect__doc__[] = -"Tell the driver to start a connect" -; - -static PyObject * -pyis_connect(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - OSErr err; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - err = is_connect(); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static char pyis_disconnect__doc__[] = -"Tell the interslip driver to start a disconnect" -; - -static PyObject * -pyis_disconnect(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - OSErr err; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - err = is_disconnect(); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static char pyis_status__doc__[] = -"Return (numeric_status, message_seqnum, message_string) status tuple" -; - -static PyObject * -pyis_status(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - long status, seqnum; - StringPtr message; - OSErr err; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - err = is_status(&status, &seqnum, &message); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - return Py_BuildValue("iiO&", (int)status, (int)seqnum, PyMac_BuildStr255, message); -} - -static char pyis_getconfig__doc__[] = -"Return configuration data (ibaud, obaud, flags, idrvname, odrvname, cfgname)" -; - -static PyObject * -pyis_getconfig(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - long baudrate, flags; - Str255 idrvname, odrvname, cfgname; - OSErr err; - int ibaud, obaud; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - err = is_getconfig(&baudrate, &flags, idrvname, odrvname, cfgname); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - ibaud = (baudrate >> 16) & 0xffff; - obaud = baudrate & 0xffff; - return Py_BuildValue("iiiO&O&O&", ibaud, obaud, (int)flags, PyMac_BuildStr255, idrvname, - PyMac_BuildStr255, odrvname, PyMac_BuildStr255, cfgname); -} - -static char pyis_setconfig__doc__[] = -"Set configuration data (ibaud, obaud, flags, idrvname, odrvname, cfgname)" -; - -static PyObject * -pyis_setconfig(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - long baudrate; - int flags; - Str255 idrvname, odrvname, cfgname; - OSErr err; - int ibaud, obaud; - - if (!PyArg_ParseTuple(args, "iiiO&O&O&", &ibaud, &obaud, &flags, PyMac_GetStr255, idrvname, - PyMac_GetStr255, odrvname, PyMac_GetStr255, cfgname)) - return NULL; - baudrate = (ibaud << 16) | obaud; - err = is_setconfig(baudrate, (long)flags, idrvname, odrvname, cfgname); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -/* List of methods defined in the module */ - -static struct PyMethodDef pyis_methods[] = { - {"open", pyis_open, 1, pyis_open__doc__}, - {"connect", pyis_connect, 1, pyis_connect__doc__}, - {"disconnect", pyis_disconnect, 1, pyis_disconnect__doc__}, - {"status", pyis_status, 1, pyis_status__doc__}, - {"getconfig", pyis_getconfig, 1, pyis_getconfig__doc__}, - {"setconfig", pyis_setconfig, 1, pyis_setconfig__doc__}, - - {NULL, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called initinterslip) */ - -static char interslip_module_documentation[] = -"" -; - -void -initinterslip() -{ - PyObject *m, *d; - - /* Create the module and add the functions */ - m = Py_InitModule4("interslip", pyis_methods, - interslip_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - ErrorObject = PyString_FromString("interslip.error"); - PyDict_SetItemString(d, "error", ErrorObject); - - /* XXXX Add constants here */ - - PyDict_SetItemString(d, "IDLE", PyInt_FromLong(IS_IDLE)); - PyDict_SetItemString(d, "WMODEM", PyInt_FromLong(IS_WMODEM)); - PyDict_SetItemString(d, "DIAL", PyInt_FromLong(IS_DIAL)); - PyDict_SetItemString(d, "LOGIN", PyInt_FromLong(IS_LOGIN)); - PyDict_SetItemString(d, "RUN", PyInt_FromLong(IS_RUN)); - PyDict_SetItemString(d, "DISC", PyInt_FromLong(IS_DISC)); - - /* Check for errors */ - if (PyErr_Occurred()) - Py_FatalError("can't initialize module interslip"); -} - diff --git a/Mac/Demo/plugins.html b/Mac/Demo/plugins.html deleted file mode 100644 index 465603c7be..0000000000 --- a/Mac/Demo/plugins.html +++ /dev/null @@ -1,363 +0,0 @@ -Creating a C extension module on the Macintosh - -

      Creating a C extension module on the Macintosh

      -
      - -This document gives a step-by-step example of how to create a new C -extension module on the mac. For this example, we will create a module -to interface to the programmers' API of InterSLIP, a package that -allows you to use MacTCP (and, hence, all internet services) over a -modem connection.

      - -

      Prerequisites

      - -There are a few things you need to pull this off. First and foremost, -you need a C development environment. Actually, you need a specific -development environment, CodeWarrior by MetroWerks. You will probably -need the latest version. You may be able to get by with an older -version of CodeWarrior or with another development environment (Up to -about 1994 python was developed with THINK C, and in the dim past it -was compiled with MPW C) assuming you have managed to get Python to -compile under your development environment, but the step-by-step -character of this document will be lost.

      - -Next, you need a python -source distribution. There is a fixed project template that -you also need if you are going to make a dynamically loaded -module. For PowerPC development you can actually get by without a full -source distribution, using the PPC Development distribution (if I have -gotten around to putting it together by the time you read -this). You'll also need a functional python interpreter, and the -Modulator program (which lives in Tools:Modulator in the -standard source distribution). You may also find that Guido's Extending and embedding -the Python interpreter is a very handy piece of documentation. I -will skip lots of details that are handled there, like complete -descriptions of Py_ParseTuple and such utility routines, -or the general structure of extension modules.

      - -

      InterSLIP and the C API to it

      - -InterSLIP, the utility to which we are going to create a python -interface, is a system extension that does all the work of connecting -to the internet over a modem connection. InterSLIP is provided -free-of-charge by InterCon. First it connects to -your modem, then it goes through the whole process of dialling, -logging in and possibly starting the SLIP software on the remote -computer and finally it starts with the real work: packing up IP -packets handed to it by MacTCP and sending them to the remote side -(and, of course, the reverse action of receiving incoming packets, -unpacking them and handing them to MacTCP). InterSLIP is a device -driver, and you control it using a application supplied with it, -InterSLIP Setup. The API that InterSLIP Setup uses to talk to the -device driver is published in the documentation and, hence, also -useable by other applications.

      - -I happened to have a C interface to the API, which is all ugly -low-level device-driver calls by itself. The C interface is in InterslipLib.c and InterslipLib.h, we'll -concentrate here on how to build the Python wrapper module around -it. Note that this is the "normal" situation when you are writing a -Python extension module: you have some sort of functionality available -to C programmers and want to make a Python interface to it.

      - -

      Using Modulator

      - -The method we describe in this document, using Modulator, is the best -method for small interfaces. For large interfaces there is another -tool, Bgen, which actually generates the complete module without you -lifting a single finger. Bgen, however, has the disadvantage of having -a very steep learning curve, so an example using it will have to wait -until another document, when I have more time.

      - -First, let us look at the InterslipLib.h header file, -and see that the whole interface consists of six routines: -is_open, is_connect, -is_disconnect, is_status, -is_getconfig and is_setconfig. Our first -step will be to create a skeleton file @interslipmodule.c, a -dummy module that will contain all the glue code that python expects -of an extension module. Creating this glue code is a breeze with -modulator, a tool that we only have to tell that we want to create a -module with methods of the six names above and that will create the -complete skeleton C code for us.

      - -Why call this dummy module @interslipmodule.c and not -interslipmodule.c? Self-preservation: if ever you happen -to repeat the whole process after you have actually turned the -skeleton module into a real module you would overwrite your -hand-written code. By calling the dummy module a different name you -have to make two mistakes in a row before you do this.

      - -On systems with the Tk windowing API for Python (currently only -unix/X11 systems, but mac support may be available when you read this) -this is extremely simple. It is actually so simple that it pays to -create the skeleton module under unix and ship the code to your -mac. You start modulator and are provided with a form in which you -fill out the details of the module you are creating.

      - -

      - -You'll need to supply a module name (interslip, in our -case), a module abbreviation (pyis, which is used as a -prefix to all the routines and data structures modulator will create -for you) and you enter the names of all the methods your module will -export (the list above, with is_ stripped off). Note that -we use pyis as the prefix instead of the more logical -is, since the latter would cause our routine names to -collide with those in the API we are interfacing to! The method names -are the names as seen by the python program, and the C routine names -will have the prefix and an underscore prepended. Modulator can do -much more, like generating code for objects and such, but that is a -topic for a later example.

      - -Once you have told modulator all about the module you want to create -you press "check", which checks that you haven't omitted any -information and "Generate code". This will prompt you for a C output -file and generate your module for you.

      - -

      Using Modulator without Tk

      - - -Modulator actually uses a two-stage process to create your code: first -the information you provided is turned into a number of python -statements and then these statements are executed to generate your -code. This is done so that you can even use modulator if you don't -have Tk support in Python: you'll just have to write the modulator -python statements by hand (about 10 lines, in our example) and -modulator will generate the C code (about 150 lines, in our -example). Here is the Python code you'll want to execute to generate -our skeleton module:

      - -

      -	import addpack
      -	addpack.addpack('Tools')
      -	addpack.addpack('modulator')
      -	import genmodule
      -
      -	m = genmodule.module()
      -	m.name = 'interslip'
      -	m.abbrev = 'pyis'
      -	m.methodlist = ['open', 'connect', 'disconnect', 'status', \
      -		'getconfig', 'setconfig']
      -	m.objects = []
      -
      -	fp = open('@interslipmodule.c', 'w')
      -	genmodule.write(fp, m)
      -
      - -Drop this program on the python interpreter and out will come your -skeleton module.

      - -Now, rename the file to interslipmodule.c and you're all set to start -developing. The module is complete in the sense that it should -compile, and that if you import it in a python program you will see -all the methods. It is, of course, not yet complete in a functional -way...

      - -

      Adding a module to 68K Python

      - -What you do now depends on whether you're developing for PowerPC (or -for CFM68K) or for "traditional" mac. For a traditional 68K Python, -you will have to add your new module to the project file of the Python -interpreter, and you have to edit "config.c" to add the module to the -set of builtin modules. In config.c you will add the module at two -places: near the start of the file there is a list of external -declarations for all init() routines. Add a line of the form -
      -		extern void initinterslip();
      -
      -here. Further down the file there is an array that is initialized with -modulename/initfunction pairs. Add a line of the form -
      -		{"interslip",	initinterslip},
      -
      -here. You may want to bracket these two lines with -
      -	#ifdef USE_INTERSLIP
      -	#endif
      -
      -lines, that way you can easily control whether the module is -incorporated into python at compile time. If you decide to do the -latter edit your config file (you can find the name in the "C/C++ -language" section of the MW preferences dialog, it will probably be -"mwerks_nonshared_config.h") and add a -
      -	#define USE_INTERSLIP
      -
      - -Make the new interpreter and check that you can import the module, see -the methods (with "dir(interslip)") and call them.

      - -

      Creating a PowerPC plugin module

      - -For PowerPC development you could follow the same path, but it is -actually a better idea to use a dynamically loadable module. The -advantage of dynamically loadable modules is that they are not loaded -until a python program actually uses them (resulting in less memory -usage by the interpreter) and that development is a lot simpler (since -your projects will all be smaller). Moreover, you can distribute a -plugin module by itself without haveing to distribute a complete -python interpreter.

      - -Go to the "PlugIns" folder and copy the files xxmodule.µ, -xxmodule_config.h and xxmodule.µ.exp to interslipmodule.µ, -interslipmodule_config.h and interslipmodule.µ.exp, respectively. Edit -interslipmodule.µ.exp and change the name of the exported routine -"initxx" to "initinterslip". Open interslipmodule.µ with CodeWarrior, -remove the file xxmodule.c and add interslipmodule.c and make a number -of adjustments to the preferences: -

        -
      • in C/C++ language, set the header file to interslipmodule_config.h -
      • in PPC linker, set the entry point to "initinterslip" -
      • in PPC PEF, set the fragment name to "interslipmodule" -
      • in PPC Project, set the output file name to "interslipmodule.slb". -
      -Next, compile and link your module, fire up python and do the same -tests as for 68K python.

      - -

      Getting the module to do real work

      - -So far, so good. In half an hour or so we have created a complete new -extension module for Python. The downside, however, is that the module -does not do anything useful. So, in the next half hour we will turn -our beautiful skeleton module into something that is at least as -beautiful but also gets some serious work done. For this once, -I have spent that half hour for you, and you can see the -results in interslipmodule.c.

      - -We add -

      -	#include "InterslipLib.h"
      -	#include "macglue.h"
      -
      -to the top of the file, and work our way through each of the methods -to add the functionality needed. Starting with open, we fill in the -template docstring, the value accessible from Python by looking at -interslip.open.__doc__. There are not many tools using -this information at the moment, but as soon as class browsers for -python become available having this minimal documentation available is -a good idea. We put "Load the interslip driver" as the comment -here.

      - -Next, we tackle the body of pyis_open(). Since it has no -arguments and no return value we don't need to mess with that, we just -have to add a call to is_open() and check the return for -an error code, in which case we raise an error: -

      -	err = is_open();
      -	if ( err ) {
      -		PyErr_Mac(ErrorObject, err);
      -		return NULL;
      -	}
      -
      -The routine PyErr_Mac() is a -useful routine that raises the exception passed as its first -argument. The data passed with the exception is based on the standard -MacOS error code given, and PyErr_Mac() attempts to locate a textual -description of the error code (which sure beats the "error -14021" -messages that so many macintosh applications tell their poor -users).

      - -We will skip pyis_connect and pyis_disconnect here, which are pretty -much identical to pyis_open: no arguments, no return value, just a -call and an error check. With pyis_status() things get interesting -again: this call still takes 3 arguments, and all happen to be values -returned (a numeric connection status indicator, a message sequence -number and a pointer to the message itself, in MacOS pascal-style -string form). We declare variables to receive the returned values, do -the call, check the error and format the return value.

      - -Building the return value is done using Py_BuildValue: -

      -	return Py_BuildValue("iiO&", (int)status, (int)seqnum, PyMac_BuildStr255, message);
      -
      -Py_BuildValue() is a very handy routine that builds tuples according -to a format string, somewhat similar to the way printf() -works. The format string specifies the arguments expected after the -string, and turns them from C objects into python objects. The -resulting objects are put in a python tuple object and returned. The -"i" format specifier signifies an "int" (hence the cast: status and -seqnum are declared as "long", which is what the is_status() routine -wants, and even though we use a 4-byte project there is really no -reason not to put the cast here). Py_BuildValue and its counterpart -Py_ParseTuple have format codes for all the common C types like ints, -shorts, C-strings, floats, etc. Also, there is a nifty escape -mechanism to format values about which is does not know. This is -invoked by the "O&" format: it expects two arguments, a routine -pointer and an int-sized data object. The routine is called with the -object as a parameter and it should return a python objects -representing the data. Macglue.h declares a number of -such formatting routines for common MacOS objects like Str255, FSSpec, -OSType, Rect, etc. See the comments in the include file for -details.

      - -Pyis_getconfig() is again similar to pyis_getstatus, only -two minor points are worth noting here. First, the C API return the -input and output baudrate squashed together into a single 4-byte -long. We separate them out before returning the result to -python. Second, whereas the status call returned us a pointer to a -Str255 it kept we are responsible for allocating the -Str255 for getconfig. This is something that would have -been easy to get wrong had we not used prototypes everywhere. Morale: -always try to include the header files for interfaces to libraries and -other stuff, so that the compiler can catch any mistakes you make.

      - -Pyis_setconfig() finally shows off -Py_ParseTuple, the companion function to -Py_BuildValue. You pass it the argument tuple "args" -that your method gets as its second argument, a format string and -pointers to where you want the arguments stored. Again, standard C -types such as strings and integers Py_ParseTuple knows all about and -through the "O&" format you can extend the functionality. For each -"O&" you pass a function pointer and a pointer to a data area. The -function will be called with a PyObject pointer and your data pointer -and it should convert the python object to the correct C type. It -should return 1 on success and 0 on failure. Again, a number of -converters for standard MacOS types are provided, and declared in -macglue.h.

      - -Next in our source file comes the method table for our module, which -has been generated by modulator (and it did a good job too!), but -which is worth looking at for a moment. Entries are of the form -

      -	{"open",	pyis_open,	1,	pyis_open__doc__},
      -
      -where the entries are python method name, C routine pointer, flags and -docstring pointer. The value to note is the 1 for the flags: this -signifies that you want to use "new-style" Py_ParseTuple behaviour. If -you are writing a new module always use this, but if you are modifying -old code which calls something like getargs(args, "(ii)", -...) you will have to put zero here. See "extending and -embedding" or possibly the getargs.c source file for details if you -need them.

      - -Finally, we add some code to the init module, to put some symbolic -constants (codes that can by returned by the status method) in the -module dictionary, so the python program can use "interslip.RUN" -instead of the cryptic "4" when it wants to check that the interslip -driver is in RUN state. Modulator has already generated code to get at -the module dictionary using PyModule_GetDict() to store the exception -object, so we simply call -

      -	PyDict_SetItemString(d, "IDLE", PyInt_FromLong(IS_IDLE));
      -
      -for each of our items. Since the last bit of code in our init routine -checks for previous errors with PyErr_Occurred() and -since PyDict_SetItemString() gracefully handles the case -of NULL parameters (if PyInt_FromLong() -failed, for instance) we don't have to do error checking here. In some -other cases you may have to do error checking yourself.

      - -This concludes our crash-course on writing Python extensions in C on -the Macintosh. If you are not done reading yet I suggest you look -back at the MacPython Crashcourse index to -find another topic to study.

      diff --git a/Mac/Demo/quicktime/MovieInWindow.py b/Mac/Demo/quicktime/MovieInWindow.py deleted file mode 100644 index 5caa7e868c..0000000000 --- a/Mac/Demo/quicktime/MovieInWindow.py +++ /dev/null @@ -1,66 +0,0 @@ -"""MovieInWindow converted to python - -Jack Jansen, CWI, December 1995 -""" - -import Qt -import QuickTime -import Qd -import QuickDraw -import Evt -import Events -import Win -import Windows -import macfs -import sys - - -def main(): - # skip the toolbox initializations, already done - # XXXX Should use gestalt here to check for quicktime version - Qt.EnterMovies() - - # Get the movie file - fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType) - if not ok: - sys.exit(0) - - # Open the window - bounds = (175, 75, 175+160, 75+120) - theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 1, 0, -1, 0, 0) - Qd.SetPort(theWindow) - # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) - - playMovieInWindow(theWindow, fss, theWindow.GetWindowPort().portRect) - -def playMovieInWindow(theWindow, theFile, movieBox): - """Play a movie in a window""" - # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil); - - # Get the movie - theMovie = loadMovie(theFile) - - # Set where we want it - theMovie.SetMovieBox(movieBox) - - # Start at the beginning - theMovie.GoToBeginningOfMovie() - - # Give a little time to preroll - theMovie.MoviesTask(0) - - # Start playing - theMovie.StartMovie() - - while not theMovie.IsMovieDone() and not Evt.Button(): - theMovie.MoviesTask(0) - -def loadMovie(theFile): - """Load a movie given an fsspec. Return the movie object""" - movieResRef = Qt.OpenMovieFile(theFile, 1) - movie, dummy = Qt.NewMovieFromFile(movieResRef, QuickTime.newMovieActive) - return movie - -if __name__ == '__main__': - main() - diff --git a/Mac/Demo/quicktime/VerySimplePlayer.py b/Mac/Demo/quicktime/VerySimplePlayer.py deleted file mode 100644 index d357342334..0000000000 --- a/Mac/Demo/quicktime/VerySimplePlayer.py +++ /dev/null @@ -1,92 +0,0 @@ -"""VerySimplePlayer converted to python - -Jack Jansen, CWI, December 1995 -""" - -import Qt -import QuickTime -import Qd -import QuickDraw -import Evt -import Events -import Win -import Windows -import macfs -import sys - -# XXXX maxbounds = (40, 40, 1000, 1000) - -def main(): - print 'hello world' # XXXX - # skip the toolbox initializations, already done - # XXXX Should use gestalt here to check for quicktime version - Qt.EnterMovies() - - # Get the movie file - fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType) - if not ok: - sys.exit(0) - - # Open the window - bounds = (175, 75, 175+160, 75+120) - theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0) - # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) - Qd.SetPort(theWindow) - - # Get the movie - theMovie = loadMovie(fss) - - # Relocate to (0, 0) - bounds = theMovie.GetMovieBox() - bounds = 0, 0, bounds[2]-bounds[0], bounds[3]-bounds[1] - theMovie.SetMovieBox(bounds) - - # Create a controller - theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie) - - # Get movie size and update window parameters - rv, bounds = theController.MCGetControllerBoundsRect() - theWindow.SizeWindow(bounds[2], bounds[3], 0) # XXXX or [3] [2]? - Qt.AlignWindow(theWindow, 0) - theWindow.ShowWindow() - - # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds) - theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1') - - # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow) - - done = 0 - while not done: - gotone, evt = Evt.WaitNextEvent(-1, 0) - (what, message, when, where, modifiers) = evt -## print what, message, when, where, modifiers # XXXX - - if theController.MCIsPlayerEvent(evt): - continue - - if what == Events.mouseDown: - part, whichWindow = Win.FindWindow(where) - if part == Windows.inGoAway: - done = whichWindow.TrackGoAway(where) - elif part == Windows.inDrag: - Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000)) - elif what == Events.updateEvt: - whichWindow = Win.WhichWindow(message) - if not whichWindow: - # Probably the console window. Print something, hope it helps. - print 'update' - else: - Qd.SetPort(whichWindow) - whichWindow.BeginUpdate() - Qd.EraseRect(whichWindow.GetWindowPort().portRect) - whichWindow.EndUpdate() - -def loadMovie(theFile): - """Load a movie given an fsspec. Return the movie object""" - movieResRef = Qt.OpenMovieFile(theFile, 1) - movie, dummy = Qt.NewMovieFromFile(movieResRef, QuickTime.newMovieActive) - return movie - -if __name__ == '__main__': - main() - diff --git a/Mac/Demo/resources/copyres.py b/Mac/Demo/resources/copyres.py deleted file mode 100644 index b401142550..0000000000 --- a/Mac/Demo/resources/copyres.py +++ /dev/null @@ -1,57 +0,0 @@ -from Res import * -from Resources import * -import MacOS - -READ = 1 -WRITE = 2 -smAllScripts = -3 - -def copyres(src, dst): - """Copy resource from src file to dst file.""" - - cur = CurResFile() - ctor, type = MacOS.GetCreatorAndType(src) - input = FSpOpenResFile(src, READ) - try: - FSpCreateResFile(dst, ctor, type, smAllScripts) - except: - raw_input("%s already exists... CR to write anyway! " % dst) - output = FSpOpenResFile(dst, WRITE) - UseResFile(input) - ntypes = Count1Types() - for itype in range(1, 1+ntypes): - type = Get1IndType(itype) - nresources = Count1Resources(type) - for ires in range(1, 1+nresources): - res = Get1IndResource(type, ires) - res.LoadResource() - id, type, name = res.GetResInfo() - size = res.SizeResource() - attrs = res.GetResAttrs() - print id, type, name, size, hex(attrs) - res.DetachResource() - UseResFile(output) - try: - res2 = Get1Resource(type, id) - except (RuntimeError, Res.Error), msg: - res2 = None - if res2: - print "Duplicate type+id, not copied" - print (res2.size, res2.data) - print res2.GetResInfo() - if res2.HomeResFile() == output: - 'OK' - elif res2.HomeResFile() == input: - 'BAD!' - else: - print 'Home:', res2.HomeResFile() - else: - res.AddResource(type, id, name) - #res.SetResAttrs(attrs) - res.WriteResource() - UseResFile(input) - UseResFile(cur) - CloseResFile(output) - CloseResFile(input) - -copyres('::python.¹.rsrc', '::foo.rsrc') diff --git a/Mac/Demo/resources/listres.py b/Mac/Demo/resources/listres.py deleted file mode 100644 index a0b24237ee..0000000000 --- a/Mac/Demo/resources/listres.py +++ /dev/null @@ -1,60 +0,0 @@ -# List all resources - -import Res -from Resources import * - -def list1resources(): - ntypes = Res.Count1Types() - for itype in range(1, 1+ntypes): - type = Res.Get1IndType(itype) - print "Type:", `type` - nresources = Res.Count1Resources(type) - for i in range(1, 1 + nresources): - Res.SetResLoad(0) - res = Res.Get1IndResource(type, i) - Res.SetResLoad(1) - info(res) - -def listresources(): - ntypes = Res.CountTypes() - for itype in range(1, 1+ntypes): - type = Res.GetIndType(itype) - print "Type:", `type` - nresources = Res.CountResources(type) - for i in range(1, 1 + nresources): - Res.SetResLoad(0) - res = Res.GetIndResource(type, i) - Res.SetResLoad(1) - info(res) - -def info(res): - print res.GetResInfo(), res.SizeResource(), decodeattrs(res.GetResAttrs()) - -attrnames = { - resChanged: 'Changed', - resPreload: 'Preload', - resProtected: 'Protected', - resLocked: 'Locked', - resPurgeable: 'Purgeable', - resSysHeap: 'SysHeap', -} - -def decodeattrs(attrs): - names = [] - for bit in range(16): - mask = 1<> 8) & 255) + chr(val & 255) - sinewave = sinewave + sample[:SAMPWIDTH] - nowave = '\0' * (n*SAMPWIDTH) - -mkwave(OCTAVE) - -class BufferedAudioDev: - def __init__(self, *args): - import audiodev - self._base = apply(audiodev.AudioDev, args) - self._buffer = [] - self._filled = 0 - self._addmethods(self._base, self._base.__class__) - def _addmethods(self, inst, cls): - for name in cls.__dict__.keys(): - if not hasattr(self, name): - try: - setattr(self, name, getattr(inst, name)) - except: - pass - for basecls in cls.__bases__: - self._addmethods(self, inst, basecls) - def writeframesraw(self, frames): - self._buffer.append(frames) - self._filled = self._filled + len(frames) - if self._filled >= QSIZE: - self.flush() - def wait(self): - self.flush() - self._base.wait() - def flush(self): - print 'flush: %d blocks, %d bytes' % (len(self._buffer), self._filled) - if self._buffer: - import string - self._base.writeframes(string.joinfields(self._buffer, '')) - self._buffer = [] - self._filled = 0 - -def main(args = sys.argv[1:]): - import getopt, string - try: - opts, args = getopt.getopt(args, 'o:p:') - except getopt.error: - sys.stderr.write('Usage ' + sys.argv[0] + - ' [ -o outfile ] [ args ] ...\n') - sys.exit(1) - dev = None - for o, a in opts: - if o == '-o': - import aifc - dev = aifc.open(a, 'w') - dev.setframerate(FRAMERATE) - dev.setsampwidth(SAMPWIDTH) - dev.setnchannels(1) - if o == '-p': - mkwave(string.atoi(a)) - if not dev: - dev = BufferedAudioDev() - dev.setoutrate(FRAMERATE) - dev.setsampwidth(SAMPWIDTH) - dev.setnchannels(1) - dev.close = dev.stop - if args: - line = string.join(args) - else: - line = sys.stdin.readline() - while line: - print line - mline = morse(line) - print mline - play(mline, dev) - if hasattr(dev, 'wait'): - dev.wait() - if not args: - line = sys.stdin.readline() - else: - line = '' - dev.close() - -# Convert a string to morse code with \001 between the characters in -# the string. -def morse(line): - res = '' - for c in line: - try: - res = res + morsetab[c] + '\001' - except KeyError: - pass - return res - -# Play a line of morse code. -def play(line, dev): - for c in line: - if c == '.': - sine(dev, DOT) - elif c == '-': - sine(dev, DAH) - else: - pause(dev, DAH) - pause(dev, DOT) - -def sine(dev, length): - dev.writeframesraw(sinewave*length) - -def pause(dev, length): - dev.writeframesraw(nowave*length) - -if __name__ == '__main__' or sys.argv[0] == __name__: - main() diff --git a/Mac/Demo/sound/morselib.py b/Mac/Demo/sound/morselib.py deleted file mode 100644 index 6f8eed6174..0000000000 --- a/Mac/Demo/sound/morselib.py +++ /dev/null @@ -1,188 +0,0 @@ -"""Translate text strings to Morse code""" - -FRAMERATE = 22050 -SAMPWIDTH = 2 - -BASEFREQ = 441 -OCTAVE = 2 - -DOT = 30 -DAH = 80 - -morsetab = { - 'a': '.-', - 'b': '-...', - 'c': '-.-.', - 'd': '-..', - 'e': '.', - 'f': '..-.', - 'g': '--.', - 'h': '....', - 'i': '..', - 'j': '.---', - 'k': '-.-', - 'l': '.-..', - 'm': '--', - 'n': '-.', - 'o': '---', - 'p': '.--.', - 'q': '--.-', - 'r': '.-.', - 's': '...', - 't': '-', - 'u': '..-', - 'v': '...-', - 'w': '.--', - 'x': '-..-', - 'y': '-.--', - 'z': '--..', - '0': '-----', - '1': '.----', - '2': '..---', - '3': '...--', - '4': '....-', - '5': '.....', - '6': '-....', - '7': '--...', - '8': '---..', - '9': '----.', - ',': '--..--', - '.': '.-.-.-', - '?': '..--..', - ';': '-.-.-.', - ':': '---...', - "'": '.----.', - '-': '-....-', - '/': '-..-.', - '(': '-.--.-', - ')': '-.--.-', # XXX same as code for '(' ??? - '_': '..--.-', - ' ': ' ' -} - -def morsecode(s): - from string import lower - m = '' - for c in s: - c = lower(c) - if morsetab.has_key(c): - c = morsetab[c] + ' ' - else: - c = '? ' - m = m + c - return m - - -class BaseMorse: - "base class for morse transmissions" - - def __init__(self): - "constructor" - self.dots = DOT - self.dahs = DAH - - def noise(self, duration): - "beep for given duration" - pass - - def pause(self, duration): - "pause for given duration" - pass - - def dot(self): - "short beep" - self.noise(self.dots) - - def dah(self): - "long beep" - self.noise(self.dahs) - - def pdot(self): - "pause as long as a dot" - self.pause(self.dots) - - def pdah(self): - "pause as long as a dah" - self.pause(self.dahs) - - def sendmorse(self, s): - for c in s: - if c == '.': self.dot() - elif c == '-': self.dah() - else: self.pdah() - self.pdot() - - def sendascii(self, s): - self.sendmorse(morsecode(s)) - - def send(self, s): - self.sendascii(s) - - -import Audio_mac -class MyAudio(Audio_mac.Play_Audio_mac): - def _callback(self, *args): - if hasattr(self, 'usercallback'): self.usercallback() - apply(Audio_mac.Play_Audio_mac._callback, (self,) + args) - - -class MacMorse(BaseMorse): - "Mac specific class to play Morse code" - - def __init__(self): - BaseMorse.__init__(self) - self.dev = MyAudio() - self.dev.setoutrate(FRAMERATE) - self.dev.setsampwidth(SAMPWIDTH) - self.dev.setnchannels(1) - self.dev.usercallback = self.usercallback - sinewave = '' - n = int(FRAMERATE / BASEFREQ) - octave = OCTAVE - from math import sin, pi - for i in range(n): - val = int(sin(2 * pi * i * octave / n) * 0x7fff) - sample = chr((val >> 8) & 255) + chr(val & 255) - sinewave = sinewave + sample[:SAMPWIDTH] - self.sinewave = sinewave - self.silence = '\0' * (n*SAMPWIDTH) - self.morsequeue = '' - - def __del__(self): - self.close() - - def close(self): - self.dev = None - - def pause(self, duration): - self.dev.writeframes(self.silence * duration) - - def noise(self, duration): - self.dev.writeframes(self.sinewave * duration) - - def sendmorse(self, s): - self.morsequeue = self.morsequeue + s - self.dev.usercallback() - self.dev.usercallback() - self.dev.usercallback() - - def usercallback(self): - if self.morsequeue: - c, self.morsequeue = self.morsequeue[0], self.morsequeue[1:] - if c == '.': self.dot() - elif c == '-': self.dah() - else: self.pdah() - self.pdot() - - -def test(): - m = MacMorse() - while 1: - try: - line = raw_input('Morse line: ') - except (EOFError, KeyboardInterrupt): - break - m.send(line) - while m.morsequeue: pass - -test() diff --git a/Mac/Demo/sound/playaiff.py b/Mac/Demo/sound/playaiff.py deleted file mode 100644 index 1022fc8a74..0000000000 --- a/Mac/Demo/sound/playaiff.py +++ /dev/null @@ -1,45 +0,0 @@ -from Sound import * -import Snd - -import aifc, audioop - -fn = 'f:just samples:2ndbeat.aif' -af = aifc.open(fn, 'r') -print af.getparams() -print 'nframes =', af.getnframes() -print 'nchannels =', af.getnchannels() -print 'framerate =', af.getframerate() -nframes = min(af.getnframes(), 100000) -frames = af.readframes(nframes) -print 'len(frames) =', len(frames) -print repr(frames[:100]) -frames = audioop.add(frames, '\x80'*len(frames), 1) -print repr(frames[:100]) - -import struct - -header1 = struct.pack('llhhllbbl', - 0, - af.getnchannels(), - af.getframerate(),0, - 0, - 0, - 0xFF, - 60, - nframes) -print repr(header1) -header2 = struct.pack('llhlll', 0, 0, 0, 0, 0, 0) -header3 = struct.pack('hhlll', - af.getsampwidth()*8, - 0, - 0, - 0, - 0) -print repr(header3) -header = header1 + header2 + header3 - -buffer = header + frames - -chan = Snd.SndNewChannel(5,0x00C0) - -Snd.SndDoCommand(chan, (bufferCmd, 0, buffer), 0) diff --git a/Mac/Demo/speech/SCRIPT b/Mac/Demo/speech/SCRIPT deleted file mode 100644 index 12e17130f1..0000000000 --- a/Mac/Demo/speech/SCRIPT +++ /dev/null @@ -1,1204 +0,0 @@ - Boy do I have a treat for you guys! -If this works you can send thanks to emeli@magnus.acs.ohio-state.edu for -bringing it to you, though I did not transcribe it. - -"Monty Python and the Holy Grail" --- the strictly unofficial script of the movie, - done in a fit of boredom by =AHH 01Jan87= - -The Cast (in order of appearance [roughly]): - KING ARTHUR : Graham Chapman - PATSY : Terry Gilliam - GUARD #1 : Michael Palin - GUARD #2 : John Cleese - MORTICIAN : Eric Idle - CUSTOMER : John Cleese - DEAD PERSON : ??? - DENNIS : Michael Palin - WOMAN : Terry Jones - BLACK KNIGHT : Michael Palin? - VILLAGER #1 : Eric Idle - VILLAGER #2 : Michael Palin - SIR BEDEMIR : Terry Jones - WITCH : ??? - VILLAGER #3 : John Cleese - NARRATOR: Michael Palin - SIR LANCELOT : John Cleese - SIR GALAHAD : Michael Palin - SIR ROBIN : Eric Idle - GOD : ??? - FRENCH GUARD : John Cleese - MINSTREL : ??? - LEFT HEAD : - MIDDLE HEAD : - RIGHT HEAD : -Graham Chapman -Terry Jones -Michael Palin - OLD MAN : Terry Gilliam - HEAD KNIGHT OF NEE : Michael Palin - FATHER : Michael Palin - PRINCE HERBERT : Graham Chapman? - GUARD #1 : Eric Idle - GUARD #2 : ??? - CONCORDE : Eric Idle - OLD CRONE : ??? - ROGER THE SHRUBBER : Eric Idle - TIM THE ENCHANTER: John Cleese - BROTHER MAYNARD: Eric Idle - SECOND BROTHER: Michael Palin - - Scene 1 - -[wind] -[clop clop] - ARTHUR: Whoa there! -[clop clop] - - GUARD #1: Halt! Who goes there? - ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle -of Camelot. King of the Britons, defeator of the Saxons, sovereign -of all England! - GUARD #1: Pull the other one! - ARTHUR: I am. And this my trusty servant Patsy. -We have ridden the length and breadth of the land in search of knights -who will join me in my court of Camelot. I must speak with your lord -and master. - GUARD #1: What, ridden on a horse? - ARTHUR: Yes! - GUARD #1: You're using coconuts! - ARTHUR: What? - GUARD #1: You've got two empty halves of coconut and your bangin' -'em together. - ARTHUR: So? We have ridden since the snows of winter covered this -land, through the kingdom of Mercea, through-- - GUARD #1: Where'd you get the coconut? - ARTHUR: We found them. - GUARD #1: Found them? In Mercea? The coconut's tropical! - ARTHUR: What do you mean? - GUARD #1: Well, this is a temperate zone. - ARTHUR: The swallow may fly south with the sun or the house martin -or the plumber may seek warmer climes in winter yet these are not -strangers to our land. - GUARD #1: Are you suggesting coconuts migrate? - ARTHUR: Not at all, they could be carried. - GUARD #1: What -- a swallow carrying a coconut? - ARTHUR: It could grip it by the husk! - GUARD #1: It's not a question of where he grips it! It's a simple -question of weight ratios! A five ounce bird could not carry a 1 pound -coconut. - ARTHUR: Well, it doesn't matter. Will you go and tell your master -that Arthur from the Court of Camelot is here. - GUARD #1: Listen, in order to maintain air-speed velocity, a swallow -needs to beat its wings 43 times every second, right? - ARTHUR: Please! - GUARD #1: Am I right? - ARTHUR: I'm not interested! - GUARD #2: It could be carried by an African swallow! - GUARD #1: Oh, yeah, an African swallow maybe, but not a European - swallow, that's my point. - GUARD #2: Oh, yeah, I agree with that... - ARTHUR: Will you ask your master if he wants to join my court -at Camelot?! - GUARD #1: But then of course African swallows are not migratory. - GUARD #2: Oh, yeah... - GUARD #1: So they couldn't bring a coconut back anyway... -[clop clop] - GUARD #2: Wait a minute -- supposing two swallows carried it together? - GUARD #1: No, they'd have to have it on a line. - GUARD #2: Well, simple! They'd just use a standard creeper! - GUARD #1: What, held under the dorsal guiding feathers? - GUARD #2: Well, why not? - -Scene 2 - - MORTICIAN: Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! -[clang] - Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! -[clang] -Bring out your dead! - CUSTOMER: Here's one -- nine pence. - DEAD PERSON: I'm not dead! - MORTICIAN: What? - CUSTOMER: Nothing -- here's your nine pence. - DEAD PERSON: I'm not dead! - MORTICIAN: Here -- he says he's not dead! - CUSTOMER: Yes, he is. - DEAD PERSON: I'm not! - MORTICIAN: He isn't. - CUSTOMER: Well, he will be soon, he's very ill. - DEAD PERSON: I'm getting better! - CUSTOMER: No, you're not -- you'll be stone dead in a moment. - MORTICIAN: Oh, I can't take him like that -- it's against regulations. - DEAD PERSON: I don't want to go in the cart! - CUSTOMER: Oh, don't be such a baby. - MORTICIAN: I can't take him... - DEAD PERSON: I feel fine! - CUSTOMER: Oh, do us a favor... - MORTICIAN: I can't. - CUSTOMER: Well, can you hang around a couple of minutes? He won't -be long. - MORTICIAN: Naaah, I got to go on to Robinson's -- they've lost nine -today. - CUSTOMER: Well, when is your next round? - MORTICIAN: Thursday. - DEAD PERSON: I think I'll go for a walk. - CUSTOMER: You're not fooling anyone y'know. Look, isn't there -something you can do? - DEAD PERSON: I feel happy... I feel happy. -[whop] - CUSTOMER: Ah, thanks very much. - MORTICIAN: Not at all. See you on Thursday. - CUSTOMER: Right. - [clop clop] - MORTICIAN: Who's that then? - CUSTOMER: I don't know. - MORTICIAN: Must be a king. - CUSTOMER: Why? - MORTICIAN: He hasn't got shit all over him. - -Scene 3 - -[clop clop] - ARTHUR: Old woman! - DENNIS: Man! - ARTHUR: Man, sorry. What knight live in that castle over there? - DENNIS: I'm thirty seven. - ARTHUR: What? - DENNIS: I'm thirty seven -- I'm not old! - ARTHUR: Well, I can't just call you 'Man'. - DENNIS: Well, you could say 'Dennis'. - ARTHUR: Well, I didn't know you were called Dennis. - DENNIS: Well, you didn't bother to find out, did you? - ARTHUR: I did say sorry about the old woman, but from the behind -you looked-- - DENNIS: What I object to is you automatically treat me like an inferior! - ARTHUR: Well, I AM king... - DENNIS: Oh king, eh, very nice. An' how'd you get that, eh? By -exploitin' the workers -- by 'angin' on to outdated imperialist dogma -which perpetuates the economic an' social differences in our society! -If there's ever going to be any progress-- - WOMAN: Dennis, there's some lovely filth down here. Oh -- how'd you do? - ARTHUR: How do you do, good lady. I am Arthur, King of the Britons. -Who's castle is that? - WOMAN: King of the who? - ARTHUR: The Britons. - WOMAN: Who are the Britons? - ARTHUR: Well, we all are. we're all Britons and I am your king. - WOMAN: I didn't know we had a king. I thought we were an autonomous -collective. - DENNIS: You're fooling yourself. We're living in a dictatorship. -A self-perpetuating autocracy in which the working classes-- - WOMAN: Oh there you go, bringing class into it again. - DENNIS: That's what it's all about if only people would-- - ARTHUR: Please, please good people. I am in haste. Who lives -in that castle? - WOMAN: No one live there. - ARTHUR: Then who is your lord? - WOMAN: We don't have a lord. - ARTHUR: What? - DENNIS: I told you. We're an anarchosyndicalist commune. We take - it in turns to act as a sort of executive officer for the week. - ARTHUR: Yes. - DENNIS: But all the decision of that officer have to be ratified -at a special biweekly meeting. - ARTHUR: Yes, I see. - DENNIS: By a simple majority in the case of purely internal affairs,-- - ARTHUR: Be quiet! - DENNIS: --but by a two-thirds majority in the case of more-- - ARTHUR: Be quiet! I order you to be quiet! - WOMAN: Order, eh -- who does he think he is? - ARTHUR: I am your king! - WOMAN: Well, I didn't vote for you. - ARTHUR: You don't vote for kings. - WOMAN: Well, 'ow did you become king then? - ARTHUR: The Lady of the Lake, - [angels sing] -her arm clad in the purest shimmering samite, held aloft Excalibur -from the bosom of the water signifying by Divine Providence that I, -Arthur was to carry Excalibur. -[singing stops] -That is why I am your king! - DENNIS: Listen -- strange women lying in ponds distributing swords -is no basis for a system of government. Supreme executive power derives -from a mandate from the masses, not from some farcical aquatic ceremony. - ARTHUR: Be quiet! - DENNIS: Well you can't expect to wield supreme executive power -just 'cause some watery tart threw a sword at you! - ARTHUR: Shut up! - DENNIS: I mean, if I went around sayin' I was an empereror just -because some moistened bint had lobbed a scimitar at me they'd put me away! - ARTHUR: Shut up! Will you shut up! - DENNIS: Ah, now we see the violence inherent in the system. - ARTHUR: Shut up! - DENNIS: Oh! Come and see the violence inherent in the system! -HELP! HELP! I'm being repressed! - ARTHUR: Bloody peasant! - DENNIS: Oh, what a give away. Did you here that, did you here that, -eh? That's what I'm on about -- did you see him repressing me, you saw -it didn't you? - -Scene 4 - -[arg] [ugh] [hah] - - ARTHUR: You fight with the strength of many men, Sir knight. -I am Arthur, King of the Britons. - -I seek the finest and the bravest knights in the land to join me - in my courted camelot. - -You have proved yourself worthy will you join me? - -You make me sad. So be it. Come, Patsy. - BLACK KNIGHT: None shall pass. - ARTHUR: What? - BLACK KNIGHT: None shall pass. - ARTHUR: I have no quarrel with you, good Sir knight, but I must -cross this bridge. - BLACK KNIGHT: Then you shall die. - ARTHUR: I command you as King of the Britons to stand aside! - BLACK KNIGHT: I move for no man. - ARTHUR: So be it! -[hah] -[parry thrust] -[ARTHUR chops the BLACK KNIGHT's left arm off] - ARTHUR: Now stand aside, worthy adversary. - BLACK KNIGHT: 'Tis but a scratch. - ARTHUR: A scratch? Your arm's off! - BLACK KNIGHT: No, it isn't. - ARTHUR: Well, what's that then? - BLACK KNIGHT: I've had worse. - ARTHUR: You liar! - BLACK KNIGHT: Come on you pansy! -[hah] -[parry thrust] -[ARTHUR chops the BLACK KNIGHT's right arm off] - ARTHUR: Victory is mine! -[kneeling] -We thank thee Lord, that in thy merc- -[hah] - BLACK KNIGHT: Come on then. - ARTHUR: What? - BLACK KNIGHT: Have at you! - ARTHUR: You are indeed brave, Sir knight, but the fight is mine. - BLACK KNIGHT: Oh, had enough, eh? - ARTHUR: Look, you stupid bastard, you've got no arms left. - BLACK KNIGHT: Yes I have. - ARTHUR: Look! - BLACK KNIGHT: Just a flesh wound. -[bang] - ARTHUR: Look, stop that. - BLACK KNIGHT: Chicken! Chicken! - ARTHUR: Look, I'll have your leg. Right! -[whop] - BLACK KNIGHT: Right, I'll do you for that! - ARTHUR: You'll what? - BLACK KNIGHT: Come 'ere! - ARTHUR: What are you going to do, bleed on me? - BLACK KNIGHT: I'm invincible! - ARTHUR: You're a loony. - BLACK KNIGHT: The Black Knight always triumphs! -Have at you! Come on then. -[whop] -[ARTHUR chops the BLACK KNIGHT's other leg off] - BLACK KNIGHT: All right; we'll call it a draw. - ARTHUR: Come, Patsy. - BLACK KNIGHT: Oh, oh, I see, running away then. You yellow -bastards! Come back here and take what's coming to you. I'll bite -your legs off! - -Scene 5 - - CROWD: A witch! A witch! A witch! We've got a witch! A witch! - VILLAGER #1: We have found a witch, might we burn her? - CROWD: Burn her! Burn! - BEDEMIR: How do you know she is a witch? - VILLAGER #2: She looks like one. - BEDEMIR: Bring her forward. - WITCH: I'm not a witch. I'm not a witch. - BEDEMIR: But you are dressed as one. - WITCH: They dressed me up like this. - CROWD: No, we didn't -- no. - WITCH: And this isn't my nose, it's a false one. - BEDEMIR: Well? - VILLAGER #1: Well, we did do the nose. - BEDEMIR: The nose? - VILLAGER #1: And the hat -- but she is a witch! - CROWD: Burn her! Witch! Witch! Burn her! - BEDEMIR: Did you dress her up like this? - CROWD: No, no... no ... yes. Yes, yes, a bit, a bit. - VILLAGER #1: She has got a wart. - BEDEMIR: What makes you think she is a witch? - VILLAGER #3: Well, she turned me into a newt. - BEDEMIR: A newt? - VILLAGER #3: I got better. - VILLAGER #2: Burn her anyway! - CROWD: Burn! Burn her! - BEDEMIR: Quiet, quiet. Quiet! There are ways of telling whether -she is a witch. - CROWD: Are there? What are they? - BEDEMIR: Tell me, what do you do with witches? - VILLAGER #2: Burn! - CROWD: Burn, burn them up! - BEDEMIR: And what do you burn apart from witches? - VILLAGER #1: More witches! - VILLAGER #2: Wood! - BEDEMIR: So, why do witches burn? - - VILLAGER #3: B--... 'cause they're made of wood...? - BEDEMIR: Good! - CROWD: Oh yeah, yeah... - BEDEMIR: So, how do we tell whether she is made of wood? - VILLAGER #1: Build a bridge out of her. - BEDEMIR: Aah, but can you not also build bridges out of stone? - VILLAGER #2: Oh, yeah. - BEDEMIR: Does wood sink in water? - VILLAGER #1: No, no. - VILLAGER #2: It floats! It floats! - VILLAGER #1: Throw her into the pond! - CROWD: The pond! - BEDEMIR: What also floats in water? - VILLAGER #1: Bread! - VILLAGER #2: Apples! - VILLAGER #3: Very small rocks! - VILLAGER #1: Cider! - VILLAGER #2: Great gravy! - VILLAGER #1: Cherries! - VILLAGER #2: Mud! - VILLAGER #3: Churches -- churches! - VILLAGER #2: Lead -- lead! - ARTHUR: A duck. - CROWD: Oooh. - BEDEMIR: Exactly! So, logically..., - VILLAGER #1: If... she.. weighs the same as a duck, she's made of wood. - BEDEMIR: And therefore--? - VILLAGER #1: A witch! - CROWD: A witch! - BEDEMIR: We shall use my larger scales! -[yelling] - BEDEMIR: Right, remove the supports! -[whop] -[creak] - CROWD: A witch! A witch! - WITCH: This is a fair cop. - CROWD: Burn her! Burn! [yelling] - BEDEMIR: Who are you who are so wise in the ways of science? - ARTHUR: I am Arthur, King of the Britons. - BEDEMIR: My liege! - ARTHUR: Good Sir knight, will you come with me to Camelot, -and join us at the Round Table? - BEDEMIR: My liege! I would be honored. - ARTHUR: What is your name? - BEDEMIR: Bedemir, my leige. - ARTHUR: Then I dub you Sir Bedemir, Knight of the Round Table. - -[Narrative Interlude] - - NARRATOR: The wise Sir Bedemir was the first to join King Arthur's -knights, but other illustrious names were soon to follow: -Sir Lancelot the Brave; Sir Galahad the Pure; and Sir Robin the -Not-quite-so-brave-as-Sir-Lancelot who had nearly fought the Dragon -of Agnor, who had nearly stood up to the vicious Chicken of Bristol -and who had personally wet himself at the Battle of Baden Hill; and -the aptly named Sir Not-appearing-in-this-film. Together they formed -a band whose names and deeds were to be retold throughout the centuries, -the Knights of the Round Table. - -Scene 6 - - BEDEMIR: And that, my liege, is how we know the Earth to be banana-shaped. - ARTHUR: This new learning amazes me, Sir Bedemir. Explain again how -sheeps' bladders may be employed to prevent earthquakes. - BEDEMIR: Oh, certainly, sir. - LANCELOT: Look, my liege! - ARTHUR: Camelot! - GALAHAD: Camelot! - LANCELOT: Camelot! - PATSY: It's only a model. - ARTHUR: Shhh! Knights, I bid you welcome to your new home. Let us -ride... to... Camelot. - -[singing] -We're knights of the round table -We dance when e'er we're able -We do routines and parlour scenes -With footwork impecc-Able. - -We dine well here in Camelot -We eat ham and jam and spam a lot - -[dancing] - -We're knights of the Round Table -Our shows are for-mid-able -Oh many times we're given rhymes -That are quite unsing-able -We not so fat in Camelot -We sing from the diaphragm a lot - -[tap-dancing] - -Oh we're tough and able -Quite indefatigable -Between our quests we [something] -And impersonate Clark Gable -It's a bit too loud in Camelot -I have to push the pram a lot. - - ARTHUR: Well, on second thought, let's not go to Camelot -- it is -a silly place. - Right. - -Scene 7 - - GOD: Arthur! Arthur, King of the Britons! Oh, don't grovel! If -there's one thing I can't stand, it's people groveling. - ARTHUR: Sorry-- - GOD: And don't apologize. Every time I try to talk to someone it's -"sorry this" and "forgive me that" and "I'm not worthy". What are you -doing now!? - ARTHUR: I'm averting my eyes, oh Lord. - GOD: Well, don't. It's like those miserable Psalms -- they're so -depressing. Now knock it off! - ARTHUR: Yes, Lord. - GOD: Right! Arthur, King of the Britons -- your Knights of the -Round -Table shall have a task to make them an example in these dark times. - ARTHUR: Good idea, oh Lord! - GOD: 'Course it's a good idea! Behold! Arthur, this is the Holy -Grail. Look well, Arthur, for it is your sacred task to seek this Grail. -That is your purpose, Arthur -- the Quest for the Holy Grail. - ARTHUR: A blessing! - LANCELOT: A blessing from the Lord! - GALAHAD: God be praised! - -Scene 8 - -[clop clop] - ARTHUR: Halt! Hallo! Hallo! - GUARD: 'Allo! Who is zis? - ARTHUR: It is King Arthur, and these are the Knights of the Round -Table. Who's castle is this? - GUARD: This is the castle of mumble mumble - ARTHUR: Go and tell your master that we have been charged by God -with a sacred quest. If he will give us food and shelter for the night -he can join us in our quest for the Holy Grail. - GUARD: Well, I'll ask him, but I don't think he'll be very keen... -Uh, he's already got one, you see? - ARTHUR: What? - GALAHAD: He says they've already got one! - ARTHUR: Are you sure he's got one? - GUARD: Oh, yes, it's very nice-uh (I told him we already got one) - ARTHUR: Well, um, can we come up and have a look? - GUARD: Of course not! You are English types-uh! - ARTHUR: Well, what are you then? - GUARD: I'm French! Why do think I have this outrageous accent, you -silly king! - GALAHAD: What are you doing in England? - GUARD: Mind your own business! - ARTHUR: If you will not show us the Grail, we shall take your castle -by force! - GUARD: You don't frighten us, English pig-dogs! Go and boil your -bottoms, sons of a silly person. I blow my nose at you, so-called -Arthur-king, you and all your silly English kaniggets. Thppppt! - GALAHAD: What a strange person. - ARTHUR: Now look here, my good man! - GUARD: I don't want to talk to you no more, you empty headed animal -food trough whopper! I fart in your general direction! You mother was -a hamster and your father smelt of elderberries! - ???: Is there someone else up there we could talk to? - GUARD: No, now go away or I shall taunt you a second time-uh! - ARTHUR: Now, this is your last chance. I've been more than reasonable. - GUARD: (Fetch-a da mush.) - wha? - GUARD: (Fetch-a da mush!) -[moo] - ARTHUR: If you do not agree to my commands, then I shall-- -[twong] -[mooooooo] -Jesus Christ! -Right! Charge! - ALL: Charge! -[mayhem] - GUARD: Ah, this one is for your mother! -[twong] - ALL: Run away! - GUARD: Thpppt! - LANCELOT: Fiends! I'll tear them apart! - ARTHUR: No no, no. - BEDEMIR: Sir! I have a plan, sir. - -[later] - -[chop] -[rumble rumble squeak] -ce labon a bunny do -wha? - un codoo? -a present! -oh, un codoo. -oui oui hurry! -wha-? -let's go! -[rumble rumble squeak] - - ARTHUR: What happens now? - BEDEMIR: Well, now, uh, Lancelet, Galahad, and I wait until nightfall, -and then leap out of the rabbit, taking the French by surprise -- not only -by surprise, but totally unarmed! - ARTHUR: Who leaps out? - BEDEMIR: Uh, Lancelot, Galahad, and I. Uh, leap out of the rabbit, uh -and uh.... - ARTHUR: Oh.... - BEDEMIR: Oh.... Um, l-look, if we built this large wooden badger-- -[twong] - ALL: Run away! Run away! Run away! Run away! -[splat] - FRENCH: Oh, haw haw haw. - -Scene 9 - - Pictures for Schools, take 8. - DIRECTOR: Action! - - NARRATOR: Defeat at the castle seems to have utterly disheartened -King Arthur. The ferocity of the French taunting took him completely -by surprise, and Arthur became convinced that a new strategy was required -if the quest for the Holy Grail were to be brought to a successful -conclusion. Arthur, having consulted his closest knights, decided that -they should separate, and search for the Grail individually. Now, this -is what they did-- -[tromp tromp] -[slash] - WOMAN: Greg! - -Scene 10 - - NARRATOR: The Tale of Sir Robin.... -So each of the knights went their separate ways. Sir Robin rode north, -through the dark forest of Ewing, accompanied by his favorite minstrels. - - MINSTREL (singing): Bravely bold Sir Robin, rode forth from Camelot. - He was not afraid to die, o Brave Sir Robin. - He was not at all afraid to be killed in nasty ways. - Brave, brave, brave, brave Sir Robin! - - He was not in the least bit scared to be mashed - into a pulp, - Or to have his eyes gouged out, and his elbows broken. - To have his kneecaps split, and his body burned away, - And his limbs all hacked and mangled, brave Sir Robin! - - His head smashed in and his heart cut out, - And his liver removed and his bowels unplugged, - And his nostrils ripped and his bottom burned off, - And his penis-- - ROBIN: That's -- that's, uh, that's enough music for now, lads. -Looks like there's dirty work afoot. - DENNIS: Anarchosyndicalism is a way of preserving freedom. - WOMAN: Oh, Dennis, forget about freedom. Now I've dropped my mud. - ALL HEADS: Halt! Who art thou? - MINSTREL (singing): He is brave Sir Robin, brave Sir Robin, who-- - ROBIN: Shut up! Um, n-n-nobody really, I'm j-just um, just passing -through. - ALL HEADS: What do you want? - MINSTREL (singing): To fight, and-- - ROBIN: Shut up! Um, oo, n-nothing, nothing really -- I, uh, j-j-ust -to um, just to p-pass through good Sir knight. - ALL HEADS: I'm afraid not! - ROBIN: Ah. W-well, actually I am a Knight of the Round Table. - ALL HEADS: You're a Knight of the Round Table? - ROBIN: I am. -TJ:In that case I shall have to kill you. -GC:Shall I? -MP:Oh, I don't think so. -GC:Well, what do I think? -TJ:I think kill him. -MP:Well let's be nice to him. -GC:Oh shut up. -TJ:Perhaps- -GC:And you. -TJ:Oh quick get the sword out I want to cut his head off! -MP:Oh, cut your own head off! -GC:Yes, do us all a favor! -TJ:What? -MP:Yapping on all the time. -GC:You're lucky, you're not next to him. -TJ:What do you mean? -GC:You snore. -TJ:Oh I don't -- anyway, you've got bad breath. -GC:Well its only because you don't brush my teeth. -MP:Oh stop bitching and let's go have tea. -TJ:All right all right all right we'll kill him first and then have tea - and biscuits. -GC:Yes. -MP:Oh, but not biscuits. -TJ:All right all right not biscuits, but lets kill him anyway. - ALL HEADS: Right! -TJ:He buggered off. -MP:So he has, he scarpered. - - MINSTREL (singing): Brave Sir Robin ran away - ROBIN: No! - MINSTREL (singing): Bravely ran away away - ROBIN: I didn't! - MINSTREL (singing): When danger reared its ugly head, - He bravely turned his tail and fled - ROBIN: No! - MINSTREL (singing): Yes Brave Sir Robin turned about - ROBIN: I didn't! - MINSTREL (singing): And gallantly he chickened out - Bravely taking to his feet - ROBIN: I never did! - MINSTREL (singing): He beat a very brave retreat - ROBIN: Oh, lie! - MINSTREL (singing): Bravest of the brave Sir Robin - ROBIN: I never! - -Scene 11 - NARRATOR: The Tale of Sir Galahad - -[boom crash] -[angels singing] - -[pound pound pound] - GALAHAD: Open the door! -Open the door! -[pound pound pound] -In the name of King Arthur, open the door! -[squeak thump] -[squeak boom] - ALL: Hello! - ZOOT: Welcome gentle Sir knight, welcome to the Castle Anthrax. - GALAHAD: The Castle Anthrax? - ZOOT: Yes... oh, it's not a very good name is it? Oh! but we are -nice and we shall attend to your every, every need! - GALAHAD: You are the keepers of the Holy Grail? - ZOOT: The what? - GALAHAD: The Grail -- it is here? - ZOOT: Oh, but you are tired, and you must rest awhile. Midget! -Crepper! - MIDGET and CREPPER: Yes, oh Zoot! - ZOOT: Prepare a bed for our guest. - MIDGET and CREPPER: Oh thank you thank you thank you-- - ZOOT: Away away vilatesses[?]! The beds here are warm and soft -- and -very, very big. - GALAHAD: Well, look, I-I-uh-- - ZOOT: What is your name, handsome knight? - GALAHAD: Sir Galahad... the Chaste. - ZOOT: Mine is Zoot... just Zoot. Oh, but come! - GALAHAD: Look, please! In God's name, show me the Grail! - ZOOT: Oh, you have suffered much! You are delirious! - GALAHAD: L-look, I have seen it! It is here, in the-- - ZOOT: Sir Galahad! You would not be so ungallant as to refuse our -hospitality. - GALAHAD: Well, I-I-uh-- - ZOOT: Oh, I am afraid our life must seem very dull and quiet compared -to yours. We are but eight score young blondes and brunettes, all between -sixteen and nineteen and a half, cut off in this castle with no one to -protect us! Oh, it is a lonely life -- bathing, dressing, undressing, -making exciting underwear.... We are just not used to handsome knights. -Nay, nay, come, come, you may lie here. Oh, but you are wounded! - GALAHAD: No, no -- i-it's nothing! - ZOOT: Oh, but you must see the doctors immediately! No, no, please, -lie down. [clap clap] - PIGLET: Ah. What seems to be the trouble? - GALAHAD: They're doctors?! - ZOOT: Uh, they've had a basic medical training, yes. - GALAHAD: B-but-- - ZOOT: Oh, come come, you must try to rest! Doctor Piglet, Doctor -Winston, practice your art. - PIGLET: Try to relax. - GALAHAD: Are you sure that's necessary? - PIGLET: We must examine you. - GALAHAD: There's nothing wrong with that! - PIGLET: Please -- we are doctors. - GALAHAD: Get off the bed! I am sworn to chastity! - PIGLET: Back to your bed! - GALAHAD: Torment me no longer! I have seen the Grail! - PIGLET: There's no grail here. - GALAHAD: I have seen it, I have seen it. I have seen-- - GIRLS: Hello. - GALAHAD: Oh-- - VARIOUS GIRLS: Hello. -Hello. -Hello. -Hello. -Hello. -Hello. - Hello. -Hello. -Hello. -Hello. -Hello. -Hello. - GALAHAD: Zoot! - DINGO: No, I am Zoot's identical twin sister, Dingo. - GALAHAD: Oh, well, excuse me, I-- - DINGO: Where are you going? - GALAHAD: I seek the Grail! I have seen it, here in this castle! - DINGO: No! Oh, no! Bad, bad Zoot! - GALAHAD: What is it? - DINGO: Oh, wicked, bad, naughty Zoot! She has been setting alight -to our beacon, which, I just remembered, is grail-shaped. It's not the -first time we've had this problem. - GALAHAD: It's not the real Grail? - DINGO: Oh, wicked, bad, naughty, evil Zoot! Oh, she is a naughty -person, and she must pay the penalty -- and here in Castle Anthrax, we -have but one punishment for setting alight the grail-shaped beacon. You -must tie her down on a bed and spank her! - GIRLS: A spanking! A spanking! - DINGO: You must spank her well. And after you have spanked her, you -may deal with her as you like. And then, spank me. - VARIOUS GIRLS: And spank me. -And me. -And me. - DINGO: Yes, yes, you must give us all a good spanking! - GIRLS: A spanking! A spanking! - DINGO: And after the spanking, the oral sex. - GIRLS: Oral sex! Oral sex! - GALAHAD: Well, I could stay a BIT longer. - LANCELOT: Sir Galahad! - GALAHAD: Oh, hello. - LANCELOT: Quick! - GALAHAD: What? - LANCELOT: Quick! - GALAHAD: Why? - LANCELOT: You're in great peril! - GALAHAD: - ZOOT: - LANCELOT: Silence, foul temptress! - GALAHAD: Now look, it's not important. - LANCELOT: Quick! Come on and we'll cover your escape! - GALAHAD: Look, I'm fine! - LANCELOT: Come on! - GALAHAD: Now look, I can tackle this lot single-handed! - DINGO: Yes! Let him tackle us single-handed! - GIRLS: Yes! Tackle us single-handed! - LANCELOT: No, Sir Galahad, come on! - GALAHAD: No, really, honestly, I can go back and handle this lot easily! - DINGO: Oh, yes, he can handle us easily. - GIRLS: Yes, yes! - GALAHAD: Wait! I can defeat them! There's only a hundred and fifty -of them! - DINGO: Yes, yes, he'll beat us easily, we haven't a chance. - GIRLS: Yes, yes. -[boom] - DINGO: Oh, shit. -[outside] - LANCELOT: We were in the nick of time, you were in great peril. - GALAHAD: I don't think I was. - LANCELOT: Yes you were, you were in terrible peril. - GALAHAD: Look, let me go back in there and face the peril. - LANCELOT: No, it's too perilous. - GALAHAD: Look, my particular knight sob as much peril as I can. - LANCELOT: No, we've got to find the Holy Grail. Come on! - GALAHAD: Well, let me have just a little bit of peril? - LANCELOT: No, it's unhealthy. - GALAHAD: Bet you're gay! - LANCELOT: No, I'm not. - - Narrative Interlude - - NARRATOR: Sir Lancelot had saved Sir Galahad from almost certain -temptation, but they were still no nearer the Grail. Meanwhile, King -Arthur and Sir Bedemir, not more than a swallow's flight away, had -discovered something. Oh, that's an unladen swallow's flight, obviously. -I mean, they were more than two laden swallow's flights away -- four, -really, if they hadn't a cord of line between them. I mean, if the birds -were walking and dragging-- - CROWD: Get on with it! - NARRATOR: Oh, anyway, on to scene twenty-four, which is a smashing -scene with some lovely acting, in which Arthur discovers a vital clue, -in which there aren't any swallows, although I think you can hear a -starling -oolp! - -Scene 12 - - OLD MAN: Ah, hee he he ha! - ARTHUR: And this enchanter of whom you speak, he has seen the grail? - OLD MAN: Ha ha he he he he! - ARTHUR: Where does he live? Old man, where does he live? - OLD MAN: He knows of a cave, a cave which no man has entered. - ARTHUR: And the Grail... The Grail is there? - OLD MAN: Very much danger, for beyond the cave lies the Gorge - of Eternal Peril, which no man has ever crossed. - ARTHUR: But the Grail! Where is the Grail!? - OLD MAN: Seek you the Bridge of Death. - ARTHUR: The Bridge of Death, which leads to the Grail? - OLD MAN: Hee hee ha ha! - -Scene 13 - - HEAD KNIGHT: Nee! -Nee! -Nee! -Nee! - ARTHUR: Who are you? - HEAD KNIGHT: We are the Knights Who Say... Nee! - ARTHUR: No! Not the Knights Who Say Nee! - HEAD KNIGHT: The same! - BEDEMIR: Who are they? - HEAD KNIGHT: We are the keepers of the sacred words: Nee, Pen, and -Nee-wom! - RANDOM: Nee-wom! - ARTHUR: Those who hear them seldom live to tell the tale! - HEAD KNIGHT: The Knights Who Say Nee demand a sacrifice! - ARTHUR: Knights of Nee, we are but simple travellers who seek the -enchanter who lives beyond these woods. - HEAD KNIGHT: Nee! Nee! Nee! Nee! - ARTHUR and PARTY: Oh, ow! - HEAD KNIGHT: We shall say 'nee' again to you if you do not appease us. - ARTHUR: Well, what is it you want? - HEAD KNIGHT: We want... a shrubbery! -[chord] - ARTHUR: A what? - HEAD KNIGHT: Nee! Nee! - ARTHUR and PARTY: Oh, ow! - ARTHUR: Please, please! No more! We shall find a shrubbery. - HEAD KNIGHT: You must return here with a shrubbery or else you will -never pass through this wood alive! - ARTHUR: O Knights of Nee, you are just and fair, and we will return -with a shrubbery. - HEAD KNIGHT: One that looks nice. - ARTHUR: Of course. - HEAD KNIGHT: And not too expensive. - ARTHUR: Yes. - HEAD KNIGHTS: Now... go! - -Scene 14 - - NARRATOR: The Tale of Sir Lancelot. - - FATHER: One day, lad, all this will be yours! - HERBERT: What, the curtains? - FATHER: No, not the curtains, lad. All that you can see! Stretched -out over the hills and valleys of this land! This'll be your kingdom, lad! - HERBERT: But, Mother! - FATHER: Father, I'm Father. - HERBERT: But Father, I don't want any of that. - FATHER: Listen, lad. I've built this kingdom up from nothing. When -I started here, all there was was swamp. All the kings said I was daft -to build a castle in a swamp, but I built it all the same, just to show -'em. It sank into the swamp. So, I built a second one. That sank into the -swamp. So I built a third one. That burned down, fell over, then sank -into the swamp. But the fourth one stayed up. An' that's what your gonna -get, lad -- the strongest castle in these islands. - HERBERT: But I don't want any of that -- I'd rather-- - FATHER: Rather what?! - HERBERT: I'd rather... just... -[music] -...sing! - FATHER: Stop that, stop that! You're not going to do a song while -I'm here. Now listen lad, in twenty minutes you're getting married to -a girl whose father owns the biggest tracts of open land in Britain. - HERBERT: But I don't want land. - FATHER: Listen, Alex,-- - HERBERT: Herbert. - FATHER: Herbert. We live in a bloody swamp. We need all the land we -can get. - HERBERT: But I don't like her. - FATHER: Don't like her?! What's wrong with her? She's beautiful, -she's rich, she's got huge... tracts of land. - HERBERT: I know, but I want the girl that I marry to have... -a certain... special... -[music] -...something... - FATHER: Cut that out, cut that out. Look, you're marryin' Princess -Looky, so you'd better get used to the idea. [smack] Guards! Make sure -the Prince doesn't leave this room until I come and get 'im. - GUARD #1: Not to leave the room even if you come and get him. - GUARD #2: Hic! - FATHER: No, no. Until I come and get 'im. - GUARD #1: Until you come and get him, we're not to enter the room. - FATHER: No, no, no. You stay in the room and make sure 'e doesn't -leave. - GUARD #1: And you'll come and get him. - GUARD #2: Hic! - FATHER: Right. - GUARD #1: We don't need to do anything, apart from just stop him -entering the room. - FATHER: No, no. Leaving the room. - GUARD #1: Leaving the room, yes. - FATHER: All right? - GUARD #1: Right. Oh, if-if-if, uh, if-if-if, uh, if-if-if we... - FATHER: Yes, what is it? - GUARD #1: Oh, if-if, oh-- - FATHER: Look, it's quite simple. - GUARD #1: Uh... - FATHER: You just stay here, and make sure 'e doesn't leave the room. -All right? - GUARD #2: Hic! - FATHER: Right. - GUARD #1: Oh, I remember. Uh, can he leave the room with us? - FATHER: N- No no no. You just keep him in here, and make sure-- - GUARD #1: Oh, yes, we'll keep him in here, obviously. But if he had -to leave and we were-- - FATHER: No, no, just keep him in here-- - GUARD #1: Until you, or anyone else,-- - FATHER: No, not anyone else, just me-- - GUARD #1: Just you. - GUARD #2: Hic! - FATHER: Get back. - GUARD #1: Get back. - FATHER: Right? - GUARD #1: Right, we'll stay here until you get back. - FATHER: And, uh, make sure he doesn't leave. - GUARD #1: What? - FATHER: Make sure 'e doesn't leave. - GUARD #1: The Prince? - FATHER: Yes, make sure 'e doesn't leave. - GUARD #1: Oh, yes, of course. I thought you meant him. Y'know, it -seemed a bit daft, me havin' to guard him when he's a guard. - FATHER: Is that clear? - GUARD #2: Hic! - GUARD #1: Oh, quite clear, no problems. - FATHER: Right. -[starts to leave] -Where are you going? - GUARD #1: We're coming with you. - FATHER: No no, I want you to stay 'ere and make sure 'e doesn't leave. - GUARD #1: Oh, I see. Right. - HERBERT: But, Father! - FATHER: Shut your noise, you! And get that suit on! And no singing! - GUARD #2: Hic! - FATHER: Oh, go get a glass of water. - -Scene 15 - - LANCELOT: Well taken, Concorde! - CONCORDE: Thank you, sir! Most kind. - LANCELOT: And again... Over we go! Good. Steady! And now, the big -one...Ooof! Come on, Concorde! -[thwonk] - CONCORDE: Message for you, sir. -[fwump] - LANCELOT: Concorde! Concorde, speak to me! "To whoever finds this -note, I have been imprisoned by my father, who wishes me to marry against -my will. Please, please, please come and rescue me. I am in the tall -tower of Swamp Castle." At last! A call, a cry of distress! This could -be the sign that leads us to the Holy Grail! Brave, brave Concorde! You -shall not have died in vain! - CONCORDE: Uh, I'm-I'm not quite dead, sir. - LANCELOT: Well, you shall not have been mortally wounded in vain! - CONCORDE: Uh, I-I think uh, I could pull through, sir. - LANCELOT: Oh, I see. - CONCORDE: Actually, I think I'm all right to come with you-- - LANCELOT: No, no, sweet Concorde! Stay here! I will send help as -soon as I have accomplished a daring and heroic rescue in my own -particular... (sigh) - CONCORDE: Idiom, sir? - LANCELOT: Idiom! - CONCORDE: No, I feel fine, actually, sir. - LANCELOT: Farewell, sweet Concorde! - CONCORDE: I'll-uh, I'll just stay here, then, shall I, sir? Yeah. - -Scene 16 - - LANCELOT: Ha-ha! etc. - GUARD #1: Now, you're not allowed to come in here, and we're-ugh! - LANCELOT: O fair one, behold your humble servant Sir Lancelot -of Camelot. I have come to take -- oh, I'm terribly sorry. - HERBERT: You got my note! - LANCELOT: Uh, well, I got A note. - HERBERT: You've come to rescue me! - LANCELOT: Uh, well, no, you see-- - HERBERT: I knew that someone would, I knew that somewhere out there... -there must be... -[music] -...someone... - FATHER: Stop that, stop that, stop it! Stop it! Who are you? - HERBERT: I'm your son! - FATHER: No, not you. - LANCELOT: I'm Sir Lancelot, sir. - HERBERT: He's come to rescue me, father. - LANCELOT: Well, let's not jump to conclusions. - FATHER: Did you kill all the guard? - LANCELOT: Uh..., oh, yes. Sorry. - FATHER: They cost fifty pounds each. - LANCELOT: Well, I'm awfully sorry, I'm -- I really can explain everything. - HERBERT: Don't be afraid of him, Sir Lancelot, I've got a rope all ready! - FATHER: You killed eight wedding guests in all! - LANCELOT: Well, you see, the thing is, I thought your son was a lady. - FATHER: I can understand that. - HERBERT: Hurry, Sir Lancelot! Hurry! - FATHER: Shut up! You only killed the bride's father, that's all! - LANCELOT: Well, I really didn't mean to... - FATHER: Didn't mean to?! You put your sword right through his head! - LANCELOT: Oh, dear. Is he all right? - FATHER: You even kicked the bride in the chest! This is going to cost -me a fortune! - LANCELOT: Well, I can explain. I was in the forest, um, riding north -from Camelot, when I got this note, you see-- - FATHER: Camelot? Are you from, uh, Camelot? - HERBERT: Hurry, Sir Lancelot! - LANCELOT: Uh, I am a Knight of King Arthur, sir. - FATHER: Pretty nice castle, Camelot. Uh, pretty good pig country.... - LANCELOT: Yes. - HERBERT: Hurry, I'm ready! - FATHER: Would you, uh, like to come and have a drink? - LANCELOT: Well, that's, uh, awfully nice of you. - HERBERT: I am ready! -[start to leave] - LANCELOT: --I mean to be, so understanding. -[thonk] - HERBERT: Oooh! - LANCELOT: Um, I think when I'm in this idiom, I sometimes get a bit, -uh, sort of carried away. - FATHER: Oh, don't worry about that. - HERBERT: Oooh! -[splat] - -Scene 17 -[wailing] - FATHER: Well, this is the main hall. We're going to have all this -knocked through, and made into one big, uh, living room. - RANDOM: There he is! - FATHER: Oh, bloody hell. - LANCELOT: Ha-ha! etc. - FATHER: Hold it, hold it! Please! - LANCELOT: Sorry, sorry. See what I mean, I just get carried away. -I really must -- sorry, sorry! Sorry, everyone. - RANDOM: He's killed the best man! -[yelling] - FATHER: Hold it, please! Hold it! This is Sir Lancelot from the - gorge of Camelot -- a very brave and influential knight, and my special -guest here today. - LANCELOT: Hello. - RANDOM: He killed my auntie! -[yelling] - FATHER: Please, please! This is supposed to be a happy occasion! -Let's not bicker and argue about who killed who. We are here today to -witness the union of two young people in the joyful bond of the holy -wedlock. Unfortunately, one of them, my son Herbert, has just fallen -to his death. But I think I've not lost a son, so much as... gained -a daughter! For, since the tragic death of her father-- - RANDOM: He's not quite dead! - FATHER: Since the near fatal wounding of her father-- - RANDOM: He's getting better! - FATHER: For, since her own father... who, when he seemed about to -recover, suddenly felt the icy hand fo death upon him,-- -[ugh] - RANDOM: Oh, he's died! - FATHER: And I want his only daughter to look upon me... as her own -dad -- in a very real, and legally binding sense. -[clapping] -And I feel sure that the merger -- uh, the union -- between the Princess -and the brave, but dangerous, Sir Lancelot of Camelot-- - LANCELOT: What? - RANDOM: Look! The dead Prince! - CONCORDE: He's not quite dead! - HERBERT: Oh, I feel much better. - FATHER: You fell out of the cold tower, you creep! - HERBERT: No, I was saved at the last minute. - FATHER: How?! - HERBERT: Well, I'll tell you... -[music] - FATHER: Not like that! Not like that! No, stop it! - SINGING: He's going to tell! He's going to tell! - FATHER: Shut up! - SINGING: He's going to tell! He's going to tell! - He's going to tell! He's going to tell! - He's going to tell! He's going to tell! - He's going to tell! He's going to tell! - CONCORDE: Quickly, sir! This way! - LANCELOT: No, it's not in my idiom! I must escape more....(sigh) - CONCORDE: Dramatically, sir? - LANCELOT: Dramatically! Hee! Ha! -[crash] -Excuse me, could, uh, could somebody give me a push, please...? - -Scene 18 - - [clop clop] - ARTHUR: Old crone! Is there anywhere in this town where we could buy -a shrubbery! -[chord] - CRONE: Who sent you? - ARTHUR: The Knights Who Say Nee. - CRONE: Agh! No! Never! We have no shrubberies here. - ARTHUR: If you do not tell us where we can buy a shrubbery, my friend -and I will say... we will say... 'nee'. - CRONE: Agh! Do your worst! - ARTHUR: Very well! If you will not assist us voluntarily,... nee! - CRONE: No! Never! No shrubberies! - ARTHUR: Nee! - BEDEMIR: Noo! Noo! - ARTHUR: No, no, no, no -- it's not that, it's 'nee'. - BEDEMIR: Noo! - ARTHUR: No, no -- 'nee'. You're not doing it properly. - BEDEMIR: Noo! Nee! - ARTHUR: That's it, that's it, you've got it. - ARTHUR and BEDEMIR: Nee! Nee! - ROGER: Are you saying 'nee' to that old woman? - ARTHUR: Um, yes. - ROGER: Oh, what sad times are these when passing ruffians can 'nee' -at will to old ladies. There is a pestilence upon this land, nothing is - sacred. Even those who arrange and design shrubberies are under -considerable economic stress at this period in history. - ARTHUR: Did you say 'shrubberies'? - ROGER: Yes, shrubberies are my trade -- I am a shrubber. My name -is Roger the Shrubber. I arrange, design, and sell shrubberies. - BEDEMIR: Nee! - ARTHUR: No! No, no, no! No! - -Scene 19 - - ARTHUR: O, Knights of Nee, we have brought you your shrubbery. May we -go now? - HEAD KNIGHT: It is a good shrubbery. I like the laurels particularly. -But there is one small problem. - ARTHUR: What is that? - HEAD KNIGHT: We are now... no longer the Knights Who Say Nee. - RANDOM: Nee! - HEAD KNIGHT: Shh shh. We are now the Knights Who Say Ecky-ecky-ecky- -ecky-pikang-zoom-boing-mumble-mumble. - RANDOM: Nee! - HEAD KNIGHT: Therefore, we must give you a test. - ARTHUR: What is this test, O Knights of-- Knights Who 'Til Recently -Said Nee? - HEAD KNIGHT: Firstly, you must find... another shrubbery! - [chord] - ARTHUR: Not another shrubbery! - HEAD KNIGHT: Then, when you have found the shrubbery, you must place -it here beside this shrubbery, only slightly higher so you get a -two-level effect with a little path running down the middle. - RANDOM: A path! A path! Nee! - HEAD KNIGHT: Then, when you have found the shrubbery, you must cut -down the mightiest tree in the forest... with... a herring! -[chord] - ARTHUR: We shall do no such thing! - HEAD KNIGHT: Oh, please! - ARTHUR: Cut down a tree with a herring? It can't be done. - KNIGHTS: Aaaaugh! Aaaugh! - HEAD KNIGHT: Don't say that word. - ARTHUR: What word? - HEAD KNIGHT: I cannot tell, suffice to say is one of the words -the Knights of Nee cannot hear. - ARTHUR: How can we not say the word if you don't tell us what it is? - KNIGHTS: Aaaaugh! Aaaugh! - ARTHUR: What, 'is'? - HEAD KNIGHT: No, not "is" -- we couldn't get vary far in life not - -Ooops I'm out of time. i'll send the rest tomorrow. - -Eric diff --git a/Mac/Demo/speech/grail.py b/Mac/Demo/speech/grail.py deleted file mode 100644 index d926569844..0000000000 --- a/Mac/Demo/speech/grail.py +++ /dev/null @@ -1,228 +0,0 @@ -# Pass this program the Holy Grail script on stdin. -import sys -import string -import stdwin -from stdwinevents import * - -try: - import macspeech -except ImportError: - macspeech = None - -WINWIDTH = 1000 -scrw, scrh = stdwin.getscrsize() -if WINWIDTH > 0.8*scrw: - WINWIDTH = int(0.8*scrw) -BLACK = stdwin.fetchcolor('black') -RED = stdwin.fetchcolor('red') -BLUE = stdwin.fetchcolor('blue') - -done='done' - -class MacSpeaker: - def __init__(self): - self.voices = [] - self.nvoices = macspeech.CountVoices() - self.curvoice = 1 - self.rate = 1.0 - - def _newvoice(self): - vd = macspeech.GetIndVoice(self.curvoice) - sc = vd.NewChannel() - self.curvoice = self.curvoice + 1 - if self.curvoice > self.nvoices: - self.curvoice = 1 - return sc - - def newvoices(self, n): - self.voices = [] - for i in range(n): - self.voices.append(self._newvoice()) - if self.rate <> 1.0: - self.setrate(1.0) - - def setrate(self, factor): - self.rate = self.rate*factor - for v in self.voices: - r = v.GetRate() - v.SetRate(r*factor) - - def speak(self, i, text): - self.voices[i-1].SpeakText(text) - - def busy(self): - return macspeech.Busy() - -[NOTHING, NEWSCENE, ACT, TEXT, MORETEXT] = range(5) -def parseline(line): - stripline = string.strip(line) - if not stripline: - return NOTHING, '' - if stripline[:5] == 'Scene': - return NEWSCENE, stripline - if line[0] == '[': - return ACT, stripline - if line[0] == ' ' and ':' in line: - splitline = string.splitfields(stripline, ':') - stripline = string.joinfields(splitline[1:], ':') - return TEXT, (splitline[0], string.strip(stripline)) - return MORETEXT, stripline - -def readscript(file): - lines = file.readlines() - acts = [] - actor_dict = {} - longest = 0 - prev_act = 0 - for i in range(len(lines)): - tp, data = parseline(lines[i]) - if tp == NEWSCENE: - acts.append(actor_dict.keys(), lines[prev_act:i]) - prev_act = i - actor_dict = {} - elif tp == TEXT: - actor_dict[data[0]] = 1 - lines[i] = tp, data - return acts[1:] - -class Main: - def __init__(self): - if macspeech: - self.speaker = MacSpeaker() - else: - self.speaker = None - sys.stdin = open('SCRIPT', 'r') - self.acts = readscript(sys.stdin) - maxactor = 0 - for actorlist, actdata in self.acts: - if len(actorlist) > maxactor: - maxactor = len(actorlist) - if not self.loadnextact(): - print 'No acts to play!' - raise done - self.lh = stdwin.lineheight() - self.winheight = (maxactor+2)*self.lh - stdwin.setdefwinsize(WINWIDTH, self.winheight) - self.win = stdwin.open('The Play') - self.win.setdocsize(WINWIDTH, self.winheight) - self.win.change(((0,0),(WINWIDTH, self.winheight))) - self.menu = self.win.menucreate('Play') - self.menu.additem('Faster', '+') - self.menu.additem('Slower', '-') - self.menu.additem('Quit', 'Q') - self.speed = 4 - - def done(self): - del self.win - del self.menu - - def loadnextact(self): - if not self.acts: return 0 - actors, lines = self.acts[0] - del self.acts[0] - prevactor = 0 - for i in range(len(lines)): - tp, data = lines[i] - if tp == NOTHING: - continue - elif tp in (NEWSCENE, ACT): - lines[i] = 0, data - elif tp == TEXT: - prevactor = actors.index(data[0]) - lines[i] = prevactor+1, data[1] - else: - lines[i] = prevactor+1, data - self.lines = lines - self.actors = [''] + actors - self.actorlines = [''] * len(self.actors) - if self.speaker: - self.speaker.newvoices(len(self.actors)-1) - self.prevline = 0 - self.actwidth = 0 - for a in self.actors: - w = stdwin.textwidth(a) - if w > self.actwidth: - self.actwidth = w - return 1 - - def loadnextline(self): - if not self.lines: return 0 - self.actorlines[self.prevline] = '' - top = self.lh*self.prevline - self.win.change(((0, top), (WINWIDTH, top+self.lh))) - line, data = self.lines[0] - del self.lines[0] - self.actorlines[line] = data - self.prevline = line - top = self.lh*self.prevline - self.win.change(((0, top), (WINWIDTH, top+self.lh))) - if line == 0: - self.win.settimer(5*self.speed) - else: - if self.speaker: - self.speaker.speak(line, data) - tv = 1 - else: - nwords = len(string.split(data)) - tv = self.speed*(nwords+1) - self.win.settimer(tv) - return 1 - - def timerevent(self): - if self.speaker and self.speaker.busy(): - self.win.settimer(1) - return - while 1: - if self.loadnextline(): return - if not self.loadnextact(): - stdwin.message('The END') - self.win.close() - raise done - self.win.change(((0,0), (WINWIDTH, self.winheight))) - - def redraw(self, top, bottom, draw): - for i in range(len(self.actors)): - tpos = i*self.lh - bpos = (i+1)*self.lh-1 - if tpos < bottom and bpos > top: - draw.setfgcolor(BLUE) - draw.text((0, tpos), self.actors[i]) - if i == 0: - draw.setfgcolor(RED) - else: - draw.setfgcolor(BLACK) - draw.text((self.actwidth+5, tpos), self.actorlines[i]) - - def run(self): - self.win.settimer(10) - while 1: - ev, win, arg = stdwin.getevent() - if ev == WE_DRAW: - ((left, top), (right, bot)) = arg - self.redraw(top, bot, self.win.begindrawing()) - elif ev == WE_TIMER: - self.timerevent() - elif ev == WE_CLOSE: - self.win.close() - raise done - elif ev == WE_MENU and arg[0] == self.menu: - if arg[1] == 0: - if self.speed > 1: - self.speed = self.speed/2 - if self.speaker: - self.speaker.setrate(1.4) - elif arg[1] == 1: - self.speed = self.speed * 2 - if self.speaker: - self.speaker.setrate(0.7) - elif arg[1] == 2: - self.win.close() - raise done - -if 1: - main = Main() - try: - main.run() - except done: - pass - del main diff --git a/Mac/Demo/speech/hum.py b/Mac/Demo/speech/hum.py deleted file mode 100644 index ac054719d1..0000000000 --- a/Mac/Demo/speech/hum.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# Hum - The singing macintosh -# -import macspeech -import sys -import string - -dict = { 'A':57, 'A#':58, 'B':59, 'C':60, 'C#':61, 'D':62, 'D#':63, - 'E':64, 'F':65, 'F#':66, 'G':67, 'G#':68} - -vd = macspeech.GetIndVoice(2) -vc = vd.NewChannel() -print 'Input strings of notes, as in A B C C# D' -while 1: - print 'S(tr)ing-', - str = sys.stdin.readline() - if not str: - break - str = string.split(str[:-1]) - data = [] - for s in str: - if not dict.has_key(s): - print 'No such note:', s - else: - data.append(dict[s]) - print data - for d in data: - vc.SetPitch(float(d)) - vc.SpeakText('la') - while macspeech.Busy(): - pass diff --git a/Mac/Demo/textedit.html b/Mac/Demo/textedit.html deleted file mode 100644 index d56ea0b5dc..0000000000 --- a/Mac/Demo/textedit.html +++ /dev/null @@ -1,152 +0,0 @@ -Using FrameWork and TextEdit - -

      Using FrameWork and TextEdit

      -
      - -In this document we use the FrameWork and TextEdit -modules to create a simple text editor. The functionality -of the editor is very basic: you can open multiple files, type text and use -cut/copy/paste. The main intention is to explain the use of FrameWork, really.

      - -

      FrameWork

      - -The FrameWork module provides you with a skeleton application. It declares a -number of classes suitable for subclassing in your application, thereby -releaving you of the burden of doing all event handling, etc. yourself. For a -real understanding you will have to browse the source. Here is a short overview -of the classes and what functionality they provide. - -
      -
      Application -
      -This is the toplevel class you will override. It maintains the menu bar and contains -the main event handling code. Normal use is to override the __init__ routine -to do your own initializations and override makeusermenus to create your menus -(your menu callback routines may be here too, but this is by no means necessary). -The event handling code can be overridden at various levels, from very low-level (the -dispatch method) to intermedeate level (do_keyDown, for instance) -to high-level (do_key). The application class knows about the Window -objects you create, and will forward events to the appropriate window (So, normally you -would have a do_key method in your window object, not your application object). - -
      MenuBar, Menu and MenuItem -
      -These classes (and a few friends like SubMenu) handle your menus. You would not -normally override them but use them as-is. The idiom for creating menus is a bit strange, -see the test code at the bottom of FrameWork for sample use. The apple menu is handled for you -by MenuBar and Application. - -
      Window -
      -The basic window. Again, a class that you normally subclass in your application, possibly -multiple times if you have different types of windows. The init call instantiates the data -structure but actually opening the window is delayed until you call open. Your -open method should call do_postopen to let the base class handle linking in to -the application object. Similarly with close and do_postclose. The -rest of the code is mainly event-oriented: you override do_postresize, -do_contentclick, do_update, do_activate -and do_key to "do your thing". When these methods are called the relevant environment -has been setup (like BeginDrawing has been called for updates, etc). - -
      windowbounds -
      -Not a class but a function: you pass it a width and height and it will return you a rectangle -you can use to create your window. It will take care of staggering windows and it will try -to fit the window on the screen (but the resulting rect will always have the size you -specify). - -
      ControlsWindow -
      -A subclass of Window which automatically handles drawing and clicking for controls. You override -the same methods as for Window (if you need to: control-related things are done automatically) and -do_controlhit. - -
      ScrolledWindow -
      -A subclass of ControlsWindow, a window with optional scrollbars. If you override do_activate -or do_postresize you must call the ScrolledWindow methods at the end of your override. -You call scrollbars to enable/disable scrollbars and updatescrollbars to -update them. You provide getscrollbarvalues to return the current x/y values (a helper -method scalebarvalues is available) and scrollbarcallback to update your -display after the user has used the scrollbars. - -
      DialogWindow -
      -A modeless dialog window initialized from a DLOG resource. See the -second Interslip example for its useage. -
      - -

      A sample text editor

      - -Let us have a look at ped.py (in the Demo:textedit folder), the Pathetic -EDitor. It has multiple windows, cut/copy/paste and keyboard input, but that is about all. It looks -as if you can resize the window but it does not work. Still, it serves as an example. We will improve -on ped later, in a waste-based example.

      - -Ped creates two classes, TEWindow and Ped. Let us start with the latter one, -which is a subclass of FrameWork.Application and our main application. The init function -has little to do aside from the standard init: it remembers a window sequence number (for untitled windows), -and sets things up for menu disable to work. Remember, the makeusermenus is called -automatically.

      - -Makeusermenus creates the File and Edit menus. It also initializes -a couple of lists that are used later to correctly enable and disable menu items (and complete menus) depending -on whether a window is open, text is selected, etc. The callback functions for the menu items are -all methods of this class.

      - -Updatemenubar handles greying out (and re-enabling) of menu items depending on whether there -is a current window and its state.

      - -The rest of the methods are all callbacks and simple to understand. They check whether there is an active -window (and complain loudly if there is none: the corresponding menu entry should have been disabled -in that case!) and call the appropriate window method. Only the _open method (the common code -for Open and New) deserves some mention. It instantiates a TEWindow -object and opens it with the title, filename and contents of the file to edit. Note that FrameWork takes -care of remembering the window object. A minor note on opening the file in binary mode: this is because -TextEdit expects MacOS style carriage-return terminated lines, not python/unix/C style newline-terminated -lines.

      - -Oh yes: the quit callback does a little magic too. It closes all windows, and only if this -succeeds it actually quits. This gives the user a chance to cancel the operation if some files are unsaved. -Quitting itself is also a bit strange: you raise self to break out of the main loop. This bit -of idiom was invented by Guido, so blame him:-).

      - -Lastly, there is the idle method, called by the Application base class when no event -is available. It is forwarded to the active window, so it can blink the text caret.

      - -The TEWindow object handles a single window. Due to this structuring it is absolutely no -problem to have multiple windows open at the same time (although a real application should exercise care when -two windows refer to the same document). TEWindow uses the standard init code inherited from -ScrolledWindow, and sets itself up at the time of the open call. It obtains screen -coordinates, opens the window, creates rectangles for TextEdit to work in (the magical number 15 -here is the size of a normal scroll bar: unfortunately there is no symbolic constant for it), -creates the TextEdit object and initializes it with our data. Finally, the scroll bars are created (the -initial values will be obtained automatically through getscrollbarvalues) and we activate -ourselves (this is unfortunately not done automatically by the MacOS event handling code).

      - -Do_idle simply calls the TextEdit routine that blinks the cursor. Getscrollbarvalues -returns the current X and Y scrollbar values, scaled to 0..32767. For X we return None, -which means "no scrollbar, please", for Y we use the scaler provided by ScrolledWindow.

      - -Scrollbar_callback is called when the user uses the scrollbar. It is passed a string 'x' -or 'y', one of 'set', '-', '--', '+', '++' and (for set) an absolute -value. Note that the sign of the value passed to TEPinScroll is counter-intuitive.

      - -do_activate (de)activates the scrollbars and calls the relevant TextEdit routine. Moreover, it -tells the application object if we are now the active window, and updates the menubar. The next few methods -are update and menu callbacks, and pretty straightforward. Note that do_close can -return without closing the window (if the document is changed and the users cancels out of the operation). -Also note the "magic" in menu_save_as -that set the correct window title.

      - -Things get moderately interesting again at the cut/copy/paste handling, since the TextEdit scrap is -separate from the desktop scrap. For that reason there are various calls to routines that move the scrap -back and forth. Have_selection is called by the menubar update code to determine whether cut and -copy should be enabled.

      - -Understanding the main program is left as an exercise to the reader.

      - -


      -That's all for this example, you could now continue with the next example, where we use WASTE, a more-or-less -TextEdit compatible library with more functionality, to rebuild our editor. Or you can -return to the table of contents to pick another topic.

      diff --git a/Mac/Demo/textedit/ped.py b/Mac/Demo/textedit/ped.py deleted file mode 100644 index 3999dae93b..0000000000 --- a/Mac/Demo/textedit/ped.py +++ /dev/null @@ -1,345 +0,0 @@ -# A minimal text editor. -# -# To be done: -# - Update viewrect after resize -# - Handle horizontal scrollbar correctly -# - Functionality: find, etc. - -from Menu import DrawMenuBar -from FrameWork import * -import Win -import Qd -import TE -import Scrap -import os -import macfs - -class TEWindow(ScrolledWindow): - def open(self, path, name, data): - self.path = path - self.name = name - r = windowbounds(400, 400) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - self.wid = w - x0, y0, x1, y1 = self.wid.GetWindowPort().portRect - x0 = x0 + 4 - y0 = y0 + 4 - x1 = x1 - 20 - y1 = y1 - 20 - vr = dr = x0, y0, x1, y1 - ##vr = 4, 0, r[2]-r[0]-15, r[3]-r[1]-15 - ##dr = (0, 0, vr[2], 0) - Qd.SetPort(w) - Qd.TextFont(4) - Qd.TextSize(9) - self.ted = TE.TENew(dr, vr) - self.ted.TEAutoView(1) - self.ted.TESetText(data) - w.DrawGrowIcon() - self.scrollbars() - self.changed = 0 - self.do_postopen() - self.do_activate(1, None) - - def do_idle(self): - self.ted.TEIdle() - - def getscrollbarvalues(self): - dr = self.ted.destRect - vr = self.ted.viewRect - height = self.ted.nLines * self.ted.lineHeight - vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) - vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) - print dr, vr, height, vx, vy - return None, vy - - def scrollbar_callback(self, which, what, value): - if which == 'y': - if what == 'set': - height = self.ted.nLines * self.ted.lineHeight - cur = self.getscrollbarvalues()[1] - delta = (cur-value)*height/32767 - if what == '-': - delta = self.ted.lineHeight - elif what == '--': - delta = (self.ted.viewRect[3]-self.ted.lineHeight) - if delta <= 0: - delta = self.ted.lineHeight - elif what == '+': - delta = -self.ted.lineHeight - elif what == '++': - delta = -(self.ted.viewRect[3]-self.ted.lineHeight) - if delta >= 0: - delta = -self.ted.lineHeight - self.ted.TEPinScroll(0, delta) - print 'SCROLL Y', delta - else: - pass # No horizontal scrolling - - def do_activate(self, onoff, evt): - print "ACTIVATE", onoff - ScrolledWindow.do_activate(self, onoff, evt) - if onoff: - self.ted.TEActivate() - self.parent.active = self - self.parent.updatemenubar() - else: - self.ted.TEDeactivate() - - def do_update(self, wid, event): - Qd.EraseRect(wid.GetWindowPort().portRect) - self.ted.TEUpdate(wid.GetWindowPort().portRect) - self.updatescrollbars() - - def do_contentclick(self, local, modifiers, evt): - shifted = (modifiers & 0x200) - self.ted.TEClick(local, shifted) - self.updatescrollbars() - self.parent.updatemenubar() - - def do_char(self, ch, event): - self.ted.TESelView() - self.ted.TEKey(ord(ch)) - self.changed = 1 - self.updatescrollbars() - self.parent.updatemenubar() - - def close(self): - if self.changed: - save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) - if save > 0: - self.menu_save() - elif save < 0: - return - if self.parent.active == self: - self.parent.active = None - self.parent.updatemenubar() - del self.ted - self.do_postclose() - - def menu_save(self): - if not self.path: - self.menu_save_as() - return # Will call us recursively - print 'Saving to ', self.path - dhandle = self.ted.TEGetText() - data = dhandle.data - fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line - fp.write(data) - if data[-1] <> '\r': fp.write('\r') - fp.close() - self.changed = 0 - - def menu_save_as(self): - fss, ok = macfs.StandardPutFile('Save as:') - if not ok: return - self.path = fss.as_pathname() - self.name = os.path.split(self.path)[-1] - self.wid.SetWTitle(self.name) - self.menu_save() - - def menu_cut(self): - self.ted.TESelView() - self.ted.TECut() - Scrap.ZeroScrap() - TE.TEToScrap() - self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def menu_copy(self): - self.ted.TECopy() - Scrap.ZeroScrap() - TE.TEToScrap() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_paste(self): - print 'SCRAP', Scrap.InfoScrap(), `Scrap.InfoScrap()[1].data` - TE.TEFromScrap() - self.ted.TESelView() - self.ted.TEPaste() - self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def menu_clear(self): - self.ted.TESelView() - self.ted.TEDelete() - self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def have_selection(self): - return (self.ted.selStart < self.ted.selEnd) - -class Ped(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.active = None - self.updatemenubar() - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window", "N", self.open) - self.openitem = MenuItem(m, "Open...", "O", self.openfile) - self.closeitem = MenuItem(m, "Close", "W", self.closewin) - m.addseparator() - self.saveitem = MenuItem(m, "Save", "S", self.save) - self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) - m.addseparator() - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - self.editmenu = m = Menu(self.menubar, "Edit") - self.undoitem = MenuItem(m, "Undo", "Z", self.undo) - self.cutitem = MenuItem(m, "Cut", "X", self.cut) - self.copyitem = MenuItem(m, "Copy", "C", self.copy) - self.pasteitem = MenuItem(m, "Paste", "V", self.paste) - self.clearitem = MenuItem(m, "Clear", "", self.clear) - - # Not yet implemented: - self.undoitem.enable(0) - - # Groups of items enabled together: - self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] - self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] - self.windowgroup_on = -1 - self.focusgroup_on = -1 - self.pastegroup_on = -1 - - def updatemenubar(self): - changed = 0 - on = (self.active <> None) - if on <> self.windowgroup_on: - for m in self.windowgroup: - m.enable(on) - self.windowgroup_on = on - changed = 1 - if on: - # only if we have an edit menu - on = self.active.have_selection() - if on <> self.focusgroup_on: - for m in self.focusgroup: - m.enable(on) - self.focusgroup_on = on - changed = 1 - on = (Scrap.InfoScrap()[0] <> 0) - if on <> self.pastegroup_on: - self.pasteitem.enable(on) - self.pastegroup_on = on - changed = 1 - if changed: - DrawMenuBar() - - # - # Apple menu - # - - def do_about(self, id, item, window, event): - EasyDialogs.Message("A simple single-font text editor") - - # - # File menu - # - - def open(self, *args): - self._open(0) - - def openfile(self, *args): - self._open(1) - - def _open(self, askfile): - if askfile: - fss, ok = macfs.StandardGetFile('TEXT') - if not ok: - return - path = fss.as_pathname() - name = os.path.split(path)[-1] - try: - fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line - data = fp.read() - fp.close() - except IOError, arg: - EasyDialogs.Message("IOERROR: "+`arg`) - return - else: - path = None - name = "Untitled %d"%self.num - data = '' - w = TEWindow(self) - w.open(path, name, data) - self.num = self.num + 1 - - def closewin(self, *args): - if self.active: - self.active.close() - else: - EasyDialogs.Message("No active window?") - - def save(self, *args): - if self.active: - self.active.menu_save() - else: - EasyDialogs.Message("No active window?") - - def saveas(self, *args): - if self.active: - self.active.menu_save_as() - else: - EasyDialogs.Message("No active window?") - - - def quit(self, *args): - for w in self._windows.values(): - w.close() - if self._windows: - return - raise self - - # - # Edit menu - # - - def undo(self, *args): - pass - - def cut(self, *args): - if self.active: - self.active.menu_cut() - else: - EasyDialogs.Message("No active window?") - - def copy(self, *args): - if self.active: - self.active.menu_copy() - else: - EasyDialogs.Message("No active window?") - - def paste(self, *args): - if self.active: - self.active.menu_paste() - else: - EasyDialogs.Message("No active window?") - - def clear(self, *args): - if self.active: - self.active.menu_clear() - else: - EasyDialogs.Message("No active window?") - - # - # Other stuff - # - - def idle(self, *args): - if self.active: - self.active.do_idle() - -def main(): - App = Ped() - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Demo/using.html b/Mac/Demo/using.html deleted file mode 100644 index d3b5e8bf21..0000000000 --- a/Mac/Demo/using.html +++ /dev/null @@ -1,380 +0,0 @@ - - -Using Python on the Macintosh - - -

      Using Python on the Macintosh

      -
      - -This document is an introduction to using Python on the Apple -Macintosh. It does not introduce the language itself, for this you -should refer to the Python Tutorial by -Guido van Rossum. This guide more-or-less replaces chapter two of the -tutorial, and provides some additional material.

      - -There is currently no good tutorial for the mac-specific features of -Python, but to whet your appetite: it has interfaces to many MacOS -toolboxes (quickdraw, sound, quicktime, open scripting, etc) and -various portable toolboxes are available too (Tk, stdwin, complex -numbers, image manipulation, etc). Some -annotated sample programs are available to give you an idea of -Python's power.

      - -The document refers to Python 1.3.3 or higher, some of the features -(like setting applet options) will not work in earlier versions of -Python.

      - -

      Invoking the interpreter

      - -The name of the interpreter may differ on different installations: it -may be called Python, PythonPPC (for powerpc -macs) or Python68K (indeed, for 68K macs). It will always -be recognizable by the "16 ton" icon, though. You start the -interpreter in interactive mode by double-clicking its icon:

      - -

      - -This should give you a text window with an informative version string -and a prompt, something like the following: -

      -Python 1.3.3 (Apr  7 1996)  [CW PPC w/GUSI]
      -Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
      ->>>
      -
      -The version string tells you the version of Python, whether it was -built for PPC or 68K macs and possibly some options used to build the -interpreter. If you find a bug or have a question about how the -interpreter works it is a good idea to include the version information -in your message.

      - -At the prompt you can type interactive python commands. See the -tutorial for more information. The interactive window works -more-or-less like a Communication Toolbox or Telnet window: you type -commands at the bottom and terminate them with the [return] -or [enter] key. Interpreter feedback also appears at the -bottom of the window, and the contents scroll as output is added. You -can use copy and paste in the normal way, but be sure to paste only at -the bottom of the document. - -

      Creating Python scripts

      - -The Python interpreter works in a way that is different from what you -would expect of a macintosh program: the interpreter is just that: an -interpreter. There is no builtin editor or other development -support. Hence, to create a Python script you need an external text -editor. For a first script you can use any editor that can create -plain, unstyled text files, such as SimpleText.

      - -For more serious scripts, though, it is advisable to use a programmers -editor, such as BBEdit or Alpha. BBEdit is -my favorite: it comes in a commercial version but also in a -fully-functional free version BBEdit Lite. You can -download it from the BareBones -site. The free version will probably provide all the functionality -you will ever need. Besides the standard edit facilities it has -multi-file searches and many other goodies that can be very handy when -editing programs.

      - -After you have created your script in the editor of your choice you -drop it on the interpreter. This will start the interpreter executing -the script, again with a console window in which the output appears -and in which you can type input if the script requires it. Normally -the interpreter will close the window and quit as soon as the script -is done executing, see below under startup -options for a way to change this.

      - -It is a good idea to have the names of all your scripts end in -.py. While this is not necessary for standalone scripts -it is needed for modules, and it is probably a good idea to start the -habit now.

      - -If you do not like to start the Python interpreter afresh for each -edit-run cycle you can use the import statement and -reload() function to speed things up in some cases. Here -is Guido's original comment for how to do this, from the 1.1 release -notes:

      - -

      - -Make sure the program is a module file (filename must be a Python -identifier followed by '.py'). You can then import it -when you test it for the first time. There are now three -possibilities: it contains a syntax error; it gets a runtime error -(unhandled exception); or it runs OK but gives wrong results. (If it -gives correct results, you are done testing and don't need to read the -rest of this paragraph. :-) Note that the following is not -Mac-specific -- it's just that on UNIX it's easier to restart the -entire script so it's rarely useful.

      - -Recovery from a syntax error is easy: edit the file and import it -again.

      - -Recovery from wrong output is almost as easy: edit the file and, -instead of importing it, call the function reload() with -the module name as argument (e.g., if your module is called -foo, type reload(foo)).

      - -Recovery from an exception is trickier. Once the syntax is correct, a -'module' entry is placed in an internal table, and following import -statements will not re-read the file, even if the module's -initialization terminated with an error (one reason why this is done -is so that mutually recursive modules are initialized only once). You -must therefore force re-reading the module with reload(), -however, if this happens the first time you try to import the module, -the import statement itself has not completed, and your workspace does -not know the module name (even though the internal table of moduesl -does!). The trick is to first import the module again, then reload -it. For instance, import foo; reload(foo). Because the -module object already exists internally, the import statement does not -attempt to execute the module again -- it just places it in your -workspace.

      - -

      Clickable python scripts

      - -If you create your script with the correct creator and type, creator -'Pyth' and type 'TEXT', you can double-click -your script and it will automatically invoke the interpreter. If you -use BBEdit you can tell it about the Python file type by adding it to -the "file types" sections of the preferences. Then, if you save a file -for the first time you can tell BBEdit to save the file as a Python -script through the "options" choice of the save dialog.

      - -The Scripts folder contains a script -fixfiletypes that will recursively traverse a folder and -set the correct creator and type for all files ending in -.py.

      - -

      -Older releases of Python used the creator code -'PYTH' in stead of 'Pyth'. If you still have -older Python sources on your system and named them with -'.py' extension the fixfiletypes script will -correct them. -
      - -

      Interaction with the user

      - -Normally, the interpreter will check for user input (mouse clicks, -keyboard input) every once in a while, so it is possible to switch to -other applications while a script runs. It is also possible to -interrupt the interpreter with the standard command-period keypress, -this will raise the KeyboardInterrupt exception. Scripts -may, however, turn off this behaviour to facilitate their own event -handling. Such scripts can only be killed with the -command-option-escape shortcut. - -

      startup options

      - -If the option key is depressed when Python starts executing -the interpreter will bring up an options dialog thru which you can -influence the way the interpreter behaves. Keep the option key -depressed until the dialog comes up.

      - -

      - -The options modify the interpreters behaviour in the following way: -

        -
      • the interpreter goes to interactive mode (in stead of -exiting) after a script has terminated normally, -
      • for every module imported a line is printed telling you where the -module was loaded from, -
      • do not print the values of expressions executed as statements in -an interactive python, -
      • do not buffer stdout and stderr, -
      • print some debugging output during the parsing phase, -
      • keep the output window open when a script terminates. -
      -In addition, you can enter a unix-style command line which is passed -to the script in sys.argv. Sys.argv[0] is always the name -of the script being executed, additional values can be passed -here. Quoting works as expected.

      - -The default options are also settable on a system-wide basis, see the -section on editing preferences.

      - -

      Module search path

      - -The module search path, sys.path, contains the folders -python will search when you import a module. The path is settable on a -system-wide basis (see the preferences section), and normally -comprises the current folder (where the script lives), the -Lib folder and some of its subfolders and possibly some -more.

      - -

      Working folder

      - -The unix concept of a working directory does not translate -directly to a similar concept on the Macintosh. To facilitate easy -porting and the use of relative pathnames in scripts the interpreter -simulates a working directory. When a script is started the initial -working directory is the folder where the script lives. In case of an -interactive interpreter the working directory is the folder where the -interpreter lives.

      - -By the way: the "standard file" folder, the folder that is presented -to the user initially for an open or save dialog, does -not follow the Python working directory. Which folder is -initially shown to the user is usually one of (a) the application -folder, (b) the "Documents" folder or (c) the folder most recently -used for such a dialog (in any Python program). This is standard MacOS -behaviour, so don't blame Python for it. The exact behaviour is -settable through a control panel since System 7.5. - -

      Interactive startup file

      - -If the folder containing the interpreter contains a file named -PythonStartup this file is executed when you start an -interactive interpreter. In this file you could import modules you -often use and other such things.

      - - -

      Compiled python scripts

      - -Once a python module has been imported the interpreter creates a -compiled version which is stored in a file with the ".py" extension -replaced by ".pyc". These compiled files, with creator -'Pyth' and type 'PYC ' load faster when -imported (because they do not have to be parsed). The Lib -folder contains a script compileall.py, running this -script will cause all modules along the python search path to be -precompiled, which will speed up your programs. Compiled files are -also double-clickable.

      - -

      Python resources

      - -MacPython has the ability to collect a number of compiled modules -together in the resource fork of a single file. This feature is useful -if you distribute a python program and want to minimize clutter: you -can put all the needed modules in a single file (which could even be -the interpreter itself).

      - -If the module search path contains a filename as one of its entries -(as opposed to a folder name, which is the normal case) this file will -be searched for a resource with type 'PYC ' and a name -matching the module being imported.

      - -The scripts folder contains a script -PackLibDir which will convert a number of modules (or -possibly a complete subtree full of modules) into such a resource -file. - -

      Setting interpreter preferences

      - -The python interpreter keeps a preferences file in the standard -location in the system folder. In this preferences file it remembers -the default module search path and the default settings for the -runtime options. The preferences are settable via -EditPythonPrefs. For PPC python this is a standalone -program living in the main Python folder, for 68K python it is a -script in the Scripts folder.

      - -The interface to edit the preferences is rather clunky for the current -release.

      - -

      - -In the editable text field at the top you enter the initial module -search path, using newline as a separator. There are two special -values you can use here: an initial substring $(PYTHON) -will expand to the Python home folder and a value of -$(APPLICATION) will expand to the the python application -itself. Note that the text field may extend "beyond the bottom" even -though it does not have a scroll bar. Using the arrow keys works, -though.

      - -The Python home folder $(PYTHON) is initially, when you execute the -interpreter for the first time, set to the folder where the -interpreter lives. You can change it here.

      - -Finally, you can set the default startup options here, through a -sub-dialog. - -

      Applets

      - -An applet is a fullblown application written in Python, similar to an -AppleScript applet (and completely different from a Java -applet). Applets are currently only supported on PowerPC macintoshes, -and are created using the mkapplet program. You create an -applet by dropping the python source script onto mkapplet. The -Demo folder contains an example of a more involved applet -with its own resource file, etc.

      - -Note that while an applet behaves as a fullblown Macintosh application -it is not self-sufficient, so distributing it to a machine without an -installed Python interpreter will not work: it needs the shared python -execution engine PythonCore, and probably various modules -from the Lib and PlugIns folders.

      - -

      Customizing applets

      - -Applets can have their own settings for the startup options and module -search path. Dropping an applet on the EditPythonPrefs -application allows you to set these, in the same way as -double-clicking EditPythonPrefs allows you to set the system-wide -defaults.

      - -Actually, not only applets but also the interpreter itself can have -non-default settings for path and options. If you make a copy of the -interpreter and drop this copy onto EditPythonPrefs you will have an -interpreter that has a different set of default settings. - -

      Where to go from here

      - -The previously mentioned Python Tutorial is -an excellent place to start reading if you have never used Python -before. Other documentation such as the library reference manual is -indexed at the Python -Documentation page.

      - -There are some annotated sample programs -available that show some mac-specific issues, like use of various -toolboxes and creation of Python applets.

      - -Finally, the Demo folder in the Macintosh distribution -contains a number of other example programs. Most of these are only -very lightly documented, but they may help you to understand some -aspects of using Python.

      - -The best way to contact fellow Macintosh Python programmers is to join -the MacPython Special Interest Group mailing list. Send a message with -"info" in the body to pythonmac-sig-request@python.org -or view the Pythonmac SIG -page on the www.python.org WWW -server.

      - -

      Troubleshooting

      - -Python is a rather safe language, and hence it should be difficult to -crash the interpreter of the system with a Python script. There is an -exception to this rule, though: the modules that interface to the -system toolboxes (windowing, quickdraw, etc) do very little error -checking and therefore a misbehaving program using these modules may -indeed crash the system. Such programs are unfortunately rather -difficult to debug, since the crash does not generate the standard -Python stack trace, obviously, and since debugging print statements -will often interfere with the operation of the program. There is -little to do about this currently.

      - -Probably the most common cause of problems with modules ported from -other systems is the Mac end-of-line convention. Where unix uses -linefeed, 0x0a, to separate lines the mac uses carriage return, -0x0d. To complicate matters more a lot of mac programming editors like -BBEdit and emacs will work happily with both conventions, so the file -will appear to be correct in the editor but cause strange errors when -imported. BBEdit has a popup menu which allows you to inspect (and -set) the end-of-line convention used in a file.

      - -

      Where to go from here

      - -The next section to check out is the annotated sample programs.

      - -


      -Jack Jansen, -jack@cwi.nl, 19-Apr-1996. - - - diff --git a/Mac/Demo/waste.html b/Mac/Demo/waste.html deleted file mode 100644 index 856d79204f..0000000000 --- a/Mac/Demo/waste.html +++ /dev/null @@ -1,69 +0,0 @@ -Using WASTE - -

      Using WASTE

      -
      - -WASTE is an almost-compatible TextEdit replacement which overcomes -some of the limitations of it (like the 32K limit) and provides some extensions -(drag and drop, images, undo support). Moreover, it has a much cleaner interface -and is therefore easier integrated in Python.

      - -WASTE is written by Marco Piovanelli, <piovanel@kagi.com>, -and copyrighted by him. You can always obtain the latest version (for use in C -or Pascal programs) and the documentation from -<ftp://ftp.dsi.unimi.it/DSI/piovanel/WASTE>. - -We explain the useage of waste here by showing how to modify the TextEdit based -ped.py of the -previous example into the waste-based wed.py, -so you should have both sources handy.

      - -Functionally, wed.py provides three new things: resizable windows, a horizontal -scroll bar and undo.

      - -Let us look at the code, first at the application class Wed. The only real change is that -we now handle undo. Aside from enabling it in the creation routine and the addition of -a callback routine there is a bit of new code in updatemenubar: Waste not only handles -the full details of implementing undo, it will also tell us what the next undo operation will undo -(or redo). We use this to our advantage by changing the undo menu label to tell the user.

      - -The WasteWindow has seen a bit more change. Initialization of the waste data structure is -a bit different, in that we can specify some options at creation time. Also, waste has no SetText -method but a UseText which expects a handle as parameter. We have to be very careful -that we keep this handle around, because Python will happily free the handle if we have no more references -to it (and I doubt that Waste would like this:-). A final difference in open -is that we use a large number for the destination rectangle width, because we will use a horizontal scroll -bar.

      - -The idle method is a bit more involved, since we also call WEAdjustCursor to -provide the correct cursor based on mouse-position. Users like this.

      - -Getscrollbarvalues is simpler than its' TextEdit counterpart because Waste correctly -updates the destination rectangle when the document changes. Also note that waste uses accessor functions -to get at internal values, as opposed to direct struct access for TextEdit.

      - -Scrollbar_callback on the other hand is more elaborate (but also provides more functionality). -It also handles horizontal scrolls (scrolling one-tenth and half a screenful with the buttons). This -function is also "multi-font-ready" in that scrolling one line will do the expected thing in case of multiple -fonts. We will implement a multi-font editor later. A minor annoyance of Waste is that is does not provide -a pinned scroll, so at the end of our callback routine we have to check that we have not scrolled past the -beginning or end of the document, and adjust when needed.

      - -do_update is also changed, because Waste is completely region-based (as opposed to rect-based). -Hence, we erase regions here and we can also return immedeately if there is nothing to update.

      - -Do_postresize is new: because Waste uses accessor functions we can now modify the viewRect from -Python, which is impossible in the Python TextEdit interface, and hence we can implement resize. The -do_key and do_contentclick methods have also seen minor changes, because the -corresponding waste routines need a bit more information than their TextEdit counterparts. The Cut/copy/paste -code is simplified, because Waste uses the normal desktop scrap.

      - -Implementing undo is a wonder of simplicity: Waste handles all the details for us. Also, the new -can_paste method (which controls greying out of the paste menu entry) is an improvement -over what ped did: in ped it was possible that paste was enabled but that the data on the -scrap was incompatible with TextEdit. No more such problems here.

      - -


      -That is all for now. At some point in the future I will extend this editor to incorporate multiple fonts and -pointsizes, pictures and possibly drag-and-drop editing but I will first have to write the code for it. -For now you will have to go back to the index to pick another example. diff --git a/Mac/Demo/waste/htmled.py b/Mac/Demo/waste/htmled.py deleted file mode 100644 index 15b90352be..0000000000 --- a/Mac/Demo/waste/htmled.py +++ /dev/null @@ -1,826 +0,0 @@ -# A minimal text editor. -# -# To be done: -# - Functionality: find, etc. - -from Menu import DrawMenuBar -from FrameWork import * -import Win -import Qd -import Res -import Fm -import waste -import WASTEconst -import Scrap -import os -import macfs -import regsub -import string -import htmllib - -WATCH = Qd.GetCursor(4).data - -LEFTMARGIN=0 - -UNDOLABELS = [ # Indexed by WEGetUndoInfo() value - None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"] - -# Style and size menu. Note that style order is important (tied to bit values) -STYLES = [ - ("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"), - ("Shadow", ""), ("Condensed", ""), ("Extended", "") - ] -SIZES = [ 9, 10, 12, 14, 18, 24] - -# Sizes for HTML tag types -HTML_SIZE={ - 'h1': 18, - 'h2': 14 -} - -BIGREGION=Qd.NewRgn() -Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) - -class WasteWindow(ScrolledWindow): - def open(self, path, name, data): - self.path = path - self.name = name - r = windowbounds(400, 400) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - self.wid = w - vr = LEFTMARGIN, 0, r[2]-r[0]-15, r[3]-r[1]-15 - dr = (0, 0, vr[2], 0) - Qd.SetPort(w) - Qd.TextFont(4) - Qd.TextSize(9) - flags = WASTEconst.weDoAutoScroll | WASTEconst.weDoOutlineHilite | \ - WASTEconst.weDoMonoStyled | WASTEconst.weDoUndo - self.ted = waste.WENew(dr, vr, flags) - style, soup = self.getstylesoup(self.path) - self.ted.WEInsert(data, style, soup) - self.ted.WESetSelection(0,0) - self.ted.WECalText() - self.ted.WEResetModCount() - w.DrawGrowIcon() - self.scrollbars() - self.do_postopen() - self.do_activate(1, None) - - def getstylesoup(self, pathname): - if not pathname: - return None, None - oldrf = Res.CurResFile() - try: - rf = Res.OpenResFile(self.path) - except Res.Error: - return None, None - try: - hstyle = Res.Get1Resource('styl', 128) - hstyle.DetachResource() - except Res.Error: - hstyle = None - try: - hsoup = Res.Get1Resource('SOUP', 128) - hsoup.DetachResource() - except Res.Error: - hsoup = None - Res.CloseResFile(rf) - Res.UseResFile(oldrf) - return hstyle, hsoup - - def do_idle(self, event): - (what, message, when, where, modifiers) = event - Qd.SetPort(self.wid) - self.ted.WEIdle() - if self.ted.WEAdjustCursor(where, BIGREGION): - return - Qd.SetCursor(Qd.qd.arrow) - - def getscrollbarvalues(self): - dr = self.ted.WEGetDestRect() - vr = self.ted.WEGetViewRect() - vx = self.scalebarvalue(dr[0], dr[2], vr[0], vr[2]) - vy = self.scalebarvalue(dr[1], dr[3], vr[1], vr[3]) - return vx, vy - - def scrollbar_callback(self, which, what, value): - if which == 'y': - # - # "line" size is minimum of top and bottom line size - # - topline_off,dummy = self.ted.WEGetOffset((1,1)) - topline_num = self.ted.WEOffsetToLine(topline_off) - toplineheight = self.ted.WEGetHeight(topline_num, topline_num+1) - - botlinepos = self.ted.WEGetViewRect()[3] - botline_off, dummy = self.ted.WEGetOffset((1, botlinepos-1)) - botline_num = self.ted.WEOffsetToLine(botline_off) - botlineheight = self.ted.WEGetHeight(botline_num, botline_num+1) - - if botlineheight == 0: - botlineheight = self.ted.WEGetHeight(botline_num-1, botline_num) - if botlineheight < toplineheight: - lineheight = botlineheight - else: - lineheight = toplineheight - if lineheight <= 0: - lineheight = 1 - # - # Now do the command. - # - if what == 'set': - height = self.ted.WEGetHeight(0, 0x3fffffff) - cur = self.getscrollbarvalues()[1] - delta = (cur-value)*height/32767 - if what == '-': - delta = lineheight - elif what == '--': - delta = (self.ted.WEGetViewRect()[3]-lineheight) - if delta <= 0: - delta = lineheight - elif what == '+': - delta = -lineheight - elif what == '++': - delta = -(self.ted.WEGetViewRect()[3]-lineheight) - if delta >= 0: - delta = -lineheight - self.ted.WEScroll(0, delta) - else: - if what == 'set': - return # XXXX - vr = self.ted.WEGetViewRect() - winwidth = vr[2]-vr[0] - if what == '-': - delta = winwidth/10 - elif what == '--': - delta = winwidth/2 - elif what == '+': - delta = -winwidth/10 - elif what == '++': - delta = -winwidth/2 - self.ted.WEScroll(delta, 0) - # Pin the scroll - l, t, r, b = self.ted.WEGetDestRect() - vl, vt, vr, vb = self.ted.WEGetViewRect() - if t > 0 or l > 0: - dx = dy = 0 - if t > 0: dy = -t - if l > 0: dx = -l - self.ted.WEScroll(dx, dy) - elif b < vb: - self.ted.WEScroll(0, vb-b) - - - def do_activate(self, onoff, evt): - Qd.SetPort(self.wid) - ScrolledWindow.do_activate(self, onoff, evt) - if onoff: - self.ted.WEActivate() - self.parent.active = self - self.parent.updatemenubar() - else: - self.ted.WEDeactivate() - - def do_update(self, wid, event): - region = wid.GetWindowPort().visRgn - if Qd.EmptyRgn(region): - return - Qd.EraseRgn(region) - self.ted.WEUpdate(region) - self.updatescrollbars() - - def do_postresize(self, width, height, window): - l, t, r, b = self.ted.WEGetViewRect() - vr = (l, t, l+width-15, t+height-15) - self.ted.WESetViewRect(vr) - Win.InvalRect(vr) - ScrolledWindow.do_postresize(self, width, height, window) - - def do_contentclick(self, local, modifiers, evt): - (what, message, when, where, modifiers) = evt - self.ted.WEClick(local, modifiers, when) - self.updatescrollbars() - self.parent.updatemenubar() - - def do_char(self, ch, event): - self.ted.WESelView() - (what, message, when, where, modifiers) = event - self.ted.WEKey(ord(ch), modifiers) - self.updatescrollbars() - self.parent.updatemenubar() - - def close(self): - if self.ted.WEGetModCount(): - save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) - if save > 0: - self.menu_save() - elif save < 0: - return - if self.parent.active == self: - self.parent.active = None - self.parent.updatemenubar() - del self.ted - self.do_postclose() - - def menu_save(self): - if not self.path: - self.menu_save_as() - return # Will call us recursively - # - # First save data - # - dhandle = self.ted.WEGetText() - data = dhandle.data - fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line - fp.write(data) - if data[-1] <> '\r': fp.write('\r') - fp.close() - # - # Now save style and soup - # - oldresfile = Res.CurResFile() - try: - rf = Res.OpenResFile(self.path) - except Res.Error: - Res.CreateResFile(self.path) - rf = Res.OpenResFile(self.path) - styles = Res.Resource('') - soup = Res.Resource('') - self.ted.WECopyRange(0, 0x3fffffff, None, styles, soup) - styles.AddResource('styl', 128, '') - soup.AddResource('SOUP', 128, '') - Res.CloseResFile(rf) - Res.UseResFile(oldresfile) - - self.ted.WEResetModCount() - - def menu_save_as(self): - fss, ok = macfs.StandardPutFile('Save as:') - if not ok: return - self.path = fss.as_pathname() - self.name = os.path.split(self.path)[-1] - self.wid.SetWTitle(self.name) - self.menu_save() - - def menu_insert(self, fp): - self.ted.WESelView() - data = fp.read() - self.ted.WEInsert(data, None, None) - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_insert_html(self, fp): - import htmllib - import formatter - f = formatter.AbstractFormatter(self) - - # Remember where we are, and don't update - Qd.SetCursor(WATCH) - start, dummy = self.ted.WEGetSelection() - self.ted.WEFeatureFlag(WASTEconst.weFInhibitRecal, 1) - - self.html_init() - p = MyHTMLParser(f) - p.feed(fp.read()) - - # Restore updating, recalc, set focus - dummy, end = self.ted.WEGetSelection() - self.ted.WECalText() - self.ted.WESetSelection(start, end) - self.ted.WESelView() - self.ted.WEFeatureFlag(WASTEconst.weFInhibitRecal, 0) - Win.InvalRect(self.ted.WEGetViewRect()) - - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_cut(self): - self.ted.WESelView() - self.ted.WECut() - Scrap.ZeroScrap() - self.ted.WECut() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_copy(self): - Scrap.ZeroScrap() - self.ted.WECopy() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_paste(self): - self.ted.WESelView() - self.ted.WEPaste() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_clear(self): - self.ted.WESelView() - self.ted.WEDelete() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_undo(self): - self.ted.WEUndo() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_setfont(self, font): - font = Fm.GetFNum(font) - self.mysetstyle(WASTEconst.weDoFont, (font, 0, 0, (0,0,0))) - self.parent.updatemenubar() - - def menu_modface(self, face): - self.mysetstyle(WASTEconst.weDoFace|WASTEconst.weDoToggleFace, - (0, face, 0, (0,0,0))) - - def menu_setface(self, face): - self.mysetstyle(WASTEconst.weDoFace|WASTEconst.weDoReplaceFace, - (0, face, 0, (0,0,0))) - - def menu_setsize(self, size): - self.mysetstyle(WASTEconst.weDoSize, (0, 0, size, (0,0,0))) - - def menu_incsize(self, size): - self.mysetstyle(WASTEconst.weDoAddSize, (0, 0, size, (0,0,0))) - - def mysetstyle(self, which, how): - self.ted.WESelView() - self.ted.WESetStyle(which, how) - self.parent.updatemenubar() - - def have_selection(self): - start, stop = self.ted.WEGetSelection() - return start < stop - - def can_paste(self): - return self.ted.WECanPaste() - - def can_undo(self): - which, redo = self.ted.WEGetUndoInfo() - which = UNDOLABELS[which] - if which == None: return None - if redo: - return "Redo "+which - else: - return "Undo "+which - - def getruninfo(self): - all = (WASTEconst.weDoFont | WASTEconst.weDoFace | WASTEconst.weDoSize) - dummy, mode, (font, face, size, color) = self.ted.WEContinuousStyle(all) - if not (mode & WASTEconst.weDoFont): - font = None - else: - font = Fm.GetFontName(font) - if not (mode & WASTEconst.weDoFace): fact = None - if not (mode & WASTEconst.weDoSize): size = None - return font, face, size - - # - # Methods for writer class for html formatter - # - - def html_init(self): - self.html_font = [12, 0, 0, 0] - self.html_style = 0 - self.html_color = (0,0,0) - self.new_font(self.html_font) - - def new_font(self, font): - if font == None: - font = (12, 0, 0, 0) - font = map(lambda x:x, font) - for i in range(len(font)): - if font[i] == None: - font[i] = self.html_font[i] - [size, italic, bold, tt] = font - self.html_font = font[:] - if tt: - font = Fm.GetFNum('Courier') - else: - font = Fm.GetFNum('Times') - if HTML_SIZE.has_key(size): - size = HTML_SIZE[size] - else: - size = 12 - face = 0 - if bold: face = face | 1 - if italic: face = face | 2 - face = face | self.html_style - self.ted.WESetStyle(WASTEconst.weDoFont | WASTEconst.weDoFace | - WASTEconst.weDoSize | WASTEconst.weDoColor, - (font, face, size, self.html_color)) - - def new_margin(self, margin, level): - self.ted.WEInsert('[Margin %s %s]'%(margin, level), None, None) - - def new_spacing(self, spacing): - self.ted.WEInsert('[spacing %s]'%spacing, None, None) - - def new_styles(self, styles): - self.html_style = 0 - self.html_color = (0,0,0) - if 'anchor' in styles: - self.html_style = self.html_style | 4 - self.html_color = (0xffff, 0, 0) - self.new_font(self.html_font) - - def send_paragraph(self, blankline): - self.ted.WEInsert('\r'*(blankline+1), None, None) - - def send_line_break(self): - self.ted.WEInsert('\r', None, None) - - def send_hor_rule(self, *args, **kw): - # Ignore ruler options, for now - dummydata = Res.Resource('') - self.ted.WEInsertObject('rulr', dummydata, (0,0)) - - def send_label_data(self, data): - self.ted.WEInsert(data, None, None) - - def send_flowing_data(self, data): - self.ted.WEInsert(data, None, None) - - def send_literal_data(self, data): - data = regsub.gsub('\n', '\r', data) - data = string.expandtabs(data) - self.ted.WEInsert(data, None, None) - -class Wed(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.active = None - self.updatemenubar() - waste.STDObjectHandlers() - # Handler for horizontal ruler - waste.WEInstallObjectHandler('rulr', 'new ', self.newRuler) - waste.WEInstallObjectHandler('rulr', 'draw', self.drawRuler) - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window", "N", self.open) - self.openitem = MenuItem(m, "Open...", "O", self.openfile) - self.closeitem = MenuItem(m, "Close", "W", self.closewin) - m.addseparator() - self.saveitem = MenuItem(m, "Save", "S", self.save) - self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) - m.addseparator() - self.insertitem = MenuItem(m, "Insert plaintext...", "", self.insertfile) - self.htmlitem = MenuItem(m, "Insert HTML...", "", self.inserthtml) - m.addseparator() - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - self.editmenu = m = Menu(self.menubar, "Edit") - self.undoitem = MenuItem(m, "Undo", "Z", self.undo) - self.cutitem = MenuItem(m, "Cut", "X", self.cut) - self.copyitem = MenuItem(m, "Copy", "C", self.copy) - self.pasteitem = MenuItem(m, "Paste", "V", self.paste) - self.clearitem = MenuItem(m, "Clear", "", self.clear) - - self.makefontmenu() - - # Groups of items enabled together: - self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, - self.editmenu, self.fontmenu, self.facemenu, self.sizemenu, - self.insertitem] - self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] - self.windowgroup_on = -1 - self.focusgroup_on = -1 - self.pastegroup_on = -1 - self.undo_label = "never" - self.ffs_values = () - - def makefontmenu(self): - self.fontmenu = Menu(self.menubar, "Font") - self.fontnames = getfontnames() - self.fontitems = [] - for n in self.fontnames: - m = MenuItem(self.fontmenu, n, "", self.selfont) - self.fontitems.append(m) - self.facemenu = Menu(self.menubar, "Style") - self.faceitems = [] - for n, shortcut in STYLES: - m = MenuItem(self.facemenu, n, shortcut, self.selface) - self.faceitems.append(m) - self.facemenu.addseparator() - self.faceitem_normal = MenuItem(self.facemenu, "Normal", "N", - self.selfacenormal) - self.sizemenu = Menu(self.menubar, "Size") - self.sizeitems = [] - for n in SIZES: - m = MenuItem(self.sizemenu, `n`, "", self.selsize) - self.sizeitems.append(m) - self.sizemenu.addseparator() - self.sizeitem_bigger = MenuItem(self.sizemenu, "Bigger", "+", - self.selsizebigger) - self.sizeitem_smaller = MenuItem(self.sizemenu, "Smaller", "-", - self.selsizesmaller) - - def selfont(self, id, item, *rest): - if self.active: - font = self.fontnames[item-1] - self.active.menu_setfont(font) - else: - EasyDialogs.Message("No active window?") - - def selface(self, id, item, *rest): - if self.active: - face = (1<<(item-1)) - self.active.menu_modface(face) - else: - EasyDialogs.Message("No active window?") - - def selfacenormal(self, *rest): - if self.active: - self.active.menu_setface(0) - else: - EasyDialogs.Message("No active window?") - - def selsize(self, id, item, *rest): - if self.active: - size = SIZES[item-1] - self.active.menu_setsize(size) - else: - EasyDialogs.Message("No active window?") - - def selsizebigger(self, *rest): - if self.active: - self.active.menu_incsize(2) - else: - EasyDialogs.Message("No active window?") - - def selsizesmaller(self, *rest): - if self.active: - self.active.menu_incsize(-2) - else: - EasyDialogs.Message("No active window?") - - def updatemenubar(self): - changed = 0 - on = (self.active <> None) - if on <> self.windowgroup_on: - for m in self.windowgroup: - m.enable(on) - self.windowgroup_on = on - changed = 1 - if on: - # only if we have an edit menu - on = self.active.have_selection() - if on <> self.focusgroup_on: - for m in self.focusgroup: - m.enable(on) - self.focusgroup_on = on - changed = 1 - on = self.active.can_paste() - if on <> self.pastegroup_on: - self.pasteitem.enable(on) - self.pastegroup_on = on - changed = 1 - on = self.active.can_undo() - if on <> self.undo_label: - if on: - self.undoitem.enable(1) - self.undoitem.settext(on) - self.undo_label = on - else: - self.undoitem.settext("Nothing to undo") - self.undoitem.enable(0) - changed = 1 - if self.updatefontmenus(): - changed = 1 - if changed: - DrawMenuBar() - - def updatefontmenus(self): - info = self.active.getruninfo() - if info == self.ffs_values: - return 0 - # Remove old checkmarks - if self.ffs_values == (): - self.ffs_values = (None, None, None) - font, face, size = self.ffs_values - if font <> None: - fnum = self.fontnames.index(font) - self.fontitems[fnum].check(0) - if face <> None: - for i in range(len(self.faceitems)): - if face & (1< None: - for i in range(len(self.sizeitems)): - if SIZES[i] == size: - self.sizeitems[i].check(0) - - self.ffs_values = info - # Set new checkmarks - font, face, size = self.ffs_values - if font <> None: - fnum = self.fontnames.index(font) - self.fontitems[fnum].check(1) - if face <> None: - for i in range(len(self.faceitems)): - if face & (1< None: - for i in range(len(self.sizeitems)): - if SIZES[i] == size: - self.sizeitems[i].check(1) - # Set outline/normal for sizes - if font: - exists = getfontsizes(font, SIZES) - for i in range(len(self.sizeitems)): - if exists[i]: - self.sizeitems[i].setstyle(0) - else: - self.sizeitems[i].setstyle(8) - - # - # Apple menu - # - - def do_about(self, id, item, window, event): - EasyDialogs.Message("A simple single-font text editor based on WASTE") - - # - # File menu - # - - def open(self, *args): - self._open(0) - - def openfile(self, *args): - self._open(1) - - def _open(self, askfile): - if askfile: - fss, ok = macfs.StandardGetFile('TEXT') - if not ok: - return - path = fss.as_pathname() - name = os.path.split(path)[-1] - try: - fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line - data = fp.read() - fp.close() - except IOError, arg: - EasyDialogs.Message("IOERROR: "+`arg`) - return - else: - path = None - name = "Untitled %d"%self.num - data = '' - w = WasteWindow(self) - w.open(path, name, data) - self.num = self.num + 1 - - def insertfile(self, *args): - if self.active: - fss, ok = macfs.StandardGetFile('TEXT') - if not ok: - return - path = fss.as_pathname() - try: - fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line - except IOError, arg: - EasyDialogs.Message("IOERROR: "+`arg`) - return - self.active.menu_insert(fp) - else: - EasyDialogs.Message("No active window?") - - def inserthtml(self, *args): - if self.active: - fss, ok = macfs.StandardGetFile('TEXT') - if not ok: - return - path = fss.as_pathname() - try: - fp = open(path, 'r') - except IOError, arg: - EasyDialogs.Message("IOERROR: "+`arg`) - return - self.active.menu_insert_html(fp) - else: - EasyDialogs.Message("No active window?") - - - def closewin(self, *args): - if self.active: - self.active.close() - else: - EasyDialogs.Message("No active window?") - - def save(self, *args): - if self.active: - self.active.menu_save() - else: - EasyDialogs.Message("No active window?") - - def saveas(self, *args): - if self.active: - self.active.menu_save_as() - else: - EasyDialogs.Message("No active window?") - - - def quit(self, *args): - for w in self._windows.values(): - w.close() - if self._windows: - return - raise self - - # - # Edit menu - # - - def undo(self, *args): - if self.active: - self.active.menu_undo() - else: - EasyDialogs.Message("No active window?") - - def cut(self, *args): - if self.active: - self.active.menu_cut() - else: - EasyDialogs.Message("No active window?") - - def copy(self, *args): - if self.active: - self.active.menu_copy() - else: - EasyDialogs.Message("No active window?") - - def paste(self, *args): - if self.active: - self.active.menu_paste() - else: - EasyDialogs.Message("No active window?") - - def clear(self, *args): - if self.active: - self.active.menu_clear() - else: - EasyDialogs.Message("No active window?") - - # - # Other stuff - # - - def idle(self, event): - if self.active: - self.active.do_idle(event) - - def newRuler(self, obj): - """Insert a new ruler. Make it as wide as the window minus 2 pxls""" - ted = obj.WEGetObjectOwner() - l, t, r, b = ted.WEGetDestRect() - return r-l, 4 - - def drawRuler(self, (l, t, r, b), obj): - y = (t+b)/2 - Qd.MoveTo(l+2, y) - Qd.LineTo(r-2, y) - return 0 - -class MyHTMLParser(htmllib.HTMLParser): - - def anchor_bgn(self, href, name, type): - self.anchor = href - if self.anchor: - self.anchorlist.append(href) - self.formatter.push_style('anchor') - - def anchor_end(self): - if self.anchor: - self.anchor = None - self.formatter.pop_style() - - -def getfontnames(): - names = [] - for i in range(256): - n = Fm.GetFontName(i) - if n: names.append(n) - return names - -def getfontsizes(name, sizes): - exist = [] - num = Fm.GetFNum(name) - for sz in sizes: - if Fm.RealFont(num, sz): - exist.append(1) - else: - exist.append(0) - return exist - -def main(): - App = Wed() - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Demo/waste/swed.py b/Mac/Demo/waste/swed.py deleted file mode 100644 index dc5de6a21e..0000000000 --- a/Mac/Demo/waste/swed.py +++ /dev/null @@ -1,628 +0,0 @@ -# A minimal text editor. -# -# To be done: -# - Functionality: find, etc. - -from Menu import DrawMenuBar -from FrameWork import * -import Win -import Qd -import Res -import Fm -import waste -import WASTEconst -import Scrap -import os -import macfs - -UNDOLABELS = [ # Indexed by WEGetUndoInfo() value - None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"] - -# Style and size menu. Note that style order is important (tied to bit values) -STYLES = [ - ("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"), - ("Shadow", ""), ("Condensed", ""), ("Extended", "") - ] -SIZES = [ 9, 10, 12, 14, 18, 24] - -BIGREGION=Qd.NewRgn() -Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) - -class WasteWindow(ScrolledWindow): - def open(self, path, name, data): - self.path = path - self.name = name - r = windowbounds(400, 400) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - self.wid = w - vr = 0, 0, r[2]-r[0]-15, r[3]-r[1]-15 - dr = (0, 0, 10240, 0) - Qd.SetPort(w) - Qd.TextFont(4) - Qd.TextSize(9) - flags = WASTEconst.weDoAutoScroll | WASTEconst.weDoOutlineHilite | \ - WASTEconst.weDoMonoStyled | WASTEconst.weDoUndo - self.ted = waste.WENew(dr, vr, flags) - style, soup = self.getstylesoup() - self.ted.WEInsert(data, style, soup) - self.ted.WESetSelection(0,0) - self.ted.WECalText() - self.ted.WEResetModCount() - w.DrawGrowIcon() - self.scrollbars() - self.do_postopen() - self.do_activate(1, None) - - def getstylesoup(self): - if not self.path: - return None, None - oldrf = Res.CurResFile() - try: - rf = Res.OpenResFile(self.path) - except Res.Error: - return None, None - try: - hstyle = Res.Get1Resource('styl', 128) - hstyle.DetachResource() - except Res.Error: - hstyle = None - try: - hsoup = Res.Get1Resource('SOUP', 128) - hsoup.DetachResource() - except Res.Error: - hsoup = None - Res.CloseResFile(rf) - Res.UseResFile(oldrf) - return hstyle, hsoup - - def do_idle(self, event): - (what, message, when, where, modifiers) = event - Qd.SetPort(self.wid) - self.ted.WEIdle() - if self.ted.WEAdjustCursor(where, BIGREGION): - return - Qd.SetCursor(Qd.qd.arrow) - - def getscrollbarvalues(self): - dr = self.ted.WEGetDestRect() - vr = self.ted.WEGetViewRect() - vx = self.scalebarvalue(dr[0], dr[2], vr[0], vr[2]) - vy = self.scalebarvalue(dr[1], dr[3], vr[1], vr[3]) - return vx, vy - - def scrollbar_callback(self, which, what, value): - if which == 'y': - if what == 'set': - height = self.ted.WEGetHeight(0, 0x3fffffff) - cur = self.getscrollbarvalues()[1] - delta = (cur-value)*height/32767 - if what == '-': - topline_off,dummy = self.ted.WEGetOffset((1,1)) - topline_num = self.ted.WEOffsetToLine(topline_off) - delta = self.ted.WEGetHeight(topline_num, topline_num+1) - elif what == '--': - delta = (self.ted.WEGetViewRect()[3]-10) - if delta <= 0: - delta = 10 # Random value - elif what == '+': - # XXXX Wrong: should be bottom line size - topline_off,dummy = self.ted.WEGetOffset((1,1)) - topline_num = self.ted.WEOffsetToLine(topline_off) - delta = -self.ted.WEGetHeight(topline_num, topline_num+1) - elif what == '++': - delta = -(self.ted.WEGetViewRect()[3]-10) - if delta >= 0: - delta = -10 - self.ted.WEScroll(0, delta) - else: - if what == 'set': - return # XXXX - vr = self.ted.WEGetViewRect() - winwidth = vr[2]-vr[0] - if what == '-': - delta = winwidth/10 - elif what == '--': - delta = winwidth/2 - elif what == '+': - delta = -winwidth/10 - elif what == '++': - delta = -winwidth/2 - self.ted.WEScroll(delta, 0) - # Pin the scroll - l, t, r, b = self.ted.WEGetDestRect() - vl, vt, vr, vb = self.ted.WEGetViewRect() - if t > 0 or l > 0: - dx = dy = 0 - if t > 0: dy = -t - if l > 0: dx = -l - self.ted.WEScroll(dx, dy) - elif b < vb: - self.ted.WEScroll(0, b-vb) - - - def do_activate(self, onoff, evt): - Qd.SetPort(self.wid) - ScrolledWindow.do_activate(self, onoff, evt) - if onoff: - self.ted.WEActivate() - self.parent.active = self - self.parent.updatemenubar() - else: - self.ted.WEDeactivate() - - def do_update(self, wid, event): - region = wid.GetWindowPort().visRgn - if Qd.EmptyRgn(region): - return - Qd.EraseRgn(region) - self.ted.WEUpdate(region) - self.updatescrollbars() - - def do_postresize(self, width, height, window): - l, t, r, b = self.ted.WEGetViewRect() - vr = (l, t, l+width-15, t+height-15) - self.ted.WESetViewRect(vr) - Win.InvalRect(vr) - ScrolledWindow.do_postresize(self, width, height, window) - - def do_contentclick(self, local, modifiers, evt): - (what, message, when, where, modifiers) = evt - self.ted.WEClick(local, modifiers, when) - self.updatescrollbars() - self.parent.updatemenubar() - - def do_char(self, ch, event): - self.ted.WESelView() - (what, message, when, where, modifiers) = event - self.ted.WEKey(ord(ch), modifiers) - self.updatescrollbars() - self.parent.updatemenubar() - - def close(self): - if self.ted.WEGetModCount(): - save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) - if save > 0: - self.menu_save() - elif save < 0: - return - if self.parent.active == self: - self.parent.active = None - self.parent.updatemenubar() - del self.ted - self.do_postclose() - - def menu_save(self): - if not self.path: - self.menu_save_as() - return # Will call us recursively - # - # First save data - # - dhandle = self.ted.WEGetText() - data = dhandle.data - fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line - fp.write(data) - if data[-1] <> '\r': fp.write('\r') - fp.close() - # - # Now save style and soup - # - oldresfile = Res.CurResFile() - try: - rf = Res.OpenResFile(self.path) - except Res.Error: - Res.CreateResFile(self.path) - rf = Res.OpenResFile(self.path) - styles = Res.Resource('') - soup = Res.Resource('') - self.ted.WECopyRange(0, 0x3fffffff, None, styles, soup) - styles.AddResource('styl', 128, '') - soup.AddResource('SOUP', 128, '') - Res.CloseResFile(rf) - Res.UseResFile(oldresfile) - - self.ted.WEResetModCount() - - def menu_save_as(self): - fss, ok = macfs.StandardPutFile('Save as:') - if not ok: return - self.path = fss.as_pathname() - self.name = os.path.split(self.path)[-1] - self.wid.SetWTitle(self.name) - self.menu_save() - - def menu_cut(self): - self.ted.WESelView() - self.ted.WECut() - Scrap.ZeroScrap() - self.ted.WECut() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_copy(self): - Scrap.ZeroScrap() - self.ted.WECopy() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_paste(self): - self.ted.WESelView() - self.ted.WEPaste() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_clear(self): - self.ted.WESelView() - self.ted.WEDelete() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_undo(self): - self.ted.WEUndo() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_setfont(self, font): - font = Fm.GetFNum(font) - self.mysetstyle(WASTEconst.weDoFont, (font, 0, 0, (0,0,0))) - self.parent.updatemenubar() - - def menu_modface(self, face): - self.mysetstyle(WASTEconst.weDoFace|WASTEconst.weDoToggleFace, - (0, face, 0, (0,0,0))) - - def menu_setface(self, face): - self.mysetstyle(WASTEconst.weDoFace|WASTEconst.weDoReplaceFace, - (0, face, 0, (0,0,0))) - - def menu_setsize(self, size): - self.mysetstyle(WASTEconst.weDoSize, (0, 0, size, (0,0,0))) - - def menu_incsize(self, size): - self.mysetstyle(WASTEconst.weDoAddSize, (0, 0, size, (0,0,0))) - - def mysetstyle(self, which, how): - self.ted.WESelView() - self.ted.WESetStyle(which, how) - self.parent.updatemenubar() - - def have_selection(self): - start, stop = self.ted.WEGetSelection() - return start < stop - - def can_paste(self): - return self.ted.WECanPaste() - - def can_undo(self): - which, redo = self.ted.WEGetUndoInfo() - which = UNDOLABELS[which] - if which == None: return None - if redo: - return "Redo "+which - else: - return "Undo "+which - - def getruninfo(self): - all = (WASTEconst.weDoFont | WASTEconst.weDoFace | WASTEconst.weDoSize) - dummy, mode, (font, face, size, color) = self.ted.WEContinuousStyle(all) - if not (mode & WASTEconst.weDoFont): - font = None - else: - font = Fm.GetFontName(font) - if not (mode & WASTEconst.weDoFace): fact = None - if not (mode & WASTEconst.weDoSize): size = None - return font, face, size - -class Wed(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.active = None - self.updatemenubar() - waste.STDObjectHandlers() - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window", "N", self.open) - self.openitem = MenuItem(m, "Open...", "O", self.openfile) - self.closeitem = MenuItem(m, "Close", "W", self.closewin) - m.addseparator() - self.saveitem = MenuItem(m, "Save", "S", self.save) - self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) - m.addseparator() - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - self.editmenu = m = Menu(self.menubar, "Edit") - self.undoitem = MenuItem(m, "Undo", "Z", self.undo) - self.cutitem = MenuItem(m, "Cut", "X", self.cut) - self.copyitem = MenuItem(m, "Copy", "C", self.copy) - self.pasteitem = MenuItem(m, "Paste", "V", self.paste) - self.clearitem = MenuItem(m, "Clear", "", self.clear) - - self.makefontmenu() - - # Groups of items enabled together: - self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, - self.editmenu, self.fontmenu, self.facemenu, self.sizemenu] - self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] - self.windowgroup_on = -1 - self.focusgroup_on = -1 - self.pastegroup_on = -1 - self.undo_label = "never" - self.ffs_values = () - - def makefontmenu(self): - self.fontmenu = Menu(self.menubar, "Font") - self.fontnames = getfontnames() - self.fontitems = [] - for n in self.fontnames: - m = MenuItem(self.fontmenu, n, "", self.selfont) - self.fontitems.append(m) - self.facemenu = Menu(self.menubar, "Style") - self.faceitems = [] - for n, shortcut in STYLES: - m = MenuItem(self.facemenu, n, shortcut, self.selface) - self.faceitems.append(m) - self.facemenu.addseparator() - self.faceitem_normal = MenuItem(self.facemenu, "Normal", "N", - self.selfacenormal) - self.sizemenu = Menu(self.menubar, "Size") - self.sizeitems = [] - for n in SIZES: - m = MenuItem(self.sizemenu, `n`, "", self.selsize) - self.sizeitems.append(m) - self.sizemenu.addseparator() - self.sizeitem_bigger = MenuItem(self.sizemenu, "Bigger", "+", - self.selsizebigger) - self.sizeitem_smaller = MenuItem(self.sizemenu, "Smaller", "-", - self.selsizesmaller) - - def selfont(self, id, item, *rest): - if self.active: - font = self.fontnames[item-1] - self.active.menu_setfont(font) - else: - EasyDialogs.Message("No active window?") - - def selface(self, id, item, *rest): - if self.active: - face = (1<<(item-1)) - self.active.menu_modface(face) - else: - EasyDialogs.Message("No active window?") - - def selfacenormal(self, *rest): - if self.active: - self.active.menu_setface(0) - else: - EasyDialogs.Message("No active window?") - - def selsize(self, id, item, *rest): - if self.active: - size = SIZES[item-1] - self.active.menu_setsize(size) - else: - EasyDialogs.Message("No active window?") - - def selsizebigger(self, *rest): - if self.active: - self.active.menu_incsize(2) - else: - EasyDialogs.Message("No active window?") - - def selsizesmaller(self, *rest): - if self.active: - self.active.menu_incsize(-2) - else: - EasyDialogs.Message("No active window?") - - def updatemenubar(self): - changed = 0 - on = (self.active <> None) - if on <> self.windowgroup_on: - for m in self.windowgroup: - m.enable(on) - self.windowgroup_on = on - changed = 1 - if on: - # only if we have an edit menu - on = self.active.have_selection() - if on <> self.focusgroup_on: - for m in self.focusgroup: - m.enable(on) - self.focusgroup_on = on - changed = 1 - on = self.active.can_paste() - if on <> self.pastegroup_on: - self.pasteitem.enable(on) - self.pastegroup_on = on - changed = 1 - on = self.active.can_undo() - if on <> self.undo_label: - if on: - self.undoitem.enable(1) - self.undoitem.settext(on) - self.undo_label = on - else: - self.undoitem.settext("Nothing to undo") - self.undoitem.enable(0) - changed = 1 - if self.updatefontmenus(): - changed = 1 - if changed: - DrawMenuBar() - - def updatefontmenus(self): - info = self.active.getruninfo() - if info == self.ffs_values: - return 0 - # Remove old checkmarks - if self.ffs_values == (): - self.ffs_values = (None, None, None) - font, face, size = self.ffs_values - if font <> None: - fnum = self.fontnames.index(font) - self.fontitems[fnum].check(0) - if face <> None: - for i in range(len(self.faceitems)): - if face & (1< None: - for i in range(len(self.sizeitems)): - if SIZES[i] == size: - self.sizeitems[i].check(0) - - self.ffs_values = info - # Set new checkmarks - font, face, size = self.ffs_values - if font <> None: - fnum = self.fontnames.index(font) - self.fontitems[fnum].check(1) - if face <> None: - for i in range(len(self.faceitems)): - if face & (1< None: - for i in range(len(self.sizeitems)): - if SIZES[i] == size: - self.sizeitems[i].check(1) - # Set outline/normal for sizes - if font: - exists = getfontsizes(font, SIZES) - for i in range(len(self.sizeitems)): - if exists[i]: - self.sizeitems[i].setstyle(0) - else: - self.sizeitems[i].setstyle(8) - - # - # Apple menu - # - - def do_about(self, id, item, window, event): - EasyDialogs.Message("A simple single-font text editor based on WASTE") - - # - # File menu - # - - def open(self, *args): - self._open(0) - - def openfile(self, *args): - self._open(1) - - def _open(self, askfile): - if askfile: - fss, ok = macfs.StandardGetFile('TEXT') - if not ok: - return - path = fss.as_pathname() - name = os.path.split(path)[-1] - try: - fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line - data = fp.read() - fp.close() - except IOError, arg: - EasyDialogs.Message("IOERROR: "+`arg`) - return - else: - path = None - name = "Untitled %d"%self.num - data = '' - w = WasteWindow(self) - w.open(path, name, data) - self.num = self.num + 1 - - def closewin(self, *args): - if self.active: - self.active.close() - else: - EasyDialogs.Message("No active window?") - - def save(self, *args): - if self.active: - self.active.menu_save() - else: - EasyDialogs.Message("No active window?") - - def saveas(self, *args): - if self.active: - self.active.menu_save_as() - else: - EasyDialogs.Message("No active window?") - - - def quit(self, *args): - for w in self._windows.values(): - w.close() - if self._windows: - return - raise self - - # - # Edit menu - # - - def undo(self, *args): - if self.active: - self.active.menu_undo() - else: - EasyDialogs.Message("No active window?") - - def cut(self, *args): - if self.active: - self.active.menu_cut() - else: - EasyDialogs.Message("No active window?") - - def copy(self, *args): - if self.active: - self.active.menu_copy() - else: - EasyDialogs.Message("No active window?") - - def paste(self, *args): - if self.active: - self.active.menu_paste() - else: - EasyDialogs.Message("No active window?") - - def clear(self, *args): - if self.active: - self.active.menu_clear() - else: - EasyDialogs.Message("No active window?") - - # - # Other stuff - # - - def idle(self, event): - if self.active: - self.active.do_idle(event) - -def getfontnames(): - names = [] - for i in range(256): - n = Fm.GetFontName(i) - if n: names.append(n) - return names - -def getfontsizes(name, sizes): - exist = [] - num = Fm.GetFNum(name) - for sz in sizes: - if Fm.RealFont(num, sz): - exist.append(1) - else: - exist.append(0) - return exist - -def main(): - App = Wed() - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Demo/waste/wed.py b/Mac/Demo/waste/wed.py deleted file mode 100644 index d4f08f4592..0000000000 --- a/Mac/Demo/waste/wed.py +++ /dev/null @@ -1,421 +0,0 @@ -# A minimal text editor. -# -# To be done: -# - Functionality: find, etc. - -from Menu import DrawMenuBar -from FrameWork import * -import Win -import Qd -import Res -import waste -import WASTEconst -import Scrap -import os -import macfs - -UNDOLABELS = [ # Indexed by WEGetUndoInfo() value - None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"] - -BIGREGION=Qd.NewRgn() -Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) - -class WasteWindow(ScrolledWindow): - def open(self, path, name, data): - self.path = path - self.name = name - r = windowbounds(400, 400) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - self.wid = w - vr = 0, 0, r[2]-r[0]-15, r[3]-r[1]-15 - dr = (0, 0, 10240, 0) - Qd.SetPort(w) - Qd.TextFont(4) - Qd.TextSize(9) - flags = WASTEconst.weDoAutoScroll | WASTEconst.weDoOutlineHilite | \ - WASTEconst.weDoMonoStyled | WASTEconst.weDoUndo - self.ted = waste.WENew(dr, vr, flags) - self.tedtexthandle = Res.Resource(data) - self.ted.WEUseText(self.tedtexthandle) - self.ted.WECalText() - w.DrawGrowIcon() - self.scrollbars() - self.changed = 0 - self.do_postopen() - self.do_activate(1, None) - - def do_idle(self, event): - (what, message, when, where, modifiers) = event - Qd.SetPort(self.wid) - self.ted.WEIdle() - if self.ted.WEAdjustCursor(where, BIGREGION): - return - Qd.SetCursor(Qd.qd.arrow) - - def getscrollbarvalues(self): - dr = self.ted.WEGetDestRect() - vr = self.ted.WEGetViewRect() - vx = self.scalebarvalue(dr[0], dr[2], vr[0], vr[2]) - vy = self.scalebarvalue(dr[1], dr[3], vr[1], vr[3]) -## print dr, vr, vx, vy - return vx, vy - - def scrollbar_callback(self, which, what, value): - if which == 'y': - if what == 'set': - height = self.ted.WEGetHeight(0, 0x3fffffff) - cur = self.getscrollbarvalues()[1] - delta = (cur-value)*height/32767 - if what == '-': - topline_off,dummy = self.ted.WEGetOffset((1,1)) - topline_num = self.ted.WEOffsetToLine(topline_off) - delta = self.ted.WEGetHeight(topline_num, topline_num+1) - elif what == '--': - delta = (self.ted.WEGetViewRect()[3]-10) - if delta <= 0: - delta = 10 # Random value - elif what == '+': - # XXXX Wrong: should be bottom line size - topline_off,dummy = self.ted.WEGetOffset((1,1)) - topline_num = self.ted.WEOffsetToLine(topline_off) - delta = -self.ted.WEGetHeight(topline_num, topline_num+1) - elif what == '++': - delta = -(self.ted.WEGetViewRect()[3]-10) - if delta >= 0: - delta = -10 - self.ted.WEScroll(0, delta) -## print 'SCROLL Y', delta - else: - if what == 'set': - return # XXXX - vr = self.ted.WEGetViewRect() - winwidth = vr[2]-vr[0] - if what == '-': - delta = winwidth/10 - elif what == '--': - delta = winwidth/2 - elif what == '+': - delta = -winwidth/10 - elif what == '++': - delta = -winwidth/2 - self.ted.WEScroll(delta, 0) - # Pin the scroll - l, t, r, b = self.ted.WEGetDestRect() - vl, vt, vr, vb = self.ted.WEGetViewRect() - if t > 0 or l > 0: - dx = dy = 0 - if t > 0: dy = -t - if l > 0: dx = -l -## print 'Extra scroll', dx, dy - self.ted.WEScroll(dx, dy) - elif b < vb: -## print 'Extra downscroll', b-vb - self.ted.WEScroll(0, b-vb) - - - def do_activate(self, onoff, evt): -## print "ACTIVATE", onoff - Qd.SetPort(self.wid) - ScrolledWindow.do_activate(self, onoff, evt) - if onoff: - self.ted.WEActivate() - self.parent.active = self - self.parent.updatemenubar() - else: - self.ted.WEDeactivate() - - def do_update(self, wid, event): - region = wid.GetWindowPort().visRgn - if Qd.EmptyRgn(region): - return - Qd.EraseRgn(region) - self.ted.WEUpdate(region) - self.updatescrollbars() - - def do_postresize(self, width, height, window): - l, t, r, b = self.ted.WEGetViewRect() - vr = (l, t, l+width-15, t+height-15) - self.ted.WESetViewRect(vr) - Win.InvalRect(vr) - ScrolledWindow.do_postresize(self, width, height, window) - - def do_contentclick(self, local, modifiers, evt): - (what, message, when, where, modifiers) = evt - self.ted.WEClick(local, modifiers, when) - self.updatescrollbars() - self.parent.updatemenubar() - - def do_char(self, ch, event): - self.ted.WESelView() - (what, message, when, where, modifiers) = event - self.ted.WEKey(ord(ch), modifiers) - self.changed = 1 - self.updatescrollbars() - self.parent.updatemenubar() - - def close(self): - if self.changed: - save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1) - if save > 0: - self.menu_save() - elif save < 0: - return - if self.parent.active == self: - self.parent.active = None - self.parent.updatemenubar() - del self.ted - del self.tedtexthandle - self.do_postclose() - - def menu_save(self): - if not self.path: - self.menu_save_as() - return # Will call us recursively -## print 'Saving to ', self.path - dhandle = self.ted.WEGetText() - data = dhandle.data - fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line - fp.write(data) - if data[-1] <> '\r': fp.write('\r') - fp.close() - self.changed = 0 - - def menu_save_as(self): - fss, ok = macfs.StandardPutFile('Save as:') - if not ok: return - self.path = fss.as_pathname() - self.name = os.path.split(self.path)[-1] - self.wid.SetWTitle(self.name) - self.menu_save() - - def menu_cut(self): - self.ted.WESelView() - self.ted.WECut() - Scrap.ZeroScrap() - self.ted.WECut() - self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def menu_copy(self): - Scrap.ZeroScrap() - self.ted.WECopy() - self.updatescrollbars() - self.parent.updatemenubar() - - def menu_paste(self): - self.ted.WESelView() - self.ted.WEPaste() - self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def menu_clear(self): - self.ted.WESelView() - self.ted.WEDelete() - self.updatescrollbars() - self.parent.updatemenubar() - self.changed = 1 - - def menu_undo(self): - self.ted.WEUndo() - self.updatescrollbars() - self.parent.updatemenubar() - - def have_selection(self): - start, stop = self.ted.WEGetSelection() - return start < stop - - def can_paste(self): - return self.ted.WECanPaste() - - def can_undo(self): - which, redo = self.ted.WEGetUndoInfo() - which = UNDOLABELS[which] - if which == None: return None - if redo: - return "Redo "+which - else: - return "Undo "+which - -class Wed(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.active = None - self.updatemenubar() - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window", "N", self.open) - self.openitem = MenuItem(m, "Open...", "O", self.openfile) - self.closeitem = MenuItem(m, "Close", "W", self.closewin) - m.addseparator() - self.saveitem = MenuItem(m, "Save", "S", self.save) - self.saveasitem = MenuItem(m, "Save as...", "", self.saveas) - m.addseparator() - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - self.editmenu = m = Menu(self.menubar, "Edit") - self.undoitem = MenuItem(m, "Undo", "Z", self.undo) - self.cutitem = MenuItem(m, "Cut", "X", self.cut) - self.copyitem = MenuItem(m, "Copy", "C", self.copy) - self.pasteitem = MenuItem(m, "Paste", "V", self.paste) - self.clearitem = MenuItem(m, "Clear", "", self.clear) - - # Groups of items enabled together: - self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem, self.editmenu] - self.focusgroup = [self.cutitem, self.copyitem, self.clearitem] - self.windowgroup_on = -1 - self.focusgroup_on = -1 - self.pastegroup_on = -1 - self.undo_label = "never" - - def updatemenubar(self): - changed = 0 - on = (self.active <> None) - if on <> self.windowgroup_on: - for m in self.windowgroup: - m.enable(on) - self.windowgroup_on = on - changed = 1 - if on: - # only if we have an edit menu - on = self.active.have_selection() - if on <> self.focusgroup_on: - for m in self.focusgroup: - m.enable(on) - self.focusgroup_on = on - changed = 1 - on = self.active.can_paste() - if on <> self.pastegroup_on: - self.pasteitem.enable(on) - self.pastegroup_on = on - changed = 1 - on = self.active.can_undo() - if on <> self.undo_label: - if on: - self.undoitem.enable(1) - self.undoitem.settext(on) - self.undo_label = on - else: - self.undoitem.settext("Nothing to undo") - self.undoitem.enable(0) - changed = 1 - if changed: - DrawMenuBar() - - # - # Apple menu - # - - def do_about(self, id, item, window, event): - EasyDialogs.Message("A simple single-font text editor based on WASTE") - - # - # File menu - # - - def open(self, *args): - self._open(0) - - def openfile(self, *args): - self._open(1) - - def _open(self, askfile): - if askfile: - fss, ok = macfs.StandardGetFile('TEXT') - if not ok: - return - path = fss.as_pathname() - name = os.path.split(path)[-1] - try: - fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line - data = fp.read() - fp.close() - except IOError, arg: - EasyDialogs.Message("IOERROR: "+`arg`) - return - else: - path = None - name = "Untitled %d"%self.num - data = '' - w = WasteWindow(self) - w.open(path, name, data) - self.num = self.num + 1 - - def closewin(self, *args): - if self.active: - self.active.close() - else: - EasyDialogs.Message("No active window?") - - def save(self, *args): - if self.active: - self.active.menu_save() - else: - EasyDialogs.Message("No active window?") - - def saveas(self, *args): - if self.active: - self.active.menu_save_as() - else: - EasyDialogs.Message("No active window?") - - - def quit(self, *args): - for w in self._windows.values(): - w.close() - if self._windows: - return - raise self - - # - # Edit menu - # - - def undo(self, *args): - if self.active: - self.active.menu_undo() - else: - EasyDialogs.Message("No active window?") - - def cut(self, *args): - if self.active: - self.active.menu_cut() - else: - EasyDialogs.Message("No active window?") - - def copy(self, *args): - if self.active: - self.active.menu_copy() - else: - EasyDialogs.Message("No active window?") - - def paste(self, *args): - if self.active: - self.active.menu_paste() - else: - EasyDialogs.Message("No active window?") - - def clear(self, *args): - if self.active: - self.active.menu_clear() - else: - EasyDialogs.Message("No active window?") - - # - # Other stuff - # - - def idle(self, event): - if self.active: - self.active.do_idle(event) - -def main(): - App = Ped() - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Include/config.h b/Mac/Include/config.h deleted file mode 100644 index 94b9bb95fa..0000000000 --- a/Mac/Include/config.h +++ /dev/null @@ -1,345 +0,0 @@ -/* config.h for Macintosh. - Most recently tested with CodeWarrior C (define: __MWERKS__), - but there are some provisions for Think C (define: THINK_C), - Apple C for MPW (define: applec), or Symantec C for MPW (define: __SC__). - There's no point in giving exact version numbers of the compilers - since we don't update this file as each compiler comes out; - with CodeWarrior, we generally use the most recent version. -*/ - -#define USE_STACKCHECK - -#ifdef applec -#define MPW -#endif - -/* Define if on Macintosh (THINK_C, MPW or __MWERKS__ should also be defined) */ -#ifndef macintosh -#define macintosh -#endif - -#ifdef THINK_C -#define HAVE_FOPENRF -#endif -#ifdef __MWERKS__ -#ifndef USE_GUSI -#define HAVE_FOPENRF -#endif -#endif - -#ifdef USE_GUSI -/* GUSI provides a lot of unixisms */ -#define HAVE_SELECT -#define DIRENT -#define HAVE_GETPEERNAME -#define HAVE_SELECT -#define HAVE_FCNTL_H -#define HAVE_SYS_TIME_H -#define HAVE_UNISTD_H -#endif - -#ifdef SYMANTEC__CFM68K__ -#define atof Py_AtoF -#define strtod Py_StrToD -#endif - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if type char is unsigned and you are not using gcc. */ -/* #undef __CHAR_UNSIGNED__ */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you have dirent.h. */ -/* #undef DIRENT */ - -/* Define to the type of elements in the array set by `getgroups'. - Usually this is either `int' or `gid_t'. */ -/* #undef GETGROUPS_T */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define if your struct tm has tm_zone. */ -/* #undef HAVE_TM_ZONE */ - -/* Define if you don't have tm_zone but do have the external array - tzname. */ -/* #undef HAVE_TZNAME */ - -/* Define if on MINIX. */ -/* #undef _MINIX */ - -/* Define to `int' if doesn't define. */ -/* #undef mode_t */ - -/* Define if you don't have dirent.h, but have ndir.h. */ -/* #undef NDIR */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS - -/* Define if you don't have dirent.h, but have sys/dir.h. */ -/* #undef SYSDIR */ - -/* Define if you don't have dirent.h, but have sys/ndir.h. */ -/* #undef SYSNDIR */ - -/* Define if you can safely include both and . */ -/* #undef TIME_WITH_SYS_TIME */ - -/* Define if your declares struct tm. */ -/* #undef TM_IN_SYS_TIME */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define if the closedir function returns void instead of int. */ -/* #undef VOID_CLOSEDIR */ - -/* Define if your contains bad prototypes for exec*() - (as it does on SGI IRIX 4.x) */ -/* #undef BAD_EXEC_PROTOTYPES */ - -/* Define if your compiler botches static forward declarations */ -#ifdef __MWERKS__ -#define BAD_STATIC_FORWARD -#endif -#ifdef __SC__ -#define BAD_STATIC_FORWARD -#endif - -/* Define to `long' if doesn't define. */ -/* #undef clock_t */ - -/* Define if getpgrp() must be called as getpgrp(0) - and (consequently) setpgrp() as setpgrp(0, 0). */ -/* #undef GETPGRP_HAVE_ARG */ - -/* Define this if your time.h defines altzone */ -/* #undef HAVE_ALTZONE */ - -/* Define if your compiler supports function prototypes */ -#define HAVE_PROTOTYPES - -/* Define if your compiler supports variable length function prototypes - (e.g. void fprintf(FILE *, char *, ...);) *and* */ -#define HAVE_STDARG_PROTOTYPES - -/* Define if you have POSIX threads */ -/* #undef _POSIX_THREADS */ - -/* Define to empty if the keyword does not work. */ -/* #undef signed */ - -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ -/* #undef SYS_SELECT_WITH_SYS_TIME */ - -/* Define if you want to use SGI (IRIX 4) dynamic linking. - This requires the "dl" library by Jack Jansen, - ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z. - Don't bother on IRIX 5, it already has dynamic linking using SunOS - style shared libraries */ -/* #undef WITH_SGI_DL */ - -/* Define if you want to emulate SGI (IRIX 4) dynamic linking. - This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4), - Sequent Symmetry (Dynix), and Atari ST. - This requires the "dl-dld" library, - ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z, - as well as the "GNU dld" library, - ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z. - Don't bother on SunOS 4 or 5, they already have dynamic linking using - shared libraries */ -/* #undef WITH_DL_DLD */ - -/* Define if you want to compile in rudimentary thread support */ -/* #undef WITH_THREAD */ - -/* Define if you want to use the GNU readline library */ -/* #undef WITH_READLINE */ - -/* Define if you have chown. */ -/* #undef HAVE_CHOWN */ - -/* Define if you have clock. */ -#define HAVE_CLOCK - -/* Define if you have dlopen. */ -/* #undef HAVE_DLOPEN */ - -/* Define if you have ftime. */ -/* #undef HAVE_FTIME */ - -/* Define if you have getpeername. */ -/* #undef HAVE_GETPEERNAME */ - -/* Define if you have getpgrp. */ -/* #undef HAVE_GETPGRP */ - -/* Define if you have getpid. */ -/* #undef HAVE_GETPID */ - -/* Define if you have gettimeofday. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define if you have getwd. */ -/* #undef HAVE_GETWD */ - -/* Define if you have link. */ -/* #undef HAVE_LINK */ - -/* Define if you have lstat. */ -/* #undef HAVE_LSTAT */ - -/* Define if you have nice. */ -/* #undef HAVE_NICE */ - -/* Define if you have readlink. */ -/* #undef HAVE_READLINK */ - -/* Define if you have select. */ -/* #undef HAVE_SELECT */ - -/* Define if you have setgid. */ -/* #undef HAVE_SETGID */ - -/* Define if you have setpgid. */ -/* #undef HAVE_SETPGID */ - -/* Define if you have setpgrp. */ -/* #undef HAVE_SETPGRP */ - -/* Define if you have setsid. */ -/* #undef HAVE_SETSID */ - -/* Define if you have setuid. */ -/* #undef HAVE_SETUID */ - -/* Define if you have setvbuf. */ -#define HAVE_SETVBUF - -/* Define if you have siginterrupt. */ -/* #undef HAVE_SIGINTERRUPT */ - -/* Define if you have symlink. */ -/* #undef HAVE_SYMLINK */ - -/* Define if you have tcgetpgrp. */ -/* #undef HAVE_TCGETPGRP */ - -/* Define if you have tcsetpgrp. */ -/* #undef HAVE_TCSETPGRP */ - -/* Define if you have times. */ -/* #undef HAVE_TIMES */ - -/* Define if you have uname. */ -/* #undef HAVE_UNAME */ - -/* Define if you have waitpid. */ -/* #undef HAVE_WAITPID */ - -/* Define if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_FCNTL_H */ - -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H - -/* Define if you have the header file. */ -#define HAVE_STDARG_H - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_PARAM_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_SELECT_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_TIME_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_TIMES_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_UN_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_UTSNAME_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_UNISTD_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_UTIME_H */ - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the inet library (-linet). */ -/* #undef HAVE_LIBINET */ - -/* Define if you have the mpc library (-lmpc). */ -/* #undef HAVE_LIBMPC */ - -/* Define if you have the nsl library (-lnsl). */ -/* #undef HAVE_LIBNSL */ - -/* Define if you have the pthreads library (-lpthreads). */ -/* #undef HAVE_LIBPTHREADS */ - -/* Define if you have the seq library (-lseq). */ -/* #undef HAVE_LIBSEQ */ - -/* Define if you have the socket library (-lsocket). */ -/* #undef HAVE_LIBSOCKET */ - -/* Define if you have the sun library (-lsun). */ -/* #undef HAVE_LIBSUN */ - -/* Define if you have the termcap library (-ltermcap). */ -/* #undef HAVE_LIBTERMCAP */ - -/* Define if you have the termlib library (-ltermlib). */ -/* #undef HAVE_LIBTERMLIB */ - -/* Define if you have the thread library (-lthread). */ -/* #undef HAVE_LIBTHREAD */ diff --git a/Mac/Include/macdefs.h b/Mac/Include/macdefs.h deleted file mode 100644 index 71f73b1056..0000000000 --- a/Mac/Include/macdefs.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Useful #includes and #defines for programming a set of Unix - look-alike file system access functions on the Macintosh. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). -*/ - -#include -#include -#include - -#ifdef THINK_C -#include -#endif - -#ifdef __MWERKS__ -#include "errno_unix.h" -#include -#define c2pstr C2PStr -#define p2cstr P2CStr -#endif -#include -#include - -/* We may be able to use a std routine in think, don't know */ -unsigned char *Pstring(char *); - -/* Macro to find out whether we can do HFS-only calls: */ -#define FSFCBLen (* (short *) 0x3f6) -#define hfsrunning() (FSFCBLen > 0) - -/* Universal constants: */ -#define MAXPATH 256 -#define TRUE 1 -#define FALSE 0 -#ifndef NULL -#define NULL 0 -#endif -#define EOS '\0' -#define SEP ':' diff --git a/Mac/Include/macglue.h b/Mac/Include/macglue.h deleted file mode 100644 index 02ee84cd25..0000000000 --- a/Mac/Include/macglue.h +++ /dev/null @@ -1,91 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#ifndef SystemSevenOrLater -#define SystemSevenOrLater 1 -#endif - -#include -#include -#include -#include - -#ifdef GENERATINGCFM /* Defined to 0 or 1 in Universal headers */ -#define HAVE_UNIVERSAL_HEADERS -#endif - -#ifdef SYMANTEC__CFM68K__ -#pragma lib_export on -#endif - -#ifdef USE_GUSI -void PyMac_FixGUSIcd Py_PROTO((void)); /* Workaround for GUSI chdir() call */ -#endif - -char *PyMac_StrError(int); /* strerror with mac errors */ - -extern int PyMac_DoYieldEnabled; /* Don't do eventloop when false */ - -extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ -PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ - -int PyMac_Idle Py_PROTO((void)); /* Idle routine */ -void PyMac_Yield Py_PROTO((void)); /* optional idle routine for mainloop */ -void PyMac_SetYield Py_PROTO((long, long, long, long)); /* Set timeouts */ -PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ -PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ -void PyMac_HandleEvent Py_PROTO((EventRecord *)); /* Handle one event, if possible */ - -int PyMac_Idle(void); /* Idle routine */ - -int PyMac_FindResourceModule(char *, char *); /* Test for 'PYC ' resource in a file */ -PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */ - -int PyMac_GetDirectory(FSSpec *dirfss, char *prompt); /* Ask user for a directory */ -void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList, - StandardFileReply *reply, char *prompt); /* Ask user for file, with prompt */ - -int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */ -PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */ - -PyObject *PyMac_BuildNumVersion(NumVersion); /* Convert NumVersion to PyObject */ - -int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ -PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ - -int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ -PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ - -int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ -PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ - -int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ -PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ - -int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for EventRecord */ -PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to PyObject */ - -int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ -PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ -void PyMac_InitApplet(void); /* Initialize and run an Applet */ diff --git a/Mac/Include/pythonresources.h b/Mac/Include/pythonresources.h deleted file mode 100644 index 93e046be6d..0000000000 --- a/Mac/Include/pythonresources.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -** Resource-IDs in use by Python. -** -** All resources used by the python interpreter itself fall -** in the range 128-256. -** -** Standard python modules use resources in the range -** 256-512. -** -** Python programs that use their own resources are advised to -** choose resource numbers higher than 512. -*/ - -/* -** Resources that reside in the python executable (or, for -** shared ppc python, in the core dynamic library) -*/ - -/* The alert for "No Python directory, where is it?" (OBSOLETE) */ -#define NOPYTHON_ALERT 128 -#define YES_ITEM 1 -#define NO_ITEM 2 -#define CURWD_ITEM 3 - -/* The alert for "this is an applet template" */ -#define NOPYC_ALERT 129 - -/* The dialog for our GetDirectory and PromptGetFile call */ -#define GETDIR_ID 130 /* Resource ID for our "get directory" */ -#define GETFILEPROMPT_ID 132 /* Resource id for prompted get file */ -#define PROMPT_ITEM 10 /* The prompt, at the top */ -#define SELECTCUR_ITEM 11 /* "Select current directory" button */ - - -/* The dialog for interactive options */ -#define OPT_DIALOG 131 /* Resource ID for dialog */ -#define OPT_OK 1 -#define OPT_CANCEL 2 -#define OPT_INSPECT 3 -#define OPT_VERBOSE 4 -#define OPT_SUPPRESS 5 -#define OPT_UNBUFFERED 6 -#define OPT_DEBUGGING 7 -#define OPT_KEEPNORMAL 8 -#define OPT_KEEPERROR 9 -#define OPT_CMDLINE 10 - -/* Dialog for 'No preferences directory' */ -#define NOPREFDIR_ID 133 - -/* Dialog for 'Create preferences file?' */ -#define NOPREFFILE_ID 134 -#define NOPREFFILE_YES 1 -#define NOPREFFILE_NO 2 - -/* Dialog for 'Bad preference file' */ -#define BADPREFFILE_ID 135 - -/* -** The following are valid both in the binary (or shared library) -** and in the Preferences file. -** For all three the override is tried first, through all current -** resource files. This allows an applet to override standard settings -** by providing a resource of the correct type. -*/ - -/* The STR# resource for sys.path initialization */ -#define PYTHONPATH_ID 128 -#define PYTHONPATHOVERRIDE_ID 129 - -/* The alis resource for locating the python home directory */ -#define PYTHONHOME_ID 128 -#define PYTHONHOMEOVERRIDE_ID 129 - -/* The Python options resource and offset of its members */ -#define PYTHONOPTIONS_ID 128 -#define PYTHONOPTIONSOVERRIDE_ID 129 -#define POPT_INSPECT 0 -#define POPT_VERBOSE 1 -#define POPT_SUPPRESS 2 -#define POPT_UNBUFFERED 3 -#define POPT_DEBUGGING 4 -#define POPT_KEEPNORM 5 -#define POPT_KEEPERR 6 - -/* From macgetpath.c: */ -void PyMac_PreferenceOptions Py_PROTO((int *inspect, int *verbose, int *suppress_print, - int *unbuffered, int *debugging, int *keep_normal, - int *keep_error)); - - diff --git a/Mac/Lib/Audio_mac.py b/Mac/Lib/Audio_mac.py deleted file mode 100644 index 450cdf12f3..0000000000 --- a/Mac/Lib/Audio_mac.py +++ /dev/null @@ -1,121 +0,0 @@ -QSIZE = 100000 -error='Audio_mac.error' - -class Play_Audio_mac: - - def __init__(self, qsize=QSIZE): - self._chan = None - self._qsize = qsize - self._outrate = 22254 - self._sampwidth = 1 - self._nchannels = 1 - self._gc = [] - self._usercallback = None - - def __del__(self): - self.stop() - self._usercallback = None - - def wait(self): - import time - while self.getfilled(): - time.sleep(0.1) - self._chan = None - self._gc = [] - - def stop(self, quietNow = 1): - ##chan = self._chan - self._chan = None - ##chan.SndDisposeChannel(1) - self._gc = [] - - def setoutrate(self, outrate): - self._outrate = outrate - - def setsampwidth(self, sampwidth): - self._sampwidth = sampwidth - - def setnchannels(self, nchannels): - self._nchannels = nchannels - - def writeframes(self, data): - import time - from Sound import * - import struct - if not self._chan: - import Snd - self._chan = Snd.SndNewChannel(5, 0, self._callback) - nframes = len(data) / self._nchannels / self._sampwidth - if len(data) != nframes * self._nchannels * self._sampwidth: - raise error, 'data is not a whole number of frames' - while self._gc and \ - self.getfilled() + nframes > \ - self._qsize / self._nchannels / self._sampwidth: - time.sleep(0.1) - if self._sampwidth == 1: - import audioop - data = audioop.add(data, '\x80'*len(data), 1) - h1 = struct.pack('llhhllbbl', - id(data)+12, - self._nchannels, - self._outrate, 0, - 0, - 0, - extSH, - 60, - nframes) - h2 = 22*'\0' - h3 = struct.pack('hhlll', - self._sampwidth*8, - 0, - 0, - 0, - 0) - header = h1+h2+h3 - self._gc.append((header, data)) - self._chan.SndDoCommand((bufferCmd, 0, header), 0) - self._chan.SndDoCommand((callBackCmd, 0, 0), 0) - - def _callback(self, *args): - del self._gc[0] - if self._usercallback: - self._usercallback() - - def setcallback(self, callback): - self._usercallback = callback - - def getfilled(self): - filled = 0 - for header, data in self._gc: - filled = filled + len(data) - return filled / self._nchannels / self._sampwidth - - def getfillable(self): - return (self._qsize / self._nchannels / self._sampwidth) - self.getfilled() - - def ulaw2lin(self, data): - import audioop - return audioop.ulaw2lin(data, 2) - -def test(): - import aifc - import macfs - fss, ok = macfs.PromptGetFile("Select an AIFF soundfile", "AIFF") - if not ok: return - fn = fss.as_pathname() - af = aifc.open(fn, 'r') - print af.getparams() - p = Play_Audio_mac() - p.setoutrate(af.getframerate()) - p.setsampwidth(af.getsampwidth()) - p.setnchannels(af.getnchannels()) - BUFSIZ = 10000 - while 1: - data = af.readframes(BUFSIZ) - if not data: break - p.writeframes(data) - print 'wrote', len(data), 'space', p.getfillable() - p.wait() - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/EasyDialogs.py b/Mac/Lib/EasyDialogs.py deleted file mode 100644 index 1854b69d8e..0000000000 --- a/Mac/Lib/EasyDialogs.py +++ /dev/null @@ -1,173 +0,0 @@ -"""Easy to use dialogs. - -Message(msg) -- display a message and an OK button. -AskString(prompt, default) -- ask for a string, display OK and Cancel buttons. -AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons. -bar = Progress(label, maxvalue) -- Display a progress bar -bar.set(value) -- Set value - -More documentation in each function. -This module uses DLOG resources 256, 257 and 258. -Based upon STDWIN dialogs with the same names and functions. -""" - -from Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog -import Qd -import QuickDraw - - -def Message(msg): - """Display a MESSAGE string. - - Return when the user clicks the OK button or presses Return. - - The MESSAGE string can be at most 255 characters long. - """ - - id = 256 - d = GetNewDialog(id, -1) - if not d: - print "Can't get DLOG resource with id =", id - return - tp, h, rect = d.GetDialogItem(2) - SetDialogItemText(h, msg) - d.SetDialogDefaultItem(1) - while 1: - n = ModalDialog(None) - if n == 1: - return - - -def AskString(prompt, default = ""): - """Display a PROMPT string and a text entry field with a DEFAULT string. - - Return the contents of the text entry field when the user clicks the - OK button or presses Return. - Return None when the user clicks the Cancel button. - - If omitted, DEFAULT is empty. - - The PROMPT and DEFAULT strings, as well as the return value, - can be at most 255 characters long. - """ - - id = 257 - d = GetNewDialog(id, -1) - if not d: - print "Can't get DLOG resource with id =", id - return - tp, h, rect = d.GetDialogItem(3) - SetDialogItemText(h, prompt) - tp, h, rect = d.GetDialogItem(4) - SetDialogItemText(h, default) -# d.SetDialogItem(4, 0, 255) - d.SetDialogDefaultItem(1) - d.SetDialogCancelItem(2) - while 1: - n = ModalDialog(None) - if n == 1: - tp, h, rect = d.GetDialogItem(4) - return GetDialogItemText(h) - if n == 2: return None - - -def AskYesNoCancel(question, default = 0): -## """Display a QUESTION string which can be answered with Yes or No. -## -## Return 1 when the user clicks the Yes button. -## Return 0 when the user clicks the No button. -## Return -1 when the user clicks the Cancel button. -## -## When the user presses Return, the DEFAULT value is returned. -## If omitted, this is 0 (No). -## -## The QUESTION strign ca be at most 255 characters. -## """ - - id = 258 - d = GetNewDialog(id, -1) - if not d: - print "Can't get DLOG resource with id =", id - return - # Button assignments: - # 1 = default (invisible) - # 2 = Yes - # 3 = No - # 4 = Cancel - # The question string is item 5 - tp, h, rect = d.GetDialogItem(5) - SetDialogItemText(h, question) - d.SetDialogCancelItem(4) - if default == 1: - d.SetDialogDefaultItem(2) - elif default == 0: - d.SetDialogDefaultItem(3) - elif default == -1: - d.SetDialogDefaultItem(4) - while 1: - n = ModalDialog(None) - if n == 1: return default - if n == 2: return 1 - if n == 3: return 0 - if n == 4: return -1 - -class ProgressBar: - def __init__(self, label="Working...", maxval=100): - self.label = label - self.maxval = maxval - self.curval = -1 - self.d = GetNewDialog(259, -1) - tp, text_h, rect = self.d.GetDialogItem(2) - SetDialogItemText(text_h, "Progress...") - self._update(0) - - def _update(self, value): - tp, h, bar_rect = self.d.GetDialogItem(3) - Qd.SetPort(self.d) - - Qd.FrameRect(bar_rect) # Draw outline - - inner_rect = Qd.InsetRect(bar_rect, 1, 1) - Qd.ForeColor(QuickDraw.whiteColor) - Qd.BackColor(QuickDraw.whiteColor) - Qd.PaintRect(inner_rect) # Clear internal - - l, t, r, b = inner_rect - r = int(l + (r-l)*value/self.maxval) - inner_rect = l, t, r, b - Qd.ForeColor(QuickDraw.blackColor) - Qd.BackColor(QuickDraw.blackColor) - Qd.PaintRect(inner_rect) # Draw bar - - # Restore settings - Qd.ForeColor(QuickDraw.blackColor) - Qd.BackColor(QuickDraw.whiteColor) - - # Test for cancel button - if ModalDialog(self._filterfunc) == 1: - raise KeyboardInterrupt - - def _filterfunc(self, d, e, *more): - return 2 # XXXX For now, this disables the cancel button - - def set(self, value): - if value < 0: value = 0 - if value > self.maxval: value = self.maxval - self._update(value) - - - -def test(): - Message("Testing EasyDialogs.") - ok = AskYesNoCancel("Do you want to proceed?") - if ok > 0: - s = AskString("Enter your first name") - Message("Thank you,\015%s" % `s`) - bar = ProgressBar("Counting...", 100) - for i in range(100): - bar.set(i) - del bar - - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/FrameWork.py b/Mac/Lib/FrameWork.py deleted file mode 100644 index 8663d1f699..0000000000 --- a/Mac/Lib/FrameWork.py +++ /dev/null @@ -1,857 +0,0 @@ -"A sort of application framework for the Mac" - -DEBUG=0 - -import MacOS -import traceback - -from AE import * -from AppleEvents import * -from Ctl import * -from Controls import * -from Dlg import * -from Dialogs import * -from Evt import * -from Events import * -from Menu import * -from Menus import * -from Qd import * -from QuickDraw import * -#from Res import * -#from Resources import * -#from Snd import * -#from Sound import * -from Win import * -from Windows import * - -import EasyDialogs - -kHighLevelEvent = 23 # Don't know what header file this should come from -SCROLLBARWIDTH = 16 # Again, not a clue... - - -# Map event 'what' field to strings -eventname = {} -eventname[1] = 'mouseDown' -eventname[2] = 'mouseUp' -eventname[3] = 'keyDown' -eventname[4] = 'keyUp' -eventname[5] = 'autoKey' -eventname[6] = 'updateEvt' -eventname[7] = 'diskEvt' -eventname[8] = 'activateEvt' -eventname[15] = 'osEvt' -eventname[23] = 'kHighLevelEvent' - -# Map part codes returned by WhichWindow() to strings -partname = {} -partname[0] = 'inDesk' -partname[1] = 'inMenuBar' -partname[2] = 'inSysWindow' -partname[3] = 'inContent' -partname[4] = 'inDrag' -partname[5] = 'inGrow' -partname[6] = 'inGoAway' -partname[7] = 'inZoomIn' -partname[8] = 'inZoomOut' - -# -# The useable portion of the screen -# ## but what happens with multiple screens? jvr -screenbounds = qd.screenBits.bounds -screenbounds = screenbounds[0]+4, screenbounds[1]+4, \ - screenbounds[2]-4, screenbounds[3]-4 - -next_window_x = 16 # jvr -next_window_y = 44 # jvr - -def windowbounds(width, height): - "Return sensible window bounds" - global next_window_x, next_window_y - r, b = next_window_x+width, next_window_y+height - if r > screenbounds[2]: - next_window_x = 16 - if b > screenbounds[3]: - next_window_y = 44 - l, t = next_window_x, next_window_y - r, b = next_window_x+width, next_window_y+height - next_window_x, next_window_y = next_window_x + 8, next_window_y + 20 # jvr - return l, t, r, b - - -class Application: - - "Application framework -- your application should be a derived class" - - def __init__(self): - self._windows = {} - self.makemenubar() - - def makemenubar(self): - self.menubar = MenuBar() - AppleMenu(self.menubar, self.getabouttext(), self.do_about) - self.makeusermenus() - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self._quititem = MenuItem(m, "Quit", "Q", self._quit) - - def _quit(self, *args): - raise self - - def appendwindow(self, wid, window): - self._windows[wid] = window - - def removewindow(self, wid): - del self._windows[wid] - - def getabouttext(self): - return "About %s..." % self.__class__.__name__ - - def do_about(self, id, item, window, event): - EasyDialogs.Message("Hello, world!" + "\015(%s)" % self.__class__.__name__) - - # The main event loop is broken up in several simple steps. - # This is done so you can override each individual part, - # if you have a need to do extra processing independent of the - # event type. - # Normally, however, you'd just define handlers for individual - # events. - # (XXX I'm not sure if using default parameter values is the right - # way to define the mask and wait time passed to WaitNextEvent.) - - def mainloop(self, mask = everyEvent, wait = 0): - saveyield = MacOS.EnableAppswitch(self.yield) - try: - while 1: - try: - self.do1event(mask, wait) - except (Application, SystemExit): - break - finally: - MacOS.EnableAppswitch(saveyield) - - yield = -1 - - def do1event(self, mask = everyEvent, wait = 0): - ok, event = self.getevent(mask, wait) - if IsDialogEvent(event): - if self.do_dialogevent(event): - return - if ok: - self.dispatch(event) - else: - self.idle(event) - - def idle(self, event): - pass - - def getevent(self, mask = everyEvent, wait = 0): - ok, event = WaitNextEvent(mask, wait) - return ok, event - - def dispatch(self, event): - (what, message, when, where, modifiers) = event - if eventname.has_key(what): - name = "do_" + eventname[what] - else: - name = "do_%d" % what - try: - handler = getattr(self, name) - except AttributeError: - handler = self.do_unknownevent - handler(event) - - def do_dialogevent(self, event): - gotone, window, item = DialogSelect(event) - if gotone: - if self._windows.has_key(window): - self._windows[window].do_itemhit(item, event) - else: - print 'Dialog event for unknown dialog' - return 1 - return 0 - - def do_mouseDown(self, event): - (what, message, when, where, modifiers) = event - partcode, wid = FindWindow(where) - - # - # Find the correct name. - # - if partname.has_key(partcode): - name = "do_" + partname[partcode] - else: - name = "do_%d" % partcode - - if wid == None: - # No window, or a non-python window - try: - handler = getattr(self, name) - except AttributeError: - # Not menubar or something, so assume someone - # else's window - MacOS.HandleEvent(event) - return - elif self._windows.has_key(wid): - # It is a window. Hand off to correct window. - window = self._windows[wid] - try: - handler = getattr(window, name) - except AttributeError: - handler = self.do_unknownpartcode - else: - # It is a python-toolbox window, but not ours. - handler = self.do_unknownwindow - handler(partcode, wid, event) - - def do_inSysWindow(self, partcode, window, event): - MacOS.HandleEvent(event) - - def do_inDesk(self, partcode, window, event): - MacOS.HandleEvent(event) - - def do_inMenuBar(self, partcode, window, event): - (what, message, when, where, modifiers) = event - result = MenuSelect(where) - id = (result>>16) & 0xffff # Hi word - item = result & 0xffff # Lo word - self.do_rawmenu(id, item, window, event) - - def do_rawmenu(self, id, item, window, event): - try: - self.do_menu(id, item, window, event) - finally: - HiliteMenu(0) - - def do_menu(self, id, item, window, event): - self.menubar.dispatch(id, item, window, event) - - - def do_unknownpartcode(self, partcode, window, event): - (what, message, when, where, modifiers) = event - if DEBUG: print "Mouse down at global:", where - if DEBUG: print "\tUnknown part code:", partcode - if DEBUG: print "\tEvent:", self.printevent(event) - MacOS.HandleEvent(event) - - def do_unknownwindow(self, partcode, window, event): - if DEBUG: print 'Unknown window:', window - MacOS.HandleEvent(event) - - def do_keyDown(self, event): - self.do_key(event) - - def do_autoKey(self, event): - if not event[-1] & cmdKey: - self.do_key(event) - - def do_key(self, event): - (what, message, when, where, modifiers) = event - c = chr(message & charCodeMask) - if modifiers & cmdKey: - if c == '.': - raise self - else: - result = MenuKey(ord(c)) - id = (result>>16) & 0xffff # Hi word - item = result & 0xffff # Lo word - if id: - self.do_rawmenu(id, item, None, event) -# elif c == 'w': -# w = FrontWindow() -# if w: -# self.do_close(w) -# else: -# if DEBUG: print 'Command-W without front window' - else: - if DEBUG: print "Command-" +`c` - else: - # See whether the front window wants it - w = FrontWindow() - if w and self._windows.has_key(w): - window = self._windows[w] - try: - do_char = window.do_char - except AttributeError: - do_char = self.do_char - do_char(c, event) - # else it wasn't for us, sigh... - - def do_char(self, c, event): - if DEBUG: print "Character", `c` - - def do_updateEvt(self, event): - (what, message, when, where, modifiers) = event - wid = WhichWindow(message) - if wid and self._windows.has_key(wid): - window = self._windows[wid] - window.do_rawupdate(wid, event) - else: - MacOS.HandleEvent(event) - - def do_activateEvt(self, event): - (what, message, when, where, modifiers) = event - # XXXX Incorrect, should be fixed in suspendresume - if type(message) == type(1): - wid = WhichWindow(message) - else: - wid = message - if wid and self._windows.has_key(wid): - window = self._windows[wid] - window.do_activate(modifiers & 1, event) - else: - MacOS.HandleEvent(event) - - def do_osEvt(self, event): - (what, message, when, where, modifiers) = event - which = (message >> 24) & 0xff - if which == 1: # suspend/resume - self.do_suspendresume(event) - else: - if DEBUG: - print 'unknown osEvt:', - self.printevent(event) - - def do_suspendresume(self, event): - # Is this a good idea??? - (what, message, when, where, modifiers) = event - w = FrontWindow() - if w: - # XXXX Incorrect, should stuff windowptr into message field - nev = (activateEvt, w, when, where, message&1) - self.do_activateEvt(nev) - - def do_kHighLevelEvent(self, event): - (what, message, when, where, modifiers) = event - if DEBUG: - print "High Level Event:", - self.printevent(event) - try: - AEProcessAppleEvent(event) - except: - print "AEProcessAppleEvent error:" - traceback.print_exc() - - def do_unknownevent(self, event): - if DEBUG: - print "Unhandled event:", - self.printevent(event) - - def printevent(self, event): - (what, message, when, where, modifiers) = event - nicewhat = `what` - if eventname.has_key(what): - nicewhat = eventname[what] - print nicewhat, - if what == kHighLevelEvent: - h, v = where - print `ostypecode(message)`, hex(when), `ostypecode(h | (v<<16))`, - else: - print hex(message), hex(when), where, - print hex(modifiers) - - -class MenuBar: - """Represent a set of menus in a menu bar. - - Interface: - - - (constructor) - - (destructor) - - addmenu - - addpopup (normally used internally) - - dispatch (called from Application) - """ - - nextid = 1 # Necessarily a class variable - - def getnextid(self): - id = self.nextid - self.nextid = id+1 - return id - - def __init__(self): - ClearMenuBar() - self.bar = GetMenuBar() - self.menus = {} - - def addmenu(self, title, after = 0): - id = self.getnextid() - if DEBUG: print 'Newmenu', title, id # XXXX - m = NewMenu(id, title) - m.InsertMenu(after) - DrawMenuBar() # XXX appears slow! better do this when we're done. jvr - return id, m - - def delmenu(self, id): - if DEBUG: print 'Delmenu', id # XXXX - DeleteMenu(id) - - def addpopup(self, title = ''): - return self.addmenu(title, -1) - - def install(self): - self.bar.SetMenuBar() - DrawMenuBar() - - def dispatch(self, id, item, window, event): - if self.menus.has_key(id): - self.menus[id].dispatch(id, item, window, event) - else: - if DEBUG: print "MenuBar.dispatch(%d, %d, %s, %s)" % \ - (id, item, window, event) - - -# XXX Need a way to get menus as resources and bind them to callbacks - -class Menu: - "One menu." - - def __init__(self, bar, title, after=0): - self.bar = bar - self.id, self.menu = self.bar.addmenu(title, after) - bar.menus[self.id] = self - self.items = [] - - def delete(self): - self.bar.delmenu(self.id) - del self.bar.menus[self.id] - del self.bar - del self.items - del self.menu - del self.id - - def additem(self, label, shortcut=None, callback=None, kind=None): - self.menu.AppendMenu('x') # add a dummy string - self.items.append(label, shortcut, callback, kind) - item = len(self.items) - self.menu.SetMenuItemText(item, label) # set the actual text - if shortcut: - self.menu.SetItemCmd(item, ord(shortcut)) - return item - - def addcheck(self, label, shortcut=None, callback=None): - return self.additem(label, shortcut, callback, 'check') - - def addradio(self, label, shortcut=None, callback=None): - return self.additem(label, shortcut, callback, 'radio') - - def addseparator(self): - self.menu.AppendMenu('(-') - self.items.append('', None, None, 'separator') - - def addsubmenu(self, label, title=''): - sub = Menu(self.bar, title, -1) - item = self.additem(label, '\x1B', None, 'submenu') - self.menu.SetItemMark(item, sub.id) - return sub - - def dispatch(self, id, item, window, event): - title, shortcut, callback, type = self.items[item-1] - if callback: - callback(id, item, window, event) - - def enable(self, onoff): - if onoff: - self.menu.EnableItem(0) - else: - self.menu.DisableItem(0) - -class MenuItem: - def __init__(self, menu, title, shortcut=None, callback=None, kind=None): - self.item = menu.additem(title, shortcut, callback) - self.menu = menu - - def check(self, onoff): - self.menu.menu.CheckItem(self.item, onoff) - - def enable(self, onoff): - if onoff: - self.menu.menu.EnableItem(self.item) - else: - self.menu.menu.DisableItem(self.item) - - def settext(self, text): - self.menu.menu.SetMenuItemText(self.item, text) - - def setstyle(self, style): - self.menu.menu.SetItemStyle(self.item, style) - - def seticon(self, icon): - self.menu.menu.SetItemIcon(self.item, icon) - - def setcmd(self, cmd): - self.menu.menu.SetItemCmd(self.item, cmd) - - def setmark(self, cmd): - self.menu.menu.SetItemMark(self.item, cmd) - - -class RadioItem(MenuItem): - def __init__(self, menu, title, shortcut=None, callback=None): - MenuItem.__init__(self, menu, title, shortcut, callback, 'radio') - -class CheckItem(MenuItem): - def __init__(self, menu, title, shortcut=None, callback=None): - MenuItem.__init__(self, menu, title, shortcut, callback, 'check') - -def Separator(menu): - menu.addseparator() - -def SubMenu(menu, label, title=''): - return menu.addsubmenu(label, title) - - -class AppleMenu(Menu): - - def __init__(self, bar, abouttext="About me...", aboutcallback=None): - Menu.__init__(self, bar, "\024") - self.additem(abouttext, None, aboutcallback) - self.addseparator() - self.menu.AppendResMenu('DRVR') - - def dispatch(self, id, item, window, event): - if item == 1: - Menu.dispatch(self, id, item, window, event) - else: - name = self.menu.GetMenuItemText(item) - OpenDeskAcc(name) - -class Window: - """A single window belonging to an application""" - - def __init__(self, parent): - self.wid = None - self.parent = parent - - def open(self, bounds=(40, 40, 400, 400), resid=None): - if resid <> None: - self.wid = GetNewWindow(resid, -1) - else: - self.wid = NewWindow(bounds, self.__class__.__name__, 1, - 8, -1, 1, 0) # changed to proc id 8 to include zoom box. jvr - self.do_postopen() - - def do_postopen(self): - """Tell our parent we exist""" - self.parent.appendwindow(self.wid, self) - - def close(self): - self.do_postclose() - - def do_postclose(self): - self.parent.removewindow(self.wid) - self.parent = None - self.wid = None - - def SetPort(self): - # Convinience method - SetPort(self.wid) - - def do_inDrag(self, partcode, window, event): - where = event[3] - window.DragWindow(where, self.draglimit) - - draglimit = screenbounds - - def do_inGoAway(self, partcode, window, event): - where = event[3] - if window.TrackGoAway(where): - self.close() - - def do_inZoom(self, partcode, window, event): - (what, message, when, where, modifiers) = event - if window.TrackBox(where, partcode): - window.ZoomWindow(partcode, 1) - rect = window.GetWindowUserState() # so that zoom really works... jvr - self.do_postresize(rect[2] - rect[0], rect[3] - rect[1], window) # jvr - - def do_inZoomIn(self, partcode, window, event): - SetPort(window) # !!! - self.do_inZoom(partcode, window, event) - - def do_inZoomOut(self, partcode, window, event): - SetPort(window) # !!! - self.do_inZoom(partcode, window, event) - - def do_inGrow(self, partcode, window, event): - (what, message, when, where, modifiers) = event - result = window.GrowWindow(where, self.growlimit) - if result: - height = (result>>16) & 0xffff # Hi word - width = result & 0xffff # Lo word - self.do_resize(width, height, window) - - growlimit = (50, 50, screenbounds[2] - screenbounds[0], screenbounds[3] - screenbounds[1]) # jvr - - def do_resize(self, width, height, window): - l, t, r, b = self.wid.GetWindowPort().portRect # jvr, forGrowIcon - self.SetPort() # jvr - InvalRect((r - SCROLLBARWIDTH + 1, b - SCROLLBARWIDTH + 1, r, b)) # jvr - window.SizeWindow(width, height, 1) # changed updateFlag to true jvr - self.do_postresize(width, height, window) - - def do_postresize(self, width, height, window): - SetPort(window) - InvalRect(window.GetWindowPort().portRect) - - def do_inContent(self, partcode, window, event): - # - # If we're not frontmost, select ourselves and wait for - # the activate event. - # - if FrontWindow() <> window: - window.SelectWindow() - return - # We are. Handle the event. - (what, message, when, where, modifiers) = event - SetPort(window) - local = GlobalToLocal(where) - self.do_contentclick(local, modifiers, event) - - def do_contentclick(self, local, modifiers, event): - if DEBUG: - print 'Click in contents at %s, modifiers %s'%(local, modifiers) - - def do_rawupdate(self, window, event): - if DEBUG: print "raw update for", window - SetPort(window) - window.BeginUpdate() - self.do_update(window, event) - window.EndUpdate() - - def do_update(self, window, event): - if DEBUG: - import time - for i in range(8): - time.sleep(0.1) - InvertRgn(window.GetWindowPort().visRgn) - FillRgn(window.GetWindowPort().visRgn, qd.gray) - else: - EraseRgn(window.GetWindowPort().visRgn) - - def do_activate(self, activate, event): - if DEBUG: print 'Activate %d for %s'%(activate, self.wid) - -class ControlsWindow(Window): - - def do_rawupdate(self, window, event): - if DEBUG: print "raw update for", window - SetPort(window) - window.BeginUpdate() - self.do_update(window, event) - #DrawControls(window) # jvr - UpdateControls(window, window.GetWindowPort().visRgn) # jvr - window.DrawGrowIcon() - window.EndUpdate() - - def do_controlhit(self, window, control, pcode, event): - if DEBUG: print "control hit in", window, "on", control, "; pcode =", pcode - - def do_inContent(self, partcode, window, event): - if FrontWindow() <> window: - window.SelectWindow() - return - (what, message, when, where, modifiers) = event - SetPort(window) # XXXX Needed? - local = GlobalToLocal(where) - ctltype, control = FindControl(local, window) - if ctltype and control: - pcode = control.TrackControl(local) - if pcode: - self.do_controlhit(window, control, pcode, event) - else: - if DEBUG: print "FindControl(%s, %s) -> (%s, %s)" % \ - (local, window, ctltype, control) - self.do_contentclick(local, modifiers, event) - -class ScrolledWindow(ControlsWindow): - def __init__(self, parent): - self.barx = self.bary = None - self.barx_enabled = self.bary_enabled = 1 - self.activated = 1 - ControlsWindow.__init__(self, parent) - - def scrollbars(self, wantx=1, wanty=1): - SetPort(self.wid) - self.barx = self.bary = None - self.barx_enabled = self.bary_enabled = 1 - x0, y0, x1, y1 = self.wid.GetWindowPort().portRect - vx, vy = self.getscrollbarvalues() - if vx == None: self.barx_enabled, vx = 0, 0 - if vy == None: self.bary_enabled, vy = 0, 0 - if wantx: - rect = x0-1, y1-(SCROLLBARWIDTH-1), x1-(SCROLLBARWIDTH-2), y1+1 - self.barx = NewControl(self.wid, rect, "", 1, vx, 0, 32767, 16, 0) - if not self.barx_enabled: self.barx.HiliteControl(255) -## InvalRect(rect) - if wanty: - rect = x1-(SCROLLBARWIDTH-1), y0-1, x1+1, y1-(SCROLLBARWIDTH-2) - self.bary = NewControl(self.wid, rect, "", 1, vy, 0, 32767, 16, 0) - if not self.bary_enabled: self.bary.HiliteControl(255) -## InvalRect(rect) - - def do_postclose(self): - self.barx = self.bary = None - ControlsWindow.do_postclose(self) - - def do_activate(self, onoff, event): - self.activated = onoff - if onoff: - if self.barx and self.barx_enabled: - self.barx.ShowControl() # jvr - if self.bary and self.bary_enabled: - self.bary.ShowControl() # jvr - else: - if self.barx: - self.barx.HideControl() # jvr; An inactive window should have *hidden* - # scrollbars, not just dimmed (no matter what - # BBEdit does... look at the Finder) - if self.bary: - self.bary.HideControl() # jvr - self.wid.DrawGrowIcon() # jvr - - def do_postresize(self, width, height, window): - l, t, r, b = self.wid.GetWindowPort().portRect - self.SetPort() - if self.barx: - self.barx.HideControl() # jvr - self.barx.MoveControl(l-1, b-(SCROLLBARWIDTH-1)) - self.barx.SizeControl((r-l)-(SCROLLBARWIDTH-3), SCROLLBARWIDTH) # jvr - if self.bary: - self.bary.HideControl() # jvr - self.bary.MoveControl(r-(SCROLLBARWIDTH-1), t-1) - self.bary.SizeControl(SCROLLBARWIDTH, (b-t)-(SCROLLBARWIDTH-3)) # jvr - if self.barx: - self.barx.ShowControl() # jvr - ValidRect((l, b - SCROLLBARWIDTH + 1, r - SCROLLBARWIDTH + 2, b)) # jvr - if self.bary: - self.bary.ShowControl() # jvr - ValidRect((r - SCROLLBARWIDTH + 1, t, r, b - SCROLLBARWIDTH + 2)) # jvr - InvalRect((r - SCROLLBARWIDTH + 1, b - SCROLLBARWIDTH + 1, r, b)) # jvr, growicon - - def do_controlhit(self, window, control, pcode, event): - if control == self.barx: - bar = self.barx - which = 'x' - elif control == self.bary: - bar = self.bary - which = 'y' - else: - return 0 - value = None - if pcode == inUpButton: - what = '-' - elif pcode == inDownButton: - what = '+' - elif pcode == inPageUp: - what = '--' - elif pcode == inPageDown: - what = '++' - else: - what = 'set' - value = bar.GetControlValue() - self.scrollbar_callback(which, what, value) - self.updatescrollbars() - return 1 - - def updatescrollbars(self): - SetPort(self.wid) - vx, vy = self.getscrollbarvalues() - if self.barx: - if vx == None: - self.barx.HiliteControl(255) - self.barx_enabled = 0 - else: - if not self.barx_enabled: - self.barx_enabled = 1 - if self.activated: - self.barx.HiliteControl(0) - self.barx.SetControlValue(vx) - if self.bary: - if vy == None: - self.bary.HiliteControl(255) - self.bary_enabled = 0 - else: - if not self.bary_enabled: - self.bary_enabled = 1 - if self.activated: - self.bary.HiliteControl(0) - self.bary.SetControlValue(vy) - - # Auxiliary function: convert standard text/image/etc coordinate - # to something palatable as getscrollbarvalues() return - def scalebarvalue(self, absmin, absmax, curmin, curmax): - if curmin <= absmin and curmax >= absmax: - return None - if curmin <= absmin: - return 0 - if curmax >= absmax: - return 32767 - perc = float(curmin-absmin)/float(absmax-absmin) - return int(perc*32767) - - # To be overridden: - - def getscrollbarvalues(self): - return 0, 0 - - def scrollbar_callback(self, which, what, value): - print 'scroll', which, what, value - -class DialogWindow(Window): - """A modeless dialog window""" - - def open(self, resid): - self.wid = GetNewDialog(resid, -1) - self.do_postopen() - - def close(self): - self.do_postclose() - - def do_itemhit(self, item, event): - print 'Dialog %s, item %d hit'%(self.wid, item) - - def do_rawupdate(self, window, event): - pass - -def ostypecode(x): - "Convert a long int to the 4-character code it really is" - s = '' - for i in range(4): - x, c = divmod(x, 256) - s = chr(c) + s - return s - - -class TestApp(Application): - - "This class is used by the test() function" - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.saveitem = MenuItem(m, "Save", "S", self.save) - Separator(m) - self.optionsmenu = mm = SubMenu(m, "Options") - self.opt1 = CheckItem(mm, "Arguments") - self.opt2 = CheckItem(mm, "Being hit on the head lessons") - self.opt3 = CheckItem(mm, "Complaints") - Separator(m) - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - def save(self, *args): - print "Save" - - def quit(self, *args): - raise self - - -def test(): - "Test program" - app = TestApp() - app.mainloop() - - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/MACFS.py b/Mac/Lib/MACFS.py deleted file mode 100644 index 132db37905..0000000000 --- a/Mac/Lib/MACFS.py +++ /dev/null @@ -1,30 +0,0 @@ -# MACFS.py - Constants used by macfs routines -# Derived from Finder.h and Folders.h - -# Flags in FInfo.Flags field: -kIsOnDesk = 0x1 -kColor = 0xE -kIsShared = 0x40 -kHasBeenInited = 0x100 -kHasCustomIcon = 0x400 -kIsStationery = 0x800 -kIsStationary = 0x800 -kNameLocked = 0x1000 -kHasBundle = 0x2000 -kIsInvisible = 0x4000 -kIsAlias = 0x8000 - -# Constants for FindFolder -kOnSystemDisk = 0x8000 -kSystemFolderType = 'macs' # the system folder -kDesktopFolderType = 'desk' # the desktop folder; objects in this folder show on the desk top. -kTrashFolderType = 'trsh' # the trash folder; objects in this folder show up in the trash -kWhereToEmptyTrashFolderType = 'empt' # the "empty trash" folder; Finder starts empty from here down -kPrintMonitorDocsFolderType = 'prnt' # Print Monitor documents -kStartupFolderType = 'strt' # Finder objects (applications, documents, DAs, aliases, to...) to open at startup go here -kAppleMenuFolderType = 'amnu' # Finder objects to put into the Apple menu go here -kControlPanelFolderType = 'ctrl' # Control Panels go here (may contain INITs) -kExtensionFolderType = 'extn' # Finder extensions go here -kFontsFolderType = 'font' # Fonts go here -kPreferencesFolderType = 'pref' # preferences for applications go here -kTemporaryFolderType = 'temp' diff --git a/Mac/Lib/SoundMgr.py b/Mac/Lib/SoundMgr.py deleted file mode 100644 index dcd8606879..0000000000 --- a/Mac/Lib/SoundMgr.py +++ /dev/null @@ -1,64 +0,0 @@ -#Constants for the MacOS Sound Manager - -nullCmd = 0 -initCmd = 1 -freeCmd = 2 -quietCmd = 3 -flushCmd = 4 -reInitCmd = 5 - -waitCmd = 10 -pauseCmd = 11 -resumeCmd = 12 -callBackCmd = 13 - -syncCmd = 14 -emptyCmd = 15 - -tickleCmd = 20 -requestNextCmd = 21 -howOftenCmd = 22 -wakeUpCmd = 23 -availableCmd = 24 -versionCmd = 25 -totalLoadCmd = 26 -loadCmd = 27 - -scaleCmd = 30 -tempoCmd = 31 - -freqDurationCmd = 40 -restCmd = 41 -freqCmd = 42 -ampCmd = 43 -timbreCmd = 44 -getAmpCmd = 45 - -waveTableCmd = 60 -phaseCmd = 61 - -soundCmd = 80 -bufferCmd = 81 -rateCmd = 82 -continueCmd = 83 -doubleBufferCmd = 84 -getRateCmd = 85 - -sizeCmd = 90 -convertCmd = 91 - -stdQLength = 128 -dataOffsetFlag = 0x8000 - -waveInitChannelMask = 0x07 -waveInitChannel0 = 0x04 -waveInitChannel1 = 0x05 -waveInitChannel2 = 0x06 -waveInitChannel3 = 0x07 - -stdSH = 0x00 # Standard sound header encode value -extSH = 0xFF # Extended sound header encode value -cmpSH = 0xFE # Compressed sound header encode value - -initSRate22k = 0x20 # 22k sampling rate - sampleSynth only -initSRate44k = 0x30 # 44k sampling rate - sampleSynth only diff --git a/Mac/Lib/audiodev.py b/Mac/Lib/audiodev.py deleted file mode 100644 index adfeb96a55..0000000000 --- a/Mac/Lib/audiodev.py +++ /dev/null @@ -1,241 +0,0 @@ -error = 'audiodev.error' - -class Play_Audio_sgi: - # Private instance variables - access frameratelist, nchannelslist, sampwidthlist, oldparams, \ - params, config, inited_outrate, inited_width, \ - inited_nchannels, port, converter, classinited: private - - classinited = 0 - frameratelist = nchannelslist = sampwidthlist = None - - def initclass(self): - import AL - Play_Audio_sgi.frameratelist = [ - (48000, AL.RATE_48000), - (44100, AL.RATE_44100), - (32000, AL.RATE_32000), - (22050, AL.RATE_22050), - (16000, AL.RATE_16000), - (11025, AL.RATE_11025), - ( 8000, AL.RATE_8000), - ] - Play_Audio_sgi.nchannelslist = [ - (1, AL.MONO), - (2, AL.STEREO), - ] - Play_Audio_sgi.sampwidthlist = [ - (1, AL.SAMPLE_8), - (2, AL.SAMPLE_16), - (3, AL.SAMPLE_24), - ] - Play_Audio_sgi.classinited = 1 - - def __init__(self): - import al, AL - if not self.classinited: - self.initclass() - self.oldparams = [] - self.params = [AL.OUTPUT_RATE, 0] - self.config = al.newconfig() - self.inited_outrate = 0 - self.inited_width = 0 - self.inited_nchannels = 0 - self.converter = None - self.port = None - return - - def __del__(self): - if self.port: - self.stop() - if self.oldparams: - import al, AL - al.setparams(AL.DEFAULT_DEVICE, self.oldparams) - self.oldparams = [] - - def wait(self): - if not self.port: - return - import time - while self.port.getfilled() > 0: - time.sleep(0.1) - self.stop() - - def stop(self): - if self.port: - self.port.closeport() - self.port = None - if self.oldparams: - import al, AL - al.setparams(AL.DEFAULT_DEVICE, self.oldparams) - self.oldparams = [] - - def setoutrate(self, rate): - for (raw, cooked) in self.frameratelist: - if rate == raw: - self.params[1] = cooked - self.inited_outrate = 1 - break - else: - raise error, 'bad output rate' - - def setsampwidth(self, width): - for (raw, cooked) in self.sampwidthlist: - if width == raw: - self.config.setwidth(cooked) - self.inited_width = 1 - break - else: - if width == 0: - import AL - self.inited_width = 0 - self.config.setwidth(AL.SAMPLE_16) - self.converter = self.ulaw2lin - else: - raise error, 'bad sample width' - - def setnchannels(self, nchannels): - for (raw, cooked) in self.nchannelslist: - if nchannels == raw: - self.config.setchannels(cooked) - self.inited_nchannels = 1 - break - else: - raise error, 'bad # of channels' - - def writeframes(self, data): - if not (self.inited_outrate and self.inited_nchannels): - raise error, 'params not specified' - if not self.port: - import al, AL - self.port = al.openport('Python', 'w', self.config) - self.oldparams = self.params[:] - al.getparams(AL.DEFAULT_DEVICE, self.oldparams) - al.setparams(AL.DEFAULT_DEVICE, self.params) - if self.converter: - data = self.converter(data) - self.port.writesamps(data) - - def getfilled(self): - if self.port: - return self.port.getfilled() - else: - return 0 - - def getfillable(self): - if self.port: - return self.port.getfillable() - else: - return self.config.getqueuesize() - - # private methods - access *: private - - def ulaw2lin(self, data): - import audioop - return audioop.ulaw2lin(data, 2) - -class Play_Audio_sun: - access outrate, sampwidth, nchannels, inited_outrate, inited_width, \ - inited_nchannels, converter: private - - def __init__(self): - self.outrate = 0 - self.sampwidth = 0 - self.nchannels = 0 - self.inited_outrate = 0 - self.inited_width = 0 - self.inited_nchannels = 0 - self.converter = None - self.port = None - return - - def __del__(self): - self.stop() - - def setoutrate(self, rate): - self.outrate = rate - self.inited_outrate = 1 - - def setsampwidth(self, width): - self.sampwidth = width - self.inited_width = 1 - - def setnchannels(self, nchannels): - self.nchannels = nchannels - self.inited_nchannels = 1 - - def writeframes(self, data): - if not (self.inited_outrate and self.inited_width and self.inited_nchannels): - raise error, 'params not specified' - if not self.port: - import sunaudiodev, SUNAUDIODEV - self.port = sunaudiodev.open('w') - info = self.port.getinfo() - info.o_sample_rate = self.outrate - info.o_channels = self.nchannels - if self.sampwidth == 0: - info.o_precision = 8 - self.o_encoding = ENCODING_ULAW - else: - info.o_precision = 8 * self.sampwidth - info.o_encoding = SUNAUDIODEV.ENCODING_LINEAR - self.port.setinfo(info) - if self.converter: - data = self.converter(data) - self.port.write(data) - - def wait(self): - if not self.port: - return - self.port.drain() - self.stop() - - def stop(self): - if self.port: - self.port.flush() - self.port.close() - self.port = None - - def getfilled(self): - if self.port: - return self.port.obufcount() - else: - return 0 - - def getfillable(self): - return BUFFERSIZE - self.getfilled() - -def AudioDev(): - try: - import al - return Play_Audio_sgi() - except ImportError: - try: - import sunaudiodev - return Play_Audio_sun() - except ImportError: - try: - import Audio_mac - return Audio_mac.Play_Audio_mac() - except ImportError: - raise error, 'no audio device' - -def test(fn = 'f:just samples:just.aif'): - import aifc - af = aifc.open(fn, 'r') - print fn, af.getparams() - p = AudioDev() - p.setoutrate(af.getframerate()) - p.setsampwidth(af.getsampwidth()) - p.setnchannels(af.getnchannels()) - BUFSIZ = af.getframerate()/af.getsampwidth()/af.getnchannels() - while 1: - data = af.readframes(BUFSIZ) - if not data: break - print len(data) - p.writeframes(data) - p.wait() - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/dbmac.py b/Mac/Lib/dbmac.py deleted file mode 100644 index 0588dbd90e..0000000000 --- a/Mac/Lib/dbmac.py +++ /dev/null @@ -1,140 +0,0 @@ -"""A slow but simple dbm clone for the Mac. - -For database spam, spam.dir contains the index (a text file), -spam.bak *may* contain a backup of the index (also a text file), -while spam.dat contains the data (a binary file). - -XXX TO DO: - -- reclaim free space (currently, space once occupied by deleted or expanded -items is never reused) - -- support concurrent access (currently, if two processes take turns making -updates, they can mess up the index) - -- support efficient access to large databases (currently, the whole index -is read when the database is opened, and some updates rewrite the whole index) - -- support opening for read-only (flag = 'm') - -""" - -_os = __import__('os') -import __builtin__ - -_open = __builtin__.open - -_BLOCKSIZE = 512 - -class _Database: - - def __init__(self, file): - self._dirfile = file + '.dir' - self._datfile = file + '.dat' - self._bakfile = file + '.bak' - # Mod by Jack: create data file if needed - try: - f = _open(self._datfile, 'r') - except IOError: - f = _open(self._datfile, 'w') - f.close() - self._update() - - def _update(self): - self._index = {} - try: - f = _open(self._dirfile) - except IOError: - pass - else: - while 1: - line = f.readline() - if not line: break - key, (pos, siz) = eval(line) - self._index[key] = (pos, siz) - f.close() - - def _commit(self): - try: _os.unlink(self._bakfile) - except _os.error: pass - try: _os.rename(self._dirfile, self._bakfile) - except _os.error: pass - f = _open(self._dirfile, 'w') - for key, (pos, siz) in self._index.items(): - f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`)) - f.close() - - def __getitem__(self, key): - pos, siz = self._index[key] # may raise KeyError - f = _open(self._datfile, 'rb') - f.seek(pos) - dat = f.read(siz) - f.close() - return dat - - def _addval(self, val): - f = _open(self._datfile, 'rb+') - f.seek(0, 2) - pos = f.tell() -## Does not work under MW compiler -## pos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE -## f.seek(pos) - npos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE - f.write('\0'*(npos-pos)) - pos = npos - - f.write(val) - f.close() - return (pos, len(val)) - - def _setval(self, pos, val): - f = _open(self._datfile, 'rb+') - f.seek(pos) - f.write(val) - f.close() - return pos, (val) - - def _addkey(self, key, (pos, siz)): - self._index[key] = (pos, siz) - f = _open(self._dirfile, 'a') - f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`)) - f.close() - - def __setitem__(self, key, val): - if not type(key) == type('') == type(val): - raise TypeError, "dbmac keys and values must be strings" - if not self._index.has_key(key): - (pos, siz) = self._addval(val) - self._addkey(key, (pos, siz)) - else: - pos, siz = self._index[key] - oldblocks = (siz + _BLOCKSIZE - 1) / _BLOCKSIZE - newblocks = (len(val) + _BLOCKSIZE - 1) / _BLOCKSIZE - if newblocks <= oldblocks: - pos, siz = self._setval(pos, val) - self._index[key] = pos, siz - else: - pos, siz = self._addval(val) - self._index[key] = pos, siz - self._addkey(key, (pos, siz)) - - def __delitem__(self, key): - del self._index[key] - self._commit() - - def keys(self): - return self._index.keys() - - def has_key(self, key): - return self._index.has_key(key) - - def __len__(self): - return len(self._index) - - def close(self): - self._index = self._datfile = self._dirfile = self._bakfile = None - - -def open(file, flag = None, mode = None): - # flag, mode arguments are currently ignored - return _Database(file) diff --git a/Mac/Lib/maccache.py b/Mac/Lib/maccache.py deleted file mode 100644 index 1e2b3d02b1..0000000000 --- a/Mac/Lib/maccache.py +++ /dev/null @@ -1,61 +0,0 @@ -# Module 'maccache' -# -# Maintain a cache of listdir(), isdir(), isfile() or exists() outcomes. -# XXX Should merge with module statcache - -import os - - -# The cache. -# Keys are absolute pathnames; -# values are 0 (nothing), 1 (file) or [...] (dir). -# -cache = {} - - -# Current working directory. -# -cwd = os.getcwd() - - -# Constants. -# -NONE = 0 -FILE = 1 -LISTTYPE = type([]) - -def _stat(name): - name = os.path.join(cwd, name) - if cache.has_key(name): - return cache[name] - if os.path.isfile(name): - cache[name] = FILE - return FILE - try: - list = os.listdir(name) - except: - cache[name] = NONE - return NONE - cache[name] = list - if name[-1:] == ':': cache[name[:-1]] = list - else: cache[name+':'] = list - return list - -def isdir(name): - st = _stat(name) - return type(st) == LISTTYPE - -def isfile(name): - st = _stat(name) - return st == FILE - -def exists(name): - st = _stat(name) - return st <> NONE - -def listdir(name): - st = _stat(name) - if type(st) == LISTTYPE: - return st - else: - raise RuntimeError, 'list non-directory' diff --git a/Mac/Lib/macostools.py b/Mac/Lib/macostools.py deleted file mode 100644 index da1e3ab08b..0000000000 --- a/Mac/Lib/macostools.py +++ /dev/null @@ -1,94 +0,0 @@ -"""macostools - Various utility functions for MacOS. - -mkalias(src, dst) - Create a finder alias 'dst' pointing to 'src' -copy(src, dst) - Full copy of 'src' to 'dst' -""" - -import macfs -import Res -import os -from MACFS import * -import MacOS -try: - openrf = MacOS.openrf -except AttributeError: - # Backward compatability - openrf = open - -Error = 'macostools.Error' - -FSSpecType = type(macfs.FSSpec(':')) - -BUFSIZ=0x80000 # Copy in 0.5Mb chunks - -# -# Not guaranteed to be correct or stay correct (Apple doesn't tell you -# how to do this), but it seems to work. -# -def mkalias(src, dst): - """Create a finder alias""" - srcfss = macfs.FSSpec(src) - dstfss = macfs.FSSpec(dst) - alias = srcfss.NewAlias() - srcfinfo = srcfss.GetFInfo() - - Res.FSpCreateResFile(dstfss, srcfinfo.Creator, srcfinfo.Type, -1) - h = Res.FSpOpenResFile(dstfss, 3) - resource = Res.Resource(alias.data) - resource.AddResource('alis', 0, '') - Res.CloseResFile(h) - - dstfinfo = dstfss.GetFInfo() - dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag - dstfss.SetFInfo(dstfinfo) - -def mkdirs(dst): - """Make directories leading to 'dst' if they don't exist yet""" - if dst == '' or os.path.exists(dst): - return - head, tail = os.path.split(dst) - if not ':' in head: - head = head + ':' - mkdirs(head) - os.mkdir(dst, 0777) - -def copy(src, dst, createpath=0): - """Copy a file, including finder info, resource fork, etc""" - if createpath: - mkdirs(os.path.split(dst)[0]) - srcfss = macfs.FSSpec(src) - dstfss = macfs.FSSpec(dst) - - ifp = open(srcfss.as_pathname(), 'rb') - ofp = open(dstfss.as_pathname(), 'wb') - d = ifp.read(BUFSIZ) - while d: - ofp.write(d) - d = ifp.read(BUFSIZ) - ifp.close() - ofp.close() - - ifp = openrf(srcfss.as_pathname(), '*rb') - ofp = openrf(dstfss.as_pathname(), '*wb') - d = ifp.read(BUFSIZ) - while d: - ofp.write(d) - d = ifp.read(BUFSIZ) - ifp.close() - ofp.close() - - sf = srcfss.GetFInfo() - df = dstfss.GetFInfo() - df.Creator, df.Type = sf.Creator, sf.Type - df.Flags = (sf.Flags & (kIsStationary|kNameLocked|kHasBundle|kIsInvisible|kIsAlias)) - dstfss.SetFInfo(df) - -def copytree(src, dst): - """Copy a complete file tree to a new destination""" - if os.path.isdir(src): - mkdirs(dst) - files = os.listdir(src) - for f in files: - copytree(os.path.join(src, f), os.path.join(dst, f)) - else: - copy(src, dst, 1) diff --git a/Mac/Lib/py_resource.py b/Mac/Lib/py_resource.py deleted file mode 100644 index 8530b59c26..0000000000 --- a/Mac/Lib/py_resource.py +++ /dev/null @@ -1,76 +0,0 @@ -"""Creation of PYC resources""" -import os -import Res -import __builtin__ - -READ = 1 -WRITE = 2 -smAllScripts = -3 - -def Pstring(str): - """Return a pascal-style string from a python-style string""" - if len(str) > 255: - raise ValueError, 'String too large' - return chr(len(str))+str - -def create(dst, creator='Pyth'): - """Create output file. Return handle and first id to use.""" - - try: - os.unlink(dst) - except os.error: - pass - Res.FSpCreateResFile(dst, creator, 'rsrc', smAllScripts) - return open(dst) - -def open(dst): - output = Res.FSpOpenResFile(dst, WRITE) - Res.UseResFile(output) - return output - -def writemodule(name, id, data, type='PYC '): - """Write pyc code to a PYC resource with given name and id.""" - # XXXX Check that it doesn't exist - res = Res.Resource(data) - res.AddResource(type, id, name) - res.WriteResource() - res.ReleaseResource() - -def frompycfile(file, name=None): - """Copy one pyc file to the open resource file""" - if name == None: - d, name = os.path.split(file) - name = name[:-4] - id = findfreeid() - writemodule(name, id, __builtin__.open(file, 'rb').read()) - return id, name - -def frompyfile(file, name=None): - """Compile python source file to pyc file and add to resource file""" - import py_compile - - py_compile.compile(file) - file = file +'c' - return frompycfile(file, name) - -# XXXX Note this is incorrect, it only handles one type and one file.... - -_firstfreeid = None - -def findfreeid(type='PYC '): - """Find next free id-number for given resource type""" - global _firstfreeid - - if _firstfreeid == None: - Res.SetResLoad(0) - highest = 511 - num = Res.Count1Resources(type) - for i in range(1, num+1): - r = Res.Get1IndResource(type, i) - id, d1, d2 = r.GetResInfo() - highest = max(highest, id) - Res.SetResLoad(1) - _firstfreeid = highest+1 - id = _firstfreeid - _firstfreeid = _firstfreeid+1 - return id diff --git a/Mac/Lib/test/AEservertest.py b/Mac/Lib/test/AEservertest.py deleted file mode 100644 index 75137380bf..0000000000 --- a/Mac/Lib/test/AEservertest.py +++ /dev/null @@ -1,211 +0,0 @@ -"""AEservertest - Test AppleEvent server interface - -(adapted from Guido's 'echo' program). - -Build an applet from this source, and include the aete resource that you -want to test. Use the AEservertest script to try things. -""" - -import sys -sys.stdout = sys.stderr -import traceback -import MacOS -import AE -from AppleEvents import * -import Evt -from Events import * -import Menu -import Dlg -import Win -from Windows import * -import Qd -import macfs - -import aetools -import EasyDialogs - -kHighLevelEvent = 23 # Not defined anywhere for Python yet? - -Quit='Quit' - -def mymessage(str): - err = AE.AEInteractWithUser(kAEDefaultTimeout) - if err: - print str - EasyDialogs.Message(str) - -def myaskstring(str, default=''): - err = AE.AEInteractWithUser(kAEDefaultTimeout) - if err: - return default - return EasyDialogs.AskString(str, default) - -def main(): - echo = EchoServer() - yield = MacOS.EnableAppswitch(-1) # Disable Python's own "event handling" - try: - try: - echo.mainloop(everyEvent, 0) - except Quit: - pass - finally: - MacOS.EnableAppswitch(yield) # Let Python have a go at events - echo.close() - - -class EchoServer: - - suites = ['aevt', 'core', 'reqd'] - - def __init__(self): - self.active = 0 - # - # Install the handlers - # - for suite in self.suites: - AE.AEInstallEventHandler(suite, typeWildCard, self.aehandler) - print (suite, typeWildCard, self.aehandler) - self.active = 1 - # - # Setup the apple menu and file/quit - # - self.appleid = 1 - self.fileid = 2 - - Menu.ClearMenuBar() - self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024") - applemenu.AppendMenu("All about echo...;(-") - applemenu.AppendResMenu('DRVR') - applemenu.InsertMenu(0) - - self.filemenu = Menu.NewMenu(self.fileid, 'File') - self.filemenu.AppendMenu("Quit/Q") - self.filemenu.InsertMenu(0) - - Menu.DrawMenuBar() - # - # Set interaction allowed (for the return values) - # - AE.AESetInteractionAllowed(kAEInteractWithAll) - - def __del__(self): - self.close() - - def close(self): - if self.active: - self.active = 0 - for suite in self.suites: - AE.AERemoveEventHandler(suite, typeWildCard) - - def mainloop(self, mask = everyEvent, timeout = 60*60): - while 1: - self.dooneevent(mask, timeout) - - def dooneevent(self, mask = everyEvent, timeout = 60*60): - got, event = Evt.WaitNextEvent(mask, timeout) - if got: - self.lowlevelhandler(event) - - def lowlevelhandler(self, event): - what, message, when, where, modifiers = event - h, v = where - if what == kHighLevelEvent: - msg = "High Level Event: %s %s" % \ - (`code(message)`, `code(h | (v<<16))`) - self.handled_by_us = 0 - try: - AE.AEProcessAppleEvent(event) - except AE.Error, err: - mymessage(msg + "\015AEProcessAppleEvent error: %s" % str(err)) - traceback.print_exc() - else: - if self.handled_by_us == 0: - print msg, "Handled by AE, somehow" - else: - print msg, 'Handled by us.' - elif what == keyDown: - c = chr(message & charCodeMask) - if modifiers & cmdKey: - if c == '.': - raise KeyboardInterrupt, "Command-period" - else: - self.menuhit(Menu.MenuKey(message&charCodeMask)) - ##MacOS.HandleEvent(event) - elif what == mouseDown: - partcode, window = Win.FindWindow(where) - if partcode == inMenuBar: - result = Menu.MenuSelect(where) - self.menuhit(result) - elif what <> autoKey: - print "Event:", (eventname(what), message, when, (h, v), modifiers) -## MacOS.HandleEvent(event) - - def menuhit(self, result): - id = (result>>16) & 0xffff # Hi word - item = result & 0xffff # Lo word - if id == self.appleid: - if item == 1: - mymessage("Echo -- echo AppleEvents") - elif item > 1: - name = self.applemenu.GetItem(item) - Qd.OpenDeskAcc(name) - elif id == self.fileid: - if item == 1: - raise Quit - - def aehandler(self, request, reply): - print "Apple Event!" - self.handled_by_us = 1 - parameters, attributes = aetools.unpackevent(request) - print "class =", `attributes['evcl'].type`, - print "id =", `attributes['evid'].type` - print "Parameters:" - keys = parameters.keys() - keys.sort() - for key in keys: - print "%s: %.150s" % (`key`, `parameters[key]`) - print " :", str(parameters[key]) - print "Attributes:" - keys = attributes.keys() - keys.sort() - for key in keys: - print "%s: %.150s" % (`key`, `attributes[key]`) - parameters['----'] = self.askreplyvalue() - aetools.packevent(reply, parameters) - - def askreplyvalue(self): - while 1: - str = myaskstring('Reply value to send (python-style)', 'None') - try: - rv = eval(str) - break - except: - pass - return rv - -_eventnames = { - keyDown: 'keyDown', - autoKey: 'autoKey', - mouseDown: 'mouseDown', - mouseUp: 'mouseUp', - updateEvt: 'updateEvt', - diskEvt: 'diskEvt', - activateEvt: 'activateEvt', - osEvt: 'osEvt', -} - -def eventname(what): - if _eventnames.has_key(what): return _eventnames[what] - else: return `what` - -def code(x): - "Convert a long int to the 4-character code it really is" - s = '' - for i in range(4): - x, c = divmod(x, 256) - s = chr(c) + s - return s - - -if __name__ == '__main__': - main() diff --git a/Mac/Lib/test/AEservertest.rsrc.hqx b/Mac/Lib/test/AEservertest.rsrc.hqx deleted file mode 100644 index f6ded2a423..0000000000 --- a/Mac/Lib/test/AEservertest.rsrc.hqx +++ /dev/null @@ -1,514 +0,0 @@ -(This file must be converted with BinHex 4.0) - -:%8&&Ff9bGQ9bG'9cG#jbFh*M!(*cFQ058d9%!3#3"f2$GSF!N!3"!!!!BVS!!'' -k!!!"#6B8)&3JD!!8)&"p%E"S%3!k!@FQ%Lm-6VS#$!`k!&Tj%8&&Ff9bGQ9bG'9 -cG#jbFh*M!J!!!(*cFQ058d9%!3!!!(*cFQ058d9%!3#3")!!N"+YGH&%!*!'Bm2 -r%F#SD3%G3"(rma0`!"!Zrr1pdK&Q%&%f[P9V!3,fK[P9V!3%`86)"Caj%&3` -!!"aP%R!!%#j$&3`!!"pL"R!"B!!"!3)X@P3Y,N5p!3!E2!&Q-#G92KT+J#"6!LJ -![`!Z)J$Y#3)"!%#$+0Xd%kRA,`a1ZJ%*5QGV!3#Q9d-k!!!"!*!5!J!!!!-!!!( -rrJ!"``)!!L)#!!33!J!))!)J%%!R)#$!*b"ai!)JHc"2J%BB6j!!3!a2N!!J""r -3%!3I`!J-(m!-'$9J(M!eB$PJ2q!a`!)!%i!#!!m!!J!%!!)!"!%#!!3$!J!(rri -!!!-!!!!"!*!6!J!!!!-!!!(rrJ!"``)!!q)#!!I`!J!2i!)J(m!R)$r!*b"ri!) -JIr"2J(ri6j!!Ira2N!!rr"r3(r`I`!rm(m!2q$rJ(r!ri$rJ2q!r`!)!(i!#!!m -!!J!%!!)!"!%#!!3$!J!(rri!!!-!!!!"!*!&#P$J!$k!!!!I3!#3"!G"8&"-!*! -'(&"C9'F!!!!"4P*&4J#3"B"*3diM!*!%!5`!!!"!#)!T3!)J""!Z#$3%,J*Z!6m -#(`3UL$q3!!)J!8!!J!!!#)!T`!2J"r![q$rm2rjrrcrq(r`rq$r`!q!"`!#!!*! -%"!#3Mrm!N"rrr`#3&rq3%!#3%2rrr`#3"2rr!*!'r`#3$rm!!2Ir!!!!r`#3"rm -!N!lr!!!U+[Ir!*!+r`#3$Im!!#SUprm!N![r!!!!X!#3#2m!!#SUprm!N!L`!!# -`X,!!!,!!N!Ir!!!U+[Irr`#3#,!!!,#`X!!!X!#3"[rrr`!Uprrkq[m!N!Z`!!! -!X!#3"[rkq[mUrrSU+[Vr!*!&X!!!X*!&!*!)rrIh+[rk+T!%q[m!N!5`!!#`N!8 -!!,!!N!ArpJ!UN!B!+[Vr!!!!X!!!X*!&!!#`!*!'r`!!+T!%!#S!+[m!N!@`N!F -!X!#3"rm!!#SU!#S!+LVr!*!&X*!(!*!+r`!!!#S!+LVkr`#3"E#3"`#3#[rr!!! -!+LVkr`#3"E#`"E!&X!@`X!#3#2rkq[m!+LVkr`#3"V#`"E!&X!@`X!#3"rrkqLS -UrbVkr`#3"l#3#3#3"rrk+LS!rrVr!*!-r`#3$2m!!2Vrr`#3$Im!N!hrN!3!N!l -r!*!1r`#3%2m!N!lr!*!*r`#3"[m!N!lr!*!)rrm!N!Er!*!1rj!5!*!Arrm!N"r -r!*!5!J#352!!N!rr!*!,$rq3"r!!N!F2r`!!r`!!!2!!N!I`$2!!m!!!!2!!N!B -2!-c2!*!&m!#3"[!-c2!!N!A`!&!!!!!2!-c2!*!%8!99!&!!!!$`$-cr!*!%8!9 -9!&!!!!rr$-rGm!#3"9!!8!!!$phmrFcI!!!&!&998!!!!!r-cpc-cI!!"3"999! -&!!!2`-c-c!cI!!8!9993"3!!!2!-c-$!c`!!"999938!!!!2!-`-$-m!!!99998 -!N!A`!-$-h`!!"99993#3"Im!$-h`!!"9&4898!!!!!rGm-cI!!!!9489&9!!!!$ -ph-r0m!!!!&@3"&!!!!$pc!rI!*!'m!#3"3m!hr!!N!E`!*!'rrm!N!I`!*!'$`# -3#2!!N!B2!*!%$`!!!2!!N!B2!*!%r`!!!2!!N!B2rj!)m!#3#rm!N!m2!*!+!3# -3"Im!!!$r!*!*r`$r!!$r!2m!N!cr!#X!r`#3#[m!+bXV!2m!N!Er!,#`X#Z3"!$ -r!*!&rrm!X2Rj+j!%!2m!N!6r!,#`X#Z3"J$r!!$rrbZ`X,$j+j!(r`!!rl#3"IN -VN!6jr`#3",#3"INV+b[jr`#3",!&X!@`"E$j+rRr!*!&X*!(qIRr!*!+rrRjqIm -!N!crqIm!N!lr!*!DJ!!!m!$`!*!%m2!2$`#3"[$!m!#3"!m-c!m!!!$`99c-`2! -!!2m&hFc-$`!!m&9Fc-c!m!rm99h-c-c2!2999Gc-cI!!"999h-cI!!"489&GcI! -!!&9999hI!*!&rGh`!*!&$pm!N!I`!*!0@+!!N!!!N!8$$P*PFA9TFQ9N)&0eDA4 -P+e4PFQec)(4SBA3JCACPFRNJBA"`E'PMBA4TEfiJFfK[G@aN)(0eF("[FR3!FQ9 -aC!!"!!%!"!4[F'9Z(%p`C@iJG'KP)(0`C@0TCQPPC#"[BQTPBh3SFbPKCACdEf4 -[BfjeE'`!!)!!B@aTFaGXDA0d)'pQ)'pLDQ9MG(-JG'mJEh"PEP!!!!!&F(*TER3 -G8(*TER3JG'KP)(0`C@0TCQPPC#"[BQTPBh3SFbPKCACdF'4[BfjeE'`!!)!!B@a -TFaKXDA0d)'pQ)'pLDQ9MG(-JG'mJF(*TER3!3!!!!39TG'9YFfCcC@aXDA0dD84 -2)%j29#"98d8k)("bEhCTC'9N)'C[FL"LB@0VGf&bC(-JBfpYF'&dD@*TE'PdH5" -hDA4S)'pXC#"PGQ9ZG#"cG@PdC5iJ)>E'`JBQ8JFQ9YEhCPC#"TEL"QGA4eFQ8 -J4QPZC'9bFi!!"(&eDA3U8A9TG#"dD'8J4QPZC'9b)#KNDA*PBh3JF'&bB@ePG'9 -b)'PREQpbC@3TB@9fG(&eDA4ZG@aX!!#!!'jeE'`FEQmJC'PbC@0d)("KFQ&YCA4 -PFL"bCA&eDA*PC!#3!!!!!!0bG@i`8f9ZG#"dEb"KEL"KF("XD@0KG'P[EL"hD'9 -Z)'Pd)'Pc)'4[G@*XC5eME'PMDf9N!'&PGR4[BA"`ER9XE!!!J!"ZG@aX('j[)'4 -TFQ9MG#"`BA*KE@9dCA)JFQ9aG@PbC@3!N!!!N!N18h4KEQ4KFQ3J8h9TG'8L3fp -YE@pZ)(4PFQec)'C[FL"YEh0d)'&`F'aTBf&dD@pZFf0[FQ8!!3!"!"%+BfaKFh- -JD@jQEb9(CA3JD@jQEh*YBA4TEfiJB@*[GA3JB@iJEf*UC@0d)'0XBA0c!'0[FQ9 -aEf*UCf0XD6KK)(*PBfpbC#"MEfjdB@PZD@jR)(4SC5"[BQTPBh69Fb"`FQp`CA* -dD@9c)'&ZC#"PE'9YC@jdF`!!!(4jF'8eG'KP)'pLDQ9MG#"ME'&cFb"KBQpeG#" -hD'PMD#"TEQC[FQeKG'P[EL"TFb"bCA&eCA0dC@5!!!!"!QPZ!(GbBf4TER4X3h4 -SC5"SG@eKEL"XB@jRG@&RC5"KEQ3JFf0bDA"d)(0jFh4PE5"TEL"hD'PMD#"dEb" -bCA4eFQiJD@jQEh*YBA4TEfk!!!9ME'pcC3p$E'pcC5"KEL"[BQTPBh4MEh*PBfa -[FfjeE'`!!)!!Ef*U)"0dD'8JEf*UC@0d)(4[)'0XEh0P%!!!!JCcBACTEQF!Ff& -fEh0KGQmiFh"PBfPQD@9c)(GSCA4SCA)JBfKKEQGPFb"cD'peE'3JBQ8JFf&fC@3 -JBQ9QEh*P)'0XEh0TEQF!S!!*Ff&fD@jR)'PZDfCTE'&XDA-NG'KP)'CTE'8JD@i -JGfKTBfJJG'mJFf&fC5"dD'8JEf*UC@0d!)!!"@0[G@jd4&*PG(9bEL"dD'8JER9 -YBQ9b)'pQ)'9XC@ePER4c)'pQ)'%JF'&bG'PMG@aKFL"ME'&cFb"hDA4SD@iJB@i -JEf*UC@0d!'0[FQ9MER4PE'pZCaCdD'8JER9YBQ9b)'pQ)'9XC@ePER4c!!!!Ef* -U)#YdD'8JEf*UC@0d)(GSEh0P)'9XC@ePER4c)'&bC5"dEb"LC5"MEh9ZG'9N!!! -!!34PB@0S!'Y[BfadHA"P*h4SC5"ME'&cFb"[CL"dD'8JC@aPE@9ZG(-JG'mJBQ8 -JBfpeER4PC!!!#@4KG'%JFfPkC595CA4eFQiJG'KP)(0THQ8JD@iJBRPdCA-JEfB -JB@iJEf*UC@0dBfpbC@4cDATXEfjR(h4SC5"cDATP)'pQ)(4SC5"[BQTPBh3JD@i -JBRPdCA-!!'pLDL!XG'KP)'pLDQ9MG#"hD'pcC5"NBA4K)(0THQ8JDA-JG'mJBQ8 -JFQ9dGA*ZC@3!N!3"!Q&c!(*dHA"dHA"P,R4SC5"NBA4K)(4jF'8JCQpb)(GSD@0 -S)(4SC5"cDATP)'Pc)'0KE'0eE'&dC@3!J!!'C'9XCA4P)%4PE'9dC5"KEL"PE'9 -YC@jd)'CbEfdJB@iJEf*UC@0dBfpbC@4PE'pZG@aX!!#!!'pLDL!9G'KP)'9XC@e -PER3JG'mJC'9XCA4P%!!!!!PNGA"XD@0KG'864(9`E'PMBA4P)'pLDQ9MG#Kc+@0 -[FQ9ME'pZEf*U)"YdEb"dD'8JC(9`E'PMBA4PC#"[BQTPBh3SFbN!!'pLDL!DG'K -P)'pLDQ9MG#Kc+5"dEb"NGA"XD@0KG'8!%!!!"!*dE`"TER0SD@jcE#*dD'8JEQ9 -h)'a[Bf&dD@pZ)'C[FL"dD'8JEf*UC@0d+(-T!)!!#A*PF'aKBfPZCf&XFR"LEfp -XEP0`C@0TCQPPFb"hD'9dD'9b)'pb)'j[G#"dEb"bCA"XB@0P)'PdC@ec)'PZ)(4 -SC5"NCA0dD@jKG'P[EL"dD'&d)'KKGQ8JG'KP)(0KE@8JEQ&YC5"KFb"TG'9YFb" -LC@PZCb"NGA"XD@0KG'9N!+!!$A"[FfPdD@pZC@3JBA4YGR"XE'PcG&&(DACPFb" -K)'aTFh3J+'PZ)'a[Bf&X)(GTEQ4[Gb"MEfpbC'PZBA4PFbNJEfBJF'pcDA4TEfj -c)'C[FL"dD'8JC'9cG'PZBA4TEfiJDA4PEA1J!!9TG'9YFfCcC@aXDA0dD842)%j -29#"98d8k)("bEhCTC'9N)'C[FL"LB@0VGf&bC(-JBfpYF'&dD@*TE'PdH5"hDA4 -S)'pXC#"PGQ9ZG#"cG@PdC5iJ)>E'`JBQ8JFQ9YEhCPC#"TEL"QGA4eFQ8J4QP -ZC'9bFi!!#Q9fC@jd)'PZCQma4f9d)'PZCQpbE@&dD@pZ)'&LEh9d)(4SC5""F(" -XC5"PGQ9ZG(-JD@iJB5"cG@PdC3"MEh*PCh4PD@9fD@icB5"bC@0[FQ3JBfpZG'& -TEQPZCb"dD'8JCACPER4c)'&ZC#"dD'9TFL"`BA*KE@9dCA*c3!"dHA"P3h4SC5" -PGQ9ZG#"ME'&cFb"[CL"dD'8J3A"`E'8JCACPER4c)'C[FL"hD'PMD#"dEb"bCA4 -eFQiJD@jQEh*YBA4TEfi!!!!"!QPZ!(GbBf4TER4X3h4SC5"SG@eKEL"XB@jRG@& -RC5"KEQ3JFf0bDA"d)(0jFh4PE5"TEL"hD'PMD#"dEb"bCA4eFQiJD@jQEh*YBA4 -TEfk!!!CPH'PcG(-D9Q9bD@Cj)'PQ)'&Z)'pLDQ9MG#"PH'PcG(0MEh*PC'pPH'* -[Ef`IG(*eC5"TCL"TG#"PH'PcG(-X)'CKE(0P)'PQ)'j[G!!!Ef*U)"CdD'8JEf* -UC@0d)'PZ)(&eCA0dD@pZ!*!&!fGPG"T(CA3JG'KP)'4KG'%JCQpb)'&Z)'pLDQ9 -MG!"MEh*PCf9dC#U3""KdD'8JC'&dB5"QFQpY)(4SC5"[BQTPBh3!!!"[BQSJ*h4 -SC5"[BQTPBh3JGfK[Ff8JC'&dB5"TFb"dEb"LC5"bCA4eFQjPC!!!!!%#BA-!FR4 -jF(4jF'8fG'KP)'4PFfPbC@3JG(P`CA-JCQpb)(4SC5"NBA4K,#"TEL"[FQ4PFL" -[CL"`FQ9QCA*PEQ0P!-!!"'eKDf856@&VC5"K)'jPGb"PE'9YC@jdBfpbC@0bC@a -[BQSJ&(4[)(4SC5"ZCAFJEf*UC@0d+(-T!!!!ER9XE!!!N!!!!!8$EQ9hDfpME(4 -jF'8FG'KP)'0XBA0c)'pQ)(4SC5"ZCAFJC@aPE@9ZG!!!!!*KG!"TER0SD@jcE#Y -dD'8JE'pMBA4TEfiJBA3JGfKTBfJJG'mJD@jcCA*d)(4SC5"PE'9YC@jd!!!#G'm -!G'mJ)'pLDL"%GfKPEL"MFQ9KG'PZCb"KEL"KE'PKFb"QD@aP,#"dD'8JEh*TCfP -ZB@`JDA4PE5"dEb"MFQ9KG'8JB@iJB@aTBA-JG'm!J!!*GfPdD#"NBA4KC'&dB5U -3"#"dD'8JD@jTG'PKE#"NBA4K)'C[FL"dD'8JC@aPE@9ZG!#!!!phDA4S)("bEh" -PFR4TCA0`FQ4dFQ9MEc4dD'8JD@jTG'PKE#"fB@aeCA-JCQpb)(4SC5"`FQp`CA* -dD@9c)'pQ)(4SC5"PE'9YC@jd!)!!"'e[GQ8J6@pfC5"[BQTPBh3SFbNJG'mJB5" -ZCAFJE'pMBA4TEfjMEh*PE@pfC@pLDL!VG'mJG'KP)'pLDQ9MG#Kc+5"KCR4PFL" -dD'9j)'KKGQ8JBQ9PEL"YEhCPC!!!Ef*U)"9dD'8JEf*UC@0d+(-T)(4[)'e[GQ8 -3!!!$!R4[!'PZFfKTER0X)R4SC5"ZCAFJE'pMBA4TEfiJCQpb)(4SC5"[BQTPBh3 -SFbN!!!!*FQ9`E'&MD@jRB@abF'*[EfaT8h"PBfPQD@9c)(GSCA4SCA)JEh)JEQp -d)(4[)(*PF'aKBf8JDA4PEA-JD@iJG'KP)'4PFh4TEQ&dD@pZ)(4SBA3JD'&fC5" -dD'8JFf&YC5"ZB@eP)'&c)'PdC@ec)'*PD@jR)'e[GQ9NS!!0F'pcDA4TEfjPC#" -KG'efF'aXDA0d88GTGQ9c)'%JE'PcG#!SD@iJE'pMB@`JGfPZC'ph)'0[Eh*ND@j -KG'9c+5"[CL"`Eh0TG'P[ER-JCQpb)(4SC5"NCA0dD@jKG'P[EL"TG'9YFk!!"'p -`C@iF6h"PEL"dD'8JFh"PBfPQD@9N)'pLDQ9MG#Kc+@&PGR4[C'pMER9XE!!!J!" -[BQSJ&faTFh3JEfBJEf*UC@0dFb"dEb"[F'9Z%!!!!J9eFfPZCh9cD@j[BQSJ,(4 -SC5"KF("XD@0KG'P[EL"QD@aP)(4[)'p`C@iJG'KP)'pLDQ9MG#"hDA4S!)!!"@P -dC@ecCR0PE'aTFh4T4%mJ6Np8)&9646SJF(*[GQPNC@3JCQpb)'*KBfYhBA*NFb" -MEfe`BA4TBQPXDA4j)(GTG'JJEfaN)'9fC@jd)(0eDA4P,L!J9fPXE#"LC5"bC@e -[GQ9N)'PZ)'CeG(9bC5"'D@jNCA*cJ!!&F(*TER3G8(*TER3JG'KP)(0`C@0TCQP -PC#"[BQTPBh3SFbPKCACdF'4[BfjeE'`!!)!!Ef*U)"KXDA0d)'pQ)'pLDQ9MG(- -JG'mJF(*TER3!N!3""@PdC@ecCR0PE'aTFh4T4%mJ6Np8)&9646SJF(*[GQPNC@3 -JCQpb)'*KBfYhBA*NFb"MEfe`BA4TBQPXDA4j)(GTG'JJEfaN)'9fC@jd)(0eDA4 -P,L!J9fPXE#"LC5"bC@e[GQ9N)'PZ)'CeG(9bC5"'D@jNCA*cJ!!%FA9TG#T4G@P -d)(4SC5"'D@jNCA)J+'4TFQ9MG#"`BA*KE@9dCA)JD@GZEh*PC#PKCACdFA9TG'j -eE'`!!)!!ER9XE!!!N!!!!!%'Ff&fD@jR!(0KGQpcBAC[6(0`C@0TCQPPFb"hD'9 -dD'9b)(4[)(0KGQ8JBh9bFQ9ZG'aj)'p`C@iJC'pMG@ePER4c)#KZEh3JFh9`F'p -bG'9N)'*j)%CTEQ4PFLN!S!!%Ff&fC5K6BACP)'&Z)'pLDQ9MG#!S6Qpd)(0eF(" -[FR4PC#"LH5"'D@jNCA)TBfpbCA0KGQ9ZG@aX!!#!!'pLDL!5G'KP)'pLDQ9MG#" -dEb"cBACP!"!!!!)#D@i!DfCTE'&XDA-qG'KP)'CTE'8JD@iJGfKTBfJJG'mJFf& -fC5"dD'8JEf*UC@0d)#KZEh3JFh9`F'pbG'9N)'*j)%CTEQ4PFLN!J!!#BA-!CQa -dF(4jF'94G'KP)'CTE'8JG(P`C5"[CL"dD'8JC'pMG@ePER3JD@iJGfKTBfJJG'm -JFf&fC5"dD'8JC'&dB5!SEQpd)(0eF("[FR4PC#"LH5"'D@jNCA)TJ!!$Ff9d&&0 -PG#"KEL"[BQTPBh3RFb"NBA4K!'0[FQ9cCA4NER9XE!!!J!"[BQSJ&(4SC5"[BQT -PBh3JG'mJBfKKEQGP!"!!!!%#G'm!C'&dB5U3"!edD'8JEQ9h)(CKE(9P!!!+Fh9 -TG'8JD@jQEb4(CA3JD@jQEh*YBA4TEfiJB@*[GA3JCACPER3JFh9TG'8SFbPMEh* -PCh4cDA0eD@iaB5"bC@0[FQ3JBfpZG'&TEQPZCb"dD'8JFh9TG'9c)'&ZC#"dD'9 -TFL"fCA*cD@pZFd!!G(P`C5PdD'8JFh9TG'8JCQpb)(GSD@0S)(4[)(*PG(9bEL" -TEQC[FQeKG'P[EJ!!!!%#D@i!Gh*MC'PZG'a$G'KP)'KeE@&Z)'aKEQGeB@GP)'& -ZC#"cBh*TF(3JFhPcG'9Y)'PZ)(GSD@0S)(4[)(*PG(9bEL"TEQC[FQeKG'P[ES! -!N!F-4QPZC'9b)&0eDA4P)8pLDQ9MG(-JB@jN)%9fC@jdFb"QEh)JG'KP)%CTEQ4 -PFJ"QEQ4b!!%!!3!0#'0XC@&Z)(9`(N&bFQ&ZCf8JDA4PEA-JD@iJGfPZC'ph)'j -TBf9XH@CZC(*QBfaeER9XE!!!J!"[BQSJ&R4SC5"hD@jNEhFJG'mJBfaPB@iJGA! -!N!3"!Q*j!'*j)#"dHA"P+R4SC5"[FQ4PFL"TEL"hD'PMD#"dEb"ME'9KEL"eF#" -dD'8JEf*UC@0dF`#!!!KMEfe`GA4PFL"8CA0d)'&dG(*TBR9dCA-JEfBJG'KTFb" -MEfe`GA4PFQCZC(*RFh4XE'pZCaGdD'8JFQ9cG@ad)'pQ)(4SC5"aG@9bHB!!G(P -`C49dD'8JBA4dFQPLGA4P)(4[)(4PFh3!!!!"!fKKFfKKFb"XEfjR(R4PFh3JFh" -PBfPQD@-JBQPdFb"[CL"bCA0`EfjcC3#!!!9PDQ9MG&&&DQ9MG#"dD'8JFh"PBfP -QD@9N)'4TFfXSFbNX)'pb)'9fCA*j)'9UC@0dB@*XC5"NDA0V)'PQ)'j[)("KFQ& -YCA4PFL"TFb"cF'9MD@CTC@4QEQ4bC@TMG'jeE'`!!)!!Ef*U)"*dD'8JDA4PEA- -JG'mJC@TPBh3!J!!!!!9PEA"dH3p&EA"dH5"dD'8JG(*KFfKQEQ4bC@e`G'jeE'` -!!)!!Ef*U)$$5C@e`G(R6)'&ZC#$5C@e`G(NJG(*KFfM6)'*[G'JJC'mJG'KP)(0 -KE@8JG'KTEQF!N!!!!!!&CA*KFf8E4A*KFf8JG'KP)(0`C@0TCQPPC#"NDA0V+(- -TCQjNFQCPFQ&ZG@aX!!#!!'pLDL!5G'KP)'PdC@ec)(4[)'9bBA0P!*!&#("eG#" -KGf&j)&"eG#"KGf&j)(4SC5"cF'9MD@CTC@3JEf*UC@0d+(-TCQjNFR"dGhP[BQS -J,(4SC5"[BQTPBh3JF(9d)'&hBANJD@iJDA4c)("eG#eKGf&j)'a[Bf&dD@pZ!!! -!Ef*U)"9dD'8JDA4PEA-JG'mJF(9d)'&hBAN!!!!""@PdC@ecCR0PE'aTFh4T4%m -J6Np8)&9646SJF(*[GQPNC@3JCQpb)'*KBfYhBA*NFb"MEfe`BA4TBQPXDA4j)(G -TG'JJEfaN)'9fC@jd)(0eDA4P,L!J9fPXE#"LC5"bC@e[GQ9N)'PZ)'CeG(9bC5" -'D@jNCA*cJ!!(FQ9cG'&bG"95CA0dBA*d)(4SC5"0B@0TER4[FfKQEQ4bFQ9cG'j -eE'`!!)!!ER9XE!!!N!!!!!!'FQ9fC@&X*d*bD@jR)(4SC5"cF'9MD@CTC@3JEf* -UC@0d+(-T)'PZG'mJGQPPG`"YDA0MEACTFfjeE'`!!)!!Ef*U)"edD'8JEf*UC@0 -d)(4[)'*P)'eKC'8JGQPcD@*XC4!!!!!'Ff9XC@0d(P0PE'9MG#"dD'8JFh"PBfP -QD@9N)'pLDQ9MG#Kc+@eTFf0cE'0dER9XE!!!J!"[BQSJ&(4SC5"[BQTPBh3JG'm -JFf9XC@0d!"!!!!!*FfKeG#"NEhGZ&e0SGA3J4'phEL"dD'8J6@&MD@jdEh0SCQj -NFR0SGA4ZG@aX!!#!!'jeE'`!!*!!!!!!"A0XC@9`%e0XC@9`)(4SC5"0B@0TER4 -[FfKQEQ4bFfj[HQjeE'`!!)!!ER9XE!!!N!!!!!!%FfpbG#p5CA4eFQiJG'KP)(0 -`C@0TCQPPC#"[BQTPBh3SFbNJD@iJB5"cEh*dC@3JE'PcG!"%394"8dp59'pLDL! -MG'KP)(0[FR4PC#"TG'9YFb"TEL"dD'9TFL"ZCAFJEh*NCA+!!'pLDL!JB5"XDA0 -d)'pQ)'CTEQ4PFL"[BQTPBh4c)(4[)(0[FR3!N!3"!Q*j!'*j)#"dHA"P)A4SC5" -`FQp`CA*dH5"dEb"cEh*d)(4SC5"TG'9YFb"LH3!!"R9`C'&dC909F'4KG'8JG'K -P)'4TFh"XBANJEfBJG'KP)(0`C@0TCQPPC#"[BQTPBh3SFbNJG'mJE@&dBfJJG'K -PDA)JEfiYC'PcDb"bCA"bCA0PER4KG'P[EJ"QEQ4bCR9`C'jeE'`!!)!!Ef*U)"* -dD'8JDA4PE5"dEb"eF'4KG'8!N!Bk%@&MBf9cFfpbH5"`FQpMCA0cF'0NB5e")(" -bEf0PFh-JE'&eEQ0SC@3JCR*[E5"K)'4PFfXJB@0MCA0cEh*j)'CTE'8!!40NCA0 -V)'&MBf9cFfpbH5"QD@aPC'&QD@pLDL!mG'KP)'4PFfXJB@0MCA0cEh*j)'CTE'8 -JCR*[E5"hD'PMD#"dD'Pc)("bEf0PFh-JGf&c)'aKG@jMD'9N!*!&%f&MBf9cFfp -bH5"`FQpMCA0cCA0`Bf4K&f9fCA*j)'&MBf9cFfpbH5"`FQpMCA0c!!%!!'0!)b& -dHA"P!!!!!3!!%Q&MBf9cFfpbH5"cG@PdBf&cC3"NFh9d'8%JC'9cDb"KBf0PFh0 -[FRNJFh9TG'0KFf8!!!!"BfpLDJ!#D@jNH'jKE@86B@0MCA0cEh*j)(0eDA4MBA0 -PFf4cGA3BCACPFRNJB@0MCA0cEh*j)(0eDA4MBA0P!!!"!!"M3#-KG(P`C3!!!!% -!!!TKE'PKFb"QD@aP!'&XD@%T3@iJB@aTBA-JCQPXC5!SBh*PBA4PC#"hDA4S)0* -0B@YP)%&XD@&cdbN!!3e[FQPRD@jKE#"TG'9YEh*TCfpLDL!TG'KP)'pbD@GTEQ& -X)'PdC@dJF'pTER4PC#"dEb"LH5"dD'8JB@aTBA-!N!3,B@aTBA-JCQPXCA0KE'P -K%'9fCA*j)'&XD@&c)'CTE'8!!!%!!'0!)b&dHA"P!!!!!3!!#f&`F'aTBf&dD@p -ZBf&`F"C"EL"KF("XD@0KG'P[EL"`FQpRFQ&Y!!!A&'&LEh9d)(4SDA-JE@&MD@j -dEh0S!'&LBRK[BQSJ9(4SC5$53@*[GA3JG'KTFb"0B@0TER4[FfM6)'4TB@a[Cb` -JB@jN)(4SC5"XDA0d)'pQ)(*eEQjTEQFJF(*[Bf9cFf9c)'4TFh"XBAPPC#"TEL" -TG!!!!"GKF("XC5"YC@je)'PdC@ec)'C[E'4PFQ&YER9[BQSJ9A4SC5"cF'9MD@& -X)'C[E'4PFL$53A"`E'8J6@9ZG5"*G'9YFbc6)(4SC5"MEfjdC@jdFb"[CL"hD'P -MD#"KF("PBA)JD@iJG'KP)%&`F'aP)'ePER8!!!PME'P`BQpKFQ4`BfaTEf*U)"e -dD'8J4QPZC'9b*h-JBfaTF'*[BA*N)(GTEQ4[G`!!&@0[ER4bEf`JF'&ZC@ac)'C -[E'4PFQ0dFQa[BQSJ)h4SC5"cF'9MD@&X)'C[E'4PFL$53fpZG(*[E#"3B@jPE(2 -6!!!(C'9cDh4[F'4PFfY[BQSJ#h4SC5"NCA0VG'p`!!!4CAKdC@jcD@pZFb"QEfa -NCA*PH(4ZEf*U)"pdD'8JFh"PBfPKE#"QEfaNCA)JdN9iG'9ZFfP[ER26!!!-CQP -XC5"cD'&bD@jR!'CcD(*LEfpX%dPc)'CTE'8JFfKKFQPZCb"[EMm3!!aQEfjdFb" -QEfaNCA)!CQCZG'pLDL!DG'KP)(0`C@0TB@`JCQpXC'9b)0*'EfjdFp-!!!!*CR* -[ER4YEh0dF'PcCQ*[Ef`L5A-JG'KTFb"dD'8JCR*[ER4YEh0d)'&`F'aTBf&dD@p -Z2`!3!"*TER0PFR4TEfiJE'pMBA4TEfi!F'PZFfpLDL"-G'KP)'0[ER4KD@jPFL" -dD'&d)'%JEQ9h)'C[E'4PFL"hEh9XC#"KF("PBA)JD@iJD@BJdNjPGb"'EfaNCA, -6)(GKFb"cC@aPBh4PC!!!!"*XBA*RCA0d)'CbC@8JBQa[BfX!E@CbC@a[EQG,G'K -P)'aKFQGPFh3JCR*PC5"LE'pMDb"[CL"`FQpMCA0c)'ePE@pbH5"KGQ&TE'&LE'8 -JG'mJE'&eEQ0S)'&Z)'&`F'aTBf&dD@pZ!!!5F(*PCQ9bC@jMCA-JCQpXC'9b!(" -bC@C[BQSJ)(4SC5"cF'9MD@&X)'C[E'4PFL$58(*PCQ9bC@jMCA26!!!!$h"bEf4 -eBh3JGQ9bFfP[ERCPFM*TG(Kd2(4SC5"fCA*cD@pZ)'pQ)(4SC5"6HA0dC@dJFfp -QG(GKFQ8JFR9ZEQPZCb"[EL"dD'Pc)%eKBfPZG'pcD!!!!!PcC@aPBh4TEfjcC@a -PEf*U)#&dD'8JFf9XC@0dD@pZ)(CTFfPLE'8JG'mJG'KP)(9cCA)3!"0cD'&bD@j -R)(0dBA*dD@jR)(9`CR0eF'*[Efa05A-J4QPXC5"cD'&bD@jR)'PZ)(4SC5"`FQp -MCA0c)'pQ)(0dBA*dD@jR)(9`)#KcG'PXE#"[CQBX)'*eG#"cEfpZ)(4[)'*P)'p -Z+6m!!!PcD'pbG'0eG(0cBh9dEf*U)$9dD'8JdNCTEQ4PFL"6D'pbG'0eG(26)'P -dC@dJD@iJG'KP)%CTEQ4PFLGc)'KPE(!JE@9ZG3!!&A0SGA4NEhGZ)'PdC@ec)'C -[E'4PFR0SC'C[BQSJ)h4SC5"cF'9MD@&X)'C[E'4PFL$58fKeG'4[GfiJ5A4PEA2 -6!!!8Fh4KFR4eF#"TG'9YFb"QEfaNCA)!Fh4bG'pLDL!LG'KP)(0`C@0TB@`JCQp -XC'9b)0*6G'&bG(9`)%PdC@ecd`!!!!ecHA0dC@dJCQpXC'9bE@&MFfpLDL!4G'K -P)&0jFh4PE5"QEfaNCA)!!"CdC@e`Eh*KFRNJDA4PEA-JCQpXC'9b!(4PEA"[BQS -J-(4SC5"cF'9MD@&X)'C[E'4PFL$59'9YF'pbBA*j)%PdC@ecdb!SD@jfDA0TBQa -P+3!!!!GfCA*cD@pZGQ9bFfPdH(3YG'KP)(CPFR0TEfiJEfBJG'KP)%CTEQ4PFL" -6Bh*TF(4TEQFJ4AKdC@jcD@pZ!!!3GQPPGb"`FQ9QCA*PEQ0PF`"`GRG`Ef*U)#* -dD'8JGQPPGb"`FQ9QCA*PEQ0PFb"MEfjdFQpX)("KEQ9X!!!!"hCTFfPLE'9`GQP -cBQp[E"j*Fb"dD'8J4QPZC'9b*h-JE'&jCA)JGQPcD@*XC6m!%!!!&f4cGA3!!QP -ZC(KZB@ePB@aTB3!#D@jNH'jKE@9KF("Q!!0TEQ4iEQ&YC8P%)#"MG'jb!!*TEQ4 -iEQ&YC@0hEQ3!!QPZC(KZB@ePC(GZC!!#D@jNH'jKE@9MBf4f!!*TEQ4iEQ&YC@4 -KCQN!!QPZC(KZB@ePBf4cD`!#D@jNH'jKE@9MC'Pc!!0TEQ4iEQ&YC8P%)#"NEf0 -Q!!*TEQ4iEQ&YC@CTE'8!!QPZC(KZB@ePBfC[E!!$D@jNH'jKE@9*4#!JCQjdCJ! -#D@jNH'jKE@9QFh9d!!*TEQ4iEQ&YC@PhEQ3!!QPZC(KZB@ePBfpLDJ!#D@jNH'j -KE@9cBh4b!!*TEQ4iEQ&YCA0hEQ3!!QPZC(KZB@ePFfjNCJ!#D@jNH'jKE@9cG'0 -c!!*TEQ4iEQ&YC@0dFR-!!QPZC(KZB@ePBhGTEJ!#D@jNH'jKE@83BA"`E'PMBA4 -TEfiJCQPXC3"KF("Q(8&Z)'&`F'aTBf&dD@pZ*h-JCQPXC5"[EL"NDA0V!!3@E@P -ZD@eeE5"`BA*dDA4TEfiJFfPkC3"YF(*dE'pZCdYdD'8JFfeKE'aPFh3JE@9YEh* -j)(0THQ8JG'KKG#"dD'8JBA"`E'PMBA4TEfiJBf&Z)("[Fh0TBQaj)'*P)'aKG@j -MD'9N)(GTG'J3!!j`BA*dDA4TEfiJFfPkC3"KF("dE'pZCcTdD'8JE@9YEh*j)(0 -THQ8JG'KKG#"dD'8JBA"`E'PMBA4TEfiJGfPXE#"LC5"XBA9ZBfKPC#"hDA4S!"! -!#R0MFQP`G'&LE'8!DA0KBQ*[Efa[5A-JG'KTFb"KF("XD@0KG'P[EL"SD@GS,@a -PGQ9X)'9fC@jd)'&hBA*P)#KKBf0PF(4c)'p`C@iJBA"`E'PMBA4TEfiX)'p`C@i -JC'pMG@ePER3X)("bD@jd)'4[Bh9YC@jd,#"KEQ3JFA9TG#Nr!!!BFh9RCf9cG'9 -N)("KFR4TG'P[EL"cDATP!(0`FR4XEfjR@R4SC5"YC@e[FRNJFfPkC5"dD'&d)(4 -SC5"NCACPE'p`CA)JFQ9MEfeYC@jNFb"dD'&d)(4SC5"KF("XD@0KG'P[EL"cD'p -eE'3JBQ8JE'&eEQ0SC@3JGfPdD!#3"4&KF("XD@0KG'P[EL"QD@aPFf&`F'B@CAC -PFRNJBA"`E'PMBA4TEfiJCQPXC3!!!3!!Bd!M)A4jF'8!!!!"!!!6BA"`E'PMBA4 -TEfiJF(*[Bf9cFh"MBA!V35"`FQpMCA0c)'aKG@jMD'9N)'CbEfdJB@iJBA"`E'P -MBA4TEfiJCQPXC3!"%'&`F'aTBf&dD@pZ)'CTE'8!BA"`CQ&`F'BjG'KP)'&`F'a -TBf&dD@pZ)'CTE'8JCR*[E5"hD'PMD#"dD'Pc)("bEf0PFh-JGf&c)'aKG@jMD'9 -N!*!%&@&`F'aTBf&dD@pZ)("bEf0PFh0PFh"MBA!CCACPFRNJBA"`E'PMBA4TEfi -JF(*[Bf9cF`!"!!"M3#-KG(P`C3!!!!%!!!PMEfjdB@PZCA*MG'jb)8&Z)'PdC@d -JG'KKG#"MEfjdB@PZFb"[G'KPFL"TG'9YF`!)%f0[EA"XCA4PE(NJCAK`B@jNC@4 -`CAKMBQp[E$j*Fb"dD'8JBfpZG'&TEQ9b)'&ZC#"KE'`JEfBJDA4c)'0SD@aNFQ9 -Z)'p`C@iJD@iJEh9dE'PZC5"fD@9h2`!3!""MEfjdB@PZCA)JGfPZC'ph!'0hEQ4 -[BQSJ)A4SC5"YB@PZ)(GTEQ4[Gb"QEh)JG'KP)'0[ER4KD@jPFJ!!$f9ZG'PbC5" -MEfjdC@jdFf9MG(0[BQSJ6(4SC5"PER4TFQ8JBfpZG'9ZG(-JEfBJG'KP)'0[ER4 -KD@jPFL`JD@jME(9ND@jR)(4SC5"MEfjdC@jdFb"[CL"TG(-JBfKTE'4bC@i!!!! -+CAK`B@jNB@*XC3"`CAKKBQp[E$e*Fb"dD'8JBfpZG'&TEQ9b)'0KF'&LE'8JEfB -JBQ9TEQFJCAK`B@jNC@3JD@jdEb"[GA4XD@jP)(CTCAFr!!!)CAK`B@jNC@3!F'9 -iF'*[Ef`Q5A-JG'KP)'0[ER4KD@jPFL"[F'9Z)'PZ)'peG'aTEQ8JGQPPGcm!%!! -5F(*PGQP[GA-JE'PcG#"fD@9h!(0fCAGXEfjRGR4SC5"XBA0d)'j[ELeTBfpZ)(C -TCAFJ+'*j)'jKE@8X)'*j)'4KG'8X)'9dBbiT)(0PE'9MG'9N)'C[FL"dD'8JBfp -ZG'&TEQ9b)#KQEh*REh4dC@iJBA-JFfp[EL"KFb"dD'8JGfPZC'ph)'Pc)'0XEh0 -PC#N!!!!*Ff9XC@0dD@pZFf9XC@pLDL!KG'KP)(0PE'9MG'P[EL"fDA0TBQaP)(4 -[)(4SC5"eFf9b%!!%GQPPG`"`GQ9hE'pZCd9dD'8JGQPPGb"cC@aPBh4PC#"QEh) -JG'KP)'0[ER4KD@jPFL!SBRNJD@0[EL`JBRNJEQ&YC5`JBRNJC'&dC5`JCA4M,LN -3!!!2C(0eG!!#D@jNH'jKE@9KE'PK!!*TEQ4iEQ&YC@&`F'B!!QPZC(KZB@ePBh4 -ZFJ!#D@jNH'jKE@9MBf4f!!*TEQ4iEQ&YC@4KCQN!!QPZC(KZB@ePC'pMCJ!#D@j -NH'jKE@9QD@aP!!*TEQ4iEQ&YC@0QEf`!!QPZC(KZB@ePCQjdCJ!#D@jNH'jKE@9 -QFh9d!!*TEQ4iEQ&YC@0[BQS!!QPZC(KZB@ePFf0dFJ!#D@jNH'jKE@9cEQ4Q!!* -TEQ4iEQ&YCA0dBh-!!QPZC(KZB@eP#Q0[ER4KD@jPFR-!Bh4ZFJpPGQ9bH5"MEfj -dB@PZCA)!!3!!Bd!M)A4jF'8!!!!"!!!3BfpZG'&TEQ9b)(GTEQ4[G`"MGfjN(%% -JGfPZC'ph)(4SBA3JBfpZG'&TER-JDA4PEA-!!!F*BfpZG'&TEQ9bBh4ZFQpLDL! -SG'KP)'0[ER4KD@jPFL"dD'Pc)(GTEQ4[Gb"TFb"[F'9ZC@3JCR*[E3!!!!4NDA0 -V!'0NDA0[BQSJ3(4SC5"NDA0V)'pZ)(GSD@0S)(4SC5"TG'9Y)(4SDA-JGfPZC'p -h)(GKFb"[F'9ZC@3JCR*[E5"TFb"cG'pbC@3!!!!'CQpXC'9b!'0QEfa[BQSJ*A4 -SC5"QEfaNCA)JG'KTFb"hD@jNEhFJDA-JEh"PEQ9N)'CbEfd!!!4TG'9Y!'0[BQT -[BQSJ)h4SC5"TG'9Y)(4SDA-JGfPZC'ph)'Pc)'p`C@jPC#"QFQpY!!!5F(*PGQP -[GA-JE'PcG#"fD@9h!(0fCAGXEfjRFh4SC5"XBA0d)'j[ELeTBfpZ)(CTCAFJ+'* -j)'jKE@8X)'*j)'4KG'8X)'9dBbiT)(0PE'9MG'9N)'C[FL"dD'8JGfPZC'ph)#K -QEh*REh4dC@iJBA-JFfp[EL"KFb"dD'8JGfPZC'ph)'Pc)'0XEh0PC#N!!!PcC@a -PBh4TEfjcC@aPEf*U)#&dD'8JFf9XC@0dD@pZ)(CTFfPLE'8JG'mJG'KP)(9cCA) -3!!4fD@9h!("fCAGXEfjR3R4SC5"fD@9h)(0PE'9MG'9N)'C[FL"dD'8JGfPZC'p -h)#KLH5"TBfpZ,#"LH5"ZB@eP,#"LH5"NBA4P,#"PG'-Z+3!3!!!2C(0eG!!#D@j -NH'jKE@9KE'PK!!*TEQ4iEQ&YC@&`F'B!!QPZC(KZB@ePBh4ZFJ!#D@jNH'jKE@9 -MBf4f!!*TEQ4iEQ&YC@4KCQN!!QPZC(KZB@ePC'pMCJ!#D@jNH'jKE@9QD@aP!!* -TEQ4iEQ&YC@0QEf`!!QPZC(KZB@ePCQjdCJ!#D@jNH'jKE@9QFh9d!!*TEQ4iEQ& -YC@0[BQS!!QPZC(KZB@ePFf0dFJ!#D@jNH'jKE@9cEQ4Q!!*TEQ4iEQ&YCA0dBh- -!!QPZC(KZB@eP%@0[ER4KD@jPFL"hD@jNEhGcBhGZC"CPGQ9bH5"MEfjdB@PZCA) -JGfPZC'ph!!!"!!"M3#-KG(P`C3!!!!%!!!eMEfjdC@jd)(0`B@0PC(GZC&K"E'` -JGfPZC'phFb`JD@jME(9ND@jR)(4SC5"NCA0VG'p`)(GTEQ4[Gb!SdPGTEQ4[Gp- -JC'pPFb"ZEh3JD@jME(9NC5"dD'8JC'9cDh4[F#"hD@jNEhFT!*!&$Q0[ER4PER3 -JFh"KBf9c!'4hEQ364ACPFRNJBfpZG'9ZG#"cF'&MC3!"!!"M3#-KG(P`C3!!!!% -!!!eMEfjdFQpX)("KEQ9XBf0NGJp")'0[ER4bEf`JF'&ZC@`!$4CMB@aMG@aKG'8 -JCQpXC'9b)(0THQ9c!(0QFhTLEfpX55K@D@9hFbNJ3A*P)'C[E'4PFL"cDATPFb" -MB@aMG@aKG'9N)'&ZC#"NDA0`E'&jC@3JD@iJ4QPZC'9b)'aTFh3JGfPZC'phFcm -3!!pMEfeYC@jd)'KPB@4TEQGcBfpYBQp[E$BS9QPPGh-T)%&bC5"MEfeYC@jdFb" -NDA0`E'&jC@3JD@iJ4QPZC'9b)'aTFh3JGfPZC'phFcm!%!!-C'&dC5"SC@&ND@j -R!(0NBA4LEfpX3#K@D@9hFbNJ3A*P)'e[C'PQD@0KG'P[EL"NBA4PFb"NDA0`E'& -jC@3JD@iJ4QPZC'9b)'aTFh3JGfPZC'phFcm!%!!BC'PcDb"TEQC[FQeKG'P[EL" -SC@&ND@jR!(0ND@jLEfpX55K@D@9hFbNJ5A-JD@jQEh*YBA4TEfiJB@*[GA3JG'K -P)(C[E(9YC5"NDA0`E'&jC@3JD@iJ4QPZC'9b)'aTFh3JGfPZC'phFcm3!!PTBfp -Z)(0THQ9XGQPcE'pZCcSS9QPPGh-T)(4SC5"cDATP)'pQ)'PMEfjc)'4TFh"XBAP -PC#"TEL"'D@jNCA)JE'PcG#"hD@jNEhGc!"!!$'YTEQ3JD'9KC'PZC`"cDfjNBQp -[E$`S9QPPGh-T)%&bC5"NEf0eE@9ZG#"VD@jNFb"NDA0`E'&jC@3JD@iJ4QPZC'9 -b)'aTFh3JGfPZC'phFcm!%!!0E'&LC@`JD'9KC'PZCh0XBQaLEfpX0#K@D@9hFbN -J3A*P)'aKBQ9XFb"NDA0`E'&jC@3JD@iJ4QPZC'9b)'aTFh3JGfPZC'phFcm!%!! --FfPkC5"SC@&ND@jR!(0cDATLEfpX0bK@D@9hFbNJ3A*P)'CTE'8JFfPkCA-JC'P -cF'aKH@9N)'PZ)%CTEQ4PFL"XDA0d)(GTEQ4[Gh-3!!acEQ&`)(4[)'GbD@3!CQG -bC'*[Efa2+&CTCAGc+5""FQ8JDA4PEA-JB@ahBAPc)(0ZBA"`C@3JG'mJG'KP)'j -PBA*PFh3JCh*TC#"`EfPZG#"hD'9Z)(4SCANJBA*P)'e[GQ9N2a!!$R0dB@GRCA* -PC#"RFQPN!'CcG'GLEfpX)5K@D@9hFbNJ3A*P)'GbD@3JE'PZCA-JFh4KCfGPFQ9 -N2a!!$hCPFR0TEfiJD'9KC'PZCh0fFR0LEfpX1bK@D@9hFbNJ3A*P)'CTE'8JGQ9 -bFfP[ER-JC'PcF'aKH@9N)'PZ)%CTEQ4PFL"XDA0d)(GTEQ4[Gh-r%!!*GQPPGb" -QEfjdGQCZG'a[EQF[+&CTCAGc+5"dD'8JD@3JEfBJG'KP)'C[ER3JGA0PC#"TEL" -'D@jNCA)JGQPPGh-3!!jfD@9h)'C[ER3JFfPkC3"fCR0kE'pZCc%S9QPPGh-T)(4 -SC5"cDATP)'pQ)(4SC5"QEfjd)(9cC@3JD@iJ4QPZC'9b)(CTCAGc%!!!!!jMEfj -dFQpX)("KEQ9XF`"MBf4f%f9fCA*j)'0[ER4bEf`JF'&ZC@`!!3!!Bd!M)A4jF'8 -!!!!"!!!6C'9cDb"KBf0PFh0[FRNJCQPXC@4KCQN935"NCA0V)'&MBf9cFfpbH5" -QD@aP!*!%&'4PFfXJB@0MCA0cEh*j)'CTE'9c!'4KCQNCCACPFRNJC'9cDb"KBf0 -PFh0[FRNJCQPXC3!"!!"M3#-KG(P`C3!!!!%!!!jNCA0VG'p`,@pLDQ9MG!"MC(0 -V-d4PFfYdEh!YEf*UC@0d)'Pc)(4SC5"ME'&cFb"[CL"dD'8JdQ4PFfYdEh$6)'p -LDQ9MG!!#$(0dBA*dGA!JC'PcD`"cC(0VEf*U)""dD'8JFh4KFR4eF#"NDA0V!!! -!"A4bBA0SG(*cD'pLDL!*G'KP)(4bBA0S!!!!$f4cGA3!!QPZC(KZB@ePB@aTB3! -#D@jNH'jKE@9KF("Q!!*TEQ4iEQ&YC@0dER)!!QPZC(KZB@ePBf0NGJ!#D@jNH'j -KE@9NB@CT!!*TEQ4iEQ&YC@4[BfB!!QPZC(KZB@ePCQPXC3!#D@jNH'jKE@9MCQp -X!!*TEQ4iEQ&YC@CZG'B!!QPZC(KZB@ePCR0eG!!#D@jNH'jKE@9MEf*U!!*TEQ4 -iEQ&YCA0MG()!!QPZC(KZB@ePFfjNCJ!#D@jNH'jKE@9cG'0c!!*TEQ4iEQ&YC34 -NDA0V!'0NDA-'35"NDA0V!!!&#'0KF'&MDA4j!'0KF'&XEfjR0(4SC5"dEh4KE#" -ZG@eLCA)JEfBJBRPdCA-J+'CbC@8JEh)JGA0PC#NJEfiJG'KP)'4TFfX!!!!*C@T -PBh4KBQaPDA0PDQ*[Ef`h3f&Z)(4SC5"YC@4TB5"MB@iJBQ8JC@TPBh4PC#!SCQa -[F("TCA-X)%0%*h-X)(0jFA9PFh3T2`!!#QCbC@8JFh"KBf8!CR*cF'a[EQFTG'K -P)'jeE@*PFL"[CL"QFQ9P)'*jG'9c)'aPCR3JEfiJG'KP)'4TFfX!!!aXEf0KE#" -fEfaeE@8!DA0bGQ*[Ef`l5A-JG'KP)'ePC'PK)'Pc)'%JE'pMB@`JGQpXG@eP)#K -bBA4SCA)JG'KKEL"K)'CTE'8JFf9bGQ9b+6m!!!GcG'&bG(9`DA0dC'*[Ef`E5A- -JG'KTFb"NDA0V)(4SC5"LEfpd)'4TFfXr!!!!$f4cGA3!!QPZC(KZB@ePB@aTB3! -#D@jNH'jKE@9KF("Q!!*TEQ4iEQ&YC@0dER)!!QPZC(KZB@ePBf0NGJ!#D@jNH'j -KE@9NB@CT!!*TEQ4iEQ&YC@4[BfB!!QPZC(KZB@ePCQPXC3!#D@jNH'jKE@9MCQp -X!!0TEQ4i583J)'jKE@9QER4Q!!*TEQ4iEQ&YC@CcGA3!!QPZC(KZB@ePBfpLDJ! -#D@jNH'jKE@9cBh4b!!*TEQ4iEQ&YCA0ZC'B!!QPZC(KZB@ePFh4MF`!#D@jNH'j -KE@8&C'PcDh0MC'Pc#Q9fCA*j)'4TFfX!!!%!!'0!)b&dHA"P!!!!!3!!$@4[Bh9 -YC@jd)'CTE'9NEf0Q$d%JC'pMG@ePER3JCQPXC3#3"!jNEf0eE@9ZG#"QD@aPF`" -NEf0Q%f9fCA*j)'4[Bh9YC@jd)'CTE'8!!3!!Bd!M)A4jF'8!!!!"!!!%CQPXC3" -QD@aP"N%JCQPXC3!!"JaMFQ9KG'pb)(4jF'8!CQ0bG(4jF'8mG'KP)%p69(P`C5" -TC'9ZG'PQH@PZCb"dD'8JBA"`E'PMBA4TEfiJG'KKG#"MFQ9KG'9N)(4SC5"TG'9 -Y!"!!#@CTE'8JG(P`C@CTG("dHA"P2A4SC5"28e4jF'8JD@4PER4TCRPTEQFJG'K -P)(4jF'8JEfBJC'&dB5"MEfjdB@PZC@3JD@iJG'KP)'PdC@d3!!CXEf0VC@3!DA0 -XDf*[Ef`65A-JG'KP)'CTE'8JE'pMDf9N2a!!$h"bEf4eBh3JGQ9bFfP[ERCPFM* -TG(Kd5(4SC5"fCA*cD@pZ)'pQ)(4SC5"`FQpNG@0d)#KfDA0TBQaP)'&d)(4SC5" -dEh!JEfBJG'KP)0*(CA3J5@jQEp-JC'PKE'pR+3!!!!TcG'&dD@pZCA*j!("cF'4 -LEfpX(8Pc)(4SC5"TG'9Y)'%JFh4KG'P[EQ9bH5"`B@3r%!!(GQ9bFfP[ERCPFR0 -TG(Kd5(4SC5"fCA*cD@pZ)'pQ)(4SC5"QD@aP)#KfDA0TBQaP)'&d)(4SC5"LEh4 -dEfdJEfBJG'KP)0*(CA3J5@jQEp-JC'PKE'pR+3#3"39QD@aPFfCTE'8+CACPFRN -JCQPXC3!!!3!!Bd!M)A4jF'8!!!!"!!!'CQpXC'9b!'0QEf`)35"QEfaNCA)!N!3 -2C(0eG!!#D@jNH'jKE@9KE'PK!!*TEQ4iEQ&YC@&`F'B!!QPZC(KZB@ePBh4ZFJ! -#D@jNH'jKE@9MBf4f!!*TEQ4iEQ&YC@4KCQN!!QPZC(KZB@ePC'pMCJ!#D@jNH'j -KE@9QD@aP!!*TEQ4iEQ&YC@0QEf`!!QPZC(KZB@ePCQjdCJ!#D@jNH'jKE@9QFh9 -d!!*TEQ4iEQ&YC@0[BQS!!QPZC(KZB@ePFf0dFJ!#D@jNH'jKE@9cEQ4Q!!*TEQ4 -iEQ&YCA0dBh-!!QPZC(KZB@eP"fC[E'4PFR0MCQpX$'9fCA*j)'C[E'4PFJ!!!3! -!Bd!M)A4jF'8!!!!"!!!*CQpZG#"QD@aPCQjdCJY")'C[ER3JCQPXC3#3"!TQEfj -d)'CTE'9c!'CZG'B2CACPFRNJCQpZG#"QD@aP!!%!!'0!)b&dHA"P!!!!!3!!$@C -[ER3JFh9TG'0KFf9QFh9d$d%JCQpZG#"cG@PdBf&cC3!!!!&MEf*U!!*TEQ4iEQ& -YC3jQEfjd)(0eDA4MBA0PF`"QFh9d%f9fCA*j)'C[ER3JFh9TG'0KFf8!!3!!Bd! -M)A4jF'8!!!!"!!!&Ch*[GA"cCh*`,8%J4h*[GA!JD@iJG'KP)&9cCA*c)'&ZC#" -(FQpeF(-JBfpZG(*[E#"`B@jPE!!&"Q*[G@jNF`"`BQjNF@4bG#0dD'8JBQpeEQ4 -TEQFJFQ9MG'&ZCfaP)'pQ)(4SC5"RFQpeF"!!"'PMEfi!D@PYCfPQB@dFG'KP)'P -MEfiJBQPdE@&`)'pQ)(4SC5"RFQpeF!!3!!YXB@*PE#"TEQ4PH'aKBQPXEfjR&R4 -SC5"XB@*PE#"[CL"dD'8JCh*[GA!!%!!%EQ&YC3"`EQ&YDA4iG"9dD'8JEQ&YC5" -[CL"dD'8JCh*[GA!3!!K`Eh0TG'P[EJ"`Eh0Z884`G$*dD'8JF'pcDA4TEfiJEfB -JG'KP)'GbEh9`)(GTG'KTEL"TG(-JF'&bC@jd)(GTEQ4[G`!3!!!!"QGbEh9`F`" -cCh*`#f9fCA*j)'GbEh9`!!%!!'0!)b&dHA"P!!!!!3!!%QPZCQpbE@&dD@pZ)(G -TEQ4[G`"TGfjN,8&Z)'PZCQpbE@&dD@pZ)(GTEQ4[Gb!SEh"PEQ9N)'*j)0*(CA3 -J5@jQEmR6+3!2"f0[E@ePER4MEfedDA4iG!YdD'8JBfpYE@9ZG"!!$@0bC@&dD@p -Z)'4KG'9MFR4NE'4d)#CdD'8JC'&dC5"[EL"hD'PMD#"dD'8JDA4PE5"hBA-JBh* -PBA4PC!!!!!4TBfpZ!'PTE@GTCQ&Y'h4SC5"TBfpZ)'*TG'eKF#"[CL"dD'8JDA4 -PE4!!"'PdC@d!BfpLDQpLDL!NG'KP)'PdC@dJG'KTFb"hD@jNEhFJGf&c)'p`C@j -PC#"QFQpY!!!!"Qa[BfYPC!"TFfaVBQp[E"0*Fb"dD'8JDA4PE5"XEf0VC@3r%!! -@E@PZD@eeE5"`BA*dDA4TEfiJFfPkC3"YF(*dE'pZCdYdD'8JFfeKE'aPFh3JE@9 -YEh*j)(0THQ8JG'KKG#"dD'8JBA"`E'PMBA4TEfiJBf&Z)("[Fh0TBQaj)'*P)'a -KG@jMD'9N)(GTG'J3!"&YEf4TCQPMBA4TEfiJC'&dC@e[C'4XC(3J,(4SC5"NBA4 -P)'pZ)(GSD@0S)(4SC5"TG'9Y)(GKFb"XBA0d)'e[C'PQD@9N!!!!$R"KFR4TG'P -[EL"cDATP!'&`F(4XEfjR1R4SC5"YC@e[FRNJFfPkC5"dD'&d)(4SC5"KF("XD@0 -KG'P[EL"hD@aX)'*P)'aKG@jMD'9N)(GTG'J!%!!0F'KjFfPMB@`JFfPkCA"SHA0 -XEfjR+A4SC5"KBh4eB@`JFh"KBf8JGA0PC#"LH5"dD'8JDA4PE5"[EL"NDA0V!!! -2F(*[C(9MG#"fCA*cD@pZGQ9b-QPdH(4)G'KP)(CPFR0TEfiJEfBJG'KP)("bEf4 -eBh3J+(CTFfPLE'8JBA3JG'KP)(4[F#"[CL"dD'8JdNGPG#"*EQC[db"ND@&XEfF -T!!!!"(0THQ8!F(4cHQa[EQFFG'KP)'a[CfPMB@`JFfPkC5"[CL"dD'8JDA4PE3! -!!!TcG'&dD@pZCA*j!("cF'4LEfpX(8Pc)(4SC5"TG'9Y)'%JFh4KG'P[EQ9bH5" -`B@3r%!!BFh9RCf9cG'9N)("KFR4TG'P[EL"cDATP!(0`FR4XEfjR@R4SC5"YC@e -[FRNJFfPkC5"dD'&d)(4SC5"NCACPE'p`CA)JFQ9MEfeYC@jNFb"dD'&d)(4SC5" -KF("XD@0KG'P[EL"cD'peE'3JBQ8JE'&eEQ0SC@3JGfPdD!!!!!GfCA*cD@pZGQ9 -bFfPdH(4)G'KP)(CPFR0TEfiJEfBJG'KP)'CTE'8J+(CTFfPLE'8JBA3JG'KP)'* -[G(4[E5"[CL"dD'8JdNGPG#"*EQC[db"ND@&XEfFT!!!!&(GKFQiJBQ9QEh*P)'9 -YF(4jD@jR!(GKFQjLEfpX0NPc)'%JC'PKE'pR)'4TFh"XBAPPC#"hD'9Z)0*&EA" -dH5"dFQ&cD-R6)'Pc)(0PE'9MG'9N2`!3!!!!%fPZCQpbE@&dD@pZ)(GTEQ4[Gh0 -TGfjN''9fCA*j)'PZCQpbE@&dD@pZ)(GTEQ4[G`!!!3!!Bd!M)A4jF'8!!!!"!!! -%DA4PE3"MEf*U"d&Z)'PdC@d!%`CLEh9ZC(-!F'*ZC(&NFR3LG'KP)'*[G@jND@j -R)(*PBh4KEQGXC5"[CL"dD'8JDA4PE3!3!!GMEfeYC@jdBfpYG'PdH(3kG'KP)'0 -[E@ePER3JC'PcF'aKH@9N)'PZ)(4SC5$54f9d)%PZCQr6)(GTEQ4[Gb"[CL"dD'8 -JDA4PE3!3!!PMEfjdB@PZCA*MG'jbEf*U)"TdD'8JBfpZG'&TEQ9b)'pQ)(4SDA- -JDA4PE3!!!!eMEfjdC@jd)(0`B@0PC(GZC'4hEQ3aG'KP)(GTEQ4[Gb"dD'&d)(G -[G@aN)'p`C@iJD@BJG'KP)'PdC@dJGf&c)'p`C@jPC!!!$@0bC@&dD@pZ)'4KG'9 -MFR4NE'4d)#CdD'8JC'&dC5"[EL"hD'PMD#"dD'8JDA4PE5"hBA-JBh*PBA4PC!! -!!!4NDA0V!'0NDA0[BQSJ*(4SC5"NDA0V)'pZ)(GSD@0S)(4SC5"TG'9Y)'Pc)(0 -dEh*PC!!!!!CQEfaNCA)!BfC[E'pLDL!QG'KP)'C[E'4PFL"TEL"hD'PMD#"dD'8 -JDA4PE5"TFb"cG'pbC@3!!!!%D@0[EJ"TD@eRD@CKE4YdD'8JD@0[EL"LDA4YBA! -JEfBJG'KP)'PdC@d3!!*TC!"*4#!JE'pZCajKEL"TC#"dD'&d)'PNC@jdD@CTCA- -JG'KP)'PdC@d!!!!5D@jQEh*YBA4TEfiJGfPZC'ph!'PhEQ4[BQSJ)h4SC5"TEQC -[FQeKG'P[EL"hD@jNEhFJCQpb)(4SC5"TG'9Y!!!%DfPZC!"VD@jNDA4iG"4dD'8 -JDfPZC#"[CL"dD'8JDA4PE3!!!!YXB@*PE#"TEQ4PH'aKBQPXEfjR&A4SC5"XB@* -PE#"[CL"dD'8JDA4PE4!!%@e[C'PQD@0KG'P[EL"NBA4PE@pNC'aNG#!XG'KP)'4 -KG'8JEfiJGfKTBfJJG'KP)'PdC@dJGf&c)'aKFh3JE@pND@CTC@3!!!!%EQ&YC3" -`EQ&YDA4iG"4dD'8JEQ&YC5"[CL"dD'8JDA4PE3!3!!e`D(PcD@0KE#"cDATPF'K -jFfa[EQFTG'KP)'&MG(9KE#"cF'&MC5"eFf9N)'*j)(4SC5"TG'9Y)'pZ)'4TFfX -!!!K`Eh0TG'P[EJ"`Eh0Z884`G$&dD'8JF'pcDA4TEfiJEfBJG'KP)'PdC@dJGfP -dD'PZ)'PdFb"`BA*PER3JGfPZC'ph%!!)Ff9XC@0dC@3!DA0cE'*[Ef`95A-JG'K -P)'PdC@dJFf9XC@0dC@3r%!!%FfPkC3"`G(0kE'pZCaadD'8JE'pRD@0KE#"cDAT -P)'pQ)(4SC5"TG'9Y!!!!"RGTEQ4[G`"MGfPZBhGTEM&dD'8JGfPZC'ph)(4SBA3 -JGfpeE'3JEh"PEL"TCL"dD'8JDA4PE5"hBA-JEh"PEQ9N!*!%"@PdC@ecBfpLDJT -PGQ9bH5"TG'9Y!!!"!!"M3#-KG(P`C3!!!!%!!!G`FQpMCA0cF(*MFb0")("bEf0 -PFh-JFR9ZEQPZCb"[EL"dD'Pc)%eKBfPZG'pcD!!+$'0bC@&dEh)JG(P`C3"QBh* -dG(P`C5"dD'8JBh*PBA4[FL"dHA"P)'pQ)(4SDA-JF(*[Bf9cF`!!!!4QD@aP!'C -TE'9[BQSJ)h4SC5"QD@aP)(4SBA3JE'&eEQ0SC@3JG'KTFb"`FQpMCA0c!!!*CQP -XC5"dHA"PCQPdF(4jF'8dG'KP)'CTE'8JG(P`C5"[CL"dD'8JCQPXC5"dD'&d)'a -KG@jMD'9N)(4SDA-JF(*[Bf9cF`!!!!PQFQpZG'e[Fh4`DA0QBQp[E#**Fb"dD'P -c)(4SC5"QFQpZG'e[Fh3JBA"`E'PMBA4TEfir!"!!"'jKE@8!F'jKE@PdH(3AG'K -P)'jKE@8JEfBJG'KP)("bEf0PFh-!!!j`BA*dDA4TEfiJFfPkC3"KF("dE'pZCd& -dD'8JFfPkC5"[CL"dD'8JF'&bG'PdD@pZ)(4SBA3JG'KTFb"KF("XD@0KG'P[EL" -hBA-JE'&eEQ0SC@3JGfPdD!!!&("KFR4TG'P[EL"cF'&MC5"eFf9N!("eFf4XEfj -R0(4SC5"ZG@eLCA)JEfBJBRPdCA-JBh9bFQ9ZG'aj)(9cC@3JD@iJG'KTFb"`BA* -dDA4TEfi!!!!0FQ9YEh4P)'9fC@jdFh*PGR4LEfpX+>E'`JG'KTFb"`FQpMCA0 -c)'&MBf9`G(-JFQ9YEh4P)'9fC@jdFcm!!!!+Ff0bDA"dB@*XC3"TFf&LBQp[E'Y -*Fb"dD'Pc)("bEf0PFh-JD'PRD#eXCACPE#"PGQ9ZG#"KGf&bC5!SB@0MCA"dFb" -[F'9Z)'&`F'aTBf&dD@pZ,#"[F'9Z)'4[Bh9YC@jd,#"`FQPZG#"NEf0eE@9ZG#` -JB@jN)(&eDA3T2`!!"hCTFfPLE'9`GQPcBQp[E"p*Fb"dD'Pc)("bEf0PFh-R)'a -KH@9b)(CTFfPLE'8r%!!!!!P`FQpMCA0cCA0`FQ0c$@9fCA*j)("bEf0PFh-!!3! -!Bd!M)A4jF'8!!!!"!!!5FfKKFQ&LE'8JBfpZG'&TEQ9b!(0MG()b35"MEfjdB@P -ZCA)JG'KKG#"YBANJBQ8JFfKKFQ9N)#KNDA0VFb"KEQ3JCQpXC'9bFbN!!!X)CAK -`Eh*dC@3!Ff9iF'*[Ef`e5A-JG'KTFb"QEfaNCA)JB5"cD'&bC5"`EfPZG#"[FL" -TER0TC'8JB5"cD'&bC5"`EfPZG$m!!!9RFQpeF(0RFR"TG(Kd0h4SC5"eFf9b)'p -b)'GbEh9`)(4SBA3JD'&c)(0`C@0TB@`JB@0MCA0c)(4[)(4SC5"QEfaNCA)3!"" -RFQpeF#"`FQPfD@aPCf9c!'G`F(*`FQPf2h4SC5"cC@8JCQpXC'9bFbpcC@8JCQP -XCA-[E@&VC5"MD'&ZCf9c)("bDACTE'9RCA-JCQpb)(4SC5"RFQpeF"!!%'GeCA0 -d)("bDACTE'9RCA-!Ch0dF("bDABqG'KP)(0PC5"QEfaNCA*c,h0PC5"QD@aPFbp -YB@YP)'0SB@jRCA-JF(*TGQPXC@GPFb"QEh)JCACPFRP[EQ8!%!!8D@jSCA*TG'9 -N)("bDACTE'9RCA-!DA"bGQ*[Efa43A*P)(4SC5"`FQPfD@aPCf9c)'pQ)(4SDA- -JDA4PE5"KE(GKHA-JG'KP)(0KE@8JBA-JG'KP)'0[ER4KD@jPFL"TG#"TFb"cG'p -bC@3JD@ir%!!(E@peER4PC(0YEh9LEfpX0%Pc)(4SDA-JCQpXC'9b)'e[G@jdC@3 -JEfiJB@j[G'KPFL"YB@0SD@jP*h-JC'9cDh4[F$m!!!!&EhGZCA*cEhGZDA4iG"j -dD'8JGA0PFL"dD'&d)'phER-JG'KTFb"QEfaNCA)!%!!3EhGZCA)JF(*TGQPXC@G -PF`"[GfjbF(*TGMpdD'8JFf9P)'C[E'4PFR-[Ff9P)'CTE'9c,feKDf8JBfKKEQG -PFb"`FQPfD@aPCf9c)'C[FL"dD'8JEhGZCA)3!!P`FQpdC@0dC@4cF(*[BQp[E$a -*Fb"MEfjdB@PZCA)JF(*[G'9MG'9N)'CbEfdJBQ9TEQFJE@pfC@3X)(*PEQ&YC@3 -JEh)JC'9XCA4PC$m!%!!'FfKKFQ9N!(0SBA*LEfpX'dPc)'0[ER4KD@jPFL"K)(0 -SBA*P)("[D@jd2a!!$R0SBA*TEQFJGfPZC'ph!(0hEQ4[BQSJ*(4SC5"cD'&bD@j -R)(GTEQ4[Gb"QEh)JG'KP)'0[ER4KD@jPFJ#3"!pNFh9d!!*TEQ4iEQ&YC@&XD@% -!!QPZC(KZB@ePBA"`CJ!#D@jNH'jKE@9MG'jb!!*TEQ4iEQ&YC@0MC(B!!QPZC(K -ZB@ePC'&QD3!#D@jNH'jKE@9NEf0Q!!*TEQ4iEQ&YC@CTE'8!!QPZC(KZB@ePBfC -[E!!#D@jNH'jKE@9QER4Q!!*TEQ4iEQ&YC@CcGA3!!QPZC(KZB@ePBfpLDJ!#D@j -NH'jKE@9cBh4b!!*TEQ4iEQ&YCA0ZC'B!!QPZC(KZB@ePFh4MF`!#D@jNH'jKE@8 -6FfKKFQ&LE'8JBfpZG'&TEQ9bFh0MG()BCACPFRNJFfKKFQ&LE'8JBfpZG'&TEQ9 -b!!!"!!"M3#-KG(P`C3!!!!%!!"*cD'&bD@jR)("bDACTE'9RCA-!F(*TGKY")(0 -PG#"[CL"cD'&bD@jR)("bEh"PFR4TCA-!!`aYB@YP)'0SB@jRCA-!F(*fGf*[Ef` -DF(*TGQPXC@GPFb"dEb"YB@YP)'0SB@jRCA-!%!!*Ff9P)'CTE'9cF(*fFQ*[Ef` -AF(*TGQPXC@GPFb"dEb"cC@8JCQPXCA-3!!YcC@8JCQpXC'9bFh"bGR0LEfpX'A" -bDACTE'9RCA-JG'mJFf9P)'C[E'4PFR-3!!!!$R0SBA*TEQFJGfPZC'ph!(0hEQ3 -R35"cD'&bD@jR)(GTEQ4[Gb!SEh"PEQ9N)'*j)0*6D'&bD@jRbG-T!!i*BfpZG'& -TEQ9bBh4ZFQpLDL!ZG'KP)'0[ER4KD@jPFL"dD'&d)(4SDA-JGfPZC'ph)(GKFb" -[F'9ZC@3JCR*[E3!!!!KPH("[FR4PC!"cCAK`BQp[E$K*Fb"dD'Pc)'0[ER4KD@j -PFL"K)(0SBA*P)("[D@jd)'pb)'PZFfPNC5"K)(0SBA*P)("[D@jd2`!!!!CQEfa -NCA)!BfC[E'pLDL!VG'KP)'C[E'4PFL"dD'&d)(4SDA-JGfPZC'ph)(GKFb"[F'9 -ZC@3JCR*[E3!!"@GbEh9`FfGbF'PdH(3kG'KP)(9cCA)JEh)JCh*[GA!JG'KKG#" -SBA-JFh"PBfPKE#"KBf0PFh-JG'mJG'KP)'0[ER4KD@jPFJ!3!""RFQpeF#"`FQP -fD@aPCf9c!'G`F(*`FQPf2h4SC5"cC@8JCQpXC'9bFbpcC@8JCQPXCA-[E@&VC5" -MD'&ZCf9c)("bDACTE'9RCA-JCQpb)(4SC5"RFQpeF"!!%'GeCA0d)("bDACTE'9 -RCA-!Ch0dF("bDABqG'KP)(0PC5"QEfaNCA*c,h0PC5"QD@aPFbpYB@YP)'0SB@j -RCA-JF(*TGQPXC@GPFb"QEh)JCACPFRP[EQ8!%!!8D@jSCA*TG'9N)("bDACTE'9 -RCA-!DA"bGQ*[Efa43A*P)(4SC5"`FQPfD@aPCf9c)'pQ)(4SDA-JDA4PE5"KE(G -KHA-JG'KP)(0KE@8JBA-JG'KP)'0[ER4KD@jPFL"TG#"TFb"cG'pbC@3JD@ir%!! -%DA4PE3"MEf*UEf*U)#PdD'8JDA4PE5"dD'&d)(4SDA-JGfPZC'ph)(GKFb"[F'9 -ZC@3JCR*[E3!!"fe[G@jdC@4cE@peBQp[E$G*Fb"dD'Pc)'0[ER4KD@jPFL"YEh9 -ZG'9N)'pZ)'&ZEh4SCA)JE@&MD'PZC5Gc)'4PFfYdEh!r!!!&EhGZCA*cEhGZDA4 -iG#"dD'8JGA0PFL"dD'&d)'phER-JG'KP)'0[ER4KD@jPFJ!3!""[GfjPFL"`FQP -fD@aPCf9c!'phER*`FQPf2h4SC5"cC@8JCQpXC'9bFbpcC@8JCQPXCA-[E@&VC5" -MD'&ZCf9c)("bDACTE'9RCA-JCQpb)(4SC5"[GfjPFK!!#A"bEh4PBh4PC(0`FQp -LEfpX2%Pc)'0[ER4KD@jPFL"`FQpdC@0dC@3JCR*[E5"LC@PZCb"YEhCPC#`JFQ9 -ZB@ePC#"[FL"NC@aPG'9N2`!3!"*cD'&bB@*XC5"MEfjdB@PZCA)!Ff0dFQpLDL! -hG'KP)(0SBA*KBQaP)'0[ER4KD@jPFL"dD'&d)(4SDA-JGfPZC'ph)(GKFb"[F'9 -ZC@3JCR*[E3!!"R0SBA*PC!"cD'&bBQp[E"Y*Fb"MEfjdB@PZCA)JB5"cD'&bC5" -`EfPZG$m3!!!!$h0SBA*TEQFJGfPZC'phFh0hEQ38CACPFRNJFfKKFQPZCb"hD@j -NEhF!!!%!!'0!)b&dHA"P!!!!!3!!#R0[G@jN)'CTE'8!FfjNCL&8D'Pc)'0XBA0 -c)(*PF(*PFf9ZG(-JFfpeEQ3JCQPXCA-!N!3,FfpeEQ3JCQPXCA0cEQ4Q%'9fCA* -j)(0[G@jN)'CTE'8!!!%!!'0!)b&dHA"P!!!!!3!!$A0dBA4eFb"hD@jNEhGaGfj -N9e4SCA0P)(GTEQ4[Gh-JBA*P)("bEfGbCA0c)'4TB@a[Ch-J+'0[F(NJGfPZC'p -h,#"bC@*eD@aN)'4PFfYdEh!JC'&dB@*KFf8X)'9YF(4j)(4bBA0S+3#3"!jcG'& -dGA-JGfPZC'phF`"aGfjN%f9fCA*j)(0dBA4eFb"hD@jNEhF!!3!!Bd!M)A4jF'8 -!!!!"!!!)Fh9TG'0KFf8!Fh4MFb&")'C[ER3JEh)JC'9cDb"KBf0PFh0[FRNJFh9 -TG'0KFf8!!!!"BfpLDJ!#D@jNH'jKE@8*Fh9TG'0KFf9cFh4MF`jPGQ9bH5"cG@P -dBf&cC3!!!3!!Bd!M)A4jF'8!!!!"!!!-G(*KFfJYEf*UC@0d!'0dFR-[9(*KFfJ -YEf*UC@0d)'Pc)(4SC5"ME'&cFb"[CL"dD'8JdR4bBA0Sdb"[BQTPBh3!!44hBA* -Z)'*PCQpbC5"PEA"dH@PZC`"hBA*ZBQp[E$C*Fb"K)'4TB@a[Cb"NDA0`E'&jC@3 -JGfKPEL$54@e`G(NJG(*KFfM*db"TFb"cC@aPBh4PC$m!%!!!$f4cGA3!!QPZC(K -ZB@ePB@aTB3!#D@jNH'jKE@9KF("Q!!*TEQ4iEQ&YC@0dER)!!QPZC(KZB@ePBf0 -NGJ!#D@jNH'jKE@9NB@CT!!*TEQ4iEQ&YC@4[BfB!!QPZC(KZB@ePCQPXC3!#D@j -NH'jKE@9MCQpX!!*TEQ4iEQ&YC@CZG'B!!QPZC(KZB@ePCR0eG!!#D@jNH'jKE@9 -MEf*U!!*TEQ4iEQ&YCA0MG()!!QPZC(KZB@ePFfjNCJ!#D@jNH'jKE@9cG'0c!!* -TEQ4iEQ&YC34eFf9b!'0eFf8X35"9Ff9b)'PZ)(4SC5"9Ff9bFb"KEQ3J4h*[GA" -c)'0[ER4bEf`JF'&ZC@`!!!8'BQpeEQ4c!("LEQ4aC(*d)R4SC5"LEh9ZC'PZCb" -bC@0dB@jRE'8JEfBJG'KP)(9cCA)!%!!%D@0[EJ"TD@eRD@CKE4YdD'8JD@0[EL" -LDA4YBA!JEfBJG'KP)(9cCA)3!!YXB@*PE#"TEQ4PH'aKBQPXEfjR&A4SC5"XB@* -PE#"[CL"dD'8JGA0PFK!!"'jKE@8!F'jKE@PdH(38G'KP)'jKE@8JEfBJG'KP)(9 -cCA)!%!!)F'pcDA4TEfi!F'pcEP&%F(3aG'KP)("[FfPdD@pZ)'pQ)(4SC5"eFf9 -b)(GTG'KTEL"TG(-JF'&bC@jd)(GTEQ4[Ga!!!!!&GA0PFR0MGA0P#Q9fCA*j)(9 -cCA)!!!%!!'0!)b&dHA"P!!!!!3!!"RGTEQ4[G`"MGfPZ#%%JGfPZC'ph!*!&"hG -TEQ4[Gh0MGfPZ$'9fCA*j)(GTEQ4[G`!!!3!!Bd!M)A4jF'8!!!!"!*!&!RChBRN -!"!PMEfjQE'PMG(0MCQaM!!!1CAKTFh4TEQFJDA4PEA-!CAKcD3!!#R0YB@aX)'P -MEfi!FfeTB`!!!f&XE'YjB@`!!'GcC@i!#!0$8&9`FQpM!!!$4P"9CR"e)!!!!de -09@eYG5!!!!KSBA*NGf&bC3"SC(Gb!!!3Eh"PFQ&dD@jR)(0jFh4PE3"[Fb!J!!! --FfpeEQ3JFhPcG'9Y!(0ZC#!!!""YC@e[FRNJBACKD@aKBQaP!'abB@d!!""YC@e -[FRNJD@jcG'&XE'9N!(*KE5!!N!8"!!!!!3!!!'+k!!"KZJ!!!3N!a(V8%83!!!! -F!2S!#N*14%`!!!"D5801)`!!!'C659T&!!!!FNC548B!!!"qD@0c)`!!!)TTBf` -i!!!!PQPME$3!!!#LD@0c1!!!!+jTBh-d!!!!ZQ&PG'8!!!$'8&P8C`!!!0)!J2r -r!!!"(3$%HD`",2rr!*!&a(KJrj!%!!!""!$%Gk`!J2rr!!!"%J$%H'3",2rr!!! -"23$%H"3",2rr!!!"J3$%H"J",2rr!!!&K3$%H#!",2rr!!!(L3$%H"!",2rr!!! -)M3$%H"`!!2rr!!!*%3#3#Q'e!-4NM!j2GfjPFL"bCA0[GA*MC931: diff --git a/Mac/Lib/test/aete.py b/Mac/Lib/test/aete.py deleted file mode 100644 index 21fff6189b..0000000000 --- a/Mac/Lib/test/aete.py +++ /dev/null @@ -1,475 +0,0 @@ -# Look for scriptable applications -- that is, applications with an 'aete' resource -# Also contains (partially) reverse engineered 'aete' resource decoding - -import MacOS -import os -import string -import sys -import types -import StringIO - -from Res import * - -def main(): - filename = "" - redirect(filename, realmain) - -def redirect(filename, func, *args): - f = filename and open(filename, 'w') - save_stdout = sys.stdout - try: - if f: sys.stdout = f - return apply(func, args) - finally: - sys.stdout = save_stdout - if f: f.close() - -def realmain(): - #list('C:System Folder:Extensions:AppleScript\252') - #list('C:Tao AppleScript:Finder Liaison:Finder Liaison 1.0') - list('C:Tao AppleScript:Scriptable Text Editor') - #list('C:Internet:Eudora 1.4.2:Eudora1.4.2') - #list('E:Excel 4.0:Microsoft Excel') - #list('C:Internet:Netscape 1.0N:Netscape 1.0N') - #find('C:') - #find('D:') - #find('E:') - #find('F:') - -def find(dir, maxlevel = 5): - hits = [] - cur = CurResFile() - names = os.listdir(dir) - tuples = map(lambda x: (os.path.normcase(x), x), names) - tuples.sort() - names = map(lambda (x, y): y, tuples) - for name in names: - if name in (os.curdir, os.pardir): continue - fullname = os.path.join(dir, name) - if os.path.islink(fullname): - pass - if os.path.isdir(fullname): - if maxlevel > 0: - sys.stderr.write(" %s\n" % `fullname`) - hits = hits + find(fullname, maxlevel-1) - else: - ctor, type = MacOS.GetCreatorAndType(fullname) - if type in ('APPL', 'FNDR', 'zsys', 'INIT', 'scri', 'cdev'): - sys.stderr.write(" %s\n" % `fullname`) - try: - rf = OpenRFPerm(fullname, 0, '\1') - except MacOS.Error, msg: - print "Error:", fullname, msg - continue - UseResFile(rf) - n = Count1Resources('aete') - if rf <> cur: - CloseResFile(rf) - UseResFile(cur) - if n > 1: - hits.append(fullname) - sys.stderr.write("YES! %d in %s\n" % (n, `fullname`)) - list(fullname) - return hits - -def list(fullname): - cur = CurResFile() - rf = OpenRFPerm(fullname, 0, '\1') - try: - UseResFile(rf) - resources = [] - for i in range(Count1Resources('aete')): - res = Get1IndResource('aete', 1+i) - resources.append(res) - for i in range(Count1Resources('aeut')): - res = Get1IndResource('aeut', 1+i) - resources.append(res) - print "\nLISTING aete+aeut RESOURCES IN", `fullname` - for res in resources: - print "decoding", res.GetResInfo(), "..." - data = res.data - try: - aete = decode(data) - showaete(aete) - print "Checking putaete..." - f = StringIO.StringIO() - putaete(f, aete) - newdata = f.getvalue() - if len(newdata) == len(data): - if newdata == data: - print "putaete created identical data" - else: - newaete = decode(newdata) - if newaete == aete: - print "putaete created equivalent data" - else: - print "putaete failed the test:" - showaete(newaete) - else: - print "putaete created different data:" - print `newdata` - except: - import traceback - traceback.print_exc() - sys.stdout.flush() - finally: - if rf <> cur: - CloseResFile(rf) - UseResFile(cur) - -def decode(data): - f = StringIO.StringIO(data) - aete = generic(getaete, f) - aete = simplify(aete) - processed = f.tell() - unprocessed = len(f.read()) - total = f.tell() - if unprocessed: - sys.stderr.write("%d processed + %d unprocessed = %d total\n" % - (processed, unprocessed, total)) - return aete - -def simplify(item): - if type(item) is types.ListType: - return map(simplify, item) - elif type(item) == types.TupleType and len(item) == 2: - return simplify(item[1]) - else: - return item - - -# Here follows the aete resource decoder. -# It is presented bottom-up instead of top-down because there are direct -# references to the lower-level part-decoders from the high-level part-decoders. - -def getbyte(f, *args): - c = f.read(1) - if not c: - raise EOFError, 'in getbyte' + str(args) - return ord(c) - -def getword(f, *args): - getalign(f) - s = f.read(2) - if len(s) < 2: - raise EOFError, 'in getword' + str(args) - return (ord(s[0])<<8) | ord(s[1]) - -def getlong(f, *args): - getalign(f) - s = f.read(4) - if len(s) < 4: - raise EOFError, 'in getlong' + str(args) - return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3]) - -def getostype(f, *args): - getalign(f) - s = f.read(4) - if len(s) < 4: - raise EOFError, 'in getostype' + str(args) - return s - -def getpstr(f, *args): - c = f.read(1) - if len(c) < 1: - raise EOFError, 'in getpstr[1]' + str(args) - nbytes = ord(c) - if nbytes == 0: return '' - s = f.read(nbytes) - if len(s) < nbytes: - raise EOFError, 'in getpstr[2]' + str(args) - return s - -def getalign(f): - if f.tell() & 1: - c = f.read(1) - ##if c <> '\0': - ## print 'align:', `c` - -def getlist(f, description, getitem): - count = getword(f) - list = [] - for i in range(count): - list.append(generic(getitem, f)) - getalign(f) - return list - -def alt_generic(what, f, *args): - print "generic", `what`, args - res = vageneric(what, f, args) - print '->', `res` - return res - -def generic(what, f, *args): - if type(what) == types.FunctionType: - return apply(what, (f,) + args) - if type(what) == types.ListType: - record = [] - for thing in what: - item = apply(generic, thing[:1] + (f,) + thing[1:]) - record.append((thing[1], item)) - return record - return "BAD GENERIC ARGS: %s" % `what` - -getdata = [ - (getostype, "type"), - (getpstr, "description"), - (getword, "flags") - ] -getargument = [ - (getpstr, "name"), - (getostype, "keyword"), - (getdata, "what") - ] -getevent = [ - (getpstr, "name"), - (getpstr, "description"), - (getostype, "suite code"), - (getostype, "event code"), - (getdata, "returns"), - (getdata, "accepts"), - (getlist, "optional arguments", getargument) - ] -getproperty = [ - (getpstr, "name"), - (getostype, "code"), - (getdata, "what") - ] -getelement = [ - (getostype, "type"), - (getlist, "keyform", getostype) - ] -getclass = [ - (getpstr, "name"), - (getostype, "class code"), - (getpstr, "description"), - (getlist, "properties", getproperty), - (getlist, "elements", getelement) - ] -getcomparison = [ - (getpstr, "operator name"), - (getostype, "operator ID"), - (getpstr, "operator comment"), - ] -getenumerator = [ - (getpstr, "enumerator name"), - (getostype, "enumerator ID"), - (getpstr, "enumerator comment") - ] -getenumeration = [ - (getostype, "enumeration ID"), - (getlist, "enumerator", getenumerator) - ] -getsuite = [ - (getpstr, "suite name"), - (getpstr, "suite description"), - (getostype, "suite ID"), - (getword, "suite level"), - (getword, "suite version"), - (getlist, "events", getevent), - (getlist, "classes", getclass), - (getlist, "comparisons", getcomparison), - (getlist, "enumerations", getenumeration) - ] -getaete = [ - (getword, "major/minor version in BCD"), - (getword, "language code"), - (getword, "script code"), - (getlist, "suites", getsuite) - ] - - -# Display 'aete' resources in a friendly manner. -# This one's done top-down again... - -def showaete(aete): - [version, language, script, suites] = aete - major, minor = divmod(version, 256) - print "\nVersion %d/%d, language %d, script %d" % \ - (major, minor, language, script) - for suite in suites: - showsuite(suite) - -def showsuite(suite): - [name, desc, code, level, version, events, classes, comps, enums] = suite - print "\nSuite %s -- %s (%s)" % (`name`, `desc`, `code`) - print "Level %d, version %d" % (level, version) - for event in events: - showevent(event) - for cls in classes: - showclass(cls) - for comp in comps: - showcomparison(comp) - for enum in enums: - showenumeration(enum) - -def showevent(event): - [name, desc, code, subcode, returns, accepts, arguments] = event - print "\n Command %s -- %s (%s, %s)" % (`name`, `desc`, `code`, `subcode`) - print " returns", showdata(returns) - print " accepts", showdata(accepts) - for arg in arguments: - showargument(arg) - -def showargument(arg): - [name, keyword, what] = arg - print " %s (%s)" % (name, `keyword`), showdata(what) - -def showclass(cls): - [name, code, desc, properties, elements] = cls - print "\n Class %s (%s) -- %s" % (`name`, `code`, `desc`) - for prop in properties: - showproperty(prop) - for elem in elements: - showelement(elem) - -def showproperty(prop): - [name, code, what] = prop - print " property %s (%s)" % (`name`, `code`), showdata(what) - -def showelement(elem): - [code, keyform] = elem - print " element %s" % `code`, "as", keyform - -def showcomparison(comp): - [name, code, comment] = comp - print " comparison %s (%s) -- %s" % (`name`, `code`, comment) - -def showenumeration(enum): - [code, items] = enum - print "\n Enum %s" % `code` - for item in items: - showenumerator(item) - -def showenumerator(item): - [name, code, desc] = item - print " %s (%s) -- %s" % (`name`, `code`, `desc`) - -def showdata(data): - [type, description, flags] = data - return "%s -- %s %s" % (`type`, `description`, showdataflags(flags)) - -dataflagdict = {15: "optional", 14: "list", 13: "enum", 12: "mutable"} -def showdataflags(flags): - bits = [] - for i in range(16): - if flags & (1<>8)&0xff)) - f.write(chr(value&0xff)) - -def putostype(f, value): - putalign(f) - if type(value) != types.StringType or len(value) != 4: - raise TypeError, "ostype must be 4-char string" - f.write(value) - -def putpstr(f, value): - if type(value) != types.StringType or len(value) > 255: - raise TypeError, "pstr must be string <= 255 chars" - f.write(chr(len(value)) + value) - - -# Call the main program - -if __name__ == '__main__': - main() -else: - realmain() diff --git a/Mac/Lib/test/cmtest.py b/Mac/Lib/test/cmtest.py deleted file mode 100644 index 7170424429..0000000000 --- a/Mac/Lib/test/cmtest.py +++ /dev/null @@ -1,45 +0,0 @@ -"""cmtest - List all components in the system""" - -import Cm -import Res -import sys - -def getstr255(r): - """Get string from str255 resource""" - if not r.data: return '' - len = ord(r.data[0]) - return r.data[1:1+len] - -def getinfo(c): - """Return (type, subtype, creator, fl1, fl2, name, description) for component""" - h1 = Res.Resource('') - h2 = Res.Resource('') - h3 = Res.Resource('') - type, subtype, creator, fl1, fl2 = c.GetComponentInfo(h1, h2, h3) - name = getstr255(h1) - description = getstr255(h2) - return type, subtype, creator, fl1, fl2, name, description - -def getallcomponents(): - """Return list with info for all components, sorted""" - any = ('\0\0\0\0', '\0\0\0\0', '\0\0\0\0', 0, 0) - c = None - rv = [] - while 1: - try: - c = Cm.FindNextComponent(c, any) - except Cm.Error: - break - rv.append(getinfo(c)) - rv.sort() - return rv - -def main(): - """Print info for all components""" - info = getallcomponents() - for type, subtype, creator, f1, f2, name, description in info: - print '%4.4s %4.4s %4.4s %s 0x%x 0x%x'%(type, subtype, creator, name, f1, f2) - print ' ', description - sys.exit(1) - -main() diff --git a/Mac/Lib/test/ctbtest.py b/Mac/Lib/test/ctbtest.py deleted file mode 100644 index 5364c44b4a..0000000000 --- a/Mac/Lib/test/ctbtest.py +++ /dev/null @@ -1,41 +0,0 @@ -# -# Simple test program for ctb module: emulate a terminal. -# -import ctb -import macconsole -import sys - -def cb(err): - print 'Done, err=', err - -def main(): - if not ctb.available(): - print 'Communications Toolbox not available' - sys.exit(1) -# c = macconsole.copen('Terminal window') - print 'Minimal terminal emulator V1.0' - print '(type @ to exit)' - print - c = macconsole.fopen(sys.stdin) - f = sys.stdin - c.setmode(macconsole.C_RAW) - - l = ctb.CMNew('Serial Tool', None) - l.Open(0) - - while 1: - l.Idle() - d = f.read(1) - if d == '@': - break - if d: - l.Write(d, ctb.cmData, -1, 0) - l.Idle() - d, dummy = l.Read(1000, ctb.cmData, 0) - if d: - f.write(d) - f.flush() - l.Close(-1, 1) - del l - -main() diff --git a/Mac/Lib/test/echo.py b/Mac/Lib/test/echo.py deleted file mode 100644 index 7376238b3e..0000000000 --- a/Mac/Lib/test/echo.py +++ /dev/null @@ -1,159 +0,0 @@ -"""'echo' -- an AppleEvent handler which handles all events the same. - -It replies to each event by echoing the parameter back to the client. -This is a good way to find out how the Script Editor formats AppleEvents, -especially to figure out all the different forms an object specifier -can have (without having to rely on Apple's implementation). -""" - -import sys -sys.stdout = sys.stderr -import traceback -import MacOS -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 mymessage(str): - err = AE.AEInteractWithUser(kAEDefaultTimeout) - if err: - print str - EasyDialogs.Message(str) - -def main(): - echo = EchoServer() - yield = MacOS.EnableAppswitch(-1) # Disable Python's own "event handling" - try: - echo.mainloop(everyEvent, 0) - finally: - MacOS.EnableAppswitch(yield) # Let Python have a go at events - echo.close() - - -class EchoServer: - - #suites = ['aevt', 'core', 'reqd'] - suites = ['****'] - - def __init__(self): - self.active = 0 - for suite in self.suites: - AE.AEInstallEventHandler(suite, typeWildCard, self.aehandler) - print (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.AppendResMenu('DRVR') - applemenu.InsertMenu(0) - Menu.DrawMenuBar() - - def __del__(self): - self.close() - - def close(self): - if self.active: - self.active = 0 - for suite in self.suites: - AE.AERemoveEventHandler(suite, typeWildCard) - - def mainloop(self, mask = everyEvent, timeout = 60*60): - while 1: - self.dooneevent(mask, timeout) - - def dooneevent(self, mask = everyEvent, timeout = 60*60): - got, event = Evt.WaitNextEvent(mask, timeout) - if got: - self.lowlevelhandler(event) - - def lowlevelhandler(self, event): - what, message, when, where, modifiers = event - h, v = where - if what == kHighLevelEvent: - msg = "High Level Event: %s %s" % \ - (`code(message)`, `code(h | (v<<16))`) - try: - AE.AEProcessAppleEvent(event) - except AE.Error, err: - mymessage(msg + "\015AEProcessAppleEvent error: %s" % str(err)) - traceback.print_exc() - else: - mymessage(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: - mymessage("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) - - def aehandler(self, request, reply): - print "Apple Event!" - parameters, attributes = aetools.unpackevent(request) - print "class =", `attributes['evcl'].type`, - print "id =", `attributes['evid'].type` - print "Parameters:" - keys = parameters.keys() - keys.sort() - for key in keys: - print "%s: %.150s" % (`key`, `parameters[key]`) - print " :", str(parameters[key]) - print "Attributes:" - keys = attributes.keys() - keys.sort() - for key in keys: - print "%s: %.150s" % (`key`, `attributes[key]`) - aetools.packevent(reply, parameters) - - -_eventnames = { - keyDown: 'keyDown', - autoKey: 'autoKey', - mouseDown: 'mouseDown', - mouseUp: 'mouseUp', - updateEvt: 'updateEvt', - diskEvt: 'diskEvt', - activateEvt: 'activateEvt', - osEvt: 'osEvt', -} - -def eventname(what): - if _eventnames.has_key(what): return _eventnames[what] - else: return `what` - -def code(x): - "Convert a long int to the 4-character code it really is" - s = '' - for i in range(4): - x, c = divmod(x, 256) - s = chr(c) + s - return s - - -if __name__ == '__main__': - main() diff --git a/Mac/Lib/test/progressbar.py b/Mac/Lib/test/progressbar.py deleted file mode 100644 index 53a7e84dda..0000000000 --- a/Mac/Lib/test/progressbar.py +++ /dev/null @@ -1,25 +0,0 @@ -# Progress dialog - -from Dlg import GetNewDialog, ModalDialog, SetDialogItemText - -count = 0 - -def filter(d, e): - r = 1 - print "Filter(%s, %s) -> %s" % (`d`, `e`, `r`) - return r - -def main(): - d = GetNewDialog(256, -1) - tp, h, rect = d.GetDialogItem(2) - SetDialogItemText(h, "Progress...") - for i in range(100): - if i%10 == 0: - str = "Progress...%d" % i - SetDialogItemText(h, str) - ModalDialog(filter) - for j in range(100): pass - -if __name__ == '__main__': - main() - diff --git a/Mac/Lib/test/tae.py b/Mac/Lib/test/tae.py deleted file mode 100644 index 73c36b9241..0000000000 --- a/Mac/Lib/test/tae.py +++ /dev/null @@ -1,112 +0,0 @@ -# The oldest AppleEvent test program. -# Its function has been overtaken by echo.py and tell.py. - -import AE -from AppleEvents import * -import Evt -from Events import * -import struct -import aetools -import macfs -import sys -import MacOS - -MacOS.EnableAppswitch(0) - -def aehandler(request, reply): - tosend = [] - print 'request:', aetools.unpackevent(request) - param = request.AEGetParamDesc(keyDirectObject, typeWildCard) - if param.type == typeAEList: - n = param.AECountItems() - print 'List has', n, 'items' - for i in range(1, 1+n): - type, item = param.AEGetNthDesc(i, typeFSS) - data = item.data - print 'item', i, ':', type, item.type, len(data), 'bytes' - vol, dir, fnlen = struct.unpack('hlb', data[:7]) - filename = data[7:7+fnlen] - print 'vol:', vol, '; dir:', dir, '; filename:', `filename` - print 'full path:', macfs.FSSpec((vol,dir,filename)).as_pathname() - tosend.append(item) - else: - pass - print 'param:', (param.type, param.data[:20]), param.data[20:] and '...' - if tosend: - passtothink(tosend) - - -def passtothink(list): - target = AE.AECreateDesc(typeApplSignature, 'KAHL') - event = AE.AECreateAppleEvent(kCoreEventClass, - kAEOpenDocuments, - target, - kAutoGenerateReturnID, - kAnyTransactionID) - aetools.packevent(event, {keyDirectObject: list}) - reply = event.AESend(kAENoReply | kAEAlwaysInteract | kAECanSwitchLayer, - kAENormalPriority, - kAEDefaultTimeout) - #print "Reply:", aetools.unpackevent(reply) - return - event = AE.AECreateAppleEvent(kCoreEventClass, - kAEOpenApplication, - target, - kAutoGenerateReturnID, - kAnyTransactionID) - reply = event.AESend(kAENoReply | kAEAlwaysInteract | kAECanSwitchLayer, - kAENormalPriority, - kAEDefaultTimeout) - -def unihandler(req, rep): - print 'unihandler' - aehandler(req, rep) - -quit = 0 -def quithandler(req, rep): - global quit - quit = 1 - -def corehandler(req, rep): - print 'core event!' - parameters, attributes = aetools.unpackevent(req) - print "event class =", attributes['evcl'] - print "event id =", attributes['evid'] - print 'parameters:', parameters - # echo the arguments, to see how Script Editor formats them - aetools.packevent(rep, parameters) - -def wildhandler(req, rep): - print 'wildcard event!' - parameters, attributes = aetools.unpackevent(req) - print "event class =", attributes['evcl'] - print "event id =", attributes['evid'] - print 'parameters:', parameters - -AE.AEInstallEventHandler(typeAppleEvent, kAEOpenApplication, aehandler) -AE.AEInstallEventHandler(typeAppleEvent, kAEOpenDocuments, aehandler) -AE.AEInstallEventHandler(typeAppleEvent, kAEPrintDocuments, aehandler) -AE.AEInstallEventHandler(typeAppleEvent, kAEQuitApplication, quithandler) -AE.AEInstallEventHandler(typeAppleEvent, typeWildCard, unihandler) -AE.AEInstallEventHandler('core', typeWildCard, corehandler) -#AE.AEInstallEventHandler(typeWildCard, typeWildCard, wildhandler) - - -def main(): - global quit - quit = 0 - while not quit: - ok, e = Evt.WaitNextEvent(-1, 60) - if ok: - print 'Event:', e - if e[0] == 23: # kHighLevelEvent - AE.AEProcessAppleEvent(e) - elif e[0] == keyDown and chr(e[1]&0xff) == '.' and e[4]&cmdKey: - raise KeyboardInterrupt, "Command-Period" - else: - MacOS.HandleEvent(e) - -if __name__ == '__main__': - main() - -print "This module is obsolete -- use echo.py or tell.py ..." diff --git a/Mac/Lib/test/tctl.py b/Mac/Lib/test/tctl.py deleted file mode 100644 index a255c56671..0000000000 --- a/Mac/Lib/test/tctl.py +++ /dev/null @@ -1,20 +0,0 @@ -# play with controls - -from Dlg import * -from Ctl import * -from Win import * -from Evt import * -import time -import sys - -def main(): - r = (40, 40, 400, 300) - w = NewWindow(r, "The Spanish Inquisition", 1, 0, -1, 1, 0x55555555) - w.DrawGrowIcon() - r = (40, 40, 100, 60) - c = NewControl(w, r, "SPAM!", 1, 0, 0, 1, 0, 0) - print 'Ok, try it...' - sys.exit(1) # So we can see what happens... - - -main() diff --git a/Mac/Lib/test/tdlg.py b/Mac/Lib/test/tdlg.py deleted file mode 100644 index 6bb051b924..0000000000 --- a/Mac/Lib/test/tdlg.py +++ /dev/null @@ -1,30 +0,0 @@ -# Function to display a message and wait for the user to hit OK. -# This uses a DLOG resource with ID=256 which is part of the standard -# Python library. -# The ID can be overridden by passing a second parameter. - -from Dlg import * -from Events import * -import string - -ID = 256 - -def f(d, event): - what, message, when, where, modifiers = event - if what == keyDown and modifiers & cmdKey and \ - string.lower(chr(message & charCodeMask)) == 'o': - return 1 - -def message(str = "Hello, world!", id = ID): - d = GetNewDialog(id, -1) - tp, h, rect = d.GetDialogItem(2) - SetDialogItemText(h, str) - while 1: - n = ModalDialog(f) - if n == 1: break - -def test(): - message() - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/test/tdlg_modeless.py b/Mac/Lib/test/tdlg_modeless.py deleted file mode 100644 index 2b6a0f7861..0000000000 --- a/Mac/Lib/test/tdlg_modeless.py +++ /dev/null @@ -1,42 +0,0 @@ -# Function to display a message and wait for the user to hit OK. -# This uses a DLOG resource with ID=256 which is part of the standard -# Python library. -# The ID can be overridden by passing a second parameter. -# This is the modeless version of this test program, the normal -# modal version is in tdlg.py - -from Dlg import * -from Evt import * -from Events import * -import MacOS -import string - -ID = 256 - -def message(str = "Hello, modeless world!", id = ID): - print 'This is to init the console window...' - d = GetNewDialog(id, -1) - tp, h, rect = d.GetDialogItem(2) - SetDialogItemText(h, str) - while 1: - ok, ev = WaitNextEvent(0xffff, 10) - if not ok: - continue - if IsDialogEvent(ev): - ok, window, item = DialogSelect(ev) - if ok: - if window == d: - if item == 1: - break - else: - print 'Unexpected item hit' - else: - print 'Unexpected dialog hit' - else: - MacOS.HandleEvent(ev) - -def test(): - message() - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/test/tell.py b/Mac/Lib/test/tell.py deleted file mode 100644 index 74e0ca0fb7..0000000000 --- a/Mac/Lib/test/tell.py +++ /dev/null @@ -1,63 +0,0 @@ -# (Slightly less) primitive operations for sending Apple Events to applications. -# This could be the basis of a Script Editor like application. - -from AE import * -from AppleEvents import * -import aetools -import types - -class TalkTo: - def __init__(self, signature): - """Create a communication channel with a particular application. - - For now, the application must be given by its 4-character signature - (because I don't know yet how to do other target types). - """ - if type(signature) != types.StringType or len(signature) != 4: - raise TypeError, "signature should be 4-char string" - self.target = AECreateDesc(typeApplSignature, signature) - self.send_flags = kAEWaitReply - self.send_priority = kAENormalPriority - self.send_timeout = kAEDefaultTimeout - def newevent(self, code, subcode, parameters = {}, attributes = {}): - event = AECreateAppleEvent(code, subcode, self.target, - kAutoGenerateReturnID, kAnyTransactionID) - aetools.packevent(event, parameters, attributes) - return event - def sendevent(self, event): - reply = event.AESend(self.send_flags, self.send_priority, - self.send_timeout) - parameters, attributes = aetools.unpackevent(reply) - return reply, parameters, attributes - - def send(self, code, subcode, parameters = {}, attributes = {}): - return self.sendevent(self.newevent(code, subcode, parameters, attributes)) - - def activate(self): - # Send undocumented but easily reverse engineered 'activate' command - self.send('misc', 'actv') - - -# This object is equivalent to "selection" in AppleScript -# (in the core suite, if that makes a difference): -get_selection = aetools.Property('sele', None) - -# Test program. You can make it do what you want by passing parameters. -# The default gets the selection from Quill (Scriptable Text Editor). - -def test(app = 'quil', suite = 'core', id = 'getd', arg = get_selection): - t = TalkTo(app) - t.activate() - if arg: - dict = {'----': arg} - else: - dict = {} - reply, parameters, attributes = t.send(suite, id, dict) - print reply, parameters - if parameters.has_key('----'): print "returns:", str(parameters['----']) - - -test() -# So we can see it: -import sys -sys.exit(1) diff --git a/Mac/Lib/test/test_finder_ae b/Mac/Lib/test/test_finder_ae deleted file mode 100644 index b6241a2ce4..0000000000 --- a/Mac/Lib/test/test_finder_ae +++ /dev/null @@ -1,5 +0,0 @@ -tell application "AEservertest" - activate - set x to window "testing" - open file x -end tell diff --git a/Mac/Lib/test/test_suite.py b/Mac/Lib/test/test_suite.py deleted file mode 100644 index 2aa690d20b..0000000000 --- a/Mac/Lib/test/test_suite.py +++ /dev/null @@ -1,25 +0,0 @@ -# -# Test of generated AE modules. -# -import sys -import macfs - -import aetools -from AppleScript_Suite import AppleScript_Suite -from Required_Suite import Required_Suite -from Standard_Suite import Standard_Suite - -class ScriptableEditor(aetools.TalkTo, AppleScript_Suite, Required_Suite, - Standard_Suite): - - def __init__(self): - aetools.TalkTo.__init__(self, 'quil') - self.activate() - -app = ScriptableEditor() -rv = app.open(macfs.FSSpec(sys.argv[0])) -print 'Opened', sys.argv[0] -print 'Return value:', rv -rv = app.get(aetools.Word(10, aetools.Document(1))) -print 'Got word 10 doc 1:', rv -sys.exit(1) diff --git a/Mac/Lib/test/tlist.py b/Mac/Lib/test/tlist.py deleted file mode 100644 index fdcfe6e1c9..0000000000 --- a/Mac/Lib/test/tlist.py +++ /dev/null @@ -1,92 +0,0 @@ -# Test List module. -# Draw a window with all the files in the current folder. -# double-clicking will change folder. -# -# This test expects Win, Evt and FrameWork (and anything used by those) -# to work. -# -# Actually, it is more a test of FrameWork by now.... - -from FrameWork import * -import Win -import Qd -import List -import Lists -import os - -class ListWindow(Window): - def open(self, name, where): - self.where = where - r = (40, 40, 400, 300) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - r2 = (0, 0, 345, 245) - Qd.SetPort(w) - self.wid = w - self.list = List.LNew(r2, (0, 0, 1, 1), (0,0), 0, w, 0, 1, 1, 1) - self.list.selFlags = Lists.lOnlyOne - self.filllist() - w.DrawGrowIcon() - self.do_postopen() - - def do_activate(self, onoff, evt): - self.list.LActivate(onoff) - - def do_update(self, *args): - self.list.LUpdate(self.wid.GetWindowPort().visRgn) - - def do_contentclick(self, local, modifiers, evt): - dclick = self.list.LClick(local, modifiers) - if dclick: - h, v = self.list.LLastClick() - file = self.list.LGetCell(1000, (h, v)) - self.where = os.path.join(self.where, file) - self.filllist() - - def filllist(self): - """Fill the list with the contents of the current directory""" - l = self.list - l.LSetDrawingMode(0) - l.LDelRow(0, 0) - contents = os.listdir(self.where) - l.LAddRow(len(contents), 0) - for i in range(len(contents)): - l.LSetCell(contents[i], (0, i)) - l.LSetDrawingMode(1) - l.LUpdate(self.wid.GetWindowPort().visRgn) - - -class TestList(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.listoflists = [] - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window...", "O", self.open) - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - def open(self, *args): - import macfs - fss, ok = macfs.GetDirectory() - if not ok: - return - w = ListWindow(self) - w.open('Window %d'%self.num, fss.as_pathname()) - self.num = self.num + 1 - self.listoflists.append(w) - - def quit(self, *args): - raise self - - def do_about(self, id, item, window, event): - EasyDialogs.Message("""Test the List Manager interface. - Simple inward-only folder browser""") - -def main(): - App = TestList() - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Lib/test/tlist_dialog.py b/Mac/Lib/test/tlist_dialog.py deleted file mode 100644 index cacfd4772c..0000000000 --- a/Mac/Lib/test/tlist_dialog.py +++ /dev/null @@ -1,79 +0,0 @@ -from Dlg import * -from Events import * -from Evt import * -from List import * -from Qd import * -import Res -import string -import MacOS - -ID = 513 - -def dodialog(items): - print 'This is to create a window' - # - # Create the dialog - # - d = GetNewDialog(ID, -1) - # - # Create the list and fill it - # - tp, h, rect = d.GetDialogItem(2) - rect = rect[0], rect[1], rect[2]-15, rect[3]-15 # Space for scrollbars - length = (len(items)+1) / 2 - list = LNew(rect, (0, 0, 2, length), (0, 0), 0, d, 0, 1, 1, 1) - for i in range(len(items)): - list.LSetCell(items[i], (i%2, i/2)) - # - # Draw it. - # - list.LSetDrawingMode(1) - list.LUpdate(self.wid.GetWindowPort().visRgn) - # - # Do the (modeless) dialog - # - while 1: - ok, ev = WaitNextEvent(0xffff, 10) - if not ok: - # No event. - continue - (what, message, when, where, modifiers) = ev - if what == updateEvt: - # XXXX We just always update our list (sigh...) - SetPort(window) - list.LUpdate(self.wid.GetWindowPort().visRgn) - if IsDialogEvent(ev): - # It is a dialog event. See if it's ours. - ok, window, item = DialogSelect(ev) - if ok: - if window == d: - # Yes, it is ours. - if item == 1: # OK button - break - elif item == 2: # List - (what, message, when, where, modifiers) = ev - SetPort(window) - if what == mouseDown: - local = GlobalToLocal(where) - list.LClick(local, modifiers) - else: - print 'Unexpected item hit' - else: - print 'Unexpected dialog hit' - else: - MacOS.HandleEvent(ev) - sel = [] - for i in range(len(items)): - ok, dummycell = list.LGetSelect(0, (i%2, i/2)) - if ok: - sel.append(list.LGetCell(256, (i%2, i/2))) - print 'Your selection:', sel - -def test(): - import os, sys - Res.OpenResFile('tlist_dialog.rsrc') - dodialog(os.listdir(':')) - sys.exit(1) - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/test/tlist_dialog.rsrc.hqx b/Mac/Lib/test/tlist_dialog.rsrc.hqx deleted file mode 100644 index 2bdd330f5e..0000000000 --- a/Mac/Lib/test/tlist_dialog.rsrc.hqx +++ /dev/null @@ -1,11 +0,0 @@ -(This file must be converted with BinHex 4.0) - -:%A4XDA0dAf4TB@a[CbjbFh*M!(*cFQ058d9%!3#3"`'IhEi!N!3"!!!!!9N!!!" -C!!!!4J$k+J!!qLS!!2SU!!$k+J!!qLS!!2SUq!$k+`!!q[rj%A4XDA0dAf4TB@a -[CbjbFh*M!J!!!(*cFQ058d9%!3!!!(*cFQ058d9%!3!!R!%!N"1YGH&'!*!'!Cm -U!!$k+J!!qLS!!2SU!!$k+J!!qLS!!2SU!!$k+J!!qLVi!2SV!!$krrN!1J!!q[m -31J!!qLX!!2Vm!!$k+J!!qLS!!2SU!!$k+J!!qLS!!2SU!!$k+J!!qLS!!2SUq!$ -k+`!!q[rj!$S!!2Vr!!$k+`!!q[`!!2SU!!$k+J!!qLS!N!3m!!)!N!@U!+!![J$ -D"!*25`#3"5J!#J#P!0S!N!F+!!S!(!$CL!j6C@aPBh3JB5"hEh*N1J!!!"8!4J# -1!3i"IJ!$!3!"!*!&!J%!!!!"!!!!!9N!!!"C!!!!4J$*82J4SJ!!!"`!4J!"4%a -24`!!!"*%594-!!!!(J)"rrm!!!"!!-P4[!)"rrm!N!A*6q"4S!: diff --git a/Mac/Lib/test/tmenu.py b/Mac/Lib/test/tmenu.py deleted file mode 100644 index bc972a88d2..0000000000 --- a/Mac/Lib/test/tmenu.py +++ /dev/null @@ -1,68 +0,0 @@ -# Create hierarchical menus for some volumes. - -import os -from Menu import * -import macfs -import sys - -def main(): - global oldbar - my_volumes = [] - while 1: - fss, ok = macfs.GetDirectory() - if not ok: - break - my_volumes.append(fss.as_pathname()) - if not my_volumes: - return - oldbar = GetMenuBar() - ClearMenuBar() - makevolmenus(my_volumes) - DrawMenuBar() - -def reset(): - oldbar.SetMenuBar() - DrawMenuBar() - -id = 1 -def nextid(): - global id - nid = id - id = id+1 - return nid - -def makevolmenus(volumes): - for vol in volumes: - makevolmenu(vol) - -def makevolmenu(vol): - menu = NewMenu(nextid(), vol) - adddirectory(menu, vol) - menu.InsertMenu(0) - -def adddirectory(menu, dir, maxdepth = 1): - print "adddirectory:", `dir`, maxdepth - files = os.listdir(dir) - item = 0 - for file in files: - item = item+1 - menu.AppendMenu('x') # add a dummy string - menu.SetMenuItemText(item, file) # set the actual text - fullname = os.path.join(dir, file) - if os.path.isdir(fullname): - menu.SetMenuItemText(item, ':' + file + ':') # append colons - if maxdepth > 0: - id = nextid() - submenu = NewMenu(id, fullname) - adddirectory(submenu, fullname, maxdepth-1) - submenu.InsertMenu(-1) - # If the 'Cmd' is 0x1B, then the 'Mark' is the submenu id - menu.SetItemMark(item, id) - menu.SetItemCmd(item, 0x1B) - if not files: - menu.AppendMenu(':') # dummy item to make it selectable - return menu - -if __name__ == '__main__': - main() - sys.exit(1) # To allow the user to interact... diff --git a/Mac/Lib/test/tscrollwin.py b/Mac/Lib/test/tscrollwin.py deleted file mode 100644 index 40e9d67b64..0000000000 --- a/Mac/Lib/test/tscrollwin.py +++ /dev/null @@ -1,86 +0,0 @@ -# Test FrameWork scrollbars -# Draw a window in which the user can type. -# -# This test expects Win, Evt and FrameWork (and anything used by those) -# to work. -# -# Actually, it is more a test of FrameWork by now.... - -from FrameWork import * -import Win -import Qd -import TE -import os - -class MyWindow(ScrolledWindow): - def open(self, name): - r = (40, 40, 400, 300) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - self.ourrect = 0, 0, 360-SCROLLBARWIDTH-1, 260-SCROLLBARWIDTH-1 - Qd.SetPort(w) - w.DrawGrowIcon() - self.wid = w - self.do_postopen() - self.vx = self.vy = 0 - self.scrollbars() - - def getscrollbarvalues(self): - return self.vx, self.vy - - def scrollbar_callback(self, which, what, value): - if what == '-': - delta = -1 - elif what == '--': - delta = -100 - elif what == '+': - delta = 1 - elif what == '++': - delta = 100 - - if which == 'x': - if value: - self.vx = value - else: - self.vx = self.vx + delta - else: - if value: - self.vy = value - else: - self.vy = self.vy + delta - Win.InvalRect(self.ourrect) - - def do_update(self, wid, event): - Qd.EraseRect(self.ourrect) - Qd.MoveTo(40, 40) - Qd.DrawString("x=%d, y=%d"%(self.vx, self.vy)) - -class TestSW(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.listoflists = [] - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window...", "O", self.open) - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - def open(self, *args): - w = MyWindow(self) - w.open('Window %d'%self.num) - self.num = self.num + 1 - self.listoflists.append(w) - - def quit(self, *args): - raise self - - def do_about(self, id, item, window, event): - EasyDialogs.Message("""Test scrolling FrameWork windows""") - -def main(): - App = TestSW() - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Lib/test/tsnd.py b/Mac/Lib/test/tsnd.py deleted file mode 100644 index ac347cb640..0000000000 --- a/Mac/Lib/test/tsnd.py +++ /dev/null @@ -1,18 +0,0 @@ -# Show off SndPlay (and some resource manager functions). -# Get a list of all 'snd ' resources in the system and play them all. - -from Res import * -from Snd import * - -ch = SndNewChannel(0, 0, None) -print "Channel:", ch - -type = 'snd ' - -for i in range(CountResources(type)): - r = GetIndResource(type, i+1) - print r.GetResInfo(), r.size - if r.GetResInfo()[0] == 1: - print "Skipping simple beep" - continue - ch.SndPlay(r, 0) diff --git a/Mac/Lib/test/tte.py b/Mac/Lib/test/tte.py deleted file mode 100644 index 9e6bee4471..0000000000 --- a/Mac/Lib/test/tte.py +++ /dev/null @@ -1,17 +0,0 @@ -# Test TE module, simple version - -from Win import * -from TE import * -import Qd - -r = (40, 40, 140, 140) -w = NewWindow(r, "TETextBox test", 1, 0, -1, 1, 0x55555555) -##w.DrawGrowIcon() - -r = (10, 10, 90, 90) - -Qd.SetPort(w) -t = TETextBox("Nobody expects the SPANISH inquisition", r, 1) - -import time -time.sleep(10) diff --git a/Mac/Lib/test/ttedit.py b/Mac/Lib/test/ttedit.py deleted file mode 100644 index a4cd7746af..0000000000 --- a/Mac/Lib/test/ttedit.py +++ /dev/null @@ -1,81 +0,0 @@ -# Test TE module. -# Draw a window in which the user can type. -# -# This test expects Win, Evt and FrameWork (and anything used by those) -# to work. -# -# Actually, it is more a test of FrameWork by now.... - -from FrameWork import * -import Win -import Qd -import TE -import os - -class TEWindow(Window): - def open(self, name): - r = (40, 40, 400, 300) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - r2 = (0, 0, 345, 245) - Qd.SetPort(w) - self.ted = TE.TENew(r2, r2) - self.ted.TEAutoView(1) - w.DrawGrowIcon() - self.wid = w - self.do_postopen() - - def do_idle(self): - self.ted.TEIdle() - - def do_activate(self, onoff, evt): - if onoff: - self.ted.TEActivate() - else: - self.ted.TEDeactivate() - - def do_update(self, wid, event): - Qd.EraseRect(wid.GetWindowPort().portRect) - self.ted.TEUpdate(wid.GetWindowPort().portRect) - - def do_contentclick(self, local, modifiers, evt): - shifted = (modifiers & 0x200) - self.ted.TEClick(local, shifted) - - def do_char(self, ch, event): - self.ted.TEKey(ord(ch)) - -class TestList(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.listoflists = [] - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window...", "O", self.open) - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - def open(self, *args): - w = TEWindow(self) - w.open('Window %d'%self.num) - self.num = self.num + 1 - self.listoflists.append(w) - - def quit(self, *args): - raise self - - def do_about(self, id, item, window, event): - EasyDialogs.Message("""Test the TextEdit interface. - Simple window in which you can type""") - - def do_idle(self, *args): - for l in self.listoflists: - l.do_idle() - -def main(): - App = TestList() - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Lib/test/twedit.py b/Mac/Lib/test/twedit.py deleted file mode 100644 index 11913c96c3..0000000000 --- a/Mac/Lib/test/twedit.py +++ /dev/null @@ -1,86 +0,0 @@ -# Test waste module. -# Draw a window in which the user can type. -# -# This test expects Win, Evt and FrameWork (and anything used by those) -# to work. -# -# Actually, it is more a test of FrameWork by now.... - -from FrameWork import * -import Win -import Qd -import waste -import WASTEconst -import os - -class WasteWindow(Window): - def open(self, name): - r = (40, 40, 400, 300) - w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) - r2 = (0, 0, 400-40-16, 300-40-16) - Qd.SetPort(w) - flags = WASTEconst.weDoAutoScroll | WASTEconst.weDoOutlineHilite | \ - WASTEconst.weDoMonoStyled - self.ted = waste.WENew(r2, r2, flags) - w.DrawGrowIcon() - self.wid = w - self.do_postopen() - - def do_idle(self): - self.ted.WEIdle() - - def do_activate(self, onoff, evt): - if onoff: - self.ted.WEActivate() - else: - self.ted.WEDeactivate() - - def do_update(self, wid, event): - Qd.EraseRect(wid.GetWindowPort().portRect) - self.ted.WEUpdate(wid.GetWindowPort().visRgn) - - def do_contentclick(self, local, modifiers, evt): - (what, message, when, where, modifiers) = evt - self.ted.WEClick(local, modifiers, when) - - def do_char(self, ch, event): - (what, message, when, where, modifiers) = event - self.ted.WEKey(ord(ch), modifiers) - -class TestWaste(Application): - def __init__(self): - Application.__init__(self) - self.num = 0 - self.listoflists = [] - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.newitem = MenuItem(m, "New window...", "O", self.open) - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - def open(self, *args): - w = WasteWindow(self) - w.open('Window %d'%self.num) - self.num = self.num + 1 - self.listoflists.append(w) - - def quit(self, *args): - raise self - - def do_about(self, id, item, window, event): - EasyDialogs.Message("""Test the WASTE interface. - Simple window in which you can type""") - - def do_idle(self, *args): - for l in self.listoflists: - l.do_idle() - -def main(): - print 'Open app' - App = TestWaste() - print 'run' - App.mainloop() - -if __name__ == '__main__': - main() - diff --git a/Mac/Lib/test/twin.py b/Mac/Lib/test/twin.py deleted file mode 100644 index 0904d320bc..0000000000 --- a/Mac/Lib/test/twin.py +++ /dev/null @@ -1,9 +0,0 @@ -# Test Win module - -from Win import * - -r = (40, 40, 400, 300) -w = NewWindow(r, "Hello world", 1, 0, -1, 1, 0x55555555) -w.DrawGrowIcon() -import time -time.sleep(10) diff --git a/Mac/Lib/toolbox/AEObjects.py b/Mac/Lib/toolbox/AEObjects.py deleted file mode 100644 index b0a7c2397a..0000000000 --- a/Mac/Lib/toolbox/AEObjects.py +++ /dev/null @@ -1,61 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AEObjects.h' - -kAEAND = 'AND ' -kAEOR = 'OR ' -kAENOT = 'NOT ' -kAEFirst = 'firs' -kAELast = 'last' -kAEMiddle = 'midd' -kAEAny = 'any ' -kAEAll = 'all ' -kAENext = 'next' -kAEPrevious = 'prev' -keyAECompOperator = 'relo' -keyAELogicalTerms = 'term' -keyAELogicalOperator = 'logc' -keyAEObject1 = 'obj1' -keyAEObject2 = 'obj2' -keyAEDesiredClass = 'want' -keyAEContainer = 'from' -keyAEKeyForm = 'form' -keyAEKeyData = 'seld' -keyAERangeStart = 'star' -keyAERangeStop = 'stop' -keyDisposeTokenProc = 'xtok' -keyAECompareProc = 'cmpr' -keyAECountProc = 'cont' -keyAEMarkTokenProc = 'mkid' -keyAEMarkProc = 'mark' -keyAEAdjustMarksProc = 'adjm' -keyAEGetErrDescProc = 'indc' -formAbsolutePosition = 'indx' -formRelativePosition = 'rele' -formTest = 'test' -formRange = 'rang' -formPropertyID = 'prop' -formName = 'name' -typeObjectSpecifier = 'obj ' -typeObjectBeingExamined = 'exmn' -typeCurrentContainer = 'ccnt' -typeToken = 'toke' -typeRelativeDescriptor = 'rel ' -typeAbsoluteOrdinal = 'abso' -typeIndexDescriptor = 'inde' -typeRangeDescriptor = 'rang' -typeLogicalDescriptor = 'logi' -typeCompDescriptor = 'cmpd' -typeOSLTokenList = 'ostl' -kAEIDoMinimum = 0x0000 -kAEIDoWhose = 0x0001 -kAEIDoMarking = 0x0004 -kAEPassSubDescs = 0x0008 -kAEResolveNestedLists = 0x0010 -kAEHandleSimpleRanges = 0x0020 -kAEUseRelativeIterators = 0x0040 -typeWhoseDescriptor = 'whos' -formWhose = 'whos' -typeWhoseRange = 'wrng' -keyAEWhoseRangeStart = 'wstr' -keyAEWhoseRangeStop = 'wstp' -keyAEIndex = 'kidx' -keyAETest = 'ktst' diff --git a/Mac/Lib/toolbox/AERegistry.py b/Mac/Lib/toolbox/AERegistry.py deleted file mode 100644 index 24511bebd9..0000000000 --- a/Mac/Lib/toolbox/AERegistry.py +++ /dev/null @@ -1,438 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AERegistry.h' - -cAEList = 'list' -cApplication = 'capp' -cArc = 'carc' -cBoolean = 'bool' -cCell = 'ccel' -cChar = 'cha ' -cColorTable = 'clrt' -cColumn = 'ccol' -cDocument = 'docu' -cDrawingArea = 'cdrw' -cEnumeration = 'enum' -cFile = 'file' -cFixed = 'fixd' -cFixedPoint = 'fpnt' -cFixedRectangle = 'frct' -cGraphicLine = 'glin' -cGraphicObject = 'cgob' -cGraphicShape = 'cgsh' -cGraphicText = 'cgtx' -cGroupedGraphic = 'cpic' -cInsertionLoc = 'insl' -cInsertionPoint = 'cins' -cIntlText = 'itxt' -cIntlWritingCode = 'intl' -cItem = 'citm' -cLine = 'clin' -cLongDateTime = 'ldt ' -cLongFixed = 'lfxd' -cLongFixedPoint = 'lfpt' -cLongFixedRectangle = 'lfrc' -cLongInteger = 'long' -cLongPoint = 'lpnt' -cLongRectangle = 'lrct' -cMachineLoc = 'mLoc' -cMenu = 'cmnu' -cMenuItem = 'cmen' -cObject = 'cobj' -cObjectSpecifier = 'obj ' -cOpenableObject = 'coob' -cOval = 'covl' -cParagraph = 'cpar' -cPICT = 'PICT' -cPixel = 'cpxl' -cPixelMap = 'cpix' -cPolygon = 'cpgn' -cProperty = 'prop' -cQDPoint = 'QDpt' -cQDRectangle = 'qdrt' -cRectangle = 'crec' -cRGBColor = 'cRGB' -cRotation = 'trot' -cRoundedRectangle = 'crrc' -cRow = 'crow' -cSelection = 'csel' -cShortInteger = 'shor' -cTable = 'ctbl' -cText = 'ctxt' -cTextFlow = 'cflo' -cTextStyles = 'tsty' -cType = 'type' -cVersion = 'vers' -cWindow = 'cwin' -cWord = 'cwor' -enumArrows = 'arro' -enumJustification = 'just' -enumKeyForm = 'kfrm' -enumPosition = 'posi' -enumProtection = 'prtn' -enumQuality = 'qual' -enumSaveOptions = 'savo' -enumStyle = 'styl' -enumTransferMode = 'tran' -formUniqueID = 'ID ' -kAEAbout = 'abou' -kAEAfter = 'afte' -kAEAliasSelection = 'sali' -kAEAllCaps = 'alcp' -kAEArrowAtEnd = 'aren' -kAEArrowAtStart = 'arst' -kAEArrowBothEnds = 'arbo' -kAEAsk = 'ask ' -kAEBefore = 'befo' -kAEBeginning = 'bgng' -kAEBeginsWith = 'bgwt' -kAEBeginTransaction = 'begi' -kAEBold = 'bold' -kAECaseSensEquals = 'cseq' -kAECentered = 'cent' -kAEChangeView = 'view' -kAEClone = 'clon' -kAEClose = 'clos' -kAECondensed = 'cond' -kAEContains = 'cont' -kAECopy = 'copy' -kAECoreSuite = 'core' -kAECountElements = 'cnte' -kAECreateElement = 'crel' -kAECreatePublisher = 'cpub' -kAECut = 'cut ' -kAEDelete = 'delo' -kAEDoObjectsExist = 'doex' -kAEDoScript = 'dosc' -kAEDrag = 'drag' -kAEDuplicateSelection = 'sdup' -kAEEditGraphic = 'edit' -kAEEmptyTrash = 'empt' -kAEEnd = 'end ' -kAEEndsWith = 'ends' -kAEEndTransaction = 'endt' -kAEEquals = '= ' -kAEExpanded = 'pexp' -kAEFast = 'fast' -kAEFinderEvents = 'FNDR' -kAEFormulaProtect = 'fpro' -kAEFullyJustified = 'full' -kAEGetClassInfo = 'qobj' -kAEGetData = 'getd' -kAEGetDataSize = 'dsiz' -kAEGetEventInfo = 'gtei' -kAEGetInfoSelection = 'sinf' -kAEGetPrivilegeSelection = 'sprv' -kAEGetSuiteInfo = 'gtsi' -kAEGreaterThan = '> ' -kAEGreaterThanEquals = '>= ' -kAEGrow = 'grow' -kAEHidden = 'hidn' -kAEHiQuality = 'hiqu' -kAEImageGraphic = 'imgr' -kAEIsUniform = 'isun' -kAEItalic = 'ital' -kAELeftJustified = 'left' -kAELessThan = '< ' -kAELessThanEquals = '<= ' -kAELowercase = 'lowc' -kAEMakeObjectsVisible = 'mvis' -kAEMiscStandards = 'misc' -kAEModifiable = 'modf' -kAEMove = 'move' -kAENo = 'no ' -kAENoArrow = 'arno' -kAENonmodifiable = 'nmod' -kAEOpen = 'odoc' -kAEOpenSelection = 'sope' -kAEOutline = 'outl' -kAEPageSetup = 'pgsu' -kAEPaste = 'past' -kAEPlain = 'plan' -kAEPrint = 'pdoc' -kAEPrintSelection = 'spri' -kAEPrintWindow = 'pwin' -kAEPutAwaySelection = 'sput' -kAEQDAddOver = 'addo' -kAEQDAddPin = 'addp' -kAEQDAdMax = 'admx' -kAEQDAdMin = 'admn' -kAEQDBic = 'bic ' -kAEQDBlend = 'blnd' -kAEQDCopy = 'cpy ' -kAEQDNotBic = 'nbic' -kAEQDNotCopy = 'ncpy' -kAEQDNotOr = 'ntor' -kAEQDNotXor = 'nxor' -kAEQDOr = 'or ' -kAEQDSubOver = 'subo' -kAEQDSubPin = 'subp' -kAEQDSupplementalSuite = 'qdsp' -kAEQDXor = 'xor ' -kAEQuickdrawSuite = 'qdrw' -kAEQuitAll = 'quia' -kAERedo = 'redo' -kAERegular = 'regl' -kAEReplace = 'rplc' -kAERequiredSuite = 'reqd' -kAERestart = 'rest' -kAERevealSelection = 'srev' -kAERevert = 'rvrt' -kAERightJustified = 'rght' -kAESave = 'save' -kAESelect = 'slct' -kAESetData = 'setd' -kAESetPosition = 'posn' -kAEShadow = 'shad' -kAEShowClipboard = 'shcl' -kAEShutDown = 'shut' -kAESleep = 'slep' -kAESmallCaps = 'smcp' -kAESpecialClassProperties = 'c@#!' -kAEStrikethrough = 'strk' -kAESubscript = 'sbsc' -kAESuperscript = 'spsc' -kAETableSuite = 'tbls' -kAETextSuite = 'TEXT' -kAETransactionTerminated = 'ttrm' -kAEUnderline = 'undl' -kAEUndo = 'undo' -kAEWholeWordEquals = 'wweq' -kAEYes = 'yes ' -kAEZoom = 'zoom' -keyAEAngle = 'kang' -keyAEArcAngle = 'parc' -keyAEBaseAddr = 'badd' -keyAEBestType = 'pbst' -keyAEBgndColor = 'kbcl' -keyAEBgndPattern = 'kbpt' -keyAEBounds = 'pbnd' -keyAECellList = 'kclt' -keyAEClassID = 'clID' -keyAEColor = 'colr' -keyAEColorTable = 'cltb' -keyAECurveHeight = 'kchd' -keyAECurveWidth = 'kcwd' -keyAEDashStyle = 'pdst' -keyAEData = 'data' -keyAEDefaultType = 'deft' -keyAEDefinitionRect = 'pdrt' -keyAEDescType = 'dstp' -keyAEDestination = 'dest' -keyAEDoAntiAlias = 'anta' -keyAEDoDithered = 'gdit' -keyAEDoRotate = 'kdrt' -keyAEDoScale = 'ksca' -keyAEDoTranslate = 'ktra' -keyAEEditionFileLoc = 'eloc' -keyAEElements = 'elms' -keyAEEndPoint = 'pend' -keyAEEventClass = 'evcl' -keyAEEventID = 'evti' -keyAEFile = 'kfil' -keyAEFileType = 'fltp' -keyAEFillColor = 'flcl' -keyAEFillPattern = 'flpt' -keyAEFlipHorizontal = 'kfho' -keyAEFlipVertical = 'kfvt' -keyAEFont = 'font' -keyAEFormula = 'pfor' -keyAEGraphicObjects = 'gobs' -keyAEID = 'ID ' -keyAEImageQuality = 'gqua' -keyAEInsertHere = 'insh' -keyAEKeyForms = 'keyf' -keyAEKeyword = 'kywd' -keyAELevel = 'levl' -keyAELineArrow = 'arro' -keyAEName = 'pnam' -keyAENewElementLoc = 'pnel' -keyAEObject = 'kobj' -keyAEObjectClass = 'kocl' -keyAEOffStyles = 'ofst' -keyAEOnStyles = 'onst' -keyAEParameters = 'prms' -keyAEParamFlags = 'pmfg' -keyAEPenColor = 'ppcl' -keyAEPenPattern = 'pppa' -keyAEPenWidth = 'ppwd' -keyAEPixelDepth = 'pdpt' -keyAEPixMapMinus = 'kpmm' -keyAEPMTable = 'kpmt' -keyAEPointList = 'ptlt' -keyAEPointSize = 'ptsz' -keyAEPosition = 'kpos' -keyAEPropData = 'prdt' -keyAEProperties = 'qpro' -keyAEProperty = 'kprp' -keyAEPropFlags = 'prfg' -keyAEPropID = 'prop' -keyAEProtection = 'ppro' -keyAERenderAs = 'kren' -keyAERequestedType = 'rtyp' -keyAEResult = '----' -keyAEResultInfo = 'rsin' -keyAERotation = 'prot' -keyAERotPoint = 'krtp' -keyAERowList = 'krls' -keyAESaveOptions = 'savo' -keyAEScale = 'pscl' -keyAEScriptTag = 'psct' -keyAEShowWhere = 'show' -keyAEStartAngle = 'pang' -keyAEStartPoint = 'pstp' -keyAEStyles = 'ksty' -keyAESuiteID = 'suit' -keyAEText = 'ktxt' -keyAETextColor = 'ptxc' -keyAETextFont = 'ptxf' -keyAETextPointSize = 'ptps' -keyAETextStyles = 'txst' -keyAETheText = 'thtx' -keyAETransferMode = 'pptm' -keyAETranslation = 'ptrs' -keyAETryAsStructGraf = 'toog' -keyAEUniformStyles = 'ustl' -keyAEUpdateOn = 'pupd' -keyAEUserTerm = 'utrm' -keyAEWindow = 'wndw' -keyAEWritingCode = 'wrcd' -keyAETSMScriptTag = 'sclg' -keyAETSMTextFont = 'ktxf' -keyAETSMTextPointSize = 'ktps' -keyMiscellaneous = 'fmsc' -keySelection = 'fsel' -keyWindow = 'kwnd' -pArcAngle = 'parc' -pBackgroundColor = 'pbcl' -pBackgroundPattern = 'pbpt' -pBestType = 'pbst' -pBounds = 'pbnd' -pClass = 'pcls' -pClipboard = 'pcli' -pColor = 'colr' -pColorTable = 'cltb' -pContents = 'pcnt' -pCornerCurveHeight = 'pchd' -pCornerCurveWidth = 'pcwd' -pDashStyle = 'pdst' -pDefaultType = 'deft' -pDefinitionRect = 'pdrt' -pEnabled = 'enbl' -pEndPoint = 'pend' -pFillColor = 'flcl' -pFillPattern = 'flpt' -pFont = 'font' -pFormula = 'pfor' -pGraphicObjects = 'gobs' -pHasCloseBox = 'hclb' -pHasTitleBar = 'ptit' -pID = 'ID ' -pIndex = 'pidx' -pInsertionLoc = 'pins' -pIsFloating = 'isfl' -pIsFrontProcess = 'pisf' -pIsModal = 'pmod' -pIsModified = 'imod' -pIsResizable = 'prsz' -pIsStationeryPad = 'pspd' -pIsZoomable = 'iszm' -pIsZoomed = 'pzum' -pItemNumber = 'itmn' -pJustification = 'pjst' -pLineArrow = 'arro' -pMenuID = 'mnid' -pName = 'pnam' -pNewElementLoc = 'pnel' -pPenColor = 'ppcl' -pPenPattern = 'pppa' -pPenWidth = 'ppwd' -pPixelDepth = 'pdpt' -pPointList = 'ptlt' -pPointSize = 'ptsz' -pProtection = 'ppro' -pRotation = 'prot' -pScale = 'pscl' -pScript = 'scpt' -pScriptTag = 'psct' -pSelected = 'selc' -pSelection = 'sele' -pStartAngle = 'pang' -pStartPoint = 'pstp' -pTextColor = 'ptxc' -pTextFont = 'ptxf' -pTextItemDelimiters = 'txdl' -pTextPointSize = 'ptps' -pTextStyles = 'txst' -pTransferMode = 'pptm' -pTranslation = 'ptrs' -pUniformStyles = 'ustl' -pUpdateOn = 'pupd' -pUserSelection = 'pusl' -pVersion = 'vers' -pVisible = 'pvis' -typeAEText = 'tTXT' -typeArc = 'carc' -typeBest = 'best' -typeCell = 'ccel' -typeClassInfo = 'gcli' -typeColorTable = 'clrt' -typeColumn = 'ccol' -typeDashStyle = 'tdas' -typeData = 'tdta' -typeDrawingArea = 'cdrw' -typeElemInfo = 'elin' -typeEnumeration = 'enum' -typeEPS = 'EPS ' -typeEventInfo = 'evin' -typeFinderWindow = 'fwin' -typeFixedPoint = 'fpnt' -typeFixedRectangle = 'frct' -typeGraphicLine = 'glin' -typeGraphicText = 'cgtx' -typeGroupedGraphic = 'cpic' -typeInsertionLoc = 'insl' -typeIntlText = 'itxt' -typeIntlWritingCode = 'intl' -typeLongDateTime = 'ldt ' -typeLongFixed = 'lfxd' -typeLongFixedPoint = 'lfpt' -typeLongFixedRectangle = 'lfrc' -typeLongPoint = 'lpnt' -typeLongRectangle = 'lrct' -typeMachineLoc = 'mLoc' -typeOval = 'covl' -typeParamInfo = 'pmin' -typePict = 'PICT' -typePixelMap = 'cpix' -typePixMapMinus = 'tpmm' -typePolygon = 'cpgn' -typePropInfo = 'pinf' -typeQDPoint = 'QDpt' -typeRectangle = 'crec' -typeRGB16 = 'tr16' -typeRGB96 = 'tr96' -typeRGBColor = 'cRGB' -typeRotation = 'trot' -typeRoundedRectangle = 'crrc' -typeRow = 'crow' -typeScrapStyles = 'styl' -typeScript = 'scpt' -typeStyledText = 'STXT' -typeSuiteInfo = 'suin' -typeTable = 'ctbl' -typeTextStyles = 'tsty' -typeTIFF = 'TIFF' -typeVersion = 'vers' -kBySmallIcon = 0 -kByIconView = 1 -kByNameView = 2 -kByDateView = 3 -kBySizeView = 4 -kByKindView = 5 -kByCommentView = 6 -kByLabelView = 7 -kByVersionView = 8 -kAEInfo = 11 -kAEMain = 0 -kAESharing = 13 -kAEZoomIn = 7 -kAEZoomOut = 8 diff --git a/Mac/Lib/toolbox/AppleEvents.py b/Mac/Lib/toolbox/AppleEvents.py deleted file mode 100644 index 4d43a93791..0000000000 --- a/Mac/Lib/toolbox/AppleEvents.py +++ /dev/null @@ -1,104 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AppleEvents.h' - -typeBoolean = 'bool' -typeChar = 'TEXT' -typeSMInt = 'shor' -typeInteger = 'long' -typeSMFloat = 'sing' -typeFloat = 'doub' -typeLongInteger = 'long' -typeShortInteger = 'shor' -typeLongFloat = 'doub' -typeShortFloat = 'sing' -typeExtended = 'exte' -typeComp = 'comp' -typeMagnitude = 'magn' -typeAEList = 'list' -typeAERecord = 'reco' -typeAppleEvent = 'aevt' -typeTrue = 'true' -typeFalse = 'fals' -typeAlias = 'alis' -typeEnumerated = 'enum' -typeType = 'type' -typeAppParameters = 'appa' -typeProperty = 'prop' -typeFSS = 'fss ' -typeKeyword = 'keyw' -typeSectionH = 'sect' -typeWildCard = '****' -typeApplSignature = 'sign' -typeQDRectangle = 'qdrt' -typeFixed = 'fixd' -typeSessionID = 'ssid' -typeTargetID = 'targ' -typeProcessSerialNumber = 'psn ' -typeNull = 'null' -keyDirectObject = '----' -keyErrorNumber = 'errn' -keyErrorString = 'errs' -keyProcessSerialNumber = 'psn ' -keyTransactionIDAttr = 'tran' -keyReturnIDAttr = 'rtid' -keyEventClassAttr = 'evcl' -keyEventIDAttr = 'evid' -keyAddressAttr = 'addr' -keyOptionalKeywordAttr = 'optk' -keyTimeoutAttr = 'timo' -keyInteractLevelAttr = 'inte' -keyEventSourceAttr = 'esrc' -keyMissedKeywordAttr = 'miss' -keyOriginalAddressAttr = 'from' -keyPreDispatch = 'phac' -keySelectProc = 'selh' -keyAERecorderCount = 'recr' -keyAEVersion = 'vers' -kCoreEventClass = 'aevt' -kAEOpenApplication = 'oapp' -kAEOpenDocuments = 'odoc' -kAEPrintDocuments = 'pdoc' -kAEQuitApplication = 'quit' -kAEAnswer = 'ansr' -kAEApplicationDied = 'obit' -kAENoReply = 0x00000001 -kAEQueueReply = 0x00000002 -kAEWaitReply = 0x00000003 -kAENeverInteract = 0x00000010 -kAECanInteract = 0x00000020 -kAEAlwaysInteract = 0x00000030 -kAECanSwitchLayer = 0x00000040 -kAEDontReconnect = 0x00000080 -kAEDontRecord = 0x00001000 -kAEDontExecute = 0x00002000 -kAENormalPriority = 0x00000000 -kAEStartRecording = 'reca' -kAEStopRecording = 'recc' -kAENotifyStartRecording = 'rec1' -kAENotifyStopRecording = 'rec0' -kAENotifyRecording = 'recr' -kAutoGenerateReturnID = -1 -kAnyTransactionID = 0 -kAEDefaultTimeout = -1 -kNoTimeOut = -2 -kAENoDispatch = 0 -kAEUseStandardDispatch = 0xFFFFFFFF -kAEDoNotIgnoreHandler = 0x00000000 -kAEIgnoreAppPhacHandler = 0x00000001 -kAEIgnoreAppEventHandler = 0x00000002 -kAEIgnoreSysPhacHandler = 0x00000004 -kAEIgnoreSysEventHandler = 0x00000008 -kAEIngoreBuiltInEventHandler = 0x00000010 -kAEDontDisposeOnResume = 0x80000000 -kAEInteractWithSelf = 0 -kAEInteractWithLocal = 1 -kAEInteractWithAll = 2 -kAEUnknownSource = 0 -kAEDirectCall = 1 -kAESameProcess = 2 -kAELocalProcess = 3 -kAERemoteProcess = 4 -kAEDataArray = 0 -kAEPackedArray = 1 -kAEHandleArray = 2 -kAEDescArray = 3 -kAEKeyDescArray = 4 diff --git a/Mac/Lib/toolbox/AppleScript_Suite.py b/Mac/Lib/toolbox/AppleScript_Suite.py deleted file mode 100644 index b0755b1e95..0000000000 --- a/Mac/Lib/toolbox/AppleScript_Suite.py +++ /dev/null @@ -1,1051 +0,0 @@ -"""Suite AppleScript Suite: Goodies for Gustav -Level 1, version 1 - -Generated from Moes:System folder:Extensions:Scripting Additions:Dialects:English Dialect -AETE/AEUT resource version 1/0, language 0, script 0 -""" - -import aetools -import MacOS - -_code = 'ascr' - -_Enum_cons = { - 'case' : 'case', # case - 'diacriticals' : 'diac', # diacriticals - 'white_space' : 'whit', # white space - 'hyphens' : 'hyph', # hyphens - 'expansion' : 'expa', # expansion - 'punctuation' : 'punc', # punctuation - 'application_responses' : 'rmte', # remote event replies -} - -_Enum_boov = { - 'true' : 'true', # the true boolean value - 'false' : 'fals', # the false boolean value -} - -_Enum_misc = { - 'current_application' : 'cura', # the current application -} - -class AppleScript_Suite: - - def activate(self, _no_object=None, _attributes={}, **_arguments): - """activate: Bring targeted application program to the front. - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'misc' - _subcode = 'actv' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def log(self, _object, _attributes={}, **_arguments): - """log: Cause a comment to be logged. - Required argument: anything - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'ascr' - _subcode = 'cmnt' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def stop_log(self, _no_object=None, _attributes={}, **_arguments): - """stop log: - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'ToyS' - _subcode = 'log0' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def start_log(self, _no_object=None, _attributes={}, **_arguments): - """start log: - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'ToyS' - _subcode = 'log1' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def copy(self, _no_object=None, _attributes={}, **_arguments): - """copy: Copy an object to the clipboard - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'misc' - _subcode = 'copy' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def do_script(self, _object, _attributes={}, **_arguments): - """do script: Execute a script - Required argument: the script to execute - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'misc' - _subcode = 'dosc' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def idle(self, _no_object=None, _attributes={}, **_arguments): - """idle: Sent to a script application when it is idle - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Number of seconds to wait for next idle event - """ - _code = 'misc' - _subcode = 'idle' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def launch(self, _no_object=None, _attributes={}, **_arguments): - """launch: Start an application for scripting - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'noop' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def tell(self, _no_object=None, _attributes={}, **_arguments): - """tell: Magic tell event for event logging - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'tell' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def end_tell(self, _no_object=None, _attributes={}, **_arguments): - """end tell: Start an application for scripting - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'tend' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_error = { - 'number' : 'errn', - 'partial_result' : 'ptlr', - '_from' : 'erob', - 'to' : 'errt', - } - - def error(self, _object=None, _attributes={}, **_arguments): - """error: Raise an error - Required argument: anything - Keyword argument number: an error number - Keyword argument partial_result: any partial result occurring before the error - Keyword argument _from: the object that caused the error - Keyword argument to: another parameter to the error - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'err ' - - aetools.keysubst(_arguments, self._argmap_error) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Call_a5_subroutine = { - 'at' : 'at ', - '_from' : 'from', - '_for' : 'for ', - 'to' : 'to ', - 'thru' : 'thru', - 'through' : 'thgh', - 'by' : 'by ', - 'on' : 'on ', - 'into' : 'into', - 'onto' : 'onto', - 'between' : 'btwn', - 'against' : 'agst', - 'out_of' : 'outo', - 'instead_of' : 'isto', - 'aside_from' : 'asdf', - 'around' : 'arnd', - 'beside' : 'bsid', - 'beneath' : 'bnth', - 'under' : 'undr', - 'over' : 'over', - 'above' : 'abve', - 'below' : 'belw', - 'apart_from' : 'aprt', - 'given' : 'givn', - 'with' : 'with', - 'without' : 'wout', - 'about' : 'abou', - 'since' : 'snce', - 'until' : 'till', - 'returning' : 'Krtn', - } - - def Call_a5_subroutine(self, _object=None, _attributes={}, **_arguments): - """CallÂ¥subroutine: A subroutine call - Required argument: anything - Keyword argument at: a preposition - Keyword argument _from: a preposition - Keyword argument _for: a preposition - Keyword argument to: a preposition - Keyword argument thru: a preposition - Keyword argument through: a preposition - Keyword argument by: a preposition - Keyword argument on: a preposition - Keyword argument into: a preposition - Keyword argument onto: a preposition - Keyword argument between: a preposition - Keyword argument against: a preposition - Keyword argument out_of: a preposition - Keyword argument instead_of: a preposition - Keyword argument aside_from: a preposition - Keyword argument around: a preposition - Keyword argument beside: a preposition - Keyword argument beneath: a preposition - Keyword argument under: a preposition - Keyword argument over: a preposition - Keyword argument above: a preposition - Keyword argument below: a preposition - Keyword argument apart_from: a preposition - Keyword argument given: a preposition - Keyword argument with: special preposition for setting event properties - Keyword argument without: special preposition for clearing event properties - Keyword argument about: a preposition - Keyword argument since: a preposition - Keyword argument until: a preposition - Keyword argument returning: specifies a pattern to match results to - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'psbr' - - aetools.keysubst(_arguments, self._argmap_Call_a5_subroutine) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _3d_(self, _object, _attributes={}, **_arguments): - """=: Equality - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '= ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _ad_(self, _object, _attributes={}, **_arguments): - """­: Inequality - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '\255 ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _2b_(self, _object, _attributes={}, **_arguments): - """+: Addition - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '+ ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _2d_(self, _object, _attributes={}, **_arguments): - """-: Subtraction - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '- ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _2a_(self, _object, _attributes={}, **_arguments): - """*: Multiplication - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '* ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _d6_(self, _object, _attributes={}, **_arguments): - """Ö: Division - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '/ ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def div(self, _object, _attributes={}, **_arguments): - """div: Quotient - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'div ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def mod(self, _object, _attributes={}, **_arguments): - """mod: Remainder - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'mod ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _5e_(self, _object, _attributes={}, **_arguments): - """^: Exponentiation - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '^ ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _3e_(self, _object, _attributes={}, **_arguments): - """>: Greater than - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '> ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _b3_(self, _object, _attributes={}, **_arguments): - """³: Greater than or equal to - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '>= ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _3c_(self, _object, _attributes={}, **_arguments): - """<: Less than - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '< ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _b2_(self, _object, _attributes={}, **_arguments): - """²: Less than or equal to - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = '<= ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _26_(self, _object, _attributes={}, **_arguments): - """&: Concatenation - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'ccat' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def starts_with(self, _object, _attributes={}, **_arguments): - """starts with: Starts with - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'bgwt' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def ends_with(self, _object, _attributes={}, **_arguments): - """ends with: Ends with - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'ends' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def contains(self, _object, _attributes={}, **_arguments): - """contains: Containment - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'cont' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _and(self, _object, _attributes={}, **_arguments): - """and: Logical conjunction - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'AND ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _or(self, _object, _attributes={}, **_arguments): - """or: Logical disjunction - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'OR ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def as(self, _object, _attributes={}, **_arguments): - """as: Coercion - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'coer' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _not(self, _object, _attributes={}, **_arguments): - """not: Logical negation - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'NOT ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def negate(self, _object, _attributes={}, **_arguments): - """negate: Numeric negation - Required argument: an AE object reference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: anything - """ - _code = 'ascr' - _subcode = 'neg ' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - -# Class '' ('undf') -- 'the undefined value' - -# Class 'upper case' ('case') -- 'Text with lower case converted to upper case' - -# Class 'machines' ('mach') -- 'every computer' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'machine' ('mach') -- 'A computer' - -# Class 'zones' ('zone') -- 'every AppleTalk zone' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'zone' ('zone') -- 'AppleTalk zone' - -# Class 'seconds' ('scnd') -- 'more than one second' - -# Class 'item' ('cobj') -- 'An item of any type' -# property 'id' ('ID ') 'long' -- 'the unique id number of this object' [mutable] - -# Class 'items' ('cobj') -- 'Every item' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'text items' ('citm') -- '' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'text item' ('citm') -- '' - -# Class 'date' ('ldt ') -- 'Absolute date and time values' -# property 'weekday' ('wkdy') 'wkdy' -- 'the day of a week of a date' [] -# property 'month' ('mnth') 'mnth' -- 'the month of a date' [] -# property 'day' ('day ') 'long' -- 'the day of the month of a date' [] -# property 'year' ('year') 'long' -- 'the year of a date' [] -# property 'time' ('time') 'long' -- 'the time since midnight of a date' [] -# property 'date string' ('dstr') 'TEXT' -- 'the date portion of a date-time value as a string' [] -# property 'time string' ('tstr') 'TEXT' -- 'the time portion of a date-time value as a string' [] - -# Class 'dates' ('ldt ') -- 'every date' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'month' ('mnth') -- 'a month' - -# Class 'months' ('mnth') -- 'every month' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'January' ('jan ') -- "It's June in January..." - -# Class 'February' ('feb ') -- 'the month of February' - -# Class 'March' ('mar ') -- 'the month of March' - -# Class 'April' ('apr ') -- 'the month of April' - -# Class 'May' ('may ') -- 'the very merry month of May' - -# Class 'June' ('jun ') -- 'the month of June' - -# Class 'July' ('jul ') -- 'the month of July' - -# Class 'August' ('aug ') -- 'the month of August' - -# Class 'September' ('sep ') -- 'the month of September' - -# Class 'October' ('oct ') -- 'the month of October' - -# Class 'November' ('nov ') -- 'the month of November' - -# Class 'December' ('dec ') -- 'the month of December' - -# Class 'weekday' ('wkdy') -- 'a weekday' - -# Class 'weekdays' ('wkdy') -- 'every weekday' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'Sunday' ('sun ') -- 'Sunday Bloody Sunday' - -# Class 'Monday' ('mon ') -- 'Blue Monday' - -# Class 'Tuesday' ('tue ') -- 'Ruby Tuesday' - -# Class 'Wednesday' ('wed ') -- 'Wednesday Week' - -# Class 'Thursday' ('thu ') -- 'Thursday Afternoon' - -# Class 'Friday' ('fri ') -- 'Friday' - -# Class 'Saturday' ('sat ') -- "Saturday Night's Alright for Fighting" - -# Class 'RGB color' ('cRGB') -- 'Three numbers specifying red, green, blue color values' - -# Class 'RGB colors' ('cRGB') -- 'every RGB color' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'integer' ('long') -- 'An integral number' - -# Class 'integers' ('long') -- 'every integer' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'boolean' ('bool') -- 'A true or false value' - -# Class 'booleans' ('bool') -- 'every boolean' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'real' ('doub') -- 'A real number' - -# Class 'reals' ('doub') -- 'every real' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'list' ('list') -- 'An ordered collection of items' -# property 'length' ('leng') 'long' -- 'the length of a list' [] - -# Class 'lists' ('list') -- 'every list' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'linked list' ('llst') -- 'An ordered collection of items' -# property 'length' ('leng') 'long' -- 'the length of a list' [] - -# Class 'linked lists' ('llst') -- 'every linked list' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'vector' ('vect') -- 'An ordered collection of items' -# property 'length' ('leng') 'long' -- 'the length of a list' [] - -# Class 'vectors' ('vect') -- 'every vector' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'record' ('reco') -- 'A set of labeled items' - -# Class 'records' ('reco') -- 'every record' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'script' ('scpt') -- 'An AppleScript script' -# property 'parent' ('pare') 'scpt' -- 'the parent of a script' [] - -# Class 'scripts' ('scpt') -- 'every script' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'string' ('TEXT') -- 'a sequence of characters' - -# Class 'strings' ('TEXT') -- 'every string' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'styled text' ('STXT') -- 'a sequence of characters with style' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'number' ('nmbr') -- 'an integer or floating point number' - -# Class 'numbers' ('nmbr') -- 'every number' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'class' ('pcls') -- 'the type of a value' -# property 'inherits' ('c@#^') 'pcls' -- 'classes to inherit properties from' [] - -# Class 'classes' ('pcls') -- 'every class' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'event' ('evnt') -- 'an AppleEvents event' - -# Class 'events' ('evnt') -- 'every event' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'property' ('prop') -- 'an AppleEvents property' - -# Class 'properties' ('prop') -- 'every property' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'constant' ('enum') -- 'A constant value' - -# Class 'constants' ('enum') -- 'every constant' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'preposition' ('prep') -- 'an AppleEvents preposition' - -# Class 'prepositions' ('prep') -- 'every preposition' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'key' ('keyf') -- 'an AppleEvents key form' - -# Class 'keys' ('keyf') -- 'every key' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'picture' ('PICT') -- 'A picture' - -# Class 'pictures' ('PICT') -- 'every picture' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'reference' ('obj ') -- 'An AppleScript reference' - -# Class 'references' ('obj ') -- 'every reference' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'data' ('rdat') -- 'An AppleScript raw data object' - -# Class 'handler' ('hand') -- 'An AppleScript handler' - -# Class 'handlers' ('hand') -- 'every handler' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'list or record' ('lr ') -- 'a list or record' - -# Class 'list or string' ('ls ') -- 'a list or string' - -# Class 'list, record or text' ('lrs ') -- 'a list, record or text' - -# Class 'number or date' ('nd ') -- 'a number or date' - -# Class 'number, date or text' ('nds ') -- 'a number, date or text' - -# Class 'alias' ('alis') -- 'a reference to an existing file' - -# Class 'aliases' ('alis') -- 'every alias' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'application' ('capp') -- 'specifies global properties of AppleScript' -# property 'result' ('rslt') 'cobj' -- 'the last result of evaluation' [] -# property 'space' ('spac') 'TEXT' -- 'a space character' [] -# property 'return' ('ret ') 'TEXT' -- 'a return character' [] -# property 'tab' ('tab ') 'TEXT' -- 'a tab character' [] -# property 'minutes' ('min ') 'TEXT' -- 'the number of seconds in a minute' [] -# property 'hours' ('hour') 'TEXT' -- 'the number of seconds in an hour' [] -# property 'days' ('days') 'TEXT' -- 'the number of seconds in a day' [] -# property 'weeks' ('week') 'TEXT' -- 'the number of seconds in a week' [] -# property 'pi' ('pi ') 'doub' -- 'the constant pi' [] -# property 'print length' ('prln') 'long' -- 'the maximum length to print' [] -# property 'print depth' ('prdp') 'long' -- 'the maximum depth to print' [] -# property 'reverse' ('rvse') 'list' -- 'the reverse of a list' [] -# property 'rest' ('rest') 'list' -- 'the rest of a list' [] -# property 'text item delimiters' ('txdl') 'list' -- 'the text item delimiters of a string' [] -# property 'AppleScript' ('ascr') 'scpt' -- 'the top-level script object' [] - -# Class 'applications' ('capp') -- 'every application' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'app' ('capp') -- 'Short name for application' - -# Class 'version' ('vers') -- 'a version value' - -# Class 'writing code info' ('citl') -- 'Script code and language code of text run' -# property 'script code' ('pscd') 'shor' -- 'the script code for the text' [] -# property 'language code' ('plcd') 'shor' -- 'the language code for the text' [] - -# Class 'writing code infos' ('citl') -- 'every writing code info' -# property '' ('c@#!') 'type' -- '' [0] diff --git a/Mac/Lib/toolbox/Components.py b/Mac/Lib/toolbox/Components.py deleted file mode 100644 index 9256caa86d..0000000000 --- a/Mac/Lib/toolbox/Components.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Components.h' - -kAppleManufacturer = 'appl' -kComponentResourceType = 'thng' -kAnyComponentType = 0 -kAnyComponentSubType = 0 -kAnyComponentManufacturer = 0 -kAnyComponentFlagsMask = 0 -cmpWantsRegisterMessage = 1L << 31 -kComponentOpenSelect = -1 -kComponentCloseSelect = -2 -kComponentCanDoSelect = -3 -kComponentVersionSelect = -4 -kComponentRegisterSelect = -5 -kComponentTargetSelect = -6 -kComponentUnregisterSelect = -7 -defaultComponentIdentical = 0 -defaultComponentAnyFlags = 1 -defaultComponentAnyManufacturer = 2 -defaultComponentAnySubType = 4 -registerComponentGlobal = 1 -registerComponentNoDuplicates = 2 -registerComponentAfterExisting = 4 diff --git a/Mac/Lib/toolbox/Controls.py b/Mac/Lib/toolbox/Controls.py deleted file mode 100644 index 2378447e41..0000000000 --- a/Mac/Lib/toolbox/Controls.py +++ /dev/null @@ -1,89 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Controls.h' - -pushButProc = 0 -checkBoxProc = 1 -radioButProc = 2 -scrollBarProc = 16 -popupMenuProc = 1008 -kControlUsesOwningWindowsFontVariant = 1 << 3 -kControlNoPart = 0 -kControlLabelPart = 1 -kControlMenuPart = 2 -kControlTrianglePart = 4 -kControlButtonPart = 10 -kControlCheckBoxPart = 11 -kControlRadioButtonPart = 11 -kControlUpButtonPart = 20 -kControlDownButtonPart = 21 -kControlPageUpPart = 22 -kControlPageDownPart = 23 -kControlIndicatorPart = 129 -kControlDisabledPart = 254 -kControlInactivePart = 255 -kControlCheckboxUncheckedValue = 0 -kControlCheckboxCheckedValue = 1 -kControlCheckboxMixedValue = 2 -kControlRadioButtonUncheckedValue = 0 -kControlRadioButtonCheckedValue = 1 -kControlRadioButtonMixedValue = 2 -popupFixedWidth = 1 << 0 -popupVariableWidth = 1 << 1 -popupUseAddResMenu = 1 << 2 -popupUseWFont = 1 << 3 -popupTitleBold = 1 << 8 -popupTitleItalic = 1 << 9 -popupTitleUnderline = 1 << 10 -popupTitleOutline = 1 << 11 -popupTitleShadow = 1 << 12 -popupTitleCondense = 1 << 13 -popupTitleExtend = 1 << 14 -popupTitleNoStyle = 1 << 15 -popupTitleLeftJust = 0x00000000 -popupTitleCenterJust = 0x00000001 -popupTitleRightJust = 0x000000FF -hAxisOnly = 1 -vAxisOnly = 2 -cFrameColor = 0 -cBodyColor = 1 -cTextColor = 2 -cThumbColor = 3 -drawCntl = 0 -testCntl = 1 -calcCRgns = 2 -initCntl = 3 -dispCntl = 4 -posCntl = 5 -thumbCntl = 6 -dragCntl = 7 -autoTrack = 8 -calcCntlRgn = 10 -calcThumbRgn = 11 -drawThumbOutline = 12 -kDrawControlEntireControl = 0 -kDrawControlIndicatorOnly = 129 -kDragControlEntireControl = 0 -kDragControlIndicator = 1 -useWFont = 8 -inLabel = 1 -inMenu = 2 -inTriangle = 4 -inButton = 10 -inCheckBox = 11 -inUpButton = 20 -inDownButton = 21 -inPageUp = 22 -inPageDown = 23 -inThumb = 129 -kNoHiliteControlPart = 0 -kInLabelControlPart = 1 -kInMenuControlPart = 2 -kInTriangleControlPart = 4 -kInButtonControlPart = 10 -kInCheckBoxControlPart = 11 -kInUpButtonControlPart = 20 -kInDownButtonControlPart = 21 -kInPageUpControlPart = 22 -kInPageDownControlPart = 23 -kInIndicatorControlPart = 129 -kReservedControlPart = 254 -kControlInactiveControlPart = 255 diff --git a/Mac/Lib/toolbox/Dialogs.py b/Mac/Lib/toolbox/Dialogs.py deleted file mode 100644 index 8586430632..0000000000 --- a/Mac/Lib/toolbox/Dialogs.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Dialogs.h' - -ctrlItem = 4 -btnCtrl = 0 -chkCtrl = 1 -radCtrl = 2 -resCtrl = 3 -statText = 8 -editText = 16 -iconItem = 32 -picItem = 64 -userItem = 0 -itemDisable = 128 -ok = 1 -cancel = 2 -stopIcon = 0 -noteIcon = 1 -cautionIcon = 2 -overlayDITL = 0 -appendDITLRight = 1 -appendDITLBottom = 2 diff --git a/Mac/Lib/toolbox/Events.py b/Mac/Lib/toolbox/Events.py deleted file mode 100644 index 7d97e29a7d..0000000000 --- a/Mac/Lib/toolbox/Events.py +++ /dev/null @@ -1,63 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Events.h' - -nullEvent = 0 -mouseDown = 1 -mouseUp = 2 -keyDown = 3 -keyUp = 4 -autoKey = 5 -updateEvt = 6 -diskEvt = 7 -activateEvt = 8 -osEvt = 15 -mDownMask = 0x0002 -mUpMask = 0x0004 -keyDownMask = 0x0008 -keyUpMask = 0x0010 -autoKeyMask = 0x0020 -updateMask = 0x0040 -diskMask = 0x0080 -activMask = 0x0100 -highLevelEventMask = 0x0400 -osMask = 0x8000 -everyEvent = 0xFFFF -charCodeMask = 0x000000FF -keyCodeMask = 0x0000FF00 -adbAddrMask = 0x00FF0000 -osEvtMessageMask = 0xFF000000L -mouseMovedMessage = 0x00FA -suspendResumeMessage = 0x0001 -resumeFlag = 1 -convertClipboardFlag = 2 -activeFlag = 0x0001 -btnState = 0x0080 -cmdKey = 0x0100 -shiftKey = 0x0200 -alphaLock = 0x0400 -optionKey = 0x0800 -controlKey = 0x1000 -rightShiftKey = 0x2000 -rightOptionKey = 0x4000 -rightControlKey = 0x8000 -activeFlagBit = 0 -btnStateBit = 7 -cmdKeyBit = 8 -shiftKeyBit = 9 -alphaLockBit = 10 -optionKeyBit = 11 -controlKeyBit = 12 -rightShiftKeyBit = 13 -rightOptionKeyBit = 14 -rightControlKeyBit = 15 -networkEvt = 10 -driverEvt = 11 -app1Evt = 12 -app2Evt = 13 -app3Evt = 14 -app4Evt = 15 -networkMask = 0x0400 -driverMask = 0x0800 -app1Mask = 0x1000 -app2Mask = 0x2000 -app3Mask = 0x4000 -app4Mask = 0x8000 diff --git a/Mac/Lib/toolbox/Finder_Suite.py b/Mac/Lib/toolbox/Finder_Suite.py deleted file mode 100644 index 3208eae4d4..0000000000 --- a/Mac/Lib/toolbox/Finder_Suite.py +++ /dev/null @@ -1,740 +0,0 @@ -"""Suite Finder Suite: Objects and Events for the Finder -Level 1, version 1 - -Generated from Moes:System folder:Extensions:Finder Scripting Extension -AETE/AEUT resource version 0/144, language 0, script 0 -""" - -import aetools -import MacOS - -_code = 'fndr' - -_Enum_vwby = { - 'conflicts' : 'cflc', # - 'existing_items' : 'exsi', # - 'small_icon' : 'smic', # - 'all' : 'kyal', # -} - -_Enum_gsen = { - 'CPU' : 'proc', # - 'FPU' : 'fpu ', # - 'MMU' : 'mmu ', # - 'hardware' : 'hdwr', # - 'operating_system' : 'os ', # - 'sound_system' : 'snd ', # - 'memory_available' : 'lram', # - 'memory_installed' : 'ram ', # -} - -class Finder_Suite: - - _argmap_clean_up = { - 'by' : 'by ', - } - - def clean_up(self, _object, _attributes={}, **_arguments): - """clean up: Arrange items in window nicely - Required argument: the window to clean up - Keyword argument by: the order in which to clean up the objects - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'fclu' - - _arguments['----'] = _object - - aetools.keysubst(_arguments, self._argmap_clean_up) - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_computer = { - 'has' : 'has ', - } - - def computer(self, _object, _attributes={}, **_arguments): - """computer: Test attributes of this computer - Required argument: the attribute to test - Keyword argument has: test specific bits of response - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: the result of the query - """ - _code = 'fndr' - _subcode = 'gstl' - - _arguments['----'] = _object - - aetools.keysubst(_arguments, self._argmap_computer) - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def eject(self, _object=None, _attributes={}, **_arguments): - """eject: Eject the specified disk(s), or every ejectable disk if no parameter is specified - Required argument: the items to eject - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'ejct' - - _arguments['----'] = _object - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def empty(self, _object=None, _attributes={}, **_arguments): - """empty: Empty the trash - Required argument: Ã’emptyÓ and Ã’empty trashÓ both do the same thing - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'empt' - - _arguments['----'] = _object - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def erase(self, _object, _attributes={}, **_arguments): - """erase: Erase the specified disk(s) - Required argument: the items to erase - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'fera' - - _arguments['----'] = _object - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_put_away = { - 'items' : 'fsel', - } - - def put_away(self, _object, _attributes={}, **_arguments): - """put away: Put away the specified object(s) - Required argument: the items to put away - Keyword argument items: DO NOT USE: provided for backwards compatibility with old event suite. Will be removed in future Finders - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: the object put away in its put-away location - """ - _code = 'fndr' - _subcode = 'ptwy' - - _arguments['----'] = _object - - aetools.keysubst(_arguments, self._argmap_put_away) - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def restart(self, _no_object=None, _attributes={}, **_arguments): - """restart: Restart the Macintosh - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'rest' - - if _no_object != None: raise TypeError, 'No direct arg expected' - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def reveal(self, _object, _attributes={}, **_arguments): - """reveal: Bring the specified object(s) into view - Required argument: the object to be made visible - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'misc' - _subcode = 'mvis' - - _arguments['----'] = _object - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def select(self, _object, _attributes={}, **_arguments): - """select: Select the specified object(s) - Required argument: the object to select - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'misc' - _subcode = 'slct' - - _arguments['----'] = _object - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def shut_down(self, _no_object=None, _attributes={}, **_arguments): - """shut down: Shut Down the Macintosh - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'shut' - - if _no_object != None: raise TypeError, 'No direct arg expected' - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def sleep(self, _no_object=None, _attributes={}, **_arguments): - """sleep: Sleep the Macintosh - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'snoz' - - if _no_object != None: raise TypeError, 'No direct arg expected' - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_sort = { - 'by' : 'by ', - } - - def sort(self, _object, _attributes={}, **_arguments): - """sort: Return the specified object(s) in a sorted list - Required argument: a list of finder objects to sort - Keyword argument by: the property to sort the items by - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: the sorted items in their new order - """ - _code = 'DATA' - _subcode = 'SORT' - - _arguments['----'] = _object - - aetools.keysubst(_arguments, self._argmap_sort) - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def update(self, _object, _attributes={}, **_arguments): - """update: Update the display of the specified object(s) to match their on-disk representation - Required argument: the item to update - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'fndr' - _subcode = 'fupd' - - _arguments['----'] = _object - - if _arguments: raise TypeError, 'No optional args expected' - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - -# Class 'accessory process' ('pcda') -- 'A process launched from a desk accessory file' -# property 'desk accessory file' ('dafi') 'obj ' -- 'the desk accessory file from which this process was launched' [] - -# Class 'accessory processes' ('pcda') -- 'every accessory process' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'accessory suitcase' ('dsut') -- 'A desk accessory suitcase' -# element 'cobj' as ['indx', 'name'] - -# Class 'accessory suitcases' ('dsut') -- 'every accessory suitcase' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'alias file' ('alia') -- 'An alias file (created with \322Make Alias\323)' -# property 'original item' ('orig') 'obj ' -- 'the original item pointed to by the alias' [] - -# Class 'alias files' ('alia') -- 'every alias file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'application' ('capp') -- 'An application program' -# property 'about this macintosh' ('abbx') 'obj ' -- 'the \322About this Macintosh\323 dialog, and the list of running processes displayed in it' [] -# property 'apple menu items folder' ('amnu') 'obj ' -- 'the special folder \322Apple Menu Items,\323 the contents of which appear in the Apple menu' [] -# property 'clipboard' ('pcli') 'obj ' -- "the Finder's clipboard window" [] -# property 'control panels folder' ('ctrl') 'obj ' -- 'the special folder \322Control Panels\323' [] -# property 'desktop' ('desk') 'obj ' -- 'the desktop' [] -# property 'extensions folder' ('extn') 'obj ' -- 'the special folder \322Extensions\323' [] -# property 'file sharing' ('fshr') 'bool' -- 'Is file sharing on?' [mutable] -# property 'fonts folder' ('ffnt') 'obj ' -- 'the special folder \322Fonts\323' [] -# property 'frontmost' ('pisf') 'bool' -- 'Is this the frontmost application?' [mutable] -# property 'insertion location' ('pins') 'obj ' -- 'the container that a new folder would appear in if \322New Folder\323 was selected' [] -# property 'largest free block' ('mfre') 'long' -- 'the largest free block of process memory available to launch an application' [] -# property 'preferences folder' ('pref') 'obj ' -- 'the special folder \322Preferences\323' [] -# property 'product version' ('ver2') 'itxt' -- 'the version of the System software running on this Macintosh' [] -# property 'selection' ('sele') 'obj ' -- 'the selection visible to the user' [mutable] -# property 'sharing starting up' ('fsup') 'bool' -- 'Is File sharing in the process of starting up (still off, but soon to be on)?' [] -# property 'shortcuts' ('scut') 'obj ' -- "the \322Finder Shortcuts\323 item in the Finder's help menu" [] -# property 'shutdown items folder' ('shdf') 'obj ' -- 'the special folder \322Shutdown Items\323' [] -# property 'startup items folder' ('strt') 'obj ' -- 'the special folder \322Startup Items\323' [] -# property 'system folder' ('macs') 'obj ' -- 'the System folder' [] -# property 'temporary items folder' ('temp') 'obj ' -- 'the special folder \322Temporary Items\323 (invisible)' [] -# property 'version' ('vers') 'itxt' -- 'the version of the Finder Scripting Extension' [] -# property 'view preferences' ('pvwp') 'obj ' -- 'the view preferences control panel' [] -# property 'visible' ('pvis') 'bool' -- "Is the Finder's layer visible?" [mutable] -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name', 'ID '] -# element 'ctnr' as ['indx', 'name'] -# element 'cwnd' as ['indx', 'name'] -# element 'dwnd' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'cdsk' as ['indx', 'name'] -# element 'cdis' as ['indx', 'name', 'ID '] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'name', 'ID '] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'iwnd' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'swnd' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] -# element 'ctrs' as ['indx', 'name'] -# element 'cwin' as ['indx', 'name'] - -# Class 'application file' ('appf') -- "An application's file on disk" -# property 'minimum partition size' ('mprt') 'long' -- 'the smallest memory size that the application can possibly be launched with' [mutable] -# property 'partition size' ('appt') 'long' -- 'the memory size that the application will be launched with' [mutable] -# property 'scriptable' ('isab') 'bool' -- 'Is this application high-level event aware (accepts open application, open document, print document, and quit)?' [] -# property 'suggested partition size' ('sprt') 'long' -- 'the memory size that the developer recommends that the application should be launched with' [] - -# Class 'application files' ('appf') -- 'every application file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'application process' ('pcap') -- 'A process launched from an application file' -# property 'application file' ('appf') 'appf' -- 'the application file from which this process was launched' [] - -# Class 'application processes' ('pcap') -- 'every application process' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'container' ('ctnr') -- 'An item that contains other items' -# property 'completely expanded' ('pexc') 'bool' -- 'Is the container and all of its children open in outline view?' [mutable] -# property 'container window' ('cwnd') 'obj ' -- 'the main window for the container' [] -# property 'entire contents' ('ects') 'obj ' -- 'the entire contents of the container, including the contents of its children' [] -# property 'expandable' ('pexa') 'bool' -- 'Is the container capable of being expanded into outline view?' [] -# property 'expanded' ('pexp') 'bool' -- 'Is the container open in outline view?' [mutable] -# property 'previous list view' ('svew') 'long' -- 'the last non-icon view (by name, by date, etc.) selected for the container (forgotten as soon as the window is closed)' [] -# property 'selection' ('sele') 'obj ' -- 'the selection visible to the user' [mutable] -# property 'view' ('pvew') 'long' -- 'the view selected for the container (by icon, by name, by date, etc.)' [mutable] -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name'] -# element 'ctnr' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'name'] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] - -# Class 'containers' ('ctnr') -- 'every container' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'container window' ('cwnd') -- 'A window that contains items' -# property 'container' ('ctnr') 'obj ' -- 'the container this window is opened from' [] -# property 'disk' ('cdis') 'obj ' -- 'the disk on which the item this window was opened from is stored' [] -# property 'folder' ('cfol') 'obj ' -- 'the folder this window is opened from' [] -# property 'item' ('cobj') 'obj ' -- 'the item this window is opened from' [] -# property 'previous list view' ('svew') 'long' -- 'the last non-icon view (by name, by date, etc.) selected for the window (forgotten as soon as the window is closed)' [] -# property 'selection' ('sele') 'obj ' -- 'the selection visible to the user' [mutable] -# property 'view' ('pvew') 'long' -- 'the view selected for the window (by icon, by name, by date, etc.)' [mutable] -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name'] -# element 'ctnr' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'name'] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] - -# Class 'container windows' ('cwnd') -- 'every container window' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'content space' ('dwnd') -- 'All windows, including the desktop window (\322Window\323 does not include the desktop window)' - -# Class 'content spaces' ('dwnd') -- 'Every content space' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'control panel' ('ccdv') -- 'A control panel' -# property 'calculate folder sizes' ('sfsz') 'bool' -- '(Views) Are folder sizes calculated and displayed in Finder list windows?' [mutable] -# property 'comment heading' ('scom') 'bool' -- '(Views) Are comments displayed in Finder list windows?' [mutable] -# property 'date heading' ('sdat') 'bool' -- '(Views) Are modification dates displayed in Finder list windows?' [mutable] -# property 'disk information heading' ('sdin') 'bool' -- '(Views) Is information about the volume displayed in Finder list windows?' [mutable] -# property 'icon size' ('lvis') 'long' -- '(Views) the size of icons displayed in Finder list windows' [mutable] -# property 'kind heading' ('sknd') 'bool' -- '(Views) Are document kinds displayed in Finder list windows?' [mutable] -# property 'label heading' ('slbl') 'bool' -- '(Views) Are labels displayed in Finder list windows?' [mutable] -# property 'size heading' ('ssiz') 'bool' -- '(Views) Are file sizes displayed in Finder list windows' [mutable] -# property 'snap to grid' ('fgrd') 'bool' -- '(Views) Are items always snapped to the nearest grid point when they are moved?' [mutable] -# property 'staggered grid' ('fstg') 'bool' -- '(Views) Are grid lines staggered?' [mutable] -# property 'version heading' ('svrs') 'bool' -- '(Views) Are file versions displayed in Finder list windows?' [mutable] -# property 'view font' ('vfnt') 'long' -- '(Views) the id of the font used in Finder views' [mutable] -# property 'view font size' ('vfsz') 'long' -- '(Views) the size of the font used in Finder views' [mutable] - -# Class 'control panels' ('ccdv') -- 'every control panel' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'desk accessory file' ('dafi') -- 'A desk accessory file' - -# Class 'desk accessory files' ('dafi') -- 'every desk accessory file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'desktop-object' ('cdsk') -- 'Desktop-object is the class of the \322desktop\323 object' -# property 'startup disk' ('sdsk') 'obj ' -- 'the startup disk' [] -# property 'trash' ('trsh') 'obj ' -- 'the trash' [] -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name'] -# element 'ctnr' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'name'] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] - -# Class 'disk' ('cdis') -- 'A disk' -# property 'capacity' ('capa') 'long' -- 'the total number of bytes (free or used) on the disk' [] -# property 'ejectable' ('isej') 'bool' -- "Can the media can be ejected (floppies, CD's, syquest)?" [] -# property 'free space' ('frsp') 'long' -- 'the number of free bytes left on the disk' [] -# property 'local volume' ('isrv') 'bool' -- 'Is the media is a local volume (rather than a file server)?' [] -# property 'startup' ('istd') 'bool' -- 'Is this disk the boot disk?' [] -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name'] -# element 'ctnr' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'ID ', 'name'] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] - -# Class 'disks' ('cdis') -- 'every disk' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'document file' ('docf') -- 'A document file' - -# Class 'document files' ('docf') -- 'every document file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'file' ('file') -- 'A file' -# property 'creator type' ('fcrt') 'type' -- 'the OSType identifying the application that created the item' [mutable] -# property 'file type' ('fitp') 'type' -- 'the OSType identifying the type of data contained in the item' [mutable] -# property 'locked' ('islk') 'bool' -- 'Is the file locked?' [mutable] -# property 'product version' ('ver2') 'itxt' -- 'the version of the product (visible at the top of the \322Get Info\323 dialog)' [] -# property 'stationery' ('pspd') 'bool' -- 'Is the item a stationery pad?' [mutable] -# property 'version' ('vers') 'itxt' -- 'the version of the file (visible at the bottom of the \322Get Info\323 dialog)' [] - -# Class 'files' ('file') -- 'every file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'folder' ('cfol') -- 'A folder' -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name'] -# element 'ctnr' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'name'] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] - -# Class 'folders' ('cfol') -- 'every folder' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'font file' ('fntf') -- 'A font file' - -# Class 'font files' ('fntf') -- 'every font file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'font suitcase' ('fsut') -- 'A font suitcase' -# element 'cobj' as ['indx', 'name'] - -# Class 'font suitcases' ('fsut') -- 'every font suitcase' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'group' ('sgrp') -- 'A Group in the Users and Groups control panel' -# property 'bounds' ('pbnd') 'qdrt' -- 'the bounding rectangle of the group' [mutable] -# property 'icon' ('iimg') 'ifam' -- 'the icon bitmap of the group' [mutable] -# property 'label index' ('labi') 'long' -- 'the label of the group' [mutable] -# property 'name' ('pnam') 'itxt' -- 'the name of the group' [mutable] -# property 'position' ('posn') 'QDpt' -- 'the position of the group within its parent window' [mutable] - -# Class 'groups' ('sgrp') -- 'every group' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'information window' ('iwnd') -- 'An information window (opened by \322Get Info\311\323)' -# property 'comment' ('comt') 'itxt' -- 'the comment' [mutable] -# property 'creation date' ('crtd') 'ldt ' -- 'the date on which the item was created' [] -# property 'icon' ('iimg') 'ifam' -- 'the icon bitmap of the item' [mutable] -# property 'item' ('cobj') 'obj ' -- 'the item this window was opened from' [] -# property 'locked' ('islk') 'bool' -- 'Is the item locked?' [mutable] -# property 'minimum partition size' ('mprt') 'long' -- 'the smallest memory size that the application can possibly be launched with' [mutable] -# property 'modification date' ('modd') 'ldt ' -- 'the date on which the item was last modified' [] -# property 'partition size' ('appt') 'long' -- 'the memory size that the application will be launched with' [mutable] -# property 'physical size' ('phys') 'long' -- 'the actual space used by the item on disk' [] -# property 'product version' ('ver2') 'itxt' -- 'the version of the product (visible at the top of the \322Get Info\323 dialog)' [] -# property 'size' ('ptsz') 'long' -- 'the logical size of the item' [] -# property 'stationery' ('pspd') 'bool' -- 'Is the item a stationery pad?' [mutable] -# property 'suggested partition size' ('sprt') 'long' -- 'the memory size that the developer recommends that the application should be launched with' [] -# property 'version' ('vers') 'itxt' -- 'the version of the file (visible at the bottom of the \322Get Info\323 dialog)' [] -# property 'warn before emptying' ('warn') 'bool' -- 'Is a dialog displayed when \322Empty trash\311\323 is selected?' [mutable] - -# Class 'information windows' ('iwnd') -- 'every information window' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'item' ('cobj') -- 'An item' -# property 'bounds' ('pbnd') 'qdrt' -- 'the bounding rectangle of the item' [mutable] -# property 'comment' ('comt') 'itxt' -- 'the comment displayed in the \322Get Info\323 window of the item' [mutable] -# property 'container' ('ctnr') 'obj ' -- 'the container of this item' [] -# property 'content space' ('dwnd') 'dwnd' -- 'the window that would open if the item was opened' [] -# property 'creation date' ('crtd') 'ldt ' -- 'the date on which the item was created' [] -# property 'disk' ('cdis') 'obj ' -- 'the disk on which the item is stored' [] -# property 'folder' ('cfol') 'obj ' -- 'the folder in which the item is stored' [] -# property 'icon' ('iimg') 'ifam' -- 'the icon bitmap of the item' [mutable] -# property 'id' ('ID ') 'long' -- 'an id that identifies the item' [] -# property 'information window' ('iwnd') 'obj ' -- 'the information window for the item' [] -# property 'kind' ('kind') 'itxt' -- 'the kind of the item' [] -# property 'label index' ('labi') 'long' -- 'the label of the item' [mutable] -# property 'modification date' ('modd') 'ldt ' -- 'the date on which the item was last modified' [] -# property 'name' ('pnam') 'itxt' -- 'the name of the item' [mutable] -# property 'physical size' ('phys') 'long' -- 'the actual space used by the item on disk' [] -# property 'position' ('posn') 'QDpt' -- 'the position of the item within its parent window' [mutable] -# property 'selected' ('issl') 'bool' -- 'Is the item selected?' [mutable] -# property 'size' ('ptsz') 'long' -- 'the logical size of the item' [] -# property 'window' ('cwin') 'cwin' -- 'the window that would open if the item was opened' [] - -# Class 'items' ('cobj') -- 'every item' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'process' ('prcs') -- 'A process running on this Macintosh' -# property 'creator type' ('fcrt') 'type' -- 'the creator type of this process' [] -# property 'file' ('file') 'obj ' -- 'the file that launched this process' [] -# property 'file type' ('fitp') 'type' -- 'the file type of the file that launched this process' [] -# property 'frontmost' ('pisf') 'bool' -- 'Is this the frontmost application?' [mutable] -# property 'name' ('pnam') 'itxt' -- 'the name of the process' [] -# property 'partition size' ('appt') 'long' -- 'the size of the partition that this application was launched with' [] -# property 'partition space used' ('pusd') 'long' -- 'the number of bytes currently used in this partition' [] -# property 'remote events' ('revt') 'bool' -- 'Will this process accepts remote events?' [] -# property 'scriptable' ('isab') 'bool' -- 'Is this process high-level event aware (accepts open application, open document, print document, and quit)?' [] -# property 'visible' ('pvis') 'bool' -- "Is this process' layer visible?" [mutable] - -# Class 'processes' ('prcs') -- 'every process' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'sharable container' ('sctr') -- 'A container that may be shared (disks and folders)' -# property 'exported' ('sexp') 'bool' -- 'Is this folder a share point or inside a share point?' [] -# property 'group' ('sgrp') 'itxt' -- 'the user or group that has special access to the folder' [mutable] -# property 'group privileges' ('gppr') 'priv' -- 'the see folders/see files/make changes privileges for the group' [mutable] -# property 'guest privileges' ('gstp') 'priv' -- 'the see folders/see files/make changes privileges for everyone' [mutable] -# property 'inherited privileges' ('iprv') 'bool' -- 'Are the privileges of this item always the same as the container it is stored in?' [mutable] -# property 'mounted' ('smou') 'bool' -- "Is this folder mounted on another machine's desktop?" [] -# property 'owner' ('sown') 'itxt' -- 'the user that owns this folder' [mutable] -# property 'owner privileges' ('ownr') 'priv' -- 'the see folders/see files/make changes privileges for the owner' [mutable] -# property 'protected' ('spro') 'bool' -- 'Is container protected from being moved, renamed or deleted?' [mutable] -# property 'shared' ('shar') 'bool' -- 'Is container a share point?' [mutable] -# property 'sharing window' ('swnd') 'obj ' -- 'the sharing window for the container' [] -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name'] -# element 'ctnr' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'name'] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] - -# Class 'sharable containers' ('sctr') -- 'every sharable container' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'sharing privileges' ('priv') -- 'A set of sharing properties' -# property 'make changes' ('prvw') 'bool' -- 'privileges to make changes' [mutable] -# property 'see files' ('prvr') 'bool' -- 'privileges to see files' [mutable] -# property 'see folders' ('prvs') 'bool' -- 'privileges to see folders' [mutable] - -# Class 'sharing window' ('swnd') -- 'A sharing window (opened by \322Sharing\311\323)' -# property 'container' ('ctnr') 'obj ' -- 'the container that this window was opened from' [] -# property 'exported' ('sexp') 'bool' -- 'Is this container a share point or inside a share point?' [] -# property 'folder' ('cfol') 'obj ' -- 'the folder that this window was opened from' [] -# property 'group' ('sgrp') 'itxt' -- 'the user or group that has special access to the container' [mutable] -# property 'group privileges' ('gppr') 'priv' -- 'the see folders/see files/make changes privileges for the group' [mutable] -# property 'guest privileges' ('gstp') 'priv' -- 'the see folders/see files/make changes privileges for everyone' [mutable] -# property 'inherited privileges' ('iprv') 'bool' -- 'Are the privileges of this item always the same as the container it is stored in?' [mutable] -# property 'item' ('cobj') 'obj ' -- 'the item that this window was opened from' [] -# property 'mounted' ('smou') 'bool' -- "Is this container mounted on another machine's desktop?" [] -# property 'owner' ('sown') 'itxt' -- 'the user that owns the container' [mutable] -# property 'owner privileges' ('ownr') 'priv' -- 'the see folders/see files/make changes privileges for the owner' [mutable] -# property 'protected' ('spro') 'bool' -- 'Is container protected from being moved, renamed or deleted?' [mutable] -# property 'sharable container' ('sctr') 'obj ' -- 'the sharable container that this window was opened from' [] -# property 'shared' ('shar') 'bool' -- 'Is container a share point?' [mutable] - -# Class 'sharing windows' ('swnd') -- 'every sharing window' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'sound file' ('sndf') -- 'This class represents sound files' - -# Class 'sound files' ('sndf') -- 'every sound file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'status window' ('qwnd') -- 'These windows are progress dialogs (copy window, rebuild desktop database, empty trash)' - -# Class 'status windows' ('qwnd') -- 'every status window' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'suitcase' ('stcs') -- 'A font or desk accessory suitcase' -# element 'cobj' as ['indx', 'name'] - -# Class 'suitcases' ('stcs') -- 'every suitcase' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'trash-object' ('ctrs') -- 'Trash-object is the class of the \322trash\323 object' -# property 'warn before emptying' ('warn') 'bool' -- 'Is a dialog displayed when \322Empty trash\311\323 is selected?' [mutable] -# element 'dsut' as ['indx', 'name'] -# element 'alia' as ['indx', 'name'] -# element 'appf' as ['indx', 'name'] -# element 'ctnr' as ['indx', 'name'] -# element 'ccdv' as ['indx', 'name'] -# element 'dafi' as ['indx', 'name'] -# element 'docf' as ['indx', 'name'] -# element 'file' as ['indx', 'name'] -# element 'cfol' as ['indx', 'name'] -# element 'fntf' as ['indx', 'name'] -# element 'fsut' as ['indx', 'name'] -# element 'cobj' as ['indx', 'name'] -# element 'sctr' as ['indx', 'name'] -# element 'sndf' as ['indx', 'name'] -# element 'stcs' as ['indx', 'name'] - -# Class 'user' ('cuse') -- 'A User in the Users and Groups control panel' -# property 'bounds' ('pbnd') 'qdrt' -- 'the bounding rectangle of the user' [mutable] -# property 'icon' ('iimg') 'ifam' -- 'the icon bitmap of the user' [mutable] -# property 'label index' ('labi') 'long' -- 'the label of the user' [mutable] -# property 'name' ('pnam') 'itxt' -- 'the name of the user' [mutable] -# property 'position' ('posn') 'QDpt' -- 'the position of the user within its parent window' [mutable] - -# Class 'users' ('cuse') -- 'every user' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'window' ('cwin') -- 'A window' - -# Class 'windows' ('cwin') -- 'every window' -# property '' ('c@#!') 'type' -- '' [0] diff --git a/Mac/Lib/toolbox/Fonts.py b/Mac/Lib/toolbox/Fonts.py deleted file mode 100644 index c0ae3efa14..0000000000 --- a/Mac/Lib/toolbox/Fonts.py +++ /dev/null @@ -1,32 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Fonts.h' - -systemFont = 0 -applFont = 1 -newYork = 2 -geneva = 3 -monaco = 4 -venice = 5 -london = 6 -athens = 7 -sanFran = 8 -toronto = 9 -cairo = 11 -losAngeles = 12 -times = 20 -helvetica = 21 -courier = 22 -symbol = 23 -mobile = 24 -commandMark = 17 -checkMark = 18 -diamondMark = 19 -appleMark = 20 -propFont = 36864 -prpFntH = 36865 -prpFntW = 36866 -prpFntHW = 36867 -fixedFont = 45056 -fxdFntH = 45057 -fxdFntW = 45058 -fxdFntHW = 45059 -fontWid = 44208 diff --git a/Mac/Lib/toolbox/Lists.py b/Mac/Lib/toolbox/Lists.py deleted file mode 100644 index a73cc6caff..0000000000 --- a/Mac/Lib/toolbox/Lists.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Lists.h' - -lDoVAutoscroll = 2 -lDoHAutoscroll = 1 -lOnlyOne = -128 -lExtendDrag = 64 -lNoDisjoint = 32 -lNoExtend = 16 -lNoRect = 8 -lUseSense = 4 -lNoNilHilite = 2 -lDoVAutoscrollBit = 1 -lDoHAutoscrollBit = 0 -lOnlyOneBit = 7 -lExtendDragBit = 6 -lNoDisjointBit = 5 -lNoExtendBit = 4 -lNoRectBit = 3 -lUseSenseBit = 2 -lNoNilHiliteBit = 1 -lInitMsg = 0 -lDrawMsg = 1 -lHiliteMsg = 2 -lCloseMsg = 3 diff --git a/Mac/Lib/toolbox/Menus.py b/Mac/Lib/toolbox/Menus.py deleted file mode 100644 index d414a6f7c4..0000000000 --- a/Mac/Lib/toolbox/Menus.py +++ /dev/null @@ -1,14 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Menus.h' - -noMark = 0 -mDrawMsg = 0 -mChooseMsg = 1 -mSizeMsg = 2 -mDrawItemMsg = 4 -mCalcItemMsg = 5 -textMenuProc = 0 -hMenuCmd = 27 -hierMenu = -1 -mPopUpMsg = 3 -mctAllItems = -98 -mctLastIDIndic = -99 diff --git a/Mac/Lib/toolbox/Metrowerks_Shell_Suite.py b/Mac/Lib/toolbox/Metrowerks_Shell_Suite.py deleted file mode 100644 index 32f45f38d8..0000000000 --- a/Mac/Lib/toolbox/Metrowerks_Shell_Suite.py +++ /dev/null @@ -1,747 +0,0 @@ -"""Suite Metrowerks Shell Suite: Events supported by the Metrowerks Project Shell -Level 1, version 1 - -Generated from Sap:Codewarrior7:Metrowerks CodeWarrior:CodeWarrior IDE 1.3 -AETE/AEUT resource version 1/0, language 0, script 0 -""" - -import aetools -import MacOS - -_code = 'MMPR' - -_Enum_savo = { - 'yes' : 'yes ', # Save changes - 'no' : 'no ', # Do not save changes - 'ask' : 'ask ', # Ask the user whether to save -} - -_Enum_ErrT = { - 'information' : 'ErIn', # - 'compiler_error' : 'ErCE', # - 'compiler_warning' : 'ErCW', # - 'definition' : 'ErDf', # - 'linker_error' : 'ErLE', # - 'linker_warning' : 'ErLW', # -} - -_Enum_Mode = { - 'ReadWrite' : 'RdWr', # The file is open with read/write privileges - 'ReadOnly' : 'Read', # The file is open with read/only privileges - 'CheckedOut_ReadWrite' : 'CkRW', # The file is checked out with read/write privileges - 'CheckedOut_ReadOnly' : 'CkRO', # The file is checked out with read/only privileges - 'CheckedOut_ReadModify' : 'CkRM', # The file is checked out with read/modify privileges - 'Locked' : 'Lock', # The file is locked on disk - 'None' : 'None', # The file is new -} - -_Enum_SrcT = { - 'source' : 'FTxt', # A source file (.c, .cp, .p, etc). - 'unknown' : 'FUnk', # An unknown file type. -} - -_Enum_PPrm = { - 'absolute' : 'Abso', # An absolute path name, including volume name. - 'project_relative' : 'PRel', # A path relative to the current projectÕs folder. - 'shell_relative' : 'SRel', # A path relative to the CodeWarriorª folder. -} - -class Metrowerks_Shell_Suite: - - _argmap_Add_Files = { - 'To_Segment' : 'Segm', - } - - def Add_Files(self, _object, _attributes={}, **_arguments): - """Add Files: Add the specified file(s) to the current project - Required argument: List of files to add - Keyword argument To_Segment: Segment number into which to add the file(s) - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Error code for each file added - """ - _code = 'MMPR' - _subcode = 'AddF' - - aetools.keysubst(_arguments, self._argmap_Add_Files) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Check_Syntax = { - 'ExternalEditor' : 'Errs', - } - - def Check_Syntax(self, _object, _attributes={}, **_arguments): - """Check Syntax: Check the syntax of the specified file(s) - Required argument: List of files to check the syntax of - Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Errors for each file whose syntax was checked - """ - _code = 'MMPR' - _subcode = 'Chek' - - aetools.keysubst(_arguments, self._argmap_Check_Syntax) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Close_Project(self, _no_object=None, _attributes={}, **_arguments): - """Close Project: Close the current project - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'ClsP' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Close_Window = { - 'Saving' : 'savo', - } - - def Close_Window(self, _object, _attributes={}, **_arguments): - """Close Window: Close the windows showing the specified files - Required argument: The files to close - Keyword argument Saving: Whether to save changes to each file before closing its window - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'ClsW' - - aetools.keysubst(_arguments, self._argmap_Close_Window) - _arguments['----'] = _object - - aetools.enumsubst(_arguments, 'savo', _Enum_savo) - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Compile = { - 'ExternalEditor' : 'Errs', - } - - def Compile(self, _object, _attributes={}, **_arguments): - """Compile: Compile the specified file(s) - Required argument: List of files to compile - Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Errors for each file compiled - """ - _code = 'MMPR' - _subcode = 'Comp' - - aetools.keysubst(_arguments, self._argmap_Compile) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Create_Project = { - 'from_stationery' : 'Tmpl', - } - - def Create_Project(self, _object, _attributes={}, **_arguments): - """Create Project: Create a new project file - Required argument: New project file specifier - Keyword argument from_stationery: undocumented, typecode 'alis' - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'NewP' - - aetools.keysubst(_arguments, self._argmap_Create_Project) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Get_Definition(self, _object, _attributes={}, **_arguments): - """Get Definition: Returns the location(s) of a globally scoped function or data object. - Required argument: undocumented, typecode 'TEXT' - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: undocumented, typecode 'FDef' - """ - _code = 'MMPR' - _subcode = 'GDef' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Get_Open_Documents(self, _no_object=None, _attributes={}, **_arguments): - """Get Open Documents: Returns the list of open documents - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: The list of documents - """ - _code = 'MMPR' - _subcode = 'GDoc' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Get_Preferences = { - 'of' : 'PRec', - 'from_panel' : 'PNam', - } - - def Get_Preferences(self, _no_object=None, _attributes={}, **_arguments): - """Get Preferences: Get the preferences for the current project - Keyword argument of: Names of requested preferences - Keyword argument from_panel: Name of the preference panel - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: The requested preferences - """ - _code = 'MMPR' - _subcode = 'Gref' - - aetools.keysubst(_arguments, self._argmap_Get_Preferences) - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Get_Project_File = { - 'Segment' : 'Segm', - } - - def Get_Project_File(self, _object, _attributes={}, **_arguments): - """Get Project File: Returns a description of a file in the project window. - Required argument: The index of the file within its segment. - Keyword argument Segment: The segment containing the file. - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: undocumented, typecode 'SrcF' - """ - _code = 'MMPR' - _subcode = 'GFil' - - aetools.keysubst(_arguments, self._argmap_Get_Project_File) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Get_Project_Specifier(self, _no_object=None, _attributes={}, **_arguments): - """Get Project Specifier: Return the File Specifier for the current project - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: File Specifier for the current project - """ - _code = 'MMPR' - _subcode = 'GetP' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Get_Segments(self, _no_object=None, _attributes={}, **_arguments): - """Get Segments: Returns a description of each segment in the project. - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: undocumented, typecode 'Seg ' - """ - _code = 'MMPR' - _subcode = 'GSeg' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Goto_Function(self, _object, _attributes={}, **_arguments): - """Goto Function: Goto Specified Function Name - Required argument: undocumented, typecode 'TEXT' - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'GoFn' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Goto_Line(self, _object, _attributes={}, **_arguments): - """Goto Line: Goto Specified Line Number - Required argument: The requested source file line number - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'GoLn' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Is_In_Project(self, _object, _attributes={}, **_arguments): - """Is In Project: Whether or not the specified file(s) is in the current project - Required argument: List of files to check for project membership - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Result code for each file - """ - _code = 'MMPR' - _subcode = 'FInP' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Make_Project = { - 'ExternalEditor' : 'Errs', - } - - def Make_Project(self, _no_object=None, _attributes={}, **_arguments): - """Make Project: Make the current project - Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Errors that occurred while making the project - """ - _code = 'MMPR' - _subcode = 'Make' - - aetools.keysubst(_arguments, self._argmap_Make_Project) - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Precompile = { - 'Saving_As' : 'Targ', - 'ExternalEditor' : 'Errs', - } - - def Precompile(self, _object, _attributes={}, **_arguments): - """Precompile: Precompile the specified file to the specified destination file - Required argument: File to precompile - Keyword argument Saving_As: Destination file for precompiled header - Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Errors for the precompiled file - """ - _code = 'MMPR' - _subcode = 'PreC' - - aetools.keysubst(_arguments, self._argmap_Precompile) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Remove_Binaries(self, _no_object=None, _attributes={}, **_arguments): - """Remove Binaries: Remove the binary object code from the current project - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'RemB' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Remove_Files(self, _object, _attributes={}, **_arguments): - """Remove Files: Remove the specified file(s) from the current project - Required argument: List of files to remove - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Error code for each file removed - """ - _code = 'MMPR' - _subcode = 'RemF' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Reset_File_Paths(self, _no_object=None, _attributes={}, **_arguments): - """Reset File Paths: Resets access paths for all files belonging to open project. - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'ReFP' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Run_Project = { - 'ExternalEditor' : 'Errs', - 'SourceDebugger' : 'DeBg', - } - - def Run_Project(self, _no_object=None, _attributes={}, **_arguments): - """Run Project: Run the current project - Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? - Keyword argument SourceDebugger: Run the application under the control of the source-level debugger - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Errors that occurred when running the project - """ - _code = 'MMPR' - _subcode = 'RunP' - - aetools.keysubst(_arguments, self._argmap_Run_Project) - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Save_Message_Window_As(self, _object, _attributes={}, **_arguments): - """Save Message Window As: Saves the message window as a text file - Required argument: Destination file for Save Message Window As - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'SvMs' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Set_Modification_Date = { - 'to' : 'MDat', - } - - def Set_Modification_Date(self, _object, _attributes={}, **_arguments): - """Set Modification Date: Changes the internal modification date of the specified file(s) - Required argument: List of files - Keyword argument to: undocumented, typecode 'ldt ' - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Error code for each modified file - """ - _code = 'MMPR' - _subcode = 'SMod' - - aetools.keysubst(_arguments, self._argmap_Set_Modification_Date) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Set_Preferences = { - 'of_panel' : 'PNam', - 'to' : 'PRec', - } - - def Set_Preferences(self, _no_object=None, _attributes={}, **_arguments): - """Set Preferences: Set the preferences for the current project - Keyword argument of_panel: Name of the preference panel - Keyword argument to: Preferences settings - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'Pref' - - aetools.keysubst(_arguments, self._argmap_Set_Preferences) - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Set_Project_File = { - 'to' : 'SrcS', - } - - def Set_Project_File(self, _object, _attributes={}, **_arguments): - """Set Project File: Changes the settings for a given file in the project. - Required argument: The name of the file - Keyword argument to: The new settings for the file - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'SFil' - - aetools.keysubst(_arguments, self._argmap_Set_Project_File) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Set_Segment = { - 'to' : 'Segm', - } - - def Set_Segment(self, _object, _attributes={}, **_arguments): - """Set Segment: Changes the name and attributes of a segment. - Required argument: The segment to change - Keyword argument to: The new name and attributes for the segment. - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'MMPR' - _subcode = 'SSeg' - - aetools.keysubst(_arguments, self._argmap_Set_Segment) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def Touch(self, _object, _attributes={}, **_arguments): - """Touch: Force recompilation of the specified file(s) - Required argument: List of files to compile - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Error code for each file touched - """ - _code = 'MMPR' - _subcode = 'Toch' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_Update_Project = { - 'ExternalEditor' : 'Errs', - } - - def Update_Project(self, _no_object=None, _attributes={}, **_arguments): - """Update Project: Update the current project - Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Errors that occurred while updating the project - """ - _code = 'MMPR' - _subcode = 'UpdP' - - aetools.keysubst(_arguments, self._argmap_Update_Project) - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - -# Class 'Access Paths' ('PATH') -- 'Contains the definitions of a project\325s access (search) paths.' -# property 'User Paths' ('PA01') 'PInf' -- 'To add an access path for the source files.' [mutable list] -# property 'System Paths' ('PA03') 'PInf' -- 'To add an access path for the include files. (Not supported in Pascal)' [mutable list] -# property 'Always Full Search' ('PA02') 'bool' -- 'To force the compiler to search for system includes like it searches for user includes.' [mutable] - -# Class 'Document' ('docu') -- 'An open text file' -# property 'name' ('pnam') 'TEXT' -- 'The document\325s name' [] -# property 'mode' ('Mode') 'Mode' -- 'The document\325s open mode' [enum] -# property 'disk file' ('file') 'fss ' -- 'The document\325s location on disk' [] - -# Class 'Error Information' ('ErrM') -- 'Describes a single error or warning from the compiler or the linker.' -# property 'kind' ('ErrT') 'ErrT' -- 'The type of error or warning.' [enum] -# property 'message' ('ErrS') 'TEXT' -- 'The error or warning message.' [] -# property 'disk file' ('file') 'fss ' -- 'The file where the error occurred. May not be returned for certain kinds of errors (eg, link errors).' [] -# property 'line' ('ErrL') 'long' -- 'The line in the file where the error occurred. May not be returned for certain kinds of errors (eg, link errors).' [] - -# Class 'Function Information' ('FDef') -- 'Describes the location of any function or global data definition within the current project.' -# property 'disk file' ('file') 'fss ' -- 'The location on disk of the file containing the definition.' [] -# property 'line' ('ErrL') 'long' -- 'The line number where the definition begins.' [] - -# Class 'Path Information' ('PInf') -- 'Contains all of the parameters that describe an access path.' -# property 'name' ('pnam') 'TEXT' -- 'The actual path name.' [mutable] -# property 'recursive' ('Recu') 'bool' -- 'Will the path be searched recursively? (Default is true)' [mutable] -# property 'origin' ('Orig') 'PPrm' -- '' [mutable enum] - -# Class 'ProjectFile' ('SrcF') -- 'A file contained in a project' -# property 'filetype' ('SrcT') 'SrcT' -- 'What kind of file is this ?' [enum] -# property 'name' ('pnam') 'TEXT' -- 'The file\325s name' [] -# property 'disk file' ('file') 'fss ' -- 'The file\325s location on disk' [] -# property 'codesize' ('CSiz') 'long' -- 'The size of this file\325s code.' [] -# property 'datasize' ('DSiz') 'long' -- 'The size of this file\325s data.' [] -# property 'up to date' ('UpTD') 'bool' -- 'Has the file been compiled since its last modification ?' [] -# property 'symbols' ('SymG') 'bool' -- 'Are debugging symbols generated for this file ?' [mutable] -# property 'weak link' ('Weak') 'bool' -- 'Is this file imported weakly into the project ? [PowerPC only]' [mutable] - -# Class 'Segment' ('Seg ') -- 'A segment or group in the project' -# property 'name' ('pnam') 'TEXT' -- '' [mutable] -# property 'filecount' ('NumF') 'shor' -- '' [] -# property 'preloaded' ('Prel') 'bool' -- 'Is the segment preloaded ? [68K only]' [mutable] -# property 'protected' ('Prot') 'bool' -- 'Is the segment protected ? [68K only]' [mutable] -# property 'locked' ('PLck') 'bool' -- 'Is the segment locked ? [68K only]' [mutable] -# property 'purgeable' ('Purg') 'bool' -- 'Is the segment purgeable ? [68K only]' [mutable] -# property 'system heap' ('SysH') 'bool' -- 'Is the segment loaded into the system heap ? [68K only]' [mutable] - -# Class 'Target' ('TARG') -- 'Contains the definitions of a project\325s target.' -# property 'Current Target' ('TA01') 'TEXT' -- 'The name of the current target.' [mutable] diff --git a/Mac/Lib/toolbox/QuickDraw.py b/Mac/Lib/toolbox/QuickDraw.py deleted file mode 100644 index a56fb12533..0000000000 --- a/Mac/Lib/toolbox/QuickDraw.py +++ /dev/null @@ -1,113 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDraw.h' - -invalColReq = -1 -srcCopy = 0 -srcOr = 1 -srcXor = 2 -srcBic = 3 -notSrcCopy = 4 -notSrcOr = 5 -notSrcXor = 6 -notSrcBic = 7 -patCopy = 8 -patOr = 9 -patXor = 10 -patBic = 11 -notPatCopy = 12 -notPatOr = 13 -notPatXor = 14 -notPatBic = 15 -grayishTextOr = 49 -hilitetransfermode = 50 -blend = 32 -addPin = 33 -addOver = 34 -subPin = 35 -addMax = 37 -adMax = 37 -subOver = 38 -adMin = 39 -ditherCopy = 64 -transparent = 36 -italicBit = 1 -ulineBit = 2 -outlineBit = 3 -shadowBit = 4 -condenseBit = 5 -extendBit = 6 -normalBit = 0 -inverseBit = 1 -redBit = 4 -greenBit = 3 -blueBit = 2 -cyanBit = 8 -magentaBit = 7 -yellowBit = 6 -blackBit = 5 -blackColor = 33 -whiteColor = 30 -redColor = 205 -greenColor = 341 -blueColor = 409 -cyanColor = 273 -magentaColor = 137 -yellowColor = 69 -picLParen = 0 -picRParen = 1 -clutType = 0 -fixedType = 1 -directType = 2 -gdDevType = 0 -interlacedDevice = 2 -roundedDevice = 5 -hasAuxMenuBar = 6 -burstDevice = 7 -ext32Device = 8 -ramInit = 10 -mainScreen = 11 -allInit = 12 -screenDevice = 13 -noDriver = 14 -screenActive = 15 -hiliteBit = 7 -pHiliteBit = 0 -defQDColors = 127 -RGBDirect = 16 -baseAddr32 = 4 -sysPatListID = 0 -iBeamCursor = 1 -crossCursor = 2 -plusCursor = 3 -watchCursor = 4 -kQDGrafVerbFrame = 0 -kQDGrafVerbPaint = 1 -kQDGrafVerbErase = 2 -kQDGrafVerbInvert = 3 -kQDGrafVerbFill = 4 -singleDevicesBit = 0 -dontMatchSeedsBit = 1 -allDevicesBit = 2 -singleDevices = 1 << singleDevicesBit -dontMatchSeeds = 1 << dontMatchSeedsBit -allDevices = 1 << allDevicesBit -kNoConstraint = 0 -kVerticalConstraint = 1 -kHorizontalConstraint = 2 -kCursorImageMajorVersion = 0x0001 -kCursorImageMinorVersion = 0x0000 -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDrawText.h' - -leftCaret = 0 -rightCaret = -1 -hilite = 1 -smLeftCaret = 0 -smRightCaret = -1 -smHilite = 1 -onlyStyleRun = 0 -leftStyleRun = 1 -rightStyleRun = 2 -middleStyleRun = 3 -smOnlyStyleRun = 0 -smLeftStyleRun = 1 -smRightStyleRun = 2 -smMiddleStyleRun = 3 diff --git a/Mac/Lib/toolbox/QuickTime.py b/Mac/Lib/toolbox/QuickTime.py deleted file mode 100644 index 8c7655a0a8..0000000000 --- a/Mac/Lib/toolbox/QuickTime.py +++ /dev/null @@ -1,234 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Movies.h' - -MovieFileType = 'MooV' -MediaHandlerType = 'mhlr' -DataHandlerType = 'dhlr' -VideoMediaType = 'vide' -SoundMediaType = 'soun' -TextMediaType = 'text' -BaseMediaType = 'gnrc' -MPEGMediaType = 'MPEG' -MusicMediaType = 'musi' -TimeCodeMediaType = 'tmcd' -HandleDataHandlerSubType = 'hndl' -VisualMediaCharacteristic = 'eyes' -AudioMediaCharacteristic = 'ears' -DoTheRightThing = 0 -dfDontDisplay = 1 << 0 -dfDontAutoScale = 1 << 1 -dfClipToTextBox = 1 << 2 -dfUseMovieBGColor = 1 << 3 -dfShrinkTextBoxToFit = 1 << 4 -dfScrollIn = 1 << 5 -dfScrollOut = 1 << 6 -dfHorizScroll = 1 << 7 -dfReverseScroll = 1 << 8 -dfContinuousScroll = 1 << 9 -dfFlowHoriz = 1 << 10 -dfDropShadow = 1 << 12 -dfAntiAlias = 1 << 13 -dfKeyedText = 1 << 14 -dfInverseHilite = 1 << 15 -searchTextDontGoToFoundTime = 1L << 16 -searchTextDontHiliteFoundText = 1L << 17 -searchTextOneTrackOnly = 1L << 18 -searchTextEnabledTracksOnly = 1L << 19 -movieProgressOpen = 0 -movieProgressUpdatePercent = 1 -movieProgressClose = 2 -progressOpFlatten = 1 -mediaQualityDraft = 0x0000 -mediaQualityNormal = 0x0040 -mediaQualityBetter = 0x0080 -mediaQualityBest = 0x00C0 -loopTimeBase = 1 -palindromeLoopTimeBase = 2 -maintainTimeBaseZero = 4 -triggerTimeFwd = 0x0001 -triggerTimeBwd = 0x0002 -triggerTimeEither = 0x0003 -triggerRateLT = 0x0004 -triggerRateGT = 0x0008 -triggerRateEqual = 0x0010 -triggerRateChange = 0 -triggerAtStart = 0x0001 -triggerAtStop = 0x0002 -timeBaseBeforeStartTime = 1 -timeBaseAfterStopTime = 2 -callBackAtTime = 1 -callBackAtRate = 2 -callBackAtTimeJump = 3 -callBackAtExtremes = 4 -callBackAtInterrupt = 0x8000 -callBackAtDeferredTask = 0x4000 -qtcbNeedsRateChanges = 1 -qtcbNeedsTimeChanges = 2 -qtcbNeedsStartStopChanges = 4 -keepInRam = 1 << 0 -unkeepInRam = 1 << 1 -flushFromRam = 1 << 2 -loadForwardTrackEdits = 1 << 3 -loadBackwardTrackEdits = 1 << 4 -newMovieActive = 1 << 0 -newMovieDontResolveDataRefs = 1 << 1 -newMovieDontAskUnresolvedDataRefs = 1 << 2 -newMovieDontAutoAlternates = 1 << 3 -trackUsageInMovie = 1 << 1 -trackUsageInPreview = 1 << 2 -trackUsageInPoster = 1 << 3 -mediaSampleNotSync = 1 << 0 -mediaSampleShadowSync = 1 << 1 -pasteInParallel = 1 -showUserSettingsDialog = 2 -movieToFileOnlyExport = 4 -nextTimeMediaSample = 1 << 0 -nextTimeMediaEdit = 1 << 1 -nextTimeTrackEdit = 1 << 2 -nextTimeSyncSample = 1 << 3 -nextTimeEdgeOK = 1 << 14 -nextTimeIgnoreActiveSegment = 1 << 15 -createMovieFileDeleteCurFile = 1L << 31 -createMovieFileDontCreateMovie = 1L << 30 -createMovieFileDontOpenFile = 1L << 29 -flattenAddMovieToDataFork = 1L << 0 -flattenActiveTracksOnly = 1L << 2 -flattenDontInterleaveFlatten = 1L << 3 -movieInDataForkResID = -1 -mcTopLeftMovie = 1 << 0 -mcScaleMovieToFit = 1 << 1 -mcWithBadge = 1 << 2 -mcNotVisible = 1 << 3 -mcWithFrame = 1 << 4 -movieScrapDontZeroScrap = 1 << 0 -movieScrapOnlyPutMovie = 1 << 1 -dataRefSelfReference = 1 << 0 -dataRefWasNotResolved = 1 << 1 -hintsScrubMode = 1 << 0 -hintsLoop = 1 << 1 -hintsDontPurge = 1 << 2 -hintsUseScreenBuffer = 1 << 5 -hintsAllowInterlace = 1 << 6 -hintsUseSoundInterp = 1 << 7 -hintsHighQuality = 1 << 8 -hintsPalindrome = 1 << 9 -hintsInactive = 1 << 11 -mediaHandlerFlagBaseClient = 1 -movieTrackMediaType = 1 << 0 -movieTrackCharacteristic = 1 << 1 -movieTrackEnabledOnly = 1 << 2 -movieDrawingCallWhenChanged = 0 -movieDrawingCallAlways = 1 -txtProcDefaultDisplay = 0 -txtProcDontDisplay = 1 -txtProcDoDisplay = 2 -findTextEdgeOK = 1 << 0 -findTextCaseSensitive = 1 << 1 -findTextReverseSearch = 1 << 2 -findTextWrapAround = 1 << 3 -findTextUseOffset = 1 << 4 -dropShadowOffsetType = 'drpo' -dropShadowTranslucencyType = 'drpt' -preloadAlways = 1L << 0 -preloadOnlyIfEnabled = 1L << 1 -MovieControllerComponentType = 'play' -mcActionIdle = 1 -mcActionDraw = 2 -mcActionActivate = 3 -mcActionDeactivate = 4 -mcActionMouseDown = 5 -mcActionKey = 6 -mcActionPlay = 8 -mcActionGoToTime = 12 -mcActionSetVolume = 14 -mcActionGetVolume = 15 -mcActionStep = 18 -mcActionSetLooping = 21 -mcActionGetLooping = 22 -mcActionSetLoopIsPalindrome = 23 -mcActionGetLoopIsPalindrome = 24 -mcActionSetGrowBoxBounds = 25 -mcActionControllerSizeChanged = 26 -mcActionSetSelectionBegin = 29 -mcActionSetSelectionDuration = 30 -mcActionSetKeysEnabled = 32 -mcActionGetKeysEnabled = 33 -mcActionSetPlaySelection = 34 -mcActionGetPlaySelection = 35 -mcActionSetUseBadge = 36 -mcActionGetUseBadge = 37 -mcActionSetFlags = 38 -mcActionGetFlags = 39 -mcActionSetPlayEveryFrame = 40 -mcActionGetPlayEveryFrame = 41 -mcActionGetPlayRate = 42 -mcActionShowBalloon = 43 -mcActionBadgeClick = 44 -mcActionMovieClick = 45 -mcActionSuspend = 46 -mcActionResume = 47 -mcActionSetControllerKeysEnabled = 48 -mcActionGetTimeSliderRect = 49 -mcActionMovieEdited = 50 -mcActionGetDragEnabled = 51 -mcActionSetDragEnabled = 52 -mcFlagSuppressMovieFrame = 1 << 0 -mcFlagSuppressStepButtons = 1 << 1 -mcFlagSuppressSpeakerButton = 1 << 2 -mcFlagsUseWindowPalette = 1 << 3 -mcFlagsDontInvalidate = 1 << 4 -mcPositionDontInvalidate = 1 << 5 -mcInfoUndoAvailable = 1 << 0 -mcInfoCutAvailable = 1 << 1 -mcInfoCopyAvailable = 1 << 2 -mcInfoPasteAvailable = 1 << 3 -mcInfoClearAvailable = 1 << 4 -mcInfoHasSound = 1 << 5 -mcInfoIsPlaying = 1 << 6 -mcInfoIsLooping = 1 << 7 -mcInfoIsInPalindrome = 1 << 8 -mcInfoEditingEnabled = 1 << 9 -mcMenuUndo = 1 -mcMenuCut = 3 -mcMenuCopy = 4 -mcMenuPaste = 5 -mcMenuClear = 6 -kMCSetMovieSelect = 0x2 -kMCGetIndMovieSelect = 0x5 -kMCRemoveMovieSelect = 0x6 -kMCIsPlayerEventSelect = 0x7 -kMCSetActionFilterSelect = 0x8 -kMCDoActionSelect = 0x9 -kMCSetControllerAttachedSelect = 0xA -kMCIsControllerAttachedSelect = 0xB -kMCSetControllerPortSelect = 0xC -kMCGetControllerPortSelect = 0xD -kMCSetVisibleSelect = 0xE -kMCGetVisibleSelect = 0xF -kMCGetControllerBoundsRectSelect = 0x10 -kMCSetControllerBoundsRectSelect = 0x11 -kMCGetControllerBoundsRgnSelect = 0x12 -kMCGetWindowRgnSelect = 0x13 -kMCMovieChangedSelect = 0x14 -kMCSetDurationSelect = 0x15 -kMCGetCurrentTimeSelect = 0x16 -kMCNewAttachedControllerSelect = 0x17 -kMCDrawSelect = 0x18 -kMCActivateSelect = 0x19 -kMCIdleSelect = 0x1A -kMCKeySelect = 0x1B -kMCClickSelect = 0x1C -kMCEnableEditingSelect = 0x1D -kMCIsEditingEnabledSelect = 0x1E -kMCCopySelect = 0x1F -kMCCutSelect = 0x20 -kMCPasteSelect = 0x21 -kMCClearSelect = 0x22 -kMCUndoSelect = 0x23 -kMCPositionControllerSelect = 0x24 -kMCGetControllerInfoSelect = 0x25 -kMCSetClipSelect = 0x28 -kMCGetClipSelect = 0x29 -kMCDrawBadgeSelect = 0x2A -kMCSetUpEditMenuSelect = 0x2B -kMCGetMenuStringSelect = 0x2C -kMCSetActionFilterWithRefConSelect = 0x2D diff --git a/Mac/Lib/toolbox/Required_Suite.py b/Mac/Lib/toolbox/Required_Suite.py deleted file mode 100644 index 67145b7809..0000000000 --- a/Mac/Lib/toolbox/Required_Suite.py +++ /dev/null @@ -1,92 +0,0 @@ -"""Suite Required Suite: Terms that every application should support -Level 1, version 1 - -Generated from Moes:System folder:Extensions:Scripting Additions:Dialects:English Dialect -AETE/AEUT resource version 1/0, language 0, script 0 -""" - -import aetools -import MacOS - -_code = 'reqd' - -class Required_Suite: - - def open(self, _object, _attributes={}, **_arguments): - """open: Open the specified object(s) - Required argument: list of objects to open - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'aevt' - _subcode = 'odoc' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _print(self, _object, _attributes={}, **_arguments): - """print: Print the specified object(s) - Required argument: list of objects to print - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'aevt' - _subcode = 'pdoc' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def quit(self, _no_object=None, _attributes={}, **_arguments): - """quit: Quit application - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'aevt' - _subcode = 'quit' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def run(self, _no_object=None, _attributes={}, **_arguments): - """run: Sent to an application when it is double-clicked - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'aevt' - _subcode = 'oapp' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - diff --git a/Mac/Lib/toolbox/Resources.py b/Mac/Lib/toolbox/Resources.py deleted file mode 100644 index 2a555450b5..0000000000 --- a/Mac/Lib/toolbox/Resources.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Resources.h' - -resSysHeap = 64 -resPurgeable = 32 -resLocked = 16 -resProtected = 8 -resPreload = 4 -resChanged = 2 -mapReadOnly = 128 -mapCompact = 64 -mapChanged = 32 -resSysRefBit = 7 -resSysHeapBit = 6 -resPurgeableBit = 5 -resLockedBit = 4 -resProtectedBit = 3 -resPreloadBit = 2 -resChangedBit = 1 -mapReadOnlyBit = 7 -mapCompactBit = 6 -mapChangedBit = 5 -kResFileNotOpened = -1 -kSystemResFile = 0 diff --git a/Mac/Lib/toolbox/Sound.py b/Mac/Lib/toolbox/Sound.py deleted file mode 100644 index 9070e42682..0000000000 --- a/Mac/Lib/toolbox/Sound.py +++ /dev/null @@ -1,102 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Sound.h' - -soundListRsrc = 'snd ' -rate44khz = 0xAC440000L -rate22050hz = 0x56220000L -rate22khz = 0x56EE8BA3L -rate11khz = 0x2B7745D1L -rate11025hz = 0x2B110000 -squareWaveSynth = 1 -waveTableSynth = 3 -sampledSynth = 5 -MACE3snthID = 11 -MACE6snthID = 13 -kMiddleC = 60 -kSimpleBeepID = 1 -kFullVolume = 0x0100 -kNoVolume = 0 -nullCmd = 0 -initCmd = 1 -freeCmd = 2 -quietCmd = 3 -flushCmd = 4 -reInitCmd = 5 -waitCmd = 10 -pauseCmd = 11 -resumeCmd = 12 -callBackCmd = 13 -syncCmd = 14 -availableCmd = 24 -versionCmd = 25 -totalLoadCmd = 26 -loadCmd = 27 -freqDurationCmd = 40 -restCmd = 41 -freqCmd = 42 -ampCmd = 43 -timbreCmd = 44 -getAmpCmd = 45 -volumeCmd = 46 -getVolumeCmd = 47 -waveTableCmd = 60 -phaseCmd = 61 -soundCmd = 80 -bufferCmd = 81 -rateCmd = 82 -continueCmd = 83 -doubleBufferCmd = 84 -getRateCmd = 85 -rateMultiplierCmd = 86 -getRateMultiplierCmd = 87 -sizeCmd = 90 -convertCmd = 91 -stdQLength = 128 -dataOffsetFlag = 0x8000 -waveInitChannelMask = 0x07 -waveInitChannel0 = 0x04 -waveInitChannel1 = 0x05 -waveInitChannel2 = 0x06 -waveInitChannel3 = 0x07 -initChanLeft = 0x0002 -initChanRight = 0x0003 -initNoInterp = 0x0004 -initNoDrop = 0x0008 -initMono = 0x0080 -initStereo = 0x00C0 -initMACE3 = 0x0300 -initMACE6 = 0x0400 -initPanMask = 0x0003 -initSRateMask = 0x0030 -initStereoMask = 0x00C0 -initCompMask = 0xFF00 -kUseOptionalOutputDevice = -1 -notCompressed = 0 -fixedCompression = -1 -variableCompression = -2 -twoToOne = 1 -eightToThree = 2 -threeToOne = 3 -sixToOne = 4 -stdSH = 0x00 -extSH = 0xFF -cmpSH = 0xFE -outsideCmpSH = 0 -insideCmpSH = 1 -aceSuccess = 0 -aceMemFull = 1 -aceNilBlock = 2 -aceBadComp = 3 -aceBadEncode = 4 -aceBadDest = 5 -aceBadCmd = 6 -sixToOnePacketSize = 8 -threeToOnePacketSize = 16 -stateBlockSize = 64 -leftOverBlockSize = 32 -firstSoundFormat = 0x0001 -secondSoundFormat = 0x0002 -dbBufferReady = 0x00000001 -dbLastBuffer = 0x00000004 -sysBeepDisable = 0x0000 -unitTypeNoSelection = 0xFFFF -unitTypeSeconds = 0x0000 diff --git a/Mac/Lib/toolbox/Standard_Suite.py b/Mac/Lib/toolbox/Standard_Suite.py deleted file mode 100644 index 0fdd7b2671..0000000000 --- a/Mac/Lib/toolbox/Standard_Suite.py +++ /dev/null @@ -1,493 +0,0 @@ -"""Suite Standard Suite: Common terms for most applications -Level 1, version 1 - -Generated from Moes:System folder:Extensions:Scripting Additions:Dialects:English Dialect -AETE/AEUT resource version 1/0, language 0, script 0 -""" - -import aetools -import MacOS - -_code = 'core' - -_Enum_savo = { - 'yes' : 'yes ', # Save objects now - 'no' : 'no ', # Do not save objects - 'ask' : 'ask ', # Ask the user whether to save -} - -_Enum_kfrm = { - 'index' : 'indx', # keyform designating indexed access - 'named' : 'name', # keyform designating named access - 'id' : 'ID ', # keyform designating access by unique identifier -} - -_Enum_styl = { - 'plain' : 'plan', # Plain - 'bold' : 'bold', # Bold - 'italic' : 'ital', # Italic - 'outline' : 'outl', # Outline - 'shadow' : 'shad', # Shadow - 'underline' : 'undl', # Underline - 'superscript' : 'spsc', # Superscript - 'subscript' : 'sbsc', # Subscript - 'strikethrough' : 'strk', # Strikethrough - 'small_caps' : 'smcp', # Small caps - 'all_caps' : 'alcp', # All capital letters - 'all_lowercase' : 'lowc', # Lowercase - 'condensed' : 'cond', # Condensed - 'expanded' : 'pexp', # Expanded - 'hidden' : 'hidn', # Hidden -} - -class Standard_Suite: - - _argmap_class_info = { - '_in' : 'wrcd', - } - - def class_info(self, _object=None, _attributes={}, **_arguments): - """class info: Get information about an object class - Required argument: the object class about which information is requested - Keyword argument _in: the human language and script system in which to return information - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: a record containing the objectÕs properties and elements - """ - _code = 'core' - _subcode = 'qobj' - - aetools.keysubst(_arguments, self._argmap_class_info) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_close = { - 'saving' : 'savo', - 'saving_in' : 'kfil', - } - - def close(self, _object, _attributes={}, **_arguments): - """close: Close an object - Required argument: the object to close - Keyword argument saving: specifies whether changes should be saved before closing - Keyword argument saving_in: the file in which to save the object - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'core' - _subcode = 'clos' - - aetools.keysubst(_arguments, self._argmap_close) - _arguments['----'] = _object - - aetools.enumsubst(_arguments, 'savo', _Enum_savo) - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_count = { - 'each' : 'kocl', - } - - def count(self, _object, _attributes={}, **_arguments): - """count: Return the number of elements of a particular class within an object - Required argument: the object whose elements are to be counted - Keyword argument each: the class of the elements to be counted. - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: the number of elements - """ - _code = 'core' - _subcode = 'cnte' - - aetools.keysubst(_arguments, self._argmap_count) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_data_size = { - 'as' : 'rtyp', - } - - def data_size(self, _object, _attributes={}, **_arguments): - """data size: Return the size in bytes of an object - Required argument: the object whose data size is to be returned - Keyword argument as: the data type for which the size is calculated - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: the size of the object in bytes - """ - _code = 'core' - _subcode = 'dsiz' - - aetools.keysubst(_arguments, self._argmap_data_size) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def delete(self, _object, _attributes={}, **_arguments): - """delete: Delete an element from an object - Required argument: the element to delete - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'core' - _subcode = 'delo' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_duplicate = { - 'to' : 'insh', - } - - def duplicate(self, _object, _attributes={}, **_arguments): - """duplicate: Duplicate object(s) - Required argument: the object(s) to duplicate - Keyword argument to: the new location for the object(s) - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the duplicated object(s) - """ - _code = 'core' - _subcode = 'clon' - - aetools.keysubst(_arguments, self._argmap_duplicate) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_event_info = { - '_in' : 'wrcd', - } - - def event_info(self, _object, _attributes={}, **_arguments): - """event info: Get information about the Apple events in a suite - Required argument: the event class of the Apple events for which to return information - Keyword argument _in: the human language and script system in which to return information - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: a record containing the events and their parameters - """ - _code = 'core' - _subcode = 'gtei' - - aetools.keysubst(_arguments, self._argmap_event_info) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def exists(self, _object, _attributes={}, **_arguments): - """exists: Verify if an object exists - Required argument: the object in question - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: true if it exists, false if not - """ - _code = 'core' - _subcode = 'doex' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_make = { - 'new' : 'kocl', - 'at' : 'insh', - 'with_data' : 'data', - 'with_properties' : 'prdt', - } - - def make(self, _no_object=None, _attributes={}, **_arguments): - """make: Make a new element - Keyword argument new: the class of the new element. - Keyword argument at: the location at which to insert the element - Keyword argument with_data: the initial data for the element - Keyword argument with_properties: the initial values for the properties of the element - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the new object(s) - """ - _code = 'core' - _subcode = 'crel' - - aetools.keysubst(_arguments, self._argmap_make) - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_move = { - 'to' : 'insh', - } - - def move(self, _object, _attributes={}, **_arguments): - """move: Move object(s) to a new location - Required argument: the object(s) to move - Keyword argument to: the new location for the object(s) - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the object(s) after they have been moved - """ - _code = 'core' - _subcode = 'move' - - aetools.keysubst(_arguments, self._argmap_move) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def open(self, _object, _attributes={}, **_arguments): - """open: Open the specified object(s) - Required argument: list of objects to open - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'aevt' - _subcode = 'odoc' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def _print(self, _object, _attributes={}, **_arguments): - """print: Print the specified object(s) - Required argument: list of objects to print - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'aevt' - _subcode = 'pdoc' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_quit = { - 'saving' : 'savo', - } - - def quit(self, _no_object=None, _attributes={}, **_arguments): - """quit: Quit an application program - Keyword argument saving: specifies whether to save currently open documents - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'aevt' - _subcode = 'quit' - - aetools.keysubst(_arguments, self._argmap_quit) - if _no_object != None: raise TypeError, 'No direct arg expected' - - aetools.enumsubst(_arguments, 'savo', _Enum_savo) - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_save = { - '_in' : 'kfil', - 'as' : 'fltp', - } - - def save(self, _object, _attributes={}, **_arguments): - """save: Save an object - Required argument: the object to save - Keyword argument _in: the file in which to save the object - Keyword argument as: the file type of the document in which to save the data - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'core' - _subcode = 'save' - - aetools.keysubst(_arguments, self._argmap_save) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_suite_info = { - '_in' : 'wrcd', - } - - def suite_info(self, _object, _attributes={}, **_arguments): - """suite info: Get information about event suite(s) - Required argument: the suite for which to return information - Keyword argument _in: the human language and script system in which to return information - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: a record containing the suites and their versions - """ - _code = 'core' - _subcode = 'gtsi' - - aetools.keysubst(_arguments, self._argmap_suite_info) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - -# Class 'application' ('capp') -- 'An application program' -# property 'clipboard' ('pcli') '****' -- 'the clipboard' [mutable list] -# property 'frontmost' ('pisf') 'bool' -- 'Is this the frontmost application?' [] -# property 'name' ('pnam') 'itxt' -- 'the name' [] -# property 'selection' ('sele') 'csel' -- 'the selection visible to the user' [mutable] -# property 'version' ('vers') 'vers' -- 'the version of the application' [] - -# Class 'applications' ('capp') -- 'Every application' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'character' ('cha ') -- 'A character' -# property 'color' ('colr') 'cRGB' -- 'the color' [mutable] -# property 'font' ('font') 'ctxt' -- 'the name of the font' [mutable] -# property 'size' ('ptsz') 'fixd' -- 'the size in points' [mutable] -# property 'writing code' ('psct') 'intl' -- 'the script system and language' [] -# property 'style' ('txst') 'tsty' -- 'the text style' [mutable] -# property 'uniform styles' ('ustl') 'tsty' -- 'the text style' [] - -# Class 'characters' ('cha ') -- 'Every character' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'document' ('docu') -- 'A document' -# property 'modified' ('imod') 'bool' -- 'Has the document been modified since the last save?' [] - -# Class 'documents' ('docu') -- 'Every document' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'file' ('file') -- 'A file' -# property 'stationery' ('pspd') 'bool' -- 'Is the file a stationery file?' [mutable] - -# Class 'files' ('file') -- 'Every file' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'selection-object' ('csel') -- 'the selection visible to the user' -# property 'contents' ('pcnt') 'type' -- 'the contents of the selection' [] - -# Class 'text' ('ctxt') -- 'Text' -# property '' ('c@#!') 'type' -- '' [0] -# property 'font' ('font') 'ctxt' -- 'the name of the font of the first character' [mutable] - -# Class 'text style info' ('tsty') -- 'On and Off styles of text run' -# property 'on styles' ('onst') 'styl' -- 'the styles that are on for the text' [enum list] -# property 'off styles' ('ofst') 'styl' -- 'the styles that are off for the text' [enum list] - -# Class 'text style infos' ('tsty') -- 'every text style info' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'window' ('cwin') -- 'A window' -# property 'bounds' ('pbnd') 'qdrt' -- 'the boundary rectangle for the window' [mutable] -# property 'closeable' ('hclb') 'bool' -- 'Does the window have a close box?' [] -# property 'titled' ('ptit') 'bool' -- 'Does the window have a title bar?' [] -# property 'index' ('pidx') 'long' -- 'the number of the window' [mutable] -# property 'floating' ('isfl') 'bool' -- 'Does the window float?' [] -# property 'modal' ('pmod') 'bool' -- 'Is the window modal?' [] -# property 'resizable' ('prsz') 'bool' -- 'Is the window resizable?' [] -# property 'zoomable' ('iszm') 'bool' -- 'Is the window zoomable?' [] -# property 'zoomed' ('pzum') 'bool' -- 'Is the window zoomed?' [mutable] -# property 'visible' ('pvis') 'bool' -- 'Is the window visible?' [mutable] - -# Class 'windows' ('cwin') -- 'Every window' -# property '' ('c@#!') 'type' -- '' [0] - -# Class 'insertion point' ('cins') -- 'An insertion location between two objects' - -# Class 'insertion points' ('cins') -- 'Every insertion location' -# property '' ('c@#!') 'type' -- '' [0] -# comparison 'starts with' ('bgwt') -- Starts with -# comparison 'contains' ('cont') -- Contains -# comparison 'ends with' ('ends') -- Ends with -# comparison '=' ('= ') -- Equal -# comparison '>' ('> ') -- Greater than -# comparison '\263' ('>= ') -- Greater than or equal to -# comparison '<' ('< ') -- Less than -# comparison '\262' ('<= ') -- Less than or equal to diff --git a/Mac/Lib/toolbox/Standard_URL_suite.py b/Mac/Lib/toolbox/Standard_URL_suite.py deleted file mode 100644 index f997c91696..0000000000 --- a/Mac/Lib/toolbox/Standard_URL_suite.py +++ /dev/null @@ -1,47 +0,0 @@ -"""Suite Standard URL suite: Mac URL standard, supported by many apps - - - -Level 1, version 1 - -Generated from flap:Programma's:Netscape 2.0b5 Folder:Netscape 2.0b5 -AETE/AEUT resource version 1/0, language 0, script 0 -""" - -import aetools -import MacOS - -_code = 'GURL' - -class Standard_URL_suite: - - _argmap_GetURL = { - 'to' : 'dest', - 'inside' : 'HWIN', - '_from' : 'refe', - } - - def GetURL(self, _object, _attributes={}, **_arguments): - """GetURL: Loads the URL (optionaly to disk) - - Required argument: The url - Keyword argument to: file the URL should be loaded into - Keyword argument inside: Window the URL should be loaded to - Keyword argument _from: Refererer, to be sent with the HTTP request - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'GURL' - _subcode = 'GURL' - - aetools.keysubst(_arguments, self._argmap_GetURL) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - diff --git a/Mac/Lib/toolbox/TextEdit.py b/Mac/Lib/toolbox/TextEdit.py deleted file mode 100644 index b6eefcf5ef..0000000000 --- a/Mac/Lib/toolbox/TextEdit.py +++ /dev/null @@ -1,56 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:TextEdit.h' - -teJustLeft = 0 -teJustCenter = 1 -teJustRight = -1 -teForceLeft = -2 -teFlushDefault = 0 -teCenter = 1 -teFlushRight = -1 -teFlushLeft = -2 -fontBit = 0 -faceBit = 1 -sizeBit = 2 -clrBit = 3 -addSizeBit = 4 -toggleBit = 5 -toglBit = 5 -doFont = 1 -doFace = 2 -doSize = 4 -doColor = 8 -doAll = 15 -addSize = 16 -doToggle = 32 -EOLHook = 0 -DRAWHook = 4 -WIDTHHook = 8 -HITTESTHook = 12 -nWIDTHHook = 24 -TextWidthHook = 28 -intEOLHook = 0 -intDrawHook = 1 -intWidthHook = 2 -intHitTestHook = 3 -intNWidthHook = 6 -intTextWidthHook = 7 -teFAutoScroll = 0 -teFAutoScr = 0 -teFTextBuffering = 1 -teFOutlineHilite = 2 -teFInlineInput = 3 -teFUseTextServices = 4 -teBitClear = 0 -teBitSet = 1 -teBitTest = -1 -teWordSelect = 4 -teWordDrag = 8 -teFromFind = 12 -teFromRecal = 16 -teFind = 0 -teHighlight = 1 -teDraw = -1 -teCaret = -2 -TEBitClear = 0 -TEBitSet = 1 -TEBitTest = -1 diff --git a/Mac/Lib/toolbox/WASTEconst.py b/Mac/Lib/toolbox/WASTEconst.py deleted file mode 100644 index 78eb2e1448..0000000000 --- a/Mac/Lib/toolbox/WASTEconst.py +++ /dev/null @@ -1,87 +0,0 @@ -# Generated from ':::::Waste 1.2 distribution:WASTE C/C++ Headers:WASTE.h' - -weCantUndoErr = -10015 -weEmptySelectionErr = -10013 -weNotHandledErr = -1708 -weUnknownObjectTypeErr = -9478 -weObjectNotFoundErr = -9477 -weReadOnlyErr = -9476 -weUndefinedSelectorErr = -50 -weFlushLeft = -2 -weFlushRight = -1 -weFlushDefault = 0 -weCenter = 1 -weJustify = 2 -weDoFont = 0x0001 -weDoFace = 0x0002 -weDoSize = 0x0004 -weDoColor = 0x0008 -weDoAddSize = 0x0010 -weDoToggleFace = 0x0020 -weDoReplaceFace = 0x0040 -weDoPreserveScript = 0x0080 -weDoExtractSubscript = 0x0100 -weDoFaceMask = 0x0200 -kLeadingEdge = -1 -kTrailingEdge = 0 -kObjectEdge = 2 -weFAutoScroll = 0 -weFOutlineHilite = 2 -weFReadOnly = 5 -weFUndo = 6 -weFIntCutAndPaste = 7 -weFDragAndDrop = 8 -weFInhibitRecal = 9 -weFUseTempMem = 10 -weFDrawOffscreen = 11 -weFInhibitRedraw = 12 -weFMonoStyled = 13 -weFInhibitColor = 31 -weDoAutoScroll = 1L << weFAutoScroll -weDoOutlineHilite = 1L << weFOutlineHilite -weDoReadOnly = 1L << weFReadOnly -weDoUndo = 1L << weFUndo -weDoIntCutAndPaste = 1L << weFIntCutAndPaste -weDoDragAndDrop = 1L << weFDragAndDrop -weDoInhibitRecal = 1L << weFInhibitRecal -weDoUseTempMem = 1L << weFUseTempMem -weDoDrawOffscreen = 1L << weFDrawOffscreen -weDoInhibitRedraw = 1L << weFInhibitRedraw -weDoMonoStyled = 1L << weFMonoStyled -weDoInhibitColor = 1L << weFInhibitColor -weBitToggle = -2 -weCharByteHook = 'cbyt' -weCharToPixelHook = 'c2p ' -weCharTypeHook = 'ctyp' -weClickLoop = 'clik' -weCurrentDrag = 'drag' -weDrawTextHook = 'draw' -weHiliteDropAreaHook = 'hidr' -weLineBreakHook = 'lbrk' -wePixelToCharHook = 'p2c ' -wePort = 'port' -weRefCon = 'refc' -weScrollProc = 'scrl' -weText = 'text' -weTranslateDragHook = 'xdrg' -weTSMDocumentID = 'tsmd' -weTSMPreUpdate = 'pre ' -weTSMPostUpdate = 'post' -weURLHint = 'urlh' -weWordBreakHook = 'wbrk' -weNewHandler = 'new ' -weDisposeHandler = 'free' -weDrawHandler = 'draw' -weClickHandler = 'clik' -weStreamHandler = 'strm' -weAKNone = 0 -weAKUnspecified = 1 -weAKTyping = 2 -weAKCut = 3 -weAKPaste = 4 -weAKClear = 5 -weAKDrag = 6 -weAKSetStyle = 7 -weToScrap = 0 -weToDrag = 1 -weToSoup = 2 diff --git a/Mac/Lib/toolbox/WWW_Suite.py b/Mac/Lib/toolbox/WWW_Suite.py deleted file mode 100644 index e14d41fd96..0000000000 --- a/Mac/Lib/toolbox/WWW_Suite.py +++ /dev/null @@ -1,411 +0,0 @@ -"""Suite WorldWideWeb suite, as defined in Spyglass spec.: -Level 1, version 1 - -Generated from flap:Programma's:Netscape 2.0b5 Folder:Netscape 2.0b5 -AETE/AEUT resource version 1/0, language 0, script 0 -""" - -import aetools -import MacOS - -_code = 'WWW!' - -class WWW_Suite: - - _argmap_OpenURL = { - 'to' : 'INTO', - 'toWindow' : 'WIND', - 'flags' : 'FLGS', - 'post_data' : 'POST', - 'post_type' : 'MIME', - 'progressApp' : 'PROG', - } - - def OpenURL(self, _object, _attributes={}, **_arguments): - """OpenURL: Opens a URL. Allows for more options than GetURL event - Required argument: URL - Keyword argument to: file destination - Keyword argument toWindow: window iD - Keyword argument flags: Binary: any combination of 1, 2 and 4 is allowed: 1 and 2 mean force reload the document. 4 is ignored - Keyword argument post_data: Form posting data - Keyword argument post_type: MIME type of the posting data. Defaults to application/x-www-form-urlencoded - Keyword argument progressApp: Application that will display progress - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: ID of the loading window - """ - _code = 'WWW!' - _subcode = 'OURL' - - aetools.keysubst(_arguments, self._argmap_OpenURL) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_ShowFile = { - 'MIME_type' : 'MIME', - 'Window_ID' : 'WIND', - 'URL' : 'URL ', - } - - def ShowFile(self, _object, _attributes={}, **_arguments): - """ShowFile: Similar to OpenDocuments, except that it specifies the parent URL, and MIME type of the file - Required argument: File to open - Keyword argument MIME_type: MIME type - Keyword argument Window_ID: Window to open the file in - Keyword argument URL: Use this as a base URL - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Window ID of the loaded window. 0 means ShowFile failed, FFFFFFF means that data was not appropriate type to display in the browser. - """ - _code = 'WWW!' - _subcode = 'SHWF' - - aetools.keysubst(_arguments, self._argmap_ShowFile) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_parse_anchor = { - 'relative_to' : 'RELA', - } - - def parse_anchor(self, _object, _attributes={}, **_arguments): - """parse anchor: Resolves the relative URL - Required argument: Main URL - Keyword argument relative_to: Relative URL - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: Parsed URL - """ - _code = 'WWW!' - _subcode = 'PRSA' - - aetools.keysubst(_arguments, self._argmap_parse_anchor) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_cancel_progress = { - 'in_window' : 'WIND', - } - - def cancel_progress(self, _object=None, _attributes={}, **_arguments): - """cancel progress: Interrupts the download of the document in the given window - Required argument: progress ID, obtained from the progress app - Keyword argument in_window: window ID of the progress to cancel - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'WWW!' - _subcode = 'CNCL' - - aetools.keysubst(_arguments, self._argmap_cancel_progress) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def find_URL(self, _object, _attributes={}, **_arguments): - """find URL: If the file was downloaded by Netscape, you can call FindURL to find out the URL used to download the file. - Required argument: File spec - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: The URL - """ - _code = 'WWW!' - _subcode = 'FURL' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def webActivate(self, _object=None, _attributes={}, **_arguments): - """webActivate: Makes Netscape the frontmost application, and selects a given window. This event is here for suite completeness/ cross-platform compatibility only, you should use standard AppleEvents instead. - Required argument: window to bring to front - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'WWW!' - _subcode = 'ACTV' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def list_windows(self, _no_object=None, _attributes={}, **_arguments): - """list windows: Lists the IDs of all the hypertext windows - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: List of unique IDs of all the hypertext windows - """ - _code = 'WWW!' - _subcode = 'LSTW' - - if _arguments: raise TypeError, 'No optional args expected' - if _no_object != None: raise TypeError, 'No direct arg expected' - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def get_window_info(self, _object=None, _attributes={}, **_arguments): - """get window info: Returns the information about the window as a list. Currently the list contains the window title and the URL. You can get the same information using standard Apple Event GetProperty. - Required argument: window ID - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: undocumented, typecode 'list' - """ - _code = 'WWW!' - _subcode = 'WNFO' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def register_URL_echo(self, _object=None, _attributes={}, **_arguments): - """register URL echo: Registers the ³echo² application. Each download from now on will be echoed to this application. - Required argument: Application signature - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'WWW!' - _subcode = 'RGUE' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - def unregister_URL_echo(self, _object, _attributes={}, **_arguments): - """unregister URL echo: cancels URL echo - Required argument: application signature - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'WWW!' - _subcode = 'UNRU' - - if _arguments: raise TypeError, 'No optional args expected' - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_register_viewer = { - 'MIME_type' : 'MIME', - 'with_file_type' : 'FTYP', - } - - def register_viewer(self, _object, _attributes={}, **_arguments): - """register viewer: Registers an application as a Å’special¹ viewer for this MIME type. The application will be launched with ViewDoc events - Required argument: Application sig - Keyword argument MIME_type: MIME type viewer is registering for - Keyword argument with_file_type: Mac file type for the downloaded files - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: TRUE if registration has been successful - """ - _code = 'WWW!' - _subcode = 'RGVW' - - aetools.keysubst(_arguments, self._argmap_register_viewer) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_unregister_viewer = { - 'MIME_type' : 'MIME', - } - - def unregister_viewer(self, _object, _attributes={}, **_arguments): - """unregister viewer: Revert to the old way of handling this MIME type - Required argument: Application sig - Keyword argument MIME_type: MIME type to be unregistered - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: TRUE if the event was successful - """ - _code = 'WWW!' - _subcode = 'UNRV' - - aetools.keysubst(_arguments, self._argmap_unregister_viewer) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_register_protocol = { - 'for_protocol' : 'PROT', - } - - def register_protocol(self, _object=None, _attributes={}, **_arguments): - """register protocol: Registers application as a ³handler² for this protocol with a given prefix. The handler will receive ³OpenURL², or if that fails, ³GetURL² event. - Required argument: Application sig - Keyword argument for_protocol: protocol prefix: ³finger:², ³file², - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: TRUE if registration has been successful - """ - _code = 'WWW!' - _subcode = 'RGPR' - - aetools.keysubst(_arguments, self._argmap_register_protocol) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_unregister_protocol = { - 'for_protocol' : 'PROT', - } - - def unregister_protocol(self, _object=None, _attributes={}, **_arguments): - """unregister protocol: reverses the effects of ³register protocol² - Required argument: Application sig. - Keyword argument for_protocol: protocol prefix. If none, unregister for all protocols - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: TRUE if successful - """ - _code = 'WWW!' - _subcode = 'UNRP' - - aetools.keysubst(_arguments, self._argmap_unregister_protocol) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_register_window_close = { - 'for_window' : 'WIND', - } - - def register_window_close(self, _object=None, _attributes={}, **_arguments): - """register window close: Netscape will notify registered application when this window closes - Required argument: Application signature - Keyword argument for_window: window ID - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: true if successful - """ - _code = 'WWW!' - _subcode = 'RGWC' - - aetools.keysubst(_arguments, self._argmap_register_window_close) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - - _argmap_unregister_window_close = { - 'for_window' : 'WIND', - } - - def unregister_window_close(self, _object=None, _attributes={}, **_arguments): - """unregister window close: Undo for register window close - Required argument: Application signature - Keyword argument for_window: window ID - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: true if successful - """ - _code = 'WWW!' - _subcode = 'UNRC' - - aetools.keysubst(_arguments, self._argmap_unregister_window_close) - _arguments['----'] = _object - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(_arguments) - # XXXX Optionally decode result - if _arguments.has_key('----'): - return _arguments['----'] - diff --git a/Mac/Lib/toolbox/Windows.py b/Mac/Lib/toolbox/Windows.py deleted file mode 100644 index bf97a431cf..0000000000 --- a/Mac/Lib/toolbox/Windows.py +++ /dev/null @@ -1,59 +0,0 @@ -# Generated from 'flap:CW9 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Windows.h' - -kWindowDefProcType = 'WDEF' -kStandardWindowDefinition = 0 -kRoundWindowDefinition = 1 -kFloatingWindowDefinition = 124 -kModalDialogVariantCode = 1 -kMovableModalDialogVariantCode = 5 -kSideFloaterVariantCode = 8 -documentProc = 0 -dBoxProc = 1 -plainDBox = 2 -altDBoxProc = 3 -noGrowDocProc = 4 -movableDBoxProc = 5 -zoomDocProc = 8 -zoomNoGrow = 12 -rDocProc = 16 -floatProc = 1985 -floatGrowProc = 1987 -floatZoomProc = 1989 -floatZoomGrowProc = 1991 -floatSideProc = 1993 -floatSideGrowProc = 1995 -floatSideZoomProc = 1997 -floatSideZoomGrowProc = 1999 -dialogKind = 2 -userKind = 8 -kDialogWindowKind = 2 -kApplicationWindowKind = 8 -inDesk = 0 -inMenuBar = 1 -inSysWindow = 2 -inContent = 3 -inDrag = 4 -inGrow = 5 -inGoAway = 6 -inZoomIn = 7 -inZoomOut = 8 -wDraw = 0 -wHit = 1 -wCalcRgns = 2 -wNew = 3 -wDispose = 4 -wGrow = 5 -wDrawGIcon = 6 -deskPatID = 16 -wNoHit = 0 -wInContent = 1 -wInDrag = 2 -wInGrow = 3 -wInGoAway = 4 -wInZoomIn = 5 -wInZoomOut = 6 -wContentColor = 0 -wFrameColor = 1 -wTextColor = 2 -wHiliteColor = 3 -wTitleBarColor = 4 diff --git a/Mac/Lib/toolbox/aepack.py b/Mac/Lib/toolbox/aepack.py deleted file mode 100644 index 8c9def73c6..0000000000 --- a/Mac/Lib/toolbox/aepack.py +++ /dev/null @@ -1,356 +0,0 @@ -"""Tools for use in AppleEvent clients and servers: -conversion between AE types and python types - -pack(x) converts a Python object to an AEDesc object -unpack(desc) does the reverse -coerce(x, wanted_sample) coerces a python object to another python object -""" - -# -# This code was originally written by Guido, and modified/extended by Jack -# to include the various types that were missing. The reference used is -# Apple Event Registry, chapter 9. -# - -import struct -import string -import types -from string import strip -from types import * -import AE -from AppleEvents import * -from AERegistry import * -from AEObjects import * -import MacOS -import macfs -import StringIO -import aetypes -from aetypes import mkenum, mktype - -# These ones seem to be missing from AppleEvents -# (they're in AERegistry.h) - -#typeColorTable = 'clrt' -#typeDrawingArea = 'cdrw' -#typePixelMap = 'cpix' -#typePixelMapMinus = 'tpmm' -#typeRotation = 'trot' -#typeTextStyles = 'tsty' -#typeStyledText = 'STXT' -#typeAEText = 'tTXT' -#typeEnumeration = 'enum' - -# -# Some AE types are immedeately coerced into something -# we like better (and which is equivalent) -# -unpacker_coercions = { - typeComp : typeExtended, - typeColorTable : typeAEList, - typeDrawingArea : typeAERecord, - typeFixed : typeExtended, - typeFloat : typeExtended, - typePixelMap : typeAERecord, - typeRotation : typeAERecord, - typeStyledText : typeAERecord, - typeTextStyles : typeAERecord, -}; - -# -# Some python types we need in the packer: -# -AEDescType = type(AE.AECreateDesc('TEXT', '')) -_sample_fss = macfs.FSSpec(':') -_sample_alias = _sample_fss.NewAliasMinimal() -FSSType = type(_sample_fss) -AliasType = type(_sample_alias) - -def pack(x, forcetype = None): - """Pack a python object into an AE descriptor""" - - if forcetype: - if type(x) is StringType: - return AE.AECreateDesc(forcetype, x) - else: - return pack(x).AECoerceDesc(forcetype) - - if x == None: - return AE.AECreateDesc('null', '') - - t = type(x) - if t == AEDescType: - return x - if t == FSSType: - return AE.AECreateDesc('fss ', x.data) - if t == AliasType: - return AE.AECreateDesc('alis', x.data) - if t == IntType: - return AE.AECreateDesc('long', struct.pack('l', x)) - if t == FloatType: - # - # XXXX (note by Guido) Weird thing -- Think C's "double" is 10 bytes, but - # struct.pack('d') return 12 bytes (and struct.unpack requires - # them, too). The first 2 bytes seem to be repeated... - # Probably an alignment problem - # XXXX (note by Jack) haven't checked this under MW - # - return AE.AECreateDesc('exte', struct.pack('d', x)[2:]) - if t == StringType: - return AE.AECreateDesc('TEXT', x) - if t == ListType: - list = AE.AECreateList('', 0) - for item in x: - list.AEPutDesc(0, pack(item)) - return list - if t == DictionaryType: - record = AE.AECreateList('', 1) - for key, value in x.items(): - record.AEPutParamDesc(key, pack(value)) - return record - if t == InstanceType and hasattr(x, '__aepack__'): - return x.__aepack__() - return AE.AECreateDesc('TEXT', repr(x)) # Copout - -def unpack(desc): - """Unpack an AE descriptor to a python object""" - t = desc.type - - if unpacker_coercions.has_key(t): - desc = desc.AECoerceDesc(unpacker_coercions[t]) - - if t == typeAEList: - l = [] - for i in range(desc.AECountItems()): - keyword, item = desc.AEGetNthDesc(i+1, '****') - l.append(unpack(item)) - return l - if t == typeAERecord: - d = {} - for i in range(desc.AECountItems()): - keyword, item = desc.AEGetNthDesc(i+1, '****') - d[keyword] = unpack(item) - return d - if t == typeAEText: - record = desc.AECoerceDesc('reco') - return mkaetext(unpack(record)) - if t == typeAlias: - return macfs.RawAlias(desc.data) - # typeAppleEvent returned as unknown - if t == typeBoolean: - return struct.unpack('b', desc.data)[0] - if t == typeChar: - return desc.data - # typeColorTable coerced to typeAEList - # typeComp coerced to extended - # typeData returned as unknown - # typeDrawingArea coerced to typeAERecord - if t == typeEnumeration: - return mkenum(desc.data) - # typeEPS returned as unknown - if t == typeExtended: - data = desc.data - # XXX See corresponding note for pack() - return struct.unpack('d', data[:2] + data)[0] - if t == typeFalse: - return 0 - # typeFixed coerced to extended - # typeFloat coerced to extended - if t == typeFSS: - return macfs.RawFSSpec(desc.data) - if t == typeInsertionLoc: - record = desc.AECoerceDesc('reco') - return mkinsertionloc(unpack(record)) - # typeInteger equal to typeLongInteger - if t == typeIntlText: - script, language = struct.unpack('hh', desc.data[:4]) - return aetypes.IntlText(script, language, desc.data[4:]) - if t == typeIntlWritingCode: - script, language = struct.unpack('hh', desc.data) - return aetypes.IntlWritingCode(script, language) - if t == typeKeyword: - return mkkeyword(desc.data) - # typeLongFloat is equal to typeFloat - if t == typeLongInteger: - return struct.unpack('l', desc.data)[0] - if t == typeNull: - return None - if t == typeMagnitude: - v = struct.unpack('l', desc.data) - if v < 0: - v = 0x100000000L + v - return v - if t == typeObjectSpecifier: - record = desc.AECoerceDesc('reco') - return mkobject(unpack(record)) - # typePict returned as unknown - # typePixelMap coerced to typeAERecord - # typePixelMapMinus returned as unknown - # typeProcessSerialNumber returned as unknown - if t == typeQDPoint: - v, h = struct.unpack('hh', desc.data) - return aetypes.QDPoint(v, h) - if t == typeQDRectangle: - v0, h0, v1, h1 = struct.unpack('hhhh', desc.data) - return aetypes.QDRectangle(v0, h0, v1, h1) - if t == typeRGBColor: - r, g, b = struct.unpack('hhh', desc.data) - return aetypes.RGBColor(r, g, b) - # typeRotation coerced to typeAERecord - # typeScrapStyles returned as unknown - # typeSessionID returned as unknown - if t == typeShortFloat: - return struct.unpack('f', desc.data)[0] - if t == typeShortInteger: - return struct.unpack('h', desc.data)[0] - # typeSMFloat identical to typeShortFloat - # typeSMInt indetical to typeShortInt - # typeStyledText coerced to typeAERecord - if t == typeTargetID: - return mktargetid(desc.data) - # typeTextStyles coerced to typeAERecord - # typeTIFF returned as unknown - if t == typeTrue: - return 1 - if t == typeType: - return mktype(desc.data) - # - # The following are special - # - if t == 'rang': - record = desc.AECoerceDesc('reco') - return mkrange(unpack(record)) - if t == 'cmpd': - record = desc.AECoerceDesc('reco') - return mkcomparison(unpack(record)) - if t == 'logi': - record = desc.AECoerceDesc('reco') - return mklogical(unpack(record)) - return mkunknown(desc.type, desc.data) - -def coerce(data, egdata): - """Coerce a python object to another type using the AE coercers""" - pdata = pack(data) - pegdata = pack(egdata) - pdata = pdata.AECoerceDesc(pegdata.type) - return unpack(pdata) - -# -# Helper routines for unpack -# -def mktargetid(data): - sessionID = getlong(data[:4]) - name = mkppcportrec(data[4:4+72]) - location = mklocationnamerec(data[76:76+36]) - rcvrName = mkppcportrec(data[112:112+72]) - return sessionID, name, location, rcvrName - -def mkppcportrec(rec): - namescript = getword(rec[:2]) - name = getpstr(rec[2:2+33]) - portkind = getword(rec[36:38]) - if portkind == 1: - ctor = rec[38:42] - type = rec[42:46] - identity = (ctor, type) - else: - identity = getpstr(rec[38:38+33]) - return namescript, name, portkind, identity - -def mklocationnamerec(rec): - kind = getword(rec[:2]) - stuff = rec[2:] - if kind == 0: stuff = None - if kind == 2: stuff = getpstr(stuff) - return kind, stuff - -def mkunknown(type, data): - return aetypes.Unknown(type, data) - -def getpstr(s): - return s[1:1+ord(s[0])] - -def getlong(s): - return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3]) - -def getword(s): - return (ord(s[0])<<8) | (ord(s[1])<<0) - -def mkkeyword(keyword): - return aetypes.Keyword(keyword) - -def mkrange(dict): - return aetypes.Range(dict['star'], dict['stop']) - -def mkcomparison(dict): - return aetypes.Comparison(dict['obj1'], dict['relo'].enum, dict['obj2']) - -def mklogical(dict): - return aetypes.Logical(dict['logc'], dict['term']) - -def mkstyledtext(dict): - return aetypes.StyledText(dict['ksty'], dict['ktxt']) - -def mkaetext(dict): - return aetypes.AEText(dict[keyAEScriptTag], dict[keyAEStyles], dict[keyAEText]) - -def mkinsertionloc(dict): - return aetypes.InsertionLoc(dict[keyAEObject], dict[keyAEPosition]) - -def mkobject(dict): - want = dict['want'].type - form = dict['form'].enum - seld = dict['seld'] - fr = dict['from'] - if form in ('name', 'indx', 'rang', 'test'): - if want == 'text': return aetypes.Text(seld, fr) - if want == 'cha ': return aetypes.Character(seld, fr) - if want == 'cwor': return aetypes.Word(seld, fr) - if want == 'clin': return aetypes.Line(seld, fr) - if want == 'cpar': return aetypes.Paragraph(seld, fr) - if want == 'cwin': return aetypes.Window(seld, fr) - if want == 'docu': return aetypes.Document(seld, fr) - if want == 'file': return aetypes.File(seld, fr) - if want == 'cins': return aetypes.InsertionPoint(seld, fr) - if want == 'prop' and form == 'prop' and aetypes.IsType(seld): - return aetypes.Property(seld.type, fr) - return aetypes.ObjectSpecifier(want, form, seld, fr) - -def _test(): - """Test program. Pack and unpack various things""" - objs = [ - 'a string', - 12, - 12.0, - None, - ['a', 'list', 'of', 'strings'], - {'key1': 'value1', 'key2':'value2'}, - macfs.FSSpec(':'), - macfs.FSSpec(':').NewAliasMinimal(), - aetypes.Enum('enum'), - aetypes.Type('type'), - aetypes.Keyword('kwrd'), - aetypes.Range(1, 10), - aetypes.Comparison(1, '< ', 10), - aetypes.Logical('not ', 1), - # Cannot do StyledText - # Cannot do AEText - aetypes.IntlText(0, 0, 'international text'), - aetypes.IntlWritingCode(0,0), - aetypes.QDPoint(50,100), - aetypes.QDRectangle(50,100,150,200), - aetypes.RGBColor(0x7000, 0x6000, 0x5000), - aetypes.Unknown('xxxx', 'unknown type data'), - aetypes.Character(1), - aetypes.Character(2, aetypes.Line(2)), - ] - for o in objs: - print 'BEFORE', o, `o` - packed = pack(o) - unpacked = unpack(packed) - print 'AFTER ', unpacked, `unpacked` - import sys - sys.exit(1) - -if __name__ == '__main__': - _test() - diff --git a/Mac/Lib/toolbox/aetools.py b/Mac/Lib/toolbox/aetools.py deleted file mode 100644 index 72e547568a..0000000000 --- a/Mac/Lib/toolbox/aetools.py +++ /dev/null @@ -1,204 +0,0 @@ -"""Tools for use in AppleEvent clients and servers. - -pack(x) converts a Python object to an AEDesc object -unpack(desc) does the reverse - -packevent(event, parameters, attributes) sets params and attrs in an AEAppleEvent record -unpackevent(event) returns the parameters and attributes from an AEAppleEvent record - -Plus... Lots of classes and routines that help representing AE objects, -ranges, conditionals, logicals, etc., so you can write, e.g.: - - x = Character(1, Document("foobar")) - -and pack(x) will create an AE object reference equivalent to AppleScript's - - character 1 of document "foobar" - -Some of the stuff that appears to be exported from this module comes from other -files: the pack stuff from aepack, the objects from aetypes. - -""" - - -from types import * -import AE -import AppleEvents -import MacOS - -from aetypes import * -from aepack import pack, unpack, coerce, AEDescType - -# Special code to unpack an AppleEvent (which is *not* a disguised record!) -# Note by Jack: No??!? If I read the docs correctly it *is*.... - -aekeywords = [ - 'tran', - 'rtid', - 'evcl', - 'evid', - 'addr', - 'optk', - 'timo', - 'inte', # this attribute is read only - will be set in AESend - 'esrc', # this attribute is read only - 'miss', # this attribute is read only - 'from' # new in 1.0.1 -] - -def missed(ae): - try: - desc = ae.AEGetAttributeDesc('miss', 'keyw') - except AE.Error, msg: - return None - return desc.data - -def unpackevent(ae): - parameters = {} - while 1: - key = missed(ae) - if not key: break - parameters[key] = unpack(ae.AEGetParamDesc(key, '****')) - attributes = {} - for key in aekeywords: - try: - desc = ae.AEGetAttributeDesc(key, '****') - except (AE.Error, MacOS.Error), msg: - if msg[0] != -1701: - raise sys.exc_type, sys.exc_value - continue - attributes[key] = unpack(desc) - return parameters, attributes - -def packevent(ae, parameters = {}, attributes = {}): - for key, value in parameters.items(): - ae.AEPutParamDesc(key, pack(value)) - for key, value in attributes.items(): - ae.AEPutAttributeDesc(key, pack(value)) - -# -# Support routine for automatically generated Suite interfaces -# These routines are also useable for the reverse function. -# -def keysubst(arguments, keydict): - """Replace long name keys by their 4-char counterparts, and check""" - ok = keydict.values() - for k in arguments.keys(): - if keydict.has_key(k): - v = arguments[k] - del arguments[k] - arguments[keydict[k]] = v - elif k != '----' and k not in ok: - raise TypeError, 'Unknown keyword argument: %s'%k - -def enumsubst(arguments, key, edict): - """Substitute a single enum keyword argument, if it occurs""" - if not arguments.has_key(key): - return - v = arguments[key] - ok = edict.values() - if edict.has_key(v): - arguments[key] = edict[v] - elif not v in ok: - raise TypeError, 'Unknown enumerator: %s'%v - -def decodeerror(arguments): - """Create the 'best' argument for a raise MacOS.Error""" - errn = arguments['errn'] - errarg = (errn, MacOS.GetErrorString(errn)) - if arguments.has_key('errs'): - errarg = errarg + (arguments['errs'],) - if arguments.has_key('erob'): - errarg = errarg + (arguments['erob'],) - return errarg - -class TalkTo: - """An AE connection to an application""" - - def __init__(self, signature): - """Create a communication channel with a particular application. - - Addressing the application is done by specifying either a - 4-byte signature, an AEDesc or an object that will __aepack__ - to an AEDesc. - """ - if type(signature) == AEDescType: - self.target = signature - elif type(signature) == InstanceType and hasattr(signature, '__aepack__'): - self.target = signature.__aepack__() - elif type(signature) == StringType and len(signature) == 4: - self.target = AE.AECreateDesc(AppleEvents.typeApplSignature, signature) - else: - raise TypeError, "signature should be 4-char string or AEDesc" - self.send_flags = AppleEvents.kAEWaitReply - self.send_priority = AppleEvents.kAENormalPriority - self.send_timeout = AppleEvents.kAEDefaultTimeout - - def newevent(self, code, subcode, parameters = {}, attributes = {}): - """Create a complete structure for an apple event""" - - event = AE.AECreateAppleEvent(code, subcode, self.target, - AppleEvents.kAutoGenerateReturnID, AppleEvents.kAnyTransactionID) - packevent(event, parameters, attributes) - return event - - def sendevent(self, event): - """Send a pre-created appleevent, await the reply and unpack it""" - - reply = event.AESend(self.send_flags, self.send_priority, - self.send_timeout) - parameters, attributes = unpackevent(reply) - return reply, parameters, attributes - - def send(self, code, subcode, parameters = {}, attributes = {}): - """Send an appleevent given code/subcode/pars/attrs and unpack the reply""" - return self.sendevent(self.newevent(code, subcode, parameters, attributes)) - - # - # The following events are somehow "standard" and don't seem to appear in any - # suite... - # - def activate(self): - """Send 'activate' command""" - self.send('misc', 'actv') - - def get(self, _object, _attributes={}): - """get: get data from an object - Required argument: the object - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: the data - """ - _code = 'core' - _subcode = 'getd' - - _arguments = {'----':_object} - - - _reply, _arguments, _attributes = self.send(_code, _subcode, - _arguments, _attributes) - if _arguments.has_key('errn'): - raise MacOS.Error, decodeerror(_arguments) - - if _arguments.has_key('----'): - return _arguments['----'] - - -# Test program -# XXXX Should test more, really... - -def test(): - target = AE.AECreateDesc('sign', 'KAHL') - ae = AE.AECreateAppleEvent('aevt', 'oapp', target, -1, 0) - print unpackevent(ae) - raw_input(":") - ae = AE.AECreateAppleEvent('core', 'getd', target, -1, 0) - obj = Character(2, Word(1, Document(1))) - print obj - print repr(obj) - packevent(ae, {'----': obj}) - params, attrs = unpackevent(ae) - print params['----'] - raw_input(":") - -if __name__ == '__main__': - test() diff --git a/Mac/Lib/toolbox/aetypes.py b/Mac/Lib/toolbox/aetypes.py deleted file mode 100644 index e0a466f781..0000000000 --- a/Mac/Lib/toolbox/aetypes.py +++ /dev/null @@ -1,452 +0,0 @@ -"""aetypes - Python objects representing various AE types.""" - -from AppleEvents import * -from AERegistry import * -from AEObjects import * -import struct -from types import * -import string - -# -# convoluted, since there are cyclic dependencies between this file and -# aetools_convert. -# -def pack(*args): - from aepack import pack - return apply(pack, args) - -def IsSubclass(cls, base): - """Test whether CLASS1 is the same as or a subclass of CLASS2""" - # Loop to optimize for single inheritance - while 1: - if cls is base: return 1 - if len(cls.__bases__) <> 1: break - cls = cls.__bases__[0] - # Recurse to cope with multiple inheritance - for c in cls.__bases__: - if IsSubclass(c, base): return 1 - return 0 - -def IsInstance(x, cls): - """Test whether OBJECT is an instance of (a subclass of) CLASS""" - return type(x) is InstanceType and IsSubclass(x.__class__, cls) - -def nice(s): - """'nice' representation of an object""" - if type(s) is StringType: return repr(s) - else: return str(s) - -class Unknown: - """An uninterpreted AE object""" - - def __init__(self, type, data): - self.type = type - self.data = data - - def __repr__(self): - return "Unknown(%s, %s)" % (`self.type`, `self.data`) - - def __aepack__(self): - return pack(self.data, self.type) - -class Enum: - """An AE enumeration value""" - - def __init__(self, enum): - self.enum = "%-4.4s" % str(enum) - - def __repr__(self): - return "Enum(%s)" % `self.enum` - - def __str__(self): - return string.strip(self.enum) - - def __aepack__(self): - return pack(self.enum, typeEnumeration) - -def IsEnum(x): - return IsInstance(x, Enum) - -def mkenum(enum): - if IsEnum(enum): return enum - return Enum(enum) - -class Type: - """An AE 4-char typename object""" - - def __init__(self, type): - self.type = "%-4.4s" % str(type) - - def __repr__(self): - return "Type(%s)" % `self.type` - - def __str__(self): - return string.strip(self.type) - - def __aepack__(self): - return pack(self.type, typeType) - -def IsType(x): - return IsInstance(x, Type) - -def mktype(type): - if IsType(type): return type - return Type(type) - - -class Keyword: - """An AE 4-char keyword object""" - - def __init__(self, keyword): - self.keyword = "%-4.4s" % str(keyword) - - def __repr__(self): - return "Keyword(%s)" % `self.keyword` - - def __str__(self): - return string.strip(self.keyword) - - def __aepack__(self): - return pack(self.keyword, typeKeyword) - -def IsKeyword(x): - return IsInstance(x, Keyword) - -class Range: - """An AE range object""" - - def __init__(self, start, stop): - self.start = start - self.stop = stop - - def __repr__(self): - return "Range(%s, %s)" % (`self.start`, `self.stop`) - - def __str__(self): - return "%s thru %s" % (nice(self.start), nice(self.stop)) - - def __aepack__(self): - return pack({'star': self.start, 'stop': self.stop}, 'rang') - -def IsRange(x): - return IsInstance(x, Range) - -class Comparison: - """An AE Comparison""" - - def __init__(self, obj1, relo, obj2): - self.obj1 = obj1 - self.relo = "%-4.4s" % str(relo) - self.obj2 = obj2 - - def __repr__(self): - return "Comparison(%s, %s, %s)" % (`self.obj1`, `self.relo`, `self.obj2`) - - def __str__(self): - return "%s %s %s" % (nice(self.obj1), string.strip(self.relo), nice(self.obj2)) - - def __aepack__(self): - return pack({'obj1': self.obj1, - 'relo': mkenum(self.relo), - 'obj2': self.obj2}, - 'cmpd') - -def IsComparison(x): - return IsInstance(x, Comparison) - -class Logical: - """An AE logical expression object""" - - def __init__(self, logc, term): - self.logc = "%-4.4s" % str(logc) - self.term = term - - def __repr__(self): - return "Logical(%s, %s)" % (`self.logc`, `self.term`) - - def __str__(self): - if type(self.term) == ListType and len(self.term) == 2: - return "%s %s %s" % (nice(self.term[0]), - string.strip(self.logc), - nice(self.term[1])) - else: - return "%s(%s)" % (string.strip(self.logc), nice(self.term)) - - def __aepack__(self): - return pack({'logc': mkenum(self.logc), 'term': self.term}, 'logi') - -def IsLogical(x): - return IsInstance(x, Logical) - -class StyledText: - """An AE object respresenting text in a certain style""" - - def __init__(self, style, text): - self.style = style - self.text = text - - def __repr__(self): - return "StyledText(%s, %s)" % (`self.style`, `self.text`) - - def __str__(self): - return self.text - - def __aepack__(self): - return pack({'ksty': self.style, 'ktxt': self.text}, 'STXT') - -def IsStyledText(x): - return IsInstance(x, StyledText) - -class AEText: - """An AE text object with style, script and language specified""" - - def __init__(self, script, style, text): - self.script = script - self.style = style - self.text = text - - def __repr__(self): - return "AEText(%s, %s, %s)" % (`self.script`, `self.style`, `self.text`) - - def __str__(self): - return self.text - - def __aepack__(self): - return pack({keyAEScriptTag: self.script, keyAEStyles: self.style, - keyAEText: self.text}, typeAEText) - -def IsAEText(x): - return IsInstance(x, AEText) - -class IntlText: - """A text object with script and language specified""" - - def __init__(self, script, language, text): - self.script = script - self.language = language - self.text = text - - def __repr__(self): - return "IntlText(%s, %s, %s)" % (`self.script`, `self.language`, `self.text`) - - def __str__(self): - return self.text - - def __aepack__(self): - return pack(struct.pack('hh', self.script, self.language)+self.text, - typeIntlText) - -def IsIntlText(x): - return IsInstance(x, IntlText) - -class IntlWritingCode: - """An object representing script and language""" - - def __init__(self, script, language): - self.script = script - self.language = language - - def __repr__(self): - return "IntlWritingCode(%s, %s)" % (`self.script`, `self.language`) - - def __str__(self): - return "script system %d, language %d"%(self.script, self.language) - - def __aepack__(self): - return pack(struct.pack('hh', self.script, self.language), - typeIntlWritingCode) - -def IsIntlWritingCode(x): - return IsInstance(x, IntlWritingCode) - -class QDPoint: - """A point""" - - def __init__(self, v, h): - self.v = v - self.h = h - - def __repr__(self): - return "QDPoint(%s, %s)" % (`self.v`, `self.h`) - - def __str__(self): - return "(%d, %d)"%(self.v, self.h) - - def __aepack__(self): - return pack(struct.pack('hh', self.v, self.h), - typeQDPoint) - -def IsQDPoint(x): - return IsInstance(x, QDPoint) - -class QDRectangle: - """A rectangle""" - - def __init__(self, v0, h0, v1, h1): - self.v0 = v0 - self.h0 = h0 - self.v1 = v1 - self.h1 = h1 - - def __repr__(self): - return "QDRectangle(%s, %s, %s, %s)" % (`self.v0`, `self.h0`, - `self.v1`, `self.h1`) - - def __str__(self): - return "(%d, %d)-(%d, %d)"%(self.v0, self.h0, self.v1, self.h1) - - def __aepack__(self): - return pack(struct.pack('hhhh', self.v0, self.h0, self.v1, self.h1), - typeQDRectangle) - -def IsQDRectangle(x): - return IsInstance(x, QDRectangle) - -class RGBColor: - """An RGB color""" - - def __init__(self, r, g, b): - self.r = r - self.g = g - self.b = b - - def __repr__(self): - return "RGBColor(%s, %s, %s)" % (`self.r`, `self.g`, `self.b`) - - def __str__(self): - return "0x%x red, 0x%x green, 0x%x blue"% (self.r, self.g, self.b) - - def __aepack__(self): - return pack(struct.pack('hhh', self.r, self.g, self.b), - typeRGBColor) - -def IsRGBColor(x): - return IsInstance(x, RGBColor) - -class ObjectSpecifier: - - """A class for constructing and manipulation AE object specifiers in python. - - An object specifier is actually a record with four fields: - - key type description - --- ---- ----------- - - 'want' type what kind of thing we want, - e.g. word, paragraph or property - - 'form' enum how we specify the thing(s) we want, - e.g. by index, by range, by name, or by property specifier - - 'seld' any which thing(s) we want, - e.g. its index, its name, or its property specifier - - 'from' object the object in which it is contained, - or null, meaning look for it in the application - - Note that we don't call this class plain "Object", since that name - is likely to be used by the application. - """ - - def __init__(self, want, form, seld, fr = None): - self.want = want - self.form = form - self.seld = seld - self.fr = fr - - def __repr__(self): - s = "ObjectSpecifier(%s, %s, %s" % (`self.want`, `self.form`, `self.seld`) - if self.fr: - s = s + ", %s)" % `self.fr` - else: - s = s + ")" - return s - - def __aepack__(self): - return pack({'want': mktype(self.want), - 'form': mkenum(self.form), - 'seld': self.seld, - 'from': self.fr}, - 'obj ') - - -def IsObjectSpecifier(x): - return IsInstance(x, ObjectSpecifier) - - -class Property(ObjectSpecifier): - - def __init__(self, which, fr = None): - ObjectSpecifier.__init__(self, 'prop', 'prop', mkenum(which), fr) - - def __repr__(self): - if self.fr: - return "Property(%s, %s)" % (`self.seld.enum`, `self.fr`) - else: - return "Property(%s)" % `self.seld.enum` - - def __str__(self): - if self.fr: - return "Property %s of %s" % (str(self.seld), str(self.fr)) - else: - return "Property %s" % str(self.seld) - - -class SelectableItem(ObjectSpecifier): - - def __init__(self, want, seld, fr = None): - t = type(seld) - if t == StringType: - form = 'name' - elif IsRange(seld): - form = 'rang' - elif IsComparison(seld) or IsLogical(seld): - form = 'test' - else: - form = 'indx' - ObjectSpecifier.__init__(self, want, form, seld, fr) - - -class ComponentItem(SelectableItem): - # Derived classes *must* set the *class attribute* 'want' to some constant - - def __init__(self, which, fr = None): - SelectableItem.__init__(self, self.want, which, fr) - - def __repr__(self): - if not self.fr: - return "%s(%s)" % (self.__class__.__name__, `self.seld`) - return "%s(%s, %s)" % (self.__class__.__name__, `self.seld`, `self.fr`) - - def __str__(self): - seld = self.seld - if type(seld) == StringType: - ss = repr(seld) - elif IsRange(seld): - start, stop = seld.start, seld.stop - if type(start) == InstanceType == type(stop) and \ - start.__class__ == self.__class__ == stop.__class__: - ss = str(start.seld) + " thru " + str(stop.seld) - else: - ss = str(seld) - else: - ss = str(seld) - s = "%s %s" % (self.__class__.__name__, ss) - if self.fr: s = s + " of %s" % str(self.fr) - return s - - -template = """ -class %s(ComponentItem): want = '%s' -""" - -exec template % ("Text", 'text') -exec template % ("Character", 'cha ') -exec template % ("Word", 'cwor') -exec template % ("Line", 'clin') -exec template % ("Paragraph", 'cpar') -exec template % ("Window", 'cwin') -exec template % ("Document", 'docu') -exec template % ("File", 'file') -exec template % ("InsertionPoint", 'cins') - diff --git a/Mac/MPW/Build b/Mac/MPW/Build deleted file mode 100644 index 5a46990db8..0000000000 --- a/Mac/MPW/Build +++ /dev/null @@ -1,3 +0,0 @@ -Make {Parameters} -f Makefile >Make.out -Set Echo 1 -Make.out diff --git a/Mac/MPW/Makefile b/Mac/MPW/Makefile deleted file mode 100644 index 3c06014cf6..0000000000 --- a/Mac/MPW/Makefile +++ /dev/null @@ -1,513 +0,0 @@ -# MPW Makefile to build Python as a shared library. -# This uses the development environment distributed on the OpenDoc CD: -# compiler (SC) is Symantec C for MPW, headers are Universal Headers. -# Running Python requires that the extensions CFM-68K and MixedModeInit are -# installed, and that the various shared libraries are in the Extensions folder. - -########################## -# Configurable variables # -########################## - -Top = ::: -CC = SC -CFlagsNoInclude = -woff -e -model cfmseg -b ¶ - -d HAVE_CONFIG_H=1 -d MPW=1 -d USE_MAC_SHARED_LIBRARY=1 -d USE_MAC_APPLET_SUPPORT -PythonIncludes = -i "{Top}"Mac: -i "{Top}"Include: -MacIncludes = -i "{CIncludes}" -CFlagsMac = {CFlagsNoInclude} {MacIncludes} {PythonIncludes} -CFlags = {CFlagsNoInclude} {PythonIncludes} {MacIncludes} -Objs = :Objs: -ExtensionsFolder = {SystemFolder}Extensions: - -######################## -# List of object files # -######################## - -ALL = ¶ - "{Objs}"acceler.c.o ¶ - "{Objs}"accessobject.c.o ¶ - "{Objs}"arraymodule.c.o ¶ - "{Objs}"atof.c.o ¶ - "{Objs}"strtod.c.o ¶ - "{Objs}"audioop.c.o ¶ - "{Objs}"bltinmodule.c.o ¶ - "{Objs}"ceval.c.o ¶ - "{Objs}"chdir.c.o ¶ - "{Objs}"classobject.c.o ¶ - "{Objs}"compile.c.o ¶ - "{Objs}"config.c.o ¶ - "{Objs}"errors.c.o ¶ - "{Objs}"fileobject.c.o ¶ - "{Objs}"floatobject.c.o ¶ -# "{Objs}"fmod.c.o ¶ - "{Objs}"frameobject.c.o ¶ - "{Objs}"funcobject.c.o ¶ - "{Objs}"gestaltmodule.c.o ¶ - "{Objs}"getargs.c.o ¶ - "{Objs}"getbootvol.c.o ¶ - "{Objs}"getopt.c.o ¶ - "{Objs}"getwd.c.o ¶ - "{Objs}"graminit.c.o ¶ - "{Objs}"grammar1.c.o ¶ - "{Objs}"imageop.c.o ¶ - "{Objs}"import.c.o ¶ - "{Objs}"importdl.c.o ¶ - "{Objs}"intobject.c.o ¶ - "{Objs}"intrcheck.c.o ¶ - "{Objs}"listobject.c.o ¶ - "{Objs}"longobject.c.o ¶ - "{Objs}"macfsmodule.c.o ¶ - "{Objs}"macgetargv.c.o ¶ - "{Objs}"macgetmtime.c.o ¶ - "{Objs}"macglue.c.o ¶ - "{Objs}"macguesstabsize.c.o ¶ - "{Objs}"macmodule.c.o ¶ - "{Objs}"macosmodule.c.o ¶ - "{Objs}"macsetfiletype.c.o ¶ - "{Objs}"macshlglue.c.o ¶ - "{Objs}"macstat.c.o ¶ - "{Objs}"mappingobject.c.o ¶ - "{Objs}"marshal.c.o ¶ -# "{Objs}"mathmodule.c.o ¶ - "{Objs}"md5c.c.o ¶ - "{Objs}"md5module.c.o ¶ - "{Objs}"methodobject.c.o ¶ - "{Objs}"mkdir.c.o ¶ - "{Objs}"modsupport.c.o ¶ - "{Objs}"moduleobject.c.o ¶ - "{Objs}"myreadline.c.o ¶ - "{Objs}"mystrtoul.c.o ¶ - "{Objs}"newmodule.c.o ¶ - "{Objs}"nfullpath.c.o ¶ - "{Objs}"node.c.o ¶ - "{Objs}"object.c.o ¶ - "{Objs}"opendir.c.o ¶ - "{Objs}"parser.c.o ¶ - "{Objs}"parsermodule.c.o ¶ - "{Objs}"parsetok.c.o ¶ - "{Objs}"pythonmain.c.o ¶ - "{Objs}"pythonrun.c.o ¶ - "{Objs}"rangeobject.c.o ¶ - "{Objs}"regexmodule.c.o ¶ - "{Objs}"regexpr.c.o ¶ - "{Objs}"rgbimgmodule.c.o ¶ - "{Objs}"rmdir.c.o ¶ - "{Objs}"rotormodule.c.o ¶ - "{Objs}"sigcheck.c.o ¶ - "{Objs}"stringobject.c.o ¶ - "{Objs}"stropmodule.c.o ¶ - "{Objs}"structmember.c.o ¶ - "{Objs}"structmodule.c.o ¶ - "{Objs}"sync.c.o ¶ - "{Objs}"sysmodule.c.o ¶ - "{Objs}"timemodule.c.o ¶ - "{Objs}"tokenizer.c.o ¶ - "{Objs}"traceback.c.o ¶ - "{Objs}"tupleobject.c.o ¶ - "{Objs}"typeobject.c.o ¶ - "{Objs}"AEmodule.c.o ¶ - "{Objs}"Ctlmodule.c.o ¶ - "{Objs}"Dlgmodule.c.o ¶ - "{Objs}"Evtmodule.c.o ¶ - "{Objs}"Menumodule.c.o ¶ - "{Objs}"Qdmodule.c.o ¶ - "{Objs}"Resmodule.c.o ¶ - "{Objs}"Sndmodule.c.o ¶ - "{Objs}"Winmodule.c.o ¶ - "{Objs}"ctbmodule.c.o ¶ -# "{Objs}"imgformat.c.o ¶ -# "{Objs}"macmain.c.o ¶ -# "{Objs}"stdwinmodule.c.o ¶ - -################ -# Main targets # -################ - -# Default target -all Ä PythonLib.slb PythonApplet - -# Install stuff -install Ä PythonLib.slb - Duplicate -y PythonLib.slb "{ExtensionsFolder}" - -# Uninstall stuff -uninstall Ä - Delete -i "{ExtensionsFolder}"PythonLib.slb - -# Delete intermediate build stuff and other temporary cruft -clean Ä - Delete -i "{Objs}"Ã….o - Delete -i PythonLib PythonApplet xxmodule - Delete -i stdout stderr - Delete -i Ã….pyc - -# Delete everything that can be reconstructed -clobber Ä clean - Delete -i Ã….slb Ã….NJ - -# Build 'xx' as a dynamically loadable module -xx Ä xxmodule.slb - -# Clean up (somewhat) - -######################### -# Build Applet template # -######################### - -PythonApplet Ä PythonLib.slb "{Objs}"macapplet.c.o - ILink ¶ - -o PythonApplet ¶ - -xm e ¶ - -model cfmseg ¶ - -c PYTa ¶ - "{Objs}"macapplet.c.o ¶ - "{CLibraries}"NuStdCLib.slb ¶ - "{Libraries}"NuInterfaceLib.slb ¶ - "{Libraries}"MixedModeLib.slb ¶ - "{Libraries}"NuIntEnv.slb ¶ - "{Libraries}"NuMathLib.o ¶ - "{Libraries}"NuMacRuntime.o ¶ - PythonLib.slb - -#################################### -# Build Python as a shared library # -#################################### - -Exports = PyExc_AttributeError - -PythonLib.slb Ä {ALL} - ILink ¶ - -o PythonLib ¶ - -xm s ¶ - -model cfmseg ¶ - -init __SINIT ¶ - -export {Exports} ¶ - "{CLibraries}"NuStdCLib.slb ¶ - "{Libraries}"NuInterfaceLib.slb ¶ - "{Libraries}"MixedModeLib.slb ¶ - "{Libraries}"NuIntEnv.slb ¶ - "{Libraries}"NuMathLib.o ¶ - "{Libraries}"NuMacRuntime.o ¶ - {ALL} - MakeFlat PythonLib -o PythonLib.slb - Echo "delete 'cfrg'(0);" | Rez -o PythonLib -a -m - -############################################# -# Build xx as a dynamically loadable module # -############################################# - -xxmodule.slb Ä PythonLib.slb "{Objs}"xxmodule.c.o - ILink ¶ - -o xxmodule ¶ - -xm s ¶ - -model cfmseg ¶ - -m initxx ¶ - "{Objs}"xxmodule.c.o ¶ - "{CLibraries}"NuStdCLib.slb ¶ - "{Libraries}"NuInterfaceLib.slb ¶ - "{Libraries}"MixedModeLib.slb ¶ - "{Libraries}"NuIntEnv.slb ¶ - "{Libraries}"NuMathLib.o ¶ - "{Libraries}"NuMacRuntime.o ¶ - PythonLib.slb - MakeFlat xxmodule -o xxmodule.slb - Echo "delete 'cfrg'(0);" | Rez -o xxmodule -a -m - Echo "delete 'cfrg'(0);" | Rez -o xxmodule.slb -a -m - -############################################## -# Targets to create the various object files # -############################################## - -"{Objs}"macapplet.c.o Ä "{Top}"Mac:macapplet.c - {CC} "{Top}"Mac:macapplet.c -o "{Objs}"macapplet.c.o -s macapplet.c {CFlags} - -"{Objs}"macmain.c.o Ä "{Top}"Mac:macmain.c - {CC} "{Top}"Mac:macmain.c -o "{Objs}"macmain.c.o -s macmain.c {CFlags} - -"{Objs}"pythonmain.c.o Ä "{Top}"Python:pythonmain.c - {CC} "{Top}"Python:pythonmain.c -o "{Objs}"pythonmain.c.o -s pythonmain.c {CFlags} - -"{Objs}"compile.c.o Ä "{Top}"Python:compile.c - {CC} "{Top}"Python:compile.c -o "{Objs}"compile.c.o -s compile.c {CFlags} - -"{Objs}"mystrtoul.c.o Ä "{Top}"Python:mystrtoul.c - {CC} "{Top}"Python:mystrtoul.c -o "{Objs}"mystrtoul.c.o -s mystrtoul.c {CFlags} - -"{Objs}"gestaltmodule.c.o Ä "{Top}"Mac:gestaltmodule.c - {CC} "{Top}"Mac:gestaltmodule.c -o "{Objs}"gestaltmodule.c.o -s gestaltmodule.c {CFlags} - -"{Objs}"macfsmodule.c.o Ä "{Top}"Mac:macfs:macfsmodule.c - {CC} "{Top}"Mac:macfs:macfsmodule.c -o "{Objs}"macfsmodule.c.o -s macfsmodule.c {CFlags} - -"{Objs}"macosmodule.c.o Ä "{Top}"Mac:macosmodule.c - {CC} "{Top}"Mac:macosmodule.c -o "{Objs}"macosmodule.c.o -s macosmodule.c {CFlags} - -"{Objs}"nfullpath.c.o Ä "{Top}"Mac:macfs:nfullpath.c - {CC} "{Top}"Mac:macfs:nfullpath.c -o "{Objs}"nfullpath.c.o -s nfullpath.c {CFlags} - -"{Objs}"tokenizer.c.o Ä "{Top}"Parser:tokenizer.c - {CC} "{Top}"Parser:tokenizer.c -o "{Objs}"tokenizer.c.o -s tokenizer.c {CFlags} - -"{Objs}"chdir.c.o Ä "{Top}"Mac:chdir.c - {CC} "{Top}"Mac:chdir.c -o "{Objs}"chdir.c.o -s chdir.c {CFlags} - -"{Objs}"config.c.o Ä "{Top}"Mac:config.c - {CC} "{Top}"Mac:config.c -o "{Objs}"config.c.o -s config.c {CFlags} - -"{Objs}"getopt.c.o Ä "{Top}"Python:getopt.c - {CC} "{Top}"Python:getopt.c -o "{Objs}"getopt.c.o -s getopt.c {CFlags} - -"{Objs}"getwd.c.o Ä "{Top}"Mac:getwd.c - {CC} "{Top}"Mac:getwd.c -o "{Objs}"getwd.c.o -s getwd.c {CFlags} - -"{Objs}"structmember.c.o Ä "{Top}"Python:structmember.c - {CC} "{Top}"Python:structmember.c -o "{Objs}"structmember.c.o -s structmember.c {CFlags} - -"{Objs}"stropmodule.c.o Ä "{Top}"Modules:stropmodule.c - {CC} "{Top}"Modules:stropmodule.c -o "{Objs}"stropmodule.c.o -s stropmodule.c {CFlags} - -"{Objs}"acceler.c.o Ä "{Top}"Parser:acceler.c - {CC} "{Top}"Parser:acceler.c -o "{Objs}"acceler.c.o -s acceler.c {CFlags} - -"{Objs}"graminit.c.o Ä "{Top}"Python:graminit.c - {CC} "{Top}"Python:graminit.c -o "{Objs}"graminit.c.o -s graminit.c {CFlags} - -"{Objs}"grammar1.c.o Ä "{Top}"Parser:grammar1.c - {CC} "{Top}"Parser:grammar1.c -o "{Objs}"grammar1.c.o -s grammar1.c {CFlags} - -"{Objs}"macguesstabsize.c.o Ä "{Top}"Mac:macguesstabsize.c - {CC} "{Top}"Mac:macguesstabsize.c -o "{Objs}"macguesstabsize.c.o -s macguesstabsize.c {CFlags} - -"{Objs}"node.c.o Ä "{Top}"Parser:node.c - {CC} "{Top}"Parser:node.c -o "{Objs}"node.c.o -s node.c {CFlags} - -"{Objs}"parser.c.o Ä "{Top}"Parser:parser.c - {CC} "{Top}"Parser:parser.c -o "{Objs}"parser.c.o -s parser.c {CFlags} - -"{Objs}"parsetok.c.o Ä "{Top}"Parser:parsetok.c - {CC} "{Top}"Parser:parsetok.c -o "{Objs}"parsetok.c.o -s parsetok.c {CFlags} - -"{Objs}"classobject.c.o Ä "{Top}"Objects:classobject.c - {CC} "{Top}"Objects:classobject.c -o "{Objs}"classobject.c.o -s classobject.c {CFlags} - -"{Objs}"import.c.o Ä "{Top}"Python:import.c - {CC} "{Top}"Python:import.c -o "{Objs}"import.c.o -s import.c {CFlags} - -"{Objs}"importdl.c.o Ä "{Top}"Python:importdl.c - {CC} "{Top}"Python:importdl.c -o "{Objs}"importdl.c.o -s importdl.c {CFlags} - -"{Objs}"macgetmtime.c.o Ä "{Top}"Mac:macgetmtime.c - {CC} "{Top}"Mac:macgetmtime.c -o "{Objs}"macgetmtime.c.o -s macgetmtime.c {CFlags} - -"{Objs}"macsetfiletype.c.o Ä "{Top}"Mac:macsetfiletype.c - {CC} "{Top}"Mac:macsetfiletype.c -o "{Objs}"macsetfiletype.c.o -s macsetfiletype.c {CFlags} - -"{Objs}"macstat.c.o Ä "{Top}"Mac:macstat.c - {CC} "{Top}"Mac:macstat.c -o "{Objs}"macstat.c.o -s macstat.c {CFlags} - -"{Objs}"macshlglue.c.o Ä "{Top}"Mac:macshlglue.c - {CC} "{Top}"Mac:macshlglue.c -o "{Objs}"macshlglue.c.o -s macshlglue.c {CFlags} - -"{Objs}"marshal.c.o Ä "{Top}"Python:marshal.c - {CC} "{Top}"Python:marshal.c -o "{Objs}"marshal.c.o -s marshal.c {CFlags} - -"{Objs}"timemodule.c.o Ä "{Top}"Modules:timemodule.c - {CC} "{Top}"Modules:timemodule.c -o "{Objs}"timemodule.c.o -s timemodule.c {CFlags} - -"{Objs}"fileobject.c.o Ä "{Top}"Objects:fileobject.c - {CC} "{Top}"Objects:fileobject.c -o "{Objs}"fileobject.c.o -s fileobject.c {CFlags} - -"{Objs}"frameobject.c.o Ä "{Top}"Objects:frameobject.c - {CC} "{Top}"Objects:frameobject.c -o "{Objs}"frameobject.c.o -s frameobject.c {CFlags} - -"{Objs}"funcobject.c.o Ä "{Top}"Objects:funcobject.c - {CC} "{Top}"Objects:funcobject.c -o "{Objs}"funcobject.c.o -s funcobject.c {CFlags} - -"{Objs}"intobject.c.o Ä "{Top}"Objects:intobject.c - {CC} "{Top}"Objects:intobject.c -o "{Objs}"intobject.c.o -s intobject.c {CFlags} - -"{Objs}"listobject.c.o Ä "{Top}"Objects:listobject.c - {CC} "{Top}"Objects:listobject.c -o "{Objs}"listobject.c.o -s listobject.c {CFlags} - -"{Objs}"mappingobject.c.o Ä "{Top}"Objects:mappingobject.c - {CC} "{Top}"Objects:mappingobject.c -o "{Objs}"mappingobject.c.o -s mappingobject.c {CFlags} - -"{Objs}"methodobject.c.o Ä "{Top}"Objects:methodobject.c - {CC} "{Top}"Objects:methodobject.c -o "{Objs}"methodobject.c.o -s methodobject.c {CFlags} - -"{Objs}"moduleobject.c.o Ä "{Top}"Objects:moduleobject.c - {CC} "{Top}"Objects:moduleobject.c -o "{Objs}"moduleobject.c.o -s moduleobject.c {CFlags} - -"{Objs}"object.c.o Ä "{Top}"Objects:object.c - {CC} "{Top}"Objects:object.c -o "{Objs}"object.c.o -s object.c {CFlags} - -"{Objs}"stringobject.c.o Ä "{Top}"Objects:stringobject.c - {CC} "{Top}"Objects:stringobject.c -o "{Objs}"stringobject.c.o -s stringobject.c {CFlags} - -"{Objs}"tupleobject.c.o Ä "{Top}"Objects:tupleobject.c - {CC} "{Top}"Objects:tupleobject.c -o "{Objs}"tupleobject.c.o -s tupleobject.c {CFlags} - -"{Objs}"accessobject.c.o Ä "{Top}"Objects:accessobject.c - {CC} "{Top}"Objects:accessobject.c -o "{Objs}"accessobject.c.o -s accessobject.c {CFlags} - -"{Objs}"floatobject.c.o Ä "{Top}"Objects:floatobject.c - {CC} "{Top}"Objects:floatobject.c -o "{Objs}"floatobject.c.o -s floatobject.c {CFlags} - -"{Objs}"longobject.c.o Ä "{Top}"Objects:longobject.c - {CC} "{Top}"Objects:longobject.c -o "{Objs}"longobject.c.o -s longobject.c {CFlags} - -"{Objs}"typeobject.c.o Ä "{Top}"Objects:typeobject.c - {CC} "{Top}"Objects:typeobject.c -o "{Objs}"typeobject.c.o -s typeobject.c {CFlags} - -"{Objs}"ceval.c.o Ä "{Top}"Python:ceval.c - {CC} "{Top}"Python:ceval.c -o "{Objs}"ceval.c.o -s ceval.c {CFlags} - -"{Objs}"errors.c.o Ä "{Top}"Python:errors.c - {CC} "{Top}"Python:errors.c -o "{Objs}"errors.c.o -s errors.c {CFlags} - -"{Objs}"intrcheck.c.o Ä "{Top}"Parser:intrcheck.c - {CC} "{Top}"Parser:intrcheck.c -o "{Objs}"intrcheck.c.o -s intrcheck.c {CFlags} - -"{Objs}"macglue.c.o Ä "{Top}"Mac:macglue.c - {CC} "{Top}"Mac:macglue.c -o "{Objs}"macglue.c.o -s macglue.c {CFlags} - -"{Objs}"macgetargv.c.o Ä "{Top}"Mac:macgetargv.c - {CC} "{Top}"Mac:macgetargv.c -o "{Objs}"macgetargv.c.o -s macgetargv.c {CFlagsMac} - -"{Objs}"modsupport.c.o Ä "{Top}"Python:modsupport.c - {CC} "{Top}"Python:modsupport.c -o "{Objs}"modsupport.c.o -s modsupport.c {CFlags} - -"{Objs}"sigcheck.c.o Ä "{Top}"Python:sigcheck.c - {CC} "{Top}"Python:sigcheck.c -o "{Objs}"sigcheck.c.o -s sigcheck.c {CFlags} - -"{Objs}"sysmodule.c.o Ä "{Top}"Python:sysmodule.c - {CC} "{Top}"Python:sysmodule.c -o "{Objs}"sysmodule.c.o -s sysmodule.c {CFlags} - -"{Objs}"traceback.c.o Ä "{Top}"Python:traceback.c - {CC} "{Top}"Python:traceback.c -o "{Objs}"traceback.c.o -s traceback.c {CFlags} - -"{Objs}"bltinmodule.c.o Ä "{Top}"Python:bltinmodule.c - {CC} "{Top}"Python:bltinmodule.c -o "{Objs}"bltinmodule.c.o -s bltinmodule.c {CFlags} - -"{Objs}"fopenRF.c.o Ä "{Top}"Mac:fopenRF.c - {CC} "{Top}"Mac:fopenRF.c -o "{Objs}"fopenRF.c.o -s fopenRF.c {CFlags} - -"{Objs}"stdwinmodule.c.o Ä "{Top}"Modules:stdwinmodule.c - {CC} "{Top}"Modules:stdwinmodule.c -o "{Objs}"stdwinmodule.c.o -s stdwinmodule.c {CFlags} - -"{Objs}"ctbmodule.c.o Ä "{Top}"Mac:ctb:ctbmodule.c - {CC} "{Top}"Mac:ctb:ctbmodule.c -o "{Objs}"ctbmodule.c.o -s ctbmodule.c {CFlags} - -"{Objs}"arraymodule.c.o Ä "{Top}"Modules:arraymodule.c - {CC} "{Top}"Modules:arraymodule.c -o "{Objs}"arraymodule.c.o -s arraymodule.c {CFlags} - -"{Objs}"getbootvol.c.o Ä "{Top}"Mac:getbootvol.c - {CC} "{Top}"Mac:getbootvol.c -o "{Objs}"getbootvol.c.o -s getbootvol.c {CFlags} - -"{Objs}"macmodule.c.o Ä "{Top}"Mac:macmodule.c - {CC} "{Top}"Mac:macmodule.c -o "{Objs}"macmodule.c.o -s macmodule.c {CFlags} - -"{Objs}"mkdir.c.o Ä "{Top}"Mac:mkdir.c - {CC} "{Top}"Mac:mkdir.c -o "{Objs}"mkdir.c.o -s mkdir.c {CFlags} - -"{Objs}"opendir.c.o Ä "{Top}"Mac:opendir.c - {CC} "{Top}"Mac:opendir.c -o "{Objs}"opendir.c.o -s opendir.c {CFlags} - -"{Objs}"rmdir.c.o Ä "{Top}"Mac:rmdir.c - {CC} "{Top}"Mac:rmdir.c -o "{Objs}"rmdir.c.o -s rmdir.c {CFlags} - -"{Objs}"sync.c.o Ä "{Top}"Mac:sync.c - {CC} "{Top}"Mac:sync.c -o "{Objs}"sync.c.o -s sync.c {CFlags} - -"{Objs}"audioop.c.o Ä "{Top}"Modules:audioop.c - {CC} "{Top}"Modules:audioop.c -o "{Objs}"audioop.c.o -s audioop.c {CFlags} - -"{Objs}"imageop.c.o Ä "{Top}"Modules:imageop.c - {CC} "{Top}"Modules:imageop.c -o "{Objs}"imageop.c.o -s imageop.c {CFlags} - -"{Objs}"imgformat.c.o Ä "{Top}"Modules:imgformat.c - {CC} "{Top}"Modules:imgformat.c -o "{Objs}"imgformat.c.o -s imgformat.c {CFlags} - -"{Objs}"macconsole.c.o Ä "{Top}"Mac:think:macconsole:macconsole.c - {CC} "{Top}"Mac:think:macconsole:macconsole.c -o "{Objs}"macconsole.c.o -s macconsole.c {CFlags} - -"{Objs}"myreadline.c.o Ä "{Top}"Parser:myreadline.c - {CC} "{Top}"Parser:myreadline.c -o "{Objs}"myreadline.c.o -s myreadline.c {CFlags} - -"{Objs}"pythonrun.c.o Ä "{Top}"Python:pythonrun.c - {CC} "{Top}"Python:pythonrun.c -o "{Objs}"pythonrun.c.o -s pythonrun.c {CFlags} - -"{Objs}"AEmodule.c.o Ä "{Top}"Tools:bgen:ae:AEmodule.c - {CC} "{Top}"Tools:bgen:ae:AEmodule.c -o "{Objs}"AEmodule.c.o -s AEmodule.c {CFlags} - -"{Objs}"Ctlmodule.c.o Ä "{Top}"Tools:bgen:ctl:Ctlmodule.c - {CC} "{Top}"Tools:bgen:ctl:Ctlmodule.c -o "{Objs}"Ctlmodule.c.o -s Ctlmodule.c {CFlags} - -"{Objs}"Dlgmodule.c.o Ä "{Top}"Tools:bgen:dlg:Dlgmodule.c - {CC} "{Top}"Tools:bgen:dlg:Dlgmodule.c -o "{Objs}"Dlgmodule.c.o -s Dlgmodule.c {CFlags} - -"{Objs}"Evtmodule.c.o Ä "{Top}"Tools:bgen:evt:Evtmodule.c - {CC} "{Top}"Tools:bgen:evt:Evtmodule.c -o "{Objs}"Evtmodule.c.o -s Evtmodule.c {CFlags} - -"{Objs}"Menumodule.c.o Ä "{Top}"Tools:bgen:menu:Menumodule.c - {CC} "{Top}"Tools:bgen:menu:Menumodule.c -o "{Objs}"Menumodule.c.o -s Menumodule.c {CFlags} - -"{Objs}"Qdmodule.c.o Ä "{Top}"Tools:bgen:qd:Qdmodule.c - {CC} "{Top}"Tools:bgen:qd:Qdmodule.c -o "{Objs}"Qdmodule.c.o -s Qdmodule.c {CFlags} - -"{Objs}"Resmodule.c.o Ä "{Top}"Tools:bgen:res:Resmodule.c - {CC} "{Top}"Tools:bgen:res:Resmodule.c -o "{Objs}"Resmodule.c.o -s Resmodule.c {CFlags} - -"{Objs}"Sndmodule.c.o Ä "{Top}"Tools:bgen:snd:Sndmodule.c - {CC} "{Top}"Tools:bgen:snd:Sndmodule.c -o "{Objs}"Sndmodule.c.o -s Sndmodule.c {CFlags} - -"{Objs}"Winmodule.c.o Ä "{Top}"Tools:bgen:win:Winmodule.c - {CC} "{Top}"Tools:bgen:win:Winmodule.c -o "{Objs}"Winmodule.c.o -s Winmodule.c {CFlags} - -"{Objs}"md5c.c.o Ä "{Top}"Modules:md5c.c - {CC} "{Top}"Modules:md5c.c -o "{Objs}"md5c.c.o -s md5c.c {CFlags} - -"{Objs}"md5module.c.o Ä "{Top}"Modules:md5module.c - {CC} "{Top}"Modules:md5module.c -o "{Objs}"md5module.c.o -s md5module.c {CFlags} - -"{Objs}"mathmodule.c.o Ä "{Top}"Modules:mathmodule.c - {CC} "{Top}"Modules:mathmodule.c -o "{Objs}"mathmodule.c.o -s mathmodule.c {CFlags} - -"{Objs}"newmodule.c.o Ä "{Top}"Modules:newmodule.c - {CC} "{Top}"Modules:newmodule.c -o "{Objs}"newmodule.c.o -s newmodule.c {CFlags} - -"{Objs}"parsermodule.c.o Ä "{Top}"Modules:parsermodule.c - {CC} "{Top}"Modules:parsermodule.c -o "{Objs}"parsermodule.c.o -s parsermodule.c {CFlags} - -"{Objs}"regexmodule.c.o Ä "{Top}"Modules:regexmodule.c - {CC} "{Top}"Modules:regexmodule.c -o "{Objs}"regexmodule.c.o -s regexmodule.c {CFlags} - -"{Objs}"regexpr.c.o Ä "{Top}"Modules:regexpr.c - {CC} "{Top}"Modules:regexpr.c -o "{Objs}"regexpr.c.o -s regexpr.c {CFlags} - -"{Objs}"rangeobject.c.o Ä "{Top}"Objects:rangeobject.c - {CC} "{Top}"Objects:rangeobject.c -o "{Objs}"rangeobject.c.o -s rangeobject.c {CFlags} - -"{Objs}"rgbimgmodule.c.o Ä "{Top}"Modules:rgbimgmodule.c - {CC} "{Top}"Modules:rgbimgmodule.c -o "{Objs}"rgbimgmodule.c.o -s rgbimgmodule.c {CFlags} - -"{Objs}"rotormodule.c.o Ä "{Top}"Modules:rotormodule.c - {CC} "{Top}"Modules:rotormodule.c -o "{Objs}"rotormodule.c.o -s rotormodule.c {CFlags} - -"{Objs}"structmodule.c.o Ä "{Top}"Modules:structmodule.c - {CC} "{Top}"Modules:structmodule.c -o "{Objs}"structmodule.c.o -s structmodule.c {CFlags} - -"{Objs}"getargs.c.o Ä "{Top}"Python:getargs.c - {CC} "{Top}"Python:getargs.c -o "{Objs}"getargs.c.o -s getargs.c {CFlags} - -"{Objs}"xxmodule.c.o Ä "{Top}"Modules:xxmodule.c - {CC} "{Top}"Modules:xxmodule.c -o "{Objs}"xxmodule.c.o -s xxmodule.c {CFlags} - -"{Objs}"atof.c.o Ä "{Top}"Python:atof.c - {CC} "{Top}"Python:atof.c -o "{Objs}"atof.c.o -s atof.c {CFlags} - -"{Objs}"strtod.c.o Ä "{Top}"Python:strtod.c - {CC} "{Top}"Python:strtod.c -o "{Objs}"strtod.c.o -s strtod.c {CFlags} - -"{Objs}"fmod.c.o Ä "{Top}"Python:fmod.c - {CC} "{Top}"Python:fmod.c -o "{Objs}"fmod.c.o -s fmod.c {CFlags} diff --git a/Mac/MPW/README b/Mac/MPW/README deleted file mode 100644 index 3d58230304..0000000000 --- a/Mac/MPW/README +++ /dev/null @@ -1,122 +0,0 @@ -Python and MPW -============== - -There is conditional code in Python for MPW. This has been used with -different compilers at various points in time. Right now it is being -used to turn the entire interpreter into a shared library on 68K Macs, -so we can build "applets" (see below). I have used MPW 3.2 and the OpenDoc -development environment from an OpenDoc CD released in 1984. This -contains the Symantec C compiler for MPW (version 7.0.4), the -Universal Headers (version 2.0a1), and early versions of CFM-68K (version 1.0a1) -(the Code Fragment Manager ported back to the 68K Mac) and -MixedModeInit (version 1.0d12), which are required to use shared libraries. - -I've created a Makefile that does everything, plus a three-line Build -script that calls Make and runs its output. The Makefile assumes that -it lives in a 1-deep subdirectory of the root, so e.g. the Python -Include directory can be referenced through "::Include". All object -files are collected in the subsubdirectory Objcode. - -I use these feature test macros: - -MPW for all MPW compilers (e.g. long double in ) -__SC__ for things specific to the Symantec C compiler - (e.g. doesn't like static forward) -__CFM68K__ for things specific to CFM-68K - (e.g. it requires the use of #pragma lib_export on|off) -HAVE_UNIVERSAL_HEADERS for things not yet in Think's headers (e.g. UPPs) -GENERATINGCFM for both PPC and 68K Code Fragment Manager - -MPW is defined in config.h (if it finds that applec is defined); -HAVE_UNIVERSAL_HEADERS is defined in macglue.h depending on whether it -thinks we are using Universal Headers. The others are defined by the -compiler or by the system headers. - -Compiler switches were a nightmare until I found I had to use -b. -This wasn't mentioned in the CFM-68K docs that came on the OpenDoc -CD-ROM. Apparently it is only needed for large projects... - - -Warning: Mixing Think C and MPW -=============================== - -(XXX Need to check what convention SC uses -- I hope it uses Think's.) - -If you are mixing Think C and MPW, you may experience weird errors in -previously correct modules. These disappear when you throw away the -module's .pyc file. The errors usually have to do with string -literals containing '\n' or '\r'. The reason is an incompatibility -between their handling of '\n' and '\r' -- in MPW C, '\n' actually is -ASCII CR while '\r' is ASCII LF, which is the reverse situation from -any other ASCII based C implementation. This behaviour is inherited -by Python compiled with MPW C. This is normally not a problem, but -*binary* files written by one system will be mis-interpreted by the -other, and this is what happens to the .pyc files. There is no easy -way to fix this in the source. (This is a real shame, since the -format of .pyc files was carefully designed to be independent of byte -order and integer size -- deviations in the ASCII character codes were -never anticipated.) - - -Building "Applets" for the Mac -============================== - -An "applet" is a tiny application that's written in a scripting language -but behaves like a real application. The behavior is much like that of -executable scripts in Unix -- but the implementation is entirely different. - -The applet's file can be small because it doesn't contain the actual -interpreter for the scripting language -- this has to be installed in the -Extensions folder (usually) before the applet will work. The applet file -itself only contains a tiny bootstrap program and the script itself -- -possibly "compiled" or otherwise encoded to save on parsing time and space, -and to make it harder to reverse engineer the script (some people care about -this). - -In Python's case, the Python interpreter, without its main program, is built -as a shared library that is dropped in the Extensions folder. Some more -shared libraries must also be present -- these form the C run-time system. -[[XXX perhaps we should link these in statically with the Python library, -for simpler distribution???]] On the 68K Mac, two more extensions are needed: -CFM-68K (the Code Fragment Manager) and MixedModeInit. These provide -functionality that's built in the Power Mac's OS. It seems that System 7.1.1 -or higher is also required. - -The applet file contains a small main program program, plus a 'PYC ' resource -named __main__ which contains the "compiled" version of the script. A 'PYC ' -resource contains exactly the same data as a ".pyc" file. (The advantage of -storing compiled modules as resources instead of files is that many modules -can be stored in a single file.) The applet's main -program initializes most of the toolbox managers (it uses the same sequence -as stdwin or the Think C console I/O library), then initializes Python, -then loads the resource and decodes it into a Python code object, and finally -passes the code object to the Python interpreter for execution. [[XXX Actually, -the applet's main program could be moved entirely to the shared library -- -there's nothing in it that's dependent on the applet's configuration. -The applet itself could then be reduced to main() { applet_main(); } ]] -[[XXX I tried this but it only save 512 bytes on a total of 10K -- the rest -is boilerplate that the linker always seems to create. Wonder how this is on -the Power Mac...]] - -A big restriction for applets is that they have no standard input and their -standard output and error streams are diverted to files called "stdout" and -"stderr". This means that in order to interact with the user, or even just -to provide some feedback while they're grinding along, they must make use of -Mac toolbox calls to create windows, etc. I plan to provide a library that at -least has the output functionality of the Think C Console I/O library or -CodeWarrior's SIOX. - -The current procedure to create an applet is not as simple as it could be. -I have written a Python script (which itself can be -- and has been -- made -into an applet!) which asks for a Python source file (input) and an existing -applet file (output). It adds a 'PYC ' resource to the applet named __main__, -which contains the compiled code of the script (it compiles on the fly, -so you don't need to have a .pyc file for the script). -Although this seems fairly simple, the practical complication is that you need -to copy the applet template first -- if you specify the template as the output, -you will overwrite the template! [[XXX I guess a simplification could be made -by using the convention that the applet built from a script has the same name -as the script but with ".py" stripped; the applet-making script could then -search for the template in a few common locations (e.g. the Python module -search path) and copy it, reducing the user interaction to just indicating the -Python source file to be converted into an applet.]] diff --git a/Mac/MPW/buildall b/Mac/MPW/buildall deleted file mode 100644 index 5b1794ae72..0000000000 --- a/Mac/MPW/buildall +++ /dev/null @@ -1,29 +0,0 @@ -Set Defines "-d MPW -d HAVE_CONFIG_H" -Set Includes "-i :: -i ::Include -i ::Mac" -Set SymOptions "-sym off" -Set ModelOptions "-model far" -Set OtherOptions "-warnings off" -Set LinkOptions "{SymOptions} {ModelOptions}" -Set COptions "{OtherOptions} {SymOptions} {ModelOptions} {Defines} {Includes}" -# For compiling code resources; Restrictions apply -Set ResCOptions "{SymOptions} -model near -b {Defines} {Includes} " - -Export ResCOptions -Export COptions -Export LinkOptions - -# modules with the source in a single sub directory -Date -Directory {Python} -for MODULE in Parser Mac Modules Objects Python - Directory :{MODULE}: - Echo "### `Directory`: make {1}" - make {1} > makefile.out - makefile.out - Directory :: -end - -Echo "### `Directory`: make {1}" -make {1} > makefile.out -makefile.out - diff --git a/Mac/Modules/ae/AEmodule.c b/Mac/Modules/ae/AEmodule.c deleted file mode 100644 index e12c6c87ab..0000000000 --- a/Mac/Modules/ae/AEmodule.c +++ /dev/null @@ -1,1181 +0,0 @@ - -/* =========================== Module AE ============================ */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -#ifndef HAVE_UNIVERSAL_HEADERS -#define AEIdleProcPtr IdleProcPtr -#define AEFilterProcPtr EventFilterProcPtr -#define AEEventHandlerProcPtr EventHandlerProcPtr -#endif - -#ifndef HAVE_UNIVERSAL_HEADERS -/* I'm trying to setup the code here so that is easily automated, -** as follows: -** - Use the UPP in the source -** - for pre-universal headers, #define each UPP as the corresponding ProcPtr -** - for each routine we pass we declare a upp_xxx that -** we initialize to the correct value in the init routine. -*/ -#define AEIdleUPP AEIdleProcPtr -#define AEFilterUPP AEFilterProcPtr -#define AEEventHandlerUPP AEEventHandlerProcPtr -#define NewAEIdleProc(x) (x) -#define NewAEFilterProc(x) (x) -#define NewAEEventHandlerProc(x) (x) -#endif - -static pascal OSErr GenericEventHandler(); /* Forward */ - -AEEventHandlerUPP upp_GenericEventHandler; - -static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn) -{ - PyMac_Yield(); - return 0; -} - -AEIdleUPP upp_AEIdleProc; - -static PyObject *AE_Error; - -/* ----------------------- Object type AEDesc ----------------------- */ - -staticforward PyTypeObject AEDesc_Type; - -#define AEDesc_Check(x) ((x)->ob_type == &AEDesc_Type) - -typedef struct AEDescObject { - PyObject_HEAD - AEDesc ob_itself; -} AEDescObject; - -static PyObject *AEDesc_New(itself) - AEDesc *itself; -{ - AEDescObject *it; - it = PyObject_NEW(AEDescObject, &AEDesc_Type); - if (it == NULL) return NULL; - it->ob_itself = *itself; - return (PyObject *)it; -} -static AEDesc_Convert(v, p_itself) - PyObject *v; - AEDesc *p_itself; -{ - if (!AEDesc_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "AEDesc required"); - return 0; - } - *p_itself = ((AEDescObject *)v)->ob_itself; - return 1; -} - -static void AEDesc_dealloc(self) - AEDescObject *self; -{ - AEDisposeDesc(&self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *AEDesc_AECoerceDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - DescType toType; - AEDesc result; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &toType)) - return NULL; - _err = AECoerceDesc(&_self->ob_itself, - toType, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &result); - return _res; -} - -static PyObject *AEDesc_AEDuplicateDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEDesc result; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = AEDuplicateDesc(&_self->ob_itself, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &result); - return _res; -} - -static PyObject *AEDesc_AECountItems(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long theCount; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = AECountItems(&_self->ob_itself, - &theCount); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - theCount); - return _res; -} - -static PyObject *AEDesc_AEPutPtr(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long index; - DescType typeCode; - char *dataPtr__in__; - long dataPtr__len__; - int dataPtr__in_len__; - if (!PyArg_ParseTuple(_args, "lO&s#", - &index, - PyMac_GetOSType, &typeCode, - &dataPtr__in__, &dataPtr__in_len__)) - return NULL; - dataPtr__len__ = dataPtr__in_len__; - _err = AEPutPtr(&_self->ob_itself, - index, - typeCode, - dataPtr__in__, dataPtr__len__); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - dataPtr__error__: ; - return _res; -} - -static PyObject *AEDesc_AEPutDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long index; - AEDesc theAEDesc; - if (!PyArg_ParseTuple(_args, "lO&", - &index, - AEDesc_Convert, &theAEDesc)) - return NULL; - _err = AEPutDesc(&_self->ob_itself, - index, - &theAEDesc); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AEGetNthPtr(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long index; - DescType desiredType; - AEKeyword theAEKeyword; - DescType typeCode; - char *dataPtr__out__; - long dataPtr__len__; - int dataPtr__in_len__; - if (!PyArg_ParseTuple(_args, "lO&i", - &index, - PyMac_GetOSType, &desiredType, - &dataPtr__in_len__)) - return NULL; - if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto dataPtr__error__; - } - dataPtr__len__ = dataPtr__in_len__; - _err = AEGetNthPtr(&_self->ob_itself, - index, - desiredType, - &theAEKeyword, - &typeCode, - dataPtr__out__, dataPtr__len__, &dataPtr__len__); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&O&s#", - PyMac_BuildOSType, theAEKeyword, - PyMac_BuildOSType, typeCode, - dataPtr__out__, (int)dataPtr__len__); - free(dataPtr__out__); - dataPtr__error__: ; - return _res; -} - -static PyObject *AEDesc_AEGetNthDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long index; - DescType desiredType; - AEKeyword theAEKeyword; - AEDesc result; - if (!PyArg_ParseTuple(_args, "lO&", - &index, - PyMac_GetOSType, &desiredType)) - return NULL; - _err = AEGetNthDesc(&_self->ob_itself, - index, - desiredType, - &theAEKeyword, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&O&", - PyMac_BuildOSType, theAEKeyword, - AEDesc_New, &result); - return _res; -} - -static PyObject *AEDesc_AESizeOfNthItem(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long index; - DescType typeCode; - Size dataSize; - if (!PyArg_ParseTuple(_args, "l", - &index)) - return NULL; - _err = AESizeOfNthItem(&_self->ob_itself, - index, - &typeCode, - &dataSize); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&l", - PyMac_BuildOSType, typeCode, - dataSize); - return _res; -} - -static PyObject *AEDesc_AEDeleteItem(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long index; - if (!PyArg_ParseTuple(_args, "l", - &index)) - return NULL; - _err = AEDeleteItem(&_self->ob_itself, - index); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AEPutParamPtr(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType typeCode; - char *dataPtr__in__; - long dataPtr__len__; - int dataPtr__in_len__; - if (!PyArg_ParseTuple(_args, "O&O&s#", - PyMac_GetOSType, &theAEKeyword, - PyMac_GetOSType, &typeCode, - &dataPtr__in__, &dataPtr__in_len__)) - return NULL; - dataPtr__len__ = dataPtr__in_len__; - _err = AEPutParamPtr(&_self->ob_itself, - theAEKeyword, - typeCode, - dataPtr__in__, dataPtr__len__); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - dataPtr__error__: ; - return _res; -} - -static PyObject *AEDesc_AEPutParamDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - AEDesc theAEDesc; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theAEKeyword, - AEDesc_Convert, &theAEDesc)) - return NULL; - _err = AEPutParamDesc(&_self->ob_itself, - theAEKeyword, - &theAEDesc); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AEGetParamPtr(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType desiredType; - DescType typeCode; - char *dataPtr__out__; - long dataPtr__len__; - int dataPtr__in_len__; - if (!PyArg_ParseTuple(_args, "O&O&i", - PyMac_GetOSType, &theAEKeyword, - PyMac_GetOSType, &desiredType, - &dataPtr__in_len__)) - return NULL; - if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto dataPtr__error__; - } - dataPtr__len__ = dataPtr__in_len__; - _err = AEGetParamPtr(&_self->ob_itself, - theAEKeyword, - desiredType, - &typeCode, - dataPtr__out__, dataPtr__len__, &dataPtr__len__); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&s#", - PyMac_BuildOSType, typeCode, - dataPtr__out__, (int)dataPtr__len__); - free(dataPtr__out__); - dataPtr__error__: ; - return _res; -} - -static PyObject *AEDesc_AEGetParamDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType desiredType; - AEDesc result; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theAEKeyword, - PyMac_GetOSType, &desiredType)) - return NULL; - _err = AEGetParamDesc(&_self->ob_itself, - theAEKeyword, - desiredType, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &result); - return _res; -} - -static PyObject *AEDesc_AESizeOfParam(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType typeCode; - Size dataSize; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theAEKeyword)) - return NULL; - _err = AESizeOfParam(&_self->ob_itself, - theAEKeyword, - &typeCode, - &dataSize); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&l", - PyMac_BuildOSType, typeCode, - dataSize); - return _res; -} - -static PyObject *AEDesc_AEDeleteParam(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theAEKeyword)) - return NULL; - _err = AEDeleteParam(&_self->ob_itself, - theAEKeyword); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AEGetAttributePtr(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType desiredType; - DescType typeCode; - char *dataPtr__out__; - long dataPtr__len__; - int dataPtr__in_len__; - if (!PyArg_ParseTuple(_args, "O&O&i", - PyMac_GetOSType, &theAEKeyword, - PyMac_GetOSType, &desiredType, - &dataPtr__in_len__)) - return NULL; - if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto dataPtr__error__; - } - dataPtr__len__ = dataPtr__in_len__; - _err = AEGetAttributePtr(&_self->ob_itself, - theAEKeyword, - desiredType, - &typeCode, - dataPtr__out__, dataPtr__len__, &dataPtr__len__); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&s#", - PyMac_BuildOSType, typeCode, - dataPtr__out__, (int)dataPtr__len__); - free(dataPtr__out__); - dataPtr__error__: ; - return _res; -} - -static PyObject *AEDesc_AEGetAttributeDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType desiredType; - AEDesc result; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theAEKeyword, - PyMac_GetOSType, &desiredType)) - return NULL; - _err = AEGetAttributeDesc(&_self->ob_itself, - theAEKeyword, - desiredType, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &result); - return _res; -} - -static PyObject *AEDesc_AESizeOfAttribute(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType typeCode; - Size dataSize; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theAEKeyword)) - return NULL; - _err = AESizeOfAttribute(&_self->ob_itself, - theAEKeyword, - &typeCode, - &dataSize); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&l", - PyMac_BuildOSType, typeCode, - dataSize); - return _res; -} - -static PyObject *AEDesc_AEPutAttributePtr(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - DescType typeCode; - char *dataPtr__in__; - long dataPtr__len__; - int dataPtr__in_len__; - if (!PyArg_ParseTuple(_args, "O&O&s#", - PyMac_GetOSType, &theAEKeyword, - PyMac_GetOSType, &typeCode, - &dataPtr__in__, &dataPtr__in_len__)) - return NULL; - dataPtr__len__ = dataPtr__in_len__; - _err = AEPutAttributePtr(&_self->ob_itself, - theAEKeyword, - typeCode, - dataPtr__in__, dataPtr__len__); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - dataPtr__error__: ; - return _res; -} - -static PyObject *AEDesc_AEPutAttributeDesc(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword theAEKeyword; - AEDesc theAEDesc; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theAEKeyword, - AEDesc_Convert, &theAEDesc)) - return NULL; - _err = AEPutAttributeDesc(&_self->ob_itself, - theAEKeyword, - &theAEDesc); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AESend(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AppleEvent reply; - AESendMode sendMode; - AESendPriority sendPriority; - long timeOutInTicks; - if (!PyArg_ParseTuple(_args, "lhl", - &sendMode, - &sendPriority, - &timeOutInTicks)) - return NULL; - _err = AESend(&_self->ob_itself, - &reply, - sendMode, - sendPriority, - timeOutInTicks, - upp_AEIdleProc, - (AEFilterUPP)0); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &reply); - return _res; -} - -static PyObject *AEDesc_AEResetTimer(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = AEResetTimer(&_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AESuspendTheCurrentEvent(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = AESuspendTheCurrentEvent(&_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AEResumeTheCurrentEvent(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AppleEvent reply; - AEEventHandlerUPP dispatcher__proc__ = upp_GenericEventHandler; - PyObject *dispatcher; - if (!PyArg_ParseTuple(_args, "O&O", - AEDesc_Convert, &reply, - &dispatcher)) - return NULL; - _err = AEResumeTheCurrentEvent(&_self->ob_itself, - &reply, - dispatcher__proc__, (long)dispatcher); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - Py_INCREF(dispatcher); /* XXX leak, but needed */ - return _res; -} - -static PyObject *AEDesc_AEGetTheCurrentEvent(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = AEGetTheCurrentEvent(&_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AEDesc_AESetTheCurrentEvent(_self, _args) - AEDescObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = AESetTheCurrentEvent(&_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef AEDesc_methods[] = { - {"AECoerceDesc", (PyCFunction)AEDesc_AECoerceDesc, 1, - "(DescType toType) -> (AEDesc result)"}, - {"AEDuplicateDesc", (PyCFunction)AEDesc_AEDuplicateDesc, 1, - "() -> (AEDesc result)"}, - {"AECountItems", (PyCFunction)AEDesc_AECountItems, 1, - "() -> (long theCount)"}, - {"AEPutPtr", (PyCFunction)AEDesc_AEPutPtr, 1, - "(long index, DescType typeCode, Buffer dataPtr) -> None"}, - {"AEPutDesc", (PyCFunction)AEDesc_AEPutDesc, 1, - "(long index, AEDesc theAEDesc) -> None"}, - {"AEGetNthPtr", (PyCFunction)AEDesc_AEGetNthPtr, 1, - "(long index, DescType desiredType, Buffer dataPtr) -> (AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr)"}, - {"AEGetNthDesc", (PyCFunction)AEDesc_AEGetNthDesc, 1, - "(long index, DescType desiredType) -> (AEKeyword theAEKeyword, AEDesc result)"}, - {"AESizeOfNthItem", (PyCFunction)AEDesc_AESizeOfNthItem, 1, - "(long index) -> (DescType typeCode, Size dataSize)"}, - {"AEDeleteItem", (PyCFunction)AEDesc_AEDeleteItem, 1, - "(long index) -> None"}, - {"AEPutParamPtr", (PyCFunction)AEDesc_AEPutParamPtr, 1, - "(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None"}, - {"AEPutParamDesc", (PyCFunction)AEDesc_AEPutParamDesc, 1, - "(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None"}, - {"AEGetParamPtr", (PyCFunction)AEDesc_AEGetParamPtr, 1, - "(AEKeyword theAEKeyword, DescType desiredType, Buffer dataPtr) -> (DescType typeCode, Buffer dataPtr)"}, - {"AEGetParamDesc", (PyCFunction)AEDesc_AEGetParamDesc, 1, - "(AEKeyword theAEKeyword, DescType desiredType) -> (AEDesc result)"}, - {"AESizeOfParam", (PyCFunction)AEDesc_AESizeOfParam, 1, - "(AEKeyword theAEKeyword) -> (DescType typeCode, Size dataSize)"}, - {"AEDeleteParam", (PyCFunction)AEDesc_AEDeleteParam, 1, - "(AEKeyword theAEKeyword) -> None"}, - {"AEGetAttributePtr", (PyCFunction)AEDesc_AEGetAttributePtr, 1, - "(AEKeyword theAEKeyword, DescType desiredType, Buffer dataPtr) -> (DescType typeCode, Buffer dataPtr)"}, - {"AEGetAttributeDesc", (PyCFunction)AEDesc_AEGetAttributeDesc, 1, - "(AEKeyword theAEKeyword, DescType desiredType) -> (AEDesc result)"}, - {"AESizeOfAttribute", (PyCFunction)AEDesc_AESizeOfAttribute, 1, - "(AEKeyword theAEKeyword) -> (DescType typeCode, Size dataSize)"}, - {"AEPutAttributePtr", (PyCFunction)AEDesc_AEPutAttributePtr, 1, - "(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None"}, - {"AEPutAttributeDesc", (PyCFunction)AEDesc_AEPutAttributeDesc, 1, - "(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None"}, - {"AESend", (PyCFunction)AEDesc_AESend, 1, - "(AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks) -> (AppleEvent reply)"}, - {"AEResetTimer", (PyCFunction)AEDesc_AEResetTimer, 1, - "() -> None"}, - {"AESuspendTheCurrentEvent", (PyCFunction)AEDesc_AESuspendTheCurrentEvent, 1, - "() -> None"}, - {"AEResumeTheCurrentEvent", (PyCFunction)AEDesc_AEResumeTheCurrentEvent, 1, - "(AppleEvent reply, EventHandler dispatcher) -> None"}, - {"AEGetTheCurrentEvent", (PyCFunction)AEDesc_AEGetTheCurrentEvent, 1, - "() -> None"}, - {"AESetTheCurrentEvent", (PyCFunction)AEDesc_AESetTheCurrentEvent, 1, - "() -> None"}, - {NULL, NULL, 0} -}; - -static PyMethodChain AEDesc_chain = { AEDesc_methods, NULL }; - -static PyObject *AEDesc_getattr(self, name) - AEDescObject *self; - char *name; -{ - - if (strcmp(name, "type") == 0) - return PyMac_BuildOSType(self->ob_itself.descriptorType); - if (strcmp(name, "data") == 0) { - PyObject *res; - char state; - state = HGetState(self->ob_itself.dataHandle); - HLock(self->ob_itself.dataHandle); - res = PyString_FromStringAndSize( - *self->ob_itself.dataHandle, - GetHandleSize(self->ob_itself.dataHandle)); - HUnlock(self->ob_itself.dataHandle); - HSetState(self->ob_itself.dataHandle, state); - return res; - } - if (strcmp(name, "__members__") == 0) - return Py_BuildValue("[ss]", "data", "type"); - - return Py_FindMethodInChain(&AEDesc_chain, (PyObject *)self, name); -} - -#define AEDesc_setattr NULL - -staticforward PyTypeObject AEDesc_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "AEDesc", /*tp_name*/ - sizeof(AEDescObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) AEDesc_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) AEDesc_getattr, /*tp_getattr*/ - (setattrfunc) AEDesc_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type AEDesc --------------------- */ - - -static PyObject *AE_AECreateDesc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - DescType typeCode; - char *dataPtr__in__; - long dataPtr__len__; - int dataPtr__in_len__; - AEDesc result; - if (!PyArg_ParseTuple(_args, "O&s#", - PyMac_GetOSType, &typeCode, - &dataPtr__in__, &dataPtr__in_len__)) - return NULL; - dataPtr__len__ = dataPtr__in_len__; - _err = AECreateDesc(typeCode, - dataPtr__in__, dataPtr__len__, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &result); - dataPtr__error__: ; - return _res; -} - -static PyObject *AE_AECoercePtr(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - DescType typeCode; - char *dataPtr__in__; - long dataPtr__len__; - int dataPtr__in_len__; - DescType toType; - AEDesc result; - if (!PyArg_ParseTuple(_args, "O&s#O&", - PyMac_GetOSType, &typeCode, - &dataPtr__in__, &dataPtr__in_len__, - PyMac_GetOSType, &toType)) - return NULL; - dataPtr__len__ = dataPtr__in_len__; - _err = AECoercePtr(typeCode, - dataPtr__in__, dataPtr__len__, - toType, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &result); - dataPtr__error__: ; - return _res; -} - -static PyObject *AE_AECreateList(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - char *factoringPtr__in__; - long factoringPtr__len__; - int factoringPtr__in_len__; - Boolean isRecord; - AEDescList resultList; - if (!PyArg_ParseTuple(_args, "s#b", - &factoringPtr__in__, &factoringPtr__in_len__, - &isRecord)) - return NULL; - factoringPtr__len__ = factoringPtr__in_len__; - _err = AECreateList(factoringPtr__in__, factoringPtr__len__, - isRecord, - &resultList); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &resultList); - factoringPtr__error__: ; - return _res; -} - -static PyObject *AE_AECreateAppleEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEEventClass theAEEventClass; - AEEventID theAEEventID; - AEAddressDesc target; - short returnID; - long transactionID; - AppleEvent result; - if (!PyArg_ParseTuple(_args, "O&O&O&hl", - PyMac_GetOSType, &theAEEventClass, - PyMac_GetOSType, &theAEEventID, - AEDesc_Convert, &target, - &returnID, - &transactionID)) - return NULL; - _err = AECreateAppleEvent(theAEEventClass, - theAEEventID, - &target, - returnID, - transactionID, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &result); - return _res; -} - -static PyObject *AE_AEProcessAppleEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - EventRecord theEventRecord; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetEventRecord, &theEventRecord)) - return NULL; - _err = AEProcessAppleEvent(&theEventRecord); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AE_AEGetInteractionAllowed(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEInteractAllowed level; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = AEGetInteractionAllowed(&level); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("b", - level); - return _res; -} - -static PyObject *AE_AESetInteractionAllowed(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEInteractAllowed level; - if (!PyArg_ParseTuple(_args, "b", - &level)) - return NULL; - _err = AESetInteractionAllowed(level); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AE_AEInteractWithUser(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long timeOutInTicks; - if (!PyArg_ParseTuple(_args, "l", - &timeOutInTicks)) - return NULL; - _err = AEInteractWithUser(timeOutInTicks, - (NMRecPtr)0, - upp_AEIdleProc); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AE_AEInstallEventHandler(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEEventClass theAEEventClass; - AEEventID theAEEventID; - AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; - PyObject *handler; - if (!PyArg_ParseTuple(_args, "O&O&O", - PyMac_GetOSType, &theAEEventClass, - PyMac_GetOSType, &theAEEventID, - &handler)) - return NULL; - _err = AEInstallEventHandler(theAEEventClass, - theAEEventID, - handler__proc__, (long)handler, - 0); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - Py_INCREF(handler); /* XXX leak, but needed */ - return _res; -} - -static PyObject *AE_AERemoveEventHandler(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEEventClass theAEEventClass; - AEEventID theAEEventID; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theAEEventClass, - PyMac_GetOSType, &theAEEventID)) - return NULL; - _err = AERemoveEventHandler(theAEEventClass, - theAEEventID, - upp_GenericEventHandler, - 0); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *AE_AEGetEventHandler(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEEventClass theAEEventClass; - AEEventID theAEEventID; - AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; - PyObject *handler; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theAEEventClass, - PyMac_GetOSType, &theAEEventID)) - return NULL; - _err = AEGetEventHandler(theAEEventClass, - theAEEventID, - &handler__proc__, (long *)&handler, - 0); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O", - handler); - Py_INCREF(handler); /* XXX leak, but needed */ - return _res; -} - -static PyObject *AE_AEManagerInfo(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - AEKeyword keyWord; - long result; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &keyWord)) - return NULL; - _err = AEManagerInfo(keyWord, - &result); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - result); - return _res; -} - -static PyMethodDef AE_methods[] = { - {"AECreateDesc", (PyCFunction)AE_AECreateDesc, 1, - "(DescType typeCode, Buffer dataPtr) -> (AEDesc result)"}, - {"AECoercePtr", (PyCFunction)AE_AECoercePtr, 1, - "(DescType typeCode, Buffer dataPtr, DescType toType) -> (AEDesc result)"}, - {"AECreateList", (PyCFunction)AE_AECreateList, 1, - "(Buffer factoringPtr, Boolean isRecord) -> (AEDescList resultList)"}, - {"AECreateAppleEvent", (PyCFunction)AE_AECreateAppleEvent, 1, - "(AEEventClass theAEEventClass, AEEventID theAEEventID, AEAddressDesc target, short returnID, long transactionID) -> (AppleEvent result)"}, - {"AEProcessAppleEvent", (PyCFunction)AE_AEProcessAppleEvent, 1, - "(EventRecord theEventRecord) -> None"}, - {"AEGetInteractionAllowed", (PyCFunction)AE_AEGetInteractionAllowed, 1, - "() -> (AEInteractAllowed level)"}, - {"AESetInteractionAllowed", (PyCFunction)AE_AESetInteractionAllowed, 1, - "(AEInteractAllowed level) -> None"}, - {"AEInteractWithUser", (PyCFunction)AE_AEInteractWithUser, 1, - "(long timeOutInTicks) -> None"}, - {"AEInstallEventHandler", (PyCFunction)AE_AEInstallEventHandler, 1, - "(AEEventClass theAEEventClass, AEEventID theAEEventID, EventHandler handler) -> None"}, - {"AERemoveEventHandler", (PyCFunction)AE_AERemoveEventHandler, 1, - "(AEEventClass theAEEventClass, AEEventID theAEEventID) -> None"}, - {"AEGetEventHandler", (PyCFunction)AE_AEGetEventHandler, 1, - "(AEEventClass theAEEventClass, AEEventID theAEEventID) -> (EventHandler handler)"}, - {"AEManagerInfo", (PyCFunction)AE_AEManagerInfo, 1, - "(AEKeyword keyWord) -> (long result)"}, - {NULL, NULL, 0} -}; - - - -static pascal OSErr -GenericEventHandler(AppleEvent *request, AppleEvent *reply, long refcon) -{ - PyObject *handler = (PyObject *)refcon; - AEDescObject *requestObject, *replyObject; - PyObject *args, *res; - if ((requestObject = (AEDescObject *)AEDesc_New(request)) == NULL) { - return -1; - } - if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) { - Py_DECREF(requestObject); - return -1; - } - if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) { - Py_DECREF(requestObject); - Py_DECREF(replyObject); - return -1; - } - res = PyEval_CallObject(handler, args); - requestObject->ob_itself.descriptorType = 'null'; - requestObject->ob_itself.dataHandle = NULL; - replyObject->ob_itself.descriptorType = 'null'; - replyObject->ob_itself.dataHandle = NULL; - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return noErr; -} - - -void initAE() -{ - PyObject *m; - PyObject *d; - - - - upp_AEIdleProc = NewAEIdleProc(AEIdleProc); - upp_GenericEventHandler = NewAEEventHandlerProc(GenericEventHandler); - - - m = Py_InitModule("AE", AE_methods); - d = PyModule_GetDict(m); - AE_Error = PyMac_GetOSErrException(); - if (AE_Error == NULL || - PyDict_SetItemString(d, "Error", AE_Error) != 0) - Py_FatalError("can't initialize AE.Error"); -} - -/* ========================= End module AE ========================== */ - diff --git a/Mac/Modules/ae/README b/Mac/Modules/ae/README deleted file mode 100644 index f91c44f671..0000000000 --- a/Mac/Modules/ae/README +++ /dev/null @@ -1,24 +0,0 @@ -A quick note on what all the files here are, currently (16-7-95), -and whether they really are source or generated. - -aegen.py Generated by aescan, temporary file -AEModule.c Generated by aescan, from AppleEvents.h -AEObjects.py Generated by aescan, from AEObjects.h -aepack.py Routines to convert python objects <-> AEDesc record - (formerly part of aetools, now imported there) -AERegistry.py Generated by aescan, from AERegistry.h -aescan.py Program to scan headers and generate AE modules -aesupport.py Helper code for aescan -aetools.py Routines/classes to create and send appleevents -aetypes.py Classes for python objects corresponding to AEDesc types - (formerly part of aetools, now imported there) -AppleEvents.py Generated by aescan, from AppleEvents.h -AppleScript_Suite.py Generated by gensuitemodule -echo.py Old test program (may still work) to echo events back to sender -gensuitemodule.py Program to scan aete/aeut resources and generate python - interface modules -Required_Suite.py Generated by gensuitemodule -Standard_Suite.py Generated by gensuitemodule -tae.py Old test program (may still work) to send an appleevent -tell.py Old test program (may still work) to send an appleevent -test_suite.py Test program to test bits of the _Suite modules and aetools/etc diff --git a/Mac/Modules/ae/aescan.py b/Mac/Modules/ae/aescan.py deleted file mode 100644 index 4317195665..0000000000 --- a/Mac/Modules/ae/aescan.py +++ /dev/null @@ -1,106 +0,0 @@ -# Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files. -# Then run aesupport to generate AEmodule.c. -0# (Should learn how to tell the compiler to compile it as well.) - -import addpack -addpack.addpack(':Tools:bgen:bgen') -import sys -import os -import string -import regex -import regsub -import MacOS -from bgenlocations import TOOLBOXDIR - -from scantools import Scanner - -def main(): - print "=== Scanning AERegistry.h for defines ===" - input = "AERegistry.h" - output = "@dummy-registry.py" - defsoutput = TOOLBOXDIR + "AERegistry.py" - scanner = AppleEventsScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Scanning AEObjects.h for defines ===" - # XXXX This isn't correct. We only scan AEObjects.h for defines, but there - # are some functions in there that are probably useful (the accessor stuff) - # once we start writing servers in python. - input = "AEObjects.h" - output = "@dummy-objects.py" - defsoutput = TOOLBOXDIR + "AEObjects.py" - scanner = AppleEventsScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Scanning AppleEvents.py ===" - input = "AppleEvents.h" - output = "aegen.py" - defsoutput = TOOLBOXDIR + "AppleEvents.py" - scanner = AppleEventsScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done Scanning and Generating, now doing 'import aesupport' ===" - import aesupport - print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ===" - -class AppleEventsScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "AEFunction" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t[-4:] == "_ptr" and m == "InMode" and \ - t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList", - "AERecord", "AppleEvent"): - classname = "AEMethod" - listname = "aedescmethods" - return classname, listname - - def makeblacklistnames(self): - return [ - "AEDisposeDesc", -# "AEGetEventHandler", - ] - - def makeblacklisttypes(self): - return [ - "ProcPtr", - "AEArrayType", - "AECoercionHandlerUPP", - "UniversalProcPtr", - ] - - def makerepairinstructions(self): - return [ - ([("Boolean", "isSysHandler", "InMode")], - [("AlwaysFalse", "*", "*")]), - - ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")], - [("EventHandler", "*", "*")]), - - ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")], - [("EventHandler", "*", "*")]), - - ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")], - [("EventHandler", "*", "*")]), - - ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")], - [("EventHandler", "*", "*")]), - - ([("void", "*", "OutMode"), ("Size", "*", "InMode"), - ("Size", "*", "OutMode")], - [("VarVarOutBuffer", "*", "InOutMode")]), - - ([("AppleEvent", "theAppleEvent", "OutMode")], - [("AppleEvent_ptr", "*", "InMode")]), - - ([("AEDescList", "theAEDescList", "OutMode")], - [("AEDescList_ptr", "*", "InMode")]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/ae/aesupport.py b/Mac/Modules/ae/aesupport.py deleted file mode 100644 index 8e4c7a3a44..0000000000 --- a/Mac/Modules/ae/aesupport.py +++ /dev/null @@ -1,202 +0,0 @@ -# This script will generate the AppleEvents interface for Python. -# It uses the "bgen" package to generate C code. -# It execs the file aegen.py which contain the function definitions -# (aegen.py was generated by aescan.py, scanning the header file). - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from macsupport import * - - -AEArrayType = Type("AEArrayType", "c") -AESendMode = Type("AESendMode", "l") -AESendPriority = Type("AESendPriority", "h") -AEInteractAllowed = Type("AEInteractAllowed", "b") - - -AEEventClass = OSTypeType('AEEventClass') -AEEventID = OSTypeType('AEEventID') -AEKeyword = OSTypeType('AEKeyword') -DescType = OSTypeType('DescType') - - -AEDesc = OpaqueType('AEDesc') -AEDesc_ptr = OpaqueType('AEDesc') - -AEAddressDesc = OpaqueType('AEAddressDesc', 'AEDesc') -AEAddressDesc_ptr = OpaqueType('AEAddressDesc', 'AEDesc') - -AEDescList = OpaqueType('AEDescList', 'AEDesc') -AEDescList_ptr = OpaqueType('AEDescList', 'AEDesc') - -AERecord = OpaqueType('AERecord', 'AEDesc') -AERecord_ptr = OpaqueType('AERecord', 'AEDesc') - -AppleEvent = OpaqueType('AppleEvent', 'AEDesc') -AppleEvent_ptr = OpaqueType('AppleEvent', 'AEDesc') - - -class EHType(Type): - def __init__(self, name = 'EventHandler', format = ''): - Type.__init__(self, name, format) - def declare(self, name): - Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name) - Output("PyObject *%s;", name) - def getargsFormat(self): - return "O" - def getargsArgs(self, name): - return "&%s" % name - def passInput(self, name): - return "%s__proc__, (long)%s" % (name, name) - def passOutput(self, name): - return "&%s__proc__, (long *)&%s" % (name, name) - def mkvalueFormat(self): - return "O" - def mkvalueArgs(self, name): - return name - def cleanup(self, name): - Output("Py_INCREF(%s); /* XXX leak, but needed */", name) - -class EHNoRefConType(EHType): - def passInput(self, name): - return "upp_GenericEventHandler" - -EventHandler = EHType() -EventHandlerNoRefCon = EHNoRefConType() - - -IdleProcPtr = FakeType("upp_AEIdleProc") -AEIdleUPP = IdleProcPtr -EventFilterProcPtr = FakeType("(AEFilterUPP)0") -AEFilterUPP = EventFilterProcPtr -NMRecPtr = FakeType("(NMRecPtr)0") -EventHandlerProcPtr = FakeType("upp_GenericEventHandler") -AEEventHandlerUPP = EventHandlerProcPtr -AlwaysFalse = FakeType("0") - - -AEFunction = OSErrFunctionGenerator -AEMethod = OSErrMethodGenerator - - -includestuff = includestuff + """ -#include - -#ifndef HAVE_UNIVERSAL_HEADERS -#define AEIdleProcPtr IdleProcPtr -#define AEFilterProcPtr EventFilterProcPtr -#define AEEventHandlerProcPtr EventHandlerProcPtr -#endif - -#ifndef HAVE_UNIVERSAL_HEADERS -/* I'm trying to setup the code here so that is easily automated, -** as follows: -** - Use the UPP in the source -** - for pre-universal headers, #define each UPP as the corresponding ProcPtr -** - for each routine we pass we declare a upp_xxx that -** we initialize to the correct value in the init routine. -*/ -#define AEIdleUPP AEIdleProcPtr -#define AEFilterUPP AEFilterProcPtr -#define AEEventHandlerUPP AEEventHandlerProcPtr -#define NewAEIdleProc(x) (x) -#define NewAEFilterProc(x) (x) -#define NewAEEventHandlerProc(x) (x) -#endif - -static pascal OSErr GenericEventHandler(); /* Forward */ - -AEEventHandlerUPP upp_GenericEventHandler; - -static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn) -{ - PyMac_Yield(); - return 0; -} - -AEIdleUPP upp_AEIdleProc; -""" - -finalstuff = finalstuff + """ -static pascal OSErr -GenericEventHandler(AppleEvent *request, AppleEvent *reply, long refcon) -{ - PyObject *handler = (PyObject *)refcon; - AEDescObject *requestObject, *replyObject; - PyObject *args, *res; - if ((requestObject = (AEDescObject *)AEDesc_New(request)) == NULL) { - return -1; - } - if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) { - Py_DECREF(requestObject); - return -1; - } - if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) { - Py_DECREF(requestObject); - Py_DECREF(replyObject); - return -1; - } - res = PyEval_CallObject(handler, args); - requestObject->ob_itself.descriptorType = 'null'; - requestObject->ob_itself.dataHandle = NULL; - replyObject->ob_itself.descriptorType = 'null'; - replyObject->ob_itself.dataHandle = NULL; - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return noErr; -} -""" - -initstuff = initstuff + """ - upp_AEIdleProc = NewAEIdleProc(AEIdleProc); - upp_GenericEventHandler = NewAEEventHandlerProc(GenericEventHandler); -""" - -module = MacModule('AE', 'AE', includestuff, finalstuff, initstuff) - -class AEDescDefiniton(ObjectDefinition): - - def __init__(self, name, prefix = None, itselftype = None): - ObjectDefinition.__init__(self, name, prefix or name, itselftype or name) - self.argref = "*" - - def outputFreeIt(self, name): - Output("AEDisposeDesc(&%s);", name) - - def outputGetattrHook(self): - Output(""" -if (strcmp(name, "type") == 0) - return PyMac_BuildOSType(self->ob_itself.descriptorType); -if (strcmp(name, "data") == 0) { - PyObject *res; - char state; - state = HGetState(self->ob_itself.dataHandle); - HLock(self->ob_itself.dataHandle); - res = PyString_FromStringAndSize( - *self->ob_itself.dataHandle, - GetHandleSize(self->ob_itself.dataHandle)); - HUnlock(self->ob_itself.dataHandle); - HSetState(self->ob_itself.dataHandle, state); - return res; -} -if (strcmp(name, "__members__") == 0) - return Py_BuildValue("[ss]", "data", "type"); -""") - - -aedescobject = AEDescDefiniton('AEDesc') -module.addobject(aedescobject) - -functions = [] -aedescmethods = [] - -execfile('aegen.py') - -for f in functions: module.add(f) -for f in aedescmethods: aedescobject.add(f) - -SetOutputFileName('AEmodule.c') -module.generate() diff --git a/Mac/Modules/ae/nsremote.py b/Mac/Modules/ae/nsremote.py deleted file mode 100644 index cace37450e..0000000000 --- a/Mac/Modules/ae/nsremote.py +++ /dev/null @@ -1,76 +0,0 @@ -"""nsremote - Control Netscape from python. - -Interface modelled after unix-interface done -by hassan@cs.stanford.edu. - -Jack Jansen, CWI, January 1996. -""" -# -# Note: this module currently uses the funny SpyGlass AppleEvents, since -# these seem to be the only way to get the info from Netscape. It would -# be nicer to use the more "object oriented" standard OSA stuff, when it -# is implemented in Netscape. -# -import addpack -import sys - -addpack.addpack('Tools') -addpack.addpack('bgen') -addpack.addpack('ae') - -import aetools -import Standard_Suite -import WWW_Suite -import MacOS - -class Netscape(aetools.TalkTo, Standard_Suite.Standard_Suite, WWW_Suite.WWW_Suite): - pass - -SIGNATURE='MOSS' - -Error = 'nsremote.Error' - -_talker = None - -def _init(): - global _talker - if _talker == None: - _talker = Netscape(SIGNATURE) - -def list(dpyinfo=""): - _init() - list = _talker.list_windows() - return map(lambda x: (x, 'version unknown'), list) - -def geturl(windowid=0, dpyinfo=""): - _init() - if windowid == 0: - ids = _talker.list_windows() - if not ids: - raise Error, 'No netscape windows open' - windowid = ids[0] - info = _talker.get_window_info(windowid) - return info - -def openurl(url, windowid=0, dpyinfo=""): - _init() - if windowid == 0: - _talker.OpenURL(url) - else: - _talker.OpenURL(url, toWindow=windowid) - -def _test(): - """Test program: Open www.python.org in all windows, then revert""" - import sys - windows_and_versions = list() - windows_and_urls = map(lambda x: (x[0], geturl(x[0])[0]), windows_and_versions) - for id, version in windows_and_versions: - openurl('http://www.python.org/', windowid=id) - print 'Type return to revert to old contents-' - sys.stdin.readline() - for id, url in windows_and_urls: - openurl(url, id) - -if __name__ == '__main__': - _test() - diff --git a/Mac/Modules/cm/Cmmodule.c b/Mac/Modules/cm/Cmmodule.c deleted file mode 100644 index fd8b331029..0000000000 --- a/Mac/Modules/cm/Cmmodule.c +++ /dev/null @@ -1,767 +0,0 @@ - -/* =========================== Module Cm ============================ */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -/* -** Parse/generate ComponentDescriptor records -*/ -PyObject *CmpDesc_New(itself) - ComponentDescription *itself; -{ - - return Py_BuildValue("O&O&O&ll", - PyMac_BuildOSType, itself->componentType, - PyMac_BuildOSType, itself->componentSubType, - PyMac_BuildOSType, itself->componentManufacturer, - itself->componentFlags, itself->componentFlagsMask); -} - -CmpDesc_Convert(v, p_itself) - PyObject *v; - ComponentDescription *p_itself; -{ - return PyArg_ParseTuple(v, "O&O&O&ll", - PyMac_GetOSType, &p_itself->componentType, - PyMac_GetOSType, &p_itself->componentSubType, - PyMac_GetOSType, &p_itself->componentManufacturer, - &p_itself->componentFlags, &p_itself->componentFlagsMask); -} - - -static PyObject *Cm_Error; - -/* ----------------- Object type ComponentInstance ------------------ */ - -PyTypeObject ComponentInstance_Type; - -#define CmpInstObj_Check(x) ((x)->ob_type == &ComponentInstance_Type) - -typedef struct ComponentInstanceObject { - PyObject_HEAD - ComponentInstance ob_itself; -} ComponentInstanceObject; - -PyObject *CmpInstObj_New(itself) - ComponentInstance itself; -{ - ComponentInstanceObject *it; - if (itself == NULL) { - PyErr_SetString(Cm_Error,"NULL ComponentInstance"); - return NULL; - } - it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -CmpInstObj_Convert(v, p_itself) - PyObject *v; - ComponentInstance *p_itself; -{ - if (!CmpInstObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "ComponentInstance required"); - return 0; - } - *p_itself = ((ComponentInstanceObject *)v)->ob_itself; - return 1; -} - -static void CmpInstObj_dealloc(self) - ComponentInstanceObject *self; -{ - /* Cleanup of self->ob_itself goes here */ - PyMem_DEL(self); -} - -static PyObject *CmpInstObj_CloseComponent(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = CloseComponent(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpInstObj_GetComponentInstanceError(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetComponentInstanceError(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpInstObj_ComponentFunctionImplemented(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - short ftnNumber; - if (!PyArg_ParseTuple(_args, "h", - &ftnNumber)) - return NULL; - _rv = ComponentFunctionImplemented(_self->ob_itself, - ftnNumber); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *CmpInstObj_GetComponentVersion(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetComponentVersion(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *CmpInstObj_ComponentSetTarget(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - ComponentInstance target; - if (!PyArg_ParseTuple(_args, "O&", - CmpInstObj_Convert, &target)) - return NULL; - _rv = ComponentSetTarget(_self->ob_itself, - target); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *CmpInstObj_SetComponentInstanceError(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr theError; - if (!PyArg_ParseTuple(_args, "h", - &theError)) - return NULL; - SetComponentInstanceError(_self->ob_itself, - theError); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpInstObj_GetComponentInstanceStorage(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetComponentInstanceStorage(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *CmpInstObj_SetComponentInstanceStorage(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle theStorage; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theStorage)) - return NULL; - SetComponentInstanceStorage(_self->ob_itself, - theStorage); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpInstObj_GetComponentInstanceA5(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetComponentInstanceA5(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *CmpInstObj_SetComponentInstanceA5(_self, _args) - ComponentInstanceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long theA5; - if (!PyArg_ParseTuple(_args, "l", - &theA5)) - return NULL; - SetComponentInstanceA5(_self->ob_itself, - theA5); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef CmpInstObj_methods[] = { - {"CloseComponent", (PyCFunction)CmpInstObj_CloseComponent, 1, - "() -> None"}, - {"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1, - "() -> None"}, - {"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1, - "(short ftnNumber) -> (long _rv)"}, - {"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1, - "() -> (long _rv)"}, - {"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1, - "(ComponentInstance target) -> (long _rv)"}, - {"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1, - "(OSErr theError) -> None"}, - {"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1, - "() -> (Handle _rv)"}, - {"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1, - "(Handle theStorage) -> None"}, - {"GetComponentInstanceA5", (PyCFunction)CmpInstObj_GetComponentInstanceA5, 1, - "() -> (long _rv)"}, - {"SetComponentInstanceA5", (PyCFunction)CmpInstObj_SetComponentInstanceA5, 1, - "(long theA5) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain CmpInstObj_chain = { CmpInstObj_methods, NULL }; - -static PyObject *CmpInstObj_getattr(self, name) - ComponentInstanceObject *self; - char *name; -{ - return Py_FindMethodInChain(&CmpInstObj_chain, (PyObject *)self, name); -} - -#define CmpInstObj_setattr NULL - -PyTypeObject ComponentInstance_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "ComponentInstance", /*tp_name*/ - sizeof(ComponentInstanceObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) CmpInstObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) CmpInstObj_getattr, /*tp_getattr*/ - (setattrfunc) CmpInstObj_setattr, /*tp_setattr*/ -}; - -/* --------------- End object type ComponentInstance ---------------- */ - - -/* --------------------- Object type Component ---------------------- */ - -PyTypeObject Component_Type; - -#define CmpObj_Check(x) ((x)->ob_type == &Component_Type) - -typedef struct ComponentObject { - PyObject_HEAD - Component ob_itself; -} ComponentObject; - -PyObject *CmpObj_New(itself) - Component itself; -{ - ComponentObject *it; - if (itself == NULL) { - /* XXXX Or should we return None? */ - PyErr_SetString(Cm_Error,"No such component"); - return NULL; - } - it = PyObject_NEW(ComponentObject, &Component_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -CmpObj_Convert(v, p_itself) - PyObject *v; - Component *p_itself; -{ - if ( v == Py_None ) { - *p_itself = 0; - return 1; - } - if (!CmpObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Component required"); - return 0; - } - *p_itself = ((ComponentObject *)v)->ob_itself; - return 1; -} - -static void CmpObj_dealloc(self) - ComponentObject *self; -{ - /* Cleanup of self->ob_itself goes here */ - PyMem_DEL(self); -} - -static PyObject *CmpObj_UnregisterComponent(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = UnregisterComponent(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpObj_GetComponentInfo(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - ComponentDescription cd; - Handle componentName; - Handle componentInfo; - Handle componentIcon; - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &componentName, - ResObj_Convert, &componentInfo, - ResObj_Convert, &componentIcon)) - return NULL; - _err = GetComponentInfo(_self->ob_itself, - &cd, - componentName, - componentInfo, - componentIcon); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - CmpDesc_New, &cd); - return _res; -} - -static PyObject *CmpObj_OpenComponent(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentInstance _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = OpenComponent(_self->ob_itself); - _res = Py_BuildValue("O&", - CmpInstObj_New, _rv); - return _res; -} - -static PyObject *CmpObj_GetComponentRefcon(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetComponentRefcon(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *CmpObj_SetComponentRefcon(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long theRefcon; - if (!PyArg_ParseTuple(_args, "l", - &theRefcon)) - return NULL; - SetComponentRefcon(_self->ob_itself, - theRefcon); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpObj_OpenComponentResFile(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = OpenComponentResFile(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *CmpObj_CountComponentInstances(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CountComponentInstances(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *CmpObj_SetDefaultComponent(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short flags; - if (!PyArg_ParseTuple(_args, "h", - &flags)) - return NULL; - _err = SetDefaultComponent(_self->ob_itself, - flags); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpObj_CaptureComponent(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Component _rv; - Component capturingComponent; - if (!PyArg_ParseTuple(_args, "O&", - CmpObj_Convert, &capturingComponent)) - return NULL; - _rv = CaptureComponent(_self->ob_itself, - capturingComponent); - _res = Py_BuildValue("O&", - CmpObj_New, _rv); - return _res; -} - -static PyObject *CmpObj_UncaptureComponent(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = UncaptureComponent(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CmpObj_GetComponentIconSuite(_self, _args) - ComponentObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle iconSuite; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetComponentIconSuite(_self->ob_itself, - &iconSuite); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - ResObj_New, iconSuite); - return _res; -} - -static PyMethodDef CmpObj_methods[] = { - {"UnregisterComponent", (PyCFunction)CmpObj_UnregisterComponent, 1, - "() -> None"}, - {"GetComponentInfo", (PyCFunction)CmpObj_GetComponentInfo, 1, - "(Handle componentName, Handle componentInfo, Handle componentIcon) -> (ComponentDescription cd)"}, - {"OpenComponent", (PyCFunction)CmpObj_OpenComponent, 1, - "() -> (ComponentInstance _rv)"}, - {"GetComponentRefcon", (PyCFunction)CmpObj_GetComponentRefcon, 1, - "() -> (long _rv)"}, - {"SetComponentRefcon", (PyCFunction)CmpObj_SetComponentRefcon, 1, - "(long theRefcon) -> None"}, - {"OpenComponentResFile", (PyCFunction)CmpObj_OpenComponentResFile, 1, - "() -> (short _rv)"}, - {"CountComponentInstances", (PyCFunction)CmpObj_CountComponentInstances, 1, - "() -> (long _rv)"}, - {"SetDefaultComponent", (PyCFunction)CmpObj_SetDefaultComponent, 1, - "(short flags) -> None"}, - {"CaptureComponent", (PyCFunction)CmpObj_CaptureComponent, 1, - "(Component capturingComponent) -> (Component _rv)"}, - {"UncaptureComponent", (PyCFunction)CmpObj_UncaptureComponent, 1, - "() -> None"}, - {"GetComponentIconSuite", (PyCFunction)CmpObj_GetComponentIconSuite, 1, - "() -> (Handle iconSuite)"}, - {NULL, NULL, 0} -}; - -PyMethodChain CmpObj_chain = { CmpObj_methods, NULL }; - -static PyObject *CmpObj_getattr(self, name) - ComponentObject *self; - char *name; -{ - return Py_FindMethodInChain(&CmpObj_chain, (PyObject *)self, name); -} - -#define CmpObj_setattr NULL - -PyTypeObject Component_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Component", /*tp_name*/ - sizeof(ComponentObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) CmpObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) CmpObj_getattr, /*tp_getattr*/ - (setattrfunc) CmpObj_setattr, /*tp_setattr*/ -}; - -/* ------------------- End object type Component -------------------- */ - - -static PyObject *Cm_RegisterComponentResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Component _rv; - ComponentResourceHandle tr; - short global; - if (!PyArg_ParseTuple(_args, "O&h", - ResObj_Convert, &tr, - &global)) - return NULL; - _rv = RegisterComponentResource(tr, - global); - _res = Py_BuildValue("O&", - CmpObj_New, _rv); - return _res; -} - -static PyObject *Cm_FindNextComponent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Component _rv; - Component aComponent; - ComponentDescription looking; - if (!PyArg_ParseTuple(_args, "O&O&", - CmpObj_Convert, &aComponent, - CmpDesc_Convert, &looking)) - return NULL; - _rv = FindNextComponent(aComponent, - &looking); - _res = Py_BuildValue("O&", - CmpObj_New, _rv); - return _res; -} - -static PyObject *Cm_CountComponents(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - ComponentDescription looking; - if (!PyArg_ParseTuple(_args, "O&", - CmpDesc_Convert, &looking)) - return NULL; - _rv = CountComponents(&looking); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Cm_GetComponentListModSeed(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetComponentListModSeed(); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Cm_CloseComponentResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short refnum; - if (!PyArg_ParseTuple(_args, "h", - &refnum)) - return NULL; - _err = CloseComponentResFile(refnum); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Cm_OpenDefaultComponent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentInstance _rv; - OSType componentType; - OSType componentSubType; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &componentType, - PyMac_GetOSType, &componentSubType)) - return NULL; - _rv = OpenDefaultComponent(componentType, - componentSubType); - _res = Py_BuildValue("O&", - CmpInstObj_New, _rv); - return _res; -} - -static PyObject *Cm_RegisterComponentResourceFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - short resRefNum; - short global; - if (!PyArg_ParseTuple(_args, "hh", - &resRefNum, - &global)) - return NULL; - _rv = RegisterComponentResourceFile(resRefNum, - global); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyMethodDef Cm_methods[] = { - {"RegisterComponentResource", (PyCFunction)Cm_RegisterComponentResource, 1, - "(ComponentResourceHandle tr, short global) -> (Component _rv)"}, - {"FindNextComponent", (PyCFunction)Cm_FindNextComponent, 1, - "(Component aComponent, ComponentDescription looking) -> (Component _rv)"}, - {"CountComponents", (PyCFunction)Cm_CountComponents, 1, - "(ComponentDescription looking) -> (long _rv)"}, - {"GetComponentListModSeed", (PyCFunction)Cm_GetComponentListModSeed, 1, - "() -> (long _rv)"}, - {"CloseComponentResFile", (PyCFunction)Cm_CloseComponentResFile, 1, - "(short refnum) -> None"}, - {"OpenDefaultComponent", (PyCFunction)Cm_OpenDefaultComponent, 1, - "(OSType componentType, OSType componentSubType) -> (ComponentInstance _rv)"}, - {"RegisterComponentResourceFile", (PyCFunction)Cm_RegisterComponentResourceFile, 1, - "(short resRefNum, short global) -> (long _rv)"}, - {NULL, NULL, 0} -}; - - - - -void initCm() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Cm", Cm_methods); - d = PyModule_GetDict(m); - Cm_Error = PyMac_GetOSErrException(); - if (Cm_Error == NULL || - PyDict_SetItemString(d, "Error", Cm_Error) != 0) - Py_FatalError("can't initialize Cm.Error"); -} - -/* ========================= End module Cm ========================== */ - diff --git a/Mac/Modules/cm/cmscan.py b/Mac/Modules/cm/cmscan.py deleted file mode 100644 index 95abeedcaf..0000000000 --- a/Mac/Modules/cm/cmscan.py +++ /dev/null @@ -1,66 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "Components" -SHORT = "Cm" - -def main(): - input = "Components.h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - # - # FindNextComponent is a special case, since it call also be called - # with None as the argument. Hence, we make it a function - # - if t == "Component" and m == "InMode" and name != "FindNextComponent": - classname = "Method" - listname = "c_methods" - elif t == "ComponentInstance" and m == "InMode": - classname = "Method" - listname = "ci_methods" - return classname, listname - - def makeblacklistnames(self): - return [ - # "GetComponentInfo" # XXXX I dont know how the Handle args are expected... - ] - - def makeblacklisttypes(self): - return [ - "ResourceSpec", - "ComponentResource", - "ComponentPlatformInfo", - "ComponentResourceExtension", - "ComponentPlatformInfoArray", - "ExtComponentResource", - "ComponentParameters", - - "ComponentRoutineUPP", - ] - - def makerepairinstructions(self): - return [ - ([('ComponentDescription', 'looking', 'OutMode')], - [('ComponentDescription', '*', 'InMode')]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/cm/cmsupport.py b/Mac/Modules/cm/cmsupport.py deleted file mode 100644 index 0a1915f3cf..0000000000 --- a/Mac/Modules/cm/cmsupport.py +++ /dev/null @@ -1,108 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'Components.h' # The Apple header file -MODNAME = 'Cm' # The name of the module - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -C_OBJECTPREFIX = 'CmpObj' # The prefix for object methods -CI_OBJECTPREFIX = 'CmpInstObj' -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ - -/* -** Parse/generate ComponentDescriptor records -*/ -PyObject *CmpDesc_New(itself) - ComponentDescription *itself; -{ - - return Py_BuildValue("O&O&O&ll", - PyMac_BuildOSType, itself->componentType, - PyMac_BuildOSType, itself->componentSubType, - PyMac_BuildOSType, itself->componentManufacturer, - itself->componentFlags, itself->componentFlagsMask); -} - -CmpDesc_Convert(v, p_itself) - PyObject *v; - ComponentDescription *p_itself; -{ - return PyArg_ParseTuple(v, "O&O&O&ll", - PyMac_GetOSType, &p_itself->componentType, - PyMac_GetOSType, &p_itself->componentSubType, - PyMac_GetOSType, &p_itself->componentManufacturer, - &p_itself->componentFlags, &p_itself->componentFlagsMask); -} - -""" - -ComponentDescription = OpaqueType('ComponentDescription', 'CmpDesc') -Component = OpaqueByValueType('Component', C_OBJECTPREFIX) -ComponentInstance = OpaqueByValueType('ComponentInstance', CI_OBJECTPREFIX) -ComponentResult = Type("ComponentResult", "l") - -ComponentResourceHandle = OpaqueByValueType("ComponentResourceHandle", "ResObj") - -class MyCIObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Cm_Error,"NULL ComponentInstance"); - return NULL; - }""") - -class MyCObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - /* XXXX Or should we return None? */ - PyErr_SetString(Cm_Error,"No such component"); - return NULL; - }""") - - def outputCheckConvertArg(self): - Output("""if ( v == Py_None ) { - *p_itself = 0; - return 1; - }""") - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -ci_object = MyCIObjectDefinition('ComponentInstance', CI_OBJECTPREFIX, - 'ComponentInstance') -c_object = MyCObjectDefinition('Component', C_OBJECTPREFIX, 'Component') -module.addobject(ci_object) -module.addobject(c_object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -c_methods = [] -ci_methods = [] -execfile(INPUTFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -for f in c_methods: c_object.add(f) -for f in ci_methods: ci_object.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/config.c b/Mac/Modules/config.c deleted file mode 100644 index 0b423ddfc3..0000000000 --- a/Mac/Modules/config.c +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- C -*- *********************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Macintosh Python configuration file */ - -#include "Python.h" -/* Table of built-in modules. - These are initialized when first imported. - Note: selection of optional extensions is now generally done by the - makesetup script. */ - -extern void initarray(); -extern void initmath(); -#ifndef WITHOUT_COMPLEX -extern void initcmath(); -#endif -extern void initparser(); -extern void initmac(); -extern void MacOS_Init(); -extern void initregex(); -extern void initstrop(); -extern void initstruct(); -extern void inittime(); -extern void initdbm(); -extern void initfcntl(); -extern void initnis(); -extern void initpwd(); -extern void initgrp(); -extern void initcrypt(); -extern void initselect(); -extern void initsocket(); -extern void initaudioop(); -extern void initimageop(); -extern void initrgbimg(); -#ifdef USE_STDWIN -extern void initstdwin(); -#endif -extern void initmd5(); -extern void initmpz(); -extern void initrotor(); -extern void inital(); -extern void initcd(); -extern void initcl(); -extern void initfm(); -extern void initgl(); -extern void initimgfile(); -extern void initimgformat(); -extern void initsgi(); -extern void initsv(); -extern void initfl(); -extern void initthread(); -extern void inittiming(); -extern void initsignal(); -extern void initnew(); -extern void initdl(); -extern void initsyslog(); -extern void initgestalt(); -extern void initmacfs(); -extern void initbinascii(); -#ifdef THINK -extern void initmacconsole(); -#endif -#ifdef USE_MACCTB -extern void initctb(); -#endif -#ifdef USE_MACSPEECH -extern void initmacspeech(); -#endif -#ifdef USE_MACTCP -extern void initmacdnr(); -extern void initmactcp(); -#endif -#ifdef USE_TOOLBOX -extern void initAE(); -extern void initCtl(); -extern void initDlg(); -extern void initEvt(); -extern void initFm(); -extern void initList(); -extern void initMenu(); -extern void initQd(); -extern void initRes(); -extern void initSnd(); -extern void initScrap(); -extern void initTE(); -extern void initWin(); -#endif -#ifdef USE_QT -extern void initCm(); -extern void initQt(); -#endif - -#ifdef USE_IMG -extern void initimgcolormap(); -extern void initimgformat(); -extern void initimggif(); -extern void initimgjpeg(); -extern void initimgpbm(); -extern void initimgppm(); -extern void initimgpgm(); -extern void initimgtiff(); -extern void initimgsgi(); -extern void initimgop(); -#endif -#ifdef USE_TK -extern void init_tkinter(); -#endif -#ifdef USE_GUSI -extern void initsocket(); -extern void initselect(); -#endif -#ifdef USE_WASTE -extern void initwaste(); -#endif -/* -- ADDMODULE MARKER 1 -- */ - -extern void PyMarshal_Init(); -extern void initimp(); - -struct _inittab inittab[] = { - - {"array", initarray}, -#ifndef SYMANTEC__CFM68K__ -/* The math library seems mostly broken... */ - {"math", initmath}, -#endif -#ifndef WITHOUT_COMPLEX - {"cmath", initcmath}, -#endif - {"parser", initparser}, - {"mac", initmac}, - {"MacOS", MacOS_Init}, - {"regex", initregex}, - {"strop", initstrop}, - {"struct", initstruct}, - {"time", inittime}, - {"audioop", initaudioop}, - {"imageop", initimageop}, - {"rgbimg", initrgbimg}, -#ifdef USE_STDWIN - {"stdwin", initstdwin}, -#endif - {"md5", initmd5}, - {"rotor", initrotor}, - {"new", initnew}, - {"gestalt", initgestalt}, - {"macfs", initmacfs}, - {"binascii", initbinascii}, -#ifdef THINK_C -/* This is an interface to the Think runtime */ - {"macconsole", initmacconsole}, -#endif -#ifdef USE_MACCTB - {"ctb", initctb}, -#endif -/* This could probably be made to work on other compilers... */ -#ifdef USE_MACSPEECH - {"macspeech", initmacspeech}, -#endif -#ifdef USE_MACTCP - {"macdnr", initmacdnr}, - {"mactcp", initmactcp}, -#endif -#ifdef USE_TOOLBOX - {"AE", initAE}, - {"Ctl", initCtl}, - {"Dlg", initDlg}, - {"Evt", initEvt}, - {"Fm", initFm}, - {"Menu", initMenu}, - {"List", initList}, - {"Qd", initQd}, - {"Snd", initSnd}, - {"Scrap", initScrap}, - {"TE", initTE}, - {"Win", initWin}, - {"Res", initRes}, -#endif -#ifdef USE_QT - {"Cm", initCm}, - {"Qt", initQt}, -#endif -#ifdef USE_IMG - {"imgcolormap", initimgcolormap}, - {"imgformat", initimgformat}, - {"imggif", initimggif}, - {"imgjpeg", initimgjpeg}, - {"imgpbm", initimgpbm}, - {"imgppm", initimgppm}, - {"imgpgm", initimgpgm}, - {"imgtiff", initimgtiff}, - {"imgsgi", initimgsgi}, - {"imgop", initimgop}, -#endif -#ifdef USE_TK - {"_tkinter", init_tkinter}, -#endif -#ifdef USE_GUSI - {"socket", initsocket}, - {"select", initselect}, -#endif -#ifdef USE_WASTE - {"waste", initwaste}, -#endif - -/* -- ADDMODULE MARKER 2 -- */ - - /* This module "lives in" with marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This module "lives in" with import.c */ - {"imp", initimp}, - - /* These entries are here for sys.builtin_module_names */ - {"__main__", NULL}, - {"__builtin__", NULL}, - {"sys", NULL}, - - /* Sentinel */ - {0, 0} -}; - diff --git a/Mac/Modules/ctbmodule.c b/Mac/Modules/ctbmodule.c deleted file mode 100644 index ef03f9227f..0000000000 --- a/Mac/Modules/ctbmodule.c +++ /dev/null @@ -1,585 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Note: This file is partially converted to the new naming standard */ -/* ctbcm objects */ - - -#include "allobjects.h" - -#include "macglue.h" - -#include -#include -#include -#include - -#ifndef HAVE_UNIVERSAL_HEADERS -#define ConnectionCompletionUPP ProcPtr -#define ConnectionChooseIdleUPP ProcPtr -#define NewConnectionCompletionProc(x) (x) -#define NewConnectionChooseIdleProc(x) (x) -#endif - -#define _UnimplementedToolTrap 0xA89F -#define _CommToolboxTrap 0x8B -#define _UnimplementedOSTrap 0x9F - -extern object *PyErr_Mac(object *,int); - -static object *ErrorObject; - -typedef struct { - OB_HEAD - ConnHandle hdl; /* The handle to the connection */ - object *callback; /* Python callback routine */ - int has_callback; /* True if callback not None */ - int err; /* Error to pass to the callback */ -} ctbcmobject; - -staticforward typeobject ctbcmtype; - -#define is_ctbcmobject(v) ((v)->ob_type == &ctbcmtype) - -static -TrapAvailable(short tNumber, TrapType tType) -{ - short unImplemented; - - if (tType == OSTrap) - unImplemented = _UnimplementedOSTrap; - else - unImplemented = _UnimplementedToolTrap; - - return NGetTrapAddress(tNumber, tType) != NGetTrapAddress(unImplemented, tType); -} - -static -initialize_ctb() -{ - OSErr err; - static initialized = -1; - - if ( initialized >= 0 ) - return initialized; - initialized = 0; - - if ( !TrapAvailable(_CommToolboxTrap, OSTrap) ) { - err_setstr(ErrorObject, "CTB not available"); - return 0; - } - if ( (err=InitCTBUtilities()) ) { - PyErr_Mac(ErrorObject, (int)err); - return 0; - } - if ( (err=InitCRM()) ) { - PyErr_Mac(ErrorObject, (int)err); - return 0; - } - if ( (err=InitCM()) ) { - PyErr_Mac(ErrorObject, (int)err); - return 0; - } - initialized = 1; - return 1; -} - -static int -ctbcm_pycallback(arg) - void *arg; -{ - ctbcmobject *self = (ctbcmobject *)arg; - object *args, *rv; - - if ( !self->has_callback ) /* It could have been removed in the meantime */ - return 0; - args = mkvalue("(i)", self->err); - rv = call_object(self->callback, args); - DECREF(args); - if( rv == NULL ) - return -1; - DECREF(rv); - return 0; -} - -/*DBG*/int ncallback; -static pascal void -ctbcm_ctbcallback(hconn) - ConnHandle hconn; -{ - ctbcmobject *self; - - /* XXXX Do I have to do the A5 mumbo-jumbo? */ - ncallback++; /*DBG*/ - self = (ctbcmobject *)CMGetUserData(hconn); - self->err = (int)((*hconn)->errCode); - Py_AddPendingCall(ctbcm_pycallback, (void *)self); -} - -static ctbcmobject * -newctbcmobject(arg) - object *arg; -{ - ctbcmobject *self; - self = NEWOBJ(ctbcmobject, &ctbcmtype); - if (self == NULL) - return NULL; - self->hdl = NULL; - INCREF(None); - self->callback = None; - self->has_callback = 0; - return self; -} - -/* ctbcm methods */ - -static void -ctbcm_dealloc(self) - ctbcmobject *self; -{ - if ( self->hdl ) { - (void)CMClose(self->hdl, 0, (ConnectionCompletionUPP)0, 0, 1); - /*XXXX Is this safe? */ - CMDispose(self->hdl); - self->hdl = NULL; - } - DEL(self); -} - -static object * -ctbcm_open(self, args) - ctbcmobject *self; - object *args; -{ - long timeout; - OSErr err; - ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); - - if (!getargs(args, "l", &timeout)) - return NULL; - if ( (err=CMOpen(self->hdl, self->has_callback, cb_upp, timeout)) < 0) - return PyErr_Mac(ErrorObject, (int)err); - INCREF(None); - return None; -} - -static object * -ctbcm_listen(self, args) - ctbcmobject *self; - object *args; -{ - long timeout; - OSErr err; - ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); - - if (!getargs(args, "l", &timeout)) - return NULL; - if ( (err=CMListen(self->hdl,self->has_callback, cb_upp, timeout)) < 0) - return PyErr_Mac(ErrorObject, (int)err); - INCREF(None); - return None; -} - -static object * -ctbcm_accept(self, args) - ctbcmobject *self; - object *args; -{ - int accept; - OSErr err; - - if (!getargs(args, "i", &accept)) - return NULL; - if ( (err=CMAccept(self->hdl, accept)) < 0) - return PyErr_Mac(ErrorObject, (int)err); - INCREF(None); - return None; -} - -static object * -ctbcm_close(self, args) - ctbcmobject *self; - object *args; -{ - int now; - long timeout; - OSErr err; - ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); - - if (!getargs(args, "(li)", &timeout, &now)) - return NULL; - if ( (err=CMClose(self->hdl, self->has_callback, cb_upp, timeout, now)) < 0) - return PyErr_Mac(ErrorObject, (int)err); - INCREF(None); - return None; -} - -static object * -ctbcm_read(self, args) - ctbcmobject *self; - object *args; -{ - long timeout, len; - int chan; - CMFlags flags; - OSErr err; - object *rv; - ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); - - if (!getargs(args, "(lil)", &len, &chan, &timeout)) - return NULL; - if ((rv=newsizedstringobject(NULL, len)) == NULL) - return NULL; - if ((err=CMRead(self->hdl, (Ptr)getstringvalue(rv), &len, (CMChannel)chan, - self->has_callback, cb_upp, timeout, &flags)) < 0) - return PyErr_Mac(ErrorObject, (int)err); - resizestring(&rv, len); - return mkvalue("(Oi)", rv, (int)flags); -} - -static object * -ctbcm_write(self, args) - ctbcmobject *self; - object *args; -{ - long timeout, len; - int chan, ilen, flags; - OSErr err; - char *buf; - ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); - - if (!getargs(args, "(s#ili)", &buf, &ilen, &chan, &timeout, &flags)) - return NULL; - len = ilen; - if ((err=CMWrite(self->hdl, (Ptr)buf, &len, (CMChannel)chan, - self->has_callback, cb_upp, timeout, (CMFlags)flags)) < 0) - return PyErr_Mac(ErrorObject, (int)err); - return newintobject((int)len); -} - -static object * -ctbcm_status(self, args) - ctbcmobject *self; - object *args; -{ - CMBufferSizes sizes; - CMStatFlags flags; - OSErr err; - object *rv; - - if (!getnoarg(args)) - return NULL; - if ((err=CMStatus(self->hdl, sizes, &flags)) < 0) - return PyErr_Mac(ErrorObject, (int)err); - rv = mkvalue("(llllll)", sizes[0], sizes[1], sizes[2], sizes[3], sizes[4], sizes[5]); - if ( rv == NULL ) - return NULL; - return mkvalue("(Ol)", rv, (long)flags); -} - -static object * -ctbcm_getconfig(self, args) - ctbcmobject *self; - object *args; -{ - char *rv; - - if (!getnoarg(args)) - return NULL; - if ((rv=(char *)CMGetConfig(self->hdl)) == NULL ) { - err_setstr(ErrorObject, "CMGetConfig failed"); - return NULL; - } - return newstringobject(rv); -} - -static object * -ctbcm_setconfig(self, args) - ctbcmobject *self; - object *args; -{ - char *cfg; - OSErr err; - - if (!getargs(args, "s", &cfg)) - return NULL; - if ((err=CMSetConfig(self->hdl, (Ptr)cfg)) < 0) - return PyErr_Mac(ErrorObject, err); - return newintobject((int)err); -} - -static object * -ctbcm_choose(self, args) - ctbcmobject *self; - object *args; -{ - int rv; - Point pt; - - if (!getnoarg(args)) - return NULL; - pt.v = 40; - pt.h = 40; - rv=CMChoose(&self->hdl, pt, (ConnectionChooseIdleUPP)0); - return newintobject(rv); -} - -static object * -ctbcm_idle(self, args) - ctbcmobject *self; - object *args; -{ - if (!getnoarg(args)) - return NULL; - CMIdle(self->hdl); - INCREF(None); - return None; -} - -static object * -ctbcm_abort(self, args) - ctbcmobject *self; - object *args; -{ - if (!getnoarg(args)) - return NULL; - CMAbort(self->hdl); - INCREF(None); - return None; -} - -static object * -ctbcm_reset(self, args) - ctbcmobject *self; - object *args; -{ - if (!getnoarg(args)) - return NULL; - CMReset(self->hdl); - INCREF(None); - return None; -} - -static object * -ctbcm_break(self, args) - ctbcmobject *self; - object *args; -{ - long duration; - ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); - - if (!getargs(args, "l", &duration)) - return NULL; - CMBreak(self->hdl, duration,self->has_callback, cb_upp); - INCREF(None); - return None; -} - -static struct methodlist ctbcm_methods[] = { - {"Open", (method)ctbcm_open}, - {"Close", (method)ctbcm_close}, - {"Read", (method)ctbcm_read}, - {"Write", (method)ctbcm_write}, - {"Status", (method)ctbcm_status}, - {"GetConfig", (method)ctbcm_getconfig}, - {"SetConfig", (method)ctbcm_setconfig}, - {"Choose", (method)ctbcm_choose}, - {"Idle", (method)ctbcm_idle}, - {"Listen", (method)ctbcm_listen}, - {"Accept", (method)ctbcm_accept}, - {"Abort", (method)ctbcm_abort}, - {"Reset", (method)ctbcm_reset}, - {"Break", (method)ctbcm_break}, - {NULL, NULL} /* sentinel */ -}; - -static object * -ctbcm_getattr(self, name) - ctbcmobject *self; - char *name; -{ - if ( strcmp(name, "callback") == 0 ) { - INCREF(self->callback); - return self->callback; - } - return findmethod(ctbcm_methods, (object *)self, name); -} - -static int -ctbcm_setattr(self, name, v) - ctbcmobject *self; - char *name; - object *v; -{ - if ( strcmp(name, "callback") != 0 ) { - err_setstr(AttributeError, "ctbcm objects have callback attr only"); - return -1; - } - if ( v == NULL ) { - v = None; - } - INCREF(v); /* XXXX Must I do this? */ - self->callback = v; - self->has_callback = (v != None); - return 0; -} - -statichere typeobject ctbcmtype = { - OB_HEAD_INIT(&Typetype) - 0, /*ob_size*/ - "ctbcm", /*tp_name*/ - sizeof(ctbcmobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)ctbcm_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)ctbcm_getattr, /*tp_getattr*/ - (setattrfunc)ctbcm_setattr, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; -/* --------------------------------------------------------------------- */ - -/* Function of no arguments returning new ctbcm object */ - -static object * -ctb_cmnew(self, args) - object *self; /* Not used */ - object *args; -{ - int strlen; - object *sizes_obj; - char *c_str; - unsigned char p_str[255]; - CMBufferSizes sizes; - short procid; - ConnHandle hdl; - ctbcmobject *rv; - - if (!getargs(args, "(s#O)", &c_str, &strlen, &sizes_obj)) - return NULL; - strncpy((char *)p_str+1, c_str, strlen); - p_str[0] = strlen; - if (!initialize_ctb()) - return NULL; - if ( sizes_obj == None ) { - memset(sizes, '\0', sizeof sizes); - } else { - if ( !getargs(sizes_obj, "(llllll)", &sizes[0], &sizes[1], &sizes[2], - &sizes[3], &sizes[4], &sizes[5])) - return NULL; - } - if ( (procid=CMGetProcID(p_str)) < 0 ) - return PyErr_Mac(ErrorObject, procid); - hdl = CMNew(procid, cmNoMenus|cmQuiet, sizes, 0, 0); - if ( hdl == NULL ) { - err_setstr(ErrorObject, "CMNew failed"); - return NULL; - } - rv = newctbcmobject(args); - if ( rv == NULL ) - return NULL; /* XXXX Should dispose of hdl */ - rv->hdl = hdl; - CMSetUserData(hdl, (long)rv); - return (object *)rv; -} - -static object * -ctb_available(self, args) - object *self; - object *args; -{ - int ok; - - if (!getnoarg(args)) - return NULL; - ok = initialize_ctb(); - err_clear(); - return newintobject(ok); -} - -/* List of functions defined in the module */ - -static struct methodlist ctb_methods[] = { - {"CMNew", ctb_cmnew}, - {"available", ctb_available}, - {NULL, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called initctb) */ - -void -initctb() -{ - object *m, *d, *o; - - /* Create the module and add the functions */ - m = initmodule("ctb", ctb_methods); - - /* Add some symbolic constants to the module */ - d = getmoduledict(m); - -#define CMCONST(name, value) o = newintobject(value); dictinsert(d, name, o) - - CMCONST("cmData", 1); - CMCONST("cmCntl", 2); - CMCONST("cmAttn", 3); - - CMCONST("cmFlagsEOM", 1); - - CMCONST("chooseDisaster", -2); - CMCONST("chooseFailed", -1); - CMCONST("chooseAborted", 0); - CMCONST("chooseOKMinor", 1); - CMCONST("chooseOKMajor", 2); - CMCONST("chooseCancel", 3); - - CMCONST("cmStatusOpening", 1); - CMCONST("cmStatusOpen", 2); - CMCONST("cmStatusClosing", 4); - CMCONST("cmStatusDataAvail", 8); - CMCONST("cmStatusCntlAvail", 0x10); - CMCONST("cmStatusAttnAvail", 0x20); - CMCONST("cmStatusDRPend", 0x40); - CMCONST("cmStatusDWPend", 0x80); - CMCONST("cmStatusCWPend", 0x100); - CMCONST("cmStatusCWPend", 0x200); - CMCONST("cmStatusARPend", 0x400); - CMCONST("cmStatusAWPend", 0x800); - CMCONST("cmStatusBreakPending", 0x1000); - CMCONST("cmStatusListenPend", 0x2000); - CMCONST("cmStatusIncomingCallPresent", 0x4000); - - ErrorObject = newstringobject("ctb.error"); - dictinsert(d, "error", ErrorObject); - - /* Check for errors */ - if (err_occurred()) - fatal("can't initialize module ctb"); -} diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c deleted file mode 100644 index 629d3fb382..0000000000 --- a/Mac/Modules/ctl/Ctlmodule.c +++ /dev/null @@ -1,713 +0,0 @@ - -/* =========================== Module Ctl =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */ - -#ifdef THINK_C -#define ControlActionUPP ProcPtr -#endif - -static PyObject *Ctl_Error; - -/* ---------------------- Object type Control ----------------------- */ - -PyTypeObject Control_Type; - -#define CtlObj_Check(x) ((x)->ob_type == &Control_Type) - -typedef struct ControlObject { - PyObject_HEAD - ControlHandle ob_itself; -} ControlObject; - -PyObject *CtlObj_New(itself) - ControlHandle itself; -{ - ControlObject *it; - if (itself == NULL) return PyMac_Error(resNotFound); - it = PyObject_NEW(ControlObject, &Control_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - SetCRefCon(itself, (long)it); - return (PyObject *)it; -} -CtlObj_Convert(v, p_itself) - PyObject *v; - ControlHandle *p_itself; -{ - if (!CtlObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Control required"); - return 0; - } - *p_itself = ((ControlObject *)v)->ob_itself; - return 1; -} - -static void CtlObj_dealloc(self) - ControlObject *self; -{ - SetCRefCon(self->ob_itself, (long)0); /* Make it forget about us */ - PyMem_DEL(self); -} - -static PyObject *CtlObj_DisposeControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DisposeControl(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_ShowControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ShowControl(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_HideControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HideControl(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_Draw1Control(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - Draw1Control(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_HiliteControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ControlPartCode hiliteState; - if (!PyArg_ParseTuple(_args, "h", - &hiliteState)) - return NULL; - HiliteControl(_self->ob_itself, - hiliteState); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_TrackControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ControlPartCode _rv; - Point thePoint; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &thePoint)) - return NULL; - _rv = TrackControl(_self->ob_itself, - thePoint, - (ControlActionUPP)0); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *CtlObj_DragControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point startPoint; - Rect limitRect; - Rect slopRect; - DragConstraint axis; - if (!PyArg_ParseTuple(_args, "O&O&O&h", - PyMac_GetPoint, &startPoint, - PyMac_GetRect, &limitRect, - PyMac_GetRect, &slopRect, - &axis)) - return NULL; - DragControl(_self->ob_itself, - startPoint, - &limitRect, - &slopRect, - axis); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_TestControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ControlPartCode _rv; - Point thePoint; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &thePoint)) - return NULL; - _rv = TestControl(_self->ob_itself, - thePoint); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *CtlObj_MoveControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 h; - SInt16 v; - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - MoveControl(_self->ob_itself, - h, - v); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_SizeControl(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 w; - SInt16 h; - if (!PyArg_ParseTuple(_args, "hh", - &w, - &h)) - return NULL; - SizeControl(_self->ob_itself, - w, - h); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_SetControlTitle(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 title; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, title)) - return NULL; - SetControlTitle(_self->ob_itself, - title); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_GetControlTitle(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 title; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, title)) - return NULL; - GetControlTitle(_self->ob_itself, - title); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_GetControlValue(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetControlValue(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *CtlObj_SetControlValue(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 newValue; - if (!PyArg_ParseTuple(_args, "h", - &newValue)) - return NULL; - SetControlValue(_self->ob_itself, - newValue); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_GetControlMinimum(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetControlMinimum(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *CtlObj_SetControlMinimum(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 newMinimum; - if (!PyArg_ParseTuple(_args, "h", - &newMinimum)) - return NULL; - SetControlMinimum(_self->ob_itself, - newMinimum); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_GetControlMaximum(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetControlMaximum(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *CtlObj_SetControlMaximum(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 newMaximum; - if (!PyArg_ParseTuple(_args, "h", - &newMaximum)) - return NULL; - SetControlMaximum(_self->ob_itself, - newMaximum); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_GetControlVariant(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetControlVariant(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *CtlObj_SetControlAction(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - SetControlAction(_self->ob_itself, - (ControlActionUPP)0); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_SetControlReference(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 data; - if (!PyArg_ParseTuple(_args, "l", - &data)) - return NULL; - SetControlReference(_self->ob_itself, - data); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *CtlObj_GetControlReference(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetControlReference(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *CtlObj_as_Resource(_self, _args) - ControlObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - return ResObj_New((Handle)_self->ob_itself); - -} - -static PyMethodDef CtlObj_methods[] = { - {"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1, - "() -> None"}, - {"ShowControl", (PyCFunction)CtlObj_ShowControl, 1, - "() -> None"}, - {"HideControl", (PyCFunction)CtlObj_HideControl, 1, - "() -> None"}, - {"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1, - "() -> None"}, - {"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1, - "(ControlPartCode hiliteState) -> None"}, - {"TrackControl", (PyCFunction)CtlObj_TrackControl, 1, - "(Point thePoint) -> (ControlPartCode _rv)"}, - {"DragControl", (PyCFunction)CtlObj_DragControl, 1, - "(Point startPoint, Rect limitRect, Rect slopRect, DragConstraint axis) -> None"}, - {"TestControl", (PyCFunction)CtlObj_TestControl, 1, - "(Point thePoint) -> (ControlPartCode _rv)"}, - {"MoveControl", (PyCFunction)CtlObj_MoveControl, 1, - "(SInt16 h, SInt16 v) -> None"}, - {"SizeControl", (PyCFunction)CtlObj_SizeControl, 1, - "(SInt16 w, SInt16 h) -> None"}, - {"SetControlTitle", (PyCFunction)CtlObj_SetControlTitle, 1, - "(Str255 title) -> None"}, - {"GetControlTitle", (PyCFunction)CtlObj_GetControlTitle, 1, - "(Str255 title) -> None"}, - {"GetControlValue", (PyCFunction)CtlObj_GetControlValue, 1, - "() -> (SInt16 _rv)"}, - {"SetControlValue", (PyCFunction)CtlObj_SetControlValue, 1, - "(SInt16 newValue) -> None"}, - {"GetControlMinimum", (PyCFunction)CtlObj_GetControlMinimum, 1, - "() -> (SInt16 _rv)"}, - {"SetControlMinimum", (PyCFunction)CtlObj_SetControlMinimum, 1, - "(SInt16 newMinimum) -> None"}, - {"GetControlMaximum", (PyCFunction)CtlObj_GetControlMaximum, 1, - "() -> (SInt16 _rv)"}, - {"SetControlMaximum", (PyCFunction)CtlObj_SetControlMaximum, 1, - "(SInt16 newMaximum) -> None"}, - {"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1, - "() -> (SInt16 _rv)"}, - {"SetControlAction", (PyCFunction)CtlObj_SetControlAction, 1, - "() -> None"}, - {"SetControlReference", (PyCFunction)CtlObj_SetControlReference, 1, - "(SInt32 data) -> None"}, - {"GetControlReference", (PyCFunction)CtlObj_GetControlReference, 1, - "() -> (SInt32 _rv)"}, - {"as_Resource", (PyCFunction)CtlObj_as_Resource, 1, - "Return this Control as a Resource"}, - {NULL, NULL, 0} -}; - -PyMethodChain CtlObj_chain = { CtlObj_methods, NULL }; - -static PyObject *CtlObj_getattr(self, name) - ControlObject *self; - char *name; -{ - return Py_FindMethodInChain(&CtlObj_chain, (PyObject *)self, name); -} - -#define CtlObj_setattr NULL - -PyTypeObject Control_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Control", /*tp_name*/ - sizeof(ControlObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) CtlObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) CtlObj_getattr, /*tp_getattr*/ - (setattrfunc) CtlObj_setattr, /*tp_setattr*/ -}; - -/* -------------------- End object type Control --------------------- */ - - -static PyObject *Ctl_NewControl(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ControlHandle _rv; - WindowPtr theWindow; - Rect boundsRect; - Str255 title; - Boolean visible; - SInt16 value; - SInt16 min; - SInt16 max; - SInt16 procID; - SInt32 refCon; - if (!PyArg_ParseTuple(_args, "O&O&O&bhhhhl", - WinObj_Convert, &theWindow, - PyMac_GetRect, &boundsRect, - PyMac_GetStr255, title, - &visible, - &value, - &min, - &max, - &procID, - &refCon)) - return NULL; - _rv = NewControl(theWindow, - &boundsRect, - title, - visible, - value, - min, - max, - procID, - refCon); - _res = Py_BuildValue("O&", - CtlObj_New, _rv); - return _res; -} - -static PyObject *Ctl_GetNewControl(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ControlHandle _rv; - SInt16 controlID; - WindowPtr owner; - if (!PyArg_ParseTuple(_args, "hO&", - &controlID, - WinObj_Convert, &owner)) - return NULL; - _rv = GetNewControl(controlID, - owner); - _res = Py_BuildValue("O&", - CtlObj_New, _rv); - return _res; -} - -static PyObject *Ctl_KillControls(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr theWindow; - if (!PyArg_ParseTuple(_args, "O&", - WinObj_Convert, &theWindow)) - return NULL; - KillControls(theWindow); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Ctl_DrawControls(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr theWindow; - if (!PyArg_ParseTuple(_args, "O&", - WinObj_Convert, &theWindow)) - return NULL; - DrawControls(theWindow); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Ctl_UpdateControls(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr theWindow; - RgnHandle updateRegion; - if (!PyArg_ParseTuple(_args, "O&O&", - WinObj_Convert, &theWindow, - ResObj_Convert, &updateRegion)) - return NULL; - UpdateControls(theWindow, - updateRegion); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Ctl_FindControl(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ControlPartCode _rv; - Point thePoint; - WindowPtr theWindow; - ControlHandle theControl; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &thePoint, - WinObj_Convert, &theWindow)) - return NULL; - _rv = FindControl(thePoint, - theWindow, - &theControl); - _res = Py_BuildValue("hO&", - _rv, - CtlObj_WhichControl, theControl); - return _res; -} - -static PyMethodDef Ctl_methods[] = { - {"NewControl", (PyCFunction)Ctl_NewControl, 1, - "(WindowPtr theWindow, Rect boundsRect, Str255 title, Boolean visible, SInt16 value, SInt16 min, SInt16 max, SInt16 procID, SInt32 refCon) -> (ControlHandle _rv)"}, - {"GetNewControl", (PyCFunction)Ctl_GetNewControl, 1, - "(SInt16 controlID, WindowPtr owner) -> (ControlHandle _rv)"}, - {"KillControls", (PyCFunction)Ctl_KillControls, 1, - "(WindowPtr theWindow) -> None"}, - {"DrawControls", (PyCFunction)Ctl_DrawControls, 1, - "(WindowPtr theWindow) -> None"}, - {"UpdateControls", (PyCFunction)Ctl_UpdateControls, 1, - "(WindowPtr theWindow, RgnHandle updateRegion) -> None"}, - {"FindControl", (PyCFunction)Ctl_FindControl, 1, - "(Point thePoint, WindowPtr theWindow) -> (ControlPartCode _rv, ControlHandle theControl)"}, - {NULL, NULL, 0} -}; - - - -PyObject * -CtlObj_WhichControl(ControlHandle c) -{ - PyObject *it; - - /* XXX What if we find a control belonging to some other package? */ - if (c == NULL) - it = NULL; - else - it = (PyObject *) GetCRefCon(c); - if (it == NULL || ((ControlObject *)it)->ob_itself != c) - it = Py_None; - Py_INCREF(it); - return it; -} - - -void initCtl() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Ctl", Ctl_methods); - d = PyModule_GetDict(m); - Ctl_Error = PyMac_GetOSErrException(); - if (Ctl_Error == NULL || - PyDict_SetItemString(d, "Error", Ctl_Error) != 0) - Py_FatalError("can't initialize Ctl.Error"); -} - -/* ========================= End module Ctl ========================= */ - diff --git a/Mac/Modules/ctl/ctledit.py b/Mac/Modules/ctl/ctledit.py deleted file mode 100644 index d8770122d8..0000000000 --- a/Mac/Modules/ctl/ctledit.py +++ /dev/null @@ -1,8 +0,0 @@ -as_resource_body = """ -return ResObj_New((Handle)_self->ob_itself); -""" - -f = ManualGenerator("as_Resource", as_resource_body) -f.docstring = lambda : "Return this Control as a Resource" - -methods.append(f) diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py deleted file mode 100644 index 661cbfebc2..0000000000 --- a/Mac/Modules/ctl/ctlscan.py +++ /dev/null @@ -1,68 +0,0 @@ -# Scan , generating ctlgen.py. -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -def main(): - input = "Controls.h" - output = "ctlgen.py" - defsoutput = TOOLBOXDIR + "Controls.py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now doing 'import ctlsupport' ===" - import ctlsupport - print "=== Done. It's up to you to compile Ctlmodule.c ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t in ("ControlHandle", "ControlRef") and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - 'DisposeControl' # Implied by deletion of control object - 'KillControls', # Implied by close of dialog - 'SetCtlAction', - ] - - def makeblacklisttypes(self): - return [ - 'ProcPtr', - 'ControlActionUPP', - 'CCTabHandle', - 'AuxCtlHandle', - ] - - def makerepairinstructions(self): - return [ - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode"), - ("long", "*", "OutMode")], - [("VarVarOutBuffer", "*", "InOutMode")]), - - # For TrackControl - ([("ProcPtr", "actionProc", "InMode")], - [("FakeType('(ControlActionUPP)0')", "*", "*")]), - ([("ControlActionUPP", "actionProc", "InMode")], - [("FakeType('(ControlActionUPP)0')", "*", "*")]), - - ([("ControlHandle", "*", "OutMode")], - [("ExistingControlHandle", "*", "*")]), - ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers - [("ExistingControlHandle", "*", "*")]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py deleted file mode 100644 index cef9f8a40b..0000000000 --- a/Mac/Modules/ctl/ctlsupport.py +++ /dev/null @@ -1,95 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -# Declarations that change for each manager -MACHEADERFILE = 'Controls.h' # The Apple header file -MODNAME = 'Ctl' # The name of the module -OBJECTNAME = 'Control' # The basic name of the objects used here - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -ControlHandle = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) -ControlRef = ControlHandle -ExistingControlHandle = OpaqueByValueType(OBJECTTYPE, "CtlObj_WhichControl", "BUG") - -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") -ControlPartCode = Type("ControlPartCode", "h") -DragConstraint = Type("DragConstraint", "h") - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */ - -#ifdef THINK_C -#define ControlActionUPP ProcPtr -#endif -""" - -finalstuff = finalstuff + """ -PyObject * -CtlObj_WhichControl(ControlHandle c) -{ - PyObject *it; - - /* XXX What if we find a control belonging to some other package? */ - if (c == NULL) - it = NULL; - else - it = (PyObject *) GetCRefCon(c); - if (it == NULL || ((ControlObject *)it)->ob_itself != c) - it = Py_None; - Py_INCREF(it); - return it; -} -""" - -class MyObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("if (itself == NULL) return PyMac_Error(resNotFound);") - def outputInitStructMembers(self): - GlobalObjectDefinition.outputInitStructMembers(self) - Output("SetCRefCon(itself, (long)it);") - def outputCleanupStructMembers(self): - Output("SetCRefCon(self->ob_itself, (long)0); /* Make it forget about us */") - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile(INPUTFILE) -execfile('ctledit.py') - -# add the populated lists to the generator groups -for f in functions: module.add(f) -for f in methods: object.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() diff --git a/Mac/Modules/dlg/Dlgmodule.c b/Mac/Modules/dlg/Dlgmodule.c deleted file mode 100644 index c0297f307b..0000000000 --- a/Mac/Modules/dlg/Dlgmodule.c +++ /dev/null @@ -1,935 +0,0 @@ - -/* =========================== Module Dlg =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -#ifndef HAVE_UNIVERSAL_HEADERS -#define NewModalFilterProc(x) (x) -#endif - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -/* XXX Shouldn't this be a stack? */ -static PyObject *Dlg_FilterProc_callback = NULL; - -static PyObject *DlgObj_New(DialogPtr); /* Forward */ - -static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog, - EventRecord *event, - short *itemHit) -{ - Boolean rv; - PyObject *args, *res; - PyObject *callback = Dlg_FilterProc_callback; - if (callback == NULL) - return 0; /* Default behavior */ - Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ - args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event); - if (args == NULL) - res = NULL; - else { - res = PyEval_CallObject(callback, args); - Py_DECREF(args); - } - if (res == NULL) { - fprintf(stderr, "Exception in Dialog Filter\n"); - PyErr_Print(); - *itemHit = -1; /* Fake return item */ - return 1; /* We handled it */ - } - else { - Dlg_FilterProc_callback = callback; - if (PyInt_Check(res)) { - *itemHit = PyInt_AsLong(res); - rv = 1; - } - else - rv = PyObject_IsTrue(res); - } - Py_DECREF(res); - return rv; -} - -static ModalFilterProcPtr -Dlg_PassFilterProc(PyObject *callback) -{ - PyObject *tmp = Dlg_FilterProc_callback; - Dlg_FilterProc_callback = NULL; - if (callback == Py_None) { - Py_XDECREF(tmp); - return NULL; - } - Py_INCREF(callback); - Dlg_FilterProc_callback = callback; - Py_XDECREF(tmp); - return &Dlg_UnivFilterProc; -} - -extern PyMethodChain WinObj_chain; - -static PyObject *Dlg_Error; - -/* ----------------------- Object type Dialog ----------------------- */ - -PyTypeObject Dialog_Type; - -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -typedef struct DialogObject { - PyObject_HEAD - DialogPtr ob_itself; -} DialogObject; - -PyObject *DlgObj_New(itself) - DialogPtr itself; -{ - DialogObject *it; - if (itself == NULL) return Py_None; - it = PyObject_NEW(DialogObject, &Dialog_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - SetWRefCon(itself, (long)it); - return (PyObject *)it; -} -DlgObj_Convert(v, p_itself) - PyObject *v; - DialogPtr *p_itself; -{ - if (v == Py_None) { *p_itself = NULL; return 1; } - if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v); - return 1; } - if (!DlgObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Dialog required"); - return 0; - } - *p_itself = ((DialogObject *)v)->ob_itself; - return 1; -} - -static void DlgObj_dealloc(self) - DialogObject *self; -{ - DisposeDialog(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *DlgObj_DrawDialog(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DrawDialog(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_UpdateDialog(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle updateRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &updateRgn)) - return NULL; - UpdateDialog(_self->ob_itself, - updateRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_GetDialogItem(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short itemNo; - short itemType; - Handle item; - Rect box; - if (!PyArg_ParseTuple(_args, "h", - &itemNo)) - return NULL; - GetDialogItem(_self->ob_itself, - itemNo, - &itemType, - &item, - &box); - _res = Py_BuildValue("hO&O&", - itemType, - OptResObj_New, item, - PyMac_BuildRect, &box); - return _res; -} - -static PyObject *DlgObj_SetDialogItem(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short itemNo; - short itemType; - Handle item; - Rect box; - if (!PyArg_ParseTuple(_args, "hhO&O&", - &itemNo, - &itemType, - ResObj_Convert, &item, - PyMac_GetRect, &box)) - return NULL; - SetDialogItem(_self->ob_itself, - itemNo, - itemType, - item, - &box); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_HideDialogItem(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short itemNo; - if (!PyArg_ParseTuple(_args, "h", - &itemNo)) - return NULL; - HideDialogItem(_self->ob_itself, - itemNo); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_ShowDialogItem(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short itemNo; - if (!PyArg_ParseTuple(_args, "h", - &itemNo)) - return NULL; - ShowDialogItem(_self->ob_itself, - itemNo); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_SelectDialogItemText(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short itemNo; - short strtSel; - short endSel; - if (!PyArg_ParseTuple(_args, "hhh", - &itemNo, - &strtSel, - &endSel)) - return NULL; - SelectDialogItemText(_self->ob_itself, - itemNo, - strtSel, - endSel); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_FindDialogItem(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - Point thePt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &thePt)) - return NULL; - _rv = FindDialogItem(_self->ob_itself, - thePt); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *DlgObj_DialogCut(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DialogCut(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_DialogPaste(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DialogPaste(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_DialogCopy(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DialogCopy(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_DialogDelete(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DialogDelete(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_AppendDITL(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle theHandle; - DITLMethod method; - if (!PyArg_ParseTuple(_args, "O&h", - ResObj_Convert, &theHandle, - &method)) - return NULL; - AppendDITL(_self->ob_itself, - theHandle, - method); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_CountDITL(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CountDITL(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *DlgObj_ShortenDITL(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short numberItems; - if (!PyArg_ParseTuple(_args, "h", - &numberItems)) - return NULL; - ShortenDITL(_self->ob_itself, - numberItems); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_StdFilterProc(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventRecord event; - short itemHit; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = StdFilterProc(_self->ob_itself, - &event, - &itemHit); - _res = Py_BuildValue("bO&h", - _rv, - PyMac_BuildEventRecord, &event, - itemHit); - return _res; -} - -static PyObject *DlgObj_SetDialogDefaultItem(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short newItem; - if (!PyArg_ParseTuple(_args, "h", - &newItem)) - return NULL; - _err = SetDialogDefaultItem(_self->ob_itself, - newItem); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_SetDialogCancelItem(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short newItem; - if (!PyArg_ParseTuple(_args, "h", - &newItem)) - return NULL; - _err = SetDialogCancelItem(_self->ob_itself, - newItem); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *DlgObj_SetDialogTracksCursor(_self, _args) - DialogObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Boolean tracks; - if (!PyArg_ParseTuple(_args, "b", - &tracks)) - return NULL; - _err = SetDialogTracksCursor(_self->ob_itself, - tracks); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef DlgObj_methods[] = { - {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1, - "() -> None"}, - {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1, - "(RgnHandle updateRgn) -> None"}, - {"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1, - "(short itemNo) -> (short itemType, Handle item, Rect box)"}, - {"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1, - "(short itemNo, short itemType, Handle item, Rect box) -> None"}, - {"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1, - "(short itemNo) -> None"}, - {"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 1, - "(short itemNo) -> None"}, - {"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1, - "(short itemNo, short strtSel, short endSel) -> None"}, - {"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1, - "(Point thePt) -> (short _rv)"}, - {"DialogCut", (PyCFunction)DlgObj_DialogCut, 1, - "() -> None"}, - {"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 1, - "() -> None"}, - {"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 1, - "() -> None"}, - {"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1, - "() -> None"}, - {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1, - "(Handle theHandle, DITLMethod method) -> None"}, - {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1, - "() -> (short _rv)"}, - {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1, - "(short numberItems) -> None"}, - {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1, - "() -> (Boolean _rv, EventRecord event, short itemHit)"}, - {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1, - "(short newItem) -> None"}, - {"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1, - "(short newItem) -> None"}, - {"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1, - "(Boolean tracks) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain DlgObj_chain = { DlgObj_methods, &WinObj_chain }; - -static PyObject *DlgObj_getattr(self, name) - DialogObject *self; - char *name; -{ - return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name); -} - -#define DlgObj_setattr NULL - -PyTypeObject Dialog_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Dialog", /*tp_name*/ - sizeof(DialogObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) DlgObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) DlgObj_getattr, /*tp_getattr*/ - (setattrfunc) DlgObj_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type Dialog --------------------- */ - - -static PyObject *Dlg_NewDialog(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - DialogPtr _rv; - Rect boundsRect; - Str255 title; - Boolean visible; - short procID; - WindowPtr behind; - Boolean goAwayFlag; - long refCon; - Handle itmLstHndl; - if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", - PyMac_GetRect, &boundsRect, - PyMac_GetStr255, title, - &visible, - &procID, - WinObj_Convert, &behind, - &goAwayFlag, - &refCon, - ResObj_Convert, &itmLstHndl)) - return NULL; - _rv = NewDialog((void *)0, - &boundsRect, - title, - visible, - procID, - behind, - goAwayFlag, - refCon, - itmLstHndl); - _res = Py_BuildValue("O&", - DlgObj_New, _rv); - return _res; -} - -static PyObject *Dlg_GetNewDialog(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - DialogPtr _rv; - short dialogID; - WindowPtr behind; - if (!PyArg_ParseTuple(_args, "hO&", - &dialogID, - WinObj_Convert, &behind)) - return NULL; - _rv = GetNewDialog(dialogID, - (void *)0, - behind); - _res = Py_BuildValue("O&", - DlgObj_New, _rv); - return _res; -} - -static PyObject *Dlg_ParamText(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 param0; - Str255 param1; - Str255 param2; - Str255 param3; - if (!PyArg_ParseTuple(_args, "O&O&O&O&", - PyMac_GetStr255, param0, - PyMac_GetStr255, param1, - PyMac_GetStr255, param2, - PyMac_GetStr255, param3)) - return NULL; - ParamText(param0, - param1, - param2, - param3); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Dlg_ModalDialog(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PyObject* modalFilter; - short itemHit; - if (!PyArg_ParseTuple(_args, "O", - &modalFilter)) - return NULL; - ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(modalFilter)), - &itemHit); - _res = Py_BuildValue("h", - itemHit); - return _res; -} - -static PyObject *Dlg_IsDialogEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventRecord theEvent; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetEventRecord, &theEvent)) - return NULL; - _rv = IsDialogEvent(&theEvent); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Dlg_DialogSelect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventRecord theEvent; - DialogPtr theDialog; - short itemHit; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetEventRecord, &theEvent)) - return NULL; - _rv = DialogSelect(&theEvent, - &theDialog, - &itemHit); - _res = Py_BuildValue("bO&h", - _rv, - WinObj_WhichWindow, theDialog, - itemHit); - return _res; -} - -static PyObject *Dlg_Alert(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short alertID; - PyObject* modalFilter; - if (!PyArg_ParseTuple(_args, "hO", - &alertID, - &modalFilter)) - return NULL; - _rv = Alert(alertID, - NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Dlg_StopAlert(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short alertID; - PyObject* modalFilter; - if (!PyArg_ParseTuple(_args, "hO", - &alertID, - &modalFilter)) - return NULL; - _rv = StopAlert(alertID, - NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Dlg_NoteAlert(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short alertID; - PyObject* modalFilter; - if (!PyArg_ParseTuple(_args, "hO", - &alertID, - &modalFilter)) - return NULL; - _rv = NoteAlert(alertID, - NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Dlg_CautionAlert(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short alertID; - PyObject* modalFilter; - if (!PyArg_ParseTuple(_args, "hO", - &alertID, - &modalFilter)) - return NULL; - _rv = CautionAlert(alertID, - NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Dlg_GetDialogItemText(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle item; - Str255 text; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &item)) - return NULL; - GetDialogItemText(item, - text); - _res = Py_BuildValue("O&", - PyMac_BuildStr255, text); - return _res; -} - -static PyObject *Dlg_SetDialogItemText(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle item; - Str255 text; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &item, - PyMac_GetStr255, text)) - return NULL; - SetDialogItemText(item, - text); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Dlg_NewColorDialog(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - DialogPtr _rv; - Rect boundsRect; - Str255 title; - Boolean visible; - short procID; - WindowPtr behind; - Boolean goAwayFlag; - long refCon; - Handle items; - if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", - PyMac_GetRect, &boundsRect, - PyMac_GetStr255, title, - &visible, - &procID, - WinObj_Convert, &behind, - &goAwayFlag, - &refCon, - ResObj_Convert, &items)) - return NULL; - _rv = NewColorDialog((void *)0, - &boundsRect, - title, - visible, - procID, - behind, - goAwayFlag, - refCon, - items); - _res = Py_BuildValue("O&", - DlgObj_New, _rv); - return _res; -} - -static PyObject *Dlg_GetAlertStage(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetAlertStage(); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Dlg_ResetAlertStage(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ResetAlertStage(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Dlg_SetDialogFont(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short value; - if (!PyArg_ParseTuple(_args, "h", - &value)) - return NULL; - SetDialogFont(value); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef Dlg_methods[] = { - {"NewDialog", (PyCFunction)Dlg_NewDialog, 1, - "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl) -> (DialogPtr _rv)"}, - {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1, - "(short dialogID, WindowPtr behind) -> (DialogPtr _rv)"}, - {"ParamText", (PyCFunction)Dlg_ParamText, 1, - "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"}, - {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1, - "(PyObject* modalFilter) -> (short itemHit)"}, - {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1, - "(EventRecord theEvent) -> (Boolean _rv)"}, - {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1, - "(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, short itemHit)"}, - {"Alert", (PyCFunction)Dlg_Alert, 1, - "(short alertID, PyObject* modalFilter) -> (short _rv)"}, - {"StopAlert", (PyCFunction)Dlg_StopAlert, 1, - "(short alertID, PyObject* modalFilter) -> (short _rv)"}, - {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1, - "(short alertID, PyObject* modalFilter) -> (short _rv)"}, - {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1, - "(short alertID, PyObject* modalFilter) -> (short _rv)"}, - {"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1, - "(Handle item) -> (Str255 text)"}, - {"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1, - "(Handle item, Str255 text) -> None"}, - {"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1, - "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon, Handle items) -> (DialogPtr _rv)"}, - {"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1, - "() -> (short _rv)"}, - {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1, - "() -> None"}, - {"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1, - "(short value) -> None"}, - {NULL, NULL, 0} -}; - - - - -void initDlg() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Dlg", Dlg_methods); - d = PyModule_GetDict(m); - Dlg_Error = PyMac_GetOSErrException(); - if (Dlg_Error == NULL || - PyDict_SetItemString(d, "Error", Dlg_Error) != 0) - Py_FatalError("can't initialize Dlg.Error"); -} - -/* ========================= End module Dlg ========================= */ - diff --git a/Mac/Modules/dlg/dlgscan.py b/Mac/Modules/dlg/dlgscan.py deleted file mode 100644 index 31c88dd33c..0000000000 --- a/Mac/Modules/dlg/dlgscan.py +++ /dev/null @@ -1,83 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "Dialogs" -SHORT = "dlg" -OBJECT = "DialogPtr" - -def main(): - input = LONG + ".h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t in ("DialogPtr", "DialogRef") and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - 'InitDialogs', - 'ErrorSound', - # Dialogs are disposed when the object is deleted - 'CloseDialog', - 'DisposDialog', - 'DisposeDialog', - 'UpdtDialog', - 'CouldAlert', - 'FreeAlert', - 'CouldDialog', - 'FreeDialog', - 'GetStdFilterProc', - ] - - def makeblacklisttypes(self): - return [ - ] - - def makerepairinstructions(self): - return [ - ([("Str255", "*", "InMode")], - [("*", "*", "OutMode")]), - - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode"), - ("long", "*", "OutMode")], - [("VarVarOutBuffer", "*", "InOutMode")]), - - # GetDialogItem return handle is optional - ([("Handle", "item", "OutMode")], - [("OptHandle", "item", "OutMode")]), - - # NewDialog ETC. - ([("void", "*", "OutMode")], - [("NullStorage", "*", "InMode")]), - - ([("DialogPtr", "*", "OutMode")], - [("ExistingDialogPtr", "*", "*")]), - ([("DialogRef", "*", "OutMode")], - [("ExistingDialogPtr", "*", "*")]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py deleted file mode 100644 index ca4e0dfd3d..0000000000 --- a/Mac/Modules/dlg/dlgsupport.py +++ /dev/null @@ -1,134 +0,0 @@ -# This script generates the Dialogs interface for Python. -# It uses the "bgen" package to generate C code. -# It execs the file dlggen.py which contain the function definitions -# (dlggen.py was generated by dlgscan.py, scanning the header file). - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from macsupport import * - -# Create the type objects - -DialogPtr = OpaqueByValueType("DialogPtr", "DlgObj") -DialogRef = DialogPtr - -# An OptHandle is either a handle or None (in case NULL is passed in). -# This is needed for GetDialogItem(). -OptHandle = OpaqueByValueType("Handle", "OptResObj") - -ModalFilterProcPtr = InputOnlyType("PyObject*", "O") -ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterProc(%s))" % name -ModalFilterUPP = ModalFilterProcPtr - -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") - -DITLMethod = Type("DITLMethod", "h") - -includestuff = includestuff + """ -#include - -#ifndef HAVE_UNIVERSAL_HEADERS -#define NewModalFilterProc(x) (x) -#endif - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -/* XXX Shouldn't this be a stack? */ -static PyObject *Dlg_FilterProc_callback = NULL; - -static PyObject *DlgObj_New(DialogPtr); /* Forward */ - -static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog, - EventRecord *event, - short *itemHit) -{ - Boolean rv; - PyObject *args, *res; - PyObject *callback = Dlg_FilterProc_callback; - if (callback == NULL) - return 0; /* Default behavior */ - Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ - args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event); - if (args == NULL) - res = NULL; - else { - res = PyEval_CallObject(callback, args); - Py_DECREF(args); - } - if (res == NULL) { - fprintf(stderr, "Exception in Dialog Filter\\n"); - PyErr_Print(); - *itemHit = -1; /* Fake return item */ - return 1; /* We handled it */ - } - else { - Dlg_FilterProc_callback = callback; - if (PyInt_Check(res)) { - *itemHit = PyInt_AsLong(res); - rv = 1; - } - else - rv = PyObject_IsTrue(res); - } - Py_DECREF(res); - return rv; -} - -static ModalFilterProcPtr -Dlg_PassFilterProc(PyObject *callback) -{ - PyObject *tmp = Dlg_FilterProc_callback; - Dlg_FilterProc_callback = NULL; - if (callback == Py_None) { - Py_XDECREF(tmp); - return NULL; - } - Py_INCREF(callback); - Dlg_FilterProc_callback = callback; - Py_XDECREF(tmp); - return &Dlg_UnivFilterProc; -} - -extern PyMethodChain WinObj_chain; -""" - - -# Define a class which specializes our object definition -class MyObjectDefinition(GlobalObjectDefinition): - def __init__(self, name, prefix = None, itselftype = None): - GlobalObjectDefinition.__init__(self, name, prefix, itselftype) - self.basechain = "&WinObj_chain" - def outputInitStructMembers(self): - GlobalObjectDefinition.outputInitStructMembers(self) - Output("SetWRefCon(itself, (long)it);") - def outputCheckNewArg(self): - Output("if (itself == NULL) return Py_None;") - def outputCheckConvertArg(self): - Output("if (v == Py_None) { *p_itself = NULL; return 1; }") - Output("if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);") - Output(" return 1; }") - def outputFreeIt(self, itselfname): - Output("DisposeDialog(%s);", itselfname) - -# Create the generator groups and link them -module = MacModule('Dlg', 'Dlg', includestuff, finalstuff, initstuff) -object = MyObjectDefinition('Dialog', 'DlgObj', 'DialogPtr') -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile("dlggen.py") - -# add the populated lists to the generator groups -for f in functions: module.add(f) -for f in methods: object.add(f) - -# generate output -SetOutputFileName('Dlgmodule.c') -module.generate() diff --git a/Mac/Modules/evt/Evtmodule.c b/Mac/Modules/evt/Evtmodule.c deleted file mode 100644 index 9078e9f5f9..0000000000 --- a/Mac/Modules/evt/Evtmodule.c +++ /dev/null @@ -1,426 +0,0 @@ - -/* =========================== Module Evt =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -static PyObject *Evt_Error; - -static PyObject *Evt_GetCaretTime(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetCaretTime(); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Evt_SetEventMask(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - EventMask value; - if (!PyArg_ParseTuple(_args, "h", - &value)) - return NULL; - SetEventMask(value); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Evt_GetDblTime(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetDblTime(); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Evt_GetNextEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventMask eventMask; - EventRecord theEvent; - if (!PyArg_ParseTuple(_args, "h", - &eventMask)) - return NULL; - _rv = GetNextEvent(eventMask, - &theEvent); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildEventRecord, &theEvent); - return _res; -} - -static PyObject *Evt_WaitNextEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventMask eventMask; - EventRecord theEvent; - UInt32 sleep; - if (!PyArg_ParseTuple(_args, "hl", - &eventMask, - &sleep)) - return NULL; - _rv = WaitNextEvent(eventMask, - &theEvent, - sleep, - (RgnHandle)0); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildEventRecord, &theEvent); - return _res; -} - -static PyObject *Evt_EventAvail(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventMask eventMask; - EventRecord theEvent; - if (!PyArg_ParseTuple(_args, "h", - &eventMask)) - return NULL; - _rv = EventAvail(eventMask, - &theEvent); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildEventRecord, &theEvent); - return _res; -} - -static PyObject *Evt_GetMouse(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point mouseLoc; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetMouse(&mouseLoc); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, mouseLoc); - return _res; -} - -static PyObject *Evt_Button(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = Button(); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Evt_StillDown(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = StillDown(); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Evt_WaitMouseUp(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WaitMouseUp(); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Evt_GetKeys(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - KeyMap theKeys__out__; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetKeys(theKeys__out__); - _res = Py_BuildValue("s#", - (char *)&theKeys__out__, (int)sizeof(KeyMap)); - theKeys__error__: ; - return _res; -} - -static PyObject *Evt_TickCount(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = TickCount(); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Evt_PostEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - EventKind eventNum; - UInt32 eventMsg; - if (!PyArg_ParseTuple(_args, "hl", - &eventNum, - &eventMsg)) - return NULL; - _err = PostEvent(eventNum, - eventMsg); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Evt_OSEventAvail(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventMask mask; - EventRecord theEvent; - if (!PyArg_ParseTuple(_args, "h", - &mask)) - return NULL; - _rv = OSEventAvail(mask, - &theEvent); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildEventRecord, &theEvent); - return _res; -} - -static PyObject *Evt_GetOSEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventMask mask; - EventRecord theEvent; - if (!PyArg_ParseTuple(_args, "h", - &mask)) - return NULL; - _rv = GetOSEvent(mask, - &theEvent); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildEventRecord, &theEvent); - return _res; -} - -static PyObject *Evt_FlushEvents(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - EventMask whichMask; - EventMask stopMask; - if (!PyArg_ParseTuple(_args, "hh", - &whichMask, - &stopMask)) - return NULL; - FlushEvents(whichMask, - stopMask); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Evt_SystemClick(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - EventRecord theEvent; - WindowPtr theWindow; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetEventRecord, &theEvent, - WinObj_Convert, &theWindow)) - return NULL; - SystemClick(&theEvent, - theWindow); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Evt_SystemTask(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - SystemTask(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Evt_SystemEvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventRecord theEvent; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetEventRecord, &theEvent)) - return NULL; - _rv = SystemEvent(&theEvent); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyMethodDef Evt_methods[] = { - {"GetCaretTime", (PyCFunction)Evt_GetCaretTime, 1, - "() -> (UInt32 _rv)"}, - {"SetEventMask", (PyCFunction)Evt_SetEventMask, 1, - "(EventMask value) -> None"}, - {"GetDblTime", (PyCFunction)Evt_GetDblTime, 1, - "() -> (UInt32 _rv)"}, - {"GetNextEvent", (PyCFunction)Evt_GetNextEvent, 1, - "(EventMask eventMask) -> (Boolean _rv, EventRecord theEvent)"}, - {"WaitNextEvent", (PyCFunction)Evt_WaitNextEvent, 1, - "(EventMask eventMask, UInt32 sleep) -> (Boolean _rv, EventRecord theEvent)"}, - {"EventAvail", (PyCFunction)Evt_EventAvail, 1, - "(EventMask eventMask) -> (Boolean _rv, EventRecord theEvent)"}, - {"GetMouse", (PyCFunction)Evt_GetMouse, 1, - "() -> (Point mouseLoc)"}, - {"Button", (PyCFunction)Evt_Button, 1, - "() -> (Boolean _rv)"}, - {"StillDown", (PyCFunction)Evt_StillDown, 1, - "() -> (Boolean _rv)"}, - {"WaitMouseUp", (PyCFunction)Evt_WaitMouseUp, 1, - "() -> (Boolean _rv)"}, - {"GetKeys", (PyCFunction)Evt_GetKeys, 1, - "() -> (KeyMap theKeys)"}, - {"TickCount", (PyCFunction)Evt_TickCount, 1, - "() -> (UInt32 _rv)"}, - {"PostEvent", (PyCFunction)Evt_PostEvent, 1, - "(EventKind eventNum, UInt32 eventMsg) -> None"}, - {"OSEventAvail", (PyCFunction)Evt_OSEventAvail, 1, - "(EventMask mask) -> (Boolean _rv, EventRecord theEvent)"}, - {"GetOSEvent", (PyCFunction)Evt_GetOSEvent, 1, - "(EventMask mask) -> (Boolean _rv, EventRecord theEvent)"}, - {"FlushEvents", (PyCFunction)Evt_FlushEvents, 1, - "(EventMask whichMask, EventMask stopMask) -> None"}, - {"SystemClick", (PyCFunction)Evt_SystemClick, 1, - "(EventRecord theEvent, WindowPtr theWindow) -> None"}, - {"SystemTask", (PyCFunction)Evt_SystemTask, 1, - "() -> None"}, - {"SystemEvent", (PyCFunction)Evt_SystemEvent, 1, - "(EventRecord theEvent) -> (Boolean _rv)"}, - {NULL, NULL, 0} -}; - - - - -void initEvt() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Evt", Evt_methods); - d = PyModule_GetDict(m); - Evt_Error = PyMac_GetOSErrException(); - if (Evt_Error == NULL || - PyDict_SetItemString(d, "Error", Evt_Error) != 0) - Py_FatalError("can't initialize Evt.Error"); -} - -/* ========================= End module Evt ========================= */ - diff --git a/Mac/Modules/evt/evtedit.py b/Mac/Modules/evt/evtedit.py deleted file mode 100644 index 50b4b1aae3..0000000000 --- a/Mac/Modules/evt/evtedit.py +++ /dev/null @@ -1,6 +0,0 @@ -f = Function(void, 'SystemClick', - (EventRecord_ptr, 'theEvent', InMode), - (WindowPtr, 'theWindow', InMode), -) -functions.append(f) - diff --git a/Mac/Modules/evt/evtscan.py b/Mac/Modules/evt/evtscan.py deleted file mode 100644 index 676c839f58..0000000000 --- a/Mac/Modules/evt/evtscan.py +++ /dev/null @@ -1,69 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "Events" -SHORT = "evt" -OBJECT = "NOTUSED" - -def main(): - input = LONG + ".h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - # This is non-functional today - if t == OBJECT and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - "KeyTranslate", - "GetEventMask", # I cannot seem to find this routine... - ] - - def makeblacklisttypes(self): - return [ - "EvQElPtr", "QHdrPtr" - ] - - def makerepairinstructions(self): - return [ - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode"), - ("long", "*", "OutMode")], - [("VarVarOutBuffer", "*", "InOutMode")]), - - ([("void", "wStorage", "OutMode")], - [("NullStorage", "*", "InMode")]), - - # GetKeys - ([('KeyMap', 'theKeys', 'InMode')], - [('*', '*', 'OutMode')]), - - # GetTicker - ([('unsigned long', '*', '*')], - [('unsigned_long', '*', '*')]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/evt/evtsupport.py b/Mac/Modules/evt/evtsupport.py deleted file mode 100644 index 0471a7e000..0000000000 --- a/Mac/Modules/evt/evtsupport.py +++ /dev/null @@ -1,81 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'Events.h' # The Apple header file -MODNAME = 'Evt' # The name of the module -OBJECTNAME = 'Event' # The basic name of the objects used here -KIND = 'Record' # Usually 'Ptr' or 'Handle' - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -#WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX) - -RgnHandle = FakeType("(RgnHandle)0") -# XXXX Should be next, but this will break a lot of code... -# RgnHandle = OpaqueByValueType("RgnHandle", "OptResObj") - -KeyMap = ArrayOutputBufferType("KeyMap") -MacOSEventKind = Type("MacOSEventKind", "h") # Old-style -MacOSEventMask = Type("MacOSEventMask", "h") # Old-style -EventMask = Type("EventMask", "h") -EventKind = Type("EventKind", "h") - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ -""" - -class MyObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("if (itself == NULL) return PyMac_Error(resNotFound);") - def outputCheckConvertArg(self): - OutLbrace("if (DlgObj_Check(v))") - Output("*p_itself = ((WindowObject *)v)->ob_itself;") - Output("return 1;") - OutRbrace() - Out(""" - if (v == Py_None) { *p_itself = NULL; return 1; } - if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } - """) - -# From here on it's basically all boiler plate... - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -##object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -##module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -##Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -##methods = [] -execfile(INPUTFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -##for f in methods: object.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/fm/Fmmodule.c b/Mac/Modules/fm/Fmmodule.c deleted file mode 100644 index 469e8d1733..0000000000 --- a/Mac/Modules/fm/Fmmodule.c +++ /dev/null @@ -1,397 +0,0 @@ - -/* =========================== Module Fm ============================ */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -/* -** Parse/generate ComponentDescriptor records -*/ -PyObject *FMRec_New(itself) - FMetricRec *itself; -{ - - return Py_BuildValue("O&O&O&O&O&", - PyMac_BuildFixed, itself->ascent, - PyMac_BuildFixed, itself->descent, - PyMac_BuildFixed, itself->leading, - PyMac_BuildFixed, itself->widMax, - ResObj_New, itself->wTabHandle); -} - -#if 0 -/* Not needed... */ -FMRec_Convert(v, p_itself) - PyObject *v; - FMetricRec *p_itself; -{ - return PyArg_ParseTuple(v, "O&O&O&O&O&", - PyMac_GetFixed, &itself->ascent, - PyMac_GetFixed, &itself->descent, - PyMac_GetFixed, &itself->leading, - PyMac_GetFixed, &itself->widMax, - ResObj_Convert, &itself->wTabHandle); -} -#endif - - -static PyObject *Fm_Error; - -static PyObject *Fm_InitFonts(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - InitFonts(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Fm_GetFontName(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short familyID; - Str255 name; - if (!PyArg_ParseTuple(_args, "h", - &familyID)) - return NULL; - GetFontName(familyID, - name); - _res = Py_BuildValue("O&", - PyMac_BuildStr255, name); - return _res; -} - -static PyObject *Fm_GetFNum(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 name; - short familyID; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, name)) - return NULL; - GetFNum(name, - &familyID); - _res = Py_BuildValue("h", - familyID); - return _res; -} - -static PyObject *Fm_RealFont(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - short fontNum; - short size; - if (!PyArg_ParseTuple(_args, "hh", - &fontNum, - &size)) - return NULL; - _rv = RealFont(fontNum, - size); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Fm_SetFontLock(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean lockFlag; - if (!PyArg_ParseTuple(_args, "b", - &lockFlag)) - return NULL; - SetFontLock(lockFlag); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Fm_SetFScaleDisable(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean fscaleDisable; - if (!PyArg_ParseTuple(_args, "b", - &fscaleDisable)) - return NULL; - SetFScaleDisable(fscaleDisable); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Fm_FontMetrics(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - FMetricRec theMetrics; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - FontMetrics(&theMetrics); - _res = Py_BuildValue("O&", - FMRec_New, &theMetrics); - return _res; -} - -static PyObject *Fm_SetFractEnable(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean fractEnable; - if (!PyArg_ParseTuple(_args, "b", - &fractEnable)) - return NULL; - SetFractEnable(fractEnable); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Fm_GetDefFontSize(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetDefFontSize(); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Fm_IsOutline(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point numer; - Point denom; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &numer, - PyMac_GetPoint, &denom)) - return NULL; - _rv = IsOutline(numer, - denom); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Fm_SetOutlinePreferred(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean outlinePreferred; - if (!PyArg_ParseTuple(_args, "b", - &outlinePreferred)) - return NULL; - SetOutlinePreferred(outlinePreferred); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Fm_GetOutlinePreferred(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetOutlinePreferred(); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Fm_SetPreserveGlyph(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean preserveGlyph; - if (!PyArg_ParseTuple(_args, "b", - &preserveGlyph)) - return NULL; - SetPreserveGlyph(preserveGlyph); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Fm_GetPreserveGlyph(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetPreserveGlyph(); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Fm_FlushFonts(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = FlushFonts(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Fm_GetSysFont(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetSysFont(); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Fm_GetAppFont(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetAppFont(); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyMethodDef Fm_methods[] = { - {"InitFonts", (PyCFunction)Fm_InitFonts, 1, - "() -> None"}, - {"GetFontName", (PyCFunction)Fm_GetFontName, 1, - "(short familyID) -> (Str255 name)"}, - {"GetFNum", (PyCFunction)Fm_GetFNum, 1, - "(Str255 name) -> (short familyID)"}, - {"RealFont", (PyCFunction)Fm_RealFont, 1, - "(short fontNum, short size) -> (Boolean _rv)"}, - {"SetFontLock", (PyCFunction)Fm_SetFontLock, 1, - "(Boolean lockFlag) -> None"}, - {"SetFScaleDisable", (PyCFunction)Fm_SetFScaleDisable, 1, - "(Boolean fscaleDisable) -> None"}, - {"FontMetrics", (PyCFunction)Fm_FontMetrics, 1, - "() -> (FMetricRec theMetrics)"}, - {"SetFractEnable", (PyCFunction)Fm_SetFractEnable, 1, - "(Boolean fractEnable) -> None"}, - {"GetDefFontSize", (PyCFunction)Fm_GetDefFontSize, 1, - "() -> (short _rv)"}, - {"IsOutline", (PyCFunction)Fm_IsOutline, 1, - "(Point numer, Point denom) -> (Boolean _rv)"}, - {"SetOutlinePreferred", (PyCFunction)Fm_SetOutlinePreferred, 1, - "(Boolean outlinePreferred) -> None"}, - {"GetOutlinePreferred", (PyCFunction)Fm_GetOutlinePreferred, 1, - "() -> (Boolean _rv)"}, - {"SetPreserveGlyph", (PyCFunction)Fm_SetPreserveGlyph, 1, - "(Boolean preserveGlyph) -> None"}, - {"GetPreserveGlyph", (PyCFunction)Fm_GetPreserveGlyph, 1, - "() -> (Boolean _rv)"}, - {"FlushFonts", (PyCFunction)Fm_FlushFonts, 1, - "() -> None"}, - {"GetSysFont", (PyCFunction)Fm_GetSysFont, 1, - "() -> (short _rv)"}, - {"GetAppFont", (PyCFunction)Fm_GetAppFont, 1, - "() -> (short _rv)"}, - {NULL, NULL, 0} -}; - - - - -void initFm() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Fm", Fm_methods); - d = PyModule_GetDict(m); - Fm_Error = PyMac_GetOSErrException(); - if (Fm_Error == NULL || - PyDict_SetItemString(d, "Error", Fm_Error) != 0) - Py_FatalError("can't initialize Fm.Error"); -} - -/* ========================= End module Fm ========================== */ - diff --git a/Mac/Modules/fm/fmscan.py b/Mac/Modules/fm/fmscan.py deleted file mode 100644 index 1a5d6a8162..0000000000 --- a/Mac/Modules/fm/fmscan.py +++ /dev/null @@ -1,47 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "Fonts" -SHORT = "Fm" - -def main(): - input = "Fonts.h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - return classname, listname - - def makeblacklistnames(self): - return [ - "OutlineMetrics", # Too complicated - ] - - def makeblacklisttypes(self): - return [ - "FMInput_ptr", # Not needed for now - "FMOutPtr", # Ditto - ] - - def makerepairinstructions(self): - return [ - ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]), - ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/fm/fmsupport.py b/Mac/Modules/fm/fmsupport.py deleted file mode 100644 index f0b1e29262..0000000000 --- a/Mac/Modules/fm/fmsupport.py +++ /dev/null @@ -1,75 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'Fonts.h' # The Apple header file -MODNAME = 'Fm' # The name of the module - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ - -/* -** Parse/generate ComponentDescriptor records -*/ -PyObject *FMRec_New(itself) - FMetricRec *itself; -{ - - return Py_BuildValue("O&O&O&O&O&", - PyMac_BuildFixed, itself->ascent, - PyMac_BuildFixed, itself->descent, - PyMac_BuildFixed, itself->leading, - PyMac_BuildFixed, itself->widMax, - ResObj_New, itself->wTabHandle); -} - -#if 0 -/* Not needed... */ -FMRec_Convert(v, p_itself) - PyObject *v; - FMetricRec *p_itself; -{ - return PyArg_ParseTuple(v, "O&O&O&O&O&", - PyMac_GetFixed, &itself->ascent, - PyMac_GetFixed, &itself->descent, - PyMac_GetFixed, &itself->leading, - PyMac_GetFixed, &itself->widMax, - ResObj_Convert, &itself->wTabHandle); -} -#endif - -""" - -FMetricRecPtr = OpaqueType('FMetricRec', 'FMRec') - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator - -# Create and populate the lists -functions = [] -execfile(INPUTFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/gestaltmodule.c b/Mac/Modules/gestaltmodule.c deleted file mode 100644 index 3494d646e3..0000000000 --- a/Mac/Modules/gestaltmodule.c +++ /dev/null @@ -1,69 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Macintosh Gestalt interface */ - -#include "allobjects.h" -#include "modsupport.h" - -#include -#include - -static object * -gestalt_gestalt(self, args) - object *self; - object *args; -{ - OSErr iErr; - char *str; - int size; - OSType selector; - long response; - if (!getargs(args, "s#", &str, &size)) - return NULL; - if (size != 4) { - err_setstr(TypeError, "gestalt arg must be 4-char string"); - return NULL; - } - selector = *(OSType*)str; - iErr = Gestalt ( selector, &response ); - if (iErr != 0) { - char buf[100]; - sprintf(buf, "Gestalt error code %d", iErr); - err_setstr(RuntimeError, buf); - return NULL; - } - return newintobject(response); -} - -static struct methodlist gestalt_methods[] = { - {"gestalt", gestalt_gestalt}, - {NULL, NULL} /* Sentinel */ -}; - -void -initgestalt() -{ - initmodule("gestalt", gestalt_methods); -} diff --git a/Mac/Modules/list/Listmodule.c b/Mac/Modules/list/Listmodule.c deleted file mode 100644 index b0ce515b0b..0000000000 --- a/Mac/Modules/list/Listmodule.c +++ /dev/null @@ -1,679 +0,0 @@ - -/* ========================== Module List =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -static PyObject *List_Error; - -/* ------------------------ Object type List ------------------------ */ - -PyTypeObject List_Type; - -#define ListObj_Check(x) ((x)->ob_type == &List_Type) - -typedef struct ListObject { - PyObject_HEAD - ListRef ob_itself; -} ListObject; - -PyObject *ListObj_New(itself) - ListRef itself; -{ - ListObject *it; - if (itself == NULL) { - PyErr_SetString(List_Error,"Cannot create null List"); - return NULL; - } - it = PyObject_NEW(ListObject, &List_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -ListObj_Convert(v, p_itself) - PyObject *v; - ListRef *p_itself; -{ - if (!ListObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "List required"); - return 0; - } - *p_itself = ((ListObject *)v)->ob_itself; - return 1; -} - -static void ListObj_dealloc(self) - ListObject *self; -{ - LDispose(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *ListObj_LAddColumn(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short count; - short colNum; - if (!PyArg_ParseTuple(_args, "hh", - &count, - &colNum)) - return NULL; - _rv = LAddColumn(count, - colNum, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *ListObj_LAddRow(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short count; - short rowNum; - if (!PyArg_ParseTuple(_args, "hh", - &count, - &rowNum)) - return NULL; - _rv = LAddRow(count, - rowNum, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *ListObj_LDelColumn(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short count; - short colNum; - if (!PyArg_ParseTuple(_args, "hh", - &count, - &colNum)) - return NULL; - LDelColumn(count, - colNum, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LDelRow(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short count; - short rowNum; - if (!PyArg_ParseTuple(_args, "hh", - &count, - &rowNum)) - return NULL; - LDelRow(count, - rowNum, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LGetSelect(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Boolean next; - Point theCell; - if (!PyArg_ParseTuple(_args, "bO&", - &next, - PyMac_GetPoint, &theCell)) - return NULL; - _rv = LGetSelect(next, - &theCell, - _self->ob_itself); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildPoint, theCell); - return _res; -} - -static PyObject *ListObj_LLastClick(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = LLastClick(_self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, _rv); - return _res; -} - -static PyObject *ListObj_LNextCell(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Boolean hNext; - Boolean vNext; - Point theCell; - if (!PyArg_ParseTuple(_args, "bbO&", - &hNext, - &vNext, - PyMac_GetPoint, &theCell)) - return NULL; - _rv = LNextCell(hNext, - vNext, - &theCell, - _self->ob_itself); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildPoint, theCell); - return _res; -} - -static PyObject *ListObj_LSize(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short listWidth; - short listHeight; - if (!PyArg_ParseTuple(_args, "hh", - &listWidth, - &listHeight)) - return NULL; - LSize(listWidth, - listHeight, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LSetDrawingMode(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean drawIt; - if (!PyArg_ParseTuple(_args, "b", - &drawIt)) - return NULL; - LSetDrawingMode(drawIt, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LScroll(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short dCols; - short dRows; - if (!PyArg_ParseTuple(_args, "hh", - &dCols, - &dRows)) - return NULL; - LScroll(dCols, - dRows, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LAutoScroll(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - LAutoScroll(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LUpdate(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle theRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theRgn)) - return NULL; - LUpdate(theRgn, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LActivate(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean act; - if (!PyArg_ParseTuple(_args, "b", - &act)) - return NULL; - LActivate(act, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LCellSize(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point cSize; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &cSize)) - return NULL; - LCellSize(cSize, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LClick(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point pt; - short modifiers; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetPoint, &pt, - &modifiers)) - return NULL; - _rv = LClick(pt, - modifiers, - _self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *ListObj_LAddToCell(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *dataPtr__in__; - short dataPtr__len__; - int dataPtr__in_len__; - Point theCell; - if (!PyArg_ParseTuple(_args, "s#O&", - &dataPtr__in__, &dataPtr__in_len__, - PyMac_GetPoint, &theCell)) - return NULL; - dataPtr__len__ = dataPtr__in_len__; - LAddToCell(dataPtr__in__, dataPtr__len__, - theCell, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - dataPtr__error__: ; - return _res; -} - -static PyObject *ListObj_LClrCell(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point theCell; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &theCell)) - return NULL; - LClrCell(theCell, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LGetCell(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *dataPtr__out__; - short dataPtr__len__; - int dataPtr__in_len__; - Point theCell; - if (!PyArg_ParseTuple(_args, "iO&", - &dataPtr__in_len__, - PyMac_GetPoint, &theCell)) - return NULL; - if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto dataPtr__error__; - } - dataPtr__len__ = dataPtr__in_len__; - LGetCell(dataPtr__out__, &dataPtr__len__, - theCell, - _self->ob_itself); - _res = Py_BuildValue("s#", - dataPtr__out__, (int)dataPtr__len__); - free(dataPtr__out__); - dataPtr__error__: ; - return _res; -} - -static PyObject *ListObj_LRect(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect cellRect; - Point theCell; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &theCell)) - return NULL; - LRect(&cellRect, - theCell, - _self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &cellRect); - return _res; -} - -static PyObject *ListObj_LSetCell(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *dataPtr__in__; - short dataPtr__len__; - int dataPtr__in_len__; - Point theCell; - if (!PyArg_ParseTuple(_args, "s#O&", - &dataPtr__in__, &dataPtr__in_len__, - PyMac_GetPoint, &theCell)) - return NULL; - dataPtr__len__ = dataPtr__in_len__; - LSetCell(dataPtr__in__, dataPtr__len__, - theCell, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - dataPtr__error__: ; - return _res; -} - -static PyObject *ListObj_LSetSelect(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean setIt; - Point theCell; - if (!PyArg_ParseTuple(_args, "bO&", - &setIt, - PyMac_GetPoint, &theCell)) - return NULL; - LSetSelect(setIt, - theCell, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ListObj_LDraw(_self, _args) - ListObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point theCell; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &theCell)) - return NULL; - LDraw(theCell, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef ListObj_methods[] = { - {"LAddColumn", (PyCFunction)ListObj_LAddColumn, 1, - "(short count, short colNum) -> (short _rv)"}, - {"LAddRow", (PyCFunction)ListObj_LAddRow, 1, - "(short count, short rowNum) -> (short _rv)"}, - {"LDelColumn", (PyCFunction)ListObj_LDelColumn, 1, - "(short count, short colNum) -> None"}, - {"LDelRow", (PyCFunction)ListObj_LDelRow, 1, - "(short count, short rowNum) -> None"}, - {"LGetSelect", (PyCFunction)ListObj_LGetSelect, 1, - "(Boolean next, Point theCell) -> (Boolean _rv, Point theCell)"}, - {"LLastClick", (PyCFunction)ListObj_LLastClick, 1, - "() -> (Point _rv)"}, - {"LNextCell", (PyCFunction)ListObj_LNextCell, 1, - "(Boolean hNext, Boolean vNext, Point theCell) -> (Boolean _rv, Point theCell)"}, - {"LSize", (PyCFunction)ListObj_LSize, 1, - "(short listWidth, short listHeight) -> None"}, - {"LSetDrawingMode", (PyCFunction)ListObj_LSetDrawingMode, 1, - "(Boolean drawIt) -> None"}, - {"LScroll", (PyCFunction)ListObj_LScroll, 1, - "(short dCols, short dRows) -> None"}, - {"LAutoScroll", (PyCFunction)ListObj_LAutoScroll, 1, - "() -> None"}, - {"LUpdate", (PyCFunction)ListObj_LUpdate, 1, - "(RgnHandle theRgn) -> None"}, - {"LActivate", (PyCFunction)ListObj_LActivate, 1, - "(Boolean act) -> None"}, - {"LCellSize", (PyCFunction)ListObj_LCellSize, 1, - "(Point cSize) -> None"}, - {"LClick", (PyCFunction)ListObj_LClick, 1, - "(Point pt, short modifiers) -> (Boolean _rv)"}, - {"LAddToCell", (PyCFunction)ListObj_LAddToCell, 1, - "(Buffer dataPtr, Point theCell) -> None"}, - {"LClrCell", (PyCFunction)ListObj_LClrCell, 1, - "(Point theCell) -> None"}, - {"LGetCell", (PyCFunction)ListObj_LGetCell, 1, - "(Buffer dataPtr, Point theCell) -> (Buffer dataPtr)"}, - {"LRect", (PyCFunction)ListObj_LRect, 1, - "(Point theCell) -> (Rect cellRect)"}, - {"LSetCell", (PyCFunction)ListObj_LSetCell, 1, - "(Buffer dataPtr, Point theCell) -> None"}, - {"LSetSelect", (PyCFunction)ListObj_LSetSelect, 1, - "(Boolean setIt, Point theCell) -> None"}, - {"LDraw", (PyCFunction)ListObj_LDraw, 1, - "(Point theCell) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain ListObj_chain = { ListObj_methods, NULL }; - -static PyObject *ListObj_getattr(self, name) - ListObject *self; - char *name; -{ - { - /* XXXX Should we HLock() here?? */ - if ( strcmp(name, "listFlags") == 0 ) - return Py_BuildValue("l", (long)(*self->ob_itself)->listFlags & 0xff); - if ( strcmp(name, "selFlags") == 0 ) - return Py_BuildValue("l", (long)(*self->ob_itself)->selFlags & 0xff); - } - return Py_FindMethodInChain(&ListObj_chain, (PyObject *)self, name); -} - -static int -ListObj_setattr(self, name, value) - ListObject *self; - char *name; - PyObject *value; -{ - long intval; - - if ( value == NULL || !PyInt_Check(value) ) - return -1; - intval = PyInt_AsLong(value); - if (strcmp(name, "listFlags") == 0 ) { - /* XXXX Should we HLock the handle here?? */ - (*self->ob_itself)->listFlags = intval; - return 0; - } - if (strcmp(name, "selFlags") == 0 ) { - (*self->ob_itself)->selFlags = intval; - return 0; - } - return -1; -} - - -PyTypeObject List_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "List", /*tp_name*/ - sizeof(ListObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) ListObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) ListObj_getattr, /*tp_getattr*/ - (setattrfunc) ListObj_setattr, /*tp_setattr*/ -}; - -/* ---------------------- End object type List ---------------------- */ - - -static PyObject *List_LNew(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ListRef _rv; - Rect rView; - Rect dataBounds; - Point cSize; - short theProc; - WindowPtr theWindow; - Boolean drawIt; - Boolean hasGrow; - Boolean scrollHoriz; - Boolean scrollVert; - if (!PyArg_ParseTuple(_args, "O&O&O&hO&bbbb", - PyMac_GetRect, &rView, - PyMac_GetRect, &dataBounds, - PyMac_GetPoint, &cSize, - &theProc, - WinObj_Convert, &theWindow, - &drawIt, - &hasGrow, - &scrollHoriz, - &scrollVert)) - return NULL; - _rv = LNew(&rView, - &dataBounds, - cSize, - theProc, - theWindow, - drawIt, - hasGrow, - scrollHoriz, - scrollVert); - _res = Py_BuildValue("O&", - ListObj_New, _rv); - return _res; -} - -static PyMethodDef List_methods[] = { - {"LNew", (PyCFunction)List_LNew, 1, - "(Rect rView, Rect dataBounds, Point cSize, short theProc, WindowPtr theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert) -> (ListRef _rv)"}, - {NULL, NULL, 0} -}; - - - - -void initList() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("List", List_methods); - d = PyModule_GetDict(m); - List_Error = PyMac_GetOSErrException(); - if (List_Error == NULL || - PyDict_SetItemString(d, "Error", List_Error) != 0) - Py_FatalError("can't initialize List.Error"); -} - -/* ======================== End module List ========================= */ - diff --git a/Mac/Modules/list/listscan.py b/Mac/Modules/list/listscan.py deleted file mode 100644 index ea11ba42df..0000000000 --- a/Mac/Modules/list/listscan.py +++ /dev/null @@ -1,74 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "Lists" -SHORT = "list" -OBJECT = "ListRef" - -def main(): - input = LONG + ".h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[-1] - # This is non-functional today - if t == OBJECT and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - "LDispose", # Done by removing the object - "LSearch", # We don't want to handle procs just yet - "LGetCellDataLocation", # What does this do?? - ] - - def makeblacklisttypes(self): - return [ - ] - - def makerepairinstructions(self): - return [ - ([('ListBounds_ptr', '*', 'InMode')], - [('Rect_ptr', '*', 'InMode')]), - - ([("Cell", "theCell", "OutMode")], - [("Cell", "theCell", "InOutMode")]), - - ([("void_ptr", "*", "InMode"), ("short", "*", "InMode")], - [("InBufferShortsize", "*", "*")]), - - ([("void", "*", "OutMode"), ("short", "*", "OutMode")], - [("VarOutBufferShortsize", "*", "InOutMode")]), - -# ([("void", "wStorage", "OutMode")], -# [("NullStorage", "*", "InMode")]), -# -# # GetKeys -# ([('KeyMap', 'theKeys', 'InMode')], -# [('*', '*', 'OutMode')]), -# -# # GetTicker -# ([('unsigned long', '*', '*')], -# [('unsigned_long', '*', '*')]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/list/listsupport.py b/Mac/Modules/list/listsupport.py deleted file mode 100644 index 026953c09b..0000000000 --- a/Mac/Modules/list/listsupport.py +++ /dev/null @@ -1,121 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'Lists.h' # The Apple header file -MODNAME = 'List' # The name of the module -OBJECTNAME = 'List' # The basic name of the objects used here -KIND = 'Handle' # Usually 'Ptr' or 'Handle' - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = "ListRef" # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects -ListRef = OpaqueByValueType("ListRef", "ListObj") -Cell = Point -VarOutBufferShortsize = VarHeapOutputBufferType('char', 'short', 's') # (buf, &len) -InBufferShortsize = VarInputBufferType('char', 'short', 's') # (buf, len) - -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") - - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ -""" - -class ListMethodGenerator(MethodGenerator): - """Similar to MethodGenerator, but has self as last argument""" - - def parseArgumentList(self, args): - args, a0 = args[:-1], args[-1] - t0, n0, m0 = a0 - if m0 != InMode: - raise ValueError, "method's 'self' must be 'InMode'" - self.itself = Variable(t0, "_self->ob_itself", SelfMode) - FunctionGenerator.parseArgumentList(self, args) - self.argumentList.append(self.itself) - -getattrHookCode = """{ - /* XXXX Should we HLock() here?? */ - if ( strcmp(name, "listFlags") == 0 ) - return Py_BuildValue("l", (long)(*self->ob_itself)->listFlags & 0xff); - if ( strcmp(name, "selFlags") == 0 ) - return Py_BuildValue("l", (long)(*self->ob_itself)->selFlags & 0xff); -}""" - -setattrCode = """ -static int -ListObj_setattr(self, name, value) - ListObject *self; - char *name; - PyObject *value; -{ - long intval; - - if ( value == NULL || !PyInt_Check(value) ) - return -1; - intval = PyInt_AsLong(value); - if (strcmp(name, "listFlags") == 0 ) { - /* XXXX Should we HLock the handle here?? */ - (*self->ob_itself)->listFlags = intval; - return 0; - } - if (strcmp(name, "selFlags") == 0 ) { - (*self->ob_itself)->selFlags = intval; - return 0; - } - return -1; -} -""" - - -class MyObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(List_Error,"Cannot create null List"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("LDispose(%s);", itselfname) - - def outputGetattrHook(self): - Output(getattrHookCode) - - def outputSetattr(self): - Output(setattrCode) - -# From here on it's basically all boiler plate... - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = FunctionGenerator -Method = ListMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile(INPUTFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -for f in methods: object.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/macfsmodule.c b/Mac/Modules/macfsmodule.c deleted file mode 100644 index 9bcdf622bc..0000000000 --- a/Mac/Modules/macfsmodule.c +++ /dev/null @@ -1,856 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#include "allobjects.h" -#include "modsupport.h" /* For getargs() etc. */ -#include "macglue.h" - -#include -#include -#include -#include -#include -#include - -#include "nfullpath.h" - -#ifdef THINK_C -#define FileFilterUPP FileFilterProcPtr -#endif - -static object *ErrorObject; - -/* ----------------------------------------------------- */ -/* Declarations for objects of type Alias */ - -typedef struct { - OB_HEAD - AliasHandle alias; -} mfsaobject; - -staticforward typeobject Mfsatype; - -#define is_mfsaobject(v) ((v)->ob_type == &Mfsatype) - -/* ---------------------------------------------------------------- */ -/* Declarations for objects of type FSSpec */ - -typedef struct { - OB_HEAD - FSSpec fsspec; -} mfssobject; - -staticforward typeobject Mfsstype; - -#define is_mfssobject(v) ((v)->ob_type == &Mfsstype) - - -/* ---------------------------------------------------------------- */ -/* Declarations for objects of type FInfo */ - -typedef struct { - OB_HEAD - FInfo finfo; -} mfsiobject; - -staticforward typeobject Mfsitype; - -#define is_mfsiobject(v) ((v)->ob_type == &Mfsitype) - - -mfssobject *newmfssobject(FSSpec *fss); /* Forward */ - -/* ---------------------------------------------------------------- */ - -static object * -mfsa_Resolve(self, args) - mfsaobject *self; - object *args; -{ - FSSpec from, *fromp, result; - Boolean changed; - OSErr err; - - from.name[0] = 0; - if (!newgetargs(args, "|O&", PyMac_GetFSSpec, &from)) - return NULL; - if (from.name[0] ) - fromp = &from; - else - fromp = NULL; - err = ResolveAlias(fromp, self->alias, &result, &changed); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - return mkvalue("(Oi)", newmfssobject(&result), (int)changed); -} - -static object * -mfsa_GetInfo(self, args) - mfsaobject *self; - object *args; -{ - Str63 value; - int i; - OSErr err; - - if (!newgetargs(args, "i", &i)) - return NULL; - err = GetAliasInfo(self->alias, (AliasInfoType)i, value); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return 0; - } - return newsizedstringobject((char *)&value[1], value[0]); -} - -static object * -mfsa_Update(self, args) - mfsaobject *self; - object *args; -{ - FSSpec target, fromfile, *fromfilep; - OSErr err; - Boolean changed; - - fromfile.name[0] = 0; - if (!newgetargs(args, "O&|O&", PyMac_GetFSSpec, &target, - PyMac_GetFSSpec, &fromfile)) - return NULL; - if ( fromfile.name[0] ) - fromfilep = &fromfile; - else - fromfilep = NULL; - err = UpdateAlias(fromfilep, &target, self->alias, &changed); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return 0; - } - return mkvalue("i", (int)changed); -} - -static struct methodlist mfsa_methods[] = { - {"Resolve", (method)mfsa_Resolve, 1}, - {"GetInfo", (method)mfsa_GetInfo, 1}, - {"Update", (method)mfsa_Update, 1}, - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - -static object * -mfsa_getattr(self, name) - mfsaobject *self; - char *name; -{ - if ( strcmp(name, "data") == 0 ) { - int size; - PyObject *rv; - - size = GetHandleSize((Handle)self->alias); - HLock((Handle)self->alias); - rv = PyString_FromStringAndSize(*(Handle)self->alias, size); - HUnlock((Handle)self->alias); - return rv; - } - return findmethod(mfsa_methods, (object *)self, name); -} - -mfsaobject * -newmfsaobject(alias) - AliasHandle alias; -{ - mfsaobject *self; - - self = NEWOBJ(mfsaobject, &Mfsatype); - if (self == NULL) - return NULL; - self->alias = alias; - return self; -} - - -static void -mfsa_dealloc(self) - mfsaobject *self; -{ -#if 0 - if ( self->alias ) { - should we do something here? - } -#endif - - DEL(self); -} - -statichere typeobject Mfsatype = { - OB_HEAD_INIT(&Typetype) - 0, /*ob_size*/ - "Alias", /*tp_name*/ - sizeof(mfsaobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)mfsa_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)mfsa_getattr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ -}; - -/* End of code for Alias objects */ -/* -------------------------------------------------------- */ - -/* ---------------------------------------------------------------- */ - -static struct methodlist mfsi_methods[] = { - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - -static mfsiobject * -newmfsiobject() -{ - mfsiobject *self; - - self = NEWOBJ(mfsiobject, &Mfsitype); - if (self == NULL) - return NULL; - memset((char *)&self->finfo, '\0', sizeof(self->finfo)); - return self; -} - -static void -mfsi_dealloc(self) - mfsiobject *self; -{ - DEL(self); -} - -static object * -mfsi_getattr(self, name) - mfsiobject *self; - char *name; -{ - if ( strcmp(name, "Type") == 0 ) - return PyMac_BuildOSType(self->finfo.fdType); - else if ( strcmp(name, "Creator") == 0 ) - return PyMac_BuildOSType(self->finfo.fdCreator); - else if ( strcmp(name, "Flags") == 0 ) - return Py_BuildValue("i", (int)self->finfo.fdFlags); - else if ( strcmp(name, "Location") == 0 ) - return PyMac_BuildPoint(self->finfo.fdLocation); - else if ( strcmp(name, "Fldr") == 0 ) - return Py_BuildValue("i", (int)self->finfo.fdFldr); - else - return findmethod(mfsi_methods, (object *)self, name); -} - - -static int -mfsi_setattr(self, name, v) - mfsiobject *self; - char *name; - object *v; -{ - int rv; - int i; - - if ( v == NULL ) { - err_setstr(AttributeError, "Cannot delete attribute"); - return -1; - } - if ( strcmp(name, "Type") == 0 ) - rv = PyMac_GetOSType(v, &self->finfo.fdType); - else if ( strcmp(name, "Creator") == 0 ) - rv = PyMac_GetOSType(v, &self->finfo.fdCreator); - else if ( strcmp(name, "Flags") == 0 ) { - rv = PyArg_Parse(v, "i", &i); - self->finfo.fdFlags = (short)i; - } else if ( strcmp(name, "Location") == 0 ) - rv = PyMac_GetPoint(v, &self->finfo.fdLocation); - else if ( strcmp(name, "Fldr") == 0 ) { - rv = PyArg_Parse(v, "i", &i); - self->finfo.fdFldr = (short)i; - } else { - err_setstr(AttributeError, "No such attribute"); - return -1; - } - if (rv) - return 0; - return -1; -} - - -static typeobject Mfsitype = { - OB_HEAD_INIT(&Typetype) - 0, /*ob_size*/ - "FInfo object", /*tp_name*/ - sizeof(mfsiobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)mfsi_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)mfsi_getattr, /*tp_getattr*/ - (setattrfunc)mfsi_setattr, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ -}; - -/* End of code for FInfo object objects */ -/* -------------------------------------------------------- */ - - -/* -** Helper routine for other modules: return an FSSpec * if the -** object is a python fsspec object, else NULL -*/ -FSSpec * -mfs_GetFSSpecFSSpec(self) - object *self; -{ - if ( is_mfssobject(self) ) - return &((mfssobject *)self)->fsspec; - return NULL; -} - -static object * -mfss_as_pathname(self, args) - mfssobject *self; - object *args; -{ - char strbuf[257]; - OSErr err; - - if (!newgetargs(args, "")) - return NULL; - err = nfullpath(&self->fsspec, strbuf); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - return newstringobject(strbuf); -} - -static object * -mfss_as_tuple(self, args) - mfssobject *self; - object *args; -{ - if (!newgetargs(args, "")) - return NULL; - return Py_BuildValue("(iis#)", self->fsspec.vRefNum, self->fsspec.parID, - &self->fsspec.name[1], self->fsspec.name[0]); -} - -static object * -mfss_NewAlias(self, args) - mfssobject *self; - object *args; -{ - FSSpec src, *srcp; - OSErr err; - AliasHandle alias; - - src.name[0] = 0; - if (!newgetargs(args, "|O&", PyMac_GetFSSpec, &src)) - return NULL; - if ( src.name[0] ) - srcp = &src; - else - srcp = NULL; - err = NewAlias(srcp, &self->fsspec, &alias); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - - return (object *)newmfsaobject(alias); -} - -static object * -mfss_NewAliasMinimal(self, args) - mfssobject *self; - object *args; -{ - OSErr err; - AliasHandle alias; - - if (!newgetargs(args, "")) - return NULL; - err = NewAliasMinimal(&self->fsspec, &alias); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - return (object *)newmfsaobject(alias); -} - -/* XXXX These routines should be replaced by a wrapper to the *FInfo routines */ -static object * -mfss_GetCreatorType(self, args) - mfssobject *self; - object *args; -{ - OSErr err; - FInfo info; - - if (!newgetargs(args, "")) - return NULL; - err = FSpGetFInfo(&self->fsspec, &info); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - return Py_BuildValue("(O&O&)", - PyMac_BuildOSType, info.fdCreator, PyMac_BuildOSType, info.fdType); -} - -static object * -mfss_SetCreatorType(self, args) - mfssobject *self; - object *args; -{ - OSErr err; - OSType creator, type; - FInfo info; - - if (!newgetargs(args, "O&O&", PyMac_GetOSType, &creator, PyMac_GetOSType, &type)) - return NULL; - err = FSpGetFInfo(&self->fsspec, &info); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - info.fdType = type; - info.fdCreator = creator; - err = FSpSetFInfo(&self->fsspec, &info); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - INCREF(None); - return None; -} - -static object * -mfss_GetFInfo(self, args) - mfssobject *self; - object *args; -{ - OSErr err; - mfsiobject *fip; - - - if (!newgetargs(args, "")) - return NULL; - if ( (fip=newmfsiobject()) == NULL ) - return NULL; - err = FSpGetFInfo(&self->fsspec, &fip->finfo); - if ( err ) { - PyErr_Mac(ErrorObject, err); - DECREF(fip); - return NULL; - } - return (object *)fip; -} - -static object * -mfss_SetFInfo(self, args) - mfssobject *self; - object *args; -{ - OSErr err; - mfsiobject *fip; - - if (!newgetargs(args, "O!", &Mfsitype, &fip)) - return NULL; - err = FSpSetFInfo(&self->fsspec, &fip->finfo); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - INCREF(None); - return None; -} - -static struct methodlist mfss_methods[] = { - {"as_pathname", (method)mfss_as_pathname, 1}, - {"as_tuple", (method)mfss_as_tuple, 1}, - {"NewAlias", (method)mfss_NewAlias, 1}, - {"NewAliasMinimal", (method)mfss_NewAliasMinimal, 1}, - {"GetCreatorType", (method)mfss_GetCreatorType, 1}, - {"SetCreatorType", (method)mfss_SetCreatorType, 1}, - {"GetFInfo", (method)mfss_GetFInfo, 1}, - {"SetFInfo", (method)mfss_SetFInfo, 1}, - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - -static object * -mfss_getattr(self, name) - mfssobject *self; - char *name; -{ - if ( strcmp(name, "data") == 0) - return PyString_FromStringAndSize((char *)&self->fsspec, sizeof(FSSpec)); - return findmethod(mfss_methods, (object *)self, name); -} - -mfssobject * -newmfssobject(fss) - FSSpec *fss; -{ - mfssobject *self; - - self = NEWOBJ(mfssobject, &Mfsstype); - if (self == NULL) - return NULL; - self->fsspec = *fss; - return self; -} - -static void -mfss_dealloc(self) - mfssobject *self; -{ - DEL(self); -} - -static object * -mfss_repr(self) - mfssobject *self; -{ - char buf[512]; - - sprintf(buf, "FSSpec((%d, %d, '%.*s'))", - self->fsspec.vRefNum, - self->fsspec.parID, - self->fsspec.name[0], self->fsspec.name+1); - return newstringobject(buf); -} - -static int -mfss_compare(v, w) - mfssobject *v, *w; -{ - int minlen; - int res; - - if ( v->fsspec.vRefNum < w->fsspec.vRefNum ) return -1; - if ( v->fsspec.vRefNum > w->fsspec.vRefNum ) return 1; - if ( v->fsspec.parID < w->fsspec.parID ) return -1; - if ( v->fsspec.parID > w->fsspec.parID ) return 1; - minlen = v->fsspec.name[0]; - if ( w->fsspec.name[0] < minlen ) minlen = w->fsspec.name[0]; - res = strncmp((char *)v->fsspec.name+1, (char *)w->fsspec.name+1, minlen); - if ( res ) return res; - if ( v->fsspec.name[0] < w->fsspec.name[0] ) return -1; - if ( v->fsspec.name[0] > w->fsspec.name[0] ) return 1; - return res; -} - -statichere typeobject Mfsstype = { - OB_HEAD_INIT(&Typetype) - 0, /*ob_size*/ - "FSSpec", /*tp_name*/ - sizeof(mfssobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)mfss_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)mfss_getattr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)mfss_compare, /*tp_compare*/ - (reprfunc)mfss_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ -}; - -/* End of code for FSSpec objects */ -/* -------------------------------------------------------- */ - -static object * -mfs_ResolveAliasFile(self, args) - object *self; /* Not used */ - object *args; -{ - FSSpec fss; - Boolean chain = 1, isfolder, wasaliased; - OSErr err; - - if (!newgetargs(args, "O&|i", PyMac_GetFSSpec, &fss, &chain)) - return NULL; - err = ResolveAliasFile(&fss, chain, &isfolder, &wasaliased); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - return mkvalue("Oii", newmfssobject(&fss), (int)isfolder, (int)wasaliased); -} - -static object * -mfs_StandardGetFile(self, args) - object *self; /* Not used */ - object *args; -{ - SFTypeList list; - short numtypes; - StandardFileReply reply; - - list[0] = list[1] = list[2] = list[3] = 0; - numtypes = 0; - if (!newgetargs(args, "|O&O&O&O&", PyMac_GetOSType, &list[0], - PyMac_GetOSType, &list[1], PyMac_GetOSType, &list[2], - PyMac_GetOSType, &list[3]) ) - return NULL; - while ( numtypes < 4 && list[numtypes] ) { - numtypes++; - } - if ( numtypes == 0 ) - numtypes = -1; - StandardGetFile((FileFilterUPP)0, numtypes, list, &reply); - return mkvalue("(Oi)", newmfssobject(&reply.sfFile), reply.sfGood); -} - -static object * -mfs_PromptGetFile(self, args) - object *self; /* Not used */ - object *args; -{ - SFTypeList list; - short numtypes; - StandardFileReply reply; - char *prompt = NULL; - - list[0] = list[1] = list[2] = list[3] = 0; - numtypes = 0; - if (!newgetargs(args, "s|O&O&O&O&", &prompt, PyMac_GetOSType, &list[0], - PyMac_GetOSType, &list[1], PyMac_GetOSType, &list[2], - PyMac_GetOSType, &list[3]) ) - return NULL; - while ( numtypes < 4 && list[numtypes] ) { - numtypes++; - } - if ( numtypes == 0 ) - numtypes = -1; - PyMac_PromptGetFile(numtypes, list, &reply, prompt); - return mkvalue("(Oi)", newmfssobject(&reply.sfFile), reply.sfGood); -} - -static object * -mfs_StandardPutFile(self, args) - object *self; /* Not used */ - object *args; -{ - Str255 prompt, dft; - StandardFileReply reply; - - dft[0] = 0; - if (!newgetargs(args, "O&|O&", PyMac_GetStr255, &prompt, PyMac_GetStr255, &dft) ) - return NULL; - StandardPutFile(prompt, dft, &reply); - return mkvalue("(Oi)",newmfssobject(&reply.sfFile), reply.sfGood); -} - -/* -** Set initial directory for file dialogs */ -static object * -mfs_SetFolder(self, args) - object *self; - object *args; -{ - FSSpec spec; - FSSpec ospec; - short orefnum; - long oparid; - - /* Get old values */ - orefnum = -LMGetSFSaveDisk(); - oparid = LMGetCurDirStore(); - (void)FSMakeFSSpec(orefnum, oparid, "\pplaceholder", &ospec); - - /* Go to working directory by default */ - (void)FSMakeFSSpec(0, 0, "\p:placeholder", &spec); - if (!newgetargs(args, "|O&", PyMac_GetFSSpec, &spec)) - return NULL; - /* Set standard-file working directory */ - LMSetSFSaveDisk(-spec.vRefNum); - LMSetCurDirStore(spec.parID); - return (object *)newmfssobject(&ospec); -} - -static object * -mfs_FSSpec(self, args) - object *self; /* Not used */ - object *args; -{ - FSSpec fss; - - if (!newgetargs(args, "O&", PyMac_GetFSSpec, &fss)) - return NULL; - return (object *)newmfssobject(&fss); -} - -static object * -mfs_RawFSSpec(self, args) - object *self; /* Not used */ - object *args; -{ - FSSpec *fssp; - int size; - - if (!newgetargs(args, "s#", &fssp, &size)) - return NULL; - if ( size != sizeof(FSSpec) ) { - PyErr_SetString(PyExc_TypeError, "Incorrect size for FSSpec record"); - return NULL; - } - return (object *)newmfssobject(fssp); -} - -static object * -mfs_RawAlias(self, args) - object *self; /* Not used */ - object *args; -{ - char *dataptr; - Handle h; - int size; - - if (!newgetargs(args, "s#", &dataptr, &size)) - return NULL; - h = NewHandle(size); - if ( h == NULL ) { - PyErr_NoMemory(); - return NULL; - } - HLock(h); - memcpy((char *)*h, dataptr, size); - HUnlock(h); - return (object *)newmfsaobject((AliasHandle)h); -} - -static object * -mfs_GetDirectory(self, args) - object *self; /* Not used */ - object *args; -{ - FSSpec fsdir; - int ok; - char *prompt = NULL; - - if (!newgetargs(args, "|s", &prompt) ) - return NULL; - - ok = PyMac_GetDirectory(&fsdir, prompt); - return mkvalue("(Oi)", newmfssobject(&fsdir), ok); -} - -static object * -mfs_FindFolder(self, args) - object *self; /* Not used */ - object *args; -{ - OSErr err; - short where; - OSType which; - int create; - short refnum; - long dirid; - - if (!newgetargs(args, "hO&i", &where, PyMac_GetOSType, &which, &create) ) - return NULL; - err = FindFolder(where, which, (Boolean)create, &refnum, &dirid); - if ( err ) { - PyErr_Mac(ErrorObject, err); - return NULL; - } - return mkvalue("(ii)", refnum, dirid); -} - -static object * -mfs_FInfo(self, args) - object *self; - object *args; -{ - return (object *)newmfsiobject(); -} - -/* List of methods defined in the module */ - -static struct methodlist mfs_methods[] = { - {"ResolveAliasFile", mfs_ResolveAliasFile, 1}, - {"StandardGetFile", mfs_StandardGetFile, 1}, - {"PromptGetFile", mfs_PromptGetFile, 1}, - {"StandardPutFile", mfs_StandardPutFile, 1}, - {"GetDirectory", mfs_GetDirectory, 1}, - {"SetFolder", mfs_SetFolder, 1}, - {"FSSpec", mfs_FSSpec, 1}, - {"RawFSSpec", mfs_RawFSSpec, 1}, - {"RawAlias", mfs_RawAlias, 1}, - {"FindFolder", mfs_FindFolder, 1}, - {"FInfo", mfs_FInfo, 1}, - - {NULL, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called initmacfs) */ - -void -initmacfs() -{ - object *m, *d; - - /* Create the module and add the functions */ - m = initmodule("macfs", mfs_methods); - - /* Add some symbolic constants to the module */ - d = getmoduledict(m); - ErrorObject = newstringobject("macfs.error"); - dictinsert(d, "error", ErrorObject); - - /* XXXX Add constants here */ - - /* Check for errors */ - if (err_occurred()) - fatal("can't initialize module macfs"); -} diff --git a/Mac/Modules/macmodule.c b/Mac/Modules/macmodule.c deleted file mode 100644 index 3d5c0ccd5f..0000000000 --- a/Mac/Modules/macmodule.c +++ /dev/null @@ -1,604 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Mac module implementation */ - -#include "allobjects.h" -#include "modsupport.h" -#include "ceval.h" - -#include -#include -#include - -#ifdef THINK_C -#include "unix.h" -#undef S_IFMT -#undef S_IFDIR -#undef S_IFCHR -#undef S_IFBLK -#undef S_IFREG -#undef S_ISDIR -#undef S_ISREG -#endif - -#ifdef USE_GUSI -#include -#include -#include -#define macstat stat -#else -#include "macstat.h" -#endif - -#ifdef __MWERKS__ -#include -#else -#include -#endif - -/* Optional routines, for some compiler/runtime combinations */ -#if defined(__MWERKS__) && defined(__powerc) -#define MALLOC_DEBUG -#endif -#if defined(USE_GUSI) || !defined(__MWERKS__) -#define WEHAVE_FDOPEN -#endif -#if defined(MPW) || defined(USE_GUSI) -#define WEHAVE_DUP -#endif - -#include "macdefs.h" -#ifdef USE_GUSI -#include -#else -#include "dirent.h" -#endif - -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif - -/* Prototypes for Unix simulation on Mac */ - -#ifndef USE_GUSI - -int chdir PROTO((const char *path)); -int mkdir PROTO((const char *path, int mode)); -DIR * opendir PROTO((char *)); -void closedir PROTO((DIR *)); -struct dirent * readdir PROTO((DIR *)); -int rmdir PROTO((const char *path)); -int sync PROTO((void)); - -#if defined(THINK_C) || defined(__SC__) -int unlink PROTO((char *)); -#else -int unlink PROTO((const char *)); -#endif - -#endif /* USE_GUSI */ - -char *getwd PROTO((char *)); -char *getbootvol PROTO((void)); - - -static object *MacError; /* Exception mac.error */ - -/* Set a MAC-specific error from errno, and return NULL */ - -static object * -mac_error() -{ - return err_errno(MacError); -} - -/* MAC generic methods */ - -static object * -mac_1str(args, func) - object *args; - int (*func) FPROTO((const char *)); -{ - char *path1; - int res; - if (!getargs(args, "s", &path1)) - return NULL; - BGN_SAVE - res = (*func)(path1); - END_SAVE - if (res < 0) - return mac_error(); - INCREF(None); - return None; -} - -static object * -mac_2str(args, func) - object *args; - int (*func) FPROTO((const char *, const char *)); -{ - char *path1, *path2; - int res; - if (!getargs(args, "(ss)", &path1, &path2)) - return NULL; - BGN_SAVE - res = (*func)(path1, path2); - END_SAVE - if (res < 0) - return mac_error(); - INCREF(None); - return None; -} - -static object * -mac_strint(args, func) - object *args; - int (*func) FPROTO((const char *, int)); -{ - char *path; - int i; - int res; - if (!getargs(args, "(si)", &path, &i)) - return NULL; - BGN_SAVE - res = (*func)(path, i); - END_SAVE - if (res < 0) - return mac_error(); - INCREF(None); - return None; -} - -static object * -mac_chdir(self, args) - object *self; - object *args; -{ -#ifdef USE_GUSI - object *rv; - - /* Change MacOS's idea of wd too */ - rv = mac_1str(args, chdir); - PyMac_FixGUSIcd(); - return rv; -#else - return mac_1str(args, chdir); -#endif - -} - -static object * -mac_close(self, args) - object *self; - object *args; -{ - int fd, res; - if (!getargs(args, "i", &fd)) - return NULL; - BGN_SAVE - res = close(fd); - END_SAVE -#ifndef USE_GUSI - /* GUSI gives surious errors here? */ - if (res < 0) - return mac_error(); -#endif - INCREF(None); - return None; -} - -#ifdef WEHAVE_DUP - -static object * -mac_dup(self, args) - object *self; - object *args; -{ - int fd; - if (!getargs(args, "i", &fd)) - return NULL; - BGN_SAVE - fd = dup(fd); - END_SAVE - if (fd < 0) - return mac_error(); - return newintobject((long)fd); -} - -#endif - -#ifdef WEHAVE_FDOPEN -static object * -mac_fdopen(self, args) - object *self; - object *args; -{ - extern int fclose PROTO((FILE *)); - int fd; - char *mode; - FILE *fp; - if (!getargs(args, "(is)", &fd, &mode)) - return NULL; - BGN_SAVE - fp = fdopen(fd, mode); - END_SAVE - if (fp == NULL) - return mac_error(); - return newopenfileobject(fp, "(fdopen)", mode, fclose); -} -#endif - -static object * -mac_getbootvol(self, args) - object *self; - object *args; -{ - char *res; - if (!getnoarg(args)) - return NULL; - BGN_SAVE - res = getbootvol(); - END_SAVE - if (res == NULL) - return mac_error(); - return newstringobject(res); -} - -static object * -mac_getcwd(self, args) - object *self; - object *args; -{ - char path[MAXPATHLEN]; - char *res; - if (!getnoarg(args)) - return NULL; - BGN_SAVE -#ifdef USE_GUSI - res = getcwd(path, sizeof path); -#else - res = getwd(path); -#endif - END_SAVE - if (res == NULL) { - err_setstr(MacError, path); - return NULL; - } - return newstringobject(res); -} - -static object * -mac_listdir(self, args) - object *self; - object *args; -{ - char *name; - object *d, *v; - DIR *dirp; - struct dirent *ep; - if (!getargs(args, "s", &name)) - return NULL; - BGN_SAVE - if ((dirp = opendir(name)) == NULL) { - RET_SAVE - return mac_error(); - } - if ((d = newlistobject(0)) == NULL) { - closedir(dirp); - RET_SAVE - return NULL; - } - while ((ep = readdir(dirp)) != NULL) { - v = newstringobject(ep->d_name); - if (v == NULL) { - DECREF(d); - d = NULL; - break; - } - if (addlistitem(d, v) != 0) { - DECREF(v); - DECREF(d); - d = NULL; - break; - } - DECREF(v); - } - closedir(dirp); - END_SAVE - - return d; -} - -static object * -mac_lseek(self, args) - object *self; - object *args; -{ - int fd; - int where; - int how; - long res; - if (!getargs(args, "(iii)", &fd, &where, &how)) - return NULL; - BGN_SAVE - res = lseek(fd, (long)where, how); - END_SAVE - if (res < 0) - return mac_error(); - return newintobject(res); -} - -static object * -mac_mkdir(self, args) - object *self; - object *args; -{ - int res; - char *path; - int mode = 0777; /* Unused */ - if (!newgetargs(args, "s|i", &path, &mode)) - return NULL; - BGN_SAVE -#ifdef USE_GUSI - res = mkdir(path); -#else - res = mkdir(path, mode); -#endif - END_SAVE - if (res < 0) - return mac_error(); - INCREF(None); - return None; -} - -static object * -mac_open(self, args) - object *self; - object *args; -{ - char *path; - int mode; - int fd; - if (!getargs(args, "(si)", &path, &mode)) - return NULL; - BGN_SAVE - fd = open(path, mode); - END_SAVE - if (fd < 0) - return mac_error(); - return newintobject((long)fd); -} - -static object * -mac_read(self, args) - object *self; - object *args; -{ - int fd, size; - object *buffer; - if (!getargs(args, "(ii)", &fd, &size)) - return NULL; - buffer = newsizedstringobject((char *)NULL, size); - if (buffer == NULL) - return NULL; - BGN_SAVE - size = read(fd, getstringvalue(buffer), size); - END_SAVE - if (size < 0) { - DECREF(buffer); - return mac_error(); - } - resizestring(&buffer, size); - return buffer; -} - -static object * -mac_rename(self, args) - object *self; - object *args; -{ - return mac_2str(args, rename); -} - -static object * -mac_rmdir(self, args) - object *self; - object *args; -{ - return mac_1str(args, rmdir); -} - -static object * -mac_stat(self, args) - object *self; - object *args; -{ - struct macstat st; - char *path; - int res; - if (!getargs(args, "s", &path)) - return NULL; - BGN_SAVE - res = macstat(path, &st); - END_SAVE - if (res != 0) - return mac_error(); - return mkvalue("(llllllllll)", - (long)st.st_mode, - (long)st.st_ino, - (long)st.st_dev, - (long)st.st_nlink, - (long)st.st_uid, - (long)st.st_gid, - (long)st.st_size, - (long)st.st_atime, - (long)st.st_mtime, - (long)st.st_ctime); -} - -static object * -mac_xstat(self, args) - object *self; - object *args; -{ - struct macstat st; - char *path; - int res; - if (!getargs(args, "s", &path)) - return NULL; - BGN_SAVE - res = macstat(path, &st); - END_SAVE - if (res != 0) - return mac_error(); -#ifdef USE_GUSI - return mkvalue("(llllllllll)", - (long)st.st_mode, - (long)st.st_ino, - (long)st.st_dev, - (long)st.st_nlink, - (long)st.st_uid, - (long)st.st_gid, - (long)st.st_size, - (long)st.st_atime, - (long)st.st_mtime, - (long)st.st_ctime); -#else - return mkvalue("(llllllllllls#s#)", - (long)st.st_mode, - (long)st.st_ino, - (long)st.st_dev, - (long)st.st_nlink, - (long)st.st_uid, - (long)st.st_gid, - (long)st.st_size, - (long)st.st_atime, - (long)st.st_mtime, - (long)st.st_ctime, - (long)st.st_rsize, - st.st_creator, 4, - st.st_type, 4); -#endif -} - -static object * -mac_sync(self, args) - object *self; - object *args; -{ - int res; - if (!getnoarg(args)) - return NULL; - BGN_SAVE - res = sync(); - END_SAVE - if (res != 0) - return mac_error(); - INCREF(None); - return None; -} - -static object * -mac_unlink(self, args) - object *self; - object *args; -{ - return mac_1str(args, (int (*)(const char *))unlink); -} - -static object * -mac_write(self, args) - object *self; - object *args; -{ - int fd, size; - char *buffer; - if (!getargs(args, "(is#)", &fd, &buffer, &size)) - return NULL; - BGN_SAVE - size = write(fd, buffer, size); - END_SAVE - if (size < 0) - return mac_error(); - return newintobject((long)size); -} - -#ifdef MALLOC_DEBUG -static object * -mac_mstats(self, args) - object*self; - object *args; -{ - mstats("python"); - INCREF(None); - return None; -} -#endif MALLOC_DEBUG - -static struct methodlist mac_methods[] = { - {"chdir", mac_chdir}, - {"close", mac_close}, -#ifdef WEHAVE_DUP - {"dup", mac_dup}, -#endif -#ifdef WEHAVE_FDOPEN - {"fdopen", mac_fdopen}, -#endif - {"getbootvol", mac_getbootvol}, /* non-standard */ - {"getcwd", mac_getcwd}, - {"listdir", mac_listdir, 0}, - {"lseek", mac_lseek}, - {"mkdir", mac_mkdir, 1}, - {"open", mac_open}, - {"read", mac_read}, - {"rename", mac_rename}, - {"rmdir", mac_rmdir}, - {"stat", mac_stat}, - {"xstat", mac_xstat}, - {"sync", mac_sync}, - {"remove", mac_unlink}, - {"unlink", mac_unlink}, - {"write", mac_write}, -#ifdef MALLOC_DEBUG - {"mstats", mac_mstats}, -#endif - - {NULL, NULL} /* Sentinel */ -}; - - -void -initmac() -{ - object *m, *d; - - m = initmodule("mac", mac_methods); - d = getmoduledict(m); - - /* Initialize mac.error exception */ - MacError = newstringobject("mac.error"); - if (MacError == NULL || dictinsert(d, "error", MacError) != 0) - fatal("can't define mac.error"); -} diff --git a/Mac/Modules/macosmodule.c b/Mac/Modules/macosmodule.c deleted file mode 100644 index 4780f1b217..0000000000 --- a/Mac/Modules/macosmodule.c +++ /dev/null @@ -1,607 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Macintosh OS-specific interface */ - -#include "Python.h" -#include "macglue.h" - -#include -#include - -static PyObject *MacOS_Error; /* Exception MacOS.Error */ - -#ifdef MPW -#define bufferIsSmall -607 /*error returns from Post and Accept */ -#endif - -static PyObject *ErrorObject; - -/* ----------------------------------------------------- */ - -/* Declarations for objects of type Resource fork */ - -typedef struct { - PyObject_HEAD - short fRefNum; - int isclosed; -} rfobject; - -staticforward PyTypeObject Rftype; - - - -/* ---------------------------------------------------------------- */ - -static void -do_close(self) - rfobject *self; -{ - if (self->isclosed ) return; - (void)FSClose(self->fRefNum); - self->isclosed = 1; -} - -static char rf_read__doc__[] = -"Read data from resource fork" -; - -static PyObject * -rf_read(self, args) - rfobject *self; - PyObject *args; -{ - long n; - PyObject *v; - OSErr err; - - if (self->isclosed) { - PyErr_SetString(PyExc_ValueError, "Operation on closed file"); - return NULL; - } - - if (!PyArg_ParseTuple(args, "l", &n)) - return NULL; - - v = PyString_FromStringAndSize((char *)NULL, n); - if (v == NULL) - return NULL; - - err = FSRead(self->fRefNum, &n, PyString_AsString(v)); - if (err && err != eofErr) { - PyMac_Error(err); - Py_DECREF(v); - return NULL; - } - _PyString_Resize(&v, n); - return v; -} - - -static char rf_write__doc__[] = -"Write to resource fork" -; - -static PyObject * -rf_write(self, args) - rfobject *self; - PyObject *args; -{ - char *buffer; - long size; - OSErr err; - - if (self->isclosed) { - PyErr_SetString(PyExc_ValueError, "Operation on closed file"); - return NULL; - } - if (!PyArg_ParseTuple(args, "s#", &buffer, &size)) - return NULL; - err = FSWrite(self->fRefNum, &size, buffer); - if (err) { - PyMac_Error(err); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - - -static char rf_seek__doc__[] = -"Set file position" -; - -static PyObject * -rf_seek(self, args) - rfobject *self; - PyObject *args; -{ - long amount, pos; - int whence = SEEK_SET; - long eof; - OSErr err; - - if (self->isclosed) { - PyErr_SetString(PyExc_ValueError, "Operation on closed file"); - return NULL; - } - if (!PyArg_ParseTuple(args, "l|i", &amount, &whence)) - return NULL; - - if ( err = GetEOF(self->fRefNum, &eof)) - goto ioerr; - - switch (whence) { - case SEEK_CUR: - if (err = GetFPos(self->fRefNum, &pos)) - goto ioerr; - break; - case SEEK_END: - pos = eof; - break; - case SEEK_SET: - pos = 0; - break; - default: - PyErr_BadArgument(); - return NULL; - } - - pos += amount; - - /* Don't bother implementing seek past EOF */ - if (pos > eof || pos < 0) { - PyErr_BadArgument(); - return NULL; - } - - if ( err = SetFPos(self->fRefNum, fsFromStart, pos) ) { -ioerr: - PyMac_Error(err); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - - -static char rf_tell__doc__[] = -"Get file position" -; - -static PyObject * -rf_tell(self, args) - rfobject *self; - PyObject *args; -{ - long where; - OSErr err; - - if (self->isclosed) { - PyErr_SetString(PyExc_ValueError, "Operation on closed file"); - return NULL; - } - if (!PyArg_ParseTuple(args, "")) - return NULL; - if ( err = GetFPos(self->fRefNum, &where) ) { - PyMac_Error(err); - return NULL; - } - return PyInt_FromLong(where); -} - -static char rf_close__doc__[] = -"Close resource fork" -; - -static PyObject * -rf_close(self, args) - rfobject *self; - PyObject *args; -{ - if (!PyArg_ParseTuple(args, "")) - return NULL; - do_close(self); - Py_INCREF(Py_None); - return Py_None; -} - - -static struct PyMethodDef rf_methods[] = { - {"read", rf_read, 1, rf_read__doc__}, - {"write", rf_write, 1, rf_write__doc__}, - {"seek", rf_seek, 1, rf_seek__doc__}, - {"tell", rf_tell, 1, rf_tell__doc__}, - {"close", rf_close, 1, rf_close__doc__}, - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - - -static rfobject * -newrfobject() -{ - rfobject *self; - - self = PyObject_NEW(rfobject, &Rftype); - if (self == NULL) - return NULL; - self->isclosed = 1; - return self; -} - - -static void -rf_dealloc(self) - rfobject *self; -{ - do_close(self); - PyMem_DEL(self); -} - -static PyObject * -rf_getattr(self, name) - rfobject *self; - char *name; -{ - return Py_FindMethod(rf_methods, (PyObject *)self, name); -} - -static char Rftype__doc__[] = -"Resource fork file object" -; - -static PyTypeObject Rftype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Resource fork", /*tp_name*/ - sizeof(rfobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)rf_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)rf_getattr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - - /* Space for future expansion */ - 0L,0L,0L,0L, - Rftype__doc__ /* Documentation string */ -}; - -/* End of code for Resource fork objects */ -/* -------------------------------------------------------- */ - -/*----------------------------------------------------------------------*/ -/* Miscellaneous File System Operations */ - -static PyObject * -MacOS_GetCreatorAndType(PyObject *self, PyObject *args) -{ - Str255 name; - FInfo info; - PyObject *creator, *type, *res; - OSErr err; - - if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, &name)) - return NULL; - if ((err = GetFInfo(name, 0, &info)) != noErr) - return PyErr_Mac(MacOS_Error, err); - creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4); - type = PyString_FromStringAndSize((char *)&info.fdType, 4); - res = Py_BuildValue("OO", creator, type); - Py_DECREF(creator); - Py_DECREF(type); - return res; -} - -static PyObject * -MacOS_SetCreatorAndType(PyObject *self, PyObject *args) -{ - Str255 name; - ResType creator, type; - FInfo info; - OSErr err; - - if (!PyArg_ParseTuple(args, "O&O&O&", - PyMac_GetStr255, &name, PyMac_GetOSType, &creator, PyMac_GetOSType, &type)) - return NULL; - if ((err = GetFInfo(name, 0, &info)) != noErr) - return PyErr_Mac(MacOS_Error, err); - info.fdCreator = creator; - info.fdType = type; - if ((err = SetFInfo(name, 0, &info)) != noErr) - return PyErr_Mac(MacOS_Error, err); - Py_INCREF(Py_None); - return Py_None; -} - -/*----------------------------------------------------------------------*/ -/* STDWIN High Level Event interface */ - -#include -#include - -#ifdef USE_STDWIN - -extern void (*_w_high_level_event_proc)(EventRecord *); - -static PyObject *MacOS_HighLevelEventHandler = NULL; - -static void -MacOS_HighLevelEventProc(EventRecord *e) -{ - if (MacOS_HighLevelEventHandler != NULL) { - PyObject *args = PyMac_BuildEventRecord(e); - PyObject *res; - if (args == NULL) - res = NULL; - else { - res = PyEval_CallObject(MacOS_HighLevelEventHandler, args); - Py_DECREF(args); - } - if (res == NULL) { - fprintf(stderr, "Exception in MacOS_HighLevelEventProc:\n"); - PyErr_Print(); - } - else - Py_DECREF(res); - } -} - -/* XXXX Need to come here from PyMac_DoYield too... */ - -static PyObject * -MacOS_SetHighLevelEventHandler(self, args) - PyObject *self; - PyObject *args; -{ - PyObject *previous = MacOS_HighLevelEventHandler; - PyObject *next = NULL; - if (!PyArg_ParseTuple(args, "|O", &next)) - return NULL; - if (next == Py_None) - next = NULL; - Py_INCREF(next); - MacOS_HighLevelEventHandler = next; - if (next == NULL) - _w_high_level_event_proc = NULL; - else - _w_high_level_event_proc = MacOS_HighLevelEventProc; - if (previous == NULL) { - Py_INCREF(Py_None); - previous = Py_None; - } - return previous; -} - -#endif /* USE_STDWIN */ - -static PyObject * -MacOS_AcceptHighLevelEvent(self, args) - PyObject *self; - PyObject *args; -{ - TargetID sender; - unsigned long refcon; - Ptr buf; - unsigned long len; - OSErr err; - PyObject *res; - - buf = NULL; - len = 0; - err = AcceptHighLevelEvent(&sender, &refcon, buf, &len); - if (err == bufferIsSmall) { - buf = malloc(len); - if (buf == NULL) - return PyErr_NoMemory(); - err = AcceptHighLevelEvent(&sender, &refcon, buf, &len); - if (err != noErr) { - free(buf); - return PyErr_Mac(MacOS_Error, (int)err); - } - } - else if (err != noErr) - return PyErr_Mac(MacOS_Error, (int)err); - res = Py_BuildValue("s#ls#", - (char *)&sender, (int)(sizeof sender), refcon, (char *)buf, (int)len); - free(buf); - return res; -} - -/* -** Set poll frequency and cpu-yield-time -*/ -static PyObject * -MacOS_SetScheduleTimes(PyObject *self, PyObject *args) -{ - long fgi, fgy, bgi, bgy; - - bgi = bgy = -2; - if (!PyArg_ParseTuple(args, "ll|ll", &fgi, &fgy, &bgi, &bgy)) - return NULL; - if ( bgi == -2 || bgy == -2 ) { - bgi = fgi; - bgy = fgy; - } - PyMac_SetYield(fgi, fgy, bgi, bgy); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -MacOS_EnableAppswitch(PyObject *self, PyObject *args) -{ - int old, new; - - if (!PyArg_ParseTuple(args, "i", &new)) - return NULL; - old = PyMac_DoYieldEnabled; - PyMac_DoYieldEnabled = new; - return Py_BuildValue("i", old); -} - - -static PyObject * -MacOS_HandleEvent(PyObject *self, PyObject *args) -{ - EventRecord ev; - - if (!PyArg_ParseTuple(args, "O&", PyMac_GetEventRecord, &ev)) - return NULL; - PyMac_HandleEvent(&ev); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -MacOS_GetErrorString(PyObject *self, PyObject *args) -{ - int errn; - - if (!PyArg_ParseTuple(args, "i", &errn)) - return NULL; - return Py_BuildValue("s", PyMac_StrError(errn)); -} - -static char splash_doc[] = "Open a splash-screen dialog by resource-id (0=close)"; - -static PyObject * -MacOS_splash(PyObject *self, PyObject *args) -{ - int resid; - static DialogPtr curdialog; - - if (!PyArg_ParseTuple(args, "i", &resid)) - return NULL; - if (curdialog) - DisposeDialog(curdialog); - - curdialog = GetNewDialog(resid, NULL, (WindowPtr)-1); - Py_INCREF(Py_None); - return Py_None; -} - - -static char openrf_doc[] = "Open resource fork of a file"; - -static PyObject * -MacOS_openrf(PyObject *self, PyObject *args) -{ - OSErr err; - char *mode = "r"; - FSSpec fss; - SignedByte permission = 1; - rfobject *fp; - - if (!PyArg_ParseTuple(args, "O&|s", PyMac_GetFSSpec, &fss, &mode)) - return NULL; - while (*mode) { - switch (*mode++) { - case '*': break; - case 'r': permission = 1; break; - case 'w': permission = 2; break; - case 'b': break; - default: - PyErr_BadArgument(); - return NULL; - } - } - - if ( (fp = newrfobject()) == NULL ) - return NULL; - - err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum); - - if ( err == fnfErr ) { - /* In stead of doing complicated things here to get creator/type - ** correct we let the standard i/o library handle it - */ - FILE *tfp; - char pathname[257]; - - if ( err=nfullpath(&fss, &pathname) ) { - PyMac_Error(err); - Py_DECREF(fp); - return NULL; - } - - if ( (tfp = fopen(pathname, "w")) == NULL ) { - PyMac_Error(fnfErr); /* What else... */ - Py_DECREF(fp); - return NULL; - } - fclose(tfp); - err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum); - } - if ( err ) { - Py_DECREF(fp); - PyMac_Error(err); - return NULL; - } - fp->isclosed = 0; - return (PyObject *)fp; -} - -static PyMethodDef MacOS_Methods[] = { - {"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1}, - {"GetCreatorAndType", MacOS_GetCreatorAndType, 1}, - {"SetCreatorAndType", MacOS_SetCreatorAndType, 1}, -#ifdef USE_STDWIN - {"SetHighLevelEventHandler", MacOS_SetHighLevelEventHandler, 1}, -#endif - {"SetScheduleTimes", MacOS_SetScheduleTimes, 1}, - {"EnableAppswitch", MacOS_EnableAppswitch, 1}, - {"HandleEvent", MacOS_HandleEvent, 1}, - {"GetErrorString", MacOS_GetErrorString, 1}, - {"openrf", MacOS_openrf, 1, openrf_doc}, - {"splash", MacOS_splash, 1, splash_doc}, - {NULL, NULL} /* Sentinel */ -}; - - -void -MacOS_Init() -{ - PyObject *m, *d; - - m = Py_InitModule("MacOS", MacOS_Methods); - d = PyModule_GetDict(m); - - /* Initialize MacOS.Error exception */ - MacOS_Error = PyMac_GetOSErrException(); - if (MacOS_Error == NULL || PyDict_SetItemString(d, "Error", MacOS_Error) != 0) - Py_FatalError("can't define MacOS.Error"); -} - diff --git a/Mac/Modules/macspeech/README b/Mac/Modules/macspeech/README deleted file mode 100644 index 690a6c30bf..0000000000 --- a/Mac/Modules/macspeech/README +++ /dev/null @@ -1,18 +0,0 @@ -To add this stuff to Macintosh python (and have some use for it): - -1. Obtain a copy of the Speech Manager. It can be found on - ftp.apple.com. -2. Put the Speech.h file from the Speech Manager distribution and - macspeechmodule.c in your python Modules directory. -3. Add the new module to python and build a new python. -4. Install the Speech Manager (under sys7 the extension goes in the - Extensions folder, the data file in the System folder) and reboot. -5. Try it. - -The test program 'hum' does that, you type notes and it hums them -(badly, addmitted, but that isn't my fault really). - -The test program 'grail' is more fun, but you need stdwin support for -it. It reads the script for the Holy Grail film from the file SCRIPT -and both animates it (text only:-) on the screen and reads it out the -speaker. It will use all voices available in the system. diff --git a/Mac/Modules/macspeechmodule.c b/Mac/Modules/macspeechmodule.c deleted file mode 100644 index 6a6e3d5a5e..0000000000 --- a/Mac/Modules/macspeechmodule.c +++ /dev/null @@ -1,552 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* xx module */ - -#include "allobjects.h" -#include "modsupport.h" - -#include -#include "Speech.h" - -#ifdef __MWERKS__ -#include -#define c2pstr C2PStr -#define p2cstr P2CStr -#else -#include "pascal.h" -#endif /* __MWERKS__ */ - -#ifdef __powerc -#include -int lib_available; -#endif /* __powerc */ - -/* Somehow the Apple Fix2X and X2Fix don't do what I expect */ -#define fixed2double(x) (((double)(x))/32768.0) -#define double2fixed(x) ((Fixed)((x)*32768.0)) - -char *CurrentSpeech; -object *ms_error_object; -int speech_available; - -static -init_available() { - OSErr err; - long result; - -#ifdef __powerc - lib_available = ((ProcPtr)SpeakString != (ProcPtr)0); -#endif - err = Gestalt(gestaltSpeechAttr, &result); - if ( err == noErr && (result & (1<ob_type == &sctype) - -static scobject * -newscobject(arg) - VoiceSpec *arg; -{ - scobject *self; - OSErr err; - - self = NEWOBJ(scobject, &sctype); - if (self == NULL) - return NULL; - if ( (err=NewSpeechChannel(arg, &self->chan)) != 0) { - DECREF(self); - return (scobject *)PyErr_Mac(ms_error_object, err); - } - self->curtext = NULL; - return self; -} - -/* sc methods */ - -static void -sc_dealloc(self) - scobject *self; -{ - DisposeSpeechChannel(self->chan); - DEL(self); -} - -static object * -sc_Stop(self, args) - scobject *self; - object *args; -{ - OSErr err; - - if (!getnoarg(args)) - return NULL; - if ((err=StopSpeech(self->chan)) != 0) { - PyErr_Mac(ms_error_object, err); - return NULL; - } - if ( self->curtext ) { - DECREF(self->curtext); - self->curtext = NULL; - } - INCREF(None); - return None; -} - -static object * -sc_SpeakText(self, args) - scobject *self; - object *args; -{ - OSErr err; - char *str; - int len; - - if (!getargs(args, "s#", &str, &len)) - return NULL; - if ( self->curtext ) { - StopSpeech(self->chan); - DECREF(self->curtext); - self->curtext = NULL; - } - if ((err=SpeakText(self->chan, (Ptr)str, (long)len)) != 0) { - PyErr_Mac(ms_error_object, err); - return 0; - } - (void)getargs(args, "O", &self->curtext); /* Or should I check this? */ - INCREF(self->curtext); - INCREF(None); - return None; -} - -static object * -sc_GetRate(self, args) - scobject *self; - object *args; -{ - OSErr err; - Fixed farg; - - if (!getnoarg(args)) - return NULL; - if ((err=GetSpeechRate(self->chan, &farg)) != 0) { - PyErr_Mac(ms_error_object, err); - return 0; - } - return newfloatobject(fixed2double(farg)); -} - -static object * -sc_GetPitch(self, args) - scobject *self; - object *args; -{ - OSErr err; - Fixed farg; - - if (!getnoarg(args)) - return NULL; - if ((err=GetSpeechPitch(self->chan, &farg)) != 0) { - PyErr_Mac(ms_error_object, err); - return 0; - } - return newfloatobject(fixed2double(farg)); -} - -static object * -sc_SetRate(self, args) - scobject *self; - object *args; -{ - OSErr err; - double darg; - - if (!getargs(args, "d", &darg)) - return NULL; - if ((err=SetSpeechRate(self->chan, double2fixed(darg))) != 0) { - PyErr_Mac(ms_error_object, err); - return 0; - } - INCREF(None); - return None; -} - -static object * -sc_SetPitch(self, args) - scobject *self; - object *args; -{ - OSErr err; - double darg; - - if (!getargs(args, "d", &darg)) - return NULL; - if ((err=SetSpeechPitch(self->chan, double2fixed(darg))) != 0) { - PyErr_Mac(ms_error_object, err); - return NULL; - } - INCREF(None); - return None; -} - -static struct methodlist sc_methods[] = { - {"Stop", (method)sc_Stop}, - {"SetRate", (method)sc_SetRate}, - {"GetRate", (method)sc_GetRate}, - {"SetPitch", (method)sc_SetPitch}, - {"GetPitch", (method)sc_GetPitch}, - {"SpeakText", (method)sc_SpeakText}, - {NULL, NULL} /* sentinel */ -}; - -static object * -sc_getattr(self, name) - scobject *self; - char *name; -{ - return findmethod(sc_methods, (object *)self, name); -} - -static typeobject sctype = { - OB_HEAD_INIT(&Typetype) - 0, /*ob_size*/ - "MacSpeechChannel", /*tp_name*/ - sizeof(scobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)sc_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)sc_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - -/* ------------- -** -** Part two - the voice object -*/ -typedef struct { - OB_HEAD - int initialized; - VoiceSpec vs; - VoiceDescription vd; -} mvobject; - -staticforward typeobject mvtype; - -#define is_mvobject(v) ((v)->ob_type == &mvtype) - -static mvobject * -newmvobject() -{ - mvobject *self; - self = NEWOBJ(mvobject, &mvtype); - if (self == NULL) - return NULL; - self->initialized = 0; - return self; -} - -static int -initmvobject(self, ind) - mvobject *self; - int ind; -{ - OSErr err; - - if ( (err=GetIndVoice((short)ind, &self->vs)) != 0 ) { - PyErr_Mac(ms_error_object, err); - return 0; - } - if ( (err=GetVoiceDescription(&self->vs, &self->vd, sizeof self->vd)) != 0) { - PyErr_Mac(ms_error_object, err); - return 0; - } - self->initialized = 1; - return 1; -} -/* mv methods */ - -static void -mv_dealloc(self) - mvobject *self; -{ - DEL(self); -} - -static object * -mv_getgender(self, args) - mvobject *self; - object *args; -{ - object *rv; - - if (!getnoarg(args)) - return NULL; - if (!self->initialized) { - err_setstr(ms_error_object, "Uninitialized voice"); - return NULL; - } - rv = newintobject(self->vd.gender); - return rv; -} - -static object * -mv_newchannel(self, args) - mvobject *self; - object *args; -{ - if (!getnoarg(args)) - return NULL; - if (!self->initialized) { - err_setstr(ms_error_object, "Uninitialized voice"); - return NULL; - } - return (object *)newscobject(&self->vs); -} - -static struct methodlist mv_methods[] = { - {"GetGender", (method)mv_getgender}, - {"NewChannel", (method)mv_newchannel}, - {NULL, NULL} /* sentinel */ -}; - -static object * -mv_getattr(self, name) - mvobject *self; - char *name; -{ - return findmethod(mv_methods, (object *)self, name); -} - -static typeobject mvtype = { - OB_HEAD_INIT(&Typetype) - 0, /*ob_size*/ - "MacVoice", /*tp_name*/ - sizeof(mvobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)mv_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)mv_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - - -/* ------------- -** -** Part three - The module interface -*/ - -/* See if Speech manager available */ - -static object * -ms_Available(self, args) - object *self; /* Not used */ - object *args; -{ - - if (!getnoarg(args)) - return NULL; - return newintobject(speech_available); -} - -/* Count number of busy speeches */ - -static object * -ms_Busy(self, args) - object *self; /* Not used */ - object *args; -{ - short result; - - if (!getnoarg(args)) - return NULL; - if ( !check_available() ) - return NULL; - result = SpeechBusy(); - return newintobject(result); -} - -/* Say something */ - -static object * -ms_SpeakString(self, args) - object *self; /* Not used */ - object *args; -{ - OSErr err; - char *str; - int len; - - if (!getstrarg(args, &str)) - return NULL; - if ( !check_available()) - return NULL; - if (CurrentSpeech) { - /* Free the old speech, after killing it off - ** (note that speach is async and c2pstr works inplace) - */ - SpeakString("\p"); - free(CurrentSpeech); - } - len = strlen(str); - CurrentSpeech = malloc(len+1); - strcpy(CurrentSpeech, str); - err = SpeakString(c2pstr(CurrentSpeech)); - if ( err ) { - PyErr_Mac(ms_error_object, err); - return NULL; - } - INCREF(None); - return None; -} - - -/* Count number of available voices */ - -static object * -ms_CountVoices(self, args) - object *self; /* Not used */ - object *args; -{ - short result; - - if (!getnoarg(args)) - return NULL; - if ( !check_available()) - return NULL; - CountVoices(&result); - return newintobject(result); -} - -static object * -ms_GetIndVoice(self, args) - object *self; /* Not used */ - object *args; -{ - mvobject *rv; - long ind; - - if( !getargs(args, "i", &ind)) - return NULL; - if ( !check_available() ) - return NULL; - rv = newmvobject(); - if ( !initmvobject(rv, ind) ) { - DECREF(rv); - return NULL; - } - return (object *)rv; -} - - -static object * -ms_Version(self, args) - object *self; /* Not used */ - object *args; -{ - NumVersion v; - - if (!getnoarg(args)) - return NULL; - if ( !check_available()) - return NULL; - v = SpeechManagerVersion(); - return newintobject(*(int *)&v); -} - - -/* List of functions defined in the module */ - -static struct methodlist ms_methods[] = { - {"Available", ms_Available}, - {"CountVoices", ms_CountVoices}, - {"Busy", ms_Busy}, - {"SpeakString", ms_SpeakString}, - {"GetIndVoice", ms_GetIndVoice}, - {"Version", ms_Version}, - {NULL, NULL} /* sentinel */ -}; - -/* Initialization function for the module (*must* be called initmacspeech) */ - -void -initmacspeech() -{ - object *m, *d; - - speech_available = init_available(); - /* Create the module and add the functions */ - m = initmodule("macspeech", ms_methods); - - /* Add some symbolic constants to the module */ - d = getmoduledict(m); - ms_error_object = newstringobject("macspeech.error"); - dictinsert(d, "error", ms_error_object); - - /* Check for errors */ - if (err_occurred()) - fatal("can't initialize module macspeech"); -} diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c deleted file mode 100644 index 07e1b8803e..0000000000 --- a/Mac/Modules/menu/Menumodule.c +++ /dev/null @@ -1,1045 +0,0 @@ - -/* ========================== Module Menu =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include /* Defines OpenDeskAcc in universal headers */ -#include /* Defines OpenDeskAcc in old headers */ -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -static PyObject *Menu_Error; - -/* ------------------------ Object type Menu ------------------------ */ - -PyTypeObject Menu_Type; - -#define MenuObj_Check(x) ((x)->ob_type == &Menu_Type) - -typedef struct MenuObject { - PyObject_HEAD - MenuHandle ob_itself; -} MenuObject; - -PyObject *MenuObj_New(itself) - MenuHandle itself; -{ - MenuObject *it; - it = PyObject_NEW(MenuObject, &Menu_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -MenuObj_Convert(v, p_itself) - PyObject *v; - MenuHandle *p_itself; -{ - if (!MenuObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Menu required"); - return 0; - } - *p_itself = ((MenuObject *)v)->ob_itself; - return 1; -} - -static void MenuObj_dealloc(self) - MenuObject *self; -{ - /* Cleanup of self->ob_itself goes here */ - PyMem_DEL(self); -} - -static PyObject *MenuObj_DisposeMenu(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DisposeMenu(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_AppendMenu(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 data; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, data)) - return NULL; - AppendMenu(_self->ob_itself, - data); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_AppendResMenu(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ResType theType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theType)) - return NULL; - AppendResMenu(_self->ob_itself, - theType); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_InsertResMenu(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ResType theType; - short afterItem; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetOSType, &theType, - &afterItem)) - return NULL; - InsertResMenu(_self->ob_itself, - theType, - afterItem); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_InsertMenu(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short beforeID; - if (!PyArg_ParseTuple(_args, "h", - &beforeID)) - return NULL; - InsertMenu(_self->ob_itself, - beforeID); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_InsertMenuItem(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 itemString; - short afterItem; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetStr255, itemString, - &afterItem)) - return NULL; - InsertMenuItem(_self->ob_itself, - itemString, - afterItem); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_DeleteMenuItem(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - DeleteMenuItem(_self->ob_itself, - item); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_SetMenuItemText(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - Str255 itemString; - if (!PyArg_ParseTuple(_args, "hO&", - &item, - PyMac_GetStr255, itemString)) - return NULL; - SetMenuItemText(_self->ob_itself, - item, - itemString); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_GetMenuItemText(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - Str255 itemString; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - GetMenuItemText(_self->ob_itself, - item, - itemString); - _res = Py_BuildValue("O&", - PyMac_BuildStr255, itemString); - return _res; -} - -static PyObject *MenuObj_DisableItem(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - DisableItem(_self->ob_itself, - item); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_EnableItem(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - EnableItem(_self->ob_itself, - item); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_CheckItem(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - Boolean checked; - if (!PyArg_ParseTuple(_args, "hb", - &item, - &checked)) - return NULL; - CheckItem(_self->ob_itself, - item, - checked); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_SetItemMark(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - short markChar; - if (!PyArg_ParseTuple(_args, "hh", - &item, - &markChar)) - return NULL; - SetItemMark(_self->ob_itself, - item, - markChar); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_GetItemMark(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - short markChar; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - GetItemMark(_self->ob_itself, - item, - &markChar); - _res = Py_BuildValue("h", - markChar); - return _res; -} - -static PyObject *MenuObj_SetItemIcon(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - short iconIndex; - if (!PyArg_ParseTuple(_args, "hh", - &item, - &iconIndex)) - return NULL; - SetItemIcon(_self->ob_itself, - item, - iconIndex); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_GetItemIcon(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - short iconIndex; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - GetItemIcon(_self->ob_itself, - item, - &iconIndex); - _res = Py_BuildValue("h", - iconIndex); - return _res; -} - -static PyObject *MenuObj_SetItemStyle(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - short chStyle; - if (!PyArg_ParseTuple(_args, "hh", - &item, - &chStyle)) - return NULL; - SetItemStyle(_self->ob_itself, - item, - chStyle); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_GetItemStyle(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - Style chStyle; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - GetItemStyle(_self->ob_itself, - item, - &chStyle); - _res = Py_BuildValue("b", - chStyle); - return _res; -} - -static PyObject *MenuObj_CalcMenuSize(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - CalcMenuSize(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_CountMItems(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CountMItems(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *MenuObj_GetItemCmd(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - short cmdChar; - if (!PyArg_ParseTuple(_args, "h", - &item)) - return NULL; - GetItemCmd(_self->ob_itself, - item, - &cmdChar); - _res = Py_BuildValue("h", - cmdChar); - return _res; -} - -static PyObject *MenuObj_SetItemCmd(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short item; - short cmdChar; - if (!PyArg_ParseTuple(_args, "hh", - &item, - &cmdChar)) - return NULL; - SetItemCmd(_self->ob_itself, - item, - cmdChar); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_PopUpMenuSelect(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - short top; - short left; - short popUpItem; - if (!PyArg_ParseTuple(_args, "hhh", - &top, - &left, - &popUpItem)) - return NULL; - _rv = PopUpMenuSelect(_self->ob_itself, - top, - left, - popUpItem); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MenuObj_InsertFontResMenu(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short afterItem; - short scriptFilter; - if (!PyArg_ParseTuple(_args, "hh", - &afterItem, - &scriptFilter)) - return NULL; - InsertFontResMenu(_self->ob_itself, - afterItem, - scriptFilter); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_InsertIntlResMenu(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ResType theType; - short afterItem; - short scriptFilter; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetOSType, &theType, - &afterItem, - &scriptFilter)) - return NULL; - InsertIntlResMenu(_self->ob_itself, - theType, - afterItem, - scriptFilter); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MenuObj_as_Resource(_self, _args) - MenuObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - return ResObj_New((Handle)_self->ob_itself); - -} - -static PyMethodDef MenuObj_methods[] = { - {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1, - "() -> None"}, - {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1, - "(Str255 data) -> None"}, - {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1, - "(ResType theType) -> None"}, - {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1, - "(ResType theType, short afterItem) -> None"}, - {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1, - "(short beforeID) -> None"}, - {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1, - "(Str255 itemString, short afterItem) -> None"}, - {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1, - "(short item) -> None"}, - {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1, - "(short item, Str255 itemString) -> None"}, - {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1, - "(short item) -> (Str255 itemString)"}, - {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1, - "(short item) -> None"}, - {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1, - "(short item) -> None"}, - {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1, - "(short item, Boolean checked) -> None"}, - {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1, - "(short item, short markChar) -> None"}, - {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1, - "(short item) -> (short markChar)"}, - {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1, - "(short item, short iconIndex) -> None"}, - {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1, - "(short item) -> (short iconIndex)"}, - {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1, - "(short item, short chStyle) -> None"}, - {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1, - "(short item) -> (Style chStyle)"}, - {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1, - "() -> None"}, - {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1, - "() -> (short _rv)"}, - {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1, - "(short item) -> (short cmdChar)"}, - {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1, - "(short item, short cmdChar) -> None"}, - {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1, - "(short top, short left, short popUpItem) -> (long _rv)"}, - {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1, - "(short afterItem, short scriptFilter) -> None"}, - {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1, - "(ResType theType, short afterItem, short scriptFilter) -> None"}, - {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1, - "Return this Menu as a Resource"}, - {NULL, NULL, 0} -}; - -PyMethodChain MenuObj_chain = { MenuObj_methods, NULL }; - -static PyObject *MenuObj_getattr(self, name) - MenuObject *self; - char *name; -{ - return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name); -} - -#define MenuObj_setattr NULL - -PyTypeObject Menu_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Menu", /*tp_name*/ - sizeof(MenuObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) MenuObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) MenuObj_getattr, /*tp_getattr*/ - (setattrfunc) MenuObj_setattr, /*tp_setattr*/ -}; - -/* ---------------------- End object type Menu ---------------------- */ - - -static PyObject *Menu_GetMBarHeight(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMBarHeight(); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Menu_InitMenus(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - InitMenus(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_NewMenu(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - MenuHandle _rv; - short menuID; - Str255 menuTitle; - if (!PyArg_ParseTuple(_args, "hO&", - &menuID, - PyMac_GetStr255, menuTitle)) - return NULL; - _rv = NewMenu(menuID, - menuTitle); - _res = Py_BuildValue("O&", - MenuObj_New, _rv); - return _res; -} - -static PyObject *Menu_GetMenu(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - MenuHandle _rv; - short resourceID; - if (!PyArg_ParseTuple(_args, "h", - &resourceID)) - return NULL; - _rv = GetMenu(resourceID); - _res = Py_BuildValue("O&", - MenuObj_New, _rv); - return _res; -} - -static PyObject *Menu_DrawMenuBar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DrawMenuBar(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_InvalMenuBar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - InvalMenuBar(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_DeleteMenu(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short menuID; - if (!PyArg_ParseTuple(_args, "h", - &menuID)) - return NULL; - DeleteMenu(menuID); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_ClearMenuBar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ClearMenuBar(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_GetNewMBar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - short menuBarID; - if (!PyArg_ParseTuple(_args, "h", - &menuBarID)) - return NULL; - _rv = GetNewMBar(menuBarID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Menu_GetMenuBar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMenuBar(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Menu_SetMenuBar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle menuList; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &menuList)) - return NULL; - SetMenuBar(menuList); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_MenuKey(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - short ch; - if (!PyArg_ParseTuple(_args, "h", - &ch)) - return NULL; - _rv = MenuKey(ch); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Menu_HiliteMenu(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short menuID; - if (!PyArg_ParseTuple(_args, "h", - &menuID)) - return NULL; - HiliteMenu(menuID); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_GetMenuHandle(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - MenuHandle _rv; - short menuID; - if (!PyArg_ParseTuple(_args, "h", - &menuID)) - return NULL; - _rv = GetMenuHandle(menuID); - _res = Py_BuildValue("O&", - MenuObj_New, _rv); - return _res; -} - -static PyObject *Menu_FlashMenuBar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short menuID; - if (!PyArg_ParseTuple(_args, "h", - &menuID)) - return NULL; - FlashMenuBar(menuID); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_SetMenuFlash(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short count; - if (!PyArg_ParseTuple(_args, "h", - &count)) - return NULL; - SetMenuFlash(count); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_MenuSelect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - Point startPt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &startPt)) - return NULL; - _rv = MenuSelect(startPt); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Menu_InitProcMenu(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short resID; - if (!PyArg_ParseTuple(_args, "h", - &resID)) - return NULL; - InitProcMenu(resID); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_MenuChoice(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MenuChoice(); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Menu_DeleteMCEntries(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short menuID; - short menuItem; - if (!PyArg_ParseTuple(_args, "hh", - &menuID, - &menuItem)) - return NULL; - DeleteMCEntries(menuID, - menuItem); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_SystemEdit(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - short editCmd; - if (!PyArg_ParseTuple(_args, "h", - &editCmd)) - return NULL; - _rv = SystemEdit(editCmd); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Menu_SystemMenu(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long menuResult; - if (!PyArg_ParseTuple(_args, "l", - &menuResult)) - return NULL; - SystemMenu(menuResult); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Menu_OpenDeskAcc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 name; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, name)) - return NULL; - OpenDeskAcc(name); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef Menu_methods[] = { - {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1, - "() -> (short _rv)"}, - {"InitMenus", (PyCFunction)Menu_InitMenus, 1, - "() -> None"}, - {"NewMenu", (PyCFunction)Menu_NewMenu, 1, - "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"}, - {"GetMenu", (PyCFunction)Menu_GetMenu, 1, - "(short resourceID) -> (MenuHandle _rv)"}, - {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1, - "() -> None"}, - {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1, - "() -> None"}, - {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1, - "(short menuID) -> None"}, - {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1, - "() -> None"}, - {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1, - "(short menuBarID) -> (Handle _rv)"}, - {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1, - "() -> (Handle _rv)"}, - {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1, - "(Handle menuList) -> None"}, - {"MenuKey", (PyCFunction)Menu_MenuKey, 1, - "(short ch) -> (long _rv)"}, - {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1, - "(short menuID) -> None"}, - {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1, - "(short menuID) -> (MenuHandle _rv)"}, - {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1, - "(short menuID) -> None"}, - {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1, - "(short count) -> None"}, - {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1, - "(Point startPt) -> (long _rv)"}, - {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1, - "(short resID) -> None"}, - {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1, - "() -> (long _rv)"}, - {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1, - "(short menuID, short menuItem) -> None"}, - {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1, - "(short editCmd) -> (Boolean _rv)"}, - {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1, - "(long menuResult) -> None"}, - {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1, - "(Str255 name) -> None"}, - {NULL, NULL, 0} -}; - - - - -void initMenu() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Menu", Menu_methods); - d = PyModule_GetDict(m); - Menu_Error = PyMac_GetOSErrException(); - if (Menu_Error == NULL || - PyDict_SetItemString(d, "Error", Menu_Error) != 0) - Py_FatalError("can't initialize Menu.Error"); -} - -/* ======================== End module Menu ========================= */ - diff --git a/Mac/Modules/menu/menuedit.py b/Mac/Modules/menu/menuedit.py deleted file mode 100644 index 7d53cd513c..0000000000 --- a/Mac/Modules/menu/menuedit.py +++ /dev/null @@ -1,13 +0,0 @@ -f = Function(void, 'OpenDeskAcc', - (Str255, 'name', InMode), -) -functions.append(f) - -as_resource_body = """ -return ResObj_New((Handle)_self->ob_itself); -""" - -f = ManualGenerator("as_Resource", as_resource_body) -f.docstring = lambda : "Return this Menu as a Resource" - -methods.append(f) diff --git a/Mac/Modules/menu/menuscan.py b/Mac/Modules/menu/menuscan.py deleted file mode 100644 index cf00dcc1d2..0000000000 --- a/Mac/Modules/menu/menuscan.py +++ /dev/null @@ -1,56 +0,0 @@ -# Scan , generating menugen.py. -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -def main(): - input = "Menus.h" - output = "menugen.py" - defsoutput = TOOLBOXDIR + "Menus.py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now doing 'import menusupport' ===" - import menusupport - print "=== Done. It's up to you to compile Menumodule.c ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t in ("MenuHandle", "MenuRef") and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - ] - - def makeblacklisttypes(self): - return [ - 'MCTableHandle', - 'MCEntryPtr', - 'MCTablePtr', - ] - - def makerepairinstructions(self): - return [ - ([("Str255", "itemString", "InMode")], - [("*", "*", "OutMode")]), - - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode"), - ("long", "*", "OutMode")], - [("VarVarOutBuffer", "*", "InOutMode")]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/menu/menusupport.py b/Mac/Modules/menu/menusupport.py deleted file mode 100644 index 2c7c7c0ac6..0000000000 --- a/Mac/Modules/menu/menusupport.py +++ /dev/null @@ -1,65 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -# Declarations that change for each manager -MACHEADERFILE = 'Menus.h' # The Apple header file -MODNAME = 'Menu' # The name of the module -OBJECTNAME = 'Menu' # The basic name of the objects used here - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -EXTRAFILE = string.lower(MODPREFIX) + 'edit.py' # A similar file but hand-made -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -MenuHandle = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) -MenuRef = MenuHandle - -unsigned_char = Type('unsigned char', 'b') - -includestuff = includestuff + """ -#include /* Defines OpenDeskAcc in universal headers */ -#include /* Defines OpenDeskAcc in old headers */ -#include <%s>""" % MACHEADERFILE + """ - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ -""" - -class MyObjectDefinition(GlobalObjectDefinition): - pass - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile(INPUTFILE) -execfile(EXTRAFILE) - -# add the populated lists to the generator groups -for f in functions: module.add(f) -for f in methods: object.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c deleted file mode 100644 index af6a92e548..0000000000 --- a/Mac/Modules/qd/Qdmodule.c +++ /dev/null @@ -1,3943 +0,0 @@ - -/* =========================== Module Qd ============================ */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -/* -** Parse/generate RGB records -*/ -PyObject *QdRGB_New(itself) - RGBColorPtr itself; -{ - - return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue); -} - -QdRGB_Convert(v, p_itself) - PyObject *v; - RGBColorPtr p_itself; -{ - long red, green, blue; - - if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) ) - return 0; - p_itself->red = (unsigned short)red; - p_itself->green = (unsigned short)green; - p_itself->blue = (unsigned short)blue; - return 1; -} - -/* -** Generate FontInfo records -*/ -static -PyObject *QdFI_New(itself) - FontInfo *itself; -{ - - return Py_BuildValue("hhhh", itself->ascent, itself->descent, - itself->widMax, itself->leading); -} - - - -static PyObject *Qd_Error; - -/* ---------------------- Object type GrafPort ---------------------- */ - -PyTypeObject GrafPort_Type; - -#define GrafObj_Check(x) ((x)->ob_type == &GrafPort_Type) - -typedef struct GrafPortObject { - PyObject_HEAD - GrafPtr ob_itself; -} GrafPortObject; - -PyObject *GrafObj_New(itself) - GrafPtr itself; -{ - GrafPortObject *it; - if (itself == NULL) return PyMac_Error(resNotFound); - it = PyObject_NEW(GrafPortObject, &GrafPort_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -GrafObj_Convert(v, p_itself) - PyObject *v; - GrafPtr *p_itself; -{ - if (DlgObj_Check(v) || WinObj_Check(v)) { - *p_itself = ((GrafPortObject *)v)->ob_itself; - return 1; - } - if (!GrafObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "GrafPort required"); - return 0; - } - *p_itself = ((GrafPortObject *)v)->ob_itself; - return 1; -} - -static void GrafObj_dealloc(self) - GrafPortObject *self; -{ - /* Cleanup of self->ob_itself goes here */ - PyMem_DEL(self); -} - -static PyMethodDef GrafObj_methods[] = { - {NULL, NULL, 0} -}; - -PyMethodChain GrafObj_chain = { GrafObj_methods, NULL }; - -static PyObject *GrafObj_getattr(self, name) - GrafPortObject *self; - char *name; -{ - - { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; - - if ( strcmp(name, "data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort)); - - if ( (itself_color->portVersion&0xc000) == 0xc000 ) { - /* Color-only attributes */ - - if ( strcmp(name, "portBits") == 0 ) - /* XXXX Do we need HLock() stuff here?? */ - return BMObj_New((BitMapPtr)*itself_color->portPixMap); - if ( strcmp(name, "grafVars") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn); - if ( strcmp(name, "chExtra") == 0 ) - return Py_BuildValue("h", itself_color->chExtra); - if ( strcmp(name, "pnLocHFrac") == 0 ) - return Py_BuildValue("h", itself_color->pnLocHFrac); - if ( strcmp(name, "bkPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat); - if ( strcmp(name, "rgbFgColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor); - if ( strcmp(name, "rgbBkColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor); - if ( strcmp(name, "pnPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat); - if ( strcmp(name, "fillPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat); - } else { - /* Mono-only attributes */ - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New(&self->ob_itself->portBits); - if ( strcmp(name, "bkPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern)); - if ( strcmp(name, "fillPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern)); - if ( strcmp(name, "pnPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern)); - } - /* - ** Accessible for both color/mono windows. - ** portVersion is really color-only, but we put it here - ** for convenience - */ - if ( strcmp(name, "portVersion") == 0 ) - return Py_BuildValue("h", itself_color->portVersion); - if ( strcmp(name, "device") == 0 ) - return PyInt_FromLong((long)self->ob_itself->device); - if ( strcmp(name, "portRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect); - if ( strcmp(name, "visRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn); - if ( strcmp(name, "clipRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn); - if ( strcmp(name, "pnLoc") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc); - if ( strcmp(name, "pnSize") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize); - if ( strcmp(name, "pnMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnMode); - if ( strcmp(name, "pnVis") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnVis); - if ( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", self->ob_itself->txFont); - if ( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (short)self->ob_itself->txFace); - if ( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->txMode); - if ( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", self->ob_itself->txSize); - if ( strcmp(name, "spExtra") == 0 ) - return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra); - /* XXXX Add more, as needed */ - /* This one is so we can compare grafports: */ - if ( strcmp(name, "_id") == 0 ) - return Py_BuildValue("l", (long)self->ob_itself); - } - return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name); -} - -#define GrafObj_setattr NULL - -PyTypeObject GrafPort_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "GrafPort", /*tp_name*/ - sizeof(GrafPortObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) GrafObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) GrafObj_getattr, /*tp_getattr*/ - (setattrfunc) GrafObj_setattr, /*tp_setattr*/ -}; - -/* -------------------- End object type GrafPort -------------------- */ - - -/* ----------------------- Object type BitMap ----------------------- */ - -PyTypeObject BitMap_Type; - -#define BMObj_Check(x) ((x)->ob_type == &BitMap_Type) - -typedef struct BitMapObject { - PyObject_HEAD - BitMapPtr ob_itself; - PyObject *referred_object; - BitMap *referred_bitmap; -} BitMapObject; - -PyObject *BMObj_New(itself) - BitMapPtr itself; -{ - BitMapObject *it; - if (itself == NULL) return PyMac_Error(resNotFound); - it = PyObject_NEW(BitMapObject, &BitMap_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - it->referred_object = NULL; - it->referred_bitmap = NULL; - return (PyObject *)it; -} -BMObj_Convert(v, p_itself) - PyObject *v; - BitMapPtr *p_itself; -{ - if (!BMObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "BitMap required"); - return 0; - } - *p_itself = ((BitMapObject *)v)->ob_itself; - return 1; -} - -static void BMObj_dealloc(self) - BitMapObject *self; -{ - Py_XDECREF(self->referred_object); - if (self->referred_bitmap) free(self->referred_bitmap); - PyMem_DEL(self); -} - -static PyMethodDef BMObj_methods[] = { - {NULL, NULL, 0} -}; - -PyMethodChain BMObj_chain = { BMObj_methods, NULL }; - -static PyObject *BMObj_getattr(self, name) - BitMapObject *self; - char *name; -{ - if ( strcmp(name, "baseAddr") == 0 ) - return PyInt_FromLong((long)self->ob_itself->baseAddr); - if ( strcmp(name, "rowBytes") == 0 ) - return PyInt_FromLong((long)self->ob_itself->rowBytes); - if ( strcmp(name, "bounds") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds); - /* XXXX Add more, as needed */ - if ( strcmp(name, "bitmap_data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap)); - if ( strcmp(name, "pixmap_data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap)); - - return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name); -} - -#define BMObj_setattr NULL - -PyTypeObject BitMap_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "BitMap", /*tp_name*/ - sizeof(BitMapObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) BMObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) BMObj_getattr, /*tp_getattr*/ - (setattrfunc) BMObj_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type BitMap --------------------- */ - - -/* ------------------ Object type QDGlobalsAccess ------------------- */ - -staticforward PyTypeObject QDGlobalsAccess_Type; - -#define QDGA_Check(x) ((x)->ob_type == &QDGlobalsAccess_Type) - -typedef struct QDGlobalsAccessObject { - PyObject_HEAD -} QDGlobalsAccessObject; - -static PyObject *QDGA_New() -{ - QDGlobalsAccessObject *it; - it = PyObject_NEW(QDGlobalsAccessObject, &QDGlobalsAccess_Type); - if (it == NULL) return NULL; - return (PyObject *)it; -} - -static void QDGA_dealloc(self) - QDGlobalsAccessObject *self; -{ - PyMem_DEL(self); -} - -static PyMethodDef QDGA_methods[] = { - {NULL, NULL, 0} -}; - -static PyMethodChain QDGA_chain = { QDGA_methods, NULL }; - -static PyObject *QDGA_getattr(self, name) - QDGlobalsAccessObject *self; - char *name; -{ - - if ( strcmp(name, "arrow") == 0 ) - return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow)); - if ( strcmp(name, "black") == 0 ) - return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black)); - if ( strcmp(name, "white") == 0 ) - return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white)); - if ( strcmp(name, "gray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray)); - if ( strcmp(name, "ltGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray)); - if ( strcmp(name, "dkGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray)); - if ( strcmp(name, "screenBits") == 0 ) - return BMObj_New(&qd.screenBits); - if ( strcmp(name, "thePort") == 0 ) - return GrafObj_New(qd.thePort); - if ( strcmp(name, "randSeed") == 0 ) - return Py_BuildValue("l", &qd.randSeed); - - return Py_FindMethodInChain(&QDGA_chain, (PyObject *)self, name); -} - -#define QDGA_setattr NULL - -staticforward PyTypeObject QDGlobalsAccess_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "QDGlobalsAccess", /*tp_name*/ - sizeof(QDGlobalsAccessObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) QDGA_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) QDGA_getattr, /*tp_getattr*/ - (setattrfunc) QDGA_setattr, /*tp_setattr*/ -}; - -/* ---------------- End object type QDGlobalsAccess ----------------- */ - - -static PyObject *Qd_SetPort(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - GrafPtr port; - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) - return NULL; - SetPort(port); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_GetPort(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - GrafPtr port; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetPort(&port); - _res = Py_BuildValue("O&", - GrafObj_New, port); - return _res; -} - -static PyObject *Qd_GrafDevice(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short device; - if (!PyArg_ParseTuple(_args, "h", - &device)) - return NULL; - GrafDevice(device); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetPortBits(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - BitMapPtr bm; - if (!PyArg_ParseTuple(_args, "O&", - BMObj_Convert, &bm)) - return NULL; - SetPortBits(bm); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PortSize(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short width; - short height; - if (!PyArg_ParseTuple(_args, "hh", - &width, - &height)) - return NULL; - PortSize(width, - height); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_MovePortTo(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short leftGlobal; - short topGlobal; - if (!PyArg_ParseTuple(_args, "hh", - &leftGlobal, - &topGlobal)) - return NULL; - MovePortTo(leftGlobal, - topGlobal); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetOrigin(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short h; - short v; - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - SetOrigin(h, - v); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetClip(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - SetClip(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_GetClip(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - GetClip(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ClipRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - ClipRect(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_BackPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "s#", - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - BackPat(pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_InitCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - InitCursor(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Cursor *crsr__in__; - int crsr__in_len__; - if (!PyArg_ParseTuple(_args, "s#", - (char **)&crsr__in__, &crsr__in_len__)) - return NULL; - if (crsr__in_len__ != sizeof(Cursor)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)"); - goto crsr__error__; - } - SetCursor(crsr__in__); - Py_INCREF(Py_None); - _res = Py_None; - crsr__error__: ; - return _res; -} - -static PyObject *Qd_HideCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HideCursor(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ShowCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ShowCursor(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ObscureCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ObscureCursor(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_HidePen(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HidePen(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ShowPen(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ShowPen(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_GetPen(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetPen(&pt); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); - return _res; -} - -static PyObject *Qd_GetPenState(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PenState pnState__out__; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetPenState(&pnState__out__); - _res = Py_BuildValue("s#", - (char *)&pnState__out__, (int)sizeof(PenState)); - pnState__error__: ; - return _res; -} - -static PyObject *Qd_SetPenState(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PenState *pnState__in__; - int pnState__in_len__; - if (!PyArg_ParseTuple(_args, "s#", - (char **)&pnState__in__, &pnState__in_len__)) - return NULL; - if (pnState__in_len__ != sizeof(PenState)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)"); - goto pnState__error__; - } - SetPenState(pnState__in__); - Py_INCREF(Py_None); - _res = Py_None; - pnState__error__: ; - return _res; -} - -static PyObject *Qd_PenSize(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short width; - short height; - if (!PyArg_ParseTuple(_args, "hh", - &width, - &height)) - return NULL; - PenSize(width, - height); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PenMode(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short mode; - if (!PyArg_ParseTuple(_args, "h", - &mode)) - return NULL; - PenMode(mode); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PenPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "s#", - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - PenPat(pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_PenNormal(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - PenNormal(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_MoveTo(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short h; - short v; - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - MoveTo(h, - v); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_Move(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "hh", - &dh, - &dv)) - return NULL; - Move(dh, - dv); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_LineTo(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short h; - short v; - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - LineTo(h, - v); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_Line(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "hh", - &dh, - &dv)) - return NULL; - Line(dh, - dv); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ForeColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long color; - if (!PyArg_ParseTuple(_args, "l", - &color)) - return NULL; - ForeColor(color); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_BackColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long color; - if (!PyArg_ParseTuple(_args, "l", - &color)) - return NULL; - BackColor(color); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ColorBit(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short whichBit; - if (!PyArg_ParseTuple(_args, "h", - &whichBit)) - return NULL; - ColorBit(whichBit); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short left; - short top; - short right; - short bottom; - if (!PyArg_ParseTuple(_args, "hhhh", - &left, - &top, - &right, - &bottom)) - return NULL; - SetRect(&r, - left, - top, - right, - bottom); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); - return _res; -} - -static PyObject *Qd_OffsetRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &dh, - &dv)) - return NULL; - OffsetRect(&r, - dh, - dv); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); - return _res; -} - -static PyObject *Qd_InsetRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &dh, - &dv)) - return NULL; - InsetRect(&r, - dh, - dv); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); - return _res; -} - -static PyObject *Qd_SectRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Rect src1; - Rect src2; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &src1, - PyMac_GetRect, &src2)) - return NULL; - _rv = SectRect(&src1, - &src2, - &dstRect); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildRect, &dstRect); - return _res; -} - -static PyObject *Qd_UnionRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect src1; - Rect src2; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &src1, - PyMac_GetRect, &src2)) - return NULL; - UnionRect(&src1, - &src2, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &dstRect); - return _res; -} - -static PyObject *Qd_EqualRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Rect rect1; - Rect rect2; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &rect1, - PyMac_GetRect, &rect2)) - return NULL; - _rv = EqualRect(&rect1, - &rect2); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_EmptyRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - _rv = EmptyRect(&r); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_FrameRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - FrameRect(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PaintRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - PaintRect(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_EraseRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - EraseRect(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InvertRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - InvertRect(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "O&s#", - PyMac_GetRect, &r, - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillRect(&r, - pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_FrameOval(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - FrameOval(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PaintOval(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - PaintOval(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_EraseOval(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - EraseOval(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InvertOval(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - InvertOval(&r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillOval(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "O&s#", - PyMac_GetRect, &r, - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillOval(&r, - pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_FrameRoundRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) - return NULL; - FrameRoundRect(&r, - ovalWidth, - ovalHeight); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PaintRoundRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) - return NULL; - PaintRoundRect(&r, - ovalWidth, - ovalHeight); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_EraseRoundRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) - return NULL; - EraseRoundRect(&r, - ovalWidth, - ovalHeight); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InvertRoundRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) - return NULL; - InvertRoundRect(&r, - ovalWidth, - ovalHeight); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillRoundRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "O&hhs#", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight, - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillRoundRect(&r, - ovalWidth, - ovalHeight, - pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_FrameArc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) - return NULL; - FrameArc(&r, - startAngle, - arcAngle); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PaintArc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) - return NULL; - PaintArc(&r, - startAngle, - arcAngle); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_EraseArc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) - return NULL; - EraseArc(&r, - startAngle, - arcAngle); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InvertArc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) - return NULL; - InvertArc(&r, - startAngle, - arcAngle); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillArc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "O&hhs#", - PyMac_GetRect, &r, - &startAngle, - &arcAngle, - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillArc(&r, - startAngle, - arcAngle, - pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_NewRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = NewRgn(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_OpenRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - OpenRgn(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_CloseRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle dstRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &dstRgn)) - return NULL; - CloseRgn(dstRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_BitMapToRegion(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - RgnHandle region; - BitMapPtr bMap; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, ®ion, - BMObj_Convert, &bMap)) - return NULL; - _err = BitMapToRegion(region, - bMap); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_DisposeRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - DisposeRgn(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_CopyRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle srcRgn; - RgnHandle dstRgn; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &srcRgn, - ResObj_Convert, &dstRgn)) - return NULL; - CopyRgn(srcRgn, - dstRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetEmptyRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - SetEmptyRgn(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetRectRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - short left; - short top; - short right; - short bottom; - if (!PyArg_ParseTuple(_args, "O&hhhh", - ResObj_Convert, &rgn, - &left, - &top, - &right, - &bottom)) - return NULL; - SetRectRgn(rgn, - left, - top, - right, - bottom); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_RectRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - Rect r; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &rgn, - PyMac_GetRect, &r)) - return NULL; - RectRgn(rgn, - &r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_OffsetRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "O&hh", - ResObj_Convert, &rgn, - &dh, - &dv)) - return NULL; - OffsetRgn(rgn, - dh, - dv); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InsetRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "O&hh", - ResObj_Convert, &rgn, - &dh, - &dv)) - return NULL; - InsetRgn(rgn, - dh, - dv); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SectRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) - return NULL; - SectRgn(srcRgnA, - srcRgnB, - dstRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_UnionRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) - return NULL; - UnionRgn(srcRgnA, - srcRgnB, - dstRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_DiffRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) - return NULL; - DiffRgn(srcRgnA, - srcRgnB, - dstRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_XorRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) - return NULL; - XorRgn(srcRgnA, - srcRgnB, - dstRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_RectInRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Rect r; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - ResObj_Convert, &rgn)) - return NULL; - _rv = RectInRgn(&r, - rgn); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_EqualRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - RgnHandle rgnA; - RgnHandle rgnB; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &rgnA, - ResObj_Convert, &rgnB)) - return NULL; - _rv = EqualRgn(rgnA, - rgnB); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_EmptyRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - _rv = EmptyRgn(rgn); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_FrameRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - FrameRgn(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PaintRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - PaintRgn(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_EraseRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - EraseRgn(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InvertRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) - return NULL; - InvertRgn(rgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "O&s#", - ResObj_Convert, &rgn, - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillRgn(rgn, - pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_ScrollRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short dh; - short dv; - RgnHandle updateRgn; - if (!PyArg_ParseTuple(_args, "O&hhO&", - PyMac_GetRect, &r, - &dh, - &dv, - ResObj_Convert, &updateRgn)) - return NULL; - ScrollRect(&r, - dh, - dv, - updateRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_CopyBits(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - BitMapPtr srcBits; - BitMapPtr dstBits; - Rect srcRect; - Rect dstRect; - short mode; - RgnHandle maskRgn; - if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&", - BMObj_Convert, &srcBits, - BMObj_Convert, &dstBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect, - &mode, - OptResObj_Convert, &maskRgn)) - return NULL; - CopyBits(srcBits, - dstBits, - &srcRect, - &dstRect, - mode, - maskRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_CopyMask(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - BitMapPtr srcBits; - BitMapPtr maskBits; - BitMapPtr dstBits; - Rect srcRect; - Rect maskRect; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&", - BMObj_Convert, &srcBits, - BMObj_Convert, &maskBits, - BMObj_Convert, &dstBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &maskRect, - PyMac_GetRect, &dstRect)) - return NULL; - CopyMask(srcBits, - maskBits, - dstBits, - &srcRect, - &maskRect, - &dstRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_OpenPicture(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle _rv; - Rect picFrame; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &picFrame)) - return NULL; - _rv = OpenPicture(&picFrame); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_PicComment(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short kind; - short dataSize; - Handle dataHandle; - if (!PyArg_ParseTuple(_args, "hhO&", - &kind, - &dataSize, - ResObj_Convert, &dataHandle)) - return NULL; - PicComment(kind, - dataSize, - dataHandle); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ClosePicture(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ClosePicture(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_DrawPicture(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle myPicture; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &myPicture, - PyMac_GetRect, &dstRect)) - return NULL; - DrawPicture(myPicture, - &dstRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_KillPicture(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle myPicture; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &myPicture)) - return NULL; - KillPicture(myPicture); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_OpenPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = OpenPoly(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_ClosePoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ClosePoly(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_KillPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) - return NULL; - KillPoly(poly); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_OffsetPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "O&hh", - ResObj_Convert, &poly, - &dh, - &dv)) - return NULL; - OffsetPoly(poly, - dh, - dv); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FramePoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) - return NULL; - FramePoly(poly); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PaintPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) - return NULL; - PaintPoly(poly); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ErasePoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) - return NULL; - ErasePoly(poly); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InvertPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) - return NULL; - InvertPoly(poly); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - Pattern *pat__in__; - int pat__in_len__; - if (!PyArg_ParseTuple(_args, "O&s#", - ResObj_Convert, &poly, - (char **)&pat__in__, &pat__in_len__)) - return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillPoly(poly, - pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; - return _res; -} - -static PyObject *Qd_SetPt(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt; - short h; - short v; - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - SetPt(&pt, - h, - v); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); - return _res; -} - -static PyObject *Qd_LocalToGlobal(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &pt)) - return NULL; - LocalToGlobal(&pt); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); - return _res; -} - -static PyObject *Qd_GlobalToLocal(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &pt)) - return NULL; - GlobalToLocal(&pt); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); - return _res; -} - -static PyObject *Qd_Random(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = Random(); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Qd_GetPixel(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - short h; - short v; - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - _rv = GetPixel(h, - v); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_ScalePt(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt; - Rect srcRect; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&O&", - PyMac_GetPoint, &pt, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) - return NULL; - ScalePt(&pt, - &srcRect, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); - return _res; -} - -static PyObject *Qd_MapPt(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt; - Rect srcRect; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&O&", - PyMac_GetPoint, &pt, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) - return NULL; - MapPt(&pt, - &srcRect, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); - return _res; -} - -static PyObject *Qd_MapRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - Rect srcRect; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&O&", - PyMac_GetRect, &r, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) - return NULL; - MapRect(&r, - &srcRect, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); - return _res; -} - -static PyObject *Qd_MapRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - Rect srcRect; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &rgn, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) - return NULL; - MapRgn(rgn, - &srcRect, - &dstRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_MapPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - Rect srcRect; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &poly, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) - return NULL; - MapPoly(poly, - &srcRect, - &dstRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_StdBits(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - BitMapPtr srcBits; - Rect srcRect; - Rect dstRect; - short mode; - RgnHandle maskRgn; - if (!PyArg_ParseTuple(_args, "O&O&O&hO&", - BMObj_Convert, &srcBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect, - &mode, - OptResObj_Convert, &maskRgn)) - return NULL; - StdBits(srcBits, - &srcRect, - &dstRect, - mode, - maskRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_AddPt(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point src; - Point dst; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &src, - PyMac_GetPoint, &dst)) - return NULL; - AddPt(src, - &dst); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, dst); - return _res; -} - -static PyObject *Qd_EqualPt(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point pt1; - Point pt2; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt1, - PyMac_GetPoint, &pt2)) - return NULL; - _rv = EqualPt(pt1, - pt2); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_PtInRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point pt; - Rect r; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt, - PyMac_GetRect, &r)) - return NULL; - _rv = PtInRect(pt, - &r); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_Pt2Rect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt1; - Point pt2; - Rect dstRect; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt1, - PyMac_GetPoint, &pt2)) - return NULL; - Pt2Rect(pt1, - pt2, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &dstRect); - return _res; -} - -static PyObject *Qd_PtToAngle(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - Point pt; - short angle; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - PyMac_GetPoint, &pt)) - return NULL; - PtToAngle(&r, - pt, - &angle); - _res = Py_BuildValue("h", - angle); - return _res; -} - -static PyObject *Qd_SubPt(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point src; - Point dst; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &src, - PyMac_GetPoint, &dst)) - return NULL; - SubPt(src, - &dst); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, dst); - return _res; -} - -static PyObject *Qd_PtInRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point pt; - RgnHandle rgn; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt, - ResObj_Convert, &rgn)) - return NULL; - _rv = PtInRgn(pt, - rgn); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_NewPixMap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixMapHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = NewPixMap(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_DisposePixMap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixMapHandle pm; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pm)) - return NULL; - DisposePixMap(pm); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_CopyPixMap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixMapHandle srcPM; - PixMapHandle dstPM; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &srcPM, - ResObj_Convert, &dstPM)) - return NULL; - CopyPixMap(srcPM, - dstPM); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_NewPixPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixPatHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = NewPixPat(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_DisposePixPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pp)) - return NULL; - DisposePixPat(pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_CopyPixPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixPatHandle srcPP; - PixPatHandle dstPP; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &srcPP, - ResObj_Convert, &dstPP)) - return NULL; - CopyPixPat(srcPP, - dstPP); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PenPixPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pp)) - return NULL; - PenPixPat(pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_BackPixPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pp)) - return NULL; - BackPixPat(pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_GetPixPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixPatHandle _rv; - short patID; - if (!PyArg_ParseTuple(_args, "h", - &patID)) - return NULL; - _rv = GetPixPat(patID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_MakeRGBPat(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixPatHandle pp; - RGBColor myColor; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &pp, - QdRGB_Convert, &myColor)) - return NULL; - MakeRGBPat(pp, - &myColor); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillCRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - ResObj_Convert, &pp)) - return NULL; - FillCRect(&r, - pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillCOval(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - ResObj_Convert, &pp)) - return NULL; - FillCOval(&r, - pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillCRoundRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&hhO&", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight, - ResObj_Convert, &pp)) - return NULL; - FillCRoundRect(&r, - ovalWidth, - ovalHeight, - pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillCArc(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&hhO&", - PyMac_GetRect, &r, - &startAngle, - &arcAngle, - ResObj_Convert, &pp)) - return NULL; - FillCArc(&r, - startAngle, - arcAngle, - pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillCRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle rgn; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &rgn, - ResObj_Convert, &pp)) - return NULL; - FillCRgn(rgn, - pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_FillCPoly(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PolyHandle poly; - PixPatHandle pp; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &poly, - ResObj_Convert, &pp)) - return NULL; - FillCPoly(poly, - pp); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_RGBForeColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RGBColor color; - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) - return NULL; - RGBForeColor(&color); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_RGBBackColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RGBColor color; - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) - return NULL; - RGBBackColor(&color); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetCPixel(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short h; - short v; - RGBColor cPix; - if (!PyArg_ParseTuple(_args, "hhO&", - &h, - &v, - QdRGB_Convert, &cPix)) - return NULL; - SetCPixel(h, - v, - &cPix); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SetPortPix(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixMapHandle pm; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pm)) - return NULL; - SetPortPix(pm); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_GetCPixel(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short h; - short v; - RGBColor cPix; - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - GetCPixel(h, - v, - &cPix); - _res = Py_BuildValue("O&", - QdRGB_New, &cPix); - return _res; -} - -static PyObject *Qd_GetForeColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RGBColor color; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetForeColor(&color); - _res = Py_BuildValue("O&", - QdRGB_New, &color); - return _res; -} - -static PyObject *Qd_GetBackColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RGBColor color; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetBackColor(&color); - _res = Py_BuildValue("O&", - QdRGB_New, &color); - return _res; -} - -static PyObject *Qd_OpColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RGBColor color; - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) - return NULL; - OpColor(&color); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_HiliteColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RGBColor color; - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) - return NULL; - HiliteColor(&color); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_AllocCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - AllocCursor(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_GetCTSeed(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetCTSeed(); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Qd_Color2Index(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - RGBColor myColor; - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &myColor)) - return NULL; - _rv = Color2Index(&myColor); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Qd_Index2Color(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long index; - RGBColor aColor; - if (!PyArg_ParseTuple(_args, "l", - &index)) - return NULL; - Index2Color(index, - &aColor); - _res = Py_BuildValue("O&", - QdRGB_New, &aColor); - return _res; -} - -static PyObject *Qd_InvertColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RGBColor myColor; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - InvertColor(&myColor); - _res = Py_BuildValue("O&", - QdRGB_New, &myColor); - return _res; -} - -static PyObject *Qd_RealColor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - RGBColor color; - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) - return NULL; - _rv = RealColor(&color); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_SetClientID(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short id; - if (!PyArg_ParseTuple(_args, "h", - &id)) - return NULL; - SetClientID(id); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ProtectEntry(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short index; - Boolean protect; - if (!PyArg_ParseTuple(_args, "hb", - &index, - &protect)) - return NULL; - ProtectEntry(index, - protect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ReserveEntry(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short index; - Boolean reserve; - if (!PyArg_ParseTuple(_args, "hb", - &index, - &reserve)) - return NULL; - ReserveEntry(index, - reserve); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_QDError(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = QDError(); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Qd_CopyDeepMask(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - BitMapPtr srcBits; - BitMapPtr maskBits; - BitMapPtr dstBits; - Rect srcRect; - Rect maskRect; - Rect dstRect; - short mode; - RgnHandle maskRgn; - if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&", - BMObj_Convert, &srcBits, - BMObj_Convert, &maskBits, - BMObj_Convert, &dstBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &maskRect, - PyMac_GetRect, &dstRect, - &mode, - OptResObj_Convert, &maskRgn)) - return NULL; - CopyDeepMask(srcBits, - maskBits, - dstBits, - &srcRect, - &maskRect, - &dstRect, - mode, - maskRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_GetPattern(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PatHandle _rv; - short patternID; - if (!PyArg_ParseTuple(_args, "h", - &patternID)) - return NULL; - _rv = GetPattern(patternID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_GetCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - CursHandle _rv; - short cursorID; - if (!PyArg_ParseTuple(_args, "h", - &cursorID)) - return NULL; - _rv = GetCursor(cursorID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_GetPicture(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle _rv; - short pictureID; - if (!PyArg_ParseTuple(_args, "h", - &pictureID)) - return NULL; - _rv = GetPicture(pictureID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_DeltaPoint(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - Point ptA; - Point ptB; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &ptA, - PyMac_GetPoint, &ptB)) - return NULL; - _rv = DeltaPoint(ptA, - ptB); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Qd_ShieldCursor(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect shieldRect; - Point offsetPt; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &shieldRect, - PyMac_GetPoint, &offsetPt)) - return NULL; - ShieldCursor(&shieldRect, - offsetPt); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_ScreenRes(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short scrnHRes; - short scrnVRes; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ScreenRes(&scrnHRes, - &scrnVRes); - _res = Py_BuildValue("hh", - scrnHRes, - scrnVRes); - return _res; -} - -static PyObject *Qd_GetIndPattern(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Pattern thePat__out__; - short patternListID; - short index; - if (!PyArg_ParseTuple(_args, "hh", - &patternListID, - &index)) - return NULL; - GetIndPattern(&thePat__out__, - patternListID, - index); - _res = Py_BuildValue("s#", - (char *)&thePat__out__, (int)sizeof(Pattern)); - thePat__error__: ; - return _res; -} - -static PyObject *Qd_TextFont(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short font; - if (!PyArg_ParseTuple(_args, "h", - &font)) - return NULL; - TextFont(font); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_TextFace(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short face; - if (!PyArg_ParseTuple(_args, "h", - &face)) - return NULL; - TextFace(face); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_TextMode(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short mode; - if (!PyArg_ParseTuple(_args, "h", - &mode)) - return NULL; - TextMode(mode); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_TextSize(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short size; - if (!PyArg_ParseTuple(_args, "h", - &size)) - return NULL; - TextSize(size); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_SpaceExtra(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed extra; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetFixed, &extra)) - return NULL; - SpaceExtra(extra); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_DrawChar(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short ch; - if (!PyArg_ParseTuple(_args, "h", - &ch)) - return NULL; - DrawChar(ch); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_DrawString(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 s; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, s)) - return NULL; - DrawString(s); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_DrawText(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *textBuf__in__; - int textBuf__len__; - int textBuf__in_len__; - short firstByte; - short byteCount; - if (!PyArg_ParseTuple(_args, "s#hh", - &textBuf__in__, &textBuf__in_len__, - &firstByte, - &byteCount)) - return NULL; - DrawText(textBuf__in__, - firstByte, - byteCount); - Py_INCREF(Py_None); - _res = Py_None; - textBuf__error__: ; - return _res; -} - -static PyObject *Qd_CharWidth(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short ch; - if (!PyArg_ParseTuple(_args, "h", - &ch)) - return NULL; - _rv = CharWidth(ch); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Qd_StringWidth(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - Str255 s; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, s)) - return NULL; - _rv = StringWidth(s); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Qd_TextWidth(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - char *textBuf__in__; - int textBuf__len__; - int textBuf__in_len__; - short firstByte; - short byteCount; - if (!PyArg_ParseTuple(_args, "s#hh", - &textBuf__in__, &textBuf__in_len__, - &firstByte, - &byteCount)) - return NULL; - _rv = TextWidth(textBuf__in__, - firstByte, - byteCount); - _res = Py_BuildValue("h", - _rv); - textBuf__error__: ; - return _res; -} - -static PyObject *Qd_GetFontInfo(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - FontInfo info; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetFontInfo(&info); - _res = Py_BuildValue("O&", - QdFI_New, &info); - return _res; -} - -static PyObject *Qd_CharExtra(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed extra; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetFixed, &extra)) - return NULL; - CharExtra(extra); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_BitMap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - BitMap *ptr; - PyObject *source; - Rect bounds; - int rowbytes; - char *data; - - if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect, - &bounds) ) - return NULL; - data = PyString_AsString(source); - if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL ) - return PyErr_NoMemory(); - ptr->baseAddr = (Ptr)data; - ptr->rowBytes = rowbytes; - ptr->bounds = bounds; - if ( (_res = BMObj_New(ptr)) == NULL ) { - free(ptr); - return NULL; - } - ((BitMapObject *)_res)->referred_object = source; - Py_INCREF(source); - ((BitMapObject *)_res)->referred_bitmap = ptr; - return _res; - -} - -static PyObject *Qd_RawBitMap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - BitMap *ptr; - PyObject *source; - - if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) ) - return NULL; - if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) { - PyErr_BadArgument(); - return NULL; - } - ptr = (BitMapPtr)PyString_AsString(source); - if ( (_res = BMObj_New(ptr)) == NULL ) { - return NULL; - } - ((BitMapObject *)_res)->referred_object = source; - Py_INCREF(source); - return _res; - -} - -static PyMethodDef Qd_methods[] = { - {"SetPort", (PyCFunction)Qd_SetPort, 1, - "(GrafPtr port) -> None"}, - {"GetPort", (PyCFunction)Qd_GetPort, 1, - "() -> (GrafPtr port)"}, - {"GrafDevice", (PyCFunction)Qd_GrafDevice, 1, - "(short device) -> None"}, - {"SetPortBits", (PyCFunction)Qd_SetPortBits, 1, - "(BitMapPtr bm) -> None"}, - {"PortSize", (PyCFunction)Qd_PortSize, 1, - "(short width, short height) -> None"}, - {"MovePortTo", (PyCFunction)Qd_MovePortTo, 1, - "(short leftGlobal, short topGlobal) -> None"}, - {"SetOrigin", (PyCFunction)Qd_SetOrigin, 1, - "(short h, short v) -> None"}, - {"SetClip", (PyCFunction)Qd_SetClip, 1, - "(RgnHandle rgn) -> None"}, - {"GetClip", (PyCFunction)Qd_GetClip, 1, - "(RgnHandle rgn) -> None"}, - {"ClipRect", (PyCFunction)Qd_ClipRect, 1, - "(Rect r) -> None"}, - {"BackPat", (PyCFunction)Qd_BackPat, 1, - "(Pattern pat) -> None"}, - {"InitCursor", (PyCFunction)Qd_InitCursor, 1, - "() -> None"}, - {"SetCursor", (PyCFunction)Qd_SetCursor, 1, - "(Cursor crsr) -> None"}, - {"HideCursor", (PyCFunction)Qd_HideCursor, 1, - "() -> None"}, - {"ShowCursor", (PyCFunction)Qd_ShowCursor, 1, - "() -> None"}, - {"ObscureCursor", (PyCFunction)Qd_ObscureCursor, 1, - "() -> None"}, - {"HidePen", (PyCFunction)Qd_HidePen, 1, - "() -> None"}, - {"ShowPen", (PyCFunction)Qd_ShowPen, 1, - "() -> None"}, - {"GetPen", (PyCFunction)Qd_GetPen, 1, - "() -> (Point pt)"}, - {"GetPenState", (PyCFunction)Qd_GetPenState, 1, - "() -> (PenState pnState)"}, - {"SetPenState", (PyCFunction)Qd_SetPenState, 1, - "(PenState pnState) -> None"}, - {"PenSize", (PyCFunction)Qd_PenSize, 1, - "(short width, short height) -> None"}, - {"PenMode", (PyCFunction)Qd_PenMode, 1, - "(short mode) -> None"}, - {"PenPat", (PyCFunction)Qd_PenPat, 1, - "(Pattern pat) -> None"}, - {"PenNormal", (PyCFunction)Qd_PenNormal, 1, - "() -> None"}, - {"MoveTo", (PyCFunction)Qd_MoveTo, 1, - "(short h, short v) -> None"}, - {"Move", (PyCFunction)Qd_Move, 1, - "(short dh, short dv) -> None"}, - {"LineTo", (PyCFunction)Qd_LineTo, 1, - "(short h, short v) -> None"}, - {"Line", (PyCFunction)Qd_Line, 1, - "(short dh, short dv) -> None"}, - {"ForeColor", (PyCFunction)Qd_ForeColor, 1, - "(long color) -> None"}, - {"BackColor", (PyCFunction)Qd_BackColor, 1, - "(long color) -> None"}, - {"ColorBit", (PyCFunction)Qd_ColorBit, 1, - "(short whichBit) -> None"}, - {"SetRect", (PyCFunction)Qd_SetRect, 1, - "(short left, short top, short right, short bottom) -> (Rect r)"}, - {"OffsetRect", (PyCFunction)Qd_OffsetRect, 1, - "(Rect r, short dh, short dv) -> (Rect r)"}, - {"InsetRect", (PyCFunction)Qd_InsetRect, 1, - "(Rect r, short dh, short dv) -> (Rect r)"}, - {"SectRect", (PyCFunction)Qd_SectRect, 1, - "(Rect src1, Rect src2) -> (Boolean _rv, Rect dstRect)"}, - {"UnionRect", (PyCFunction)Qd_UnionRect, 1, - "(Rect src1, Rect src2) -> (Rect dstRect)"}, - {"EqualRect", (PyCFunction)Qd_EqualRect, 1, - "(Rect rect1, Rect rect2) -> (Boolean _rv)"}, - {"EmptyRect", (PyCFunction)Qd_EmptyRect, 1, - "(Rect r) -> (Boolean _rv)"}, - {"FrameRect", (PyCFunction)Qd_FrameRect, 1, - "(Rect r) -> None"}, - {"PaintRect", (PyCFunction)Qd_PaintRect, 1, - "(Rect r) -> None"}, - {"EraseRect", (PyCFunction)Qd_EraseRect, 1, - "(Rect r) -> None"}, - {"InvertRect", (PyCFunction)Qd_InvertRect, 1, - "(Rect r) -> None"}, - {"FillRect", (PyCFunction)Qd_FillRect, 1, - "(Rect r, Pattern pat) -> None"}, - {"FrameOval", (PyCFunction)Qd_FrameOval, 1, - "(Rect r) -> None"}, - {"PaintOval", (PyCFunction)Qd_PaintOval, 1, - "(Rect r) -> None"}, - {"EraseOval", (PyCFunction)Qd_EraseOval, 1, - "(Rect r) -> None"}, - {"InvertOval", (PyCFunction)Qd_InvertOval, 1, - "(Rect r) -> None"}, - {"FillOval", (PyCFunction)Qd_FillOval, 1, - "(Rect r, Pattern pat) -> None"}, - {"FrameRoundRect", (PyCFunction)Qd_FrameRoundRect, 1, - "(Rect r, short ovalWidth, short ovalHeight) -> None"}, - {"PaintRoundRect", (PyCFunction)Qd_PaintRoundRect, 1, - "(Rect r, short ovalWidth, short ovalHeight) -> None"}, - {"EraseRoundRect", (PyCFunction)Qd_EraseRoundRect, 1, - "(Rect r, short ovalWidth, short ovalHeight) -> None"}, - {"InvertRoundRect", (PyCFunction)Qd_InvertRoundRect, 1, - "(Rect r, short ovalWidth, short ovalHeight) -> None"}, - {"FillRoundRect", (PyCFunction)Qd_FillRoundRect, 1, - "(Rect r, short ovalWidth, short ovalHeight, Pattern pat) -> None"}, - {"FrameArc", (PyCFunction)Qd_FrameArc, 1, - "(Rect r, short startAngle, short arcAngle) -> None"}, - {"PaintArc", (PyCFunction)Qd_PaintArc, 1, - "(Rect r, short startAngle, short arcAngle) -> None"}, - {"EraseArc", (PyCFunction)Qd_EraseArc, 1, - "(Rect r, short startAngle, short arcAngle) -> None"}, - {"InvertArc", (PyCFunction)Qd_InvertArc, 1, - "(Rect r, short startAngle, short arcAngle) -> None"}, - {"FillArc", (PyCFunction)Qd_FillArc, 1, - "(Rect r, short startAngle, short arcAngle, Pattern pat) -> None"}, - {"NewRgn", (PyCFunction)Qd_NewRgn, 1, - "() -> (RgnHandle _rv)"}, - {"OpenRgn", (PyCFunction)Qd_OpenRgn, 1, - "() -> None"}, - {"CloseRgn", (PyCFunction)Qd_CloseRgn, 1, - "(RgnHandle dstRgn) -> None"}, - {"BitMapToRegion", (PyCFunction)Qd_BitMapToRegion, 1, - "(RgnHandle region, BitMapPtr bMap) -> None"}, - {"DisposeRgn", (PyCFunction)Qd_DisposeRgn, 1, - "(RgnHandle rgn) -> None"}, - {"CopyRgn", (PyCFunction)Qd_CopyRgn, 1, - "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"}, - {"SetEmptyRgn", (PyCFunction)Qd_SetEmptyRgn, 1, - "(RgnHandle rgn) -> None"}, - {"SetRectRgn", (PyCFunction)Qd_SetRectRgn, 1, - "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"}, - {"RectRgn", (PyCFunction)Qd_RectRgn, 1, - "(RgnHandle rgn, Rect r) -> None"}, - {"OffsetRgn", (PyCFunction)Qd_OffsetRgn, 1, - "(RgnHandle rgn, short dh, short dv) -> None"}, - {"InsetRgn", (PyCFunction)Qd_InsetRgn, 1, - "(RgnHandle rgn, short dh, short dv) -> None"}, - {"SectRgn", (PyCFunction)Qd_SectRgn, 1, - "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, - {"UnionRgn", (PyCFunction)Qd_UnionRgn, 1, - "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, - {"DiffRgn", (PyCFunction)Qd_DiffRgn, 1, - "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, - {"XorRgn", (PyCFunction)Qd_XorRgn, 1, - "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, - {"RectInRgn", (PyCFunction)Qd_RectInRgn, 1, - "(Rect r, RgnHandle rgn) -> (Boolean _rv)"}, - {"EqualRgn", (PyCFunction)Qd_EqualRgn, 1, - "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"}, - {"EmptyRgn", (PyCFunction)Qd_EmptyRgn, 1, - "(RgnHandle rgn) -> (Boolean _rv)"}, - {"FrameRgn", (PyCFunction)Qd_FrameRgn, 1, - "(RgnHandle rgn) -> None"}, - {"PaintRgn", (PyCFunction)Qd_PaintRgn, 1, - "(RgnHandle rgn) -> None"}, - {"EraseRgn", (PyCFunction)Qd_EraseRgn, 1, - "(RgnHandle rgn) -> None"}, - {"InvertRgn", (PyCFunction)Qd_InvertRgn, 1, - "(RgnHandle rgn) -> None"}, - {"FillRgn", (PyCFunction)Qd_FillRgn, 1, - "(RgnHandle rgn, Pattern pat) -> None"}, - {"ScrollRect", (PyCFunction)Qd_ScrollRect, 1, - "(Rect r, short dh, short dv, RgnHandle updateRgn) -> None"}, - {"CopyBits", (PyCFunction)Qd_CopyBits, 1, - "(BitMapPtr srcBits, BitMapPtr dstBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"}, - {"CopyMask", (PyCFunction)Qd_CopyMask, 1, - "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect) -> None"}, - {"OpenPicture", (PyCFunction)Qd_OpenPicture, 1, - "(Rect picFrame) -> (PicHandle _rv)"}, - {"PicComment", (PyCFunction)Qd_PicComment, 1, - "(short kind, short dataSize, Handle dataHandle) -> None"}, - {"ClosePicture", (PyCFunction)Qd_ClosePicture, 1, - "() -> None"}, - {"DrawPicture", (PyCFunction)Qd_DrawPicture, 1, - "(PicHandle myPicture, Rect dstRect) -> None"}, - {"KillPicture", (PyCFunction)Qd_KillPicture, 1, - "(PicHandle myPicture) -> None"}, - {"OpenPoly", (PyCFunction)Qd_OpenPoly, 1, - "() -> (PolyHandle _rv)"}, - {"ClosePoly", (PyCFunction)Qd_ClosePoly, 1, - "() -> None"}, - {"KillPoly", (PyCFunction)Qd_KillPoly, 1, - "(PolyHandle poly) -> None"}, - {"OffsetPoly", (PyCFunction)Qd_OffsetPoly, 1, - "(PolyHandle poly, short dh, short dv) -> None"}, - {"FramePoly", (PyCFunction)Qd_FramePoly, 1, - "(PolyHandle poly) -> None"}, - {"PaintPoly", (PyCFunction)Qd_PaintPoly, 1, - "(PolyHandle poly) -> None"}, - {"ErasePoly", (PyCFunction)Qd_ErasePoly, 1, - "(PolyHandle poly) -> None"}, - {"InvertPoly", (PyCFunction)Qd_InvertPoly, 1, - "(PolyHandle poly) -> None"}, - {"FillPoly", (PyCFunction)Qd_FillPoly, 1, - "(PolyHandle poly, Pattern pat) -> None"}, - {"SetPt", (PyCFunction)Qd_SetPt, 1, - "(short h, short v) -> (Point pt)"}, - {"LocalToGlobal", (PyCFunction)Qd_LocalToGlobal, 1, - "(Point pt) -> (Point pt)"}, - {"GlobalToLocal", (PyCFunction)Qd_GlobalToLocal, 1, - "(Point pt) -> (Point pt)"}, - {"Random", (PyCFunction)Qd_Random, 1, - "() -> (short _rv)"}, - {"GetPixel", (PyCFunction)Qd_GetPixel, 1, - "(short h, short v) -> (Boolean _rv)"}, - {"ScalePt", (PyCFunction)Qd_ScalePt, 1, - "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"}, - {"MapPt", (PyCFunction)Qd_MapPt, 1, - "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"}, - {"MapRect", (PyCFunction)Qd_MapRect, 1, - "(Rect r, Rect srcRect, Rect dstRect) -> (Rect r)"}, - {"MapRgn", (PyCFunction)Qd_MapRgn, 1, - "(RgnHandle rgn, Rect srcRect, Rect dstRect) -> None"}, - {"MapPoly", (PyCFunction)Qd_MapPoly, 1, - "(PolyHandle poly, Rect srcRect, Rect dstRect) -> None"}, - {"StdBits", (PyCFunction)Qd_StdBits, 1, - "(BitMapPtr srcBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"}, - {"AddPt", (PyCFunction)Qd_AddPt, 1, - "(Point src, Point dst) -> (Point dst)"}, - {"EqualPt", (PyCFunction)Qd_EqualPt, 1, - "(Point pt1, Point pt2) -> (Boolean _rv)"}, - {"PtInRect", (PyCFunction)Qd_PtInRect, 1, - "(Point pt, Rect r) -> (Boolean _rv)"}, - {"Pt2Rect", (PyCFunction)Qd_Pt2Rect, 1, - "(Point pt1, Point pt2) -> (Rect dstRect)"}, - {"PtToAngle", (PyCFunction)Qd_PtToAngle, 1, - "(Rect r, Point pt) -> (short angle)"}, - {"SubPt", (PyCFunction)Qd_SubPt, 1, - "(Point src, Point dst) -> (Point dst)"}, - {"PtInRgn", (PyCFunction)Qd_PtInRgn, 1, - "(Point pt, RgnHandle rgn) -> (Boolean _rv)"}, - {"NewPixMap", (PyCFunction)Qd_NewPixMap, 1, - "() -> (PixMapHandle _rv)"}, - {"DisposePixMap", (PyCFunction)Qd_DisposePixMap, 1, - "(PixMapHandle pm) -> None"}, - {"CopyPixMap", (PyCFunction)Qd_CopyPixMap, 1, - "(PixMapHandle srcPM, PixMapHandle dstPM) -> None"}, - {"NewPixPat", (PyCFunction)Qd_NewPixPat, 1, - "() -> (PixPatHandle _rv)"}, - {"DisposePixPat", (PyCFunction)Qd_DisposePixPat, 1, - "(PixPatHandle pp) -> None"}, - {"CopyPixPat", (PyCFunction)Qd_CopyPixPat, 1, - "(PixPatHandle srcPP, PixPatHandle dstPP) -> None"}, - {"PenPixPat", (PyCFunction)Qd_PenPixPat, 1, - "(PixPatHandle pp) -> None"}, - {"BackPixPat", (PyCFunction)Qd_BackPixPat, 1, - "(PixPatHandle pp) -> None"}, - {"GetPixPat", (PyCFunction)Qd_GetPixPat, 1, - "(short patID) -> (PixPatHandle _rv)"}, - {"MakeRGBPat", (PyCFunction)Qd_MakeRGBPat, 1, - "(PixPatHandle pp, RGBColor myColor) -> None"}, - {"FillCRect", (PyCFunction)Qd_FillCRect, 1, - "(Rect r, PixPatHandle pp) -> None"}, - {"FillCOval", (PyCFunction)Qd_FillCOval, 1, - "(Rect r, PixPatHandle pp) -> None"}, - {"FillCRoundRect", (PyCFunction)Qd_FillCRoundRect, 1, - "(Rect r, short ovalWidth, short ovalHeight, PixPatHandle pp) -> None"}, - {"FillCArc", (PyCFunction)Qd_FillCArc, 1, - "(Rect r, short startAngle, short arcAngle, PixPatHandle pp) -> None"}, - {"FillCRgn", (PyCFunction)Qd_FillCRgn, 1, - "(RgnHandle rgn, PixPatHandle pp) -> None"}, - {"FillCPoly", (PyCFunction)Qd_FillCPoly, 1, - "(PolyHandle poly, PixPatHandle pp) -> None"}, - {"RGBForeColor", (PyCFunction)Qd_RGBForeColor, 1, - "(RGBColor color) -> None"}, - {"RGBBackColor", (PyCFunction)Qd_RGBBackColor, 1, - "(RGBColor color) -> None"}, - {"SetCPixel", (PyCFunction)Qd_SetCPixel, 1, - "(short h, short v, RGBColor cPix) -> None"}, - {"SetPortPix", (PyCFunction)Qd_SetPortPix, 1, - "(PixMapHandle pm) -> None"}, - {"GetCPixel", (PyCFunction)Qd_GetCPixel, 1, - "(short h, short v) -> (RGBColor cPix)"}, - {"GetForeColor", (PyCFunction)Qd_GetForeColor, 1, - "() -> (RGBColor color)"}, - {"GetBackColor", (PyCFunction)Qd_GetBackColor, 1, - "() -> (RGBColor color)"}, - {"OpColor", (PyCFunction)Qd_OpColor, 1, - "(RGBColor color) -> None"}, - {"HiliteColor", (PyCFunction)Qd_HiliteColor, 1, - "(RGBColor color) -> None"}, - {"AllocCursor", (PyCFunction)Qd_AllocCursor, 1, - "() -> None"}, - {"GetCTSeed", (PyCFunction)Qd_GetCTSeed, 1, - "() -> (long _rv)"}, - {"Color2Index", (PyCFunction)Qd_Color2Index, 1, - "(RGBColor myColor) -> (long _rv)"}, - {"Index2Color", (PyCFunction)Qd_Index2Color, 1, - "(long index) -> (RGBColor aColor)"}, - {"InvertColor", (PyCFunction)Qd_InvertColor, 1, - "() -> (RGBColor myColor)"}, - {"RealColor", (PyCFunction)Qd_RealColor, 1, - "(RGBColor color) -> (Boolean _rv)"}, - {"SetClientID", (PyCFunction)Qd_SetClientID, 1, - "(short id) -> None"}, - {"ProtectEntry", (PyCFunction)Qd_ProtectEntry, 1, - "(short index, Boolean protect) -> None"}, - {"ReserveEntry", (PyCFunction)Qd_ReserveEntry, 1, - "(short index, Boolean reserve) -> None"}, - {"QDError", (PyCFunction)Qd_QDError, 1, - "() -> (short _rv)"}, - {"CopyDeepMask", (PyCFunction)Qd_CopyDeepMask, 1, - "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"}, - {"GetPattern", (PyCFunction)Qd_GetPattern, 1, - "(short patternID) -> (PatHandle _rv)"}, - {"GetCursor", (PyCFunction)Qd_GetCursor, 1, - "(short cursorID) -> (CursHandle _rv)"}, - {"GetPicture", (PyCFunction)Qd_GetPicture, 1, - "(short pictureID) -> (PicHandle _rv)"}, - {"DeltaPoint", (PyCFunction)Qd_DeltaPoint, 1, - "(Point ptA, Point ptB) -> (long _rv)"}, - {"ShieldCursor", (PyCFunction)Qd_ShieldCursor, 1, - "(Rect shieldRect, Point offsetPt) -> None"}, - {"ScreenRes", (PyCFunction)Qd_ScreenRes, 1, - "() -> (short scrnHRes, short scrnVRes)"}, - {"GetIndPattern", (PyCFunction)Qd_GetIndPattern, 1, - "(short patternListID, short index) -> (Pattern thePat)"}, - {"TextFont", (PyCFunction)Qd_TextFont, 1, - "(short font) -> None"}, - {"TextFace", (PyCFunction)Qd_TextFace, 1, - "(short face) -> None"}, - {"TextMode", (PyCFunction)Qd_TextMode, 1, - "(short mode) -> None"}, - {"TextSize", (PyCFunction)Qd_TextSize, 1, - "(short size) -> None"}, - {"SpaceExtra", (PyCFunction)Qd_SpaceExtra, 1, - "(Fixed extra) -> None"}, - {"DrawChar", (PyCFunction)Qd_DrawChar, 1, - "(short ch) -> None"}, - {"DrawString", (PyCFunction)Qd_DrawString, 1, - "(Str255 s) -> None"}, - {"DrawText", (PyCFunction)Qd_DrawText, 1, - "(Buffer textBuf, short firstByte, short byteCount) -> None"}, - {"CharWidth", (PyCFunction)Qd_CharWidth, 1, - "(short ch) -> (short _rv)"}, - {"StringWidth", (PyCFunction)Qd_StringWidth, 1, - "(Str255 s) -> (short _rv)"}, - {"TextWidth", (PyCFunction)Qd_TextWidth, 1, - "(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"}, - {"GetFontInfo", (PyCFunction)Qd_GetFontInfo, 1, - "() -> (FontInfo info)"}, - {"CharExtra", (PyCFunction)Qd_CharExtra, 1, - "(Fixed extra) -> None"}, - {"BitMap", (PyCFunction)Qd_BitMap, 1, - "Take (string, int, Rect) argument and create BitMap"}, - {"RawBitMap", (PyCFunction)Qd_RawBitMap, 1, - "Take string BitMap and turn into BitMap object"}, - {NULL, NULL, 0} -}; - - - - -void initQd() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Qd", Qd_methods); - d = PyModule_GetDict(m); - Qd_Error = PyMac_GetOSErrException(); - if (Qd_Error == NULL || - PyDict_SetItemString(d, "Error", Qd_Error) != 0) - Py_FatalError("can't initialize Qd.Error"); - - { - PyObject *o; - - o = QDGA_New(); - if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0) - Py_FatalError("can't initialize Qd.qd"); - } - - -} - -/* ========================= End module Qd ========================== */ - diff --git a/Mac/Modules/qd/qdedit.py b/Mac/Modules/qd/qdedit.py deleted file mode 100644 index 2242c5a355..0000000000 --- a/Mac/Modules/qd/qdedit.py +++ /dev/null @@ -1,29 +0,0 @@ -f = Function(void, 'GlobalToLocal', - (Point, 'thePoint', InOutMode), -) -functions.append(f) - -f = Function(void, 'LocalToGlobal', - (Point, 'thePoint', InOutMode), -) -functions.append(f) - -f = Function(void, 'SetPort', - (WindowPtr, 'thePort', InMode), -) -functions.append(f) - -f = Function(void, 'ClipRect', - (Rect, 'r', InMode), -) -functions.append(f) - -f = Function(void, 'EraseRect', - (Rect, 'r', InMode), -) -functions.append(f) - -f = Function(void, 'OpenDeskAcc', - (Str255, 'name', InMode), -) -functions.append(f) diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py deleted file mode 100644 index 4155df0130..0000000000 --- a/Mac/Modules/qd/qdscan.py +++ /dev/null @@ -1,139 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -def main(): - input = "QuickDraw.h" - output = "qdgen.py" - defsoutput = TOOLBOXDIR + "QuickDraw.py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - - # Grmpf. Universal Headers have Text-stuff in a different include file... - input = "QuickDrawText.h" - output = "@qdgentext.py" - defsoutput = "@QuickDrawText.py" - have_extra = 0 - try: - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - have_extra = 1 - except IOError: - pass - if have_extra: - print "=== Copying QuickDrawText stuff into main files... ===" - ifp = open("@qdgentext.py") - ofp = open("qdgen.py", "a") - ofp.write(ifp.read()) - ifp.close() - ofp.close() - ifp = open("@QuickDrawText.py") - ofp = open(TOOLBOXDIR + "QuickDraw.py", "a") - ofp.write(ifp.read()) - ifp.close() - ofp.close() - - print "=== Done scanning and generating, now importing the generated code... ===" - import qdsupport - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] -## elif t == "PolyHandle" and m == "InMode": -## classname = "Method" -## listname = "p_methods" -## elif t == "RgnHandle" and m == "InMode": -## classname = "Method" -## listname = "r_methods" - return classname, listname - - def makeblacklistnames(self): - return [ - 'InitGraf', - 'StuffHex', - 'StdLine', - 'StdComment', - 'StdGetPic', - 'OpenPort', - 'InitPort', - 'ClosePort', - 'OpenCPort', - 'InitCPort', - 'CloseCPort', - 'BitMapToRegionGlue', - ] - - def makeblacklisttypes(self): - return [ - 'CCrsrHandle', - 'CIconHandle', - 'CQDProcs', - 'CSpecArray', - 'CTabHandle', - 'ColorComplementProcPtr', - 'ColorComplementUPP', - 'ColorSearchProcPtr', - 'ColorSearchUPP', - 'ConstPatternParam', - 'DeviceLoopDrawingProcPtr', - 'DeviceLoopFlags', -## 'FontInfo', - 'GDHandle', - 'GrafVerb', - 'OpenCPicParams_ptr', - 'Ptr', - 'QDProcs', - 'ReqListRec', - 'void_ptr', - ] - - def makerepairinstructions(self): - return [ - ([('void_ptr', 'textBuf', 'InMode'), - ('short', 'firstByte', 'InMode'), - ('short', 'byteCount', 'InMode')], - [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]), - - # GetPen and SetPt use a point-pointer as output-only: - ('GetPen', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]), - ('SetPt', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]), - - # All others use it as input/output: - ([('Point', '*', 'OutMode')], - [('*', '*', 'InOutMode')]), - - # InsetRect, OffsetRect - ([('Rect', 'r', 'OutMode'), - ('short', 'dh', 'InMode'), - ('short', 'dv', 'InMode')], - [('Rect', 'r', 'InOutMode'), - ('short', 'dh', 'InMode'), - ('short', 'dv', 'InMode')]), - - # MapRect - ([('Rect', 'r', 'OutMode'), - ('Rect_ptr', 'srcRect', 'InMode'), - ('Rect_ptr', 'dstRect', 'InMode')], - [('Rect', 'r', 'InOutMode'), - ('Rect_ptr', 'srcRect', 'InMode'), - ('Rect_ptr', 'dstRect', 'InMode')]), - - # CopyBits and friends - ([('RgnHandle', 'maskRgn', 'InMode')], - [('OptRgnHandle', 'maskRgn', 'InMode')]), - - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py deleted file mode 100644 index 61e7dd852d..0000000000 --- a/Mac/Modules/qd/qdsupport.py +++ /dev/null @@ -1,374 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -# Declarations that change for each manager -MACHEADERFILE = 'QuickDraw.h' # The Apple header file -MODNAME = 'Qd' # The name of the module -OBJECTNAME = 'Graf' # The basic name of the objects used here - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -EXTRAFILE = string.lower(MODPREFIX) + 'edit.py' # A similar file but hand-made -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -class TextThingieClass(FixedInputBufferType): - def getargsCheck(self, name): - pass - -TextThingie = TextThingieClass(None) - -# These are temporary! -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") -OptRgnHandle = OpaqueByValueType("RgnHandle", "OptResObj") -PicHandle = OpaqueByValueType("PicHandle", "ResObj") -PolyHandle = OpaqueByValueType("PolyHandle", "ResObj") -PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj") -PixPatHandle = OpaqueByValueType("PixPatHandle", "ResObj") -PatHandle = OpaqueByValueType("PatHandle", "ResObj") -CursHandle = OpaqueByValueType("CursHandle", "ResObj") -CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj") -GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj") -BitMap_ptr = OpaqueByValueType("BitMapPtr", "BMObj") -RGBColor = OpaqueType('RGBColor', 'QdRGB') -RGBColor_ptr = RGBColor -FontInfo = OpaqueType('FontInfo', 'QdFI') - -Cursor_ptr = StructInputBufferType('Cursor') -Pattern = StructOutputBufferType('Pattern') -Pattern_ptr = StructInputBufferType('Pattern') -PenState = StructOutputBufferType('PenState') -PenState_ptr = StructInputBufferType('PenState') - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -/* -** Parse/generate RGB records -*/ -PyObject *QdRGB_New(itself) - RGBColorPtr itself; -{ - - return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue); -} - -QdRGB_Convert(v, p_itself) - PyObject *v; - RGBColorPtr p_itself; -{ - long red, green, blue; - - if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) ) - return 0; - p_itself->red = (unsigned short)red; - p_itself->green = (unsigned short)green; - p_itself->blue = (unsigned short)blue; - return 1; -} - -/* -** Generate FontInfo records -*/ -static -PyObject *QdFI_New(itself) - FontInfo *itself; -{ - - return Py_BuildValue("hhhh", itself->ascent, itself->descent, - itself->widMax, itself->leading); -} - - -""" - -variablestuff = """ -{ - PyObject *o; - - o = QDGA_New(); - if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0) - Py_FatalError("can't initialize Qd.qd"); -} -""" - -## not yet... -## -##class Region_ObjectDefinition(GlobalObjectDefinition): -## def outputCheckNewArg(self): -## Output("if (itself == NULL) return PyMac_Error(resNotFound);") -## def outputFreeIt(self, itselfname): -## Output("DisposeRegion(%s);", itselfname) -## -##class Polygon_ObjectDefinition(GlobalObjectDefinition): -## def outputCheckNewArg(self): -## Output("if (itself == NULL) return PyMac_Error(resNotFound);") -## def outputFreeIt(self, itselfname): -## Output("KillPoly(%s);", itselfname) - -class MyGRObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("if (itself == NULL) return PyMac_Error(resNotFound);") - def outputCheckConvertArg(self): - OutLbrace("if (DlgObj_Check(v) || WinObj_Check(v))") - Output("*p_itself = ((GrafPortObject *)v)->ob_itself;") - Output("return 1;") - OutRbrace() - def outputGetattrHook(self): - Output(""" - { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; - - if ( strcmp(name, "data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort)); - - if ( (itself_color->portVersion&0xc000) == 0xc000 ) { - /* Color-only attributes */ - - if ( strcmp(name, "portBits") == 0 ) - /* XXXX Do we need HLock() stuff here?? */ - return BMObj_New((BitMapPtr)*itself_color->portPixMap); - if ( strcmp(name, "grafVars") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn); - if ( strcmp(name, "chExtra") == 0 ) - return Py_BuildValue("h", itself_color->chExtra); - if ( strcmp(name, "pnLocHFrac") == 0 ) - return Py_BuildValue("h", itself_color->pnLocHFrac); - if ( strcmp(name, "bkPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat); - if ( strcmp(name, "rgbFgColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor); - if ( strcmp(name, "rgbBkColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor); - if ( strcmp(name, "pnPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat); - if ( strcmp(name, "fillPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat); - } else { - /* Mono-only attributes */ - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New(&self->ob_itself->portBits); - if ( strcmp(name, "bkPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern)); - if ( strcmp(name, "fillPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern)); - if ( strcmp(name, "pnPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern)); - } - /* - ** Accessible for both color/mono windows. - ** portVersion is really color-only, but we put it here - ** for convenience - */ - if ( strcmp(name, "portVersion") == 0 ) - return Py_BuildValue("h", itself_color->portVersion); - if ( strcmp(name, "device") == 0 ) - return PyInt_FromLong((long)self->ob_itself->device); - if ( strcmp(name, "portRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect); - if ( strcmp(name, "visRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn); - if ( strcmp(name, "clipRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn); - if ( strcmp(name, "pnLoc") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc); - if ( strcmp(name, "pnSize") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize); - if ( strcmp(name, "pnMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnMode); - if ( strcmp(name, "pnVis") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnVis); - if ( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", self->ob_itself->txFont); - if ( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (short)self->ob_itself->txFace); - if ( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->txMode); - if ( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", self->ob_itself->txSize); - if ( strcmp(name, "spExtra") == 0 ) - return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra); - /* XXXX Add more, as needed */ - /* This one is so we can compare grafports: */ - if ( strcmp(name, "_id") == 0 ) - return Py_BuildValue("l", (long)self->ob_itself); - }""") - -class MyBMObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("if (itself == NULL) return PyMac_Error(resNotFound);") - def outputStructMembers(self): - # We need to more items: a pointer to privately allocated data - # and a python object we're referring to. - Output("%s ob_itself;", self.itselftype) - Output("PyObject *referred_object;") - Output("BitMap *referred_bitmap;") - def outputInitStructMembers(self): - Output("it->ob_itself = %sitself;", self.argref) - Output("it->referred_object = NULL;") - Output("it->referred_bitmap = NULL;") - def outputCleanupStructMembers(self): - Output("Py_XDECREF(self->referred_object);") - Output("if (self->referred_bitmap) free(self->referred_bitmap);") - def outputGetattrHook(self): - Output("""if ( strcmp(name, "baseAddr") == 0 ) - return PyInt_FromLong((long)self->ob_itself->baseAddr); - if ( strcmp(name, "rowBytes") == 0 ) - return PyInt_FromLong((long)self->ob_itself->rowBytes); - if ( strcmp(name, "bounds") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds); - /* XXXX Add more, as needed */ - if ( strcmp(name, "bitmap_data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap)); - if ( strcmp(name, "pixmap_data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap)); - """) - -# This object is instanciated once, and will access qd globals. -class QDGlobalsAccessObjectDefinition(ObjectDefinition): - def outputStructMembers(self): - pass - def outputNew(self): - Output() - Output("%sPyObject *%s_New()", self.static, self.prefix) - OutLbrace() - Output("%s *it;", self.objecttype) - Output("it = PyObject_NEW(%s, &%s);", self.objecttype, self.typename) - Output("if (it == NULL) return NULL;") - Output("return (PyObject *)it;") - OutRbrace() - def outputConvert(self): - pass - def outputCleanupStructMembers(self): - pass - - def outputGetattrHook(self): - Output(""" - if ( strcmp(name, "arrow") == 0 ) - return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow)); - if ( strcmp(name, "black") == 0 ) - return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black)); - if ( strcmp(name, "white") == 0 ) - return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white)); - if ( strcmp(name, "gray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray)); - if ( strcmp(name, "ltGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray)); - if ( strcmp(name, "dkGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray)); - if ( strcmp(name, "screenBits") == 0 ) - return BMObj_New(&qd.screenBits); - if ( strcmp(name, "thePort") == 0 ) - return GrafObj_New(qd.thePort); - if ( strcmp(name, "randSeed") == 0 ) - return Py_BuildValue("l", &qd.randSeed); - """) - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff) -##r_object = Region_ObjectDefinition('Region', 'QdRgn', 'RgnHandle') -##po_object = Polygon_ObjectDefinition('Polygon', 'QdPgn', 'PolyHandle') -##module.addobject(r_object) -##module.addobject(po_object) -gr_object = MyGRObjectDefinition("GrafPort", "GrafObj", "GrafPtr") -module.addobject(gr_object) -bm_object = MyBMObjectDefinition("BitMap", "BMObj", "BitMapPtr") -module.addobject(bm_object) -qd_object = QDGlobalsAccessObjectDefinition("QDGlobalsAccess", "QDGA", "XXXX") -module.addobject(qd_object) - - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile(INPUTFILE) -#execfile(EXTRAFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -##for f in r_methods: r_object.add(f) -##for f in po_methods: po_object.add(f) - -# -# We manually generate a routine to create a BitMap from python data. -# -BitMap_body = """ -BitMap *ptr; -PyObject *source; -Rect bounds; -int rowbytes; -char *data; - -if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect, - &bounds) ) - return NULL; -data = PyString_AsString(source); -if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL ) - return PyErr_NoMemory(); -ptr->baseAddr = (Ptr)data; -ptr->rowBytes = rowbytes; -ptr->bounds = bounds; -if ( (_res = BMObj_New(ptr)) == NULL ) { - free(ptr); - return NULL; -} -((BitMapObject *)_res)->referred_object = source; -Py_INCREF(source); -((BitMapObject *)_res)->referred_bitmap = ptr; -return _res; -""" - -f = ManualGenerator("BitMap", BitMap_body) -f.docstring = lambda: """Take (string, int, Rect) argument and create BitMap""" -module.add(f) - -# -# And again, for turning a correctly-formatted structure into the object -# -RawBitMap_body = """ -BitMap *ptr; -PyObject *source; - -if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) ) - return NULL; -if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) { - PyErr_BadArgument(); - return NULL; -} -ptr = (BitMapPtr)PyString_AsString(source); -if ( (_res = BMObj_New(ptr)) == NULL ) { - return NULL; -} -((BitMapObject *)_res)->referred_object = source; -Py_INCREF(source); -return _res; -""" - -f = ManualGenerator("RawBitMap", RawBitMap_body) -f.docstring = lambda: """Take string BitMap and turn into BitMap object""" -module.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() -SetOutputFile() # Close it diff --git a/Mac/Modules/qt/Qtmodule.c b/Mac/Modules/qt/Qtmodule.c deleted file mode 100644 index ffba461dd9..0000000000 --- a/Mac/Modules/qt/Qtmodule.c +++ /dev/null @@ -1,6007 +0,0 @@ - -/* =========================== Module Qt ============================ */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -/* Exported by Cmmodule.c: */ -extern PyObject *CmpObj_New(Component); -extern int CmpObj_Convert(PyObject *, Component *); -extern PyObject *CmpInstObj_New(ComponentInstance); -extern int CmpInstObj_Convert(PyObject *, ComponentInstance *); - -/* Exported by Qdmodule.c: */ -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); - -/* Our own, used before defined: */ -staticforward PyObject *TrackObj_New(Track); -staticforward int TrackObj_Convert(PyObject *, Track *); -staticforward PyObject *MovieObj_New(Movie); -staticforward int MovieObj_Convert(PyObject *, Movie *); -staticforward PyObject *MovieCtlObj_New(MovieController); -staticforward int MovieCtlObj_Convert(PyObject *, MovieController *); - - - -static PyObject *Qt_Error; - -/* ------------------ Object type MovieController ------------------- */ - -PyTypeObject MovieController_Type; - -#define MovieCtlObj_Check(x) ((x)->ob_type == &MovieController_Type) - -typedef struct MovieControllerObject { - PyObject_HEAD - MovieController ob_itself; -} MovieControllerObject; - -PyObject *MovieCtlObj_New(itself) - MovieController itself; -{ - MovieControllerObject *it; - if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null MovieController"); - return NULL; - } - it = PyObject_NEW(MovieControllerObject, &MovieController_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -MovieCtlObj_Convert(v, p_itself) - PyObject *v; - MovieController *p_itself; -{ - if (!MovieCtlObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "MovieController required"); - return 0; - } - *p_itself = ((MovieControllerObject *)v)->ob_itself; - return 1; -} - -static void MovieCtlObj_dealloc(self) - MovieControllerObject *self; -{ - DisposeMovieController(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *MovieCtlObj_MCSetMovie(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Movie theMovie; - WindowPtr movieWindow; - Point where; - if (!PyArg_ParseTuple(_args, "O&O&O&", - MovieObj_Convert, &theMovie, - WinObj_Convert, &movieWindow, - PyMac_GetPoint, &where)) - return NULL; - _rv = MCSetMovie(_self->ob_itself, - theMovie, - movieWindow, - where); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetIndMovie(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - short index; - if (!PyArg_ParseTuple(_args, "h", - &index)) - return NULL; - _rv = MCGetIndMovie(_self->ob_itself, - index); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCRemoveMovie(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCRemoveMovie(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCIsPlayerEvent(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - EventRecord e; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetEventRecord, &e)) - return NULL; - _rv = MCIsPlayerEvent(_self->ob_itself, - &e); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCDoAction(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - short action; - void * params; - if (!PyArg_ParseTuple(_args, "hs", - &action, - ¶ms)) - return NULL; - _rv = MCDoAction(_self->ob_itself, - action, - params); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCSetControllerAttached(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Boolean attach; - if (!PyArg_ParseTuple(_args, "b", - &attach)) - return NULL; - _rv = MCSetControllerAttached(_self->ob_itself, - attach); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCIsControllerAttached(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCIsControllerAttached(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCSetVisible(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Boolean visible; - if (!PyArg_ParseTuple(_args, "b", - &visible)) - return NULL; - _rv = MCSetVisible(_self->ob_itself, - visible); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetVisible(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCGetVisible(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetControllerBoundsRect(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Rect bounds; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCGetControllerBoundsRect(_self->ob_itself, - &bounds); - _res = Py_BuildValue("lO&", - _rv, - PyMac_BuildRect, &bounds); - return _res; -} - -static PyObject *MovieCtlObj_MCSetControllerBoundsRect(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Rect bounds; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &bounds)) - return NULL; - _rv = MCSetControllerBoundsRect(_self->ob_itself, - &bounds); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetControllerBoundsRgn(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCGetControllerBoundsRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetWindowRgn(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - WindowPtr w; - if (!PyArg_ParseTuple(_args, "O&", - WinObj_Convert, &w)) - return NULL; - _rv = MCGetWindowRgn(_self->ob_itself, - w); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCMovieChanged(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Movie m; - if (!PyArg_ParseTuple(_args, "O&", - MovieObj_Convert, &m)) - return NULL; - _rv = MCMovieChanged(_self->ob_itself, - m); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCSetDuration(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "l", - &duration)) - return NULL; - _rv = MCSetDuration(_self->ob_itself, - duration); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetCurrentTime(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue _rv; - TimeScale scale; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCGetCurrentTime(_self->ob_itself, - &scale); - _res = Py_BuildValue("ll", - _rv, - scale); - return _res; -} - -static PyObject *MovieCtlObj_MCNewAttachedController(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Movie theMovie; - WindowPtr w; - Point where; - if (!PyArg_ParseTuple(_args, "O&O&O&", - MovieObj_Convert, &theMovie, - WinObj_Convert, &w, - PyMac_GetPoint, &where)) - return NULL; - _rv = MCNewAttachedController(_self->ob_itself, - theMovie, - w, - where); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCDraw(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - WindowPtr w; - if (!PyArg_ParseTuple(_args, "O&", - WinObj_Convert, &w)) - return NULL; - _rv = MCDraw(_self->ob_itself, - w); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCActivate(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - WindowPtr w; - Boolean activate; - if (!PyArg_ParseTuple(_args, "O&b", - WinObj_Convert, &w, - &activate)) - return NULL; - _rv = MCActivate(_self->ob_itself, - w, - activate); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCIdle(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCIdle(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCKey(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - SInt8 key; - long modifiers; - if (!PyArg_ParseTuple(_args, "bl", - &key, - &modifiers)) - return NULL; - _rv = MCKey(_self->ob_itself, - key, - modifiers); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCClick(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - WindowPtr w; - Point where; - long when; - long modifiers; - if (!PyArg_ParseTuple(_args, "O&O&ll", - WinObj_Convert, &w, - PyMac_GetPoint, &where, - &when, - &modifiers)) - return NULL; - _rv = MCClick(_self->ob_itself, - w, - where, - when, - modifiers); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCEnableEditing(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Boolean enabled; - if (!PyArg_ParseTuple(_args, "b", - &enabled)) - return NULL; - _rv = MCEnableEditing(_self->ob_itself, - enabled); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCIsEditingEnabled(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCIsEditingEnabled(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCCopy(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCCopy(_self->ob_itself); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCCut(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCCut(_self->ob_itself); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCPaste(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Movie srcMovie; - if (!PyArg_ParseTuple(_args, "O&", - MovieObj_Convert, &srcMovie)) - return NULL; - _rv = MCPaste(_self->ob_itself, - srcMovie); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCClear(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCClear(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCUndo(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCUndo(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCPositionController(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Rect movieRect; - Rect controllerRect; - long someFlags; - if (!PyArg_ParseTuple(_args, "O&O&l", - PyMac_GetRect, &movieRect, - PyMac_GetRect, &controllerRect, - &someFlags)) - return NULL; - _rv = MCPositionController(_self->ob_itself, - &movieRect, - &controllerRect, - someFlags); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetControllerInfo(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - long someFlags; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCGetControllerInfo(_self->ob_itself, - &someFlags); - _res = Py_BuildValue("ll", - _rv, - someFlags); - return _res; -} - -static PyObject *MovieCtlObj_MCSetClip(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - RgnHandle theClip; - RgnHandle movieClip; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &theClip, - ResObj_Convert, &movieClip)) - return NULL; - _rv = MCSetClip(_self->ob_itself, - theClip, - movieClip); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetClip(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - RgnHandle theClip; - RgnHandle movieClip; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MCGetClip(_self->ob_itself, - &theClip, - &movieClip); - _res = Py_BuildValue("lO&O&", - _rv, - ResObj_New, theClip, - ResObj_New, movieClip); - return _res; -} - -static PyObject *MovieCtlObj_MCDrawBadge(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - RgnHandle movieRgn; - RgnHandle badgeRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &movieRgn)) - return NULL; - _rv = MCDrawBadge(_self->ob_itself, - movieRgn, - &badgeRgn); - _res = Py_BuildValue("lO&", - _rv, - ResObj_New, badgeRgn); - return _res; -} - -static PyObject *MovieCtlObj_MCSetUpEditMenu(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - long modifiers; - MenuHandle mh; - if (!PyArg_ParseTuple(_args, "lO&", - &modifiers, - MenuObj_Convert, &mh)) - return NULL; - _rv = MCSetUpEditMenu(_self->ob_itself, - modifiers, - mh); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieCtlObj_MCGetMenuString(_self, _args) - MovieControllerObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - long modifiers; - short item; - Str255 aString; - if (!PyArg_ParseTuple(_args, "lhO&", - &modifiers, - &item, - PyMac_GetStr255, aString)) - return NULL; - _rv = MCGetMenuString(_self->ob_itself, - modifiers, - item, - aString); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyMethodDef MovieCtlObj_methods[] = { - {"MCSetMovie", (PyCFunction)MovieCtlObj_MCSetMovie, 1, - "(Movie theMovie, WindowPtr movieWindow, Point where) -> (ComponentResult _rv)"}, - {"MCGetIndMovie", (PyCFunction)MovieCtlObj_MCGetIndMovie, 1, - "(short index) -> (Movie _rv)"}, - {"MCRemoveMovie", (PyCFunction)MovieCtlObj_MCRemoveMovie, 1, - "() -> (ComponentResult _rv)"}, - {"MCIsPlayerEvent", (PyCFunction)MovieCtlObj_MCIsPlayerEvent, 1, - "(EventRecord e) -> (ComponentResult _rv)"}, - {"MCDoAction", (PyCFunction)MovieCtlObj_MCDoAction, 1, - "(short action, void * params) -> (ComponentResult _rv)"}, - {"MCSetControllerAttached", (PyCFunction)MovieCtlObj_MCSetControllerAttached, 1, - "(Boolean attach) -> (ComponentResult _rv)"}, - {"MCIsControllerAttached", (PyCFunction)MovieCtlObj_MCIsControllerAttached, 1, - "() -> (ComponentResult _rv)"}, - {"MCSetVisible", (PyCFunction)MovieCtlObj_MCSetVisible, 1, - "(Boolean visible) -> (ComponentResult _rv)"}, - {"MCGetVisible", (PyCFunction)MovieCtlObj_MCGetVisible, 1, - "() -> (ComponentResult _rv)"}, - {"MCGetControllerBoundsRect", (PyCFunction)MovieCtlObj_MCGetControllerBoundsRect, 1, - "() -> (ComponentResult _rv, Rect bounds)"}, - {"MCSetControllerBoundsRect", (PyCFunction)MovieCtlObj_MCSetControllerBoundsRect, 1, - "(Rect bounds) -> (ComponentResult _rv)"}, - {"MCGetControllerBoundsRgn", (PyCFunction)MovieCtlObj_MCGetControllerBoundsRgn, 1, - "() -> (RgnHandle _rv)"}, - {"MCGetWindowRgn", (PyCFunction)MovieCtlObj_MCGetWindowRgn, 1, - "(WindowPtr w) -> (RgnHandle _rv)"}, - {"MCMovieChanged", (PyCFunction)MovieCtlObj_MCMovieChanged, 1, - "(Movie m) -> (ComponentResult _rv)"}, - {"MCSetDuration", (PyCFunction)MovieCtlObj_MCSetDuration, 1, - "(TimeValue duration) -> (ComponentResult _rv)"}, - {"MCGetCurrentTime", (PyCFunction)MovieCtlObj_MCGetCurrentTime, 1, - "() -> (TimeValue _rv, TimeScale scale)"}, - {"MCNewAttachedController", (PyCFunction)MovieCtlObj_MCNewAttachedController, 1, - "(Movie theMovie, WindowPtr w, Point where) -> (ComponentResult _rv)"}, - {"MCDraw", (PyCFunction)MovieCtlObj_MCDraw, 1, - "(WindowPtr w) -> (ComponentResult _rv)"}, - {"MCActivate", (PyCFunction)MovieCtlObj_MCActivate, 1, - "(WindowPtr w, Boolean activate) -> (ComponentResult _rv)"}, - {"MCIdle", (PyCFunction)MovieCtlObj_MCIdle, 1, - "() -> (ComponentResult _rv)"}, - {"MCKey", (PyCFunction)MovieCtlObj_MCKey, 1, - "(SInt8 key, long modifiers) -> (ComponentResult _rv)"}, - {"MCClick", (PyCFunction)MovieCtlObj_MCClick, 1, - "(WindowPtr w, Point where, long when, long modifiers) -> (ComponentResult _rv)"}, - {"MCEnableEditing", (PyCFunction)MovieCtlObj_MCEnableEditing, 1, - "(Boolean enabled) -> (ComponentResult _rv)"}, - {"MCIsEditingEnabled", (PyCFunction)MovieCtlObj_MCIsEditingEnabled, 1, - "() -> (long _rv)"}, - {"MCCopy", (PyCFunction)MovieCtlObj_MCCopy, 1, - "() -> (Movie _rv)"}, - {"MCCut", (PyCFunction)MovieCtlObj_MCCut, 1, - "() -> (Movie _rv)"}, - {"MCPaste", (PyCFunction)MovieCtlObj_MCPaste, 1, - "(Movie srcMovie) -> (ComponentResult _rv)"}, - {"MCClear", (PyCFunction)MovieCtlObj_MCClear, 1, - "() -> (ComponentResult _rv)"}, - {"MCUndo", (PyCFunction)MovieCtlObj_MCUndo, 1, - "() -> (ComponentResult _rv)"}, - {"MCPositionController", (PyCFunction)MovieCtlObj_MCPositionController, 1, - "(Rect movieRect, Rect controllerRect, long someFlags) -> (ComponentResult _rv)"}, - {"MCGetControllerInfo", (PyCFunction)MovieCtlObj_MCGetControllerInfo, 1, - "() -> (ComponentResult _rv, long someFlags)"}, - {"MCSetClip", (PyCFunction)MovieCtlObj_MCSetClip, 1, - "(RgnHandle theClip, RgnHandle movieClip) -> (ComponentResult _rv)"}, - {"MCGetClip", (PyCFunction)MovieCtlObj_MCGetClip, 1, - "() -> (ComponentResult _rv, RgnHandle theClip, RgnHandle movieClip)"}, - {"MCDrawBadge", (PyCFunction)MovieCtlObj_MCDrawBadge, 1, - "(RgnHandle movieRgn) -> (ComponentResult _rv, RgnHandle badgeRgn)"}, - {"MCSetUpEditMenu", (PyCFunction)MovieCtlObj_MCSetUpEditMenu, 1, - "(long modifiers, MenuHandle mh) -> (ComponentResult _rv)"}, - {"MCGetMenuString", (PyCFunction)MovieCtlObj_MCGetMenuString, 1, - "(long modifiers, short item, Str255 aString) -> (ComponentResult _rv)"}, - {NULL, NULL, 0} -}; - -PyMethodChain MovieCtlObj_chain = { MovieCtlObj_methods, NULL }; - -static PyObject *MovieCtlObj_getattr(self, name) - MovieControllerObject *self; - char *name; -{ - return Py_FindMethodInChain(&MovieCtlObj_chain, (PyObject *)self, name); -} - -#define MovieCtlObj_setattr NULL - -PyTypeObject MovieController_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "MovieController", /*tp_name*/ - sizeof(MovieControllerObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) MovieCtlObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) MovieCtlObj_getattr, /*tp_getattr*/ - (setattrfunc) MovieCtlObj_setattr, /*tp_setattr*/ -}; - -/* ---------------- End object type MovieController ----------------- */ - - -/* ---------------------- Object type TimeBase ---------------------- */ - -PyTypeObject TimeBase_Type; - -#define TimeBaseObj_Check(x) ((x)->ob_type == &TimeBase_Type) - -typedef struct TimeBaseObject { - PyObject_HEAD - TimeBase ob_itself; -} TimeBaseObject; - -PyObject *TimeBaseObj_New(itself) - TimeBase itself; -{ - TimeBaseObject *it; - if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null TimeBase"); - return NULL; - } - it = PyObject_NEW(TimeBaseObject, &TimeBase_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -TimeBaseObj_Convert(v, p_itself) - PyObject *v; - TimeBase *p_itself; -{ - if (!TimeBaseObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "TimeBase required"); - return 0; - } - *p_itself = ((TimeBaseObject *)v)->ob_itself; - return 1; -} - -static void TimeBaseObj_dealloc(self) - TimeBaseObject *self; -{ - DisposeTimeBase(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *TimeBaseObj_SetTimeBaseValue(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue t; - TimeScale s; - if (!PyArg_ParseTuple(_args, "ll", - &t, - &s)) - return NULL; - SetTimeBaseValue(_self->ob_itself, - t, - s); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TimeBaseObj_GetTimeBaseRate(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTimeBaseRate(_self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildFixed, _rv); - return _res; -} - -static PyObject *TimeBaseObj_SetTimeBaseRate(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetFixed, &r)) - return NULL; - SetTimeBaseRate(_self->ob_itself, - r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TimeBaseObj_GetTimeBaseFlags(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTimeBaseFlags(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TimeBaseObj_SetTimeBaseFlags(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long timeBaseFlags; - if (!PyArg_ParseTuple(_args, "l", - &timeBaseFlags)) - return NULL; - SetTimeBaseFlags(_self->ob_itself, - timeBaseFlags); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TimeBaseObj_GetTimeBaseMasterTimeBase(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeBase _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTimeBaseMasterTimeBase(_self->ob_itself); - _res = Py_BuildValue("O&", - TimeBaseObj_New, _rv); - return _res; -} - -static PyObject *TimeBaseObj_GetTimeBaseMasterClock(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentInstance _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTimeBaseMasterClock(_self->ob_itself); - _res = Py_BuildValue("O&", - CmpInstObj_New, _rv); - return _res; -} - -static PyObject *TimeBaseObj_GetTimeBaseEffectiveRate(_self, _args) - TimeBaseObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTimeBaseEffectiveRate(_self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildFixed, _rv); - return _res; -} - -static PyMethodDef TimeBaseObj_methods[] = { - {"SetTimeBaseValue", (PyCFunction)TimeBaseObj_SetTimeBaseValue, 1, - "(TimeValue t, TimeScale s) -> None"}, - {"GetTimeBaseRate", (PyCFunction)TimeBaseObj_GetTimeBaseRate, 1, - "() -> (Fixed _rv)"}, - {"SetTimeBaseRate", (PyCFunction)TimeBaseObj_SetTimeBaseRate, 1, - "(Fixed r) -> None"}, - {"GetTimeBaseFlags", (PyCFunction)TimeBaseObj_GetTimeBaseFlags, 1, - "() -> (long _rv)"}, - {"SetTimeBaseFlags", (PyCFunction)TimeBaseObj_SetTimeBaseFlags, 1, - "(long timeBaseFlags) -> None"}, - {"GetTimeBaseMasterTimeBase", (PyCFunction)TimeBaseObj_GetTimeBaseMasterTimeBase, 1, - "() -> (TimeBase _rv)"}, - {"GetTimeBaseMasterClock", (PyCFunction)TimeBaseObj_GetTimeBaseMasterClock, 1, - "() -> (ComponentInstance _rv)"}, - {"GetTimeBaseEffectiveRate", (PyCFunction)TimeBaseObj_GetTimeBaseEffectiveRate, 1, - "() -> (Fixed _rv)"}, - {NULL, NULL, 0} -}; - -PyMethodChain TimeBaseObj_chain = { TimeBaseObj_methods, NULL }; - -static PyObject *TimeBaseObj_getattr(self, name) - TimeBaseObject *self; - char *name; -{ - return Py_FindMethodInChain(&TimeBaseObj_chain, (PyObject *)self, name); -} - -#define TimeBaseObj_setattr NULL - -PyTypeObject TimeBase_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "TimeBase", /*tp_name*/ - sizeof(TimeBaseObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) TimeBaseObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) TimeBaseObj_getattr, /*tp_getattr*/ - (setattrfunc) TimeBaseObj_setattr, /*tp_setattr*/ -}; - -/* -------------------- End object type TimeBase -------------------- */ - - -/* ---------------------- Object type UserData ---------------------- */ - -PyTypeObject UserData_Type; - -#define UserDataObj_Check(x) ((x)->ob_type == &UserData_Type) - -typedef struct UserDataObject { - PyObject_HEAD - UserData ob_itself; -} UserDataObject; - -PyObject *UserDataObj_New(itself) - UserData itself; -{ - UserDataObject *it; - if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null UserData"); - return NULL; - } - it = PyObject_NEW(UserDataObject, &UserData_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -UserDataObj_Convert(v, p_itself) - PyObject *v; - UserData *p_itself; -{ - if (!UserDataObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "UserData required"); - return 0; - } - *p_itself = ((UserDataObject *)v)->ob_itself; - return 1; -} - -static void UserDataObj_dealloc(self) - UserDataObject *self; -{ - DisposeUserData(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *UserDataObj_GetUserData(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle data; - OSType udType; - long index; - if (!PyArg_ParseTuple(_args, "O&O&l", - ResObj_Convert, &data, - PyMac_GetOSType, &udType, - &index)) - return NULL; - _err = GetUserData(_self->ob_itself, - data, - udType, - index); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *UserDataObj_AddUserData(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle data; - OSType udType; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &data, - PyMac_GetOSType, &udType)) - return NULL; - _err = AddUserData(_self->ob_itself, - data, - udType); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *UserDataObj_RemoveUserData(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - OSType udType; - long index; - if (!PyArg_ParseTuple(_args, "O&l", - PyMac_GetOSType, &udType, - &index)) - return NULL; - _err = RemoveUserData(_self->ob_itself, - udType, - index); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *UserDataObj_CountUserDataType(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - OSType udType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &udType)) - return NULL; - _rv = CountUserDataType(_self->ob_itself, - udType); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *UserDataObj_GetNextUserDataType(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - OSType udType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &udType)) - return NULL; - _rv = GetNextUserDataType(_self->ob_itself, - udType); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *UserDataObj_AddUserDataText(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle data; - OSType udType; - long index; - short itlRegionTag; - if (!PyArg_ParseTuple(_args, "O&O&lh", - ResObj_Convert, &data, - PyMac_GetOSType, &udType, - &index, - &itlRegionTag)) - return NULL; - _err = AddUserDataText(_self->ob_itself, - data, - udType, - index, - itlRegionTag); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *UserDataObj_GetUserDataText(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle data; - OSType udType; - long index; - short itlRegionTag; - if (!PyArg_ParseTuple(_args, "O&O&lh", - ResObj_Convert, &data, - PyMac_GetOSType, &udType, - &index, - &itlRegionTag)) - return NULL; - _err = GetUserDataText(_self->ob_itself, - data, - udType, - index, - itlRegionTag); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *UserDataObj_RemoveUserDataText(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - OSType udType; - long index; - short itlRegionTag; - if (!PyArg_ParseTuple(_args, "O&lh", - PyMac_GetOSType, &udType, - &index, - &itlRegionTag)) - return NULL; - _err = RemoveUserDataText(_self->ob_itself, - udType, - index, - itlRegionTag); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *UserDataObj_PutUserDataIntoHandle(_self, _args) - UserDataObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle h; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &h)) - return NULL; - _err = PutUserDataIntoHandle(_self->ob_itself, - h); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef UserDataObj_methods[] = { - {"GetUserData", (PyCFunction)UserDataObj_GetUserData, 1, - "(Handle data, OSType udType, long index) -> None"}, - {"AddUserData", (PyCFunction)UserDataObj_AddUserData, 1, - "(Handle data, OSType udType) -> None"}, - {"RemoveUserData", (PyCFunction)UserDataObj_RemoveUserData, 1, - "(OSType udType, long index) -> None"}, - {"CountUserDataType", (PyCFunction)UserDataObj_CountUserDataType, 1, - "(OSType udType) -> (short _rv)"}, - {"GetNextUserDataType", (PyCFunction)UserDataObj_GetNextUserDataType, 1, - "(OSType udType) -> (long _rv)"}, - {"AddUserDataText", (PyCFunction)UserDataObj_AddUserDataText, 1, - "(Handle data, OSType udType, long index, short itlRegionTag) -> None"}, - {"GetUserDataText", (PyCFunction)UserDataObj_GetUserDataText, 1, - "(Handle data, OSType udType, long index, short itlRegionTag) -> None"}, - {"RemoveUserDataText", (PyCFunction)UserDataObj_RemoveUserDataText, 1, - "(OSType udType, long index, short itlRegionTag) -> None"}, - {"PutUserDataIntoHandle", (PyCFunction)UserDataObj_PutUserDataIntoHandle, 1, - "(Handle h) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain UserDataObj_chain = { UserDataObj_methods, NULL }; - -static PyObject *UserDataObj_getattr(self, name) - UserDataObject *self; - char *name; -{ - return Py_FindMethodInChain(&UserDataObj_chain, (PyObject *)self, name); -} - -#define UserDataObj_setattr NULL - -PyTypeObject UserData_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "UserData", /*tp_name*/ - sizeof(UserDataObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) UserDataObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) UserDataObj_getattr, /*tp_getattr*/ - (setattrfunc) UserDataObj_setattr, /*tp_setattr*/ -}; - -/* -------------------- End object type UserData -------------------- */ - - -/* ----------------------- Object type Media ------------------------ */ - -PyTypeObject Media_Type; - -#define MediaObj_Check(x) ((x)->ob_type == &Media_Type) - -typedef struct MediaObject { - PyObject_HEAD - Media ob_itself; -} MediaObject; - -PyObject *MediaObj_New(itself) - Media itself; -{ - MediaObject *it; - if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null Media"); - return NULL; - } - it = PyObject_NEW(MediaObject, &Media_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -MediaObj_Convert(v, p_itself) - PyObject *v; - Media *p_itself; -{ - if (!MediaObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Media required"); - return 0; - } - *p_itself = ((MediaObject *)v)->ob_itself; - return 1; -} - -static void MediaObj_dealloc(self) - MediaObject *self; -{ - DisposeTrackMedia(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *MediaObj_LoadMediaIntoRam(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue time; - TimeValue duration; - long flags; - if (!PyArg_ParseTuple(_args, "lll", - &time, - &duration, - &flags)) - return NULL; - _err = LoadMediaIntoRam(_self->ob_itself, - time, - duration, - flags); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaTrack(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaTrack(_self->ob_itself); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *MediaObj_GetMediaTimeScale(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeScale _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaTimeScale(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MediaObj_SetMediaTimeScale(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeScale timeScale; - if (!PyArg_ParseTuple(_args, "l", - &timeScale)) - return NULL; - SetMediaTimeScale(_self->ob_itself, - timeScale); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaDuration(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaDuration(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MediaObj_GetMediaLanguage(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaLanguage(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *MediaObj_SetMediaLanguage(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short language; - if (!PyArg_ParseTuple(_args, "h", - &language)) - return NULL; - SetMediaLanguage(_self->ob_itself, - language); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaQuality(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaQuality(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *MediaObj_SetMediaQuality(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short quality; - if (!PyArg_ParseTuple(_args, "h", - &quality)) - return NULL; - SetMediaQuality(_self->ob_itself, - quality); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaHandlerDescription(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSType mediaType; - Str255 creatorName; - OSType creatorManufacturer; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, creatorName)) - return NULL; - GetMediaHandlerDescription(_self->ob_itself, - &mediaType, - creatorName, - &creatorManufacturer); - _res = Py_BuildValue("O&O&", - PyMac_BuildOSType, mediaType, - PyMac_BuildOSType, creatorManufacturer); - return _res; -} - -static PyObject *MediaObj_GetMediaUserData(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UserData _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaUserData(_self->ob_itself); - _res = Py_BuildValue("O&", - UserDataObj_New, _rv); - return _res; -} - -static PyObject *MediaObj_GetMediaHandler(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - MediaHandler _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaHandler(_self->ob_itself); - _res = Py_BuildValue("O&", - CmpInstObj_New, _rv); - return _res; -} - -static PyObject *MediaObj_SetMediaHandler(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - MediaHandlerComponent mH; - if (!PyArg_ParseTuple(_args, "O&", - CmpObj_Convert, &mH)) - return NULL; - _err = SetMediaHandler(_self->ob_itself, - mH); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_BeginMediaEdits(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = BeginMediaEdits(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_EndMediaEdits(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = EndMediaEdits(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_SetMediaDefaultDataRefIndex(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short index; - if (!PyArg_ParseTuple(_args, "h", - &index)) - return NULL; - _err = SetMediaDefaultDataRefIndex(_self->ob_itself, - index); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaDataHandlerDescription(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short index; - OSType dhType; - Str255 creatorName; - OSType creatorManufacturer; - if (!PyArg_ParseTuple(_args, "hO&", - &index, - PyMac_GetStr255, creatorName)) - return NULL; - GetMediaDataHandlerDescription(_self->ob_itself, - index, - &dhType, - creatorName, - &creatorManufacturer); - _res = Py_BuildValue("O&O&", - PyMac_BuildOSType, dhType, - PyMac_BuildOSType, creatorManufacturer); - return _res; -} - -static PyObject *MediaObj_GetMediaDataHandler(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - DataHandler _rv; - short index; - if (!PyArg_ParseTuple(_args, "h", - &index)) - return NULL; - _rv = GetMediaDataHandler(_self->ob_itself, - index); - _res = Py_BuildValue("O&", - CmpInstObj_New, _rv); - return _res; -} - -static PyObject *MediaObj_SetMediaDataHandler(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short index; - DataHandlerComponent dataHandler; - if (!PyArg_ParseTuple(_args, "hO&", - &index, - CmpObj_Convert, &dataHandler)) - return NULL; - _err = SetMediaDataHandler(_self->ob_itself, - index, - dataHandler); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaSampleDescriptionCount(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaSampleDescriptionCount(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MediaObj_GetMediaSampleDescription(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long index; - SampleDescriptionHandle descH; - if (!PyArg_ParseTuple(_args, "lO&", - &index, - ResObj_Convert, &descH)) - return NULL; - GetMediaSampleDescription(_self->ob_itself, - index, - descH); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_SetMediaSampleDescription(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long index; - SampleDescriptionHandle descH; - if (!PyArg_ParseTuple(_args, "lO&", - &index, - ResObj_Convert, &descH)) - return NULL; - _err = SetMediaSampleDescription(_self->ob_itself, - index, - descH); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaSampleCount(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMediaSampleCount(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MediaObj_SampleNumToMediaTime(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long logicalSampleNum; - TimeValue sampleTime; - TimeValue sampleDuration; - if (!PyArg_ParseTuple(_args, "l", - &logicalSampleNum)) - return NULL; - SampleNumToMediaTime(_self->ob_itself, - logicalSampleNum, - &sampleTime, - &sampleDuration); - _res = Py_BuildValue("ll", - sampleTime, - sampleDuration); - return _res; -} - -static PyObject *MediaObj_MediaTimeToSampleNum(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue time; - long sampleNum; - TimeValue sampleTime; - TimeValue sampleDuration; - if (!PyArg_ParseTuple(_args, "l", - &time)) - return NULL; - MediaTimeToSampleNum(_self->ob_itself, - time, - &sampleNum, - &sampleTime, - &sampleDuration); - _res = Py_BuildValue("lll", - sampleNum, - sampleTime, - sampleDuration); - return _res; -} - -static PyObject *MediaObj_AddMediaSample(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle dataIn; - long inOffset; - unsigned long size; - TimeValue durationPerSample; - SampleDescriptionHandle sampleDescriptionH; - long numberOfSamples; - short sampleFlags; - TimeValue sampleTime; - if (!PyArg_ParseTuple(_args, "O&lllO&lh", - ResObj_Convert, &dataIn, - &inOffset, - &size, - &durationPerSample, - ResObj_Convert, &sampleDescriptionH, - &numberOfSamples, - &sampleFlags)) - return NULL; - _err = AddMediaSample(_self->ob_itself, - dataIn, - inOffset, - size, - durationPerSample, - sampleDescriptionH, - numberOfSamples, - sampleFlags, - &sampleTime); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - sampleTime); - return _res; -} - -static PyObject *MediaObj_AddMediaSampleReference(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long dataOffset; - unsigned long size; - TimeValue durationPerSample; - SampleDescriptionHandle sampleDescriptionH; - long numberOfSamples; - short sampleFlags; - TimeValue sampleTime; - if (!PyArg_ParseTuple(_args, "lllO&lh", - &dataOffset, - &size, - &durationPerSample, - ResObj_Convert, &sampleDescriptionH, - &numberOfSamples, - &sampleFlags)) - return NULL; - _err = AddMediaSampleReference(_self->ob_itself, - dataOffset, - size, - durationPerSample, - sampleDescriptionH, - numberOfSamples, - sampleFlags, - &sampleTime); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - sampleTime); - return _res; -} - -static PyObject *MediaObj_GetMediaSample(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle dataOut; - long maxSizeToGrow; - long size; - TimeValue time; - TimeValue sampleTime; - TimeValue durationPerSample; - SampleDescriptionHandle sampleDescriptionH; - long sampleDescriptionIndex; - long maxNumberOfSamples; - long numberOfSamples; - short sampleFlags; - if (!PyArg_ParseTuple(_args, "O&llO&l", - ResObj_Convert, &dataOut, - &maxSizeToGrow, - &time, - ResObj_Convert, &sampleDescriptionH, - &maxNumberOfSamples)) - return NULL; - _err = GetMediaSample(_self->ob_itself, - dataOut, - maxSizeToGrow, - &size, - time, - &sampleTime, - &durationPerSample, - sampleDescriptionH, - &sampleDescriptionIndex, - maxNumberOfSamples, - &numberOfSamples, - &sampleFlags); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("lllllh", - size, - sampleTime, - durationPerSample, - sampleDescriptionIndex, - numberOfSamples, - sampleFlags); - return _res; -} - -static PyObject *MediaObj_GetMediaSampleReference(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long dataOffset; - long size; - TimeValue time; - TimeValue sampleTime; - TimeValue durationPerSample; - SampleDescriptionHandle sampleDescriptionH; - long sampleDescriptionIndex; - long maxNumberOfSamples; - long numberOfSamples; - short sampleFlags; - if (!PyArg_ParseTuple(_args, "lO&l", - &time, - ResObj_Convert, &sampleDescriptionH, - &maxNumberOfSamples)) - return NULL; - _err = GetMediaSampleReference(_self->ob_itself, - &dataOffset, - &size, - time, - &sampleTime, - &durationPerSample, - sampleDescriptionH, - &sampleDescriptionIndex, - maxNumberOfSamples, - &numberOfSamples, - &sampleFlags); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("llllllh", - dataOffset, - size, - sampleTime, - durationPerSample, - sampleDescriptionIndex, - numberOfSamples, - sampleFlags); - return _res; -} - -static PyObject *MediaObj_SetMediaPreferredChunkSize(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long maxChunkSize; - if (!PyArg_ParseTuple(_args, "l", - &maxChunkSize)) - return NULL; - _err = SetMediaPreferredChunkSize(_self->ob_itself, - maxChunkSize); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaPreferredChunkSize(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long maxChunkSize; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetMediaPreferredChunkSize(_self->ob_itself, - &maxChunkSize); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - maxChunkSize); - return _res; -} - -static PyObject *MediaObj_SetMediaShadowSync(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long frameDiffSampleNum; - long syncSampleNum; - if (!PyArg_ParseTuple(_args, "ll", - &frameDiffSampleNum, - &syncSampleNum)) - return NULL; - _err = SetMediaShadowSync(_self->ob_itself, - frameDiffSampleNum, - syncSampleNum); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_GetMediaShadowSync(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long frameDiffSampleNum; - long syncSampleNum; - if (!PyArg_ParseTuple(_args, "l", - &frameDiffSampleNum)) - return NULL; - _err = GetMediaShadowSync(_self->ob_itself, - frameDiffSampleNum, - &syncSampleNum); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - syncSampleNum); - return _res; -} - -static PyObject *MediaObj_GetMediaDataSize(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - TimeValue startTime; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &startTime, - &duration)) - return NULL; - _rv = GetMediaDataSize(_self->ob_itself, - startTime, - duration); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MediaObj_GetMediaNextInterestingTime(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short interestingTimeFlags; - TimeValue time; - Fixed rate; - TimeValue interestingTime; - TimeValue interestingDuration; - if (!PyArg_ParseTuple(_args, "hlO&", - &interestingTimeFlags, - &time, - PyMac_GetFixed, &rate)) - return NULL; - GetMediaNextInterestingTime(_self->ob_itself, - interestingTimeFlags, - time, - rate, - &interestingTime, - &interestingDuration); - _res = Py_BuildValue("ll", - interestingTime, - interestingDuration); - return _res; -} - -static PyObject *MediaObj_GetMediaDataRef(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short index; - Handle dataRef; - OSType dataRefType; - long dataRefAttributes; - if (!PyArg_ParseTuple(_args, "h", - &index)) - return NULL; - _err = GetMediaDataRef(_self->ob_itself, - index, - &dataRef, - &dataRefType, - &dataRefAttributes); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&O&l", - ResObj_New, dataRef, - PyMac_BuildOSType, dataRefType, - dataRefAttributes); - return _res; -} - -static PyObject *MediaObj_SetMediaDataRef(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short index; - Handle dataRef; - OSType dataRefType; - if (!PyArg_ParseTuple(_args, "hO&O&", - &index, - ResObj_Convert, &dataRef, - PyMac_GetOSType, &dataRefType)) - return NULL; - _err = SetMediaDataRef(_self->ob_itself, - index, - dataRef, - dataRefType); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_SetMediaDataRefAttributes(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short index; - long dataRefAttributes; - if (!PyArg_ParseTuple(_args, "hl", - &index, - &dataRefAttributes)) - return NULL; - _err = SetMediaDataRefAttributes(_self->ob_itself, - index, - dataRefAttributes); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MediaObj_AddMediaDataRef(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short index; - Handle dataRef; - OSType dataRefType; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &dataRef, - PyMac_GetOSType, &dataRefType)) - return NULL; - _err = AddMediaDataRef(_self->ob_itself, - &index, - dataRef, - dataRefType); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("h", - index); - return _res; -} - -static PyObject *MediaObj_GetMediaDataRefCount(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short count; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetMediaDataRefCount(_self->ob_itself, - &count); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("h", - count); - return _res; -} - -static PyObject *MediaObj_SetMediaPlayHints(_self, _args) - MediaObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long flags; - long flagsMask; - if (!PyArg_ParseTuple(_args, "ll", - &flags, - &flagsMask)) - return NULL; - SetMediaPlayHints(_self->ob_itself, - flags, - flagsMask); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef MediaObj_methods[] = { - {"LoadMediaIntoRam", (PyCFunction)MediaObj_LoadMediaIntoRam, 1, - "(TimeValue time, TimeValue duration, long flags) -> None"}, - {"GetMediaTrack", (PyCFunction)MediaObj_GetMediaTrack, 1, - "() -> (Track _rv)"}, - {"GetMediaTimeScale", (PyCFunction)MediaObj_GetMediaTimeScale, 1, - "() -> (TimeScale _rv)"}, - {"SetMediaTimeScale", (PyCFunction)MediaObj_SetMediaTimeScale, 1, - "(TimeScale timeScale) -> None"}, - {"GetMediaDuration", (PyCFunction)MediaObj_GetMediaDuration, 1, - "() -> (TimeValue _rv)"}, - {"GetMediaLanguage", (PyCFunction)MediaObj_GetMediaLanguage, 1, - "() -> (short _rv)"}, - {"SetMediaLanguage", (PyCFunction)MediaObj_SetMediaLanguage, 1, - "(short language) -> None"}, - {"GetMediaQuality", (PyCFunction)MediaObj_GetMediaQuality, 1, - "() -> (short _rv)"}, - {"SetMediaQuality", (PyCFunction)MediaObj_SetMediaQuality, 1, - "(short quality) -> None"}, - {"GetMediaHandlerDescription", (PyCFunction)MediaObj_GetMediaHandlerDescription, 1, - "(Str255 creatorName) -> (OSType mediaType, OSType creatorManufacturer)"}, - {"GetMediaUserData", (PyCFunction)MediaObj_GetMediaUserData, 1, - "() -> (UserData _rv)"}, - {"GetMediaHandler", (PyCFunction)MediaObj_GetMediaHandler, 1, - "() -> (MediaHandler _rv)"}, - {"SetMediaHandler", (PyCFunction)MediaObj_SetMediaHandler, 1, - "(MediaHandlerComponent mH) -> None"}, - {"BeginMediaEdits", (PyCFunction)MediaObj_BeginMediaEdits, 1, - "() -> None"}, - {"EndMediaEdits", (PyCFunction)MediaObj_EndMediaEdits, 1, - "() -> None"}, - {"SetMediaDefaultDataRefIndex", (PyCFunction)MediaObj_SetMediaDefaultDataRefIndex, 1, - "(short index) -> None"}, - {"GetMediaDataHandlerDescription", (PyCFunction)MediaObj_GetMediaDataHandlerDescription, 1, - "(short index, Str255 creatorName) -> (OSType dhType, OSType creatorManufacturer)"}, - {"GetMediaDataHandler", (PyCFunction)MediaObj_GetMediaDataHandler, 1, - "(short index) -> (DataHandler _rv)"}, - {"SetMediaDataHandler", (PyCFunction)MediaObj_SetMediaDataHandler, 1, - "(short index, DataHandlerComponent dataHandler) -> None"}, - {"GetMediaSampleDescriptionCount", (PyCFunction)MediaObj_GetMediaSampleDescriptionCount, 1, - "() -> (long _rv)"}, - {"GetMediaSampleDescription", (PyCFunction)MediaObj_GetMediaSampleDescription, 1, - "(long index, SampleDescriptionHandle descH) -> None"}, - {"SetMediaSampleDescription", (PyCFunction)MediaObj_SetMediaSampleDescription, 1, - "(long index, SampleDescriptionHandle descH) -> None"}, - {"GetMediaSampleCount", (PyCFunction)MediaObj_GetMediaSampleCount, 1, - "() -> (long _rv)"}, - {"SampleNumToMediaTime", (PyCFunction)MediaObj_SampleNumToMediaTime, 1, - "(long logicalSampleNum) -> (TimeValue sampleTime, TimeValue sampleDuration)"}, - {"MediaTimeToSampleNum", (PyCFunction)MediaObj_MediaTimeToSampleNum, 1, - "(TimeValue time) -> (long sampleNum, TimeValue sampleTime, TimeValue sampleDuration)"}, - {"AddMediaSample", (PyCFunction)MediaObj_AddMediaSample, 1, - "(Handle dataIn, long inOffset, unsigned long size, TimeValue durationPerSample, SampleDescriptionHandle sampleDescriptionH, long numberOfSamples, short sampleFlags) -> (TimeValue sampleTime)"}, - {"AddMediaSampleReference", (PyCFunction)MediaObj_AddMediaSampleReference, 1, - "(long dataOffset, unsigned long size, TimeValue durationPerSample, SampleDescriptionHandle sampleDescriptionH, long numberOfSamples, short sampleFlags) -> (TimeValue sampleTime)"}, - {"GetMediaSample", (PyCFunction)MediaObj_GetMediaSample, 1, - "(Handle dataOut, long maxSizeToGrow, TimeValue time, SampleDescriptionHandle sampleDescriptionH, long maxNumberOfSamples) -> (long size, TimeValue sampleTime, TimeValue durationPerSample, long sampleDescriptionIndex, long numberOfSamples, short sampleFlags)"}, - {"GetMediaSampleReference", (PyCFunction)MediaObj_GetMediaSampleReference, 1, - "(TimeValue time, SampleDescriptionHandle sampleDescriptionH, long maxNumberOfSamples) -> (long dataOffset, long size, TimeValue sampleTime, TimeValue durationPerSample, long sampleDescriptionIndex, long numberOfSamples, short sampleFlags)"}, - {"SetMediaPreferredChunkSize", (PyCFunction)MediaObj_SetMediaPreferredChunkSize, 1, - "(long maxChunkSize) -> None"}, - {"GetMediaPreferredChunkSize", (PyCFunction)MediaObj_GetMediaPreferredChunkSize, 1, - "() -> (long maxChunkSize)"}, - {"SetMediaShadowSync", (PyCFunction)MediaObj_SetMediaShadowSync, 1, - "(long frameDiffSampleNum, long syncSampleNum) -> None"}, - {"GetMediaShadowSync", (PyCFunction)MediaObj_GetMediaShadowSync, 1, - "(long frameDiffSampleNum) -> (long syncSampleNum)"}, - {"GetMediaDataSize", (PyCFunction)MediaObj_GetMediaDataSize, 1, - "(TimeValue startTime, TimeValue duration) -> (long _rv)"}, - {"GetMediaNextInterestingTime", (PyCFunction)MediaObj_GetMediaNextInterestingTime, 1, - "(short interestingTimeFlags, TimeValue time, Fixed rate) -> (TimeValue interestingTime, TimeValue interestingDuration)"}, - {"GetMediaDataRef", (PyCFunction)MediaObj_GetMediaDataRef, 1, - "(short index) -> (Handle dataRef, OSType dataRefType, long dataRefAttributes)"}, - {"SetMediaDataRef", (PyCFunction)MediaObj_SetMediaDataRef, 1, - "(short index, Handle dataRef, OSType dataRefType) -> None"}, - {"SetMediaDataRefAttributes", (PyCFunction)MediaObj_SetMediaDataRefAttributes, 1, - "(short index, long dataRefAttributes) -> None"}, - {"AddMediaDataRef", (PyCFunction)MediaObj_AddMediaDataRef, 1, - "(Handle dataRef, OSType dataRefType) -> (short index)"}, - {"GetMediaDataRefCount", (PyCFunction)MediaObj_GetMediaDataRefCount, 1, - "() -> (short count)"}, - {"SetMediaPlayHints", (PyCFunction)MediaObj_SetMediaPlayHints, 1, - "(long flags, long flagsMask) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain MediaObj_chain = { MediaObj_methods, NULL }; - -static PyObject *MediaObj_getattr(self, name) - MediaObject *self; - char *name; -{ - return Py_FindMethodInChain(&MediaObj_chain, (PyObject *)self, name); -} - -#define MediaObj_setattr NULL - -PyTypeObject Media_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Media", /*tp_name*/ - sizeof(MediaObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) MediaObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) MediaObj_getattr, /*tp_getattr*/ - (setattrfunc) MediaObj_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type Media ---------------------- */ - - -/* ----------------------- Object type Track ------------------------ */ - -PyTypeObject Track_Type; - -#define TrackObj_Check(x) ((x)->ob_type == &Track_Type) - -typedef struct TrackObject { - PyObject_HEAD - Track ob_itself; -} TrackObject; - -PyObject *TrackObj_New(itself) - Track itself; -{ - TrackObject *it; - if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null Track"); - return NULL; - } - it = PyObject_NEW(TrackObject, &Track_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -TrackObj_Convert(v, p_itself) - PyObject *v; - Track *p_itself; -{ - if (!TrackObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Track required"); - return 0; - } - *p_itself = ((TrackObject *)v)->ob_itself; - return 1; -} - -static void TrackObj_dealloc(self) - TrackObject *self; -{ - DisposeMovieTrack(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *TrackObj_LoadTrackIntoRam(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue time; - TimeValue duration; - long flags; - if (!PyArg_ParseTuple(_args, "lll", - &time, - &duration, - &flags)) - return NULL; - _err = LoadTrackIntoRam(_self->ob_itself, - time, - duration, - flags); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackPict(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle _rv; - TimeValue time; - if (!PyArg_ParseTuple(_args, "l", - &time)) - return NULL; - _rv = GetTrackPict(_self->ob_itself, - time); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackClipRgn(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackClipRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackClipRgn(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle theClip; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theClip)) - return NULL; - SetTrackClipRgn(_self->ob_itself, - theClip); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackDisplayBoundsRgn(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackDisplayBoundsRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackMovieBoundsRgn(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackMovieBoundsRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackBoundsRgn(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackBoundsRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackMatte(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixMapHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackMatte(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackMatte(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixMapHandle theMatte; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theMatte)) - return NULL; - SetTrackMatte(_self->ob_itself, - theMatte); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackID(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackID(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackMovie(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackMovie(_self->ob_itself); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackEnabled(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackEnabled(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackEnabled(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean isEnabled; - if (!PyArg_ParseTuple(_args, "b", - &isEnabled)) - return NULL; - SetTrackEnabled(_self->ob_itself, - isEnabled); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackUsage(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackUsage(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackUsage(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long usage; - if (!PyArg_ParseTuple(_args, "l", - &usage)) - return NULL; - SetTrackUsage(_self->ob_itself, - usage); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackDuration(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackDuration(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackOffset(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackOffset(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackOffset(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue movieOffsetTime; - if (!PyArg_ParseTuple(_args, "l", - &movieOffsetTime)) - return NULL; - SetTrackOffset(_self->ob_itself, - movieOffsetTime); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackLayer(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackLayer(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackLayer(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short layer; - if (!PyArg_ParseTuple(_args, "h", - &layer)) - return NULL; - SetTrackLayer(_self->ob_itself, - layer); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackAlternate(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackAlternate(_self->ob_itself); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackAlternate(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track alternateT; - if (!PyArg_ParseTuple(_args, "O&", - TrackObj_Convert, &alternateT)) - return NULL; - SetTrackAlternate(_self->ob_itself, - alternateT); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackVolume(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackVolume(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackVolume(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short volume; - if (!PyArg_ParseTuple(_args, "h", - &volume)) - return NULL; - SetTrackVolume(_self->ob_itself, - volume); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackDimensions(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed width; - Fixed height; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetTrackDimensions(_self->ob_itself, - &width, - &height); - _res = Py_BuildValue("O&O&", - PyMac_BuildFixed, width, - PyMac_BuildFixed, height); - return _res; -} - -static PyObject *TrackObj_SetTrackDimensions(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed width; - Fixed height; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetFixed, &width, - PyMac_GetFixed, &height)) - return NULL; - SetTrackDimensions(_self->ob_itself, - width, - height); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackUserData(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UserData _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackUserData(_self->ob_itself); - _res = Py_BuildValue("O&", - UserDataObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_NewTrackMedia(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Media _rv; - OSType mediaType; - TimeScale timeScale; - Handle dataRef; - OSType dataRefType; - if (!PyArg_ParseTuple(_args, "O&lO&O&", - PyMac_GetOSType, &mediaType, - &timeScale, - ResObj_Convert, &dataRef, - PyMac_GetOSType, &dataRefType)) - return NULL; - _rv = NewTrackMedia(_self->ob_itself, - mediaType, - timeScale, - dataRef, - dataRefType); - _res = Py_BuildValue("O&", - MediaObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackMedia(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Media _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackMedia(_self->ob_itself); - _res = Py_BuildValue("O&", - MediaObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_InsertMediaIntoTrack(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue trackStart; - TimeValue mediaTime; - TimeValue mediaDuration; - Fixed mediaRate; - if (!PyArg_ParseTuple(_args, "lllO&", - &trackStart, - &mediaTime, - &mediaDuration, - PyMac_GetFixed, &mediaRate)) - return NULL; - _err = InsertMediaIntoTrack(_self->ob_itself, - trackStart, - mediaTime, - mediaDuration, - mediaRate); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_InsertTrackSegment(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Track dstTrack; - TimeValue srcIn; - TimeValue srcDuration; - TimeValue dstIn; - if (!PyArg_ParseTuple(_args, "O&lll", - TrackObj_Convert, &dstTrack, - &srcIn, - &srcDuration, - &dstIn)) - return NULL; - _err = InsertTrackSegment(_self->ob_itself, - dstTrack, - srcIn, - srcDuration, - dstIn); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_InsertEmptyTrackSegment(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue dstIn; - TimeValue dstDuration; - if (!PyArg_ParseTuple(_args, "ll", - &dstIn, - &dstDuration)) - return NULL; - _err = InsertEmptyTrackSegment(_self->ob_itself, - dstIn, - dstDuration); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_DeleteTrackSegment(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue startTime; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &startTime, - &duration)) - return NULL; - _err = DeleteTrackSegment(_self->ob_itself, - startTime, - duration); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_ScaleTrackSegment(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue startTime; - TimeValue oldDuration; - TimeValue newDuration; - if (!PyArg_ParseTuple(_args, "lll", - &startTime, - &oldDuration, - &newDuration)) - return NULL; - _err = ScaleTrackSegment(_self->ob_itself, - startTime, - oldDuration, - newDuration); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_IsScrapMovie(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Component _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = IsScrapMovie(_self->ob_itself); - _res = Py_BuildValue("O&", - CmpObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_CopyTrackSettings(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Track dstTrack; - if (!PyArg_ParseTuple(_args, "O&", - TrackObj_Convert, &dstTrack)) - return NULL; - _err = CopyTrackSettings(_self->ob_itself, - dstTrack); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_AddEmptyTrackToMovie(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Movie dstMovie; - Handle dataRef; - OSType dataRefType; - Track dstTrack; - if (!PyArg_ParseTuple(_args, "O&O&O&", - MovieObj_Convert, &dstMovie, - ResObj_Convert, &dataRef, - PyMac_GetOSType, &dataRefType)) - return NULL; - _err = AddEmptyTrackToMovie(_self->ob_itself, - dstMovie, - dataRef, - dataRefType, - &dstTrack); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - TrackObj_New, dstTrack); - return _res; -} - -static PyObject *TrackObj_AddTrackReference(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Track refTrack; - OSType refType; - long addedIndex; - if (!PyArg_ParseTuple(_args, "O&O&", - TrackObj_Convert, &refTrack, - PyMac_GetOSType, &refType)) - return NULL; - _err = AddTrackReference(_self->ob_itself, - refTrack, - refType, - &addedIndex); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - addedIndex); - return _res; -} - -static PyObject *TrackObj_DeleteTrackReference(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - OSType refType; - long index; - if (!PyArg_ParseTuple(_args, "O&l", - PyMac_GetOSType, &refType, - &index)) - return NULL; - _err = DeleteTrackReference(_self->ob_itself, - refType, - index); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_SetTrackReference(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Track refTrack; - OSType refType; - long index; - if (!PyArg_ParseTuple(_args, "O&O&l", - TrackObj_Convert, &refTrack, - PyMac_GetOSType, &refType, - &index)) - return NULL; - _err = SetTrackReference(_self->ob_itself, - refTrack, - refType, - index); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackReference(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - OSType refType; - long index; - if (!PyArg_ParseTuple(_args, "O&l", - PyMac_GetOSType, &refType, - &index)) - return NULL; - _rv = GetTrackReference(_self->ob_itself, - refType, - index); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetNextTrackReferenceType(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSType _rv; - OSType refType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &refType)) - return NULL; - _rv = GetNextTrackReferenceType(_self->ob_itself, - refType); - _res = Py_BuildValue("O&", - PyMac_BuildOSType, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackReferenceCount(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - OSType refType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &refType)) - return NULL; - _rv = GetTrackReferenceCount(_self->ob_itself, - refType); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackEditRate(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed _rv; - TimeValue atTime; - if (!PyArg_ParseTuple(_args, "l", - &atTime)) - return NULL; - _rv = GetTrackEditRate(_self->ob_itself, - atTime); - _res = Py_BuildValue("O&", - PyMac_BuildFixed, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackDataSize(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - TimeValue startTime; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &startTime, - &duration)) - return NULL; - _rv = GetTrackDataSize(_self->ob_itself, - startTime, - duration); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TrackObj_PtInTrack(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point pt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &pt)) - return NULL; - _rv = PtInTrack(_self->ob_itself, - pt); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackNextInterestingTime(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short interestingTimeFlags; - TimeValue time; - Fixed rate; - TimeValue interestingTime; - TimeValue interestingDuration; - if (!PyArg_ParseTuple(_args, "hlO&", - &interestingTimeFlags, - &time, - PyMac_GetFixed, &rate)) - return NULL; - GetTrackNextInterestingTime(_self->ob_itself, - interestingTimeFlags, - time, - rate, - &interestingTime, - &interestingDuration); - _res = Py_BuildValue("ll", - interestingTime, - interestingDuration); - return _res; -} - -static PyObject *TrackObj_GetTrackSegmentDisplayBoundsRgn(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - TimeValue time; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &time, - &duration)) - return NULL; - _rv = GetTrackSegmentDisplayBoundsRgn(_self->ob_itself, - time, - duration); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TrackObj_GetTrackStatus(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetTrackStatus(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TrackObj_SetTrackLoadSettings(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue preloadTime; - TimeValue preloadDuration; - long preloadFlags; - long defaultHints; - if (!PyArg_ParseTuple(_args, "llll", - &preloadTime, - &preloadDuration, - &preloadFlags, - &defaultHints)) - return NULL; - SetTrackLoadSettings(_self->ob_itself, - preloadTime, - preloadDuration, - preloadFlags, - defaultHints); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TrackObj_GetTrackLoadSettings(_self, _args) - TrackObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue preloadTime; - TimeValue preloadDuration; - long preloadFlags; - long defaultHints; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetTrackLoadSettings(_self->ob_itself, - &preloadTime, - &preloadDuration, - &preloadFlags, - &defaultHints); - _res = Py_BuildValue("llll", - preloadTime, - preloadDuration, - preloadFlags, - defaultHints); - return _res; -} - -static PyMethodDef TrackObj_methods[] = { - {"LoadTrackIntoRam", (PyCFunction)TrackObj_LoadTrackIntoRam, 1, - "(TimeValue time, TimeValue duration, long flags) -> None"}, - {"GetTrackPict", (PyCFunction)TrackObj_GetTrackPict, 1, - "(TimeValue time) -> (PicHandle _rv)"}, - {"GetTrackClipRgn", (PyCFunction)TrackObj_GetTrackClipRgn, 1, - "() -> (RgnHandle _rv)"}, - {"SetTrackClipRgn", (PyCFunction)TrackObj_SetTrackClipRgn, 1, - "(RgnHandle theClip) -> None"}, - {"GetTrackDisplayBoundsRgn", (PyCFunction)TrackObj_GetTrackDisplayBoundsRgn, 1, - "() -> (RgnHandle _rv)"}, - {"GetTrackMovieBoundsRgn", (PyCFunction)TrackObj_GetTrackMovieBoundsRgn, 1, - "() -> (RgnHandle _rv)"}, - {"GetTrackBoundsRgn", (PyCFunction)TrackObj_GetTrackBoundsRgn, 1, - "() -> (RgnHandle _rv)"}, - {"GetTrackMatte", (PyCFunction)TrackObj_GetTrackMatte, 1, - "() -> (PixMapHandle _rv)"}, - {"SetTrackMatte", (PyCFunction)TrackObj_SetTrackMatte, 1, - "(PixMapHandle theMatte) -> None"}, - {"GetTrackID", (PyCFunction)TrackObj_GetTrackID, 1, - "() -> (long _rv)"}, - {"GetTrackMovie", (PyCFunction)TrackObj_GetTrackMovie, 1, - "() -> (Movie _rv)"}, - {"GetTrackEnabled", (PyCFunction)TrackObj_GetTrackEnabled, 1, - "() -> (Boolean _rv)"}, - {"SetTrackEnabled", (PyCFunction)TrackObj_SetTrackEnabled, 1, - "(Boolean isEnabled) -> None"}, - {"GetTrackUsage", (PyCFunction)TrackObj_GetTrackUsage, 1, - "() -> (long _rv)"}, - {"SetTrackUsage", (PyCFunction)TrackObj_SetTrackUsage, 1, - "(long usage) -> None"}, - {"GetTrackDuration", (PyCFunction)TrackObj_GetTrackDuration, 1, - "() -> (TimeValue _rv)"}, - {"GetTrackOffset", (PyCFunction)TrackObj_GetTrackOffset, 1, - "() -> (TimeValue _rv)"}, - {"SetTrackOffset", (PyCFunction)TrackObj_SetTrackOffset, 1, - "(TimeValue movieOffsetTime) -> None"}, - {"GetTrackLayer", (PyCFunction)TrackObj_GetTrackLayer, 1, - "() -> (short _rv)"}, - {"SetTrackLayer", (PyCFunction)TrackObj_SetTrackLayer, 1, - "(short layer) -> None"}, - {"GetTrackAlternate", (PyCFunction)TrackObj_GetTrackAlternate, 1, - "() -> (Track _rv)"}, - {"SetTrackAlternate", (PyCFunction)TrackObj_SetTrackAlternate, 1, - "(Track alternateT) -> None"}, - {"GetTrackVolume", (PyCFunction)TrackObj_GetTrackVolume, 1, - "() -> (short _rv)"}, - {"SetTrackVolume", (PyCFunction)TrackObj_SetTrackVolume, 1, - "(short volume) -> None"}, - {"GetTrackDimensions", (PyCFunction)TrackObj_GetTrackDimensions, 1, - "() -> (Fixed width, Fixed height)"}, - {"SetTrackDimensions", (PyCFunction)TrackObj_SetTrackDimensions, 1, - "(Fixed width, Fixed height) -> None"}, - {"GetTrackUserData", (PyCFunction)TrackObj_GetTrackUserData, 1, - "() -> (UserData _rv)"}, - {"NewTrackMedia", (PyCFunction)TrackObj_NewTrackMedia, 1, - "(OSType mediaType, TimeScale timeScale, Handle dataRef, OSType dataRefType) -> (Media _rv)"}, - {"GetTrackMedia", (PyCFunction)TrackObj_GetTrackMedia, 1, - "() -> (Media _rv)"}, - {"InsertMediaIntoTrack", (PyCFunction)TrackObj_InsertMediaIntoTrack, 1, - "(TimeValue trackStart, TimeValue mediaTime, TimeValue mediaDuration, Fixed mediaRate) -> None"}, - {"InsertTrackSegment", (PyCFunction)TrackObj_InsertTrackSegment, 1, - "(Track dstTrack, TimeValue srcIn, TimeValue srcDuration, TimeValue dstIn) -> None"}, - {"InsertEmptyTrackSegment", (PyCFunction)TrackObj_InsertEmptyTrackSegment, 1, - "(TimeValue dstIn, TimeValue dstDuration) -> None"}, - {"DeleteTrackSegment", (PyCFunction)TrackObj_DeleteTrackSegment, 1, - "(TimeValue startTime, TimeValue duration) -> None"}, - {"ScaleTrackSegment", (PyCFunction)TrackObj_ScaleTrackSegment, 1, - "(TimeValue startTime, TimeValue oldDuration, TimeValue newDuration) -> None"}, - {"IsScrapMovie", (PyCFunction)TrackObj_IsScrapMovie, 1, - "() -> (Component _rv)"}, - {"CopyTrackSettings", (PyCFunction)TrackObj_CopyTrackSettings, 1, - "(Track dstTrack) -> None"}, - {"AddEmptyTrackToMovie", (PyCFunction)TrackObj_AddEmptyTrackToMovie, 1, - "(Movie dstMovie, Handle dataRef, OSType dataRefType) -> (Track dstTrack)"}, - {"AddTrackReference", (PyCFunction)TrackObj_AddTrackReference, 1, - "(Track refTrack, OSType refType) -> (long addedIndex)"}, - {"DeleteTrackReference", (PyCFunction)TrackObj_DeleteTrackReference, 1, - "(OSType refType, long index) -> None"}, - {"SetTrackReference", (PyCFunction)TrackObj_SetTrackReference, 1, - "(Track refTrack, OSType refType, long index) -> None"}, - {"GetTrackReference", (PyCFunction)TrackObj_GetTrackReference, 1, - "(OSType refType, long index) -> (Track _rv)"}, - {"GetNextTrackReferenceType", (PyCFunction)TrackObj_GetNextTrackReferenceType, 1, - "(OSType refType) -> (OSType _rv)"}, - {"GetTrackReferenceCount", (PyCFunction)TrackObj_GetTrackReferenceCount, 1, - "(OSType refType) -> (long _rv)"}, - {"GetTrackEditRate", (PyCFunction)TrackObj_GetTrackEditRate, 1, - "(TimeValue atTime) -> (Fixed _rv)"}, - {"GetTrackDataSize", (PyCFunction)TrackObj_GetTrackDataSize, 1, - "(TimeValue startTime, TimeValue duration) -> (long _rv)"}, - {"PtInTrack", (PyCFunction)TrackObj_PtInTrack, 1, - "(Point pt) -> (Boolean _rv)"}, - {"GetTrackNextInterestingTime", (PyCFunction)TrackObj_GetTrackNextInterestingTime, 1, - "(short interestingTimeFlags, TimeValue time, Fixed rate) -> (TimeValue interestingTime, TimeValue interestingDuration)"}, - {"GetTrackSegmentDisplayBoundsRgn", (PyCFunction)TrackObj_GetTrackSegmentDisplayBoundsRgn, 1, - "(TimeValue time, TimeValue duration) -> (RgnHandle _rv)"}, - {"GetTrackStatus", (PyCFunction)TrackObj_GetTrackStatus, 1, - "() -> (ComponentResult _rv)"}, - {"SetTrackLoadSettings", (PyCFunction)TrackObj_SetTrackLoadSettings, 1, - "(TimeValue preloadTime, TimeValue preloadDuration, long preloadFlags, long defaultHints) -> None"}, - {"GetTrackLoadSettings", (PyCFunction)TrackObj_GetTrackLoadSettings, 1, - "() -> (TimeValue preloadTime, TimeValue preloadDuration, long preloadFlags, long defaultHints)"}, - {NULL, NULL, 0} -}; - -PyMethodChain TrackObj_chain = { TrackObj_methods, NULL }; - -static PyObject *TrackObj_getattr(self, name) - TrackObject *self; - char *name; -{ - return Py_FindMethodInChain(&TrackObj_chain, (PyObject *)self, name); -} - -#define TrackObj_setattr NULL - -PyTypeObject Track_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Track", /*tp_name*/ - sizeof(TrackObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) TrackObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) TrackObj_getattr, /*tp_getattr*/ - (setattrfunc) TrackObj_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type Track ---------------------- */ - - -/* ----------------------- Object type Movie ------------------------ */ - -PyTypeObject Movie_Type; - -#define MovieObj_Check(x) ((x)->ob_type == &Movie_Type) - -typedef struct MovieObject { - PyObject_HEAD - Movie ob_itself; -} MovieObject; - -PyObject *MovieObj_New(itself) - Movie itself; -{ - MovieObject *it; - if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null Movie"); - return NULL; - } - it = PyObject_NEW(MovieObject, &Movie_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -MovieObj_Convert(v, p_itself) - PyObject *v; - Movie *p_itself; -{ - if (!MovieObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Movie required"); - return 0; - } - *p_itself = ((MovieObject *)v)->ob_itself; - return 1; -} - -static void MovieObj_dealloc(self) - MovieObject *self; -{ - DisposeMovie(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *MovieObj_MoviesTask(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long maxMilliSecToUse; - if (!PyArg_ParseTuple(_args, "l", - &maxMilliSecToUse)) - return NULL; - MoviesTask(_self->ob_itself, - maxMilliSecToUse); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_PrerollMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue time; - Fixed Rate; - if (!PyArg_ParseTuple(_args, "lO&", - &time, - PyMac_GetFixed, &Rate)) - return NULL; - _err = PrerollMovie(_self->ob_itself, - time, - Rate); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_LoadMovieIntoRam(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue time; - TimeValue duration; - long flags; - if (!PyArg_ParseTuple(_args, "lll", - &time, - &duration, - &flags)) - return NULL; - _err = LoadMovieIntoRam(_self->ob_itself, - time, - duration, - flags); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_SetMovieActive(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean active; - if (!PyArg_ParseTuple(_args, "b", - &active)) - return NULL; - SetMovieActive(_self->ob_itself, - active); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieActive(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieActive(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *MovieObj_StartMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - StartMovie(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_StopMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - StopMovie(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GoToBeginningOfMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GoToBeginningOfMovie(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GoToEndOfMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GoToEndOfMovie(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_IsMovieDone(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = IsMovieDone(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *MovieObj_GetMoviePreviewMode(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMoviePreviewMode(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *MovieObj_SetMoviePreviewMode(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean usePreview; - if (!PyArg_ParseTuple(_args, "b", - &usePreview)) - return NULL; - SetMoviePreviewMode(_self->ob_itself, - usePreview); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_ShowMoviePoster(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ShowMoviePoster(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieTimeBase(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeBase _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieTimeBase(_self->ob_itself); - _res = Py_BuildValue("O&", - TimeBaseObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetNextTrackForCompositing(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - Track theTrack; - if (!PyArg_ParseTuple(_args, "O&", - TrackObj_Convert, &theTrack)) - return NULL; - _rv = GetNextTrackForCompositing(_self->ob_itself, - theTrack); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetPrevTrackForCompositing(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - Track theTrack; - if (!PyArg_ParseTuple(_args, "O&", - TrackObj_Convert, &theTrack)) - return NULL; - _rv = GetPrevTrackForCompositing(_self->ob_itself, - theTrack); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetMoviePict(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle _rv; - TimeValue time; - if (!PyArg_ParseTuple(_args, "l", - &time)) - return NULL; - _rv = GetMoviePict(_self->ob_itself, - time); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetMoviePosterPict(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMoviePosterPict(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_UpdateMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = UpdateMovie(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieBox(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect boxRect; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetMovieBox(_self->ob_itself, - &boxRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &boxRect); - return _res; -} - -static PyObject *MovieObj_SetMovieBox(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect boxRect; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &boxRect)) - return NULL; - SetMovieBox(_self->ob_itself, - &boxRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieDisplayClipRgn(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieDisplayClipRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_SetMovieDisplayClipRgn(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle theClip; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theClip)) - return NULL; - SetMovieDisplayClipRgn(_self->ob_itself, - theClip); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieClipRgn(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieClipRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_SetMovieClipRgn(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle theClip; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theClip)) - return NULL; - SetMovieClipRgn(_self->ob_itself, - theClip); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieDisplayBoundsRgn(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieDisplayBoundsRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetMovieBoundsRgn(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieBoundsRgn(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_PutMovieIntoHandle(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle publicMovie; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &publicMovie)) - return NULL; - _err = PutMovieIntoHandle(_self->ob_itself, - publicMovie); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_PutMovieIntoDataFork(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short fRefNum; - long offset; - long maxSize; - if (!PyArg_ParseTuple(_args, "hll", - &fRefNum, - &offset, - &maxSize)) - return NULL; - _err = PutMovieIntoDataFork(_self->ob_itself, - fRefNum, - offset, - maxSize); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieTimeScale(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeScale _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieTimeScale(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieObj_SetMovieTimeScale(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeScale timeScale; - if (!PyArg_ParseTuple(_args, "l", - &timeScale)) - return NULL; - SetMovieTimeScale(_self->ob_itself, - timeScale); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieDuration(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieDuration(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieObj_GetMovieRate(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieRate(_self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildFixed, _rv); - return _res; -} - -static PyObject *MovieObj_SetMovieRate(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed rate; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetFixed, &rate)) - return NULL; - SetMovieRate(_self->ob_itself, - rate); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMoviePreferredRate(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMoviePreferredRate(_self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildFixed, _rv); - return _res; -} - -static PyObject *MovieObj_SetMoviePreferredRate(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Fixed rate; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetFixed, &rate)) - return NULL; - SetMoviePreferredRate(_self->ob_itself, - rate); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMoviePreferredVolume(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMoviePreferredVolume(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *MovieObj_SetMoviePreferredVolume(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short volume; - if (!PyArg_ParseTuple(_args, "h", - &volume)) - return NULL; - SetMoviePreferredVolume(_self->ob_itself, - volume); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieVolume(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieVolume(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *MovieObj_SetMovieVolume(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short volume; - if (!PyArg_ParseTuple(_args, "h", - &volume)) - return NULL; - SetMovieVolume(_self->ob_itself, - volume); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMoviePreviewTime(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue previewTime; - TimeValue previewDuration; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetMoviePreviewTime(_self->ob_itself, - &previewTime, - &previewDuration); - _res = Py_BuildValue("ll", - previewTime, - previewDuration); - return _res; -} - -static PyObject *MovieObj_SetMoviePreviewTime(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue previewTime; - TimeValue previewDuration; - if (!PyArg_ParseTuple(_args, "ll", - &previewTime, - &previewDuration)) - return NULL; - SetMoviePreviewTime(_self->ob_itself, - previewTime, - previewDuration); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMoviePosterTime(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMoviePosterTime(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieObj_SetMoviePosterTime(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue posterTime; - if (!PyArg_ParseTuple(_args, "l", - &posterTime)) - return NULL; - SetMoviePosterTime(_self->ob_itself, - posterTime); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieSelection(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue selectionTime; - TimeValue selectionDuration; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetMovieSelection(_self->ob_itself, - &selectionTime, - &selectionDuration); - _res = Py_BuildValue("ll", - selectionTime, - selectionDuration); - return _res; -} - -static PyObject *MovieObj_SetMovieSelection(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue selectionTime; - TimeValue selectionDuration; - if (!PyArg_ParseTuple(_args, "ll", - &selectionTime, - &selectionDuration)) - return NULL; - SetMovieSelection(_self->ob_itself, - selectionTime, - selectionDuration); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_SetMovieActiveSegment(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue startTime; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &startTime, - &duration)) - return NULL; - SetMovieActiveSegment(_self->ob_itself, - startTime, - duration); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieActiveSegment(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue startTime; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetMovieActiveSegment(_self->ob_itself, - &startTime, - &duration); - _res = Py_BuildValue("ll", - startTime, - duration); - return _res; -} - -static PyObject *MovieObj_SetMovieTimeValue(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue newtime; - if (!PyArg_ParseTuple(_args, "l", - &newtime)) - return NULL; - SetMovieTimeValue(_self->ob_itself, - newtime); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieUserData(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UserData _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieUserData(_self->ob_itself); - _res = Py_BuildValue("O&", - UserDataObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetMovieTrackCount(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieTrackCount(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieObj_GetMovieTrack(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - long trackID; - if (!PyArg_ParseTuple(_args, "l", - &trackID)) - return NULL; - _rv = GetMovieTrack(_self->ob_itself, - trackID); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetMovieIndTrack(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - long index; - if (!PyArg_ParseTuple(_args, "l", - &index)) - return NULL; - _rv = GetMovieIndTrack(_self->ob_itself, - index); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetMovieIndTrackType(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - long index; - OSType trackType; - long flags; - if (!PyArg_ParseTuple(_args, "lO&l", - &index, - PyMac_GetOSType, &trackType, - &flags)) - return NULL; - _rv = GetMovieIndTrackType(_self->ob_itself, - index, - trackType, - flags); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_NewMovieTrack(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Track _rv; - Fixed width; - Fixed height; - short trackVolume; - if (!PyArg_ParseTuple(_args, "O&O&h", - PyMac_GetFixed, &width, - PyMac_GetFixed, &height, - &trackVolume)) - return NULL; - _rv = NewMovieTrack(_self->ob_itself, - width, - height, - trackVolume); - _res = Py_BuildValue("O&", - TrackObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_SetAutoTrackAlternatesEnabled(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean enable; - if (!PyArg_ParseTuple(_args, "b", - &enable)) - return NULL; - SetAutoTrackAlternatesEnabled(_self->ob_itself, - enable); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_SelectMovieAlternates(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - SelectMovieAlternates(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_InsertMovieSegment(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Movie dstMovie; - TimeValue srcIn; - TimeValue srcDuration; - TimeValue dstIn; - if (!PyArg_ParseTuple(_args, "O&lll", - MovieObj_Convert, &dstMovie, - &srcIn, - &srcDuration, - &dstIn)) - return NULL; - _err = InsertMovieSegment(_self->ob_itself, - dstMovie, - srcIn, - srcDuration, - dstIn); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_InsertEmptyMovieSegment(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue dstIn; - TimeValue dstDuration; - if (!PyArg_ParseTuple(_args, "ll", - &dstIn, - &dstDuration)) - return NULL; - _err = InsertEmptyMovieSegment(_self->ob_itself, - dstIn, - dstDuration); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_DeleteMovieSegment(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue startTime; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &startTime, - &duration)) - return NULL; - _err = DeleteMovieSegment(_self->ob_itself, - startTime, - duration); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_ScaleMovieSegment(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - TimeValue startTime; - TimeValue oldDuration; - TimeValue newDuration; - if (!PyArg_ParseTuple(_args, "lll", - &startTime, - &oldDuration, - &newDuration)) - return NULL; - _err = ScaleMovieSegment(_self->ob_itself, - startTime, - oldDuration, - newDuration); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_CutMovieSelection(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CutMovieSelection(_self->ob_itself); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_CopyMovieSelection(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CopyMovieSelection(_self->ob_itself); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_PasteMovieSelection(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie src; - if (!PyArg_ParseTuple(_args, "O&", - MovieObj_Convert, &src)) - return NULL; - PasteMovieSelection(_self->ob_itself, - src); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_AddMovieSelection(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie src; - if (!PyArg_ParseTuple(_args, "O&", - MovieObj_Convert, &src)) - return NULL; - AddMovieSelection(_self->ob_itself, - src); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_ClearMovieSelection(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ClearMovieSelection(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_PutMovieIntoTypedHandle(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Track targetTrack; - OSType handleType; - Handle publicMovie; - TimeValue start; - TimeValue dur; - long flags; - ComponentInstance userComp; - if (!PyArg_ParseTuple(_args, "O&O&O&lllO&", - TrackObj_Convert, &targetTrack, - PyMac_GetOSType, &handleType, - ResObj_Convert, &publicMovie, - &start, - &dur, - &flags, - CmpInstObj_Convert, &userComp)) - return NULL; - _err = PutMovieIntoTypedHandle(_self->ob_itself, - targetTrack, - handleType, - publicMovie, - start, - dur, - flags, - userComp); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_CopyMovieSettings(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Movie dstMovie; - if (!PyArg_ParseTuple(_args, "O&", - MovieObj_Convert, &dstMovie)) - return NULL; - _err = CopyMovieSettings(_self->ob_itself, - dstMovie); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_ConvertMovieToFile(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Track onlyTrack; - FSSpec outputFile; - OSType fileType; - OSType creator; - ScriptCode scriptTag; - short resID; - long flags; - ComponentInstance userComp; - if (!PyArg_ParseTuple(_args, "O&O&O&O&hlO&", - TrackObj_Convert, &onlyTrack, - PyMac_GetFSSpec, &outputFile, - PyMac_GetOSType, &fileType, - PyMac_GetOSType, &creator, - &scriptTag, - &flags, - CmpInstObj_Convert, &userComp)) - return NULL; - _err = ConvertMovieToFile(_self->ob_itself, - onlyTrack, - &outputFile, - fileType, - creator, - scriptTag, - &resID, - flags, - userComp); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("h", - resID); - return _res; -} - -static PyObject *MovieObj_GetMovieDataSize(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - TimeValue startTime; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &startTime, - &duration)) - return NULL; - _rv = GetMovieDataSize(_self->ob_itself, - startTime, - duration); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *MovieObj_PtInMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point pt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &pt)) - return NULL; - _rv = PtInMovie(_self->ob_itself, - pt); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *MovieObj_SetMovieLanguage(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long language; - if (!PyArg_ParseTuple(_args, "l", - &language)) - return NULL; - SetMovieLanguage(_self->ob_itself, - language); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieNextInterestingTime(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short interestingTimeFlags; - short numMediaTypes; - OSType whichMediaTypes; - TimeValue time; - Fixed rate; - TimeValue interestingTime; - TimeValue interestingDuration; - if (!PyArg_ParseTuple(_args, "hhO&lO&", - &interestingTimeFlags, - &numMediaTypes, - PyMac_GetOSType, &whichMediaTypes, - &time, - PyMac_GetFixed, &rate)) - return NULL; - GetMovieNextInterestingTime(_self->ob_itself, - interestingTimeFlags, - numMediaTypes, - &whichMediaTypes, - time, - rate, - &interestingTime, - &interestingDuration); - _res = Py_BuildValue("ll", - interestingTime, - interestingDuration); - return _res; -} - -static PyObject *MovieObj_AddMovieResource(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short resRefNum; - short resId; - Str255 resName; - if (!PyArg_ParseTuple(_args, "hO&", - &resRefNum, - PyMac_GetStr255, resName)) - return NULL; - _err = AddMovieResource(_self->ob_itself, - resRefNum, - &resId, - resName); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("h", - resId); - return _res; -} - -static PyObject *MovieObj_UpdateMovieResource(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short resRefNum; - short resId; - Str255 resName; - if (!PyArg_ParseTuple(_args, "hhO&", - &resRefNum, - &resId, - PyMac_GetStr255, resName)) - return NULL; - _err = UpdateMovieResource(_self->ob_itself, - resRefNum, - resId, - resName); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_HasMovieChanged(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = HasMovieChanged(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *MovieObj_ClearMovieChanged(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ClearMovieChanged(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_SetMovieDefaultDataRef(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle dataRef; - OSType dataRefType; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &dataRef, - PyMac_GetOSType, &dataRefType)) - return NULL; - _err = SetMovieDefaultDataRef(_self->ob_itself, - dataRef, - dataRefType); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieDefaultDataRef(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle dataRef; - OSType dataRefType; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetMovieDefaultDataRef(_self->ob_itself, - &dataRef, - &dataRefType); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&O&", - ResObj_New, dataRef, - PyMac_BuildOSType, dataRefType); - return _res; -} - -static PyObject *MovieObj_SetMovieColorTable(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - CTabHandle ctab; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &ctab)) - return NULL; - _err = SetMovieColorTable(_self->ob_itself, - ctab); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieColorTable(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - CTabHandle ctab; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetMovieColorTable(_self->ob_itself, - &ctab); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - ResObj_New, ctab); - return _res; -} - -static PyObject *MovieObj_FlattenMovie(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long movieFlattenFlags; - FSSpec theFile; - OSType creator; - ScriptCode scriptTag; - long createMovieFileFlags; - short resId; - Str255 resName; - if (!PyArg_ParseTuple(_args, "lO&O&hlO&", - &movieFlattenFlags, - PyMac_GetFSSpec, &theFile, - PyMac_GetOSType, &creator, - &scriptTag, - &createMovieFileFlags, - PyMac_GetStr255, resName)) - return NULL; - FlattenMovie(_self->ob_itself, - movieFlattenFlags, - &theFile, - creator, - scriptTag, - createMovieFileFlags, - &resId, - resName); - _res = Py_BuildValue("h", - resId); - return _res; -} - -static PyObject *MovieObj_FlattenMovieData(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - long movieFlattenFlags; - FSSpec theFile; - OSType creator; - ScriptCode scriptTag; - long createMovieFileFlags; - if (!PyArg_ParseTuple(_args, "lO&O&hl", - &movieFlattenFlags, - PyMac_GetFSSpec, &theFile, - PyMac_GetOSType, &creator, - &scriptTag, - &createMovieFileFlags)) - return NULL; - _rv = FlattenMovieData(_self->ob_itself, - movieFlattenFlags, - &theFile, - creator, - scriptTag, - createMovieFileFlags); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_MovieSearchText(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Ptr text; - long size; - long searchFlags; - Track searchTrack; - TimeValue searchTime; - long searchOffset; - if (!PyArg_ParseTuple(_args, "sll", - &text, - &size, - &searchFlags)) - return NULL; - _err = MovieSearchText(_self->ob_itself, - text, - size, - searchFlags, - &searchTrack, - &searchTime, - &searchOffset); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&ll", - TrackObj_New, searchTrack, - searchTime, - searchOffset); - return _res; -} - -static PyObject *MovieObj_GetPosterBox(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect boxRect; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetPosterBox(_self->ob_itself, - &boxRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &boxRect); - return _res; -} - -static PyObject *MovieObj_SetPosterBox(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect boxRect; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &boxRect)) - return NULL; - SetPosterBox(_self->ob_itself, - &boxRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_GetMovieSegmentDisplayBoundsRgn(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - TimeValue time; - TimeValue duration; - if (!PyArg_ParseTuple(_args, "ll", - &time, - &duration)) - return NULL; - _rv = GetMovieSegmentDisplayBoundsRgn(_self->ob_itself, - time, - duration); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_GetMovieStatus(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - Track firstProblemTrack; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMovieStatus(_self->ob_itself, - &firstProblemTrack); - _res = Py_BuildValue("lO&", - _rv, - TrackObj_New, firstProblemTrack); - return _res; -} - -static PyObject *MovieObj_NewMovieController(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - MovieController _rv; - Rect movieRect; - long someFlags; - if (!PyArg_ParseTuple(_args, "O&l", - PyMac_GetRect, &movieRect, - &someFlags)) - return NULL; - _rv = NewMovieController(_self->ob_itself, - &movieRect, - someFlags); - _res = Py_BuildValue("O&", - MovieCtlObj_New, _rv); - return _res; -} - -static PyObject *MovieObj_PutMovieOnScrap(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long movieScrapFlags; - if (!PyArg_ParseTuple(_args, "l", - &movieScrapFlags)) - return NULL; - _err = PutMovieOnScrap(_self->ob_itself, - movieScrapFlags); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *MovieObj_SetMoviePlayHints(_self, _args) - MovieObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long flags; - long flagsMask; - if (!PyArg_ParseTuple(_args, "ll", - &flags, - &flagsMask)) - return NULL; - SetMoviePlayHints(_self->ob_itself, - flags, - flagsMask); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef MovieObj_methods[] = { - {"MoviesTask", (PyCFunction)MovieObj_MoviesTask, 1, - "(long maxMilliSecToUse) -> None"}, - {"PrerollMovie", (PyCFunction)MovieObj_PrerollMovie, 1, - "(TimeValue time, Fixed Rate) -> None"}, - {"LoadMovieIntoRam", (PyCFunction)MovieObj_LoadMovieIntoRam, 1, - "(TimeValue time, TimeValue duration, long flags) -> None"}, - {"SetMovieActive", (PyCFunction)MovieObj_SetMovieActive, 1, - "(Boolean active) -> None"}, - {"GetMovieActive", (PyCFunction)MovieObj_GetMovieActive, 1, - "() -> (Boolean _rv)"}, - {"StartMovie", (PyCFunction)MovieObj_StartMovie, 1, - "() -> None"}, - {"StopMovie", (PyCFunction)MovieObj_StopMovie, 1, - "() -> None"}, - {"GoToBeginningOfMovie", (PyCFunction)MovieObj_GoToBeginningOfMovie, 1, - "() -> None"}, - {"GoToEndOfMovie", (PyCFunction)MovieObj_GoToEndOfMovie, 1, - "() -> None"}, - {"IsMovieDone", (PyCFunction)MovieObj_IsMovieDone, 1, - "() -> (Boolean _rv)"}, - {"GetMoviePreviewMode", (PyCFunction)MovieObj_GetMoviePreviewMode, 1, - "() -> (Boolean _rv)"}, - {"SetMoviePreviewMode", (PyCFunction)MovieObj_SetMoviePreviewMode, 1, - "(Boolean usePreview) -> None"}, - {"ShowMoviePoster", (PyCFunction)MovieObj_ShowMoviePoster, 1, - "() -> None"}, - {"GetMovieTimeBase", (PyCFunction)MovieObj_GetMovieTimeBase, 1, - "() -> (TimeBase _rv)"}, - {"GetNextTrackForCompositing", (PyCFunction)MovieObj_GetNextTrackForCompositing, 1, - "(Track theTrack) -> (Track _rv)"}, - {"GetPrevTrackForCompositing", (PyCFunction)MovieObj_GetPrevTrackForCompositing, 1, - "(Track theTrack) -> (Track _rv)"}, - {"GetMoviePict", (PyCFunction)MovieObj_GetMoviePict, 1, - "(TimeValue time) -> (PicHandle _rv)"}, - {"GetMoviePosterPict", (PyCFunction)MovieObj_GetMoviePosterPict, 1, - "() -> (PicHandle _rv)"}, - {"UpdateMovie", (PyCFunction)MovieObj_UpdateMovie, 1, - "() -> None"}, - {"GetMovieBox", (PyCFunction)MovieObj_GetMovieBox, 1, - "() -> (Rect boxRect)"}, - {"SetMovieBox", (PyCFunction)MovieObj_SetMovieBox, 1, - "(Rect boxRect) -> None"}, - {"GetMovieDisplayClipRgn", (PyCFunction)MovieObj_GetMovieDisplayClipRgn, 1, - "() -> (RgnHandle _rv)"}, - {"SetMovieDisplayClipRgn", (PyCFunction)MovieObj_SetMovieDisplayClipRgn, 1, - "(RgnHandle theClip) -> None"}, - {"GetMovieClipRgn", (PyCFunction)MovieObj_GetMovieClipRgn, 1, - "() -> (RgnHandle _rv)"}, - {"SetMovieClipRgn", (PyCFunction)MovieObj_SetMovieClipRgn, 1, - "(RgnHandle theClip) -> None"}, - {"GetMovieDisplayBoundsRgn", (PyCFunction)MovieObj_GetMovieDisplayBoundsRgn, 1, - "() -> (RgnHandle _rv)"}, - {"GetMovieBoundsRgn", (PyCFunction)MovieObj_GetMovieBoundsRgn, 1, - "() -> (RgnHandle _rv)"}, - {"PutMovieIntoHandle", (PyCFunction)MovieObj_PutMovieIntoHandle, 1, - "(Handle publicMovie) -> None"}, - {"PutMovieIntoDataFork", (PyCFunction)MovieObj_PutMovieIntoDataFork, 1, - "(short fRefNum, long offset, long maxSize) -> None"}, - {"GetMovieTimeScale", (PyCFunction)MovieObj_GetMovieTimeScale, 1, - "() -> (TimeScale _rv)"}, - {"SetMovieTimeScale", (PyCFunction)MovieObj_SetMovieTimeScale, 1, - "(TimeScale timeScale) -> None"}, - {"GetMovieDuration", (PyCFunction)MovieObj_GetMovieDuration, 1, - "() -> (TimeValue _rv)"}, - {"GetMovieRate", (PyCFunction)MovieObj_GetMovieRate, 1, - "() -> (Fixed _rv)"}, - {"SetMovieRate", (PyCFunction)MovieObj_SetMovieRate, 1, - "(Fixed rate) -> None"}, - {"GetMoviePreferredRate", (PyCFunction)MovieObj_GetMoviePreferredRate, 1, - "() -> (Fixed _rv)"}, - {"SetMoviePreferredRate", (PyCFunction)MovieObj_SetMoviePreferredRate, 1, - "(Fixed rate) -> None"}, - {"GetMoviePreferredVolume", (PyCFunction)MovieObj_GetMoviePreferredVolume, 1, - "() -> (short _rv)"}, - {"SetMoviePreferredVolume", (PyCFunction)MovieObj_SetMoviePreferredVolume, 1, - "(short volume) -> None"}, - {"GetMovieVolume", (PyCFunction)MovieObj_GetMovieVolume, 1, - "() -> (short _rv)"}, - {"SetMovieVolume", (PyCFunction)MovieObj_SetMovieVolume, 1, - "(short volume) -> None"}, - {"GetMoviePreviewTime", (PyCFunction)MovieObj_GetMoviePreviewTime, 1, - "() -> (TimeValue previewTime, TimeValue previewDuration)"}, - {"SetMoviePreviewTime", (PyCFunction)MovieObj_SetMoviePreviewTime, 1, - "(TimeValue previewTime, TimeValue previewDuration) -> None"}, - {"GetMoviePosterTime", (PyCFunction)MovieObj_GetMoviePosterTime, 1, - "() -> (TimeValue _rv)"}, - {"SetMoviePosterTime", (PyCFunction)MovieObj_SetMoviePosterTime, 1, - "(TimeValue posterTime) -> None"}, - {"GetMovieSelection", (PyCFunction)MovieObj_GetMovieSelection, 1, - "() -> (TimeValue selectionTime, TimeValue selectionDuration)"}, - {"SetMovieSelection", (PyCFunction)MovieObj_SetMovieSelection, 1, - "(TimeValue selectionTime, TimeValue selectionDuration) -> None"}, - {"SetMovieActiveSegment", (PyCFunction)MovieObj_SetMovieActiveSegment, 1, - "(TimeValue startTime, TimeValue duration) -> None"}, - {"GetMovieActiveSegment", (PyCFunction)MovieObj_GetMovieActiveSegment, 1, - "() -> (TimeValue startTime, TimeValue duration)"}, - {"SetMovieTimeValue", (PyCFunction)MovieObj_SetMovieTimeValue, 1, - "(TimeValue newtime) -> None"}, - {"GetMovieUserData", (PyCFunction)MovieObj_GetMovieUserData, 1, - "() -> (UserData _rv)"}, - {"GetMovieTrackCount", (PyCFunction)MovieObj_GetMovieTrackCount, 1, - "() -> (long _rv)"}, - {"GetMovieTrack", (PyCFunction)MovieObj_GetMovieTrack, 1, - "(long trackID) -> (Track _rv)"}, - {"GetMovieIndTrack", (PyCFunction)MovieObj_GetMovieIndTrack, 1, - "(long index) -> (Track _rv)"}, - {"GetMovieIndTrackType", (PyCFunction)MovieObj_GetMovieIndTrackType, 1, - "(long index, OSType trackType, long flags) -> (Track _rv)"}, - {"NewMovieTrack", (PyCFunction)MovieObj_NewMovieTrack, 1, - "(Fixed width, Fixed height, short trackVolume) -> (Track _rv)"}, - {"SetAutoTrackAlternatesEnabled", (PyCFunction)MovieObj_SetAutoTrackAlternatesEnabled, 1, - "(Boolean enable) -> None"}, - {"SelectMovieAlternates", (PyCFunction)MovieObj_SelectMovieAlternates, 1, - "() -> None"}, - {"InsertMovieSegment", (PyCFunction)MovieObj_InsertMovieSegment, 1, - "(Movie dstMovie, TimeValue srcIn, TimeValue srcDuration, TimeValue dstIn) -> None"}, - {"InsertEmptyMovieSegment", (PyCFunction)MovieObj_InsertEmptyMovieSegment, 1, - "(TimeValue dstIn, TimeValue dstDuration) -> None"}, - {"DeleteMovieSegment", (PyCFunction)MovieObj_DeleteMovieSegment, 1, - "(TimeValue startTime, TimeValue duration) -> None"}, - {"ScaleMovieSegment", (PyCFunction)MovieObj_ScaleMovieSegment, 1, - "(TimeValue startTime, TimeValue oldDuration, TimeValue newDuration) -> None"}, - {"CutMovieSelection", (PyCFunction)MovieObj_CutMovieSelection, 1, - "() -> (Movie _rv)"}, - {"CopyMovieSelection", (PyCFunction)MovieObj_CopyMovieSelection, 1, - "() -> (Movie _rv)"}, - {"PasteMovieSelection", (PyCFunction)MovieObj_PasteMovieSelection, 1, - "(Movie src) -> None"}, - {"AddMovieSelection", (PyCFunction)MovieObj_AddMovieSelection, 1, - "(Movie src) -> None"}, - {"ClearMovieSelection", (PyCFunction)MovieObj_ClearMovieSelection, 1, - "() -> None"}, - {"PutMovieIntoTypedHandle", (PyCFunction)MovieObj_PutMovieIntoTypedHandle, 1, - "(Track targetTrack, OSType handleType, Handle publicMovie, TimeValue start, TimeValue dur, long flags, ComponentInstance userComp) -> None"}, - {"CopyMovieSettings", (PyCFunction)MovieObj_CopyMovieSettings, 1, - "(Movie dstMovie) -> None"}, - {"ConvertMovieToFile", (PyCFunction)MovieObj_ConvertMovieToFile, 1, - "(Track onlyTrack, FSSpec outputFile, OSType fileType, OSType creator, ScriptCode scriptTag, long flags, ComponentInstance userComp) -> (short resID)"}, - {"GetMovieDataSize", (PyCFunction)MovieObj_GetMovieDataSize, 1, - "(TimeValue startTime, TimeValue duration) -> (long _rv)"}, - {"PtInMovie", (PyCFunction)MovieObj_PtInMovie, 1, - "(Point pt) -> (Boolean _rv)"}, - {"SetMovieLanguage", (PyCFunction)MovieObj_SetMovieLanguage, 1, - "(long language) -> None"}, - {"GetMovieNextInterestingTime", (PyCFunction)MovieObj_GetMovieNextInterestingTime, 1, - "(short interestingTimeFlags, short numMediaTypes, OSType whichMediaTypes, TimeValue time, Fixed rate) -> (TimeValue interestingTime, TimeValue interestingDuration)"}, - {"AddMovieResource", (PyCFunction)MovieObj_AddMovieResource, 1, - "(short resRefNum, Str255 resName) -> (short resId)"}, - {"UpdateMovieResource", (PyCFunction)MovieObj_UpdateMovieResource, 1, - "(short resRefNum, short resId, Str255 resName) -> None"}, - {"HasMovieChanged", (PyCFunction)MovieObj_HasMovieChanged, 1, - "() -> (Boolean _rv)"}, - {"ClearMovieChanged", (PyCFunction)MovieObj_ClearMovieChanged, 1, - "() -> None"}, - {"SetMovieDefaultDataRef", (PyCFunction)MovieObj_SetMovieDefaultDataRef, 1, - "(Handle dataRef, OSType dataRefType) -> None"}, - {"GetMovieDefaultDataRef", (PyCFunction)MovieObj_GetMovieDefaultDataRef, 1, - "() -> (Handle dataRef, OSType dataRefType)"}, - {"SetMovieColorTable", (PyCFunction)MovieObj_SetMovieColorTable, 1, - "(CTabHandle ctab) -> None"}, - {"GetMovieColorTable", (PyCFunction)MovieObj_GetMovieColorTable, 1, - "() -> (CTabHandle ctab)"}, - {"FlattenMovie", (PyCFunction)MovieObj_FlattenMovie, 1, - "(long movieFlattenFlags, FSSpec theFile, OSType creator, ScriptCode scriptTag, long createMovieFileFlags, Str255 resName) -> (short resId)"}, - {"FlattenMovieData", (PyCFunction)MovieObj_FlattenMovieData, 1, - "(long movieFlattenFlags, FSSpec theFile, OSType creator, ScriptCode scriptTag, long createMovieFileFlags) -> (Movie _rv)"}, - {"MovieSearchText", (PyCFunction)MovieObj_MovieSearchText, 1, - "(Ptr text, long size, long searchFlags) -> (Track searchTrack, TimeValue searchTime, long searchOffset)"}, - {"GetPosterBox", (PyCFunction)MovieObj_GetPosterBox, 1, - "() -> (Rect boxRect)"}, - {"SetPosterBox", (PyCFunction)MovieObj_SetPosterBox, 1, - "(Rect boxRect) -> None"}, - {"GetMovieSegmentDisplayBoundsRgn", (PyCFunction)MovieObj_GetMovieSegmentDisplayBoundsRgn, 1, - "(TimeValue time, TimeValue duration) -> (RgnHandle _rv)"}, - {"GetMovieStatus", (PyCFunction)MovieObj_GetMovieStatus, 1, - "() -> (ComponentResult _rv, Track firstProblemTrack)"}, - {"NewMovieController", (PyCFunction)MovieObj_NewMovieController, 1, - "(Rect movieRect, long someFlags) -> (MovieController _rv)"}, - {"PutMovieOnScrap", (PyCFunction)MovieObj_PutMovieOnScrap, 1, - "(long movieScrapFlags) -> None"}, - {"SetMoviePlayHints", (PyCFunction)MovieObj_SetMoviePlayHints, 1, - "(long flags, long flagsMask) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain MovieObj_chain = { MovieObj_methods, NULL }; - -static PyObject *MovieObj_getattr(self, name) - MovieObject *self; - char *name; -{ - return Py_FindMethodInChain(&MovieObj_chain, (PyObject *)self, name); -} - -#define MovieObj_setattr NULL - -PyTypeObject Movie_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Movie", /*tp_name*/ - sizeof(MovieObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) MovieObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) MovieObj_getattr, /*tp_getattr*/ - (setattrfunc) MovieObj_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type Movie ---------------------- */ - - -static PyObject *Qt_EnterMovies(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = EnterMovies(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_ExitMovies(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ExitMovies(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_GetMoviesError(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetMoviesError(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_ClearMoviesStickyError(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ClearMoviesStickyError(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_GetMoviesStickyError(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetMoviesStickyError(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_DisposeMatte(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PixMapHandle theMatte; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theMatte)) - return NULL; - DisposeMatte(theMatte); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_NewMovie(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - long flags; - if (!PyArg_ParseTuple(_args, "l", - &flags)) - return NULL; - _rv = NewMovie(flags); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *Qt_GetDataHandler(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Component _rv; - Handle dataRef; - OSType dataHandlerSubType; - long flags; - if (!PyArg_ParseTuple(_args, "O&O&l", - ResObj_Convert, &dataRef, - PyMac_GetOSType, &dataHandlerSubType, - &flags)) - return NULL; - _rv = GetDataHandler(dataRef, - dataHandlerSubType, - flags); - _res = Py_BuildValue("O&", - CmpObj_New, _rv); - return _res; -} - -static PyObject *Qt_PasteHandleIntoMovie(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle h; - OSType handleType; - Movie theMovie; - long flags; - ComponentInstance userComp; - if (!PyArg_ParseTuple(_args, "O&O&O&lO&", - ResObj_Convert, &h, - PyMac_GetOSType, &handleType, - MovieObj_Convert, &theMovie, - &flags, - CmpInstObj_Convert, &userComp)) - return NULL; - _err = PasteHandleIntoMovie(h, - handleType, - theMovie, - flags, - userComp); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_TrackTimeToMediaTime(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeValue _rv; - TimeValue value; - Track theTrack; - if (!PyArg_ParseTuple(_args, "lO&", - &value, - TrackObj_Convert, &theTrack)) - return NULL; - _rv = TrackTimeToMediaTime(value, - theTrack); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Qt_NewUserData(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - UserData theUserData; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = NewUserData(&theUserData); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - UserDataObj_New, theUserData); - return _res; -} - -static PyObject *Qt_NewUserDataFromHandle(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle h; - UserData theUserData; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &h)) - return NULL; - _err = NewUserDataFromHandle(h, - &theUserData); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - UserDataObj_New, theUserData); - return _res; -} - -static PyObject *Qt_CreateMovieFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - FSSpec fileSpec; - OSType creator; - ScriptCode scriptTag; - long createMovieFileFlags; - short resRefNum; - Movie newmovie; - if (!PyArg_ParseTuple(_args, "O&O&hl", - PyMac_GetFSSpec, &fileSpec, - PyMac_GetOSType, &creator, - &scriptTag, - &createMovieFileFlags)) - return NULL; - _err = CreateMovieFile(&fileSpec, - creator, - scriptTag, - createMovieFileFlags, - &resRefNum, - &newmovie); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("hO&", - resRefNum, - MovieObj_New, newmovie); - return _res; -} - -static PyObject *Qt_OpenMovieFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - FSSpec fileSpec; - short resRefNum; - SInt8 permission; - if (!PyArg_ParseTuple(_args, "O&b", - PyMac_GetFSSpec, &fileSpec, - &permission)) - return NULL; - _err = OpenMovieFile(&fileSpec, - &resRefNum, - permission); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("h", - resRefNum); - return _res; -} - -static PyObject *Qt_CloseMovieFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short resRefNum; - if (!PyArg_ParseTuple(_args, "h", - &resRefNum)) - return NULL; - _err = CloseMovieFile(resRefNum); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_DeleteMovieFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - FSSpec fileSpec; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetFSSpec, &fileSpec)) - return NULL; - _err = DeleteMovieFile(&fileSpec); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_NewMovieFromFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Movie theMovie; - short resRefNum; - short newMovieFlags; - Boolean dataRefWasChanged; - if (!PyArg_ParseTuple(_args, "hh", - &resRefNum, - &newMovieFlags)) - return NULL; - _err = NewMovieFromFile(&theMovie, - resRefNum, - (short *)0, - (StringPtr)0, - newMovieFlags, - &dataRefWasChanged); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&b", - MovieObj_New, theMovie, - dataRefWasChanged); - return _res; -} - -static PyObject *Qt_NewMovieFromHandle(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Movie theMovie; - Handle h; - short newMovieFlags; - Boolean dataRefWasChanged; - if (!PyArg_ParseTuple(_args, "O&h", - ResObj_Convert, &h, - &newMovieFlags)) - return NULL; - _err = NewMovieFromHandle(&theMovie, - h, - newMovieFlags, - &dataRefWasChanged); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&b", - MovieObj_New, theMovie, - dataRefWasChanged); - return _res; -} - -static PyObject *Qt_NewMovieFromDataFork(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Movie theMovie; - short fRefNum; - long fileOffset; - short newMovieFlags; - Boolean dataRefWasChanged; - if (!PyArg_ParseTuple(_args, "hlh", - &fRefNum, - &fileOffset, - &newMovieFlags)) - return NULL; - _err = NewMovieFromDataFork(&theMovie, - fRefNum, - fileOffset, - newMovieFlags, - &dataRefWasChanged); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&b", - MovieObj_New, theMovie, - dataRefWasChanged); - return _res; -} - -static PyObject *Qt_RemoveMovieResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short resRefNum; - short resId; - if (!PyArg_ParseTuple(_args, "hh", - &resRefNum, - &resId)) - return NULL; - _err = RemoveMovieResource(resRefNum, - resId); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_GetVideoMediaGraphicsMode(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - HandlerError _rv; - MediaHandler mh; - long graphicsMode; - RGBColor opColor; - if (!PyArg_ParseTuple(_args, "O&", - CmpInstObj_Convert, &mh)) - return NULL; - _rv = GetVideoMediaGraphicsMode(mh, - &graphicsMode, - &opColor); - _res = Py_BuildValue("llO&", - _rv, - graphicsMode, - QdRGB_New, &opColor); - return _res; -} - -static PyObject *Qt_SetVideoMediaGraphicsMode(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - HandlerError _rv; - MediaHandler mh; - long graphicsMode; - RGBColor opColor; - if (!PyArg_ParseTuple(_args, "O&lO&", - CmpInstObj_Convert, &mh, - &graphicsMode, - QdRGB_Convert, &opColor)) - return NULL; - _rv = SetVideoMediaGraphicsMode(mh, - graphicsMode, - &opColor); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Qt_GetSoundMediaBalance(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - HandlerError _rv; - MediaHandler mh; - short balance; - if (!PyArg_ParseTuple(_args, "O&", - CmpInstObj_Convert, &mh)) - return NULL; - _rv = GetSoundMediaBalance(mh, - &balance); - _res = Py_BuildValue("lh", - _rv, - balance); - return _res; -} - -static PyObject *Qt_SetSoundMediaBalance(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - HandlerError _rv; - MediaHandler mh; - short balance; - if (!PyArg_ParseTuple(_args, "O&h", - CmpInstObj_Convert, &mh, - &balance)) - return NULL; - _rv = SetSoundMediaBalance(mh, - balance); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Qt_FindNextText(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ComponentResult _rv; - MediaHandler mh; - Ptr text; - long size; - short findFlags; - TimeValue startTime; - TimeValue foundTime; - TimeValue foundDuration; - long offset; - if (!PyArg_ParseTuple(_args, "O&slhl", - CmpInstObj_Convert, &mh, - &text, - &size, - &findFlags, - &startTime)) - return NULL; - _rv = FindNextText(mh, - text, - size, - findFlags, - startTime, - &foundTime, - &foundDuration, - &offset); - _res = Py_BuildValue("llll", - _rv, - foundTime, - foundDuration, - offset); - return _res; -} - -static PyObject *Qt_NewMovieFromScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Movie _rv; - long newMovieFlags; - if (!PyArg_ParseTuple(_args, "l", - &newMovieFlags)) - return NULL; - _rv = NewMovieFromScrap(newMovieFlags); - _res = Py_BuildValue("O&", - MovieObj_New, _rv); - return _res; -} - -static PyObject *Qt_NewTimeBase(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TimeBase _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = NewTimeBase(); - _res = Py_BuildValue("O&", - TimeBaseObj_New, _rv); - return _res; -} - -static PyObject *Qt_AlignWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr wp; - Boolean front; - if (!PyArg_ParseTuple(_args, "O&b", - WinObj_Convert, &wp, - &front)) - return NULL; - AlignWindow(wp, - front, - (Rect *)0, - (ICMAlignmentProcRecordPtr)0); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qt_DragAlignedWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr wp; - Point startPt; - Rect boundsRect; - if (!PyArg_ParseTuple(_args, "O&O&O&", - WinObj_Convert, &wp, - PyMac_GetPoint, &startPt, - PyMac_GetRect, &boundsRect)) - return NULL; - DragAlignedWindow(wp, - startPt, - &boundsRect, - (Rect *)0, - (ICMAlignmentProcRecordPtr)0); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef Qt_methods[] = { - {"EnterMovies", (PyCFunction)Qt_EnterMovies, 1, - "() -> None"}, - {"ExitMovies", (PyCFunction)Qt_ExitMovies, 1, - "() -> None"}, - {"GetMoviesError", (PyCFunction)Qt_GetMoviesError, 1, - "() -> None"}, - {"ClearMoviesStickyError", (PyCFunction)Qt_ClearMoviesStickyError, 1, - "() -> None"}, - {"GetMoviesStickyError", (PyCFunction)Qt_GetMoviesStickyError, 1, - "() -> None"}, - {"DisposeMatte", (PyCFunction)Qt_DisposeMatte, 1, - "(PixMapHandle theMatte) -> None"}, - {"NewMovie", (PyCFunction)Qt_NewMovie, 1, - "(long flags) -> (Movie _rv)"}, - {"GetDataHandler", (PyCFunction)Qt_GetDataHandler, 1, - "(Handle dataRef, OSType dataHandlerSubType, long flags) -> (Component _rv)"}, - {"PasteHandleIntoMovie", (PyCFunction)Qt_PasteHandleIntoMovie, 1, - "(Handle h, OSType handleType, Movie theMovie, long flags, ComponentInstance userComp) -> None"}, - {"TrackTimeToMediaTime", (PyCFunction)Qt_TrackTimeToMediaTime, 1, - "(TimeValue value, Track theTrack) -> (TimeValue _rv)"}, - {"NewUserData", (PyCFunction)Qt_NewUserData, 1, - "() -> (UserData theUserData)"}, - {"NewUserDataFromHandle", (PyCFunction)Qt_NewUserDataFromHandle, 1, - "(Handle h) -> (UserData theUserData)"}, - {"CreateMovieFile", (PyCFunction)Qt_CreateMovieFile, 1, - "(FSSpec fileSpec, OSType creator, ScriptCode scriptTag, long createMovieFileFlags) -> (short resRefNum, Movie newmovie)"}, - {"OpenMovieFile", (PyCFunction)Qt_OpenMovieFile, 1, - "(FSSpec fileSpec, SInt8 permission) -> (short resRefNum)"}, - {"CloseMovieFile", (PyCFunction)Qt_CloseMovieFile, 1, - "(short resRefNum) -> None"}, - {"DeleteMovieFile", (PyCFunction)Qt_DeleteMovieFile, 1, - "(FSSpec fileSpec) -> None"}, - {"NewMovieFromFile", (PyCFunction)Qt_NewMovieFromFile, 1, - "(short resRefNum, short newMovieFlags) -> (Movie theMovie, Boolean dataRefWasChanged)"}, - {"NewMovieFromHandle", (PyCFunction)Qt_NewMovieFromHandle, 1, - "(Handle h, short newMovieFlags) -> (Movie theMovie, Boolean dataRefWasChanged)"}, - {"NewMovieFromDataFork", (PyCFunction)Qt_NewMovieFromDataFork, 1, - "(short fRefNum, long fileOffset, short newMovieFlags) -> (Movie theMovie, Boolean dataRefWasChanged)"}, - {"RemoveMovieResource", (PyCFunction)Qt_RemoveMovieResource, 1, - "(short resRefNum, short resId) -> None"}, - {"GetVideoMediaGraphicsMode", (PyCFunction)Qt_GetVideoMediaGraphicsMode, 1, - "(MediaHandler mh) -> (HandlerError _rv, long graphicsMode, RGBColor opColor)"}, - {"SetVideoMediaGraphicsMode", (PyCFunction)Qt_SetVideoMediaGraphicsMode, 1, - "(MediaHandler mh, long graphicsMode, RGBColor opColor) -> (HandlerError _rv)"}, - {"GetSoundMediaBalance", (PyCFunction)Qt_GetSoundMediaBalance, 1, - "(MediaHandler mh) -> (HandlerError _rv, short balance)"}, - {"SetSoundMediaBalance", (PyCFunction)Qt_SetSoundMediaBalance, 1, - "(MediaHandler mh, short balance) -> (HandlerError _rv)"}, - {"FindNextText", (PyCFunction)Qt_FindNextText, 1, - "(MediaHandler mh, Ptr text, long size, short findFlags, TimeValue startTime) -> (ComponentResult _rv, TimeValue foundTime, TimeValue foundDuration, long offset)"}, - {"NewMovieFromScrap", (PyCFunction)Qt_NewMovieFromScrap, 1, - "(long newMovieFlags) -> (Movie _rv)"}, - {"NewTimeBase", (PyCFunction)Qt_NewTimeBase, 1, - "() -> (TimeBase _rv)"}, - {"AlignWindow", (PyCFunction)Qt_AlignWindow, 1, - "(WindowPtr wp, Boolean front) -> None"}, - {"DragAlignedWindow", (PyCFunction)Qt_DragAlignedWindow, 1, - "(WindowPtr wp, Point startPt, Rect boundsRect) -> None"}, - {NULL, NULL, 0} -}; - - - - -void initQt() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Qt", Qt_methods); - d = PyModule_GetDict(m); - Qt_Error = PyMac_GetOSErrException(); - if (Qt_Error == NULL || - PyDict_SetItemString(d, "Error", Qt_Error) != 0) - Py_FatalError("can't initialize Qt.Error"); -} - -/* ========================= End module Qt ========================== */ - diff --git a/Mac/Modules/qt/qtscan.py b/Mac/Modules/qt/qtscan.py deleted file mode 100644 index 7fba93654a..0000000000 --- a/Mac/Modules/qt/qtscan.py +++ /dev/null @@ -1,113 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "QuickTime" -SHORT = "qt" -OBJECTS = ("Movie", "Track", "Media", "UserData", "TimeBase", "MovieController") - -def main(): - input = "Movies.h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t in OBJECTS and m == "InMode": - classname = "Method" - listname = t + "_methods" - return classname, listname - - def makeblacklistnames(self): - return [ - "DisposeMovie", # Done on python-object disposal - "DisposeMovieTrack", # ditto - "DisposeTrackMedia", # ditto - "DisposeUserData", # ditto - "DisposeTimeBase", # ditto - "DisposeMovieController", # ditto - "GetMovieCreationTime", # type "unsigned long" in C, inparseable - "GetMovieModificationTime", # Ditto - "GetTrackCreationTime", # ditto - "GetTrackModificationTime", # Ditto - "GetMediaCreationTime", # ditto - "GetMediaModificationTime", # Ditto - # The following 4 use 'void *' in an uncontrolled way - # TBD when I've read the manual... - "GetUserDataItem", - "SetUserDataItem", - "SetTextSampleData", - # bgen gets the argument in/out wrong.. - "AddTextSample", - "AddTESample", - "AddHiliteSample", - "HiliteTextSample", - ] - - def makeblacklisttypes(self): - return [ - # I don't think we want to do these - "QTSyncTaskPtr", - # We dont do callbacks yet, so no need for these - "QTCallBack", - # Skipped for now, due to laziness - "TimeRecord", - "TimeRecord_ptr", - "TrackEditState", - "MovieEditState", - "MatrixRecord", - "MatrixRecord_ptr", - "SampleReferencePtr", -# "SampleDescription", -# "SoundDescription", -# "TextDescription", -# "MusicDescription", - # I dont know yet how to do these. - "CGrafPtr", - "GDHandle", - # Routine pointers, not yet. - "MoviesErrorUPP", - "MoviePreviewCallOutUPP", - "MovieDrawingCompleteUPP", - "QTCallBackUPP", - "TextMediaUPP", - "MovieProgressUPP", - "MovieRgnCoverUPP", - "MCActionFilterUPP", - "MCActionFilterWithRefConUPP", - "GetMovieUPP", - "ModalFilterUPP", - ] - - def makerepairinstructions(self): - return [ - ([('FSSpec', '*', 'OutMode')], [('FSSpec_ptr', '*', 'InMode')]), - - # Movie controller creation - ([('ComponentInstance', 'NewMovieController', 'ReturnMode')], - [('MovieController', '*', 'ReturnMode')]), - - # NewMovieFromFile - ([('short', 'resId', 'OutMode'), ('StringPtr', 'resName', 'InMode')], - [('dummyshortptr', 'resId', 'InMode'), ('dummyStringPtr', 'resName', 'InMode')]), - - # MCDoAction - ([('void', 'params', 'OutMode')], [('mcactionparams', 'params', 'InMode')]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/qt/qtsupport.py b/Mac/Modules/qt/qtsupport.py deleted file mode 100644 index 17ba808d22..0000000000 --- a/Mac/Modules/qt/qtsupport.py +++ /dev/null @@ -1,224 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -#error missing SetActionFilter - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'Movies.h' # The Apple header file -MODNAME = 'Qt' # The name of the module -OBJECTNAME = 'Movie' # The basic name of the objects used here - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = "Movie" # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ - -/* Exported by Cmmodule.c: */ -extern PyObject *CmpObj_New(Component); -extern int CmpObj_Convert(PyObject *, Component *); -extern PyObject *CmpInstObj_New(ComponentInstance); -extern int CmpInstObj_Convert(PyObject *, ComponentInstance *); - -/* Exported by Qdmodule.c: */ -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); - -/* Our own, used before defined: */ -staticforward PyObject *TrackObj_New(Track); -staticforward int TrackObj_Convert(PyObject *, Track *); -staticforward PyObject *MovieObj_New(Movie); -staticforward int MovieObj_Convert(PyObject *, Movie *); -staticforward PyObject *MovieCtlObj_New(MovieController); -staticforward int MovieCtlObj_Convert(PyObject *, MovieController *); - - -""" - -# Our (opaque) objects -Movie = OpaqueByValueType('Movie', 'MovieObj') -Track = OpaqueByValueType('Track', 'TrackObj') -Media = OpaqueByValueType('Media', 'MediaObj') -UserData = OpaqueByValueType('UserData', 'UserDataObj') -TimeBase = OpaqueByValueType('TimeBase', 'TimeBaseObj') -MovieController = OpaqueByValueType('MovieController', 'MovieCtlObj') - -# Other opaque objects -Component = OpaqueByValueType('Component', 'CmpObj') -MediaHandlerComponent = OpaqueByValueType('MediaHandlerComponent', 'CmpObj') -DataHandlerComponent = OpaqueByValueType('DataHandlerComponent', 'CmpObj') - -ComponentInstance = OpaqueByValueType('ComponentInstance', 'CmpInstObj') -MediaHandler = OpaqueByValueType('MediaHandler', 'CmpInstObj') -DataHandler = OpaqueByValueType('DataHandler', 'CmpInstObj') - -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") -PicHandle = OpaqueByValueType("PicHandle", "ResObj") -CTabHandle = OpaqueByValueType("CTabHandle", "ResObj") -PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj") -SampleDescriptionHandle = OpaqueByValueType("SampleDescriptionHandle", "ResObj") -TEHandle = OpaqueByValueType("TEHandle", "ResObj") -# Silly Apple, passing an OStype by reference... -OSType_ptr = OpaqueType("OSType", "PyMac_BuildOSType", "PyMac_GetOSType") - -RGBColor = OpaqueType("RGBColor", "QdRGB") -RGBColor_ptr = OpaqueType("RGBColor", "QdRGB") - -# Non-opaque types, mostly integer-ish -TimeValue = Type("TimeValue", "l") -TimeScale = Type("TimeScale", "l") -TimeBaseFlags = Type("TimeBaseFlags", "l") -QTCallBackFlags = Type("QTCallBackFlags", "h") -TimeBaseStatus = Type("TimeBaseStatus", "l") -QTCallBackType = Type("QTCallBackType", "h") -nextTimeFlagsEnum = Type("nextTimeFlagsEnum", "h") -createMovieFileFlagsEnum = Type("createMovieFileFlagsEnum", "l") -movieFlattenFlagsEnum = Type("movieFlattenFlagsEnum", "l") -dataRefAttributesFlags = Type("dataRefAttributesFlags", "l") -playHintsEnum = Type("playHintsEnum", "l") -mediaHandlerFlagsEnum = Type("mediaHandlerFlagsEnum", "l") -ComponentResult = Type("ComponentResult", "l") -HandlerError = Type("HandlerError", "l") -Ptr = InputOnlyType("Ptr", "s") -StringPtr = Type("StringPtr", "s") -mcactionparams = InputOnlyType("void *", "s") - -# Could-not-be-bothered-types (NewMovieFromFile) -dummyshortptr = FakeType('(short *)0') -dummyStringPtr = FakeType('(StringPtr)0') - -class MovieObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null Movie"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("DisposeMovie(%s);", itselfname) - -class TrackObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null Track"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("DisposeMovieTrack(%s);", itselfname) - -class MediaObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null Media"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("DisposeTrackMedia(%s);", itselfname) - -class UserDataObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null UserData"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("DisposeUserData(%s);", itselfname) - -class TimeBaseObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null TimeBase"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("DisposeTimeBase(%s);", itselfname) - -class MovieCtlObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create null MovieController"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("DisposeMovieController(%s);", itselfname) - -# From here on it's basically all boiler plate... - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -Movie_object = MovieObjectDefinition('Movie', 'MovieObj', 'Movie') -Track_object = TrackObjectDefinition('Track', 'TrackObj', 'Track') -Media_object = MediaObjectDefinition('Media', 'MediaObj', 'Media') -UserData_object = UserDataObjectDefinition('UserData', 'UserDataObj', 'UserData') -TimeBase_object = TimeBaseObjectDefinition('TimeBase', 'TimeBaseObj', 'TimeBase') -MovieController_object = MovieCtlObjectDefinition('MovieController', 'MovieCtlObj', 'MovieController') - -module.addobject(MovieController_object) -module.addobject(TimeBase_object) -module.addobject(UserData_object) -module.addobject(Media_object) -module.addobject(Track_object) -module.addobject(Movie_object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -MovieController_methods = [] -TimeBase_methods = [] -UserData_methods = [] -Media_methods = [] -Track_methods = [] -Movie_methods = [] -execfile(INPUTFILE) - -# -# Some functions from ImageCompression.h that we need: -ICMAlignmentProcRecordPtr = FakeType('(ICMAlignmentProcRecordPtr)0') -dummyRect = FakeType('(Rect *)0') - -f = Function(void, 'AlignWindow', - (WindowPtr, 'wp', InMode), - (Boolean, 'front', InMode), - (dummyRect, 'alignmentRect', InMode), - (ICMAlignmentProcRecordPtr, 'alignmentProc', InMode), -) -functions.append(f) - -f = Function(void, 'DragAlignedWindow', - (WindowPtr, 'wp', InMode), - (Point, 'startPt', InMode), - (Rect_ptr, 'boundsRect', InMode), - (dummyRect, 'alignmentRect', InMode), - (ICMAlignmentProcRecordPtr, 'alignmentProc', InMode), -) -functions.append(f) - - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -for f in MovieController_methods: MovieController_object.add(f) -for f in TimeBase_methods: TimeBase_object.add(f) -for f in UserData_methods: UserData_object.add(f) -for f in Media_methods: Media_object.add(f) -for f in Track_methods: Track_object.add(f) -for f in Movie_methods: Movie_object.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c deleted file mode 100644 index dd5d75ac5a..0000000000 --- a/Mac/Modules/res/Resmodule.c +++ /dev/null @@ -1,1392 +0,0 @@ - -/* =========================== Module Res =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -static PyObject *Res_Error; - -/* ---------------------- Object type Resource ---------------------- */ - -PyTypeObject Resource_Type; - -#define ResObj_Check(x) ((x)->ob_type == &Resource_Type) - -typedef struct ResourceObject { - PyObject_HEAD - Handle ob_itself; -} ResourceObject; - -PyObject *ResObj_New(itself) - Handle itself; -{ - ResourceObject *it; - if (itself == NULL) return PyMac_Error(resNotFound); - it = PyObject_NEW(ResourceObject, &Resource_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -ResObj_Convert(v, p_itself) - PyObject *v; - Handle *p_itself; -{ - if (!ResObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Resource required"); - return 0; - } - *p_itself = ((ResourceObject *)v)->ob_itself; - return 1; -} - -static void ResObj_dealloc(self) - ResourceObject *self; -{ - /* Cleanup of self->ob_itself goes here */ - PyMem_DEL(self); -} - -static PyObject *ResObj_HomeResFile(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = HomeResFile(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *ResObj_LoadResource(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - LoadResource(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_ReleaseResource(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ReleaseResource(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_DetachResource(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DetachResource(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_GetResAttrs(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetResAttrs(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *ResObj_GetResInfo(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short theID; - ResType theType; - Str255 name; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetResInfo(_self->ob_itself, - &theID, - &theType, - name); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("hO&O&", - theID, - PyMac_BuildOSType, theType, - PyMac_BuildStr255, name); - return _res; -} - -static PyObject *ResObj_SetResInfo(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short theID; - Str255 name; - if (!PyArg_ParseTuple(_args, "hO&", - &theID, - PyMac_GetStr255, name)) - return NULL; - SetResInfo(_self->ob_itself, - theID, - name); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_AddResource(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ResType theType; - short theID; - Str255 name; - if (!PyArg_ParseTuple(_args, "O&hO&", - PyMac_GetOSType, &theType, - &theID, - PyMac_GetStr255, name)) - return NULL; - AddResource(_self->ob_itself, - theType, - theID, - name); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_GetResourceSizeOnDisk(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetResourceSizeOnDisk(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *ResObj_GetMaxResourceSize(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetMaxResourceSize(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *ResObj_RsrcMapEntry(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = RsrcMapEntry(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *ResObj_SetResAttrs(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short attrs; - if (!PyArg_ParseTuple(_args, "h", - &attrs)) - return NULL; - SetResAttrs(_self->ob_itself, - attrs); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_ChangedResource(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ChangedResource(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_RemoveResource(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - RemoveResource(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_WriteResource(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WriteResource(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_SetResourceSize(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long newSize; - if (!PyArg_ParseTuple(_args, "l", - &newSize)) - return NULL; - SetResourceSize(_self->ob_itself, - newSize); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *ResObj_GetNextFOND(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetNextFOND(_self->ob_itself); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *ResObj_as_Control(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - return CtlObj_New((ControlHandle)_self->ob_itself); - -} - -static PyObject *ResObj_as_Menu(_self, _args) - ResourceObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - return MenuObj_New((MenuHandle)_self->ob_itself); - -} - -static PyMethodDef ResObj_methods[] = { - {"HomeResFile", (PyCFunction)ResObj_HomeResFile, 1, - "() -> (short _rv)"}, - {"LoadResource", (PyCFunction)ResObj_LoadResource, 1, - "() -> None"}, - {"ReleaseResource", (PyCFunction)ResObj_ReleaseResource, 1, - "() -> None"}, - {"DetachResource", (PyCFunction)ResObj_DetachResource, 1, - "() -> None"}, - {"GetResAttrs", (PyCFunction)ResObj_GetResAttrs, 1, - "() -> (short _rv)"}, - {"GetResInfo", (PyCFunction)ResObj_GetResInfo, 1, - "() -> (short theID, ResType theType, Str255 name)"}, - {"SetResInfo", (PyCFunction)ResObj_SetResInfo, 1, - "(short theID, Str255 name) -> None"}, - {"AddResource", (PyCFunction)ResObj_AddResource, 1, - "(ResType theType, short theID, Str255 name) -> None"}, - {"GetResourceSizeOnDisk", (PyCFunction)ResObj_GetResourceSizeOnDisk, 1, - "() -> (long _rv)"}, - {"GetMaxResourceSize", (PyCFunction)ResObj_GetMaxResourceSize, 1, - "() -> (long _rv)"}, - {"RsrcMapEntry", (PyCFunction)ResObj_RsrcMapEntry, 1, - "() -> (long _rv)"}, - {"SetResAttrs", (PyCFunction)ResObj_SetResAttrs, 1, - "(short attrs) -> None"}, - {"ChangedResource", (PyCFunction)ResObj_ChangedResource, 1, - "() -> None"}, - {"RemoveResource", (PyCFunction)ResObj_RemoveResource, 1, - "() -> None"}, - {"WriteResource", (PyCFunction)ResObj_WriteResource, 1, - "() -> None"}, - {"SetResourceSize", (PyCFunction)ResObj_SetResourceSize, 1, - "(long newSize) -> None"}, - {"GetNextFOND", (PyCFunction)ResObj_GetNextFOND, 1, - "() -> (Handle _rv)"}, - {"as_Control", (PyCFunction)ResObj_as_Control, 1, - "Return this resource/handle as a Control"}, - {"as_Menu", (PyCFunction)ResObj_as_Menu, 1, - "Return this resource/handle as a Menu"}, - {NULL, NULL, 0} -}; - -PyMethodChain ResObj_chain = { ResObj_methods, NULL }; - -static PyObject *ResObj_getattr(self, name) - ResourceObject *self; - char *name; -{ - - if (strcmp(name, "size") == 0) - return PyInt_FromLong(GetHandleSize(self->ob_itself)); - if (strcmp(name, "data") == 0) { - PyObject *res; - char state; - state = HGetState(self->ob_itself); - HLock(self->ob_itself); - res = PyString_FromStringAndSize( - *self->ob_itself, - GetHandleSize(self->ob_itself)); - HUnlock(self->ob_itself); - HSetState(self->ob_itself, state); - return res; - } - if (strcmp(name, "__members__") == 0) - return Py_BuildValue("[ss]", "data", "size"); - - return Py_FindMethodInChain(&ResObj_chain, (PyObject *)self, name); -} - -static int -ResObj_setattr(self, name, value) - ResourceObject *self; - char *name; - PyObject *value; -{ - char *data; - long size; - - if (strcmp(name, "data") != 0 || value == NULL ) - return -1; - if ( !PyString_Check(value) ) - return -1; - size = PyString_Size(value); - data = PyString_AsString(value); - /* XXXX Do I need the GetState/SetState calls? */ - SetHandleSize(self->ob_itself, size); - if ( MemError()) - return -1; - HLock(self->ob_itself); - memcpy((char *)*self->ob_itself, data, size); - HUnlock(self->ob_itself); - /* XXXX Should I do the Changed call immedeately? */ - return 0; -} - - -PyTypeObject Resource_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Resource", /*tp_name*/ - sizeof(ResourceObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) ResObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) ResObj_getattr, /*tp_getattr*/ - (setattrfunc) ResObj_setattr, /*tp_setattr*/ -}; - -/* -------------------- End object type Resource -------------------- */ - - -static PyObject *Res_InitResources(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = InitResources(); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_RsrcZoneInit(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - RsrcZoneInit(); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_CloseResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short refNum; - if (!PyArg_ParseTuple(_args, "h", - &refNum)) - return NULL; - CloseResFile(refNum); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_ResError(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = ResError(); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_CurResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CurResFile(); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_CreateResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 fileName; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, fileName)) - return NULL; - CreateResFile(fileName); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_OpenResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - Str255 fileName; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, fileName)) - return NULL; - _rv = OpenResFile(fileName); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_UseResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short refNum; - if (!PyArg_ParseTuple(_args, "h", - &refNum)) - return NULL; - UseResFile(refNum); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_CountTypes(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CountTypes(); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_Count1Types(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = Count1Types(); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_GetIndType(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ResType theType; - short index; - if (!PyArg_ParseTuple(_args, "h", - &index)) - return NULL; - GetIndType(&theType, - index); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - PyMac_BuildOSType, theType); - return _res; -} - -static PyObject *Res_Get1IndType(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ResType theType; - short index; - if (!PyArg_ParseTuple(_args, "h", - &index)) - return NULL; - Get1IndType(&theType, - index); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - PyMac_BuildOSType, theType); - return _res; -} - -static PyObject *Res_SetResLoad(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean load; - if (!PyArg_ParseTuple(_args, "b", - &load)) - return NULL; - SetResLoad(load); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_CountResources(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - ResType theType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theType)) - return NULL; - _rv = CountResources(theType); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_Count1Resources(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - ResType theType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theType)) - return NULL; - _rv = Count1Resources(theType); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_GetIndResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - ResType theType; - short index; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetOSType, &theType, - &index)) - return NULL; - _rv = GetIndResource(theType, - index); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Res_Get1IndResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - ResType theType; - short index; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetOSType, &theType, - &index)) - return NULL; - _rv = Get1IndResource(theType, - index); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Res_GetResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - ResType theType; - short theID; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetOSType, &theType, - &theID)) - return NULL; - _rv = GetResource(theType, - theID); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Res_Get1Resource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - ResType theType; - short theID; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetOSType, &theType, - &theID)) - return NULL; - _rv = Get1Resource(theType, - theID); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Res_GetNamedResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - ResType theType; - Str255 name; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theType, - PyMac_GetStr255, name)) - return NULL; - _rv = GetNamedResource(theType, - name); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Res_Get1NamedResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - ResType theType; - Str255 name; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &theType, - PyMac_GetStr255, name)) - return NULL; - _rv = Get1NamedResource(theType, - name); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Res_UniqueID(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - ResType theType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theType)) - return NULL; - _rv = UniqueID(theType); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_Unique1ID(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - ResType theType; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetOSType, &theType)) - return NULL; - _rv = Unique1ID(theType); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_UpdateResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short refNum; - if (!PyArg_ParseTuple(_args, "h", - &refNum)) - return NULL; - UpdateResFile(refNum); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_SetResPurge(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean install; - if (!PyArg_ParseTuple(_args, "b", - &install)) - return NULL; - SetResPurge(install); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_GetResFileAttrs(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short refNum; - if (!PyArg_ParseTuple(_args, "h", - &refNum)) - return NULL; - _rv = GetResFileAttrs(refNum); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_SetResFileAttrs(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short refNum; - short attrs; - if (!PyArg_ParseTuple(_args, "hh", - &refNum, - &attrs)) - return NULL; - SetResFileAttrs(refNum, - attrs); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_OpenRFPerm(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - Str255 fileName; - short vRefNum; - SignedByte permission; - if (!PyArg_ParseTuple(_args, "O&hb", - PyMac_GetStr255, fileName, - &vRefNum, - &permission)) - return NULL; - _rv = OpenRFPerm(fileName, - vRefNum, - permission); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_RGetResource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - ResType theType; - short theID; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetOSType, &theType, - &theID)) - return NULL; - _rv = RGetResource(theType, - theID); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Res_HOpenResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short vRefNum; - long dirID; - Str255 fileName; - SignedByte permission; - if (!PyArg_ParseTuple(_args, "hlO&b", - &vRefNum, - &dirID, - PyMac_GetStr255, fileName, - &permission)) - return NULL; - _rv = HOpenResFile(vRefNum, - dirID, - fileName, - permission); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_HCreateResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short vRefNum; - long dirID; - Str255 fileName; - if (!PyArg_ParseTuple(_args, "hlO&", - &vRefNum, - &dirID, - PyMac_GetStr255, fileName)) - return NULL; - HCreateResFile(vRefNum, - dirID, - fileName); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_FSpOpenResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - FSSpec spec; - SignedByte permission; - if (!PyArg_ParseTuple(_args, "O&b", - PyMac_GetFSSpec, &spec, - &permission)) - return NULL; - _rv = FSpOpenResFile(&spec, - permission); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *Res_FSpCreateResFile(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - FSSpec spec; - OSType creator; - OSType fileType; - ScriptCode scriptTag; - if (!PyArg_ParseTuple(_args, "O&O&O&h", - PyMac_GetFSSpec, &spec, - PyMac_GetOSType, &creator, - PyMac_GetOSType, &fileType, - &scriptTag)) - return NULL; - FSpCreateResFile(&spec, - creator, - fileType, - scriptTag); - { - OSErr _err = ResError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Res_Resource(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - char *buf; - int len; - Handle h; - - if (!PyArg_ParseTuple(_args, "s#", &buf, &len)) - return NULL; - h = NewHandle(len); - if ( h == NULL ) { - PyErr_NoMemory(); - return NULL; - } - HLock(h); - memcpy(*h, buf, len); - HUnlock(h); - return (PyObject *)ResObj_New(h); - -} - -static PyMethodDef Res_methods[] = { - {"InitResources", (PyCFunction)Res_InitResources, 1, - "() -> (short _rv)"}, - {"RsrcZoneInit", (PyCFunction)Res_RsrcZoneInit, 1, - "() -> None"}, - {"CloseResFile", (PyCFunction)Res_CloseResFile, 1, - "(short refNum) -> None"}, - {"ResError", (PyCFunction)Res_ResError, 1, - "() -> (short _rv)"}, - {"CurResFile", (PyCFunction)Res_CurResFile, 1, - "() -> (short _rv)"}, - {"CreateResFile", (PyCFunction)Res_CreateResFile, 1, - "(Str255 fileName) -> None"}, - {"OpenResFile", (PyCFunction)Res_OpenResFile, 1, - "(Str255 fileName) -> (short _rv)"}, - {"UseResFile", (PyCFunction)Res_UseResFile, 1, - "(short refNum) -> None"}, - {"CountTypes", (PyCFunction)Res_CountTypes, 1, - "() -> (short _rv)"}, - {"Count1Types", (PyCFunction)Res_Count1Types, 1, - "() -> (short _rv)"}, - {"GetIndType", (PyCFunction)Res_GetIndType, 1, - "(short index) -> (ResType theType)"}, - {"Get1IndType", (PyCFunction)Res_Get1IndType, 1, - "(short index) -> (ResType theType)"}, - {"SetResLoad", (PyCFunction)Res_SetResLoad, 1, - "(Boolean load) -> None"}, - {"CountResources", (PyCFunction)Res_CountResources, 1, - "(ResType theType) -> (short _rv)"}, - {"Count1Resources", (PyCFunction)Res_Count1Resources, 1, - "(ResType theType) -> (short _rv)"}, - {"GetIndResource", (PyCFunction)Res_GetIndResource, 1, - "(ResType theType, short index) -> (Handle _rv)"}, - {"Get1IndResource", (PyCFunction)Res_Get1IndResource, 1, - "(ResType theType, short index) -> (Handle _rv)"}, - {"GetResource", (PyCFunction)Res_GetResource, 1, - "(ResType theType, short theID) -> (Handle _rv)"}, - {"Get1Resource", (PyCFunction)Res_Get1Resource, 1, - "(ResType theType, short theID) -> (Handle _rv)"}, - {"GetNamedResource", (PyCFunction)Res_GetNamedResource, 1, - "(ResType theType, Str255 name) -> (Handle _rv)"}, - {"Get1NamedResource", (PyCFunction)Res_Get1NamedResource, 1, - "(ResType theType, Str255 name) -> (Handle _rv)"}, - {"UniqueID", (PyCFunction)Res_UniqueID, 1, - "(ResType theType) -> (short _rv)"}, - {"Unique1ID", (PyCFunction)Res_Unique1ID, 1, - "(ResType theType) -> (short _rv)"}, - {"UpdateResFile", (PyCFunction)Res_UpdateResFile, 1, - "(short refNum) -> None"}, - {"SetResPurge", (PyCFunction)Res_SetResPurge, 1, - "(Boolean install) -> None"}, - {"GetResFileAttrs", (PyCFunction)Res_GetResFileAttrs, 1, - "(short refNum) -> (short _rv)"}, - {"SetResFileAttrs", (PyCFunction)Res_SetResFileAttrs, 1, - "(short refNum, short attrs) -> None"}, - {"OpenRFPerm", (PyCFunction)Res_OpenRFPerm, 1, - "(Str255 fileName, short vRefNum, SignedByte permission) -> (short _rv)"}, - {"RGetResource", (PyCFunction)Res_RGetResource, 1, - "(ResType theType, short theID) -> (Handle _rv)"}, - {"HOpenResFile", (PyCFunction)Res_HOpenResFile, 1, - "(short vRefNum, long dirID, Str255 fileName, SignedByte permission) -> (short _rv)"}, - {"HCreateResFile", (PyCFunction)Res_HCreateResFile, 1, - "(short vRefNum, long dirID, Str255 fileName) -> None"}, - {"FSpOpenResFile", (PyCFunction)Res_FSpOpenResFile, 1, - "(FSSpec spec, SignedByte permission) -> (short _rv)"}, - {"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1, - "(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None"}, - {"Resource", (PyCFunction)Res_Resource, 1, - "Convert a string to a resource object.\n\nThe created resource object is actually just a handle.\nApply AddResource() to write it to a resource file.\n"}, - {NULL, NULL, 0} -}; - - - - -/* Alternative version of ResObj_New, which returns None for null argument */ -PyObject *OptResObj_New(itself) - Handle itself; -{ - if (itself == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return ResObj_New(itself); -} - -OptResObj_Convert(v, p_itself) - PyObject *v; - Handle *p_itself; -{ - if ( v == Py_None ) { - *p_itself = NULL; - return 1; - } - if (!ResObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Resource required"); - return 0; - } - *p_itself = ((ResourceObject *)v)->ob_itself; - return 1; -} - - - -void initRes() -{ - PyObject *m; - PyObject *d; - - - - - - m = Py_InitModule("Res", Res_methods); - d = PyModule_GetDict(m); - Res_Error = PyMac_GetOSErrException(); - if (Res_Error == NULL || - PyDict_SetItemString(d, "Error", Res_Error) != 0) - Py_FatalError("can't initialize Res.Error"); -} - -/* ========================= End module Res ========================= */ - diff --git a/Mac/Modules/res/resedit.py b/Mac/Modules/res/resedit.py deleted file mode 100644 index bffec5fee9..0000000000 --- a/Mac/Modules/res/resedit.py +++ /dev/null @@ -1,41 +0,0 @@ -resource_body = """ -char *buf; -int len; -Handle h; - -if (!PyArg_ParseTuple(_args, "s#", &buf, &len)) - return NULL; -h = NewHandle(len); -if ( h == NULL ) { - PyErr_NoMemory(); - return NULL; -} -HLock(h); -memcpy(*h, buf, len); -HUnlock(h); -return (PyObject *)ResObj_New(h); -""" - -f = ManualGenerator("Resource", resource_body) -f.docstring = lambda: """Convert a string to a resource object. - -The created resource object is actually just a handle. -Apply AddResource() to write it to a resource file. -""" -functions.append(f) - -# Convert resources to other things. - -as_xxx_body = """ -return %sObj_New((%sHandle)_self->ob_itself); -""" - -def genresconverter(longname, shortname): - - f = ManualGenerator("as_%s"%longname, as_xxx_body%(shortname, longname)) - docstring = "Return this resource/handle as a %s"%longname - f.docstring = lambda docstring=docstring: docstring - return f - -resmethods.append(genresconverter("Control", "Ctl")) -resmethods.append(genresconverter("Menu", "Menu")) diff --git a/Mac/Modules/res/resscan.py b/Mac/Modules/res/resscan.py deleted file mode 100644 index eff0005a8c..0000000000 --- a/Mac/Modules/res/resscan.py +++ /dev/null @@ -1,70 +0,0 @@ -# Scan Resources.h header file, generate resgen.py and Resources.py files. -# Then run ressupport to generate Resmodule.c. -# (Should learn how to tell the compiler to compile it as well.) - -import sys -import os -import string -import regex -import regsub -import MacOS -import addpack -addpack.addpack(':Tools:bgen:bgen') -from bgenlocations import TOOLBOXDIR - -from scantools import Scanner - -def main(): - input = "Resources.h" - output = "resgen.py" - defsoutput = TOOLBOXDIR + "Resources.py" - scanner = ResourcesScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now doing 'import ressupport' ===" - import ressupport - print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ===" - -class ResourcesScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "ResFunction" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t == "Handle" and m == "InMode": - classname = "ResMethod" - listname = "resmethods" - return classname, listname - - def makeblacklistnames(self): - return [ - "ReadPartialResource", - "WritePartialResource", - "TempInsertROMMap", -## "RmveResource", # RemoveResource -## "SizeResource", # GetResourceSizeOnDisk -## "MaxSizeRsrc", # GetMaxResourceSize - ] - - def makerepairinstructions(self): - return [ - ([("Str255", "*", "InMode")], - [("*", "*", "OutMode")]), - - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode")], - [("InOutBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode"), - ("long", "*", "OutMode")], - [("OutBuffer", "*", "InOutMode")]), - - ([("SInt8", "*", "*")], - [("SignedByte", "*", "*")]) - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py deleted file mode 100644 index 8c899f0410..0000000000 --- a/Mac/Modules/res/ressupport.py +++ /dev/null @@ -1,141 +0,0 @@ -# This script will generate the Resources interface for Python. -# It uses the "bgen" package to generate C code. -# It execs the file resgen.py which contain the function definitions -# (resgen.py was generated by resscan.py, scanning the header file). - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from macsupport import * - - -class ResMixIn: - - def checkit(self): - OutLbrace() - Output("OSErr _err = ResError();") - Output("if (_err != noErr) return PyMac_Error(_err);") - OutRbrace() - FunctionGenerator.checkit(self) # XXX - -class ResFunction(ResMixIn, FunctionGenerator): pass -class ResMethod(ResMixIn, MethodGenerator): pass - -# includestuff etc. are imported from macsupport - -includestuff = includestuff + """ -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ -""" - -finalstuff = finalstuff + """ - -/* Alternative version of ResObj_New, which returns None for null argument */ -PyObject *OptResObj_New(itself) - Handle itself; -{ - if (itself == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return ResObj_New(itself); -} - -OptResObj_Convert(v, p_itself) - PyObject *v; - Handle *p_itself; -{ - if ( v == Py_None ) { - *p_itself = NULL; - return 1; - } - if (!ResObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Resource required"); - return 0; - } - *p_itself = ((ResourceObject *)v)->ob_itself; - return 1; -} - -""" - -initstuff = initstuff + """ -""" - -module = MacModule('Res', 'Res', includestuff, finalstuff, initstuff) - -getattrHookCode = """ -if (strcmp(name, "size") == 0) - return PyInt_FromLong(GetHandleSize(self->ob_itself)); -if (strcmp(name, "data") == 0) { - PyObject *res; - char state; - state = HGetState(self->ob_itself); - HLock(self->ob_itself); - res = PyString_FromStringAndSize( - *self->ob_itself, - GetHandleSize(self->ob_itself)); - HUnlock(self->ob_itself); - HSetState(self->ob_itself, state); - return res; -} -if (strcmp(name, "__members__") == 0) - return Py_BuildValue("[ss]", "data", "size"); -""" - -setattrCode = """ -static int -ResObj_setattr(self, name, value) - ResourceObject *self; - char *name; - PyObject *value; -{ - char *data; - long size; - - if (strcmp(name, "data") != 0 || value == NULL ) - return -1; - if ( !PyString_Check(value) ) - return -1; - size = PyString_Size(value); - data = PyString_AsString(value); - /* XXXX Do I need the GetState/SetState calls? */ - SetHandleSize(self->ob_itself, size); - if ( MemError()) - return -1; - HLock(self->ob_itself); - memcpy((char *)*self->ob_itself, data, size); - HUnlock(self->ob_itself); - /* XXXX Should I do the Changed call immedeately? */ - return 0; -} -""" - -class ResDefiniton(GlobalObjectDefinition): - - def outputCheckNewArg(self): - Output("if (itself == NULL) return PyMac_Error(resNotFound);") - - def outputGetattrHook(self): - Output(getattrHookCode) - - def outputSetattr(self): - Output(setattrCode) - - -resobject = ResDefiniton('Resource', 'ResObj', 'Handle') -module.addobject(resobject) - -functions = [] -resmethods = [] - -execfile('resgen.py') -execfile('resedit.py') - -for f in functions: module.add(f) -for f in resmethods: resobject.add(f) - -SetOutputFileName('Resmodule.c') -module.generate() diff --git a/Mac/Modules/scrap/Scrapmodule.c b/Mac/Modules/scrap/Scrapmodule.c deleted file mode 100644 index b44e7cd89f..0000000000 --- a/Mac/Modules/scrap/Scrapmodule.c +++ /dev/null @@ -1,202 +0,0 @@ - -/* ========================== Module Scrap ========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *PMObj_New(PixMapHandle); -extern int PMObj_Convert(PyObject *, PixMapHandle *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -/* -** Generate ScrapInfo records -*/ -PyObject *SCRRec_New(itself) - ScrapStuff *itself; -{ - - return Py_BuildValue("lO&hhO&", itself->scrapSize, - ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState, - PyMac_BuildStr255, itself->scrapName); -} - -static PyObject *Scrap_Error; - -static PyObject *Scrap_InfoScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - ScrapStuffPtr _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = InfoScrap(); - _res = Py_BuildValue("O&", - SCRRec_New, _rv); - return _res; -} - -static PyObject *Scrap_UnloadScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = UnloadScrap(); - if ( _rv ) return PyMac_Error((OSErr)_rv); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *Scrap_LoadScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = LoadScrap(); - if ( _rv ) return PyMac_Error((OSErr)_rv); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *Scrap_GetScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - Handle hDest; - ResType theType; - long offset; - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &hDest, - PyMac_GetOSType, &theType)) - return NULL; - _rv = GetScrap(hDest, - theType, - &offset); - _res = Py_BuildValue("ll", - _rv, - offset); - return _res; -} - -static PyObject *Scrap_ZeroScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = ZeroScrap(); - if ( _rv ) return PyMac_Error((OSErr)_rv); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *Scrap_PutScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - long length; - ResType theType; - char *source__in__; - int source__len__; - int source__in_len__; - if (!PyArg_ParseTuple(_args, "O&s#", - PyMac_GetOSType, &theType, - &source__in__, &source__in_len__)) - return NULL; - length = source__in_len__; - _rv = PutScrap(length, - theType, - source__in__); - if ( _rv ) return PyMac_Error((OSErr)_rv); - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef Scrap_methods[] = { - {"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1, - "() -> (ScrapStuff _rv)"}, - {"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1, - "() -> (OSErr)"}, - {"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1, - "() -> (OSErr)"}, - {"GetScrap", (PyCFunction)Scrap_GetScrap, 1, - "(Handle hDest, ResType theType) -> (long _rv, long offset)"}, - {"ZeroScrap", (PyCFunction)Scrap_ZeroScrap, 1, - "() -> (OSErr)"}, - {"PutScrap", (PyCFunction)Scrap_PutScrap, 1, - "(ResType theType, Buffer source) -> (OSErr)"}, - {NULL, NULL, 0} -}; - - - - -void initScrap() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Scrap", Scrap_methods); - d = PyModule_GetDict(m); - Scrap_Error = PyMac_GetOSErrException(); - if (Scrap_Error == NULL || - PyDict_SetItemString(d, "Error", Scrap_Error) != 0) - Py_FatalError("can't initialize Scrap.Error"); -} - -/* ======================== End module Scrap ======================== */ - diff --git a/Mac/Modules/scrap/scrapscan.py b/Mac/Modules/scrap/scrapscan.py deleted file mode 100644 index 0bad7c264b..0000000000 --- a/Mac/Modules/scrap/scrapscan.py +++ /dev/null @@ -1,46 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. -# -# Note that the scrap-manager include file is so weird that this -# generates a boilerplate to be edited by hand. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "Scrap" -SHORT = "Scrap" - -def main(): - input = "Scrap.h" - output = SHORT + "gen.py" - defsoutput = "@Scrap.py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - return classname, listname - - def makeblacklistnames(self): - return [ - ] - - def makeblacklisttypes(self): - return [ - ] - - def makerepairinstructions(self): - return [ - ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]), - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/scrap/scrapsupport.py b/Mac/Modules/scrap/scrapsupport.py deleted file mode 100644 index 701e197409..0000000000 --- a/Mac/Modules/scrap/scrapsupport.py +++ /dev/null @@ -1,60 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -# NOTE: the scrap include file is so bad that the bgen output has to be -# massaged by hand. - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'Scrap.h' # The Apple header file -MODNAME = 'Scrap' # The name of the module - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = '@' + MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ - -/* -** Generate ScrapInfo records -*/ -PyObject *SCRRec_New(itself) - ScrapStuff *itself; -{ - - return Py_BuildValue("lO&hhO&", itself->scrapSize, - ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState, - PyMac_BuildStr255, itself->scrapName; -} -""" - -ScrapStuffPtr = OpaqueType('ScrapStuff', 'SCRRec') -putscrapbuffer = FixedInputBufferType('void *') - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator - -# Create and populate the lists -functions = [] -execfile(INPUTFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/snd/Sndmodule.c b/Mac/Modules/snd/Sndmodule.c deleted file mode 100644 index 74951ce072..0000000000 --- a/Mac/Modules/snd/Sndmodule.c +++ /dev/null @@ -1,803 +0,0 @@ - -/* =========================== Module Snd =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -#ifndef HAVE_UNIVERSAL_HEADERS -#define SndCallBackUPP ProcPtr -#define NewSndCallBackProc(x) ((SndCallBackProcPtr)(x)) -#define SndListHandle Handle -#endif - -#include /* for Set(Current)A5 */ - -/* Create a SndCommand object (an (int, int, int) tuple) */ -static PyObject * -SndCmd_New(SndCommand *pc) -{ - return Py_BuildValue("hhl", pc->cmd, pc->param1, pc->param2); -} - -/* Convert a SndCommand argument */ -static int -SndCmd_Convert(PyObject *v, SndCommand *pc) -{ - int len; - pc->param1 = 0; - pc->param2 = 0; - if (PyTuple_Check(v)) { - if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2)) - return 1; - PyErr_Clear(); - return PyArg_ParseTuple(v, "hhs#", &pc->cmd, &pc->param1, &pc->param2, &len); - } - return PyArg_Parse(v, "h", &pc->cmd); -} - -static pascal void SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd); /* Forward */ - -static PyObject *Snd_Error; - -/* --------------------- Object type SndChannel --------------------- */ - -staticforward PyTypeObject SndChannel_Type; - -#define SndCh_Check(x) ((x)->ob_type == &SndChannel_Type) - -typedef struct SndChannelObject { - PyObject_HEAD - SndChannelPtr ob_itself; - /* Members used to implement callbacks: */ - PyObject *ob_callback; - long ob_A5; - SndCommand ob_cmd; -} SndChannelObject; - -static PyObject *SndCh_New(itself) - SndChannelPtr itself; -{ - SndChannelObject *it; - it = PyObject_NEW(SndChannelObject, &SndChannel_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - it->ob_callback = NULL; - it->ob_A5 = SetCurrentA5(); - return (PyObject *)it; -} -static SndCh_Convert(v, p_itself) - PyObject *v; - SndChannelPtr *p_itself; -{ - if (!SndCh_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "SndChannel required"); - return 0; - } - *p_itself = ((SndChannelObject *)v)->ob_itself; - return 1; -} - -static void SndCh_dealloc(self) - SndChannelObject *self; -{ - SndDisposeChannel(self->ob_itself, 1); - Py_XDECREF(self->ob_callback); - PyMem_DEL(self); -} - -static PyObject *SndCh_SndDoCommand(_self, _args) - SndChannelObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - SndCommand cmd; - Boolean noWait; - if (!PyArg_ParseTuple(_args, "O&b", - SndCmd_Convert, &cmd, - &noWait)) - return NULL; - _err = SndDoCommand(_self->ob_itself, - &cmd, - noWait); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *SndCh_SndDoImmediate(_self, _args) - SndChannelObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - SndCommand cmd; - if (!PyArg_ParseTuple(_args, "O&", - SndCmd_Convert, &cmd)) - return NULL; - _err = SndDoImmediate(_self->ob_itself, - &cmd); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *SndCh_SndPlay(_self, _args) - SndChannelObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - SndListHandle sndHdl; - Boolean async; - if (!PyArg_ParseTuple(_args, "O&b", - ResObj_Convert, &sndHdl, - &async)) - return NULL; - _err = SndPlay(_self->ob_itself, - sndHdl, - async); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *SndCh_SndStartFilePlay(_self, _args) - SndChannelObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short fRefNum; - short resNum; - long bufferSize; - Boolean async; - if (!PyArg_ParseTuple(_args, "hhlb", - &fRefNum, - &resNum, - &bufferSize, - &async)) - return NULL; - _err = SndStartFilePlay(_self->ob_itself, - fRefNum, - resNum, - bufferSize, - 0, - 0, - 0, - async); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *SndCh_SndPauseFilePlay(_self, _args) - SndChannelObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = SndPauseFilePlay(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *SndCh_SndStopFilePlay(_self, _args) - SndChannelObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Boolean quietNow; - if (!PyArg_ParseTuple(_args, "b", - &quietNow)) - return NULL; - _err = SndStopFilePlay(_self->ob_itself, - quietNow); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *SndCh_SndChannelStatus(_self, _args) - SndChannelObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short theLength; - SCStatus theStatus__out__; - if (!PyArg_ParseTuple(_args, "h", - &theLength)) - return NULL; - _err = SndChannelStatus(_self->ob_itself, - theLength, - &theStatus__out__); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("s#", - (char *)&theStatus__out__, (int)sizeof(SCStatus)); - theStatus__error__: ; - return _res; -} - -static PyMethodDef SndCh_methods[] = { - {"SndDoCommand", (PyCFunction)SndCh_SndDoCommand, 1, - "(SndCommand cmd, Boolean noWait) -> None"}, - {"SndDoImmediate", (PyCFunction)SndCh_SndDoImmediate, 1, - "(SndCommand cmd) -> None"}, - {"SndPlay", (PyCFunction)SndCh_SndPlay, 1, - "(SndListHandle sndHdl, Boolean async) -> None"}, - {"SndStartFilePlay", (PyCFunction)SndCh_SndStartFilePlay, 1, - "(short fRefNum, short resNum, long bufferSize, Boolean async) -> None"}, - {"SndPauseFilePlay", (PyCFunction)SndCh_SndPauseFilePlay, 1, - "() -> None"}, - {"SndStopFilePlay", (PyCFunction)SndCh_SndStopFilePlay, 1, - "(Boolean quietNow) -> None"}, - {"SndChannelStatus", (PyCFunction)SndCh_SndChannelStatus, 1, - "(short theLength) -> (SCStatus theStatus)"}, - {NULL, NULL, 0} -}; - -static PyMethodChain SndCh_chain = { SndCh_methods, NULL }; - -static PyObject *SndCh_getattr(self, name) - SndChannelObject *self; - char *name; -{ - return Py_FindMethodInChain(&SndCh_chain, (PyObject *)self, name); -} - -#define SndCh_setattr NULL - -staticforward PyTypeObject SndChannel_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "SndChannel", /*tp_name*/ - sizeof(SndChannelObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) SndCh_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) SndCh_getattr, /*tp_getattr*/ - (setattrfunc) SndCh_setattr, /*tp_setattr*/ -}; - -/* ------------------- End object type SndChannel ------------------- */ - - -static PyObject *Snd_SndNewChannel(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - SndChannelPtr chan = 0; - short synth; - long init; - PyObject* userRoutine; - if (!PyArg_ParseTuple(_args, "hlO", - &synth, - &init, - &userRoutine)) - return NULL; - if (userRoutine != Py_None && !PyCallable_Check(userRoutine)) - { - PyErr_SetString(PyExc_TypeError, "callback must be callable"); - goto userRoutine__error__; - } - _err = SndNewChannel(&chan, - synth, - init, - NewSndCallBackProc(SndCh_UserRoutine)); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - SndCh_New, chan); - if (_res != NULL && userRoutine != Py_None) - { - SndChannelObject *p = (SndChannelObject *)_res; - p->ob_itself->userInfo = (long)p; - Py_INCREF(userRoutine); - p->ob_callback = userRoutine; - } - userRoutine__error__: ; - return _res; -} - -static PyObject *Snd_SndControl(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short id; - SndCommand cmd; - if (!PyArg_ParseTuple(_args, "h", - &id)) - return NULL; - _err = SndControl(id, - &cmd); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - SndCmd_New, &cmd); - return _res; -} - -static PyObject *Snd_SndSoundManagerVersion(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - NumVersion _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = SndSoundManagerVersion(); - _res = Py_BuildValue("O&", - PyMac_BuildNumVersion, _rv); - return _res; -} - -static PyObject *Snd_SndManagerStatus(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short theLength; - SMStatus theStatus__out__; - if (!PyArg_ParseTuple(_args, "h", - &theLength)) - return NULL; - _err = SndManagerStatus(theLength, - &theStatus__out__); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("s#", - (char *)&theStatus__out__, (int)sizeof(SMStatus)); - theStatus__error__: ; - return _res; -} - -static PyObject *Snd_SndGetSysBeepState(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short sysBeepState; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - SndGetSysBeepState(&sysBeepState); - _res = Py_BuildValue("h", - sysBeepState); - return _res; -} - -static PyObject *Snd_SndSetSysBeepState(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - short sysBeepState; - if (!PyArg_ParseTuple(_args, "h", - &sysBeepState)) - return NULL; - _err = SndSetSysBeepState(sysBeepState); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Snd_MACEVersion(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - NumVersion _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = MACEVersion(); - _res = Py_BuildValue("O&", - PyMac_BuildNumVersion, _rv); - return _res; -} - -static PyObject *Snd_Comp3to1(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *buffer__in__; - char *buffer__out__; - long buffer__len__; - int buffer__in_len__; - StateBlock *state__in__; - StateBlock state__out__; - int state__in_len__; - unsigned long numChannels; - unsigned long whichChannel; - if (!PyArg_ParseTuple(_args, "s#s#ll", - &buffer__in__, &buffer__in_len__, - (char **)&state__in__, &state__in_len__, - &numChannels, - &whichChannel)) - return NULL; - if ((buffer__out__ = malloc(buffer__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto buffer__error__; - } - buffer__len__ = buffer__in_len__; - if (state__in_len__ != sizeof(StateBlock)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(StateBlock)"); - goto state__error__; - } - Comp3to1(buffer__in__, buffer__out__, (long)buffer__len__, - state__in__, &state__out__, - numChannels, - whichChannel); - _res = Py_BuildValue("s#s#", - buffer__out__, (int)buffer__len__, - (char *)&state__out__, (int)sizeof(StateBlock)); - state__error__: ; - free(buffer__out__); - buffer__error__: ; - return _res; -} - -static PyObject *Snd_Exp1to3(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *buffer__in__; - char *buffer__out__; - long buffer__len__; - int buffer__in_len__; - StateBlock *state__in__; - StateBlock state__out__; - int state__in_len__; - unsigned long numChannels; - unsigned long whichChannel; - if (!PyArg_ParseTuple(_args, "s#s#ll", - &buffer__in__, &buffer__in_len__, - (char **)&state__in__, &state__in_len__, - &numChannels, - &whichChannel)) - return NULL; - if ((buffer__out__ = malloc(buffer__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto buffer__error__; - } - buffer__len__ = buffer__in_len__; - if (state__in_len__ != sizeof(StateBlock)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(StateBlock)"); - goto state__error__; - } - Exp1to3(buffer__in__, buffer__out__, (long)buffer__len__, - state__in__, &state__out__, - numChannels, - whichChannel); - _res = Py_BuildValue("s#s#", - buffer__out__, (int)buffer__len__, - (char *)&state__out__, (int)sizeof(StateBlock)); - state__error__: ; - free(buffer__out__); - buffer__error__: ; - return _res; -} - -static PyObject *Snd_Comp6to1(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *buffer__in__; - char *buffer__out__; - long buffer__len__; - int buffer__in_len__; - StateBlock *state__in__; - StateBlock state__out__; - int state__in_len__; - unsigned long numChannels; - unsigned long whichChannel; - if (!PyArg_ParseTuple(_args, "s#s#ll", - &buffer__in__, &buffer__in_len__, - (char **)&state__in__, &state__in_len__, - &numChannels, - &whichChannel)) - return NULL; - if ((buffer__out__ = malloc(buffer__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto buffer__error__; - } - buffer__len__ = buffer__in_len__; - if (state__in_len__ != sizeof(StateBlock)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(StateBlock)"); - goto state__error__; - } - Comp6to1(buffer__in__, buffer__out__, (long)buffer__len__, - state__in__, &state__out__, - numChannels, - whichChannel); - _res = Py_BuildValue("s#s#", - buffer__out__, (int)buffer__len__, - (char *)&state__out__, (int)sizeof(StateBlock)); - state__error__: ; - free(buffer__out__); - buffer__error__: ; - return _res; -} - -static PyObject *Snd_Exp1to6(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *buffer__in__; - char *buffer__out__; - long buffer__len__; - int buffer__in_len__; - StateBlock *state__in__; - StateBlock state__out__; - int state__in_len__; - unsigned long numChannels; - unsigned long whichChannel; - if (!PyArg_ParseTuple(_args, "s#s#ll", - &buffer__in__, &buffer__in_len__, - (char **)&state__in__, &state__in_len__, - &numChannels, - &whichChannel)) - return NULL; - if ((buffer__out__ = malloc(buffer__in_len__)) == NULL) - { - PyErr_NoMemory(); - goto buffer__error__; - } - buffer__len__ = buffer__in_len__; - if (state__in_len__ != sizeof(StateBlock)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(StateBlock)"); - goto state__error__; - } - Exp1to6(buffer__in__, buffer__out__, (long)buffer__len__, - state__in__, &state__out__, - numChannels, - whichChannel); - _res = Py_BuildValue("s#s#", - buffer__out__, (int)buffer__len__, - (char *)&state__out__, (int)sizeof(StateBlock)); - state__error__: ; - free(buffer__out__); - buffer__error__: ; - return _res; -} - -static PyObject *Snd_GetSysBeepVolume(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long level; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetSysBeepVolume(&level); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - level); - return _res; -} - -static PyObject *Snd_SetSysBeepVolume(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long level; - if (!PyArg_ParseTuple(_args, "l", - &level)) - return NULL; - _err = SetSysBeepVolume(level); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Snd_GetDefaultOutputVolume(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long level; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = GetDefaultOutputVolume(&level); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - level); - return _res; -} - -static PyObject *Snd_SetDefaultOutputVolume(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - long level; - if (!PyArg_ParseTuple(_args, "l", - &level)) - return NULL; - _err = SetDefaultOutputVolume(level); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Snd_GetSoundHeaderOffset(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - SndListHandle sndHandle; - long offset; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &sndHandle)) - return NULL; - _err = GetSoundHeaderOffset(sndHandle, - &offset); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - offset); - return _res; -} - -static PyMethodDef Snd_methods[] = { - {"SndNewChannel", (PyCFunction)Snd_SndNewChannel, 1, - "(short synth, long init, PyObject* userRoutine) -> (SndChannelPtr chan)"}, - {"SndControl", (PyCFunction)Snd_SndControl, 1, - "(short id) -> (SndCommand cmd)"}, - {"SndSoundManagerVersion", (PyCFunction)Snd_SndSoundManagerVersion, 1, - "() -> (NumVersion _rv)"}, - {"SndManagerStatus", (PyCFunction)Snd_SndManagerStatus, 1, - "(short theLength) -> (SMStatus theStatus)"}, - {"SndGetSysBeepState", (PyCFunction)Snd_SndGetSysBeepState, 1, - "() -> (short sysBeepState)"}, - {"SndSetSysBeepState", (PyCFunction)Snd_SndSetSysBeepState, 1, - "(short sysBeepState) -> None"}, - {"MACEVersion", (PyCFunction)Snd_MACEVersion, 1, - "() -> (NumVersion _rv)"}, - {"Comp3to1", (PyCFunction)Snd_Comp3to1, 1, - "(Buffer buffer, StateBlock state, unsigned long numChannels, unsigned long whichChannel) -> (Buffer buffer, StateBlock state)"}, - {"Exp1to3", (PyCFunction)Snd_Exp1to3, 1, - "(Buffer buffer, StateBlock state, unsigned long numChannels, unsigned long whichChannel) -> (Buffer buffer, StateBlock state)"}, - {"Comp6to1", (PyCFunction)Snd_Comp6to1, 1, - "(Buffer buffer, StateBlock state, unsigned long numChannels, unsigned long whichChannel) -> (Buffer buffer, StateBlock state)"}, - {"Exp1to6", (PyCFunction)Snd_Exp1to6, 1, - "(Buffer buffer, StateBlock state, unsigned long numChannels, unsigned long whichChannel) -> (Buffer buffer, StateBlock state)"}, - {"GetSysBeepVolume", (PyCFunction)Snd_GetSysBeepVolume, 1, - "() -> (long level)"}, - {"SetSysBeepVolume", (PyCFunction)Snd_SetSysBeepVolume, 1, - "(long level) -> None"}, - {"GetDefaultOutputVolume", (PyCFunction)Snd_GetDefaultOutputVolume, 1, - "() -> (long level)"}, - {"SetDefaultOutputVolume", (PyCFunction)Snd_SetDefaultOutputVolume, 1, - "(long level) -> None"}, - {"GetSoundHeaderOffset", (PyCFunction)Snd_GetSoundHeaderOffset, 1, - "(SndListHandle sndHandle) -> (long offset)"}, - {NULL, NULL, 0} -}; - - - -/* Routine passed to Py_AddPendingCall -- call the Python callback */ -static int -SndCh_CallCallBack(arg) - void *arg; -{ - SndChannelObject *p = (SndChannelObject *)arg; - PyObject *args; - PyObject *res; - args = Py_BuildValue("(O(hhl))", - p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2); - res = PyEval_CallObject(p->ob_callback, args); - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -/* Routine passed to NewSndChannel -- schedule a call to SndCh_CallCallBack */ -static pascal void -SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd) -{ - SndChannelObject *p = (SndChannelObject *)(chan->userInfo); - if (p->ob_callback != NULL) { - long A5 = SetA5(p->ob_A5); - p->ob_cmd = *cmd; - Py_AddPendingCall(SndCh_CallCallBack, (void *)p); - SetA5(A5); - } -} - - -void initSnd() -{ - PyObject *m; - PyObject *d; - - - - - - m = Py_InitModule("Snd", Snd_methods); - d = PyModule_GetDict(m); - Snd_Error = PyMac_GetOSErrException(); - if (Snd_Error == NULL || - PyDict_SetItemString(d, "Error", Snd_Error) != 0) - Py_FatalError("can't initialize Snd.Error"); -} - -/* ========================= End module Snd ========================= */ - diff --git a/Mac/Modules/snd/sndscan.py b/Mac/Modules/snd/sndscan.py deleted file mode 100644 index 249aa57494..0000000000 --- a/Mac/Modules/snd/sndscan.py +++ /dev/null @@ -1,109 +0,0 @@ -# Scan Sound.h header file, generate sndgen.py and Sound.py files. -# Then import sndsupport (which execs sndgen.py) to generate Sndmodule.c. -# (Should learn how to tell the compiler to compile it as well.) - -import addpack -addpack.addpack(':Tools:bgen:bgen') -from bgenlocations import TOOLBOXDIR - -from scantools import Scanner - -def main(): - input = "Sound.h" - output = "sndgen.py" - defsoutput = TOOLBOXDIR + "Sound.py" - scanner = SoundScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now doing 'import sndsupport' ===" - import sndsupport - print "=== Done. It's up to you to compile Sndmodule.c ===" - -class SoundScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "SndFunction" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t == "SndChannelPtr" and m == "InMode": - classname = "SndMethod" - listname = "sndmethods" - return classname, listname - - def makeblacklistnames(self): - return [ - 'SndDisposeChannel', # automatic on deallocation - 'SndAddModifier', # for internal use only - 'SndPlayDoubleBuffer', # very low level routine - # Obsolete: - 'StartSound', - 'StopSound', - 'SoundDone', - # These are soundMgr 3.0 routines that I can't seem to find... - 'GetSoundPreference', - 'SetSoundPreference', - 'GetCompressionInfo', - # Calls with void_ptr arguments (to be done). - 'SndGetInfo', - 'SndSetInfo', - # And old calls that are no longer supported - 'SetSoundVol', - 'GetSoundVol', - - ] - - def makeblacklisttypes(self): - return [ - "GetSoundVol", - "SetSoundVol", - "UnsignedFixed", - # Don't have the time to dig into this... - "Component", - ] - - def makerepairinstructions(self): - return [ - ([("Str255", "*", "InMode")], - [("*", "*", "OutMode")]), - - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode"), - ("long", "*", "OutMode")], - [("VarVarOutBuffer", "*", "InOutMode")]), - - ([("SCStatusPtr", "*", "InMode")], - [("SCStatus", "*", "OutMode")]), - - ([("SMStatusPtr", "*", "InMode")], - [("SMStatus", "*", "OutMode")]), - - ([("CompressionInfoPtr", "*", "InMode")], - [("CompressionInfo", "*", "OutMode")]), - - # For SndPlay's SndListHandle argument - ([("Handle", "sndHdl", "InMode")], - [("SndListHandle", "*", "*")]), - - # For SndStartFilePlay - ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")], - [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]), - - # For Comp3to1 etc. - ([("void_ptr", "inBuffer", "InMode"), - ("void", "outBuffer", "OutMode"), - ("unsigned_long", "cnt", "InMode")], - [("InOutBuffer", "buffer", "InOutMode")]), - - # Ditto -## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")], -## [("InOutBuf128", "state", "InOutMode")]), - ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")], - [("StateBlock", "state", "InOutMode")]), - - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/snd/sndsupport.py b/Mac/Modules/snd/sndsupport.py deleted file mode 100644 index b3b32f1999..0000000000 --- a/Mac/Modules/snd/sndsupport.py +++ /dev/null @@ -1,207 +0,0 @@ -# This script generates the Sound interface for Python. -# It uses the "bgen" package to generate C code. -# It execs the file sndgen.py which contain the function definitions -# (sndgen.py was generated by sndscan.py, scanning the header file). - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -from macsupport import * - - -# define our own function and module generators - -class SndMixIn: pass - -class SndFunction(SndMixIn, OSErrFunctionGenerator): pass -class SndMethod(SndMixIn, OSErrMethodGenerator): pass - - -# includestuff etc. are imported from macsupport - -includestuff = includestuff + """ -#include - -#ifndef HAVE_UNIVERSAL_HEADERS -#define SndCallBackUPP ProcPtr -#define NewSndCallBackProc(x) ((SndCallBackProcPtr)(x)) -#define SndListHandle Handle -#endif -""" - -initstuff = initstuff + """ -""" - - -# define types used for arguments (in addition to standard and macsupport types) - -class SndChannelPtrType(OpaqueByValueType): - def declare(self, name): - # Initializing all SndChannelPtr objects to 0 saves - # special-casing NewSndChannel(), where it is formally an - # input-output parameter but we treat it as output-only - # (since Python users are not supposed to allocate memory) - Output("SndChannelPtr %s = 0;", name) - -SndChannelPtr = SndChannelPtrType('SndChannelPtr', 'SndCh') - -SndCommand = OpaqueType('SndCommand', 'SndCmd') -SndCommand_ptr = OpaqueType('SndCommand', 'SndCmd') -SndListHandle = OpaqueByValueType("SndListHandle", "ResObj") - -class SndCallBackType(InputOnlyType): - def __init__(self): - Type.__init__(self, 'PyObject*', 'O') - def getargsCheck(self, name): - Output("if (%s != Py_None && !PyCallable_Check(%s))", name, name) - OutLbrace() - Output('PyErr_SetString(PyExc_TypeError, "callback must be callable");') - Output("goto %s__error__;", name) - OutRbrace() - def passInput(self, name): - return "NewSndCallBackProc(SndCh_UserRoutine)" - def cleanup(self, name): - # XXX This knows it is executing inside the SndNewChannel wrapper - Output("if (_res != NULL && %s != Py_None)", name) - OutLbrace() - Output("SndChannelObject *p = (SndChannelObject *)_res;") - Output("p->ob_itself->userInfo = (long)p;") - Output("Py_INCREF(%s);", name) - Output("p->ob_callback = %s;", name) - OutRbrace() - DedentLevel() - Output(" %s__error__: ;", name) - IndentLevel() - -SndCallBackProcPtr = SndCallBackType() -SndCallBackUPP = SndCallBackProcPtr - -SndCompletionProcPtr = FakeType('(SndCompletionProcPtr)0') # XXX -SndCompletionUPP = SndCompletionProcPtr - -##InOutBuf128 = FixedInputOutputBufferType(128) -StateBlock = StructInputOutputBufferType('StateBlock') - -AudioSelectionPtr = FakeType('0') # XXX - -ProcPtr = FakeType('0') # XXX -FilePlayCompletionUPP = FakeType('0') # XXX - -SCStatus = StructOutputBufferType('SCStatus') -SMStatus = StructOutputBufferType('SMStatus') -CompressionInfo = StructOutputBufferType('CompressionInfo') - -includestuff = includestuff + """ -#include /* for Set(Current)A5 */ - -/* Create a SndCommand object (an (int, int, int) tuple) */ -static PyObject * -SndCmd_New(SndCommand *pc) -{ - return Py_BuildValue("hhl", pc->cmd, pc->param1, pc->param2); -} - -/* Convert a SndCommand argument */ -static int -SndCmd_Convert(PyObject *v, SndCommand *pc) -{ - int len; - pc->param1 = 0; - pc->param2 = 0; - if (PyTuple_Check(v)) { - if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2)) - return 1; - PyErr_Clear(); - return PyArg_ParseTuple(v, "hhs#", &pc->cmd, &pc->param1, &pc->param2, &len); - } - return PyArg_Parse(v, "h", &pc->cmd); -} - -static pascal void SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd); /* Forward */ -""" - - -finalstuff = finalstuff + """ -/* Routine passed to Py_AddPendingCall -- call the Python callback */ -static int -SndCh_CallCallBack(arg) - void *arg; -{ - SndChannelObject *p = (SndChannelObject *)arg; - PyObject *args; - PyObject *res; - args = Py_BuildValue("(O(hhl))", - p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2); - res = PyEval_CallObject(p->ob_callback, args); - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -/* Routine passed to NewSndChannel -- schedule a call to SndCh_CallCallBack */ -static pascal void -SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd) -{ - SndChannelObject *p = (SndChannelObject *)(chan->userInfo); - if (p->ob_callback != NULL) { - long A5 = SetA5(p->ob_A5); - p->ob_cmd = *cmd; - Py_AddPendingCall(SndCh_CallCallBack, (void *)p); - SetA5(A5); - } -} -""" - - -# create the module and object definition and link them - -class SndObjectDefinition(ObjectDefinition): - - def outputStructMembers(self): - ObjectDefinition.outputStructMembers(self) - Output("/* Members used to implement callbacks: */") - Output("PyObject *ob_callback;") - Output("long ob_A5;"); - Output("SndCommand ob_cmd;") - - def outputInitStructMembers(self): - ObjectDefinition.outputInitStructMembers(self) - Output("it->ob_callback = NULL;") - Output("it->ob_A5 = SetCurrentA5();"); - - def outputCleanupStructMembers(self): - ObjectDefinition.outputCleanupStructMembers(self) - Output("Py_XDECREF(self->ob_callback);") - - def outputFreeIt(self, itselfname): - Output("SndDisposeChannel(%s, 1);", itselfname) - - -sndobject = SndObjectDefinition('SndChannel', 'SndCh', 'SndChannelPtr') -module = MacModule('Snd', 'Snd', includestuff, finalstuff, initstuff) -module.addobject(sndobject) - - -# create lists of functions and object methods - -functions = [] -sndmethods = [] - - -# populate the lists - -execfile('sndgen.py') - - -# add the functions and methods to the module and object, respectively - -for f in functions: module.add(f) -for f in sndmethods: sndobject.add(f) - - -# generate output - -SetOutputFileName('Sndmodule.c') -module.generate() diff --git a/Mac/Modules/te/TEmodule.c b/Mac/Modules/te/TEmodule.c deleted file mode 100644 index 3a5a062c1c..0000000000 --- a/Mac/Modules/te/TEmodule.c +++ /dev/null @@ -1,1040 +0,0 @@ - -/* =========================== Module TE ============================ */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -/* Exported by Qdmodule.c: */ -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); - -/* -** Parse/generate TextStyle records -*/ -PyObject *TextStyle_New(itself) - TextStylePtr itself; -{ - - return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, - &itself->tsColor); -} - -TextStyle_Convert(v, p_itself) - PyObject *v; - TextStylePtr p_itself; -{ - long font, face, size; - - if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) - return 0; - p_itself->tsFont = (short)font; - p_itself->tsFace = (Style)face; - p_itself->tsSize = (short)size; - return 1; -} - -static PyObject *TE_Error; - -/* ------------------------- Object type TE ------------------------- */ - -PyTypeObject TE_Type; - -#define TEObj_Check(x) ((x)->ob_type == &TE_Type) - -typedef struct TEObject { - PyObject_HEAD - TEHandle ob_itself; -} TEObject; - -PyObject *TEObj_New(itself) - TEHandle itself; -{ - TEObject *it; - if (itself == NULL) { - PyErr_SetString(TE_Error,"Cannot create null TE"); - return NULL; - } - it = PyObject_NEW(TEObject, &TE_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -TEObj_Convert(v, p_itself) - PyObject *v; - TEHandle *p_itself; -{ - if (!TEObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "TE required"); - return 0; - } - *p_itself = ((TEObject *)v)->ob_itself; - return 1; -} - -static void TEObj_dealloc(self) - TEObject *self; -{ - TEDispose(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *TEObj_TESetText(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *text__in__; - long text__len__; - int text__in_len__; - if (!PyArg_ParseTuple(_args, "s#", - &text__in__, &text__in_len__)) - return NULL; - text__len__ = text__in_len__; - TESetText(text__in__, text__len__, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - text__error__: ; - return _res; -} - -static PyObject *TEObj_TEGetText(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - CharsHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = TEGetText(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TEObj_TEIdle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TEIdle(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TESetSelect(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long selStart; - long selEnd; - if (!PyArg_ParseTuple(_args, "ll", - &selStart, - &selEnd)) - return NULL; - TESetSelect(selStart, - selEnd, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEActivate(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TEActivate(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEDeactivate(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TEDeactivate(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEKey(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short key; - if (!PyArg_ParseTuple(_args, "h", - &key)) - return NULL; - TEKey(key, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TECut(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TECut(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TECopy(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TECopy(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEPaste(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TEPaste(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEDelete(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TEDelete(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEInsert(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *text__in__; - long text__len__; - int text__in_len__; - if (!PyArg_ParseTuple(_args, "s#", - &text__in__, &text__in_len__)) - return NULL; - text__len__ = text__in_len__; - TEInsert(text__in__, text__len__, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - text__error__: ; - return _res; -} - -static PyObject *TEObj_TESetAlignment(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short just; - if (!PyArg_ParseTuple(_args, "h", - &just)) - return NULL; - TESetAlignment(just, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEUpdate(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect rUpdate; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &rUpdate)) - return NULL; - TEUpdate(&rUpdate, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEScroll(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "hh", - &dh, - &dv)) - return NULL; - TEScroll(dh, - dv, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TESelView(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TESelView(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEPinScroll(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short dh; - short dv; - if (!PyArg_ParseTuple(_args, "hh", - &dh, - &dv)) - return NULL; - TEPinScroll(dh, - dv, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEAutoView(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean fAuto; - if (!PyArg_ParseTuple(_args, "b", - &fAuto)) - return NULL; - TEAutoView(fAuto, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TECalText(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TECalText(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEGetOffset(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - Point pt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &pt)) - return NULL; - _rv = TEGetOffset(pt, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *TEObj_TEGetPoint(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point _rv; - short offset; - if (!PyArg_ParseTuple(_args, "h", - &offset)) - return NULL; - _rv = TEGetPoint(offset, - _self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, _rv); - return _res; -} - -static PyObject *TEObj_TEClick(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point pt; - Boolean fExtend; - if (!PyArg_ParseTuple(_args, "O&b", - PyMac_GetPoint, &pt, - &fExtend)) - return NULL; - TEClick(pt, - fExtend, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TESetStyleHandle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TEStyleHandle theHandle; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &theHandle)) - return NULL; - TESetStyleHandle(theHandle, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEGetStyleHandle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TEStyleHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = TEGetStyleHandle(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TEObj_TEGetStyle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short offset; - TextStyle theStyle; - short lineHeight; - short fontAscent; - if (!PyArg_ParseTuple(_args, "h", - &offset)) - return NULL; - TEGetStyle(offset, - &theStyle, - &lineHeight, - &fontAscent, - _self->ob_itself); - _res = Py_BuildValue("O&hh", - TextStyle_New, &theStyle, - lineHeight, - fontAscent); - return _res; -} - -static PyObject *TEObj_TEStylePaste(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - TEStylePaste(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TESetStyle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short mode; - TextStyle newStyle; - Boolean fRedraw; - if (!PyArg_ParseTuple(_args, "hO&b", - &mode, - TextStyle_Convert, &newStyle, - &fRedraw)) - return NULL; - TESetStyle(mode, - &newStyle, - fRedraw, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEReplaceStyle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short mode; - TextStyle oldStyle; - TextStyle newStyle; - Boolean fRedraw; - if (!PyArg_ParseTuple(_args, "hO&O&b", - &mode, - TextStyle_Convert, &oldStyle, - TextStyle_Convert, &newStyle, - &fRedraw)) - return NULL; - TEReplaceStyle(mode, - &oldStyle, - &newStyle, - fRedraw, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TEGetStyleScrapHandle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - StScrpHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = TEGetStyleScrapHandle(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TEObj_TEStyleInsert(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *text__in__; - long text__len__; - int text__in_len__; - StScrpHandle hST; - if (!PyArg_ParseTuple(_args, "s#O&", - &text__in__, &text__in_len__, - ResObj_Convert, &hST)) - return NULL; - text__len__ = text__in_len__; - TEStyleInsert(text__in__, text__len__, - hST, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - text__error__: ; - return _res; -} - -static PyObject *TEObj_TEGetHeight(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - long endLine; - long startLine; - if (!PyArg_ParseTuple(_args, "ll", - &endLine, - &startLine)) - return NULL; - _rv = TEGetHeight(endLine, - startLine, - _self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TEObj_TEContinuousStyle(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - short mode; - TextStyle aStyle; - if (!PyArg_ParseTuple(_args, "hO&", - &mode, - TextStyle_Convert, &aStyle)) - return NULL; - _rv = TEContinuousStyle(&mode, - &aStyle, - _self->ob_itself); - _res = Py_BuildValue("bhO&", - _rv, - mode, - TextStyle_New, &aStyle); - return _res; -} - -static PyObject *TEObj_TEUseStyleScrap(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long rangeStart; - long rangeEnd; - StScrpHandle newStyles; - Boolean fRedraw; - if (!PyArg_ParseTuple(_args, "llO&b", - &rangeStart, - &rangeEnd, - ResObj_Convert, &newStyles, - &fRedraw)) - return NULL; - TEUseStyleScrap(rangeStart, - rangeEnd, - newStyles, - fRedraw, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TEObj_TENumStyles(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - long rangeStart; - long rangeEnd; - if (!PyArg_ParseTuple(_args, "ll", - &rangeStart, - &rangeEnd)) - return NULL; - _rv = TENumStyles(rangeStart, - rangeEnd, - _self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TEObj_TEFeatureFlag(_self, _args) - TEObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - short feature; - short action; - if (!PyArg_ParseTuple(_args, "hh", - &feature, - &action)) - return NULL; - _rv = TEFeatureFlag(feature, - action, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyMethodDef TEObj_methods[] = { - {"TESetText", (PyCFunction)TEObj_TESetText, 1, - "(Buffer text) -> None"}, - {"TEGetText", (PyCFunction)TEObj_TEGetText, 1, - "() -> (CharsHandle _rv)"}, - {"TEIdle", (PyCFunction)TEObj_TEIdle, 1, - "() -> None"}, - {"TESetSelect", (PyCFunction)TEObj_TESetSelect, 1, - "(long selStart, long selEnd) -> None"}, - {"TEActivate", (PyCFunction)TEObj_TEActivate, 1, - "() -> None"}, - {"TEDeactivate", (PyCFunction)TEObj_TEDeactivate, 1, - "() -> None"}, - {"TEKey", (PyCFunction)TEObj_TEKey, 1, - "(short key) -> None"}, - {"TECut", (PyCFunction)TEObj_TECut, 1, - "() -> None"}, - {"TECopy", (PyCFunction)TEObj_TECopy, 1, - "() -> None"}, - {"TEPaste", (PyCFunction)TEObj_TEPaste, 1, - "() -> None"}, - {"TEDelete", (PyCFunction)TEObj_TEDelete, 1, - "() -> None"}, - {"TEInsert", (PyCFunction)TEObj_TEInsert, 1, - "(Buffer text) -> None"}, - {"TESetAlignment", (PyCFunction)TEObj_TESetAlignment, 1, - "(short just) -> None"}, - {"TEUpdate", (PyCFunction)TEObj_TEUpdate, 1, - "(Rect rUpdate) -> None"}, - {"TEScroll", (PyCFunction)TEObj_TEScroll, 1, - "(short dh, short dv) -> None"}, - {"TESelView", (PyCFunction)TEObj_TESelView, 1, - "() -> None"}, - {"TEPinScroll", (PyCFunction)TEObj_TEPinScroll, 1, - "(short dh, short dv) -> None"}, - {"TEAutoView", (PyCFunction)TEObj_TEAutoView, 1, - "(Boolean fAuto) -> None"}, - {"TECalText", (PyCFunction)TEObj_TECalText, 1, - "() -> None"}, - {"TEGetOffset", (PyCFunction)TEObj_TEGetOffset, 1, - "(Point pt) -> (short _rv)"}, - {"TEGetPoint", (PyCFunction)TEObj_TEGetPoint, 1, - "(short offset) -> (Point _rv)"}, - {"TEClick", (PyCFunction)TEObj_TEClick, 1, - "(Point pt, Boolean fExtend) -> None"}, - {"TESetStyleHandle", (PyCFunction)TEObj_TESetStyleHandle, 1, - "(TEStyleHandle theHandle) -> None"}, - {"TEGetStyleHandle", (PyCFunction)TEObj_TEGetStyleHandle, 1, - "() -> (TEStyleHandle _rv)"}, - {"TEGetStyle", (PyCFunction)TEObj_TEGetStyle, 1, - "(short offset) -> (TextStyle theStyle, short lineHeight, short fontAscent)"}, - {"TEStylePaste", (PyCFunction)TEObj_TEStylePaste, 1, - "() -> None"}, - {"TESetStyle", (PyCFunction)TEObj_TESetStyle, 1, - "(short mode, TextStyle newStyle, Boolean fRedraw) -> None"}, - {"TEReplaceStyle", (PyCFunction)TEObj_TEReplaceStyle, 1, - "(short mode, TextStyle oldStyle, TextStyle newStyle, Boolean fRedraw) -> None"}, - {"TEGetStyleScrapHandle", (PyCFunction)TEObj_TEGetStyleScrapHandle, 1, - "() -> (StScrpHandle _rv)"}, - {"TEStyleInsert", (PyCFunction)TEObj_TEStyleInsert, 1, - "(Buffer text, StScrpHandle hST) -> None"}, - {"TEGetHeight", (PyCFunction)TEObj_TEGetHeight, 1, - "(long endLine, long startLine) -> (long _rv)"}, - {"TEContinuousStyle", (PyCFunction)TEObj_TEContinuousStyle, 1, - "(short mode, TextStyle aStyle) -> (Boolean _rv, short mode, TextStyle aStyle)"}, - {"TEUseStyleScrap", (PyCFunction)TEObj_TEUseStyleScrap, 1, - "(long rangeStart, long rangeEnd, StScrpHandle newStyles, Boolean fRedraw) -> None"}, - {"TENumStyles", (PyCFunction)TEObj_TENumStyles, 1, - "(long rangeStart, long rangeEnd) -> (long _rv)"}, - {"TEFeatureFlag", (PyCFunction)TEObj_TEFeatureFlag, 1, - "(short feature, short action) -> (short _rv)"}, - {NULL, NULL, 0} -}; - -PyMethodChain TEObj_chain = { TEObj_methods, NULL }; - -static PyObject *TEObj_getattr(self, name) - TEObject *self; - char *name; -{ - - if( strcmp(name, "destRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->destRect); - if( strcmp(name, "viewRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->viewRect); - if( strcmp(name, "selRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->selRect); - if( strcmp(name, "lineHeight") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->lineHeight); - if( strcmp(name, "fontAscent") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->fontAscent); - if( strcmp(name, "selPoint") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, - &(*self->ob_itself)->selPoint); - if( strcmp(name, "selStart") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selStart); - if( strcmp(name, "selEnd") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selEnd); - if( strcmp(name, "active") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->active); - if( strcmp(name, "just") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->just); - if( strcmp(name, "teLength") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->teLength); - if( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFont); - if( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFace); - if( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txMode); - if( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txSize); - if( strcmp(name, "nLines") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->nLines); - - return Py_FindMethodInChain(&TEObj_chain, (PyObject *)self, name); -} - -#define TEObj_setattr NULL - -PyTypeObject TE_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "TE", /*tp_name*/ - sizeof(TEObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) TEObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) TEObj_getattr, /*tp_getattr*/ - (setattrfunc) TEObj_setattr, /*tp_setattr*/ -}; - -/* ----------------------- End object type TE ----------------------- */ - - -static PyObject *TE_TEScrapHandle(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = TEScrapHandle(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *TE_TEGetScrapLength(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = TEGetScrapLength(); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *TE_TENew(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TEHandle _rv; - Rect destRect; - Rect viewRect; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &destRect, - PyMac_GetRect, &viewRect)) - return NULL; - _rv = TENew(&destRect, - &viewRect); - _res = Py_BuildValue("O&", - TEObj_New, _rv); - return _res; -} - -static PyObject *TE_TETextBox(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - char *text__in__; - long text__len__; - int text__in_len__; - Rect box; - short just; - if (!PyArg_ParseTuple(_args, "s#O&h", - &text__in__, &text__in_len__, - PyMac_GetRect, &box, - &just)) - return NULL; - text__len__ = text__in_len__; - TETextBox(text__in__, text__len__, - &box, - just); - Py_INCREF(Py_None); - _res = Py_None; - text__error__: ; - return _res; -} - -static PyObject *TE_TEStyleNew(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - TEHandle _rv; - Rect destRect; - Rect viewRect; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &destRect, - PyMac_GetRect, &viewRect)) - return NULL; - _rv = TEStyleNew(&destRect, - &viewRect); - _res = Py_BuildValue("O&", - TEObj_New, _rv); - return _res; -} - -static PyObject *TE_TESetScrapLength(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long length; - if (!PyArg_ParseTuple(_args, "l", - &length)) - return NULL; - TESetScrapLength(length); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TE_TEFromScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = TEFromScrap(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *TE_TEToScrap(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = TEToScrap(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef TE_methods[] = { - {"TEScrapHandle", (PyCFunction)TE_TEScrapHandle, 1, - "() -> (Handle _rv)"}, - {"TEGetScrapLength", (PyCFunction)TE_TEGetScrapLength, 1, - "() -> (long _rv)"}, - {"TENew", (PyCFunction)TE_TENew, 1, - "(Rect destRect, Rect viewRect) -> (TEHandle _rv)"}, - {"TETextBox", (PyCFunction)TE_TETextBox, 1, - "(Buffer text, Rect box, short just) -> None"}, - {"TEStyleNew", (PyCFunction)TE_TEStyleNew, 1, - "(Rect destRect, Rect viewRect) -> (TEHandle _rv)"}, - {"TESetScrapLength", (PyCFunction)TE_TESetScrapLength, 1, - "(long length) -> None"}, - {"TEFromScrap", (PyCFunction)TE_TEFromScrap, 1, - "() -> None"}, - {"TEToScrap", (PyCFunction)TE_TEToScrap, 1, - "() -> None"}, - {NULL, NULL, 0} -}; - - - - -void initTE() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("TE", TE_methods); - d = PyModule_GetDict(m); - TE_Error = PyMac_GetOSErrException(); - if (TE_Error == NULL || - PyDict_SetItemString(d, "Error", TE_Error) != 0) - Py_FatalError("can't initialize TE.Error"); -} - -/* ========================= End module TE ========================== */ - diff --git a/Mac/Modules/te/tescan.py b/Mac/Modules/te/tescan.py deleted file mode 100644 index 8d919e8665..0000000000 --- a/Mac/Modules/te/tescan.py +++ /dev/null @@ -1,61 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -LONG = "TextEdit" -SHORT = "te" -OBJECT = "TEHandle" - -def main(): - input = LONG + ".h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[-1] - # This is non-functional today - if t == OBJECT and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - "TEDispose", - "TEInit", - "TEGetHiliteRgn", - ] - - def makeblacklisttypes(self): - return [ - "TEClickLoopUPP", - "UniversalProcPtr", - "WordBreakUPP" - ] - - def makerepairinstructions(self): - return [ - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - # TEContinuousStyle - ([("short", "mode", "OutMode"), ("TextStyle", "aStyle", "OutMode")], - [("short", "mode", "InOutMode"), ("TextStyle", "aStyle", "InOutMode")]) - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/te/tesupport.py b/Mac/Modules/te/tesupport.py deleted file mode 100644 index 7802ae9d5e..0000000000 --- a/Mac/Modules/te/tesupport.py +++ /dev/null @@ -1,154 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'TextEdit.h' # The Apple header file -MODNAME = 'TE' # The name of the module -OBJECTNAME = 'TE' # The basic name of the objects used here -KIND = 'Handle' # Usually 'Ptr' or 'Handle' - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = "TEHandle" # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects -TEHandle = OpaqueByValueType("TEHandle", "TEObj") -CharsHandle = OpaqueByValueType("CharsHandle", "ResObj") -##Handle = OpaqueByValueType("Handle", "ResObj") -StScrpHandle = OpaqueByValueType("StScrpHandle", "ResObj") -TEStyleHandle = OpaqueByValueType("TEStyleHandle", "ResObj") -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") - -TextStyle = OpaqueType("TextStyle", "TextStyle") -TextStyle_ptr = TextStyle - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ - -/* Exported by Qdmodule.c: */ -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); - -/* -** Parse/generate TextStyle records -*/ -PyObject *TextStyle_New(itself) - TextStylePtr itself; -{ - - return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, - &itself->tsColor); -} - -TextStyle_Convert(v, p_itself) - PyObject *v; - TextStylePtr p_itself; -{ - long font, face, size; - - if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) - return 0; - p_itself->tsFont = (short)font; - p_itself->tsFace = (Style)face; - p_itself->tsSize = (short)size; - return 1; -} -""" - -class TEMethodGenerator(OSErrMethodGenerator): - """Similar to MethodGenerator, but has self as last argument""" - - def parseArgumentList(self, args): - args, a0 = args[:-1], args[-1] - t0, n0, m0 = a0 - if m0 != InMode: - raise ValueError, "method's 'self' must be 'InMode'" - self.itself = Variable(t0, "_self->ob_itself", SelfMode) - FunctionGenerator.parseArgumentList(self, args) - self.argumentList.append(self.itself) - - - -class MyObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(TE_Error,"Cannot create null TE"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - Output("TEDispose(%s);", itselfname) - - def outputGetattrHook(self): - Output(""" - if( strcmp(name, "destRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->destRect); - if( strcmp(name, "viewRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->viewRect); - if( strcmp(name, "selRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->selRect); - if( strcmp(name, "lineHeight") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->lineHeight); - if( strcmp(name, "fontAscent") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->fontAscent); - if( strcmp(name, "selPoint") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, - &(*self->ob_itself)->selPoint); - if( strcmp(name, "selStart") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selStart); - if( strcmp(name, "selEnd") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selEnd); - if( strcmp(name, "active") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->active); - if( strcmp(name, "just") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->just); - if( strcmp(name, "teLength") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->teLength); - if( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFont); - if( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFace); - if( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txMode); - if( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txSize); - if( strcmp(name, "nLines") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->nLines); - """) - -# From here on it's basically all boiler plate... - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = TEMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile(INPUTFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -for f in methods: object.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/waste/wastemodule.c b/Mac/Modules/waste/wastemodule.c deleted file mode 100644 index 571a307ef3..0000000000 --- a/Mac/Modules/waste/wastemodule.c +++ /dev/null @@ -1,1947 +0,0 @@ - -/* ========================== Module waste ========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include -#include - -/* Exported by Qdmodule.c: */ -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); - -/* Forward declaration */ -staticforward PyObject *WEOObj_New(WEObjectReference); -staticforward PyObject *ExistingwasteObj_New(WEReference); - -/* -** Parse/generate TextStyle records -*/ -static -PyObject *TextStyle_New(itself) - TextStylePtr itself; -{ - - return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, - &itself->tsColor); -} - -static -TextStyle_Convert(v, p_itself) - PyObject *v; - TextStylePtr p_itself; -{ - long font, face, size; - - if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) - return 0; - p_itself->tsFont = (short)font; - p_itself->tsFace = (Style)face; - p_itself->tsSize = (short)size; - return 1; -} - -/* -** Parse/generate RunInfo records -*/ -static -PyObject *RunInfo_New(itself) - WERunInfo *itself; -{ - - return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight, - itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject); -} - -/* Conversion of long points and rects */ -int -LongRect_Convert(PyObject *v, LongRect *r) -{ - return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom); -} - -PyObject * -LongRect_New(LongRect *r) -{ - return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom); -} - - -LongPt_Convert(PyObject *v, LongPt *p) -{ - return PyArg_Parse(v, "(ll)", &p->h, &p->v); -} - -PyObject * -LongPt_New(LongPt *p) -{ - return Py_BuildValue("(ll)", p->h, p->v); -} - -/* Stuff for the callbacks: */ -static PyObject *callbackdict; -WENewObjectUPP upp_new_handler; -WEDisposeObjectUPP upp_dispose_handler; -WEDrawObjectUPP upp_draw_handler; -WEClickObjectUPP upp_click_handler; - -static OSErr -any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv) -{ - FlavorType tp; - PyObject *key, *func; - - if ( args == NULL ) return errAECorruptData; - - tp = WEGetObjectType(who); - - if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL) - return errAECorruptData; - if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) { - Py_DECREF(key); - return errAEHandlerNotFound; - } - Py_INCREF(func); - *rv = PyEval_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(key); - if ( *rv == NULL ) { - fprintf(stderr, "--Exception in callback: "); - PyErr_Print(); - return errAEReplyNotArrived; - } - return 0; -} - -static pascal OSErr -my_new_handler(Point *objectSize, WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("(O&)", WEOObj_New, objref); - err = any_handler(weNewHandler, objref, args, &rv); - if (!err) { - if (!PyMac_GetPoint(rv, objectSize) ) - err = errAECoercionFail; - } - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return err; -} - -static pascal OSErr -my_dispose_handler(WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("(O&)", WEOObj_New, objref); - err = any_handler(weDisposeHandler, objref, args, &rv); - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return err; -} - -static pascal OSErr -my_draw_handler(Rect *destRect, WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref); - err = any_handler(weDrawHandler, objref, args, &rv); - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return err; -} - -static pascal Boolean -my_click_handler(Point hitPt, EventModifiers modifiers, - unsigned long clickTime, WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - int retvalue; - OSErr err; - - args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt, - (long)modifiers, (long)clickTime, WEOObj_New, objref); - err = any_handler(weClickHandler, objref, args, &rv); - if (!err) - retvalue = PyInt_AsLong(rv); - else - retvalue = 0; - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return retvalue; -} - - - -static PyObject *waste_Error; - -/* ------------------------ Object type WEO ------------------------- */ - -PyTypeObject WEO_Type; - -#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type) - -typedef struct WEOObject { - PyObject_HEAD - WEObjectReference ob_itself; -} WEOObject; - -PyObject *WEOObj_New(itself) - WEObjectReference itself; -{ - WEOObject *it; - if (itself == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - it = PyObject_NEW(WEOObject, &WEO_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -WEOObj_Convert(v, p_itself) - PyObject *v; - WEObjectReference *p_itself; -{ - if (!WEOObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "WEO required"); - return 0; - } - *p_itself = ((WEOObject *)v)->ob_itself; - return 1; -} - -static void WEOObj_dealloc(self) - WEOObject *self; -{ - /* Cleanup of self->ob_itself goes here */ - PyMem_DEL(self); -} - -static PyObject *WEOObj_WEGetObjectType(_self, _args) - WEOObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - FlavorType _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetObjectType(_self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildOSType, _rv); - return _res; -} - -static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args) - WEOObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetObjectDataHandle(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *WEOObj_WEGetObjectSize(_self, _args) - WEOObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetObjectSize(_self->ob_itself); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, _rv); - return _res; -} - -static PyObject *WEOObj_WEGetObjectOwner(_self, _args) - WEOObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WEReference _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetObjectOwner(_self->ob_itself); - _res = Py_BuildValue("O&", - ExistingwasteObj_New, _rv); - return _res; -} - -static PyObject *WEOObj_WEGetObjectRefCon(_self, _args) - WEOObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetObjectRefCon(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *WEOObj_WESetObjectRefCon(_self, _args) - WEOObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 refCon; - if (!PyArg_ParseTuple(_args, "l", - &refCon)) - return NULL; - WESetObjectRefCon(_self->ob_itself, - refCon); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef WEOObj_methods[] = { - {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1, - "() -> (FlavorType _rv)"}, - {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1, - "() -> (Handle _rv)"}, - {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1, - "() -> (Point _rv)"}, - {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1, - "() -> (WEReference _rv)"}, - {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1, - "() -> (SInt32 _rv)"}, - {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1, - "(SInt32 refCon) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain WEOObj_chain = { WEOObj_methods, NULL }; - -static PyObject *WEOObj_getattr(self, name) - WEOObject *self; - char *name; -{ - return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name); -} - -#define WEOObj_setattr NULL - -PyTypeObject WEO_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "WEO", /*tp_name*/ - sizeof(WEOObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) WEOObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) WEOObj_getattr, /*tp_getattr*/ - (setattrfunc) WEOObj_setattr, /*tp_setattr*/ -}; - -/* ---------------------- End object type WEO ----------------------- */ - - -/* ----------------------- Object type waste ------------------------ */ - -PyTypeObject waste_Type; - -#define wasteObj_Check(x) ((x)->ob_type == &waste_Type) - -typedef struct wasteObject { - PyObject_HEAD - WEReference ob_itself; -} wasteObject; - -PyObject *wasteObj_New(itself) - WEReference itself; -{ - wasteObject *it; - if (itself == NULL) { - PyErr_SetString(waste_Error,"Cannot create null WE"); - return NULL; - } - it = PyObject_NEW(wasteObject, &waste_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - WESetInfo(weRefCon, (void *)&it, itself); - return (PyObject *)it; -} -wasteObj_Convert(v, p_itself) - PyObject *v; - WEReference *p_itself; -{ - if (!wasteObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "waste required"); - return 0; - } - *p_itself = ((wasteObject *)v)->ob_itself; - return 1; -} - -static void wasteObj_dealloc(self) - wasteObject *self; -{ - WEDispose(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *wasteObj_WEGetText(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetText(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *wasteObj_WEGetChar(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - SInt32 offset; - if (!PyArg_ParseTuple(_args, "l", - &offset)) - return NULL; - _rv = WEGetChar(offset, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *wasteObj_WEGetTextLength(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetTextLength(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *wasteObj_WECountLines(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WECountLines(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *wasteObj_WEGetHeight(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - SInt32 startLine; - SInt32 endLine; - if (!PyArg_ParseTuple(_args, "ll", - &startLine, - &endLine)) - return NULL; - _rv = WEGetHeight(startLine, - endLine, - _self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *wasteObj_WEGetSelection(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 selStart; - SInt32 selEnd; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEGetSelection(&selStart, - &selEnd, - _self->ob_itself); - _res = Py_BuildValue("ll", - selStart, - selEnd); - return _res; -} - -static PyObject *wasteObj_WEGetDestRect(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongRect destRect; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEGetDestRect(&destRect, - _self->ob_itself); - _res = Py_BuildValue("O&", - LongRect_New, &destRect); - return _res; -} - -static PyObject *wasteObj_WEGetViewRect(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongRect viewRect; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEGetViewRect(&viewRect, - _self->ob_itself); - _res = Py_BuildValue("O&", - LongRect_New, &viewRect); - return _res; -} - -static PyObject *wasteObj_WEIsActive(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEIsActive(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *wasteObj_WEOffsetToLine(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - SInt32 offset; - if (!PyArg_ParseTuple(_args, "l", - &offset)) - return NULL; - _rv = WEOffsetToLine(offset, - _self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *wasteObj_WEGetLineRange(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 lineNo; - SInt32 lineStart; - SInt32 lineEnd; - if (!PyArg_ParseTuple(_args, "l", - &lineNo)) - return NULL; - WEGetLineRange(lineNo, - &lineStart, - &lineEnd, - _self->ob_itself); - _res = Py_BuildValue("ll", - lineStart, - lineEnd); - return _res; -} - -static PyObject *wasteObj_WEGetClickCount(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UInt16 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetClickCount(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *wasteObj_WESetSelection(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 selStart; - SInt32 selEnd; - if (!PyArg_ParseTuple(_args, "ll", - &selStart, - &selEnd)) - return NULL; - WESetSelection(selStart, - selEnd, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WESetDestRect(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongRect destRect; - if (!PyArg_ParseTuple(_args, "O&", - LongRect_Convert, &destRect)) - return NULL; - WESetDestRect(&destRect, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WESetViewRect(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongRect viewRect; - if (!PyArg_ParseTuple(_args, "O&", - LongRect_Convert, &viewRect)) - return NULL; - WESetViewRect(&viewRect, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEContinuousStyle(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - WEStyleMode mode; - TextStyle ts; - if (!PyArg_ParseTuple(_args, "h", - &mode)) - return NULL; - _rv = WEContinuousStyle(&mode, - &ts, - _self->ob_itself); - _res = Py_BuildValue("bhO&", - _rv, - mode, - TextStyle_New, &ts); - return _res; -} - -static PyObject *wasteObj_WEGetRunInfo(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 offset; - WERunInfo runInfo; - if (!PyArg_ParseTuple(_args, "l", - &offset)) - return NULL; - WEGetRunInfo(offset, - &runInfo, - _self->ob_itself); - _res = Py_BuildValue("O&", - RunInfo_New, &runInfo); - return _res; -} - -static PyObject *wasteObj_WEGetOffset(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - LongPt thePoint; - WEEdge edge; - if (!PyArg_ParseTuple(_args, "O&", - LongPt_Convert, &thePoint)) - return NULL; - _rv = WEGetOffset(&thePoint, - &edge, - _self->ob_itself); - _res = Py_BuildValue("lb", - _rv, - edge); - return _res; -} - -static PyObject *wasteObj_WEGetPoint(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 offset; - SInt16 direction; - LongPt thePoint; - SInt16 lineHeight; - if (!PyArg_ParseTuple(_args, "lh", - &offset, - &direction)) - return NULL; - WEGetPoint(offset, - direction, - &thePoint, - &lineHeight, - _self->ob_itself); - _res = Py_BuildValue("O&h", - LongPt_New, &thePoint, - lineHeight); - return _res; -} - -static PyObject *wasteObj_WEFindWord(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 offset; - WEEdge edge; - SInt32 wordStart; - SInt32 wordEnd; - if (!PyArg_ParseTuple(_args, "lb", - &offset, - &edge)) - return NULL; - WEFindWord(offset, - edge, - &wordStart, - &wordEnd, - _self->ob_itself); - _res = Py_BuildValue("ll", - wordStart, - wordEnd); - return _res; -} - -static PyObject *wasteObj_WEFindLine(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 offset; - WEEdge edge; - SInt32 lineStart; - SInt32 lineEnd; - if (!PyArg_ParseTuple(_args, "lb", - &offset, - &edge)) - return NULL; - WEFindLine(offset, - edge, - &lineStart, - &lineEnd, - _self->ob_itself); - _res = Py_BuildValue("ll", - lineStart, - lineEnd); - return _res; -} - -static PyObject *wasteObj_WECopyRange(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - SInt32 rangeStart; - SInt32 rangeEnd; - Handle hText; - StScrpHandle hStyles; - WESoupHandle hSoup; - if (!PyArg_ParseTuple(_args, "llO&O&O&", - &rangeStart, - &rangeEnd, - OptResObj_Convert, &hText, - OptResObj_Convert, &hStyles, - OptResObj_Convert, &hSoup)) - return NULL; - _err = WECopyRange(rangeStart, - rangeEnd, - hText, - hStyles, - hSoup, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEGetAlignment(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WEAlignment _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetAlignment(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *wasteObj_WESetAlignment(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WEAlignment alignment; - if (!PyArg_ParseTuple(_args, "b", - &alignment)) - return NULL; - WESetAlignment(alignment, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WECalText(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WECalText(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEUpdate(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle updateRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &updateRgn)) - return NULL; - WEUpdate(updateRgn, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEScroll(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 hOffset; - SInt32 vOffset; - if (!PyArg_ParseTuple(_args, "ll", - &hOffset, - &vOffset)) - return NULL; - WEScroll(hOffset, - vOffset, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WESelView(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WESelView(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEActivate(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEActivate(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEDeactivate(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEDeactivate(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEKey(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 key; - EventModifiers modifiers; - if (!PyArg_ParseTuple(_args, "hh", - &key, - &modifiers)) - return NULL; - WEKey(key, - modifiers, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEClick(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point hitPt; - EventModifiers modifiers; - UInt32 clickTime; - if (!PyArg_ParseTuple(_args, "O&hl", - PyMac_GetPoint, &hitPt, - &modifiers, - &clickTime)) - return NULL; - WEClick(hitPt, - modifiers, - clickTime, - _self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEAdjustCursor(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point mouseLoc; - RgnHandle mouseRgn; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &mouseLoc, - ResObj_Convert, &mouseRgn)) - return NULL; - _rv = WEAdjustCursor(mouseLoc, - mouseRgn, - _self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *wasteObj_WEIdle(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UInt32 maxSleep; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEIdle(&maxSleep, - _self->ob_itself); - _res = Py_BuildValue("l", - maxSleep); - return _res; -} - -static PyObject *wasteObj_WEInsert(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - char *pText__in__; - long pText__len__; - int pText__in_len__; - StScrpHandle hStyles; - WESoupHandle hSoup; - if (!PyArg_ParseTuple(_args, "s#O&O&", - &pText__in__, &pText__in_len__, - OptResObj_Convert, &hStyles, - OptResObj_Convert, &hSoup)) - return NULL; - pText__len__ = pText__in_len__; - _err = WEInsert(pText__in__, pText__len__, - hStyles, - hSoup, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - pText__error__: ; - return _res; -} - -static PyObject *wasteObj_WEDelete(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WEDelete(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WESetStyle(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - WEStyleMode mode; - TextStyle ts; - if (!PyArg_ParseTuple(_args, "hO&", - &mode, - TextStyle_Convert, &ts)) - return NULL; - _err = WESetStyle(mode, - &ts, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEUseStyleScrap(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - StScrpHandle hStyles; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &hStyles)) - return NULL; - _err = WEUseStyleScrap(hStyles, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEUseText(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - Handle hText; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &hText)) - return NULL; - _err = WEUseText(hText, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEUndo(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WEUndo(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEClearUndo(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEClearUndo(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEGetUndoInfo(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WEActionKind _rv; - Boolean redoFlag; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetUndoInfo(&redoFlag, - _self->ob_itself); - _res = Py_BuildValue("hb", - _rv, - redoFlag); - return _res; -} - -static PyObject *wasteObj_WEIsTyping(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEIsTyping(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *wasteObj_WEGetModCount(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - UInt32 _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WEGetModCount(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *wasteObj_WEResetModCount(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEResetModCount(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEInsertObject(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - FlavorType objectType; - Handle objectDataHandle; - Point objectSize; - if (!PyArg_ParseTuple(_args, "O&O&O&", - PyMac_GetOSType, &objectType, - ResObj_Convert, &objectDataHandle, - PyMac_GetPoint, &objectSize)) - return NULL; - _err = WEInsertObject(objectType, - objectDataHandle, - objectSize, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEGetSelectedObject(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - WEObjectReference obj; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WEGetSelectedObject(&obj, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - WEOObj_New, obj); - return _res; -} - -static PyObject *wasteObj_WEFindNextObject(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - SInt32 offset; - WEObjectReference obj; - if (!PyArg_ParseTuple(_args, "l", - &offset)) - return NULL; - _rv = WEFindNextObject(offset, - &obj, - _self->ob_itself); - _res = Py_BuildValue("lO&", - _rv, - WEOObj_New, obj); - return _res; -} - -static PyObject *wasteObj_WEUseSoup(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - WESoupHandle hSoup; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &hSoup)) - return NULL; - _err = WEUseSoup(hSoup, - _self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WECut(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WECut(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WECopy(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WECopy(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEPaste(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WEPaste(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WECanPaste(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = WECanPaste(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *wasteObj_WEGetHiliteRgn(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - SInt32 rangeStart; - SInt32 rangeEnd; - if (!PyArg_ParseTuple(_args, "ll", - &rangeStart, - &rangeEnd)) - return NULL; - _rv = WEGetHiliteRgn(rangeStart, - rangeEnd, - _self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *wasteObj_WECharByte(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - SInt32 offset; - if (!PyArg_ParseTuple(_args, "l", - &offset)) - return NULL; - _rv = WECharByte(offset, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *wasteObj_WECharType(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - SInt32 offset; - if (!PyArg_ParseTuple(_args, "l", - &offset)) - return NULL; - _rv = WECharType(offset, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *wasteObj_WEStopInlineSession(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - WEStopInlineSession(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *wasteObj_WEFeatureFlag(_self, _args) - wasteObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt16 _rv; - SInt16 feature; - SInt16 action; - if (!PyArg_ParseTuple(_args, "hh", - &feature, - &action)) - return NULL; - _rv = WEFeatureFlag(feature, - action, - _self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyMethodDef wasteObj_methods[] = { - {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1, - "() -> (Handle _rv)"}, - {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1, - "(SInt32 offset) -> (SInt16 _rv)"}, - {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1, - "() -> (SInt32 _rv)"}, - {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1, - "() -> (SInt32 _rv)"}, - {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1, - "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"}, - {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1, - "() -> (SInt32 selStart, SInt32 selEnd)"}, - {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1, - "() -> (LongRect destRect)"}, - {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1, - "() -> (LongRect viewRect)"}, - {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1, - "() -> (Boolean _rv)"}, - {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1, - "(SInt32 offset) -> (SInt32 _rv)"}, - {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1, - "(SInt32 lineNo) -> (SInt32 lineStart, SInt32 lineEnd)"}, - {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1, - "() -> (UInt16 _rv)"}, - {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1, - "(SInt32 selStart, SInt32 selEnd) -> None"}, - {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1, - "(LongRect destRect) -> None"}, - {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1, - "(LongRect viewRect) -> None"}, - {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1, - "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"}, - {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1, - "(SInt32 offset) -> (WERunInfo runInfo)"}, - {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1, - "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"}, - {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1, - "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"}, - {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1, - "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"}, - {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1, - "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"}, - {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1, - "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"}, - {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1, - "() -> (WEAlignment _rv)"}, - {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1, - "(WEAlignment alignment) -> None"}, - {"WECalText", (PyCFunction)wasteObj_WECalText, 1, - "() -> None"}, - {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1, - "(RgnHandle updateRgn) -> None"}, - {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1, - "(SInt32 hOffset, SInt32 vOffset) -> None"}, - {"WESelView", (PyCFunction)wasteObj_WESelView, 1, - "() -> None"}, - {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1, - "() -> None"}, - {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1, - "() -> None"}, - {"WEKey", (PyCFunction)wasteObj_WEKey, 1, - "(SInt16 key, EventModifiers modifiers) -> None"}, - {"WEClick", (PyCFunction)wasteObj_WEClick, 1, - "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"}, - {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1, - "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"}, - {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1, - "() -> (UInt32 maxSleep)"}, - {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1, - "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"}, - {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1, - "() -> None"}, - {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1, - "(WEStyleMode mode, TextStyle ts) -> None"}, - {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1, - "(StScrpHandle hStyles) -> None"}, - {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1, - "(Handle hText) -> None"}, - {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1, - "() -> None"}, - {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1, - "() -> None"}, - {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1, - "() -> (WEActionKind _rv, Boolean redoFlag)"}, - {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1, - "() -> (Boolean _rv)"}, - {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1, - "() -> (UInt32 _rv)"}, - {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1, - "() -> None"}, - {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1, - "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"}, - {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1, - "() -> (WEObjectReference obj)"}, - {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1, - "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"}, - {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1, - "(WESoupHandle hSoup) -> None"}, - {"WECut", (PyCFunction)wasteObj_WECut, 1, - "() -> None"}, - {"WECopy", (PyCFunction)wasteObj_WECopy, 1, - "() -> None"}, - {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1, - "() -> None"}, - {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1, - "() -> (Boolean _rv)"}, - {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1, - "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"}, - {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1, - "(SInt32 offset) -> (SInt16 _rv)"}, - {"WECharType", (PyCFunction)wasteObj_WECharType, 1, - "(SInt32 offset) -> (SInt16 _rv)"}, - {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1, - "() -> None"}, - {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1, - "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"}, - {NULL, NULL, 0} -}; - -PyMethodChain wasteObj_chain = { wasteObj_methods, NULL }; - -static PyObject *wasteObj_getattr(self, name) - wasteObject *self; - char *name; -{ - return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name); -} - -#define wasteObj_setattr NULL - -PyTypeObject waste_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "waste", /*tp_name*/ - sizeof(wasteObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) wasteObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) wasteObj_getattr, /*tp_getattr*/ - (setattrfunc) wasteObj_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type waste ---------------------- */ - - -static PyObject *waste_WENew(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - LongRect destRect; - LongRect viewRect; - UInt32 flags; - WEReference we; - if (!PyArg_ParseTuple(_args, "O&O&l", - LongRect_Convert, &destRect, - LongRect_Convert, &viewRect, - &flags)) - return NULL; - _err = WENew(&destRect, - &viewRect, - flags, - &we); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - wasteObj_New, we); - return _res; -} - -static PyObject *waste_WEInstallTSMHandlers(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WEInstallTSMHandlers(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *waste_WERemoveTSMHandlers(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = WERemoveTSMHandlers(); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *waste_WELongPointToPoint(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongPt lp; - Point p; - if (!PyArg_ParseTuple(_args, "O&", - LongPt_Convert, &lp)) - return NULL; - WELongPointToPoint(&lp, - &p); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, p); - return _res; -} - -static PyObject *waste_WEPointToLongPoint(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point p; - LongPt lp; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &p)) - return NULL; - WEPointToLongPoint(p, - &lp); - _res = Py_BuildValue("O&", - LongPt_New, &lp); - return _res; -} - -static PyObject *waste_WESetLongRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongRect lr; - SInt32 left; - SInt32 top; - SInt32 right; - SInt32 bottom; - if (!PyArg_ParseTuple(_args, "llll", - &left, - &top, - &right, - &bottom)) - return NULL; - WESetLongRect(&lr, - left, - top, - right, - bottom); - _res = Py_BuildValue("O&", - LongRect_New, &lr); - return _res; -} - -static PyObject *waste_WELongRectToRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongRect lr; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - LongRect_Convert, &lr)) - return NULL; - WELongRectToRect(&lr, - &r); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); - return _res; -} - -static PyObject *waste_WERectToLongRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - LongRect lr; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - WERectToLongRect(&r, - &lr); - _res = Py_BuildValue("O&", - LongRect_New, &lr); - return _res; -} - -static PyObject *waste_WEOffsetLongRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - LongRect lr; - SInt32 hOffset; - SInt32 vOffset; - if (!PyArg_ParseTuple(_args, "ll", - &hOffset, - &vOffset)) - return NULL; - WEOffsetLongRect(&lr, - hOffset, - vOffset); - _res = Py_BuildValue("O&", - LongRect_New, &lr); - return _res; -} - -static PyObject *waste_WELongPointInLongRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - LongPt lp; - LongRect lr; - if (!PyArg_ParseTuple(_args, "O&O&", - LongPt_Convert, &lp, - LongRect_Convert, &lr)) - return NULL; - _rv = WELongPointInLongRect(&lp, - &lr); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *waste_STDObjectHandlers(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - OSErr err; - // install the sample object handlers for pictures and sounds -#define kTypePicture 'PICT' -#define kTypeSound 'snd ' - - if ( !PyArg_ParseTuple(_args, "") ) return NULL; - - if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler, - (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler, - (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler, - (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler, - (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler, - (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler, - (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr) - goto cleanup; - Py_INCREF(Py_None); - return Py_None; - - cleanup: - return PyMac_Error(err); - -} - -static PyObject *waste_WEInstallObjectHandler(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - OSErr err; - FlavorType objectType; - WESelector selector; - PyObject *py_handler; - UniversalProcPtr handler; - WEReference we = NULL; - PyObject *key; - - - if ( !PyArg_ParseTuple(_args, "O&O&O|O&", - PyMac_GetOSType, &objectType, - PyMac_GetOSType, &selector, - &py_handler, - ExistingwasteObj_New, &we) ) return NULL; - - if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler; - else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler; - else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler; - else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler; - else return PyMac_Error(weUndefinedSelectorErr); - - if ((key = Py_BuildValue("O&O&", - PyMac_BuildOSType, objectType, - PyMac_BuildOSType, selector)) == NULL ) - return NULL; - - PyDict_SetItem(callbackdict, key, py_handler); - - err = WEInstallObjectHandler(objectType, selector, handler, we); - if ( err ) return PyMac_Error(err); - Py_INCREF(Py_None); - return Py_None; - -} - -static PyMethodDef waste_methods[] = { - {"WENew", (PyCFunction)waste_WENew, 1, - "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"}, - {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1, - "() -> None"}, - {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1, - "() -> None"}, - {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1, - "(LongPt lp) -> (Point p)"}, - {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1, - "(Point p) -> (LongPt lp)"}, - {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1, - "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"}, - {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1, - "(LongRect lr) -> (Rect r)"}, - {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1, - "(Rect r) -> (LongRect lr)"}, - {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1, - "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"}, - {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1, - "(LongPt lp, LongRect lr) -> (Boolean _rv)"}, - {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1, - NULL}, - {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1, - NULL}, - {NULL, NULL, 0} -}; - - - -/* Return the object corresponding to the window, or NULL */ - -PyObject * -ExistingwasteObj_New(w) - WEReference w; -{ - PyObject *it = NULL; - - if (w == NULL) - it = NULL; - else - WEGetInfo(weRefCon, (void *)&it, w); - if (it == NULL || ((wasteObject *)it)->ob_itself != w) - it = Py_None; - Py_INCREF(it); - return it; -} - - -void initwaste() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("waste", waste_methods); - d = PyModule_GetDict(m); - waste_Error = PyMac_GetOSErrException(); - if (waste_Error == NULL || - PyDict_SetItemString(d, "Error", waste_Error) != 0) - Py_FatalError("can't initialize waste.Error"); - - callbackdict = PyDict_New(); - if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0) - Py_FatalError("can't initialize Waste.callbackdict"); - upp_new_handler = NewWENewObjectProc(my_new_handler); - upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler); - upp_draw_handler = NewWEDrawObjectProc(my_draw_handler); - upp_click_handler = NewWEClickObjectProc(my_click_handler); - - -} - -/* ======================== End module waste ======================== */ - diff --git a/Mac/Modules/waste/wastescan.py b/Mac/Modules/waste/wastescan.py deleted file mode 100644 index add9364fe5..0000000000 --- a/Mac/Modules/waste/wastescan.py +++ /dev/null @@ -1,86 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import addpack -addpack.addpack(':tools:bgen:bgen') -from scantools import Scanner -from bgenlocations import TOOLBOXDIR - -WASTEDIR=":::::Waste 1.2 distribution:" - -OBJECT = "TEHandle" -SHORT = "waste" -OBJECT = "WEReference" -OBJECT2 = "WEObjectReference" - -def main(): - input = WASTEDIR + "WASTE C/C++ Headers:WASTE.h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + "WASTEconst.py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() -## scanner.gentypetest(SHORT+"typetest.py") - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[-1] - # This is non-functional today - if t == OBJECT and m == "InMode": - classname = "Method" - listname = "methods" - else: - t, n, m = arglist[0] - if t == OBJECT2 and m == "InMode": - classname = "Method2" - listname = "methods2" - return classname, listname - - def makeblacklistnames(self): - return [ - "WEDispose", - "WESetInfo", # Argument type unknown... - "WEGetInfo", - "WEVersion", # Unfortunately... - ] - - def makeblacklisttypes(self): - return [ - "DragReference", # For now... - "UniversalProcPtr", - ] - - def makerepairinstructions(self): - return [ - ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")], - [("InBuffer", "*", "*")]), - - # WEContinuousStyle - ([("WEStyleMode", "mode", "OutMode"), ("TextStyle", "ts", "OutMode")], - [("WEStyleMode", "mode", "InOutMode"), ("TextStyle", "ts", "OutMode")]), - - # WECopyRange - ([('Handle', 'hText', 'InMode'), ('StScrpHandle', 'hStyles', 'InMode'), - ('WESoupHandle', 'hSoup', 'InMode')], - [('OptHandle', 'hText', 'InMode'), ('OptStScrpHandle', 'hStyles', 'InMode'), - ('OptSoupHandle', 'hSoup', 'InMode')]), - - # WEInsert - ([('StScrpHandle', 'hStyles', 'InMode'), ('WESoupHandle', 'hSoup', 'InMode')], - [('OptStScrpHandle', 'hStyles', 'InMode'), ('OptSoupHandle', 'hSoup', 'InMode')]), - - # WEGetObjectOwner - ("WEGetObjectOwner", - [('WEReference', '*', 'ReturnMode')], - [('ExistingWEReference', '*', 'ReturnMode')]) - - ] - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/waste/wastesupport.py b/Mac/Modules/waste/wastesupport.py deleted file mode 100644 index 4671529842..0000000000 --- a/Mac/Modules/waste/wastesupport.py +++ /dev/null @@ -1,403 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -# Declarations that change for each manager -MACHEADERFILE = 'WASTE.h' # The Apple header file -MODNAME = 'waste' # The name of the module -OBJECTNAME = 'waste' # The basic name of the objects used here -KIND = 'Ptr' # Usually 'Ptr' or 'Handle' - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = "WEReference" # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = 'wastegen.py' # The file generated by the scanner -TYPETESTFILE = 'wastetypetest.py' # Another file generated by the scanner -OUTPUTFILE = "wastemodule.c" # The file generated by this program - -from macsupport import * - -# Create the type objects -WEReference = OpaqueByValueType("WEReference", "wasteObj") -ExistingWEReference = OpaqueByValueType("WEReference", "ExistingwasteObj") -WEObjectReference = OpaqueByValueType("WEObjectReference", "WEOObj") -StScrpHandle = OpaqueByValueType("StScrpHandle", "ResObj") -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") -EventModifiers = Type("EventModifiers", "h") -FlavorType = OSTypeType("FlavorType") -WESelector = OSTypeType("WESelector") - -OptHandle = OpaqueByValueType("Handle", "OptResObj") -OptSoupHandle = OpaqueByValueType("WESoupHandle", "OptResObj") -OptStScrpHandle = OpaqueByValueType("StScrpHandle", "OptResObj") - -WEStyleMode = Type("WEStyleMode", "h") -WEActionKind = Type("WEActionKind", "h") -WEAlignment = Type("WEAlignment", "b") -WEEdge = Type("WEEdge", "b") -WESoupHandle = OpaqueByValueType("WESoupHandle", "ResObj") -WERunInfo = OpaqueType("WERunInfo", "RunInfo") - -TextStyle = OpaqueType("TextStyle", "TextStyle") -TextStyle_ptr = TextStyle -LongPt = OpaqueType("LongPt", "LongPt") -LongPt_ptr = LongPt -LongRect = OpaqueType("LongRect", "LongRect") -LongRect_ptr = LongRect - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ -#include - -/* Exported by Qdmodule.c: */ -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); - -/* Forward declaration */ -staticforward PyObject *WEOObj_New(WEObjectReference); -staticforward PyObject *ExistingwasteObj_New(WEReference); - -/* -** Parse/generate TextStyle records -*/ -static -PyObject *TextStyle_New(itself) - TextStylePtr itself; -{ - - return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, - &itself->tsColor); -} - -static -TextStyle_Convert(v, p_itself) - PyObject *v; - TextStylePtr p_itself; -{ - long font, face, size; - - if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) - return 0; - p_itself->tsFont = (short)font; - p_itself->tsFace = (Style)face; - p_itself->tsSize = (short)size; - return 1; -} - -/* -** Parse/generate RunInfo records -*/ -static -PyObject *RunInfo_New(itself) - WERunInfo *itself; -{ - - return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight, - itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject); -} - -/* Conversion of long points and rects */ -int -LongRect_Convert(PyObject *v, LongRect *r) -{ - return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom); -} - -PyObject * -LongRect_New(LongRect *r) -{ - return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom); -} - - -LongPt_Convert(PyObject *v, LongPt *p) -{ - return PyArg_Parse(v, "(ll)", &p->h, &p->v); -} - -PyObject * -LongPt_New(LongPt *p) -{ - return Py_BuildValue("(ll)", p->h, p->v); -} - -/* Stuff for the callbacks: */ -static PyObject *callbackdict; -WENewObjectUPP upp_new_handler; -WEDisposeObjectUPP upp_dispose_handler; -WEDrawObjectUPP upp_draw_handler; -WEClickObjectUPP upp_click_handler; - -static OSErr -any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv) -{ - FlavorType tp; - PyObject *key, *func; - - if ( args == NULL ) return errAECorruptData; - - tp = WEGetObjectType(who); - - if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL) - return errAECorruptData; - if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) { - Py_DECREF(key); - return errAEHandlerNotFound; - } - Py_INCREF(func); - *rv = PyEval_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(key); - if ( *rv == NULL ) { - fprintf(stderr, "--Exception in callback: "); - PyErr_Print(); - return errAEReplyNotArrived; - } - return 0; -} - -static pascal OSErr -my_new_handler(Point *objectSize, WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("(O&)", WEOObj_New, objref); - err = any_handler(weNewHandler, objref, args, &rv); - if (!err) { - if (!PyMac_GetPoint(rv, objectSize) ) - err = errAECoercionFail; - } - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return err; -} - -static pascal OSErr -my_dispose_handler(WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("(O&)", WEOObj_New, objref); - err = any_handler(weDisposeHandler, objref, args, &rv); - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return err; -} - -static pascal OSErr -my_draw_handler(Rect *destRect, WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref); - err = any_handler(weDrawHandler, objref, args, &rv); - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return err; -} - -static pascal Boolean -my_click_handler(Point hitPt, EventModifiers modifiers, - unsigned long clickTime, WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - int retvalue; - OSErr err; - - args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt, - (long)modifiers, (long)clickTime, WEOObj_New, objref); - err = any_handler(weClickHandler, objref, args, &rv); - if (!err) - retvalue = PyInt_AsLong(rv); - else - retvalue = 0; - if ( args ) Py_DECREF(args); - if ( rv ) Py_DECREF(rv); - return retvalue; -} - - -""" -finalstuff = finalstuff + """ -/* Return the object corresponding to the window, or NULL */ - -PyObject * -ExistingwasteObj_New(w) - WEReference w; -{ - PyObject *it = NULL; - - if (w == NULL) - it = NULL; - else - WEGetInfo(weRefCon, (void *)&it, w); - if (it == NULL || ((wasteObject *)it)->ob_itself != w) - it = Py_None; - Py_INCREF(it); - return it; -} -""" - -class WEMethodGenerator(OSErrMethodGenerator): - """Similar to MethodGenerator, but has self as last argument""" - - def parseArgumentList(self, args): - args, a0 = args[:-1], args[-1] - t0, n0, m0 = a0 - if m0 != InMode: - raise ValueError, "method's 'self' must be 'InMode'" - self.itself = Variable(t0, "_self->ob_itself", SelfMode) - FunctionGenerator.parseArgumentList(self, args) - self.argumentList.append(self.itself) - - - -class WEObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(waste_Error,"Cannot create null WE"); - return NULL; - }""") - def outputInitStructMembers(self): - GlobalObjectDefinition.outputInitStructMembers(self) - Output("WESetInfo(weRefCon, (void *)&it, itself);") - def outputFreeIt(self, itselfname): - Output("WEDispose(%s);", itselfname) - -class WEOObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - Py_INCREF(Py_None); - return Py_None; - }""") - -variablestuff = """ - callbackdict = PyDict_New(); - if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0) - Py_FatalError("can't initialize Waste.callbackdict"); - upp_new_handler = NewWENewObjectProc(my_new_handler); - upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler); - upp_draw_handler = NewWEDrawObjectProc(my_draw_handler); - upp_click_handler = NewWEClickObjectProc(my_click_handler); -""" - - -# From here on it's basically all boiler plate... - -# Test types used for existence -## execfile(TYPETESTFILE) - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff) -object = WEObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -object2 = WEOObjectDefinition("WEO", "WEOObj", "WEObjectReference") -module.addobject(object2) -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = WEMethodGenerator -Method2 = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -methods2 = [] -execfile(INPUTFILE) - -# A function written by hand: -stdhandlers_body = """ - OSErr err; - // install the sample object handlers for pictures and sounds -#define kTypePicture 'PICT' -#define kTypeSound 'snd ' - - if ( !PyArg_ParseTuple(_args, "") ) return NULL; - - if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler, - (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler, - (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler, - (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler, - (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler, - (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler, - (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr) - goto cleanup; - Py_INCREF(Py_None); - return Py_None; - -cleanup: - return PyMac_Error(err); -""" - -inshandler_body = """ - OSErr err; - FlavorType objectType; - WESelector selector; - PyObject *py_handler; - UniversalProcPtr handler; - WEReference we = NULL; - PyObject *key; - - - if ( !PyArg_ParseTuple(_args, "O&O&O|O&", - PyMac_GetOSType, &objectType, - PyMac_GetOSType, &selector, - &py_handler, - ExistingwasteObj_New, &we) ) return NULL; - - if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler; - else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler; - else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler; - else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler; - else return PyMac_Error(weUndefinedSelectorErr); - - if ((key = Py_BuildValue("O&O&", - PyMac_BuildOSType, objectType, - PyMac_BuildOSType, selector)) == NULL ) - return NULL; - - PyDict_SetItem(callbackdict, key, py_handler); - - err = WEInstallObjectHandler(objectType, selector, handler, we); - if ( err ) return PyMac_Error(err); - Py_INCREF(Py_None); - return Py_None; -""" - -stdhand = ManualGenerator("STDObjectHandlers", stdhandlers_body) -inshand = ManualGenerator("WEInstallObjectHandler", inshandler_body) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -module.add(stdhand) -module.add(inshand) -for f in methods: object.add(f) -for f in methods2: object2.add(f) - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() - diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c deleted file mode 100644 index afac85f321..0000000000 --- a/Mac/Modules/win/Winmodule.c +++ /dev/null @@ -1,1354 +0,0 @@ - -/* =========================== Module Win =========================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include -#include -#include -#include - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -#ifdef HAVE_UNIVERSAL_HEADERS -#define WindowPeek WindowPtr -#endif - -static PyObject *Win_Error; - -/* ----------------------- Object type Window ----------------------- */ - -PyTypeObject Window_Type; - -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -typedef struct WindowObject { - PyObject_HEAD - WindowPtr ob_itself; -} WindowObject; - -PyObject *WinObj_New(itself) - WindowPtr itself; -{ - WindowObject *it; - if (itself == NULL) return PyMac_Error(resNotFound); - it = PyObject_NEW(WindowObject, &Window_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - SetWRefCon(itself, (long)it); - return (PyObject *)it; -} -WinObj_Convert(v, p_itself) - PyObject *v; - WindowPtr *p_itself; -{ - if (DlgObj_Check(v)) { - *p_itself = ((WindowObject *)v)->ob_itself; - return 1; - } - - if (v == Py_None) { *p_itself = NULL; return 1; } - if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } - - if (!WinObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "Window required"); - return 0; - } - *p_itself = ((WindowObject *)v)->ob_itself; - return 1; -} - -static void WinObj_dealloc(self) - WindowObject *self; -{ - DisposeWindow(self->ob_itself); - PyMem_DEL(self); -} - -static PyObject *WinObj_GetWTitle(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 title; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetWTitle(_self->ob_itself, - title); - _res = Py_BuildValue("O&", - PyMac_BuildStr255, title); - return _res; -} - -static PyObject *WinObj_SelectWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - SelectWindow(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_HideWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HideWindow(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_ShowWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ShowWindow(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_ShowHide(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean showFlag; - if (!PyArg_ParseTuple(_args, "b", - &showFlag)) - return NULL; - ShowHide(_self->ob_itself, - showFlag); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_HiliteWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean fHilite; - if (!PyArg_ParseTuple(_args, "b", - &fHilite)) - return NULL; - HiliteWindow(_self->ob_itself, - fHilite); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_BringToFront(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - BringToFront(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_SendBehind(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr behindWindow; - if (!PyArg_ParseTuple(_args, "O&", - WinObj_Convert, &behindWindow)) - return NULL; - SendBehind(_self->ob_itself, - behindWindow); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_DrawGrowIcon(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - DrawGrowIcon(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_MoveWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short hGlobal; - short vGlobal; - Boolean front; - if (!PyArg_ParseTuple(_args, "hhb", - &hGlobal, - &vGlobal, - &front)) - return NULL; - MoveWindow(_self->ob_itself, - hGlobal, - vGlobal, - front); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_SizeWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short w; - short h; - Boolean fUpdate; - if (!PyArg_ParseTuple(_args, "hhb", - &w, - &h, - &fUpdate)) - return NULL; - SizeWindow(_self->ob_itself, - w, - h, - fUpdate); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_ZoomWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short partCode; - Boolean front; - if (!PyArg_ParseTuple(_args, "hb", - &partCode, - &front)) - return NULL; - ZoomWindow(_self->ob_itself, - partCode, - front); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_BeginUpdate(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - BeginUpdate(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_EndUpdate(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - EndUpdate(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_SetWRefCon(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long data; - if (!PyArg_ParseTuple(_args, "l", - &data)) - return NULL; - SetWRefCon(_self->ob_itself, - data); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GetWRefCon(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWRefCon(_self->ob_itself); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *WinObj_SetWindowPic(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle pic; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pic)) - return NULL; - SetWindowPic(_self->ob_itself, - pic); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GetWindowPic(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - PicHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWindowPic(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *WinObj_ClipAbove(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - ClipAbove(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_SaveOld(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - SaveOld(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_DrawNew(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean update; - if (!PyArg_ParseTuple(_args, "b", - &update)) - return NULL; - DrawNew(_self->ob_itself, - update); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_PaintOne(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle clobberedRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &clobberedRgn)) - return NULL; - PaintOne(_self->ob_itself, - clobberedRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_PaintBehind(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle clobberedRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &clobberedRgn)) - return NULL; - PaintBehind(_self->ob_itself, - clobberedRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_CalcVis(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - CalcVis(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_CalcVisBehind(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle clobberedRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &clobberedRgn)) - return NULL; - CalcVisBehind(_self->ob_itself, - clobberedRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GrowWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - Point startPt; - Rect bBox; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &startPt, - PyMac_GetRect, &bBox)) - return NULL; - _rv = GrowWindow(_self->ob_itself, - startPt, - &bBox); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *WinObj_TrackBox(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point thePt; - short partCode; - if (!PyArg_ParseTuple(_args, "O&h", - PyMac_GetPoint, &thePt, - &partCode)) - return NULL; - _rv = TrackBox(_self->ob_itself, - thePt, - partCode); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *WinObj_GetWVariant(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWVariant(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *WinObj_SetWTitle(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Str255 title; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, title)) - return NULL; - SetWTitle(_self->ob_itself, - title); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_TrackGoAway(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - Point thePt; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &thePt)) - return NULL; - _rv = TrackGoAway(_self->ob_itself, - thePt); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *WinObj_DragWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Point startPt; - Rect boundsRect; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &startPt, - PyMac_GetRect, &boundsRect)) - return NULL; - DragWindow(_self->ob_itself, - startPt, - &boundsRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GetWindowPort(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - CGrafPtr _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWindowPort(_self->ob_itself); - _res = Py_BuildValue("O&", - GrafObj_New, _rv); - return _res; -} - -static PyObject *WinObj_SetPortWindowPort(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - SetPortWindowPort(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GetWindowKind(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWindowKind(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *WinObj_SetWindowKind(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short wKind; - if (!PyArg_ParseTuple(_args, "h", - &wKind)) - return NULL; - SetWindowKind(_self->ob_itself, - wKind); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_IsWindowVisible(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = IsWindowVisible(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *WinObj_IsWindowHilited(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = IsWindowHilited(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWindowGoAwayFlag(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *WinObj_GetWindowZoomFlag(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWindowZoomFlag(_self->ob_itself); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *WinObj_GetWindowStructureRgn(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle r; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &r)) - return NULL; - GetWindowStructureRgn(_self->ob_itself, - r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GetWindowContentRgn(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle r; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &r)) - return NULL; - GetWindowContentRgn(_self->ob_itself, - r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GetWindowUpdateRgn(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle r; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &r)) - return NULL; - GetWindowUpdateRgn(_self->ob_itself, - r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_GetWindowTitleWidth(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWindowTitleWidth(_self->ob_itself); - _res = Py_BuildValue("h", - _rv); - return _res; -} - -static PyObject *WinObj_GetNextWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetNextWindow(_self->ob_itself); - _res = Py_BuildValue("O&", - WinObj_WhichWindow, _rv); - return _res; -} - -static PyObject *WinObj_GetWindowStandardState(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetWindowStandardState(_self->ob_itself, - &r); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); - return _res; -} - -static PyObject *WinObj_GetWindowUserState(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetWindowUserState(_self->ob_itself, - &r); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); - return _res; -} - -static PyObject *WinObj_SetWindowStandardState(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - SetWindowStandardState(_self->ob_itself, - &r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *WinObj_SetWindowUserState(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect r; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) - return NULL; - SetWindowUserState(_self->ob_itself, - &r); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef WinObj_methods[] = { - {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1, - "() -> (Str255 title)"}, - {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1, - "() -> None"}, - {"HideWindow", (PyCFunction)WinObj_HideWindow, 1, - "() -> None"}, - {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1, - "() -> None"}, - {"ShowHide", (PyCFunction)WinObj_ShowHide, 1, - "(Boolean showFlag) -> None"}, - {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1, - "(Boolean fHilite) -> None"}, - {"BringToFront", (PyCFunction)WinObj_BringToFront, 1, - "() -> None"}, - {"SendBehind", (PyCFunction)WinObj_SendBehind, 1, - "(WindowPtr behindWindow) -> None"}, - {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1, - "() -> None"}, - {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1, - "(short hGlobal, short vGlobal, Boolean front) -> None"}, - {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1, - "(short w, short h, Boolean fUpdate) -> None"}, - {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1, - "(short partCode, Boolean front) -> None"}, - {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1, - "() -> None"}, - {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1, - "() -> None"}, - {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1, - "(long data) -> None"}, - {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1, - "() -> (long _rv)"}, - {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1, - "(PicHandle pic) -> None"}, - {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1, - "() -> (PicHandle _rv)"}, - {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1, - "() -> None"}, - {"SaveOld", (PyCFunction)WinObj_SaveOld, 1, - "() -> None"}, - {"DrawNew", (PyCFunction)WinObj_DrawNew, 1, - "(Boolean update) -> None"}, - {"PaintOne", (PyCFunction)WinObj_PaintOne, 1, - "(RgnHandle clobberedRgn) -> None"}, - {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1, - "(RgnHandle clobberedRgn) -> None"}, - {"CalcVis", (PyCFunction)WinObj_CalcVis, 1, - "() -> None"}, - {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1, - "(RgnHandle clobberedRgn) -> None"}, - {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1, - "(Point startPt, Rect bBox) -> (long _rv)"}, - {"TrackBox", (PyCFunction)WinObj_TrackBox, 1, - "(Point thePt, short partCode) -> (Boolean _rv)"}, - {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1, - "() -> (short _rv)"}, - {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1, - "(Str255 title) -> None"}, - {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1, - "(Point thePt) -> (Boolean _rv)"}, - {"DragWindow", (PyCFunction)WinObj_DragWindow, 1, - "(Point startPt, Rect boundsRect) -> None"}, - {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1, - "() -> (CGrafPtr _rv)"}, - {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1, - "() -> None"}, - {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1, - "() -> (short _rv)"}, - {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1, - "(short wKind) -> None"}, - {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1, - "() -> (Boolean _rv)"}, - {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1, - "() -> (Boolean _rv)"}, - {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1, - "() -> (Boolean _rv)"}, - {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1, - "() -> (Boolean _rv)"}, - {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1, - "(RgnHandle r) -> None"}, - {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1, - "(RgnHandle r) -> None"}, - {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1, - "(RgnHandle r) -> None"}, - {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1, - "() -> (short _rv)"}, - {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1, - "() -> (WindowPtr _rv)"}, - {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1, - "() -> (Rect r)"}, - {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1, - "() -> (Rect r)"}, - {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1, - "(Rect r) -> None"}, - {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1, - "(Rect r) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain WinObj_chain = { WinObj_methods, NULL }; - -static PyObject *WinObj_getattr(self, name) - WindowObject *self; - char *name; -{ - return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name); -} - -#define WinObj_setattr NULL - -PyTypeObject Window_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "Window", /*tp_name*/ - sizeof(WindowObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) WinObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) WinObj_getattr, /*tp_getattr*/ - (setattrfunc) WinObj_setattr, /*tp_setattr*/ -}; - -/* --------------------- End object type Window --------------------- */ - - -static PyObject *Win_GetGrayRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetGrayRgn(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Win_InitWindows(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - InitWindows(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Win_GetWMgrPort(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - GrafPtr wPort; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetWMgrPort(&wPort); - _res = Py_BuildValue("O&", - GrafObj_New, wPort); - return _res; -} - -static PyObject *Win_NewWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr _rv; - Rect boundsRect; - Str255 title; - Boolean visible; - short theProc; - WindowPtr behind; - Boolean goAwayFlag; - long refCon; - if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", - PyMac_GetRect, &boundsRect, - PyMac_GetStr255, title, - &visible, - &theProc, - WinObj_Convert, &behind, - &goAwayFlag, - &refCon)) - return NULL; - _rv = NewWindow((void *)0, - &boundsRect, - title, - visible, - theProc, - behind, - goAwayFlag, - refCon); - _res = Py_BuildValue("O&", - WinObj_New, _rv); - return _res; -} - -static PyObject *Win_GetNewWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr _rv; - short windowID; - WindowPtr behind; - if (!PyArg_ParseTuple(_args, "hO&", - &windowID, - WinObj_Convert, &behind)) - return NULL; - _rv = GetNewWindow(windowID, - (void *)0, - behind); - _res = Py_BuildValue("O&", - WinObj_New, _rv); - return _res; -} - -static PyObject *Win_FrontWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = FrontWindow(); - _res = Py_BuildValue("O&", - WinObj_WhichWindow, _rv); - return _res; -} - -static PyObject *Win_InvalRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect badRect; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &badRect)) - return NULL; - InvalRect(&badRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Win_InvalRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle badRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &badRgn)) - return NULL; - InvalRgn(badRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Win_ValidRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Rect goodRect; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &goodRect)) - return NULL; - ValidRect(&goodRect); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Win_ValidRgn(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - RgnHandle goodRgn; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &goodRgn)) - return NULL; - ValidRgn(goodRgn); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Win_CheckUpdate(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventRecord theEvent; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = CheckUpdate(&theEvent); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildEventRecord, &theEvent); - return _res; -} - -static PyObject *Win_FindWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - short _rv; - Point thePoint; - WindowPtr theWindow; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &thePoint)) - return NULL; - _rv = FindWindow(thePoint, - &theWindow); - _res = Py_BuildValue("hO&", - _rv, - WinObj_WhichWindow, theWindow); - return _res; -} - -static PyObject *Win_PinRect(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - long _rv; - Rect theRect; - Point thePt; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &theRect, - PyMac_GetPoint, &thePt)) - return NULL; - _rv = PinRect(&theRect, - thePt); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Win_GetCWMgrPort(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - CGrafPtr wMgrCPort; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - GetCWMgrPort(&wMgrCPort); - _res = Py_BuildValue("O&", - GrafObj_New, wMgrCPort); - return _res; -} - -static PyObject *Win_NewCWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr _rv; - Rect boundsRect; - Str255 title; - Boolean visible; - short procID; - WindowPtr behind; - Boolean goAwayFlag; - long refCon; - if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", - PyMac_GetRect, &boundsRect, - PyMac_GetStr255, title, - &visible, - &procID, - WinObj_Convert, &behind, - &goAwayFlag, - &refCon)) - return NULL; - _rv = NewCWindow((void *)0, - &boundsRect, - title, - visible, - procID, - behind, - goAwayFlag, - refCon); - _res = Py_BuildValue("O&", - WinObj_New, _rv); - return _res; -} - -static PyObject *Win_GetNewCWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - WindowPtr _rv; - short windowID; - WindowPtr behind; - if (!PyArg_ParseTuple(_args, "hO&", - &windowID, - WinObj_Convert, &behind)) - return NULL; - _rv = GetNewCWindow(windowID, - (void *)0, - behind); - _res = Py_BuildValue("O&", - WinObj_New, _rv); - return _res; -} - -static PyObject *Win_WhichWindow(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - - long ptr; - - if ( !PyArg_ParseTuple(_args, "i", &ptr) ) - return NULL; - return WinObj_WhichWindow((WindowPtr)ptr); - -} - -static PyMethodDef Win_methods[] = { - {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1, - "() -> (RgnHandle _rv)"}, - {"InitWindows", (PyCFunction)Win_InitWindows, 1, - "() -> None"}, - {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1, - "() -> (GrafPtr wPort)"}, - {"NewWindow", (PyCFunction)Win_NewWindow, 1, - "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, - {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1, - "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, - {"FrontWindow", (PyCFunction)Win_FrontWindow, 1, - "() -> (WindowPtr _rv)"}, - {"InvalRect", (PyCFunction)Win_InvalRect, 1, - "(Rect badRect) -> None"}, - {"InvalRgn", (PyCFunction)Win_InvalRgn, 1, - "(RgnHandle badRgn) -> None"}, - {"ValidRect", (PyCFunction)Win_ValidRect, 1, - "(Rect goodRect) -> None"}, - {"ValidRgn", (PyCFunction)Win_ValidRgn, 1, - "(RgnHandle goodRgn) -> None"}, - {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1, - "() -> (Boolean _rv, EventRecord theEvent)"}, - {"FindWindow", (PyCFunction)Win_FindWindow, 1, - "(Point thePoint) -> (short _rv, WindowPtr theWindow)"}, - {"PinRect", (PyCFunction)Win_PinRect, 1, - "(Rect theRect, Point thePt) -> (long _rv)"}, - {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1, - "() -> (CGrafPtr wMgrCPort)"}, - {"NewCWindow", (PyCFunction)Win_NewCWindow, 1, - "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, - {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1, - "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, - {"WhichWindow", (PyCFunction)Win_WhichWindow, 1, - "Resolve an integer WindowPtr address to a Window object"}, - {NULL, NULL, 0} -}; - - - -/* Return the object corresponding to the window, or NULL */ - -PyObject * -WinObj_WhichWindow(w) - WindowPtr w; -{ - PyObject *it; - - /* XXX What if we find a stdwin window or a window belonging - to some other package? */ - if (w == NULL) - it = NULL; - else - it = (PyObject *) GetWRefCon(w); - if (it == NULL || ((WindowObject *)it)->ob_itself != w) - it = Py_None; - Py_INCREF(it); - return it; -} - - -void initWin() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("Win", Win_methods); - d = PyModule_GetDict(m); - Win_Error = PyMac_GetOSErrException(); - if (Win_Error == NULL || - PyDict_SetItemString(d, "Error", Win_Error) != 0) - Py_FatalError("can't initialize Win.Error"); -} - -/* ========================= End module Win ========================= */ - diff --git a/Mac/Modules/win/winedit.py b/Mac/Modules/win/winedit.py deleted file mode 100644 index a5812f1347..0000000000 --- a/Mac/Modules/win/winedit.py +++ /dev/null @@ -1,98 +0,0 @@ -# These are inline-routines/defines, so we do them "by hand" -# - -f = Method(CGrafPtr, 'GetWindowPort', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(void, 'SetPortWindowPort', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(short, 'GetWindowKind', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(void, 'SetWindowKind', - (WindowRef, 'theWindow', InMode), - (short, 'wKind', InMode), -) -methods.append(f) - - -f = Method(Boolean, 'IsWindowVisible', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(Boolean, 'IsWindowHilited', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(Boolean, 'GetWindowGoAwayFlag', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(Boolean, 'GetWindowZoomFlag', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(void, 'GetWindowStructureRgn', - (WindowRef, 'theWindow', InMode), - (RgnHandle, 'r', InMode), -) -methods.append(f) - -f = Method(void, 'GetWindowContentRgn', - (WindowRef, 'theWindow', InMode), - (RgnHandle, 'r', InMode), -) -methods.append(f) - -f = Method(void, 'GetWindowUpdateRgn', - (WindowRef, 'theWindow', InMode), - (RgnHandle, 'r', InMode), -) -methods.append(f) - -f = Method(short, 'GetWindowTitleWidth', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(ExistingWindowPtr, 'GetNextWindow', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) - -f = Method(void, 'GetWindowStandardState', - (WindowRef, 'theWindow', InMode), - (Rect, 'r', OutMode), -) -methods.append(f) - -f = Method(void, 'GetWindowUserState', - (WindowRef, 'theWindow', InMode), - (Rect, 'r', OutMode), -) -methods.append(f) - - -f = Method(void, 'SetWindowStandardState', - (WindowRef, 'theWindow', InMode), - (Rect, 'r', InMode), -) -methods.append(f) - -f = Method(void, 'SetWindowUserState', - (WindowRef, 'theWindow', InMode), - (Rect, 'r', InMode), -) -methods.append(f) - diff --git a/Mac/Modules/win/winscan.py b/Mac/Modules/win/winscan.py deleted file mode 100644 index 2d332ad162..0000000000 --- a/Mac/Modules/win/winscan.py +++ /dev/null @@ -1,76 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. -import addpack -addpack.addpack(':Tools:bgen:bgen') -from bgenlocations import TOOLBOXDIR - -from scantools import Scanner - -def main(): - input = "Windows.h" - output = "wingen.py" - defsoutput = TOOLBOXDIR + "Windows.py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Done scanning and generating, now importing the generated code... ===" - import winsupport - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - 'DisposeWindow', # Implied when the object is deleted - 'CloseWindow', - ] - - def makeblacklisttypes(self): - return [ - 'ProcPtr', - 'WCTabHandle', - 'AuxWinHandle', - 'PixPatHandle', - 'DragGrayRgnUPP', - ] - - def makerepairinstructions(self): - return [ - - # GetWTitle - ([("Str255", "*", "InMode")], - [("*", "*", "OutMode")]), - - ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], - [("InBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("long", "*", "InMode"), - ("long", "*", "OutMode")], - [("VarVarOutBuffer", "*", "InOutMode")]), - - ([("void", "wStorage", "OutMode")], - [("NullStorage", "*", "InMode")]), - - ([("WindowPtr", "*", "OutMode")], - [("ExistingWindowPtr", "*", "*")]), - ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles - [("ExistingWindowPtr", "*", "*")]), - - ([("WindowPtr", "FrontWindow", "ReturnMode")], - [("ExistingWindowPtr", "*", "*")]), - ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto - [("ExistingWindowPtr", "*", "*")]), - ] - -if __name__ == "__main__": - main() - diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py deleted file mode 100644 index 9aed179a80..0000000000 --- a/Mac/Modules/win/winsupport.py +++ /dev/null @@ -1,132 +0,0 @@ -# This script generates a Python interface for an Apple Macintosh Manager. -# It uses the "bgen" package to generate C code. -# The function specifications are generated by scanning the mamager's header file, -# using the "scantools" package (customized for this particular manager). - -import string - -import addpack -addpack.addpack(':Tools:bgen:bgen') - -# Declarations that change for each manager -MACHEADERFILE = 'Windows.h' # The Apple header file -MODNAME = 'Win' # The name of the module -OBJECTNAME = 'Window' # The basic name of the objects used here - -# The following is *usually* unchanged but may still require tuning -MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods -INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -EDITFILE = string.lower(MODPREFIX) + 'edit.py' # The manual definitions -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program - -from macsupport import * - -# Create the type objects - -WindowPtr = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) -WindowRef = WindowPtr -WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX) -WindowPeek.passInput = lambda name: "(WindowPeek)(%s)" % name -CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj") -GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj") - -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") -PicHandle = OpaqueByValueType("PicHandle", "ResObj") - -includestuff = includestuff + """ -#include <%s>""" % MACHEADERFILE + """ - -#define resNotFound -192 /* Can't include because of Python's "errors.h" */ - -#ifdef HAVE_UNIVERSAL_HEADERS -#define WindowPeek WindowPtr -#endif -""" - -finalstuff = finalstuff + """ -/* Return the object corresponding to the window, or NULL */ - -PyObject * -WinObj_WhichWindow(w) - WindowPtr w; -{ - PyObject *it; - - /* XXX What if we find a stdwin window or a window belonging - to some other package? */ - if (w == NULL) - it = NULL; - else - it = (PyObject *) GetWRefCon(w); - if (it == NULL || ((WindowObject *)it)->ob_itself != w) - it = Py_None; - Py_INCREF(it); - return it; -} -""" - -class MyObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("if (itself == NULL) return PyMac_Error(resNotFound);") - def outputInitStructMembers(self): - GlobalObjectDefinition.outputInitStructMembers(self) - Output("SetWRefCon(itself, (long)it);") - def outputCheckConvertArg(self): - OutLbrace("if (DlgObj_Check(v))") - Output("*p_itself = ((WindowObject *)v)->ob_itself;") - Output("return 1;") - OutRbrace() - Out(""" - if (v == Py_None) { *p_itself = NULL; return 1; } - if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } - """) - def outputFreeIt(self, itselfname): - Output("DisposeWindow(%s);", itselfname) -# From here on it's basically all boiler plate... - -# Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile(INPUTFILE) - -# Add a manual routine for converting integer WindowPtr's (as returned by -# various event routines) to a WindowObject. -whichwin_body = """ -long ptr; - -if ( !PyArg_ParseTuple(_args, "i", &ptr) ) - return NULL; -return WinObj_WhichWindow((WindowPtr)ptr); -""" - -f = ManualGenerator("WhichWindow", whichwin_body) -f.docstring = lambda : "Resolve an integer WindowPtr address to a Window object" - -functions.append(f) - -# And add the routines that access the internal bits of a window struct. They -# are currently #defined in Windows.h, they will be real routines in Copland -# (at which time this execfile can go) -execfile(EDITFILE) - -# add the populated lists to the generator groups -# (in a different wordl the scan program would generate this) -for f in functions: module.add(f) -for f in methods: object.add(f) - - - -# generate output (open the output file as late as possible) -SetOutputFileName(OUTPUTFILE) -module.generate() diff --git a/Mac/Python/macapplet.c b/Mac/Python/macapplet.c deleted file mode 100644 index 55e635fe05..0000000000 --- a/Mac/Python/macapplet.c +++ /dev/null @@ -1,36 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Macintosh Applet Python main program */ - -#ifdef __CFM68K__ -#pragma lib_export on -#endif - -extern void PyMac_InitApplet(); - -void -main() { - PyMac_InitApplet(); -} diff --git a/Mac/Python/macapplication.c b/Mac/Python/macapplication.c deleted file mode 100644 index 5532345da2..0000000000 --- a/Mac/Python/macapplication.c +++ /dev/null @@ -1,36 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Macintosh Applet Python main program */ - -#ifdef SYMANTEC__CFM68K__ -#pragma lib_export on -#endif - -extern void PyMac_InitApplication(); - -void -main() { - PyMac_InitApplication(); -} diff --git a/Mac/Python/macgetargv.c b/Mac/Python/macgetargv.c deleted file mode 100644 index a06b100f8b..0000000000 --- a/Mac/Python/macgetargv.c +++ /dev/null @@ -1,313 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Construct argc and argv for main() by using Apple Events */ -/* From Jack's implementation for STDWIN */ - -#include - -#ifndef SystemSevenOrLater -#define SystemSevenOrLater 1 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef GENERATINGCFM /* Defined to 0 or 1 in Universal headers */ -#define HAVE_UNIVERSAL_HEADERS -#endif - -#ifdef SYMANTEC__CFM68K__ -#pragma lib_export on -#endif - -#ifndef HAVE_UNIVERSAL_HEADERS -#define NewAEEventHandlerProc(x) (x) -#define AEEventHandlerUPP EventHandlerProcPtr -#endif - -static int arg_count; -static char *arg_vector[256]; - -/* Duplicate a string to the heap. We also export this since it isn't standard -** and others use it -*/ - -char * -strdup(char *src) -{ - char *dst = malloc(strlen(src) + 1); - if (dst) - strcpy(dst, src); - return dst; -} - -/* Return FSSpec of current application */ - -OSErr -PyMac_process_location(FSSpec *applicationSpec) -{ - ProcessSerialNumber currentPSN; - ProcessInfoRec info; - - currentPSN.highLongOfPSN = 0; - currentPSN.lowLongOfPSN = kCurrentProcess; - info.processInfoLength = sizeof(ProcessInfoRec); - info.processName = NULL; - info.processAppSpec = applicationSpec; - return GetProcessInformation(¤tPSN, &info); -} - -/* Given an FSSpec, return the FSSpec of the parent folder */ - -static OSErr -get_folder_parent (FSSpec * fss, FSSpec * parent) -{ - CInfoPBRec rec; - short err; - - * parent = * fss; - rec.hFileInfo.ioNamePtr = parent->name; - rec.hFileInfo.ioVRefNum = parent->vRefNum; - rec.hFileInfo.ioDirID = parent->parID; - rec.hFileInfo.ioFDirIndex = -1; - rec.hFileInfo.ioFVersNum = 0; - if (err = PBGetCatInfoSync (& rec)) - return err; - parent->parID = rec.dirInfo.ioDrParID; -/* parent->name[0] = 0; */ - return 0; -} - -/* Given an FSSpec return a full, colon-separated pathname */ - -static OSErr -get_full_path (FSSpec *fss, char *buf) -{ - short err; - FSSpec fss_parent, fss_current; - char tmpbuf[256]; - int plen; - - fss_current = *fss; - plen = fss_current.name[0]; - memcpy(buf, &fss_current.name[1], plen); - buf[plen] = 0; - while (fss_current.parID > 1) { - /* Get parent folder name */ - if (err = get_folder_parent(&fss_current, &fss_parent)) - return err; - fss_current = fss_parent; - /* Prepend path component just found to buf */ - plen = fss_current.name[0]; - if (strlen(buf) + plen + 1 > 256) { - /* Oops... Not enough space (shouldn't happen) */ - *buf = 0; - return -1; - } - memcpy(tmpbuf, &fss_current.name[1], plen); - tmpbuf[plen] = ':'; - strcpy(&tmpbuf[plen+1], buf); - strcpy(buf, tmpbuf); - } - return 0; -} - -/* Return the full program name */ - -static char * -get_application_name() -{ - static char appname[256]; - FSSpec appspec; - - if (PyMac_process_location(&appspec)) - return NULL; - if (get_full_path(&appspec, appname)) - return NULL; - return appname; -} - -/* Check that there aren't any args remaining in the event */ - -static OSErr -get_missing_params(AppleEvent *theAppleEvent) -{ - DescType theType; - Size actualSize; - OSErr err; - - err = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard, - &theType, nil, 0, &actualSize); - if (err == errAEDescNotFound) - return noErr; - else - return errAEEventNotHandled; -} - -static int got_one; /* Flag that we can stop getting events */ - -/* Handle the Print or Quit events (by failing) */ - -static pascal OSErr -handle_not(AppleEvent *theAppleEvent, AppleEvent *reply, long refCon) -{ - #pragma unused (reply, refCon) - got_one = 1; - return errAEEventNotHandled; -} - -/* Handle the Open Application event (by ignoring it) */ - -static pascal OSErr -handle_open_app(AppleEvent *theAppleEvent, AppleEvent *reply, long refCon) -{ - #pragma unused (reply, refCon) -#if 0 - /* Test by Jack: would removing this facilitate debugging? */ - got_one = 1; -#endif - return get_missing_params(theAppleEvent); -} - -/* Handle the Open Document event, by adding an argument */ - -static pascal OSErr -handle_open_doc(AppleEvent *theAppleEvent, AppleEvent *reply, long refCon) -{ - #pragma unused (reply, refCon) - OSErr err; - AEDescList doclist; - AEKeyword keywd; - DescType rttype; - long i, ndocs, size; - FSSpec fss; - char path[256]; - - got_one = 1; - if (err = AEGetParamDesc(theAppleEvent, - keyDirectObject, typeAEList, &doclist)) - return err; - if (err = get_missing_params(theAppleEvent)) - return err; - if (err = AECountItems(&doclist, &ndocs)) - return err; - for(i = 1; i <= ndocs; i++) { - err = AEGetNthPtr(&doclist, i, typeFSS, - &keywd, &rttype, &fss, sizeof(fss), &size); - if (err) - break; - get_full_path(&fss, path); - arg_vector[arg_count++] = strdup(path); - } - return err; -} - -/* Install standard core event handlers */ -AEEventHandlerUPP open_doc_upp; -AEEventHandlerUPP open_app_upp; -AEEventHandlerUPP not_upp; - -static void -set_ae_handlers() -{ - open_doc_upp = NewAEEventHandlerProc(handle_open_doc); - open_app_upp = NewAEEventHandlerProc(handle_open_app); - not_upp = NewAEEventHandlerProc(handle_not); - - AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, - open_app_upp, 0L, false); - AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, - open_doc_upp, 0L, false); - AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, - not_upp, 0L, false); - AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, - not_upp, 0L, false); -} - -/* Uninstall standard core event handlers */ - -static void -reset_ae_handlers() -{ - AERemoveEventHandler(kCoreEventClass, kAEOpenApplication, - open_app_upp, false); - AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, - open_doc_upp, false); - AERemoveEventHandler(kCoreEventClass, kAEPrintDocuments, - not_upp, false); - AERemoveEventHandler(kCoreEventClass, kAEQuitApplication, - not_upp, false); -} - -/* Wait for events until a core event has been handled */ - -static void -event_loop() -{ - EventRecord event; - int n; - int ok; - - got_one = 0; - for (n = 0; n < 100 && !got_one; n++) { - SystemTask(); - ok = GetNextEvent(everyEvent, &event); - if (ok && event.what == kHighLevelEvent) { - AEProcessAppleEvent(&event); - } - } -} - -/* Get the argv vector, return argc */ - -int -PyMac_GetArgv(pargv) - char ***pargv; -{ - - arg_count = 0; - arg_vector[arg_count++] = strdup(get_application_name()); - - set_ae_handlers(); - event_loop(); - reset_ae_handlers(); - - arg_vector[arg_count] = NULL; - - *pargv = arg_vector; - return arg_count; -} diff --git a/Mac/Python/macgetcompiler.c b/Mac/Python/macgetcompiler.c deleted file mode 100644 index 999e74a9c6..0000000000 --- a/Mac/Python/macgetcompiler.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Return a string representing the compiler name */ - -#include "config.h" - -#ifdef THINK_C -#define COMPILER " [THINK C]" -#endif - -#ifdef __MWERKS__ -#ifdef USE_GUSI -#define HASGUSI " w/GUSI" -#else -#define HASGUSI "" -#endif -#ifdef __powerc -#define COMPILER " [CW PPC" HASGUSI "]" -#else -#ifdef __CFM68K__ -#define COMPILER " [CW CFM68K" HASGUSI "]" -#else -#define COMPILER " [CW 68K" HASGUSI "]" -#endif -#endif -#endif - -#ifdef MPW -#ifdef __SC__ -#define COMPILER " [Symantec MPW]" -#else -#define COMPILER " [Apple MPW]" -#endif -#endif - -char * -Py_GetCompiler() -{ - return COMPILER; -} diff --git a/Mac/Python/macgetmtime.c b/Mac/Python/macgetmtime.c deleted file mode 100644 index aeb1e70dbd..0000000000 --- a/Mac/Python/macgetmtime.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "macstat.h" -#include "rename2.h" - -/* Interfaced used by import.c */ - -long -getmtime(path) - char *path; -{ - struct macstat st; - if (macstat(path, &st) != 0) - return -1L; - return st.st_mtime; -} diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c deleted file mode 100644 index 40dd6c10d6..0000000000 --- a/Mac/Python/macgetpath.c +++ /dev/null @@ -1,340 +0,0 @@ -#include "Python.h" -#include "osdefs.h" - -#include "pythonresources.h" - - -/* Return the initial python search path. This is called once from -** initsys() to initialize sys.path. -** -** If USE_BUILTIN_PATH is defined the path defined here is used -** (after prepending the python home dir to each item). -** If it is not defined the path is gotten from a resource in the -** Preferences file. -** -** XXXX This code needs cleaning up. The routines here have moved -** around quite a bit, and they're pretty messy for that reason. -*/ - -#include -#include -#include -#include -#include -#include - -#define PYTHONPATH "\ -:\n\ -:Lib\n\ -:Lib:stdwin\n\ -:Lib:test\n\ -:Lib:mac" - - -char * -Py_GetPath() -{ - /* Modified by Jack to do something a bit more sensible: - ** - Prepend the python home-directory (which is obtained from a Preferences - ** resource) - ** - Add : - */ - static char *pythonpath; - char *curwd; - char *p, *endp; - int newlen; - staticforward char *PyMac_GetPythonDir(); -#ifndef USE_BUILTIN_PATH - staticforward char *PyMac_GetPythonPath(); -#endif - - if ( pythonpath ) return pythonpath; - curwd = PyMac_GetPythonDir(); -#ifndef USE_BUILTIN_PATH - if ( pythonpath = PyMac_GetPythonPath(curwd) ) - return pythonpath; - printf("Warning: No pythonpath resource found, using builtin default\n"); -#endif - p = PYTHONPATH; - endp = p; - pythonpath = malloc(2); - if ( pythonpath == NULL ) return PYTHONPATH; - strcpy(pythonpath, ":"); - while (*endp) { - endp = strchr(p, '\n'); - if ( endp == NULL ) - endp = p + strlen(p); - newlen = strlen(pythonpath) + 1 + strlen(curwd) + (endp-p); - pythonpath = realloc(pythonpath, newlen+1); - if ( pythonpath == NULL ) return PYTHONPATH; - strcat(pythonpath, "\n"); - if ( *p == ':' ) { - p++; - strcat(pythonpath, curwd); - strncat(pythonpath, p, (endp-p)); - newlen--; /* Ok, ok, we've allocated one byte too much */ - } else { - /* We've allocated too much in this case */ - newlen -= strlen(curwd); - pythonpath = realloc(pythonpath, newlen+1); - if ( pythonpath == NULL ) return PYTHONPATH; - strncat(pythonpath, p, (endp-p)); - } - pythonpath[newlen] = '\0'; - p = endp + 1; - } - return pythonpath; -} - -/* -** Open/create the Python Preferences file, return the handle -*/ -static short -PyMac_OpenPrefFile() -{ - AliasHandle handle; - FSSpec dirspec; - short prefrh; - short prefdirRefNum; - long prefdirDirID; - short action; - OSErr err; - - if ( FindFolder(kOnSystemDisk, 'pref', kDontCreateFolder, &prefdirRefNum, - &prefdirDirID) != noErr ) { - /* Something wrong with preferences folder */ - (void)StopAlert(NOPREFDIR_ID, NULL); - exit(1); - } - - (void)FSMakeFSSpec(prefdirRefNum, prefdirDirID, "\pPython Preferences", &dirspec); - prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); - if ( prefrh < 0 ) { - action = CautionAlert(NOPREFFILE_ID, NULL); - if ( action == NOPREFFILE_NO ) - exit(1); - - FSpCreateResFile(&dirspec, 'Pyth', 'pref', 0); - prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); - if ( prefrh == -1 ) { - /* This "cannot happen":-) */ - printf("Cannot create preferences file, error %d\n", ResError()); - exit(1); - } - if ( (err=PyMac_process_location(&dirspec)) != 0 ) { - printf("Cannot get FSSpec for application, error %d\n", err); - exit(1); - } - dirspec.name[0] = 0; - if ((err=NewAlias(NULL, &dirspec, &handle)) != 0 ) { - printf("Cannot make alias to application directory, error %d\n", err); - exit(1); - } - AddResource((Handle)handle, 'alis', PYTHONHOME_ID, "\p"); - UpdateResFile(prefrh); - - } else { - UseResFile(prefrh); - } - return prefrh; -} - -/* -** Return the name of the Python directory -*/ -static char * -PyMac_GetPythonDir() -{ - static char name[256]; - AliasHandle handle; - FSSpec dirspec; - Boolean modified = 0; - short oldrh, prefrh; - - oldrh = CurResFile(); - /* - ** First look for an override of the preferences file - */ - handle = (AliasHandle)GetResource('alis', PYTHONHOMEOVERRIDE_ID); - if ( handle != NULL ) { - prefrh = oldrh; - } else { - /* - ** Remember old resource file and try to open preferences file - ** in the preferences folder. - */ - prefrh = PyMac_OpenPrefFile(); - /* So, we've opened our preferences file, we hope. Look for the alias */ - handle = (AliasHandle)Get1Resource('alis', PYTHONHOME_ID); - if ( handle == NULL ) { - (void)StopAlert(BADPREFFILE_ID, NULL); - exit(1); - } - } - /* It exists. Resolve it (possibly updating it) */ - if ( ResolveAlias(NULL, handle, &dirspec, &modified) != noErr ) { - (void)StopAlert(BADPREFFILE_ID, NULL); - exit(1); - } - if ( modified ) { - ChangedResource((Handle)handle); - UpdateResFile(prefrh); - } - if ( prefrh != oldrh ) { - CloseResFile(prefrh); - UseResFile(oldrh); - } - - if ( nfullpath(&dirspec, name) == 0 ) { - strcat(name, ":"); - } else { - /* If all fails, we return the current directory */ - printf("Python home dir exists but I cannot find the pathname!!\n"); - name[0] = 0; - (void)getwd(name); - } - return name; -} - -#ifndef USE_BUILTIN_PATH -static char * -PyMac_GetPythonPath(dir) -char *dir; -{ - FSSpec dirspec; - short oldrh, prefrh = -1; - short prefdirRefNum; - long prefdirDirID; - char *rv; - int i, newlen; - Str255 pathitem; - int resource_id; - OSErr err; - - /* - ** Remember old resource file and try to open preferences file - ** in the preferences folder. - */ - oldrh = CurResFile(); - if ( FindFolder(kOnSystemDisk, 'pref', kDontCreateFolder, &prefdirRefNum, - &prefdirDirID) == noErr ) { - (void)FSMakeFSSpec(prefdirRefNum, prefdirDirID, "\pPython Preferences", &dirspec); - prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); - } - /* At this point, we may or may not have the preferences file open, and it - ** may or may not contain a sys.path STR# resource. We don't care, if it doesn't - ** exist we use the one from the application (the default). - ** We put an initial '\n' in front of the path that we don't return to the caller - */ - if( (rv = malloc(2)) == NULL ) - goto out; - strcpy(rv, "\n"); - /* - ** See whether there's an override. - */ - GetIndString(pathitem, PYTHONPATHOVERRIDE_ID, 1); - if ( pathitem[0] ) - resource_id = PYTHONPATHOVERRIDE_ID; - else - resource_id = PYTHONPATH_ID; - for(i=1; ; i++) { - GetIndString(pathitem, resource_id, i); - if( pathitem[0] == 0 ) - break; - if ( pathitem[0] >= 9 && strncmp((char *)pathitem+1, "$(PYTHON)", 9) == 0 ) { - /* We have to put the directory in place */ - newlen = strlen(rv) + strlen(dir) + (pathitem[0]-9) + 2; - if( (rv=realloc(rv, newlen)) == NULL) - goto out; - strcat(rv, dir); - /* Skip a colon at the beginning of the item */ - if ( pathitem[0] > 9 && pathitem[1+9] == ':' ) { - memcpy(rv+strlen(rv), pathitem+1+10, pathitem[0]-10); - newlen--; - } else { - memcpy(rv+strlen(rv), pathitem+1+9, pathitem[0]-9); - } - rv[newlen-2] = '\n'; - rv[newlen-1] = 0; - } else if ( pathitem[0] >= 14 && strncmp((char *)pathitem+1, "$(APPLICATION)", 14) == 0 ) { - /* This is the application itself */ - char fullname[256]; - - if ( (err=PyMac_process_location(&dirspec)) != 0 ) { - printf("Cannot get FSSpec for application, error %d\n", err); - exit(1); - } - if ( nfullpath(&dirspec, fullname) != 0 ) { - printf("Cannot convert application fsspec to path\n"); - exit(1); - } - newlen = strlen(rv) + strlen(fullname) + 2; - if( (rv=realloc(rv, newlen)) == NULL) - goto out; - strcpy(rv+strlen(rv), fullname); - rv[newlen-2] = '\n'; - rv[newlen-1] = 0; - - } else { - /* Use as-is */ - newlen = strlen(rv) + (pathitem[0]) + 2; - if( (rv=realloc(rv, newlen)) == NULL) - goto out; - memcpy(rv+strlen(rv), pathitem+1, pathitem[0]); - rv[newlen-2] = '\n'; - rv[newlen-1] = 0; - } - } - if( strlen(rv) == 1) { - free(rv); - rv = NULL; - } - if ( rv ) { - rv[strlen(rv)-1] = 0; - rv++; - } -out: - if ( prefrh ) { - CloseResFile(prefrh); - UseResFile(oldrh); - } - return rv; -} -#endif /* !USE_BUILTIN_PATH */ - -void -PyMac_PreferenceOptions(int *inspect, int *verbose, int *suppress_print, - int *unbuffered, int *debugging, int *keep_normal, - int *keep_error) -{ - short oldrh, prefrh; - Handle handle; - int size; - char *p; - - - oldrh = CurResFile(); - prefrh = PyMac_OpenPrefFile(); - handle = GetResource('Popt', PYTHONOPTIONSOVERRIDE_ID); - if ( handle == NULL ) - handle = GetResource('Popt', PYTHONOPTIONS_ID); - if ( handle == NULL ) { - return; - } - HLock(handle); - size = GetHandleSize(handle); - p = (char *)*handle; - - if ( size > POPT_INSPECT ) *inspect = p[POPT_INSPECT]; - if ( size > POPT_VERBOSE ) *verbose = p[POPT_VERBOSE]; - if ( size > POPT_SUPPRESS ) *suppress_print = p[POPT_SUPPRESS]; - if ( size > POPT_UNBUFFERED ) *unbuffered = p[POPT_UNBUFFERED]; - if ( size > POPT_DEBUGGING ) *debugging = p[POPT_DEBUGGING]; - if ( size > POPT_KEEPNORM ) *keep_normal = p[POPT_KEEPNORM]; - if ( size > POPT_KEEPERR ) *keep_error = p[POPT_KEEPERR]; - - HUnlock(handle); - - CloseResFile(prefrh); - UseResFile(oldrh); -} diff --git a/Mac/Python/macgetplatform.c b/Mac/Python/macgetplatform.c deleted file mode 100644 index 4442ea249f..0000000000 --- a/Mac/Python/macgetplatform.c +++ /dev/null @@ -1,7 +0,0 @@ - -char * -Py_GetPlatform() -{ - return "mac"; -} - diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c deleted file mode 100644 index 112604ee02..0000000000 --- a/Mac/Python/macglue.c +++ /dev/null @@ -1,834 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#ifdef __CFM68K__ -/* cfm68k InterfaceLib exports GetEventQueue, but Events.h doesn't know this -** and defines it as GetEvQHdr (which is correct for PPC). This fix is for -** CW9, check that the workaround is still needed for the next release. -*/ -#define GetEvQHdr GetEventQueue -#endif /* __CFM68K__ */ - -#include - -#ifdef __CFM68K__ -#undef GetEventQueue -#endif /* __CFM68K__ */ - -#include "Python.h" - -#include "macglue.h" -#include "marshal.h" -#include "import.h" - -#include "pythonresources.h" - -#include /* for Set(Current)A5 */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef THINK_C -#include /* For EvQElPtr */ -#endif -#ifdef __MWERKS__ -#include -#endif -#ifdef USE_GUSI -#include /* For Path2FSSpec */ -#include /* For SetSFCurDir, etc */ -#endif - -#ifndef HAVE_UNIVERSAL_HEADERS -#define GetResourceSizeOnDisk(x) SizeResource(x) -typedef DlgHookYDProcPtr DlgHookYDUPP; -#define NewDlgHookYDProc(userRoutine) ((DlgHookYDUPP) (userRoutine)) -typedef FileFilterYDProcPtr FileFilterYDUPP; -#endif - -#include -#include - -/* -** When less than this amount of stackspace is left we -** raise a MemoryError. -*/ -#ifndef MINIMUM_STACK_SIZE -#ifdef __powerc -#define MINIMUM_STACK_SIZE 8192 -#else -#define MINIMUM_STACK_SIZE 4096 -#endif -#endif - -/* -** We have to be careful, since we can't handle -** things like updates (and they'll keep coming back if we don't -** handle them). Note that we don't know who has windows open, so -** even handing updates off to SIOUX under MW isn't going to work. -*/ -#define MAINLOOP_EVENTMASK (mDownMask|keyDownMask|osMask) - -#include - -/* XXX We should include Errors.h here, but it has a name conflict -** with the python errors.h. */ -#define fnfErr -43 - -/* Declared in macfsmodule.c: */ -extern FSSpec *mfs_GetFSSpecFSSpec(); - -/* Interrupt code variables: */ -static int interrupted; /* Set to true when cmd-. seen */ -static RETSIGTYPE intcatcher Py_PROTO((int)); - -/* -** We attempt to be a good citizen by giving up the CPU periodically. -** When in the foreground we do this less often and for shorter periods -** than when in the background. At this time we also check for events and -** pass them off to SIOUX, if compiling with mwerks. -** The counts here are in ticks of 1/60th second. -** XXXX The initial values here are not based on anything. -** FG-python gives up the cpu for 1/60th 5 times per second, -** BG-python for .2 second 10 times per second. -*/ -static long interval_fg = 12; -static long interval_bg = 6; -static long yield_fg = 1; -static long yield_bg = 12; -static long lastyield; -static int in_foreground; - -/* -** When > 0, do full scanning for events (program is not event aware) -** when == 0, only scan for Command-period -** when < 0, don't do any event scanning -*/ -int PyMac_DoYieldEnabled = 1; - -/* -** Some stuff for our GetDirectory and PromptGetFile routines -*/ -struct hook_args { - int selectcur_hit; /* Set to true when "select current" selected */ - char *prompt; /* The prompt */ -}; -static DlgHookYDUPP myhook_upp; -static int upp_inited = 0; - -#ifdef USE_GUSI -/* -** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of -** the working directory. Hence, we call this routine after each call -** to chdir() to rectify things. -*/ -void -PyMac_FixGUSIcd() -{ - WDPBRec pb; - FSSpec curdirfss; - - if ( Path2FSSpec(":x", &curdirfss) != noErr ) - return; - - /* Set MacOS "working directory" */ - pb.ioNamePtr= "\p"; - pb.ioVRefNum= curdirfss.vRefNum; - pb.ioWDDirID= curdirfss.parID; - if (PBHSetVol(&pb, 0) != noErr) - return; -} - -#ifdef __CFM68K__ -void SpinCursor(short x) { /* Dummy */ } -#endif /* __CFM68K */ - -#endif - - -/* Convert C to Pascal string. Returns pointer to static buffer. */ -unsigned char * -Pstring(char *str) -{ - static Str255 buf; - int len; - - len = strlen(str); - if (len > 255) - len = 255; - buf[0] = (unsigned char)len; - strncpy((char *)buf+1, str, len); - return buf; -} - -/* Like strerror() but for Mac OS error numbers */ -char *PyMac_StrError(int err) -{ - static char buf[256]; - Handle h; - char *str; - - h = GetResource('Estr', err); - if ( h ) { - HLock(h); - str = (char *)*h; - memcpy(buf, str+1, (unsigned char)str[0]); - buf[(unsigned char)str[0]] = '\0'; - HUnlock(h); - ReleaseResource(h); - } else { - sprintf(buf, "Mac OS error code %d", err); - } - return buf; -} - -/* Exception object shared by all Mac specific modules for Mac OS errors */ -PyObject *PyMac_OSErrException; - -/* Initialize and return PyMac_OSErrException */ -PyObject * -PyMac_GetOSErrException() -{ - if (PyMac_OSErrException == NULL) - PyMac_OSErrException = PyString_FromString("Mac OS Error"); - return PyMac_OSErrException; -} - -/* Set a MAC-specific error from errno, and return NULL; return None if no error */ -PyObject * -PyErr_Mac(PyObject *eobj, int err) -{ - char *msg; - PyObject *v; - - if (err == 0 && !PyErr_Occurred()) { - Py_INCREF(Py_None); - return Py_None; - } - if (err == -1 && PyErr_Occurred()) - return NULL; - msg = PyMac_StrError(err); - v = Py_BuildValue("(is)", err, msg); - PyErr_SetObject(eobj, v); - Py_DECREF(v); - return NULL; -} - -/* Call PyErr_Mac with PyMac_OSErrException */ -PyObject * -PyMac_Error(OSErr err) -{ - return PyErr_Mac(PyMac_GetOSErrException(), err); -} - -#ifdef USE_STACKCHECK -/* Check for stack overflow */ -int -PyOS_CheckStack() -{ - long left; - - left = StackSpace(); - if ( left < MINIMUM_STACK_SIZE ) - return -1; - return 0; -} -#endif /* USE_STACKCHECK */ - -/* The catcher routine (which may not be used for all compilers) */ -static RETSIGTYPE -intcatcher(sig) - int sig; -{ - interrupted = 1; - signal(SIGINT, intcatcher); -} - -void -PyOS_InitInterrupts() -{ - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - signal(SIGINT, intcatcher); -} - -/* -** This routine scans the event queue looking for cmd-. -** This is the only way to get an interrupt under THINK (since it -** doesn't do SIGINT handling), but is also used under MW, when -** the full-fledged event loop is disabled. This way, we can at least -** interrupt a runaway python program. -*/ -static void -scan_event_queue(flush) - int flush; -{ - register EvQElPtr q; - - q = (EvQElPtr) GetEventQueue()->qHead; - - for (; q; q = (EvQElPtr)q->qLink) { - if (q->evtQWhat == keyDown && - (char)q->evtQMessage == '.' && - (q->evtQModifiers & cmdKey) != 0) { - if ( flush ) - FlushEvents(keyDownMask, 0); - interrupted = 1; - break; - } - } -} - -int -PyOS_InterruptOccurred() -{ - if (PyMac_DoYieldEnabled < 0) - return 0; -#ifdef THINK_C - scan_event_queue(1); -#endif - PyMac_Yield(); - if (interrupted) { - interrupted = 0; - return 1; - } - return 0; -} - -/* intrpeek() is like intrcheck(), but it doesn't flush the events. The -** idea is that you call intrpeek() somewhere in a busy-wait loop, and return -** None as soon as it returns 1. The mainloop will then pick up the cmd-. soon -** thereafter. -*/ -static int -intrpeek() -{ -#ifdef THINK_C - scan_event_queue(0); -#endif - return interrupted; -} - -/* Check whether we are in the foreground */ -int -PyMac_InForeground() -{ - static ProcessSerialNumber ours; - static inited; - ProcessSerialNumber curfg; - Boolean eq; - - if ( inited == 0 ) - (void)GetCurrentProcess(&ours); - inited = 1; - if ( GetFrontProcess(&curfg) < 0 ) - eq = 1; - else if ( SameProcess(&ours, &curfg, &eq) < 0 ) - eq = 1; - return (int)eq; - -} - -/* -** Set yield timeouts -*/ -void -PyMac_SetYield(long fgi, long fgy, long bgi, long bgy) -{ - interval_fg = fgi; - yield_fg = fgy; - interval_bg = bgi; - yield_bg = bgy; -} - -/* -** Handle an event, either one found in the mainloop eventhandler or -** one passed back from the python program. -*/ -void -PyMac_HandleEvent(evp) - EventRecord *evp; -{ - -#ifdef __MWERKS__ - { - int siouxdidit; - - /* If SIOUX wants it we're done */ - siouxdidit = SIOUXHandleOneEvent(evp); - if ( siouxdidit ) - return; - } -#else - /* Other compilers are just unlucky: we only weed out clicks in other applications */ - if ( evp->what == mouseDown ) { - WindowPtr wp; - - if ( FindWindow(evp->where, &wp) == inSysWindow ) { - SystemClick(evp, wp); - return; - } - } -#endif /* !__MWERKS__ */ -} - -/* -** Yield the CPU to other tasks. -*/ -static void -PyMac_DoYield() -{ - EventRecord ev; - long yield; - static int no_waitnextevent = -1; - int gotone; - - if ( no_waitnextevent < 0 ) { - no_waitnextevent = (NGetTrapAddress(_WaitNextEvent, ToolTrap) == - NGetTrapAddress(_Unimplemented, ToolTrap)); - } - - if ( PyMac_DoYieldEnabled >= 0) { -#ifndef THINK_C - /* Under think this has been done before in intrcheck() or intrpeek() */ - scan_event_queue(0); -#endif - return; - } - - in_foreground = PyMac_InForeground(); - if ( in_foreground ) - yield = yield_fg; - else - yield = yield_bg; - while ( 1 ) { - if ( no_waitnextevent ) { - SystemTask(); - gotone = GetNextEvent(MAINLOOP_EVENTMASK, &ev); - } else { - gotone = WaitNextEvent(MAINLOOP_EVENTMASK, &ev, yield, NULL); - } - /* Get out quickly if nothing interesting is happening */ - if ( !gotone || ev.what == nullEvent ) - break; - PyMac_HandleEvent(&ev); - } - lastyield = TickCount(); -} - -/* -** Yield the CPU to other tasks if opportune -*/ -void -PyMac_Yield() { - long iv; - - if ( in_foreground ) - iv = interval_fg; - else - iv = interval_bg; - if ( TickCount() > lastyield + iv ) - PyMac_DoYield(); -} - -/* -** Idle routine for busy-wait loops. -** Gives up CPU, handles events and returns true if an interrupt is pending -** (but not actually handled yet). -*/ -int -PyMac_Idle() -{ - PyMac_DoYield(); - return intrpeek(); -} -/* -** Returns true if the argument has a resource fork, and it contains -** a 'PYC ' resource of the correct name -*/ -int -PyMac_FindResourceModule(module, filename) -char *module; -char *filename; -{ - FSSpec fss; - FInfo finfo; - short oldrh, filerh; - int ok; - Handle h; - - if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ) - return 0; /* It doesn't exist */ - if ( FSpGetFInfo(&fss, &finfo) != noErr ) - return 0; /* shouldn't happen, I guess */ - oldrh = CurResFile(); - filerh = FSpOpenResFile(&fss, fsRdPerm); - if ( filerh == -1 ) - return 0; - UseResFile(filerh); - SetResLoad(0); - h = Get1NamedResource('PYC ', Pstring(module)); - SetResLoad(1); - ok = (h != NULL); - CloseResFile(filerh); - UseResFile(oldrh); - return ok; -} - -/* -** Load the specified module from a resource -*/ -PyObject * -PyMac_LoadResourceModule(module, filename) -char *module; -char *filename; -{ - FSSpec fss; - FInfo finfo; - short oldrh, filerh; - Handle h; - OSErr err; - PyObject *m, *co; - long num, size; - - if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr ) - goto error; - if ( (err=FSpGetFInfo(&fss, &finfo)) != noErr ) - goto error; - oldrh = CurResFile(); - filerh = FSpOpenResFile(&fss, fsRdPerm); - if ( filerh == -1 ) { - err = ResError(); - goto error; - } - UseResFile(filerh); - h = Get1NamedResource('PYC ', Pstring(module)); - if ( h == NULL ) { - err = ResError(); - goto error; - } - HLock(h); - /* - ** XXXX The next few lines are intimately tied to the format of pyc - ** files. I'm not sure whether this code should be here or in import.c -- Jack - */ - size = GetHandleSize(h); - if ( size < 8 ) { - PyErr_SetString(PyExc_ImportError, "Resource too small"); - co = NULL; - } else { - num = (*h)[0] & 0xff; - num = num | (((*h)[1] & 0xff) << 8); - num = num | (((*h)[2] & 0xff) << 16); - num = num | (((*h)[3] & 0xff) << 24); - if ( num != PyImport_GetMagicNumber() ) { - PyErr_SetString(PyExc_ImportError, "Bad MAGIC in resource"); - co = NULL; - } else { - co = PyMarshal_ReadObjectFromString((*h)+8, size-8); - } - } - HUnlock(h); - CloseResFile(filerh); - UseResFile(oldrh); - if ( co ) { - m = PyImport_ExecCodeModule(module, co); - Py_DECREF(co); - } else { - m = NULL; - } - return m; -error: - { - char buf[512]; - - sprintf(buf, "%s: %s", filename, PyMac_StrError(err)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } -} - -/* -** Helper routine for GetDirectory -*/ -static pascal short -myhook_proc(short item, DialogPtr theDialog, struct hook_args *dataptr) -{ - if ( item == sfHookFirstCall && dataptr->prompt) { - Handle prompth; - short type; - Rect rect; - - GetDialogItem(theDialog, PROMPT_ITEM, &type, &prompth, &rect); - if ( prompth ) - SetDialogItemText(prompth, (unsigned char *)dataptr->prompt); - } else - if ( item == SELECTCUR_ITEM ) { - item = sfItemCancelButton; - dataptr->selectcur_hit = 1; - } - return item; -} - -/* -** Ask the user for a directory. I still can't understand -** why Apple doesn't provide a standard solution for this... -*/ -int -PyMac_GetDirectory(dirfss, prompt) - FSSpec *dirfss; - char *prompt; -{ - static SFTypeList list = {'fldr', 0, 0, 0}; - static Point where = {-1, -1}; - StandardFileReply reply; - struct hook_args hook_args; - - if ( !upp_inited ) { - myhook_upp = NewDlgHookYDProc(myhook_proc); - upp_inited = 1; - } - if ( prompt && *prompt ) - hook_args.prompt = (char *)Pstring(prompt); - else - hook_args.prompt = NULL; - hook_args.selectcur_hit = 0; - CustomGetFile((FileFilterYDUPP)0, 1, list, &reply, GETDIR_ID, where, myhook_upp, - NULL, NULL, NULL, (void *)&hook_args); - - reply.sfFile.name[0] = 0; - if( FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, dirfss) ) - return 0; - return hook_args.selectcur_hit; -} - -/* -** Slightly extended StandardGetFile: accepts a prompt */ -void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList, - StandardFileReply *reply, char *prompt) -{ - static Point where = {-1, -1}; - struct hook_args hook_args; - - if ( !upp_inited ) { - myhook_upp = NewDlgHookYDProc(myhook_proc); - upp_inited = 1; - } - if ( prompt && *prompt ) - hook_args.prompt = (char *)Pstring(prompt); - else - hook_args.prompt = NULL; - hook_args.selectcur_hit = 0; - CustomGetFile((FileFilterYDUPP)0, numTypes, typeList, reply, GETFILEPROMPT_ID, where, - myhook_upp, NULL, NULL, NULL, (void *)&hook_args); -} - -/* Convert a 4-char string object argument to an OSType value */ -int -PyMac_GetOSType(PyObject *v, OSType *pr) -{ - if (!PyString_Check(v) || PyString_Size(v) != 4) { - PyErr_SetString(PyExc_TypeError, - "OSType arg must be string of 4 chars"); - return 0; - } - memcpy((char *)pr, PyString_AsString(v), 4); - return 1; -} - -/* Convert an OSType value to a 4-char string object */ -PyObject * -PyMac_BuildOSType(OSType t) -{ - return PyString_FromStringAndSize((char *)&t, 4); -} - -/* Convert an NumVersion value to a 4-element tuple */ -PyObject * -PyMac_BuildNumVersion(NumVersion t) -{ - return Py_BuildValue("(hhhh)", t.majorRev, t.minorAndBugRev, t.stage, t.nonRelRev); -} - - -/* Convert a Python string object to a Str255 */ -int -PyMac_GetStr255(PyObject *v, Str255 pbuf) -{ - int len; - if (!PyString_Check(v) || (len = PyString_Size(v)) > 255) { - PyErr_SetString(PyExc_TypeError, - "Str255 arg must be string of at most 255 chars"); - return 0; - } - pbuf[0] = len; - memcpy((char *)(pbuf+1), PyString_AsString(v), len); - return 1; -} - -/* Convert a Str255 to a Python string object */ -PyObject * -PyMac_BuildStr255(Str255 s) -{ - return PyString_FromStringAndSize((char *)&s[1], (int)s[0]); -} - - -/* -** Convert a Python object to an FSSpec. -** The object may either be a full pathname or a triple -** (vrefnum, dirid, path). -** NOTE: This routine will fail on pre-sys7 machines. -** The caller is responsible for not calling this routine -** in those cases (which is fine, since everyone calling -** this is probably sys7 dependent anyway). -*/ -int -PyMac_GetFSSpec(PyObject *v, FSSpec *fs) -{ - Str255 path; - short refnum; - long parid; - OSErr err; - FSSpec *fs2; - - /* first check whether it already is an FSSpec */ - fs2 = mfs_GetFSSpecFSSpec(v); - if ( fs2 ) { - (void)FSMakeFSSpec(fs2->vRefNum, fs2->parID, fs2->name, fs); - return 1; - } - if ( PyString_Check(v) ) { - /* It's a pathname */ - if( !PyArg_Parse(v, "O&", PyMac_GetStr255, &path) ) - return 0; - refnum = 0; /* XXXX Should get CurWD here?? */ - parid = 0; - } else { - if( !PyArg_Parse(v, "(hlO&); FSSpec should be fullpath or (vrefnum,dirid,path)", - &refnum, &parid, PyMac_GetStr255, &path)) { - return 0; - } - } - err = FSMakeFSSpec(refnum, parid, path, fs); - if ( err && err != fnfErr ) { - PyErr_Mac(PyExc_ValueError, err); - return 0; - } - return 1; -} - - -/* Convert a Python object to a Rect. - The object must be a (left, top, right, bottom) tuple. - (This differs from the order in the struct but is consistent with - the arguments to SetRect(), and also with STDWIN). */ -int -PyMac_GetRect(PyObject *v, Rect *r) -{ - return PyArg_Parse(v, "(hhhh)", &r->left, &r->top, &r->right, &r->bottom); -} - -/* Convert a Rect to a Python object */ -PyObject * -PyMac_BuildRect(Rect *r) -{ - return Py_BuildValue("(hhhh)", r->left, r->top, r->right, r->bottom); -} - - -/* Convert a Python object to a Point. - The object must be a (h, v) tuple. - (This differs from the order in the struct but is consistent with - the arguments to SetPoint(), and also with STDWIN). */ -int -PyMac_GetPoint(PyObject *v, Point *p) -{ - return PyArg_Parse(v, "(hh)", &p->h, &p->v); -} - -/* Convert a Point to a Python object */ -PyObject * -PyMac_BuildPoint(Point p) -{ - return Py_BuildValue("(hh)", p.h, p.v); -} - - -/* Convert a Python object to an EventRecord. - The object must be a (what, message, when, (v, h), modifiers) tuple. */ -int -PyMac_GetEventRecord(PyObject *v, EventRecord *e) -{ - return PyArg_Parse(v, "(hll(hh)h)", - &e->what, - &e->message, - &e->when, - &e->where.h, - &e->where.v, - &e->modifiers); -} - -/* Convert a Rect to an EventRecord object */ -PyObject * -PyMac_BuildEventRecord(EventRecord *e) -{ - return Py_BuildValue("(hll(hh)h)", - e->what, - e->message, - e->when, - e->where.h, - e->where.v, - e->modifiers); -} - -/* Convert Python object to Fixed */ -int -PyMac_GetFixed(PyObject *v, Fixed *f) -{ - double d; - - if( !PyArg_Parse(v, "d", &d)) - return 0; - *f = (Fixed)(d * 0x10000); - return 1; -} - -/* Convert a Point to a Python object */ -PyObject * -PyMac_BuildFixed(Fixed f) -{ - double d; - - d = f; - d = d / 0x10000; - return Py_BuildValue("d", d); -} - diff --git a/Mac/Python/macguesstabsize.c b/Mac/Python/macguesstabsize.c deleted file mode 100644 index ec4af3d699..0000000000 --- a/Mac/Python/macguesstabsize.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include - -#include - -/* Interface used by parsetok.c */ - -guesstabsize(path) - char *path; -{ - Str255 s; - int refnum; - Handle h; - int tabsize = 0; - s[0] = strlen(path); - memcpy(s+1, path, s[0]); - refnum = OpenResFile(s); - if (refnum == -1) - return 0; - UseResFile(refnum); - h = GetIndResource('ETAB', 1); - if (h != 0) { - tabsize = (*(short**)h)[1]; - } - CloseResFile(refnum); - return tabsize; -} diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c deleted file mode 100644 index 7241539f15..0000000000 --- a/Mac/Python/macmain.c +++ /dev/null @@ -1,440 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Python interpreter main program */ - -#include "Python.h" -#include "pythonresources.h" -#include "import.h" -#include "marshal.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __MWERKS__ -#include -#define USE_SIOUX -#endif - -#ifdef THINK_C -#include -#endif - -#define STARTUP "PythonStartup" - -extern int Py_DebugFlag; /* For parser.c, declared in pythonrun.c */ -extern int Py_VerboseFlag; /* For import.c, declared in pythonrun.c */ -extern int Py_SuppressPrintingFlag; /* For ceval.c, declared in pythonrun.c */ - - -/* Subroutines that live in their own file */ -extern char *Py_GetVersion Py_PROTO((void)); -extern char *Py_GetCopyright Py_PROTO((void)); - - -/* For Py_GetProgramName(); set by main() */ -static char *argv0; - -/* For Py_GetArgcArgv(); set by main() */ -static char **orig_argv; -static int orig_argc; - -/* Flags indicating whether stdio window should stay open on termination */ -static int keep_normal; -static int keep_error = 1; - -static void Py_Main Py_PROTO((int, char **)); /* Forward */ -void PyMac_Exit Py_PROTO((int)); /* Forward */ - -/* Initialize the Mac toolbox world */ - -static void -init_mac_world() -{ -#ifdef THINK_C - printf("\n"); -#else - MaxApplZone(); - InitGraf(&qd.thePort); - InitFonts(); - InitWindows(); - TEInit(); - InitDialogs((long)0); - InitMenus(); - InitCursor(); -#endif -} - -/* Initialization code shared by interpreter and applets */ - -static void -init_common() -{ - - /* Initialize toolboxes */ - init_mac_world(); - -#ifdef USE_MAC_SHARED_LIBRARY - /* Add the shared library to the stack of resource files */ - PyMac_AddLibResources(); -#endif - -#if defined(USE_GUSI) - /* Setup GUSI */ - GUSIDefaultSetup(); -#endif - -#ifdef USE_SIOUX - /* Set various SIOUX flags. Some are changed later based on options */ - SIOUXSettings.asktosaveonclose = 0; - SIOUXSettings.showstatusline = 0; - SIOUXSettings.tabspaces = 4; -#endif - -} - - -#ifdef USE_MAC_APPLET_SUPPORT -/* Applet support */ - -/* Run a compiled Python Python script from 'PYC ' resource __main__ */ -static int -run_main_resource() -{ - Handle h; - long size; - PyObject *code; - PyObject *result; - - h = GetNamedResource('PYC ', "\p__main__"); - if (h == NULL) { - Alert(NOPYC_ALERT, NULL); - return 1; - } - size = GetResourceSizeOnDisk(h); - HLock(h); - code = PyMarshal_ReadObjectFromString(*h + 8, (int)(size - 8)); - HUnlock(h); - ReleaseResource(h); - if (code == NULL) { - PyErr_Print(); - return 1; - } - result = PyImport_ExecCodeModule("__main__", code); - Py_DECREF(code); - if (result == NULL) { - PyErr_Print(); - return 1; - } - Py_DECREF(result); - return 0; -} - -/* Initialization sequence for applets */ -void -PyMac_InitApplet() -{ - int argc; - char **argv; - int err; - - init_common(); - argc = PyMac_GetArgv(&argv); - Py_Initialize(); - PySys_SetArgv(argc, argv); - err = run_main_resource(); - fflush(stderr); - fflush(stdout); - PyMac_Exit(err); - /* XXX Should we bother to Py_Exit(sts)? */ -} - -#endif /* USE_MAC_APPLET_SUPPORT */ - -/* For normal application */ -void -PyMac_InitApplication() -{ - int argc; - char **argv; - - init_common(); - argc = PyMac_GetArgv(&argv); - if ( argc > 1 ) { - /* We're running a script. Attempt to change current directory */ - char curwd[256], *endp; - - strcpy(curwd, argv[1]); - endp = strrchr(curwd, ':'); - if ( endp && endp > curwd ) { - *endp = '\0'; - - chdir(curwd); -#ifdef USE_GUSI - /* Change MacOS's idea of wd too */ - PyMac_FixGUSIcd(); -#endif - } - } - Py_Main(argc, argv); -} - -/* -** PyMac_InteractiveOptions - Allow user to set options if option key is pressed -*/ -void -PyMac_InteractiveOptions(int *inspect, int *verbose, int *suppress_print, - int *unbuffered, int *debugging, int *keep_normal, - int *keep_error, int *argcp, char ***argvp) -{ - KeyMap rmap; - unsigned char *map; - short item, type; - ControlHandle handle; - DialogPtr dialog; - Rect rect; - int old_argc = *argcp; - int i; - - /* Default-defaults: */ - *keep_error = 1; - /* Get default settings from our preference file */ - PyMac_PreferenceOptions(inspect, verbose, suppress_print, - unbuffered, debugging, keep_normal, keep_error); - /* If option is pressed override these */ - GetKeys(rmap); - map = (unsigned char *)rmap; - if ( ( map[0x3a>>3] & (1<<(0x3a&7)) ) == 0 ) /* option key is 3a */ - return; - - dialog = GetNewDialog(OPT_DIALOG, NULL, (WindowPtr)-1); - if ( dialog == NULL ) { - printf("Option dialog not found - cannot set options\n"); - return; - } - SetDialogDefaultItem(dialog, OPT_OK); - SetDialogCancelItem(dialog, OPT_CANCEL); - - /* Set default values */ -#define SET_OPT_ITEM(num, var) \ - GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \ - SetCtlValue(handle, (short)*(var)); - - SET_OPT_ITEM(OPT_INSPECT, inspect); - SET_OPT_ITEM(OPT_VERBOSE, verbose); - SET_OPT_ITEM(OPT_SUPPRESS, suppress_print); - SET_OPT_ITEM(OPT_UNBUFFERED, unbuffered); - SET_OPT_ITEM(OPT_DEBUGGING, debugging); - SET_OPT_ITEM(OPT_KEEPNORMAL, keep_normal); - SET_OPT_ITEM(OPT_KEEPERROR, keep_error); - -#undef SET_OPT_ITEM - - while (1) { - handle = NULL; - ModalDialog(NULL, &item); - if ( item == OPT_OK ) - break; - if ( item == OPT_CANCEL ) { - DisposDialog(dialog); - exit(0); - } - if ( item == OPT_CMDLINE ) { - int new_argc, newer_argc; - char **new_argv, **newer_argv; - - new_argc = ccommand(&new_argv); - newer_argc = (new_argc-1) + old_argc; - newer_argv = malloc((newer_argc+1)*sizeof(char *)); - if( !newer_argv ) - Py_FatalError("Cannot malloc argv\n"); - for(i=0; i" : filename) != 0; - if (filename != NULL) - fclose(fp); - - if (inspect && isatty((int)fileno(stdin)) && - (filename != NULL || command != NULL)) - sts = PyRun_AnyFile(stdin, "") != 0; - - Py_Exit(sts); - /*NOTREACHED*/ -} - -/* -** Terminate application -*/ -void -PyMac_Exit(status) - int status; -{ - int keep; - - if ( status ) - keep = keep_error; - else - keep = keep_normal; - -#ifdef USE_SIOUX - if (keep) { - SIOUXSettings.standalone = 1; - SIOUXSettings.autocloseonquit = 0; - SIOUXSetTitle("\p\307terminated\310"); - } - else - SIOUXSettings.autocloseonquit = 1; -#endif -#ifdef THINK_C - console_options.pause_atexit = keep; -#endif - - exit(status); -} - -/* Return the program name -- some code out there needs this. */ - -char * -Py_GetProgramName() -{ - return argv0; -} - - -/* Make the *original* argc/argv available to other modules. - This is rare, but it is needed by the secureware extension. */ - -void -Py_GetArgcArgv(argc,argv) - int *argc; - char ***argv; -{ - *argc = orig_argc; - *argv = orig_argv; -} - -/* More cruft that shouldn't really be here, used in sysmodule.c */ - -char * -Py_GetPrefix() -{ - return ""; -} - -char * -Py_GetExecPrefix() -{ - return ""; -} diff --git a/Mac/Python/macsetfiletype.c b/Mac/Python/macsetfiletype.c deleted file mode 100644 index 38b51ba33a..0000000000 --- a/Mac/Python/macsetfiletype.c +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * macsetfiletype - Set the mac's idea of file type - * - */ - -#include "macdefs.h" - -int -setfiletype(name, creator, type) -char *name; -long creator, type; -{ - FInfo info; - unsigned char *pname; - - pname = (StringPtr) Pstring(name); - if ( GetFInfo(pname, 0, &info) < 0 ) - return -1; - info.fdType = type; - info.fdCreator = creator; - return SetFInfo(pname, 0, &info); -} - -long -getfiletype(name) -char *name; -{ - FInfo info; - unsigned char *pname; - - pname = (StringPtr) Pstring(name); - if ( GetFInfo(pname, 0, &info) < 0 ) - return -1; - return info.fdType; -} - diff --git a/Mac/Python/macshlglue.c b/Mac/Python/macshlglue.c deleted file mode 100644 index 58fe7fd3a0..0000000000 --- a/Mac/Python/macshlglue.c +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Shared library initialization code. -** -** This code calls the MetroWerks shared-library initialization code -** and performs one extra step: it remembers the FSSpec of the file -** we are loaded from, so we can later call PyMac_AddLibResources to -** add the file to our resource file chain. -** -** This file is needed for PythonCore and for any dynamically loaded -** module that has interesting resources in its .slb file. -** Use by replacing __initialize in the "CFM preferences" init field -** by __initialize_with_resources. -*/ - -#include -#include -#include -#include -#include - - -/* -** Variables passed from shared lib initialization to PyMac_AddLibResources. -*/ -static int library_fss_valid; -static FSSpec library_fss; - -/* -** Routine called upon fragment load. We attempt to save the FSSpec from which we're -** loaded. We always return noErr (we just continue without the resources). -*/ -OSErr pascal -__initialize_with_resources(InitBlockPtr data) -{ - /* Call the MW runtime's initialization routine */ -/* #ifdef __CFM68K__ */ -#if 1 - __initialize(); -#else - __sinit(); -#endif - - if ( data == nil ) return noErr; - if ( data->fragLocator.where == kOnDiskFlat ) { - library_fss = *data->fragLocator.u.onDisk.fileSpec; - library_fss_valid = 1; - } else if ( data->fragLocator.where == kOnDiskSegmented ) { - library_fss = *data->fragLocator.u.inSegs.fileSpec; - library_fss_valid = 1; - } - return noErr; -} - -/* -** Insert the library resources into the search path. Put them after -** the resources from the application (which we assume is the current -** resource file). Again, we ignore errors. -*/ -void -PyMac_AddLibResources() -{ - if ( !library_fss_valid ) - return; - (void)FSpOpenResFile(&library_fss, fsRdPerm); -} - diff --git a/Mac/ReadMeOrSuffer b/Mac/ReadMeOrSuffer deleted file mode 100644 index 7339fbffc0..0000000000 --- a/Mac/ReadMeOrSuffer +++ /dev/null @@ -1,130 +0,0 @@ -How to install Python 1.3.3 on your Macintosh ------------------------------------------------- - -Even if you don't usually read readme files: please read at least the -first sections of this file, failure to do so will probably result in -an unuseable python system. If this warning is too late and you already -have an non-functional python: it is best to remove all traces and start -with a fresh distribution. Especially don't forget to remove the -"python preferences" file from the Preferences folder, and possibly -"PythonCore" from the Extensions folder. Before you mail me for help *please* -try the steps above (cleaning up and re-installing): it should fix most -common mistakes. - -If this is your first encounter with Python: you definitely need the common -user documentation (common to all platforms). You can find this (in various -forms) on www.python.org and ftp.python.org. - -Mac-specific documentation is included in this distribution in folder Mac:Demo. -The documentation is sparse, but it will have to serve for now. The documentation -is in HTML format, start with index.html. - -If you have a pre-system 7 macintosh: sorry, this release will not work -on your system. Too many sys7 features are used to make a sys6 python -easy to create. If you really want one: tell me, maybe I can be convinced. -Alternatively: get the sources, put in the necessary gestalt() and -compatability calls yourself and send me the results. - -If you don't have enough memory: the sizes choosen are somewhat arbitrary. -Try lowering them and seeing whether the resulting python is still usable. -Note, however, that python running out of memory may result in your mac -freezing. If this happens I would like to hear of it. - -Note that if you're using Tk you might want to raise the memory size, tcl -and tk are quite a memory hog. - -PowerPC Macintosh instructions ------------------------------- - -1. Remove older versions of "PythonCore" and "Python Preferences" - from your system folder. - -2. Run the MkPluginAliases applet. This will first ask you whether it should - create an initial preferences file. Let it do so. Next, it will create a - number of aliases in the PlugIns folder. If this fails in mysterious ways - examine the script (in Mac:scripts:MkPluginAliases.py) and create the aliases - by hand (and tell me what you did to make the script fail:-). - -3. To make sure any applets you create can find the common interpreter code - you should move PythonCore to the Extensions folder (drop it on the - System Folder and it will find its own way). Alternatively, you can - make an alias called "PythonCore" in the Extensions folder and - point it to the real PythonCore. You may want to start PythonPPC - again at this point to check that you actually put the extension in - the right place. - -4. You're all set now. Continue with the common instructions. - -68K Macintosh instructions --------------------------- - -1. Remove old "Python Preferences" file from the Preferences folder, if you - have one (the file, that is, not the folder:-). - -2. Run Python68K. This will create an initial preferences file (after - asking you if that's ok with you). Quit python. - -3. Continue with the next section. - -Common instructions -------------------- - -You should now have a functioning python. It is probably a good idea to run -"testall.py" from :Lib:test at this point, this should not give any errors. -Running testall.py is done by double-clicking it or dropping it onto the -interpreter. -Next, try "compileall.py" from :Lib to create all .pyc files (but this isn't -really important). - -PPC users have a couple of applets in the main folder they may want to try, -(68K users can use the corresponding scripts from the "scripts" folder): - -- EditPythonPrefs allows you to edit the preferences file, to change the - python home folder or modify the initial sys.path setting. - The default settings are "liberal", you can remove stdwin and tkinter if - you don't use them and maybe others. -- RunLibScript allows you to run any script as __main__ after setting arguments, - changing stdin/stdout/workdir, etc. Most of this functionality can also be - obtained nowadays by option-dragging a script to the interpreter. -- For PPC only, mkapplet creates a python applet, a tiny application written - in python. Drop a python source on it and out comes the application. More - information can be found in the "Mac:Demo" folder. - -PPC users will see one more files in the python folder: PythonApplet. This is -the template for building applets, leave it alone. - -Things to see -------------- - -There are some readme files in the "Read me files" folder that may contain -useful information. There is also a first stab at documentation (plus examples) -in the Mac:Demo folder. The toplevel Demo folder has machine-independent demos. -See the file Readme-mac for mac-specific notes. The Mac:Lib:test folder also -has some programs that show simple capabilities of various modules. - -The "scripts" folder has some sample scripts. Some are useful, some are just -interesting to look at to see how various things work. The MkDistr, mkapplet -and fullbuild scripts (plus the ones mentioned above) may help you to understand -how to use AppleEvents and various other toolboxes from python. - -The 'img' group of modules, which handles I/O of many different image formats -(not pict yet, sigh:-) is included, but without documentation. You can find -docs at ftp://ftp.cwi.nl/pub/jack/python/img (or somewhere around there). - -Feedback --------- - -Send bug reports, suggestions, contributions and fanmail to . -Be warned however that I'm pretty busy at the moment, so I may not always -respond immedeately. -Alternatively, you can try sending to comp.lang.python or python-list@cwi.nl, -but since I read the newsgroup, not the mailinglist, I may miss it there -(but other people may know quite a bit more than me anyway:-). - - Jack Jansen - Centrum voor Wiskunde en Informatica - Kruislaan 413 - 1098 SJ Amsterdam - the Netherlands - - , http://www.cwi.nl/~jack diff --git a/Mac/Relnotes-1.1 b/Mac/Relnotes-1.1 deleted file mode 100644 index 364c3ece23..0000000000 --- a/Mac/Relnotes-1.1 +++ /dev/null @@ -1,131 +0,0 @@ -PYTHON RELEASE NOTES FOR THE MACINTOSH - -VERSION 1.1 - -For the most part, Python on the Mac works just like Python under UNIX. -The most important differences are: - -- Since there is no shell environment on the Mac, the start-up file - has a fixed name: PythonStartup. If a file by this name exists - (either in the current folder or in the system folder) it is executed - when an interactive interpreter is started. - -- The default search path for modules is different: first the current - directory is searched, then the subdirectories 'lib', 'lib:stdwin' and - 'demo'. As always, you can change this (e.g. in your PythonStartup - file) by assigning or appending to sys.path -- use Macintosh pathnames! - (The default contains no absolute paths because these are unlikely - to make sense on other people's hard disks.) - -- The user interface for typing interactive commands is different. - This is actually the THINK C console I/O module, which is based on - the Mac toolbox TextEdit. A standard Edit menu provides Cut, Copy, - Paste and Clear (Undo is only there for Desk Accessories). A minimal - File menu provides Quit, which immediately exits the application, - without the usual cleanup. You can Copy from previous output, - but you can't scroll back beyond the 24x80 screen. The TAB key - always brings you to the end of the current input line; indentation - must be entered with spaces (a single space is enough). - End-of-file is generated by Command-D; Command-Period interrupts. - There is an annoying limit in the length of an input line to a single - screen line (less the prompt). Use \ to input long statements. - Change your program if it requires long lines typed on input. - Even though there is no resize box, the window can be resized by - dragging its bottom right corner, but the maximum size is 24x80. - -- Tabs in module files are interpreted as 4 (four!) spaces. This is - consistent with most Mac editors that I know. For individual files - you can change the tab size with a comment like - - # vi:set tabsize=8: - - (exactly as shown here, including the colons!). If you are consistent - in always using tabs for indentation on UNIX, your files will be - parsed correctly on the Mac, although they may look funny if you - have nicely lined-up comments or tables using tabs. Never using tabs - also works. Mixing tabs and spaces to simulate 4-character indentation - levels is likely to fail. - -- You can start a script from the Finder by selecting the script and - the Python interpreter together and then double clicking. If you - make the owner of the script PYTH (the type should always be TEXT) - Python will be launched if you double click it! - There is no way to pass command line arguments to Python scripts. - -- The set of built-in modules is different: - - = Operating system functions for the 'os' module is provided by the - built-in module 'mac', not 'posix'. This doesn't have all the - functions from posix, for obvious reasons (if you know the Mac - O/S a little bit). The functions in os.path are provided by - macpath, they know about Mac pathnames etc. - - = None of the UNIX specific modules ('socket', 'pwd', 'grp' etc.) - exists. - - = Module 'stdwin' is always available. It uses the Mac version of - STDWIN, which interfaces directly with the Mac toolbox. The most - important difference is in the font names; setfont() has a second - argument specifying the point size and an optional third one - specifying the variation: a single letter character string, - 'i' for italics, 'b' for bold. Note that when STDWIN is waiting - for events, the standard File and Edit menus are inactive but - still visible, and (most annoyingly) the Apple menu is also inactive; - conversely, menus put up by STDWIN are not active when the Python is - reading from the keyboard. If you open Python together with a text - file containing a Python script, the script will be executed and - a console window is only generated when the script uses standard - input or output. A script that uses STDWIN exclusively for its I/O - will have a working Apple menu and no extraneous File/Edit menus. - (This is because both stdwin and stdio try to initialize the - windowing environment; whoever gets there first owns the Apple menu.) - LIMITATIONS: a few recent additions to STDWIN for X11 have not yet - been added to the Mac version. There are no bitmap objects, and - the setwinpos() and setwinsize() methods are non--functional. - -- Because launching an application on the Mac is so tedious, you will - want to edit your program with a desk accessory editor (e.g., Sigma - edit) and test the changed version without leaving Python. This is - possible but requires some care. Make sure the program is a module - file (filename must be a Python identifier followed by '.py'). You - can then import it when you test it for the first time. There are - now three possibilities: it contains a syntax error; it gets a runtime - error (unhandled exception); or it runs OK but gives wrong results. - (If it gives correct results, you are done testing and don't need - to read the rest of this paragraph. :-) Note that the following - is not Mac-specific -- it's just that on UNIX it's easier to restart - the entire script so it's rarely useful. - - Recovery from a syntax error is easy: edit the file and import it - again. - - Recovery from wrong output is almost as easy: edit the file and, - instead of importing it, call the function reload() with the module - name as argument (e.g., if your module is called foo, type - "reload(foo)"). - - Recovery from an exception is trickier. Once the syntax is correct, - a 'module' entry is placed in an internal table, and following import - statements will not re-read the file, even if the module's initialization - terminated with an error (one reason why this is done is so that - mutually recursive modules are initialized only once). You must - therefore force re-reading the module with reload(), however, if this - happens the first time you try to import the module, the import statement - itself has not completed, and your workspace does not know the module - name (even though the internal table of moduesl does!). The trick is - to first import the module again, then reload it. For instance, - "import foo; reload(foo)". Because the module object already exists - internally, the import statement does not attempt to execute the - module again -- it just places it in your workspace. - - When you edit a module you don't have to worry about the corresponding - '.pyc' file (a "compiled" version of the module, which loads much faster - than the textual version): the interpreter notices that the '.py' file - has changed (because its modification time has changed) and ignores the - '.pyc' file. When parsing is successful, a new '.pyc' file is written; - if this fails (no write permission, disk full or whatever) it is - silently skipped but attempted again the next time the same module - is loaded. (Thus, if you plan to place a Python library on a read-only - disk, it is advisable to "warm the cache" by making the disk writable - and importing all modules once. The standard module 'importall' helps - in doing this.) diff --git a/Mac/Relnotes-1.2 b/Mac/Relnotes-1.2 deleted file mode 100644 index f11e34339f..0000000000 --- a/Mac/Relnotes-1.2 +++ /dev/null @@ -1,169 +0,0 @@ -BUILDING PYTHON 1.2 FOR THE MACINTOSH -************************************* - -Python can be built on the Mac using either THINK C 6.0 (or 7.0), or -CodeWarrior 5.0 (for 68K and PPC). In the past it has also been compiled -with earlier versions of Think, but no guarantees are made that the -source is still compatible with those versions. (Think C 5.0 appears -to be OK.) Likewise, new compiler versions may effectively change the -language accepted (or the library provided!) and thus cause problems. - -MPW is a special case -- it used to be possible to build Python as -an MPW tool using MPW 3.2, and this may still work, but I haven't -tried this lately. What I have tried, however, is building Python -as a shared library for CFM-68K, using the Symantec C compiler for MPW. -See subdirectory MPW and the README file there for more info. - - -1. Using Think C 6.0 (or 7.0) -============================= - -1.1 The directory structure ---------------------------- - -I duplicate the UNIX directory structure from the distribution. The -subdirectories needed to compile are: Mac, Include, Parser, Python, -Objects, Modules. (Don't bother with Grammar and the parser -generator, nor with the Doc subdirectory.) - -For running and testing, you also need Lib and its subdirectories test -and stdwin. You could also copy some things from the Demo/stdwin -directory (unfortunately most other demos are UNIX specific and even -many stdwin demos are). - -Make sure there is no config.c file in the Modules subdirectory (if -you copy from a directory where you have done a UNIX build this might -occur). Also don't use the config.h generated on UNIX. - -1.2 The project file --------------------- - -I put all source files in one project, which I place in the parent -directory of the source directories. - -1.2.1 Project type - -(This is the Set Project Type... dialog in the Project menu.) - -Set the creator to PYTH; turn on "far data"; leave "far code" and -"separate strs" unchecked (they just serve to bloat the application). -A partition size of 1000K should be enough to run the standard test -suite (which requires a lot of memory because it stress tests the -parser quite a bit) and most demos or medium-size applications. The -interpreter will do basic things in as little at 500K but this may -prevent parsing larger modules. - -1.2.2 Compiler options - -(This is the Options -> THINK C ... dialog in the Edit menu.) - - - Start with Factory Settings. - - - In the Prefix, remove #include and add - #define HAVE_CONFIG_H - - - Choose any optimizer and debugger settings you like. - You - can choose 4-byte ints if you want. This requires that you - rebuild the ANSI and unix libraries with 4-bytes ints as well - (better make copies with names like ANSI 32 bit). With 4-byte - ints the interpreter is marginally bigger and somewhat (~10%) - slower, but Python programs can use strings and lists with - more than 32000 items (with 2-byte ints these can cause - crashes). The range of Python integers is not affected (these - are always represented as longs). In fact, nowadays I always - use 4-byte integers, since it is actually rather annoying that - strings >= 64K cause crashes. - -1.2.3 Files to add - -(This is the Add Files... dialog in the Source menu.) - -The following source files must be added to the project. I use a -separate segment for each begin letter -- this avoids segment -overflow, except for 'c', where you have to put either ceval.c or -compile.c in a separate segment. You could also group them by -subdirectory or function, but you may still have to split segments -arbitrarily because of the 32000 bytes restriction. - - - From Mac: all .c files. - - - From Parser: acceler.c, grammar1.c, - myreadline.c, node.c, parser.c, parsetok.c, tokenizer.c. - - - From Python: bltinmodule.c, ceval.c, cgensupport.c, - compile.c, errors.c, getargs.c getopt.c, graminit.c, import.c, - importdl.c, marshal.c, modsupport.c, mystrtoul.c, - pythonmain.c, pythonrun.c, sigcheck.c, structmember.c, - sysmodule.c, traceback.c (i.e. all .c files except dup2.c, - fmod.c, frozenmain.c, getcwd.c, getmtime.c, memmove.c, - sigcheck.c, strerror.c, strtod.c, thread.c) - - - From Objects: all .c files except xxobject.c. - - - From Modules: all the modules listed in config.c (in the Mac - subdirectory) in the initializer for inittab[], before - "ADDMODULE MARKER 2". Also add md5c.c if you add md5module.c, - and regexpr.c if you add regexmodule.c. (You'll find - macmodule.c in the Mac subdirectory, so it should already have - been added in a previous step.) Note that for most modules, - the source file is called module.c, but for a few long - module names it is just .c. Don't add stdwinmodule.c - yet, - -The following THINK C libraries must be added: from Standard -Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each -library in a separate segment. Also see my earlier remark on 4-byte -ints. - -1.4 Adding STDWIN ------------------ - -STDWIN is built in two separate projects: stdwin.pi contains the core -STDWIN implementation from Ports/mac, textedit.pi contains the files -from Packs/textedit. Use the same compiler options as for Python and -the same general source setup (in a sister directory of the toplevel -Python directory). Put all sources in the same segment. To -stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c. - -The two projects can now be added as libraries to the Python project. -You must also add stdwinmodule.c and add "#define USE_STDWIN" to the -Prefix in the compiler options dialog (this only affects macmain.c and -config.c). - -Note that stdwinmodule.c contains an #include statement that -references "stdwin.h" by relative path name -- if the stdwin toplevel -directory is not a sibling of the python toplevel directory, you may -have to adjust the number of colons in the pathname. - -1.5 Resources -------------- - -Since I created them with ResEdit I have no text source of the -resources needed to give the application an icon etc... You can copy -the size, bundle, file reference and icon resources from the -distributed Python application with ResEdit. THINK C automatically -copies resources into the application file from a file -.rsrc. - -1.6 Think C 5.0 ---------------- - -Tim Gilbert adds one note that will be helpful to future Think C 5.0 -users: When you have a really big project like python, and you want to -compile and run it, if you just hit Command-R, often Think C will -compile the remaining files, think for a moment, and then give you a -warning "internal error(ZREF)--please remove objects." Don't listen -to it. It is lying. What you should do instead is "Check Link..." -and _then_ hit Run. Why? Ask Symantec. - - -2. Using MicroWerks CodeWarrior 5.0 -=================================== - -Essentially, follow the instructions for Think C. - -XXX Should at least list the project options. - - ---Guido van Rossum, CWI, Amsterdam - diff --git a/Mac/Relnotes-1.3 b/Mac/Relnotes-1.3 deleted file mode 100644 index a38f139883..0000000000 --- a/Mac/Relnotes-1.3 +++ /dev/null @@ -1,118 +0,0 @@ - Changes since 1.3beta3 - ---------------------- -- MkPluginAliases.py now works in a virgin distribution environment. It is - also distributed as an applet. -- hexbin from binhex.py has been fixed -- various bits and pieces in readme files clarified -- mkapplet bug wrt owner resource (and, hence, trouble starting applets) fixed. -- Compiled with CodeWarrior 7. -- AE client modules generated with gensuitemodule.py now use keyword args. -- img modules updated to latest version (including pbm and sgi support). -- Everything compiled with all optimization options available. Let me know - if you suspect errors that are due to this. - - Changes since Python 1.2 for the mac - ------------------------------------ -- PPC python now uses a shared library organization. This allows the - creation of dynamically loadable extension modules (contact me) and - creation of python applets (see mkapplet.py). A number of previously - builtin modules are now dynamically loaded. Dynamically loaded - modules are distributed in the PlugIns folder. -- Python modules can live in 'PYC ' resources (with a name equal to the - module name, so many modules can live in a single file). If you put a - file (in stead of a folder) in sys.path its resources will be searched. - See the PackLibDir script for creating such a file. -- new binhex module (partially working, hexbin has problems) -- Python now has a Preferences file, editable with - EditPythonPrefs. Remembered are the python 'home folder' and the - initial value for sys.path. If no preferences file is found a simple - one is created. - NOTE: this only works correctly if you start python the first time - from the correct folder. -- new img modules, to read/write/convert images in various formats -- new MacOS toolbox modules: AE, Ctl, Dlg, Event, List, Qd, Res, Snd - and Win. These provide access to various of the MacOS toolbox - interfaces. No documentation yet, but the __doc__ strings provide at - least the calling sequence (and Inside Mac will give you the - semantics). Minimal demos are provided for most toolbox interfaces, - and the 'scripts' directory has some more examples. -- AppleEvent client interfaces can be generated from aete/aeut - resources. No support for objects yet, nor for server interfaces. -- Lib:mac:FrameWork.py has an application framework (under - construction). -- (PPC Only) support for building Python applets: tiny standalone - python applications. -- fp = open(filename, '*r') opens resource-fork of a file for reading - (and similar for writing). -- option-dragging a file to the interpreter (or immedeately pressing -