From de42ea08807c18969c8e6dfffe5035a71e6b343c Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@6015fed2-1504-0410-9fe1-9d1591cc4771> Date: Wed, 14 Feb 1996 18:37:46 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create tag 'cnrisync'. git-svn-id: http://svn.python.org/projects/python/tags/cnrisync@5867 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/example1/InterslipControl-1.py | 92 - Mac/Demo/example1/InterslipControl-1.rsrc.hqx | 13 - Mac/Demo/example2/InterslipControl-2.py | 116 - Mac/Demo/example2/InterslipControl-2.rsrc.hqx | 55 - Mac/Demo/imgbrowse/imgbrowse.py | 156 - Mac/Demo/interslip/InterslipLib.c | 97 - Mac/Demo/interslip/InterslipLib.h | 20 - Mac/Demo/interslip/interslipmodule.c | 225 - Mac/Demo/quicktime/MovieInWindow.py | 71 - Mac/Demo/quicktime/VerySimplePlayer.py | 97 - Mac/Demo/scripting/Eudora_Suite.py | 363 -- Mac/Demo/scripting/Standard_Suite.py | 277 - Mac/Demo/scripting/testeudora.py | 41 - Mac/Demo/speech/SCRIPT | 1204 ---- Mac/Demo/speech/grail.py | 228 - Mac/Demo/speech/hum.py | 31 - Mac/Include/config.h | 336 -- Mac/Include/macdefs.h | 38 - Mac/Include/macglue.h | 85 - Mac/Include/pythonresources.h | 67 - Mac/Lib/test/cmtest.py | 45 - Mac/Lib/test/ctbtest.py | 41 - Mac/Lib/toolbox/Components.py | 23 - Mac/Lib/toolbox/Fonts.py | 32 - Mac/Lib/toolbox/QuickTime.py | 234 - Mac/MPW/Build | 3 - Mac/MPW/Makefile | 513 -- Mac/MPW/README | 122 - Mac/MPW/buildall | 29 - Mac/Modules/cm/Cmgen.py | 158 - Mac/Modules/cm/Cmmodule.c | 767 --- Mac/Modules/cm/cmscan.py | 65 - Mac/Modules/cm/cmsupport.py | 108 - Mac/Modules/config.c | 232 - Mac/Modules/ctbmodule.c | 585 -- Mac/Modules/fm/Fmgen.py | 84 - Mac/Modules/fm/Fmmodule.c | 400 -- Mac/Modules/fm/fmscan.py | 46 - Mac/Modules/fm/fmsupport.py | 75 - Mac/Modules/gestaltmodule.c | 69 - Mac/Modules/macfsmodule.c | 827 --- Mac/Modules/macmodule.c | 595 -- Mac/Modules/macosmodule.c | 260 - Mac/Modules/macspeech/README | 18 - Mac/Modules/macspeechmodule.c | 552 -- Mac/Modules/qt/Qtmodule.c | 6007 -------------------- Mac/Modules/qt/qtgen.py | 1712 ------ Mac/Modules/qt/qtscan.py | 112 - Mac/Modules/qt/qtsupport.py | 224 - Mac/Python/macapplet.c | 35 - Mac/Python/macapplication.c | 41 - Mac/Python/macgetargv.c | 335 -- Mac/Python/macgetcompiler.c | 36 - Mac/Python/macgetmtime.c | 14 - Mac/Python/macgetpath.c | 265 - Mac/Python/macgetplatform.c | 7 - Mac/Python/macglue.c | 759 --- Mac/Python/macguesstabsize.c | 29 - Mac/Python/macmain.c | 344 -- Mac/Python/macsetfiletype.c | 37 - Mac/Python/macshlglue.c | 66 - Mac/README | 169 - Mac/ReadMeOrSuffer | 124 - Mac/Relnotes-1.1 | 131 - Mac/Relnotes-1.2 | 169 - Mac/Relnotes-1.3 | 118 - Mac/Relnotes-source | 75 - Mac/Resources/appletbundle.rsrc.hqx | 119 - Mac/Resources/bundle.rsrc.hqx | 244 - Mac/Resources/dialogs.rsrc.hqx | 60 - Mac/Resources/errors.rsrc.hqx | 596 -- Mac/Resources/pythonpath.rsrc.hqx | 11 - Mac/USING | 131 - Mac/Unsupported/mactcp/dnrglue.c | 301 - Mac/Unsupported/mactcp/macdnrmodule.c | 459 -- Mac/Unsupported/mactcp/mactcpmodule.c | 990 ---- Mac/Unsupported/mactcp/mactcpmodules.mu.hqx | 188 - Mac/Unsupported/mactcp/tcpglue.c | 477 -- Mac/Unsupported/mactcp/tcpglue.h | 68 - Mac/Unsupported/stdwinmodule.mu.hqx | 150 - Mac/errno_unix.h | 18 - Mac/fopenRF.c | 336 -- Mac/mkapplet.py | 257 - Mac/mwerks/errno_unix.h | 18 - Mac/mwerks/macuseshlstart.c | 29 - 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 | 10 - Mac/mwerks/mwerks_plugin_config.h | 1 - Mac/mwerks/mwerks_shared_config.h | 7 - Mac/mwerks/mwerks_shlib_config.h | 3 - Mac/mwerks/mwerksglue.c | 166 - Mac/mwerks/mwfopenrf.c | 50 - Mac/mwerks/old/mwerks_cfm68k_config.h | 2 - Mac/mwerks/old/mwerks_nsgusi_config.h | 11 - Mac/mwerks/old/mwerks_tk_config.h | 5 - Mac/mwerks/projects/MWCRuntime-Python.mu.hqx | 101 - Mac/mwerks/projects/PlugIns/_tkinter.ppc.mu.hqx | 210 - Mac/mwerks/projects/PlugIns/ctb.ppc.mu.hqx | 148 - Mac/mwerks/projects/PlugIns/imgmodules.ppc.mu.hqx | 256 - Mac/mwerks/projects/PlugIns/macspeech.ppc.mu.hqx | 146 - .../projects/PlugIns/toolboxmodules.ppc.mu.hqx | 281 - Mac/mwerks/projects/PlugIns/xx.ppc.mu.hqx | 121 - Mac/mwerks/projects/Python68Kgusi.mu.hqx | 1025 ---- Mac/mwerks/projects/PythonPPCgusi.mu.hqx | 1029 ---- Mac/mwerks/projects/PythonPPCstandalone.mu.hqx | 1154 ---- Mac/mwerks/projects/PythonPPCtk.mu.hqx | 820 --- Mac/mwerks/projects/README-Projectfiles | 24 - .../projects/build.mac68k.stand/Python68K.mu.hqx | 1128 ---- .../build.macppc.shared/PythonAppletPPC.mu.hqx | 103 - .../build.macppc.shared/PythonCorePPC.mu.hqx | 789 --- .../projects/build.macppc.shared/PythonPPC.mu.hqx | 104 - Mac/mwerks/projects/miniPythonCFM68K.mu.hqx | 861 --- Mac/mwerksglue.c | 43 - Mac/scripts/BuildApplet.py | 300 - Mac/scripts/BuildApplet.rsrc.hqx | 37 - Mac/scripts/ConfigurePython.py | 135 - Mac/scripts/ConfigurePython.rsrc.hqx | 44 - Mac/scripts/EditPythonPrefs.py | 168 - Mac/scripts/EditPythonPrefs.rsrc.hqx | 51 - Mac/scripts/MkDistr.py | 280 - Mac/scripts/MkDistr.rsrc.hqx | 31 - Mac/scripts/MkDistr_ui.py | 346 -- Mac/scripts/MkPluginAliases.as | 79 - Mac/scripts/PackLibDir.py | 89 - Mac/scripts/PackLibDir.rsrc.hqx | 38 - Mac/scripts/RunLibScript.py | 111 - Mac/scripts/RunLibScript.rsrc.hqx | 54 - Mac/scripts/binhextree.py | 156 - Mac/scripts/crlf.py | 29 - Mac/scripts/fixfiletypes.py | 50 - Mac/scripts/fullbuild.py | 104 - 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 | 2058 ------- Python/pythonmain.c | 211 - Tools/world/world | 143 - 192 files changed, 46406 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/example1/InterslipControl-1.py delete mode 100644 Mac/Demo/example1/InterslipControl-1.rsrc.hqx 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/interslip/InterslipLib.c delete mode 100644 Mac/Demo/interslip/InterslipLib.h delete mode 100644 Mac/Demo/interslip/interslipmodule.c delete mode 100644 Mac/Demo/quicktime/MovieInWindow.py delete mode 100644 Mac/Demo/quicktime/VerySimplePlayer.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/speech/SCRIPT delete mode 100644 Mac/Demo/speech/grail.py delete mode 100644 Mac/Demo/speech/hum.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/test/cmtest.py delete mode 100644 Mac/Lib/test/ctbtest.py delete mode 100644 Mac/Lib/toolbox/Components.py delete mode 100644 Mac/Lib/toolbox/Fonts.py delete mode 100644 Mac/Lib/toolbox/QuickTime.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/cm/Cmgen.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/fm/Fmgen.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/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/qt/Qtmodule.c delete mode 100644 Mac/Modules/qt/qtgen.py delete mode 100644 Mac/Modules/qt/qtscan.py delete mode 100644 Mac/Modules/qt/qtsupport.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/README 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-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/pythonpath.rsrc.hqx delete mode 100644 Mac/USING 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.hqx delete mode 100644 Mac/Unsupported/mactcp/tcpglue.c delete mode 100644 Mac/Unsupported/mactcp/tcpglue.h 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/mwerksglue.c 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_tk_config.h delete mode 100644 Mac/mwerks/projects/MWCRuntime-Python.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/_tkinter.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/ctb.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/imgmodules.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/macspeech.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/toolboxmodules.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/PlugIns/xx.ppc.mu.hqx delete mode 100644 Mac/mwerks/projects/Python68Kgusi.mu.hqx delete mode 100644 Mac/mwerks/projects/PythonPPCgusi.mu.hqx delete mode 100644 Mac/mwerks/projects/PythonPPCstandalone.mu.hqx delete mode 100644 Mac/mwerks/projects/PythonPPCtk.mu.hqx delete mode 100644 Mac/mwerks/projects/README-Projectfiles delete mode 100644 Mac/mwerks/projects/build.mac68k.stand/Python68K.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.hqx delete mode 100644 Mac/mwerks/projects/build.macppc.shared/PythonPPC.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/MkDistr.py delete mode 100644 Mac/scripts/MkDistr.rsrc.hqx delete mode 100644 Mac/scripts/MkDistr_ui.py delete mode 100644 Mac/scripts/MkPluginAliases.as 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/fixfiletypes.py delete mode 100644 Mac/scripts/fullbuild.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 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 a84a7d5267..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() - - 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() - - 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 5d009641c7..0000000000 --- a/Mac/Demo/PICTbrowse/PICTbrowse.rsrc.hqx +++ /dev/null @@ -1,11 +0,0 @@ -(This file may be decompressed with BinHex 4.0) - -:$e"*3e4LFQphFf8ZFR0bB`"bFh*M8P0&4!%!N!F"P%(e!*!%!3!!!!%r!!!!2`!! -!&A4J4r`!2Vr!!$kr`!!qYJ!!2VB!!$kf!!!qYJ!!2VrS!p35808BR*[Gh0P,R*c -FQ-#!!!!FR0bBe*6483"!*!&FR0bBe*6483"!*!%J!#3%Uc0"jX!N!B"P2m!!2Vr -!!$kf!!!qYJ!!2VB!!$kf!!!q[qJ!2Vr)2!!q[m!!2Vr!!$kf"8!!2VB!!$kf!!! -%rVB!!$krb!+)!XJ$!'J!#!'X4!8q!$kr`!!qYJ!!2VB!!$kf!!!qYJ!!2VB!!$k -r`!!q[m!!2Vrq!$kra!Q!!$krm!!q[m`q!$kr`#3""8!3!!3!43!a3!!!3!"!*!& -!J#3"5)!!3#3"38!#J#M!+`!N!Hd!$`!b!"f"!46D'ph!!!"!!!!!6m!!!!r!!!! -93$`,136H!!!!"`!4J!"4%a24`!!!"*%594-!!!!(J)!N!X#!2rr!!!!'3#3"!j# -FQphFf9b)(GTEQ4[Gcf!: diff --git a/Mac/Demo/PICTbrowse/PICTbrowse2.py b/Mac/Demo/PICTbrowse/PICTbrowse2.py deleted file mode 100644 index deffba693c..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() - - 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() - - 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/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 d2c937f646..0000000000 --- a/Mac/Demo/example1/InterslipControl-1.rsrc.hqx +++ /dev/null @@ -1,13 +0,0 @@ -(This file must be converted with BinHex 4.0) -:&dPZG'9bFfaTF%0[ER4bEf`Y-5jbFh*M!(*cFQ058d9%!*!)!LIr03#3"!%!N!- -"``#3!m-!N!0NCQBd4$9%-%3a4$*%-a*QCM-c0%8e46"&-88b46-5CQBA5@jdCA* -cE'P`3fpZG(*[E#da,R*cFQ-#!*!$FR0bB`!!FR0bBe*6483"!!"R!(S!N"+X``N -h!*!'!LFcN!3d)!!e)!!`)!!a)!!b)!!c%M-c!!!d)!%e)!%`)!%a)!%b)!%c5b@ -U5bQU5bUU5bZU5bbU5bfU5bkU5bp,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!!N!-9!'!!-J$ -!!C)!!3%!!3#3"3)!N!@Q!!F!N!8m!!S!8!"@"!G$EfjZC@0d!*!'2!"D!&!!V`3 -+4'PcBfpZEQ9MG!#3"6`!Y!"3!4F%$99`C'&dC5"cG'&dGA-!N!Bm!5)!8!&@"!4 -4G@Pd!*!&#J"D!"S"9BJ!N!BH!&S!,J&@L!#3"JS!#J!D!&@)"e0dBA4eFcTK!*! -&(J!+!#i!9BJ)6@9cFf&RC6S!!!%!N!-"``#3!m-!N!0N!2!Xe"2@!*!$(!"'!!& -%6%p(!*!$%N4*9%`!N!-H!J#3#2!VV!)!!!m!N!-C!2!VE!j$EfjdFQpX)%4TB@a -[C`j$EfjdFQpX)'4TB@a[ChcP: diff --git a/Mac/Demo/example2/InterslipControl-2.py b/Mac/Demo/example2/InterslipControl-2.py deleted file mode 100644 index 661c4a4349..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): - "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 f940bf6214..0000000000 --- a/Mac/Demo/example2/InterslipControl-2.rsrc.hqx +++ /dev/null @@ -1,55 +0,0 @@ -(This file must be converted with BinHex 4.0) -:&dPZG'9bFfaTF%0[ER4bEf`Y-LjbFh*M!(*cFQ058d9%!*!)$2eid3#3"!%!N!- -,T!!!#U3!!!&CCQBd4$9%-%3a4$*%-a*QCM-c0%8e46"&-88b46-5CQBA5@jdCA* -cE'P`3fpZG(*[E#db,R*cFQ-#!!)!FR0bB`)!FR0bBe*6483"!!!d!)!!N"+X``N -h!*!'$2dcN!3d)!!e)!!`)!!a)!!b)!!c%M-c!!!d)!%e)!%`)!%a)!%b)!%c5b@ -U5bQU5bUU5bZU5bbU5bfU5bkU5bp,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!!N!-9!'B!KJ$ -&!GB!!!%!!3#3"3)!N!89!'!!E!%@!AJ!!3%!!3#3"3)"!*!%(&"C9'N!N!-"4P* -&4J#3"B"*3diM!*!&J!#3!`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%#(rm1"#hr!)JVIbp3+b9HS'PPS%"T*B#!Irq"!!!J!J!!%!3!!!J)!!!%%!! -!!L!!!!&!!*!$J!!!!3!!%!1!!!3(`!"%$q!!9Ir`!&(rq!"3rr`!82rq!"2rr`" -6rrq!4rrr`%rrrq"Irrr`Irrrq(rrrrcrN!2qIrq3!hrrrriIrrrm2rrrq$rrrr! -rrrrJIrrr`(rrri"rrrm!!$rq!!!Ir!!!$rJ!!!I`!!!$i!!!!F!!N!1!!*!$"!# -3%2m!N"2r!*!+r`$r!*!8r`#3"rm!+`$r!*!2r`#3!rm!N!Er!#Z3!`$r!*!1r`$ -r!2m!X*!%r`!VN!8!r`#3$Im!r`#3!l!!!,!VN!J!r`#3$2m!r`#3",#`qT!$+j! -(!2m!N![r!2m!N!5`X2U3!bZ3#!$r!*!-r`!!X*!'+j!+!2m!N!Rr!2m!!,#3"LZ -3#`$r!*!)r`#3!l#3#2SVN!Emrr`V!2m!N!Ir!!$rX*!)qLZ3"2Q*+j!$LIN!r`# -3"[m!r`#`N!MkqLZ3!iNVL5Z*+r`V!2m!N!Arr`#`N!Vk+b[m+j!(r#X!r`#3"2m -!+l#3#[SV+rmVL5Z*+iNVrbXV!2m!!2rr+bZ`N!VkqL[m+j!(r#Z3!`$r!!$rr,# -3$2SV+r`VL5Z*+iNVN!Er!2rrX*!-qLXVqBNVN!1*q5Z3"2Vr!*!%X*!-q[SVN!2 -mrr`VN!Akr`#3",!&X,!&X*!*qLZ3"rmV+rVr!*!&X!@`"E#`"E#3"rSVrb[rN!6 -jrrVr!*!'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[SVN!2kr`# -3%[rkN!JV+rVr!*!8rrU3"b[kr`#3&[rk+j!&q[m!N"MrqLZ3!rVr!*!DrrSVq[m -!N"crq[m!N"lr!*!4!J#3#!m!N!N2!*!&m2!!N!N2!*!$$``2!*!($`!2!*!$m-c -!m!#3"Jq3!`99A`c-c!m!N!B2$`!&!&c-N!2!m!#3"3m2!!"9hGc-N!-2!*!&$`m -!!&AGh-b3!m$`!*!&$`"9N!2-N!82!*!%$`m!9C!$c*!&`2!!N!-2!!99N!0Gc*! -$lq`2!*!$$`$e9C!$AFc-fXc+d2!!!!m2"9@3!ehFc+b3!q`2!!!2m&@3"Gc1c*! -$cX$`!!m-9C!&h-r+N!22c!m!rma9N!AGcXb3!ml-`2!2j9@3"9h-l+b3!mc-c`r -e9C!&AFcDc-VFc-h`!!99N!9Gh-c[l-c-h`!!89899C!%h-b3!rc0m!!!89&9&9@ -3!pcmrrrIh`#3!e&494&4&4AIhrrmrI!!!!9484898489A2c-c0m!N!-&89%9%9% -9&9h-c-h`!*!$"9@3"ehFc0m!N!RphC!$h-h`!*!*$pf3!pcI!*!,rFc-cI!!N!X -2h-cI!*!0rFh`!*!0$pm!N!r`!*!*!3#3"Im!N!2r!*!*r`$r!!$r!2m!N!cr!#X -!r`#3#[m!+j!$!2m!N!Er!,#3!bZ3"!$r!*!&rrm!X2Rj+j!%!2m!N!6r!,#3!bZ -3!rQ*+`$r!!$rrbZ`N!2j+bZ*q5Z3!rm!!2q`N!Aj+j!%qIm!N!5`N!Aj+rrrqIm -!N!5`"E!&X!@`q5[jr`#3"E#3"rRjr`#3#[rjN!2r!*!-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`!!8C!$AFh`!!"9N!0Gh`#3"IhGm!#3"3r -I!*!(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@0 -d!*!'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#"$Efj -dFQpXB3#3"@i!2!#$!1')&NTKBfXJ5Q&ZFf9Z,#"$9dNX)$%j168!N!1!!!%!!"! -#J!!%"%!!4!JJ!&A`%!"4)!J!81!%!&$!!J!6m!%!8r!!J%Ii$N"2q"%J9r`UN!" -[r%")6ra94-rq3%*rrLU"Iri4!Krr$J3Yr`#)+hm[8#XPAU"TCD"!D5@!J(rrJ3! -!)!)!!"!%!!!)#!!!""!!!!)J!!!"3!#3!i!!N!3"!*!$!3#3!`ZN!!!+T!!!!9N -!a!8%%Pi!N!-F!5B!#d4-6dF!!3"L4%P86!!"!(T#6N4-!*!$NNC548B!N!1H580 -1)`#3!kTTBf`i!*!$YQPME$3!N!2#D@0c1!#3!mjTBh-d!*!$fQPMFb-!N!2Q580 -26J#3!r*3@94T!*!$rJ)!N!X#!3!2!*!$'3#3"!)!rrm!!!Ne!*!%!J(rr`!!#E% -!N!@!rrm!N!-b!-3$U!#!rrm!N!05!-3#X!#!rrm!N!0G!-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)(*PFfpeFQ0PITS: diff --git a/Mac/Demo/imgbrowse/imgbrowse.py b/Mac/Demo/imgbrowse/imgbrowse.py deleted file mode 100644 index e498a06487..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), - 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, 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/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/quicktime/MovieInWindow.py b/Mac/Demo/quicktime/MovieInWindow.py deleted file mode 100644 index 8ff3b424de..0000000000 --- a/Mac/Demo/quicktime/MovieInWindow.py +++ /dev/null @@ -1,71 +0,0 @@ -"""MovieInWindow converted to python - -Jack Jansen, CWI, December 1995 -""" - -import addpack -addpack.addpack(':Tools:bgen:qt') -addpack.addpack(':Tools:bgen:qd') -addpack.addpack(':Tools:bgen:evt') -addpack.addpack(':Tools:bgen:win') -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 24c97fb53e..0000000000 --- a/Mac/Demo/quicktime/VerySimplePlayer.py +++ /dev/null @@ -1,97 +0,0 @@ -"""VerySimplePlayer converted to python - -Jack Jansen, CWI, December 1995 -""" - -import addpack -addpack.addpack(':Tools:bgen:qt') -addpack.addpack(':Tools:bgen:qd') -addpack.addpack(':Tools:bgen:evt') -addpack.addpack(':Tools:bgen:win') -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/scripting/Eudora_Suite.py b/Mac/Demo/scripting/Eudora_Suite.py deleted file mode 100644 index 7f209a567f..0000000000 --- a/Mac/Demo/scripting/Eudora_Suite.py +++ /dev/null @@ -1,363 +0,0 @@ -"""Suite Eudora Suite: Terms specific to Eudora -Level 1, version 1 - -Generated from Moes:Programma's:Eudora:Eudora Light -AETE/AEUT resource version 2/16, language 0, script 0 -""" - -import addpack -addpack.addpack('Tools') -addpack.addpack('bgen') -addpack.addpack('ae') - -import aetools -import MacOS - -_code = 'CSOm' - -_Enum_eSta = { - 'unread' : 'euS\001', # has not been read - 'already_read' : 'euS\002', # has been read - 'replied' : 'euS\003', # has been replied to - 'forwarded' : 'euS\010', # has been forwarded - 'redirected' : 'euS\004', # has been redirected - 'not_sendable' : 'euS\005', # cannot be sent - 'sendable' : 'euS\006', # can be sent - 'queued' : 'euS\007', # queued for delivery - 'sent' : 'euS\011', # has been sent - 'never_sent' : 'euS\012', # never was sent -} - -_Enum_eSig = { - 'none' : 'sig\000', # no signature - 'standard' : 'sig\001', # standard signature file - 'alternate' : 'sig\002', # alternate signature file -} - -_Enum_eAty = { - 'AppleDouble' : 'atc\000', # AppleDouble format - 'AppleSingle' : 'atc\001', # AppleSingle format - 'BinHex' : 'atc\002', # BinHex format - 'uuencode' : 'atc\003', # uuencode format -} - -_Enum_eNot = { - 'mail_arrives' : 'wArv', # mail arrival - 'mail_sent' : 'wSnt', # mail has been sent - 'will_connect' : 'wWCn', # eudora is about to connect to a mail server - 'has_connected' : 'wHCn', # eudora has finished talking to a mail server - 'has_manually_filtered' : 'mFil', # eudora has finished manually filtering messages - 'opens_filters' : 'wFil', # user has requested Eudora open the filter window -} - -class Eudora_Suite: - - _argmap_connect = { - 'sending' : 'eSen', - 'checking' : 'eChk', - 'waiting' : 'eIdl', - } - - def connect(self, _no_object=None, _attributes={}, **_arguments): - """connect: Connect to the mail server and transfer mail - Keyword argument sending: true to make eudora send queued messages - Keyword argument checking: true to make eudora check for mail - Keyword argument waiting: true to make eudora wait for idle time before checking - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'CSOm' - _subcode = 'eCon' - - aetools.keysubst(_arguments, self._argmap_connect) - 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_reply = { - 'quoting' : 'eQTx', - 'everyone' : 'eRAl', - 'self' : 'eSlf', - } - - def reply(self, _object, _attributes={}, **_arguments): - """reply: Reply to a message - Required argument: the message to reply to - Keyword argument quoting: true if you want to quote the original text in the reply - Keyword argument everyone: true if you want the reply to go to everyone who got the original - Keyword argument self: true if you want the reply to go to yourself, too - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the reply message - """ - _code = 'CSOm' - _subcode = 'eRep' - - aetools.keysubst(_arguments, self._argmap_reply) - _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 forward(self, _object, _attributes={}, **_arguments): - """forward: Forward a message - Required argument: the message to forward - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the forwarded message - """ - _code = 'CSOm' - _subcode = 'eFwd' - - 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 redirect(self, _object, _attributes={}, **_arguments): - """redirect: Redirect a message - Required argument: the message to redirect - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the redirected message - """ - _code = 'CSOm' - _subcode = 'eRdr' - - 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 send_again(self, _object, _attributes={}, **_arguments): - """send again: Send a message again - Required argument: the message to send again - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the message sent again - """ - _code = 'CSOm' - _subcode = 'eSav' - - 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_queue = { - '_for' : 'eWhn', - } - - def queue(self, _object, _attributes={}, **_arguments): - """queue: Queue a message to be sent - Required argument: the message to queue - Keyword argument _for: date to send the message, in seconds since 1904, UTC - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'CSOm' - _subcode = 'eQue' - - aetools.keysubst(_arguments, self._argmap_queue) - _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 unqueue(self, _object, _attributes={}, **_arguments): - """unqueue: Remove a message from the queue, so it wonÍt be sent - Required argument: the message to unqueue - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'CSOm' - _subcode = 'eUnQ' - - 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_attach_to = { - 'documents' : 'eDcl', - } - - def attach_to(self, _object, _attributes={}, **_arguments): - """attach to: Attach documents to a message - Required argument: the message to attach the documents to - Keyword argument documents: list of documents to attach - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'CSOm' - _subcode = 'eAtc' - - aetools.keysubst(_arguments, self._argmap_attach_to) - _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_start_notifying = { - 'when' : 'eWHp', - } - - def start_notifying(self, _object, _attributes={}, **_arguments): - """start notifying: Notify an application of things that happen - Required argument: an application to notify - Keyword argument when: what to notify the application of - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'CSOm' - _subcode = 'nIns' - - aetools.keysubst(_arguments, self._argmap_start_notifying) - _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_stop_notifying = { - 'when' : 'eWHp', - } - - def stop_notifying(self, _object, _attributes={}, **_arguments): - """stop notifying: Stop notifying applications of things that are happening - Required argument: an application currently being notified - Keyword argument when: the things no longer to notify it of - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'CSOm' - _subcode = 'nRem' - - aetools.keysubst(_arguments, self._argmap_stop_notifying) - _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_notice = { - 'occurrence' : 'eWHp', - 'messages' : 'eMLs', - } - - def notice(self, _no_object=None, _attributes={}, **_arguments): - """notice: Eudora sends this event to notify an application that something happened - Keyword argument occurrence: what happened - Keyword argument messages: of the messages involved - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'CSOm' - _subcode = 'eNot' - - aetools.keysubst(_arguments, self._argmap_notice) - if _no_object != None: raise TypeError, 'No direct arg expected' - - aetools.enumsubst(_arguments, 'eWHp', _Enum_eNot) - - _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 'mail folder' ('euMF') -- 'A folder containing mailboxes or other mail folders.' -# property 'name' ('pnam') 'itxt' -- 'the name' [] -# element 'euMB' as ['indx', 'name'] -# element 'euMF' as ['indx', 'name'] - -# Class 'mailbox' ('euMB') -- 'A mailbox.' -# property 'name' ('pnam') 'itxt' -- 'the name of the mail folder' [] -# property 'space wasted' ('euWS') 'long' -- 'the amount of waste space in the mailbox' [] -# property 'space required' ('euNS') 'long' -- 'the minimum amount of space required to hold the mailbox' [] -# property 'location' ('euFS') 'fss ' -- 'the file the mailbox is stored in' [] -# property 'toc location' ('eTFS') 'fss ' -- 'the file the table of contents is stored in' [] -# element 'euMS' as ['indx'] - -# Class 'message' ('euMS') -- 'A message' -# property 'body' ('eBod') 'TEXT' -- 'the body of the message' [mutable] -# property 'priority' ('euPY') 'long' -- 'the priority' [mutable] -# property 'label' ('eLbl') 'long' -- 'the index of the label' [mutable] -# property 'status' ('euST') 'eSta' -- 'the message status' [mutable enum] -# property 'sender' ('euSe') 'itxt' -- 'the sender as appearing in the message summary' [mutable] -# property 'date' ('euDa') 'itxt' -- 'the date as appearing in the message summary' [] -# property 'subject' ('euSu') 'itxt' -- 'the subject as appearing in the message summary' [mutable] -# property 'size' ('euSi') 'long' -- 'the size of the message' [] -# property 'outgoing' ('euOu') 'bool' -- 'is the message is outgoing?' [] -# property 'signature' ('eSig') 'eSig' -- 'which signature the message should have' [mutable enum] -# property 'QP' ('eMQP') 'bool' -- 'is Eudora allowed to encode text?' [mutable] -# property 'return receipt' ('eRRR') 'bool' -- 'is a return receipt is requested?' [mutable] -# property 'wrap' ('eWrp') 'bool' -- 'should the text be wrapped when sent?' [mutable] -# property 'tab expansion' ('eTab') 'bool' -- 'should tabs get expanded to spaces?' [mutable] -# property 'keep copy' ('eCpy') 'bool' -- 'should a copy should be kept after message is sent?' [mutable] -# property 'preserve macintosh info' ('eXTX') 'bool' -- 'should Macintosh information always be sent with attachments?' [mutable] -# property 'attachment encoding' ('eATy') 'eAty' -- 'the type of encoding to use for attachments' [mutable enum] -# property 'show all headers' ('eBla') 'bool' -- 'should all headers be visible?' [mutable] -# property 'transliteration table' ('eTbl') 'long' -- 'the resource id of the transliteration table' [mutable] -# property 'will be fetched' ('eWFh') 'bool' -- 'will the message be [re]fetched on next check?' [mutable] -# property 'will be deleted' ('eWDl') 'bool' -- 'will the message be deleted from server on next check?' [mutable] -# element 'euFd' as ['name'] - -# Class 'field' ('euFd') -- 'An RFC 822 header field in a message (field named "" is the body)' - -# Class 'setting' ('ePrf') -- "Eudora's settings" diff --git a/Mac/Demo/scripting/Standard_Suite.py b/Mac/Demo/scripting/Standard_Suite.py deleted file mode 100644 index cd11b9ddb4..0000000000 --- a/Mac/Demo/scripting/Standard_Suite.py +++ /dev/null @@ -1,277 +0,0 @@ -"""Suite Standard Suite: Common terms for most applications -Level 1, version 1 - -Generated from Moes:Programma's:Eudora:Eudora Light -AETE/AEUT resource version 2/16, language 0, script 0 -""" - -import addpack -addpack.addpack('Tools') -addpack.addpack('bgen') -addpack.addpack('ae') - -import aetools -import MacOS - -_code = 'CoRe' - -class Standard_Suite: - - def close(self, _object, _attributes={}, **_arguments): - """close: Close an object - Required argument: the object to close - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'core' - _subcode = 'clos' - - 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_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 'each' is optional in AppleScript - 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['----'] - - 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['----'] - - def get(self, _object, _attributes={}, **_arguments): - """get: Get the data for an object - Required argument: the object whose data is to be returned - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: the data from the object - """ - _code = 'core' - _subcode = 'getd' - - 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', - } - - def make(self, _no_object=None, _attributes={}, **_arguments): - """make: Make a new element - Keyword argument new: the class of the new element. Keyword 'new' is optional in AppleScript - Keyword argument at: the location at which to insert the element - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the new object - """ - _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 to a new location - Required argument: the object to move - Keyword argument to: the new location for the object - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the object 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['----'] - - _argmap_duplicate = { - 'to' : 'insh', - } - - def duplicate(self, _object, _attributes={}, **_arguments): - """duplicate: Make a duplicate object - Required argument: the object to move - Keyword argument to: the new location for the object - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: to the object after they have been moved - """ - _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['----'] - - def open(self, _object, _attributes={}, **_arguments): - """open: Open the specified object - 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 message - Required argument: the message 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 save(self, _object, _attributes={}, **_arguments): - """save: Save an object - Required argument: the composition message to save - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'core' - _subcode = 'save' - - 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 = { - 'to' : 'data', - } - - def set(self, _object, _attributes={}, **_arguments): - """set: Set an object's data - Required argument: the object to change - Keyword argument to: the new value - Keyword argument _attributes: AppleEvent attribute dictionary - """ - _code = 'core' - _subcode = 'setd' - - aetools.keysubst(_arguments, self._argmap_set) - _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 'version' ('vers') 'itxt' -- 'the version number' [] -# property 'selected text' ('eStx') 'TEXT' -- 'the text of the user\325s current selection' [] -# element 'euMF' as ['indx', 'name'] -# element 'ePrf' as ['indx'] diff --git a/Mac/Demo/scripting/testeudora.py b/Mac/Demo/scripting/testeudora.py deleted file mode 100644 index 4c83085475..0000000000 --- a/Mac/Demo/scripting/testeudora.py +++ /dev/null @@ -1,41 +0,0 @@ -"""A test program that allows us to control Eudora""" - -import sys -import addpack -addpack.addpack('Tools') -addpack.addpack('bgen') -addpack.addpack('ae') -import aetools -import Eudora_Suite -import Required_Suite -import MacOS - -class Eudora(aetools.TalkTo, Required_Suite.Required_Suite, \ - Eudora_Suite.Eudora_Suite): - """A class that can talk to Eudora""" - pass - -# The Creator signature of eudora: -SIGNATURE="????" - -def main(): - talker = Eudora(SIGNATURE) - while 1: - print 'get, put, quit (eudora) or exit (this program) ?' - line = sys.stdin.readline() - try: - if line[0] == 'g': - talker.connect(checking=1) - elif line[0] == 'p': - talker.connect(sending=1) - elif line[0] == 'q': - talker.quit() - elif line[0] == 'e': - break - except MacOS.Error, arg: - if arg[0] == -609: - print 'Connection invalid, is eudora running?' - else: - print 'Error, possibly ', arg[1] - -main() 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/Include/config.h b/Mac/Include/config.h deleted file mode 100644 index 4fd79ec857..0000000000 --- a/Mac/Include/config.h +++ /dev/null @@ -1,336 +0,0 @@ -/* config.h for Macintosh THINK C 6.0, CodeWarrior 4 and MPW 3.2. */ - -#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 9213f2f33f..0000000000 --- a/Mac/Include/macglue.h +++ /dev/null @@ -1,85 +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 - -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 */ - -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 4b353c5d98..0000000000 --- a/Mac/Include/pythonresources.h +++ /dev/null @@ -1,67 +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 - -/* 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 -*/ - -/* The STR# resource for sys.path initialization */ -#define PYTHONPATH_ID 128 - -/* The alis resource for locating the python home directory */ -#define PYTHONHOME_ID 128 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/toolbox/Components.py b/Mac/Lib/toolbox/Components.py deleted file mode 100644 index d211cecbb0..0000000000 --- a/Mac/Lib/toolbox/Components.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated from 'Sap:CodeWarrior7: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/Fonts.py b/Mac/Lib/toolbox/Fonts.py deleted file mode 100644 index ff1e62b932..0000000000 --- a/Mac/Lib/toolbox/Fonts.py +++ /dev/null @@ -1,32 +0,0 @@ -# Generated from 'flap:CodeWarrior: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/QuickTime.py b/Mac/Lib/toolbox/QuickTime.py deleted file mode 100644 index f4e0259c15..0000000000 --- a/Mac/Lib/toolbox/QuickTime.py +++ /dev/null @@ -1,234 +0,0 @@ -# Generated from 'Sap:CodeWarrior7: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/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/cm/Cmgen.py b/Mac/Modules/cm/Cmgen.py deleted file mode 100644 index f3b8991fa1..0000000000 --- a/Mac/Modules/cm/Cmgen.py +++ /dev/null @@ -1,158 +0,0 @@ -# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Components.h' - -f = Function(Component, 'RegisterComponentResource', - (ComponentResourceHandle, 'tr', InMode), - (short, 'global', InMode), -) -functions.append(f) - -f = Method(OSErr, 'UnregisterComponent', - (Component, 'aComponent', InMode), -) -c_methods.append(f) - -f = Function(Component, 'FindNextComponent', - (Component, 'aComponent', InMode), - (ComponentDescription, 'looking', InMode), -) -functions.append(f) - -f = Function(long, 'CountComponents', - (ComponentDescription, 'looking', InMode), -) -functions.append(f) - -f = Method(OSErr, 'GetComponentInfo', - (Component, 'aComponent', InMode), - (ComponentDescription, 'cd', OutMode), - (Handle, 'componentName', InMode), - (Handle, 'componentInfo', InMode), - (Handle, 'componentIcon', InMode), -) -c_methods.append(f) - -f = Function(long, 'GetComponentListModSeed', -) -functions.append(f) - -f = Method(ComponentInstance, 'OpenComponent', - (Component, 'aComponent', InMode), -) -c_methods.append(f) - -f = Method(OSErr, 'CloseComponent', - (ComponentInstance, 'aComponentInstance', InMode), -) -ci_methods.append(f) - -f = Method(OSErr, 'GetComponentInstanceError', - (ComponentInstance, 'aComponentInstance', InMode), -) -ci_methods.append(f) - -f = Method(long, 'ComponentFunctionImplemented', - (ComponentInstance, 'ci', InMode), - (short, 'ftnNumber', InMode), -) -ci_methods.append(f) - -f = Method(long, 'GetComponentVersion', - (ComponentInstance, 'ci', InMode), -) -ci_methods.append(f) - -f = Method(long, 'ComponentSetTarget', - (ComponentInstance, 'ci', InMode), - (ComponentInstance, 'target', InMode), -) -ci_methods.append(f) - -f = Method(void, 'SetComponentInstanceError', - (ComponentInstance, 'aComponentInstance', InMode), - (OSErr, 'theError', InMode), -) -ci_methods.append(f) - -f = Method(long, 'GetComponentRefcon', - (Component, 'aComponent', InMode), -) -c_methods.append(f) - -f = Method(void, 'SetComponentRefcon', - (Component, 'aComponent', InMode), - (long, 'theRefcon', InMode), -) -c_methods.append(f) - -f = Method(short, 'OpenComponentResFile', - (Component, 'aComponent', InMode), -) -c_methods.append(f) - -f = Function(OSErr, 'CloseComponentResFile', - (short, 'refnum', InMode), -) -functions.append(f) - -f = Method(Handle, 'GetComponentInstanceStorage', - (ComponentInstance, 'aComponentInstance', InMode), -) -ci_methods.append(f) - -f = Method(void, 'SetComponentInstanceStorage', - (ComponentInstance, 'aComponentInstance', InMode), - (Handle, 'theStorage', InMode), -) -ci_methods.append(f) - -f = Method(long, 'GetComponentInstanceA5', - (ComponentInstance, 'aComponentInstance', InMode), -) -ci_methods.append(f) - -f = Method(void, 'SetComponentInstanceA5', - (ComponentInstance, 'aComponentInstance', InMode), - (long, 'theA5', InMode), -) -ci_methods.append(f) - -f = Method(long, 'CountComponentInstances', - (Component, 'aComponent', InMode), -) -c_methods.append(f) - -f = Method(OSErr, 'SetDefaultComponent', - (Component, 'aComponent', InMode), - (short, 'flags', InMode), -) -c_methods.append(f) - -f = Function(ComponentInstance, 'OpenDefaultComponent', - (OSType, 'componentType', InMode), - (OSType, 'componentSubType', InMode), -) -functions.append(f) - -f = Method(Component, 'CaptureComponent', - (Component, 'capturedComponent', InMode), - (Component, 'capturingComponent', InMode), -) -c_methods.append(f) - -f = Method(OSErr, 'UncaptureComponent', - (Component, 'aComponent', InMode), -) -c_methods.append(f) - -f = Function(long, 'RegisterComponentResourceFile', - (short, 'resRefNum', InMode), - (short, 'global', InMode), -) -functions.append(f) - -f = Method(OSErr, 'GetComponentIconSuite', - (Component, 'aComponent', InMode), - (Handle, 'iconSuite', OutMode), -) -c_methods.append(f) - 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 d568a73e49..0000000000 --- a/Mac/Modules/cm/cmscan.py +++ /dev/null @@ -1,65 +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 - -LONG = "Components" -SHORT = "Cm" - -def main(): - input = "Components.h" - output = SHORT + "gen.py" - defsoutput = 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 2dc4f50fa2..0000000000 --- a/Mac/Modules/config.c +++ /dev/null @@ -1,232 +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_BGEN -extern void initAE(); -extern void initCm(); -extern void initCtl(); -extern void initDlg(); -extern void initEvt(); -extern void initFm(); -extern void initList(); -extern void initMenu(); -extern void initQd(); -extern void initQt(); -extern void initRes(); -extern void initSnd(); -extern void initWin(); -#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 -/* -- ADDMODULE MARKER 1 -- */ - -extern void PyMarshal_Init(); -extern void initimp(); - -struct { - char *name; - void (*initfunc)(); -} 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_BGEN - {"AE", initAE}, - {"Cm", initCm}, - {"Ctl", initCtl}, - {"Dlg", initDlg}, - {"Evt", initEvt}, - {"Fm", initFm}, - {"Menu", initMenu}, - {"List", initList}, - {"Qd", initQd}, - {"Qt", initQt}, - {"Snd", initSnd}, - {"Win", initWin}, - {"Res", initRes}, -#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 - -/* -- 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/fm/Fmgen.py b/Mac/Modules/fm/Fmgen.py deleted file mode 100644 index 7d9203f726..0000000000 --- a/Mac/Modules/fm/Fmgen.py +++ /dev/null @@ -1,84 +0,0 @@ -# Generated from 'flap:CodeWarrior:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Fonts.h' - -f = Function(void, 'InitFonts', -) -functions.append(f) - -f = Function(void, 'GetFontName', - (short, 'familyID', InMode), - (Str255, 'name', OutMode), -) -functions.append(f) - -f = Function(void, 'GetFNum', - (ConstStr255Param, 'name', InMode), - (short, 'familyID', OutMode), -) -functions.append(f) - -f = Function(Boolean, 'RealFont', - (short, 'fontNum', InMode), - (short, 'size', InMode), -) -functions.append(f) - -f = Function(void, 'SetFontLock', - (Boolean, 'lockFlag', InMode), -) -functions.append(f) - -f = Function(void, 'SetFScaleDisable', - (Boolean, 'fscaleDisable', InMode), -) -functions.append(f) - -f = Function(void, 'FontMetrics', - (FMetricRecPtr, 'theMetrics', OutMode), -) -functions.append(f) - -f = Function(void, 'SetFractEnable', - (Boolean, 'fractEnable', InMode), -) -functions.append(f) - -f = Function(short, 'GetDefFontSize', -) -functions.append(f) - -f = Function(Boolean, 'IsOutline', - (Point, 'numer', InMode), - (Point, 'denom', InMode), -) -functions.append(f) - -f = Function(void, 'SetOutlinePreferred', - (Boolean, 'outlinePreferred', InMode), -) -functions.append(f) - -f = Function(Boolean, 'GetOutlinePreferred', -) -functions.append(f) - -f = Function(void, 'SetPreserveGlyph', - (Boolean, 'preserveGlyph', InMode), -) -functions.append(f) - -f = Function(Boolean, 'GetPreserveGlyph', -) -functions.append(f) - -f = Function(OSErr, 'FlushFonts', -) -functions.append(f) - -f = Function(short, 'GetSysFont', -) -functions.append(f) - -f = Function(short, 'GetAppFont', -) -functions.append(f) - diff --git a/Mac/Modules/fm/Fmmodule.c b/Mac/Modules/fm/Fmmodule.c deleted file mode 100644 index ef264bca11..0000000000 --- a/Mac/Modules/fm/Fmmodule.c +++ /dev/null @@ -1,400 +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 *PMObj_New(PixMapHandle); -extern int PMObj_Convert(PyObject *, PixMapHandle *); - -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 adbb3dca69..0000000000 --- a/Mac/Modules/fm/fmscan.py +++ /dev/null @@ -1,46 +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 - -LONG = "Fonts" -SHORT = "Fm" - -def main(): - input = "Fonts.h" - output = SHORT + "gen.py" - defsoutput = 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/macfsmodule.c b/Mac/Modules/macfsmodule.c deleted file mode 100644 index 69725cccc8..0000000000 --- a/Mac/Modules/macfsmodule.c +++ /dev/null @@ -1,827 +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 "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); -} - -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}, - {"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 bf132a54a8..0000000000 --- a/Mac/Modules/macmodule.c +++ /dev/null @@ -1,595 +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 -#define macstat stat -#else -#include "macstat.h" -#endif - -#ifdef __MWERKS__ -/* For CodeWarrior 4 also define CW4 */ -#include -#else -#include -#endif - -#if defined(__MWERKS__) && defined(__powerc) -#define MALLOC_DEBUG -#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 */ - -int chdir PROTO((const char *path)); -char *getbootvol PROTO((void)); -char *getwd PROTO((char *)); -#ifdef USE_GUSI -int mkdir PROTO((const char *path)); -DIR * opendir PROTO((const char *)); -int closedir PROTO((DIR *)); -#else -int mkdir PROTO((const char *path, int mode)); -DIR * opendir PROTO((char *)); -void closedir PROTO((DIR *)); -#endif -struct dirent * readdir PROTO((DIR *)); -int rmdir PROTO((const char *path)); -int sync PROTO((void)); -#if defined(THINK_C) || defined(__SC__) || defined(USE_GUSI) -int unlink PROTO((char *)); -#else -int unlink PROTO((const char *)); -#endif - - - -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; -{ - return mac_1str(args, chdir); -} - -#ifndef CW4 -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 - if (res < 0) - return mac_error(); - INCREF(None); - return None; -} -#endif /* !__MWERKS__ */ - -#ifdef MPW - -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 /* MPW */ - -#ifndef __MWERKS__ -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 - res = getwd(path); - 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; -} - -#ifndef CW4 -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); -} -#endif /* !CW4 */ - -#ifdef USE_GUSI -/* GUSI mkdir doesn't accept the (dummy) mode. Grrr. */ -int _gusi_mkdir(name, mode) - char *name; - int mode; -{ - return mkdir(name); -} -#endif /* USE_GUSI */ - -static object * -mac_mkdir(self, args) - object *self; - object *args; -{ -#ifdef USE_GUSI - return mac_strint(args, _gusi_mkdir); -#else - return mac_strint(args, mkdir); -#endif -} - -#ifndef CW4 -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; -} -#endif /* !__MWERKS */ - -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); -} - -#ifndef CW4 -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); -} -#endif /* !__MWERKS__ */ - -#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}, -#ifndef CW4 - {"close", mac_close}, -#endif -#ifdef MPW - {"dup", mac_dup}, -#endif -#ifndef __MWERKS__ - {"fdopen", mac_fdopen}, -#endif - {"getbootvol", mac_getbootvol}, /* non-standard */ - {"getcwd", mac_getcwd}, - {"listdir", mac_listdir, 0}, -#ifndef CW4 - {"lseek", mac_lseek}, -#endif - {"mkdir", mac_mkdir}, -#ifndef CW4 - {"open", mac_open}, - {"read", mac_read}, -#endif - {"rename", mac_rename}, - {"rmdir", mac_rmdir}, - {"stat", mac_stat}, - {"xstat", mac_xstat}, - {"sync", mac_sync}, - {"unlink", mac_unlink}, -#ifndef CW4 - {"write", mac_write}, -#endif -#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 23d39611db..0000000000 --- a/Mac/Modules/macosmodule.c +++ /dev/null @@ -1,260 +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 - -static PyObject *MacOS_Error; /* Exception MacOS.Error */ - -#ifdef MPW -#define bufferIsSmall -607 /*error returns from Post and Accept */ -#endif - - -/*----------------------------------------------------------------------*/ -/* 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 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}, - {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/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/qtgen.py b/Mac/Modules/qt/qtgen.py deleted file mode 100644 index b10312e16b..0000000000 --- a/Mac/Modules/qt/qtgen.py +++ /dev/null @@ -1,1712 +0,0 @@ -# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Movies.h' - -f = Function(OSErr, 'EnterMovies', -) -functions.append(f) - -f = Function(void, 'ExitMovies', -) -functions.append(f) - -f = Function(OSErr, 'GetMoviesError', -) -functions.append(f) - -f = Function(void, 'ClearMoviesStickyError', -) -functions.append(f) - -f = Function(OSErr, 'GetMoviesStickyError', -) -functions.append(f) - -f = Method(void, 'MoviesTask', - (Movie, 'theMovie', InMode), - (long, 'maxMilliSecToUse', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'PrerollMovie', - (Movie, 'theMovie', InMode), - (TimeValue, 'time', InMode), - (Fixed, 'Rate', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'LoadMovieIntoRam', - (Movie, 'theMovie', InMode), - (TimeValue, 'time', InMode), - (TimeValue, 'duration', InMode), - (long, 'flags', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'LoadTrackIntoRam', - (Track, 'theTrack', InMode), - (TimeValue, 'time', InMode), - (TimeValue, 'duration', InMode), - (long, 'flags', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'LoadMediaIntoRam', - (Media, 'theMedia', InMode), - (TimeValue, 'time', InMode), - (TimeValue, 'duration', InMode), - (long, 'flags', InMode), -) -Media_methods.append(f) - -f = Method(void, 'SetMovieActive', - (Movie, 'theMovie', InMode), - (Boolean, 'active', InMode), -) -Movie_methods.append(f) - -f = Method(Boolean, 'GetMovieActive', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'StartMovie', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'StopMovie', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'GoToBeginningOfMovie', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'GoToEndOfMovie', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(Boolean, 'IsMovieDone', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(Boolean, 'GetMoviePreviewMode', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMoviePreviewMode', - (Movie, 'theMovie', InMode), - (Boolean, 'usePreview', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'ShowMoviePoster', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(TimeBase, 'GetMovieTimeBase', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(Track, 'GetNextTrackForCompositing', - (Movie, 'theMovie', InMode), - (Track, 'theTrack', InMode), -) -Movie_methods.append(f) - -f = Method(Track, 'GetPrevTrackForCompositing', - (Movie, 'theMovie', InMode), - (Track, 'theTrack', InMode), -) -Movie_methods.append(f) - -f = Method(PicHandle, 'GetMoviePict', - (Movie, 'theMovie', InMode), - (TimeValue, 'time', InMode), -) -Movie_methods.append(f) - -f = Method(PicHandle, 'GetTrackPict', - (Track, 'theTrack', InMode), - (TimeValue, 'time', InMode), -) -Track_methods.append(f) - -f = Method(PicHandle, 'GetMoviePosterPict', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'UpdateMovie', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'GetMovieBox', - (Movie, 'theMovie', InMode), - (Rect, 'boxRect', OutMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieBox', - (Movie, 'theMovie', InMode), - (Rect_ptr, 'boxRect', InMode), -) -Movie_methods.append(f) - -f = Method(RgnHandle, 'GetMovieDisplayClipRgn', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieDisplayClipRgn', - (Movie, 'theMovie', InMode), - (RgnHandle, 'theClip', InMode), -) -Movie_methods.append(f) - -f = Method(RgnHandle, 'GetMovieClipRgn', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieClipRgn', - (Movie, 'theMovie', InMode), - (RgnHandle, 'theClip', InMode), -) -Movie_methods.append(f) - -f = Method(RgnHandle, 'GetTrackClipRgn', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackClipRgn', - (Track, 'theTrack', InMode), - (RgnHandle, 'theClip', InMode), -) -Track_methods.append(f) - -f = Method(RgnHandle, 'GetMovieDisplayBoundsRgn', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(RgnHandle, 'GetTrackDisplayBoundsRgn', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(RgnHandle, 'GetMovieBoundsRgn', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(RgnHandle, 'GetTrackMovieBoundsRgn', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(RgnHandle, 'GetTrackBoundsRgn', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(PixMapHandle, 'GetTrackMatte', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackMatte', - (Track, 'theTrack', InMode), - (PixMapHandle, 'theMatte', InMode), -) -Track_methods.append(f) - -f = Function(void, 'DisposeMatte', - (PixMapHandle, 'theMatte', InMode), -) -functions.append(f) - -f = Function(Movie, 'NewMovie', - (long, 'flags', InMode), -) -functions.append(f) - -f = Method(OSErr, 'PutMovieIntoHandle', - (Movie, 'theMovie', InMode), - (Handle, 'publicMovie', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'PutMovieIntoDataFork', - (Movie, 'theMovie', InMode), - (short, 'fRefNum', InMode), - (long, 'offset', InMode), - (long, 'maxSize', InMode), -) -Movie_methods.append(f) - -f = Method(TimeScale, 'GetMovieTimeScale', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieTimeScale', - (Movie, 'theMovie', InMode), - (TimeScale, 'timeScale', InMode), -) -Movie_methods.append(f) - -f = Method(TimeValue, 'GetMovieDuration', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(Fixed, 'GetMovieRate', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieRate', - (Movie, 'theMovie', InMode), - (Fixed, 'rate', InMode), -) -Movie_methods.append(f) - -f = Method(Fixed, 'GetMoviePreferredRate', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMoviePreferredRate', - (Movie, 'theMovie', InMode), - (Fixed, 'rate', InMode), -) -Movie_methods.append(f) - -f = Method(short, 'GetMoviePreferredVolume', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMoviePreferredVolume', - (Movie, 'theMovie', InMode), - (short, 'volume', InMode), -) -Movie_methods.append(f) - -f = Method(short, 'GetMovieVolume', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieVolume', - (Movie, 'theMovie', InMode), - (short, 'volume', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'GetMoviePreviewTime', - (Movie, 'theMovie', InMode), - (TimeValue, 'previewTime', OutMode), - (TimeValue, 'previewDuration', OutMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMoviePreviewTime', - (Movie, 'theMovie', InMode), - (TimeValue, 'previewTime', InMode), - (TimeValue, 'previewDuration', InMode), -) -Movie_methods.append(f) - -f = Method(TimeValue, 'GetMoviePosterTime', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMoviePosterTime', - (Movie, 'theMovie', InMode), - (TimeValue, 'posterTime', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'GetMovieSelection', - (Movie, 'theMovie', InMode), - (TimeValue, 'selectionTime', OutMode), - (TimeValue, 'selectionDuration', OutMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieSelection', - (Movie, 'theMovie', InMode), - (TimeValue, 'selectionTime', InMode), - (TimeValue, 'selectionDuration', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieActiveSegment', - (Movie, 'theMovie', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'duration', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'GetMovieActiveSegment', - (Movie, 'theMovie', InMode), - (TimeValue, 'startTime', OutMode), - (TimeValue, 'duration', OutMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMovieTimeValue', - (Movie, 'theMovie', InMode), - (TimeValue, 'newtime', InMode), -) -Movie_methods.append(f) - -f = Method(UserData, 'GetMovieUserData', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(long, 'GetMovieTrackCount', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(Track, 'GetMovieTrack', - (Movie, 'theMovie', InMode), - (long, 'trackID', InMode), -) -Movie_methods.append(f) - -f = Method(Track, 'GetMovieIndTrack', - (Movie, 'theMovie', InMode), - (long, 'index', InMode), -) -Movie_methods.append(f) - -f = Method(Track, 'GetMovieIndTrackType', - (Movie, 'theMovie', InMode), - (long, 'index', InMode), - (OSType, 'trackType', InMode), - (long, 'flags', InMode), -) -Movie_methods.append(f) - -f = Method(long, 'GetTrackID', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(Movie, 'GetTrackMovie', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(Track, 'NewMovieTrack', - (Movie, 'theMovie', InMode), - (Fixed, 'width', InMode), - (Fixed, 'height', InMode), - (short, 'trackVolume', InMode), -) -Movie_methods.append(f) - -f = Method(Boolean, 'GetTrackEnabled', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackEnabled', - (Track, 'theTrack', InMode), - (Boolean, 'isEnabled', InMode), -) -Track_methods.append(f) - -f = Method(long, 'GetTrackUsage', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackUsage', - (Track, 'theTrack', InMode), - (long, 'usage', InMode), -) -Track_methods.append(f) - -f = Method(TimeValue, 'GetTrackDuration', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(TimeValue, 'GetTrackOffset', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackOffset', - (Track, 'theTrack', InMode), - (TimeValue, 'movieOffsetTime', InMode), -) -Track_methods.append(f) - -f = Method(short, 'GetTrackLayer', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackLayer', - (Track, 'theTrack', InMode), - (short, 'layer', InMode), -) -Track_methods.append(f) - -f = Method(Track, 'GetTrackAlternate', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackAlternate', - (Track, 'theTrack', InMode), - (Track, 'alternateT', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetAutoTrackAlternatesEnabled', - (Movie, 'theMovie', InMode), - (Boolean, 'enable', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SelectMovieAlternates', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(short, 'GetTrackVolume', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackVolume', - (Track, 'theTrack', InMode), - (short, 'volume', InMode), -) -Track_methods.append(f) - -f = Method(void, 'GetTrackDimensions', - (Track, 'theTrack', InMode), - (Fixed, 'width', OutMode), - (Fixed, 'height', OutMode), -) -Track_methods.append(f) - -f = Method(void, 'SetTrackDimensions', - (Track, 'theTrack', InMode), - (Fixed, 'width', InMode), - (Fixed, 'height', InMode), -) -Track_methods.append(f) - -f = Method(UserData, 'GetTrackUserData', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(Media, 'NewTrackMedia', - (Track, 'theTrack', InMode), - (OSType, 'mediaType', InMode), - (TimeScale, 'timeScale', InMode), - (Handle, 'dataRef', InMode), - (OSType, 'dataRefType', InMode), -) -Track_methods.append(f) - -f = Method(Media, 'GetTrackMedia', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(Track, 'GetMediaTrack', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(TimeScale, 'GetMediaTimeScale', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(void, 'SetMediaTimeScale', - (Media, 'theMedia', InMode), - (TimeScale, 'timeScale', InMode), -) -Media_methods.append(f) - -f = Method(TimeValue, 'GetMediaDuration', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(short, 'GetMediaLanguage', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(void, 'SetMediaLanguage', - (Media, 'theMedia', InMode), - (short, 'language', InMode), -) -Media_methods.append(f) - -f = Method(short, 'GetMediaQuality', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(void, 'SetMediaQuality', - (Media, 'theMedia', InMode), - (short, 'quality', InMode), -) -Media_methods.append(f) - -f = Method(void, 'GetMediaHandlerDescription', - (Media, 'theMedia', InMode), - (OSType, 'mediaType', OutMode), - (Str255, 'creatorName', InMode), - (OSType, 'creatorManufacturer', OutMode), -) -Media_methods.append(f) - -f = Method(UserData, 'GetMediaUserData', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(MediaHandler, 'GetMediaHandler', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaHandler', - (Media, 'theMedia', InMode), - (MediaHandlerComponent, 'mH', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'BeginMediaEdits', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'EndMediaEdits', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaDefaultDataRefIndex', - (Media, 'theMedia', InMode), - (short, 'index', InMode), -) -Media_methods.append(f) - -f = Method(void, 'GetMediaDataHandlerDescription', - (Media, 'theMedia', InMode), - (short, 'index', InMode), - (OSType, 'dhType', OutMode), - (Str255, 'creatorName', InMode), - (OSType, 'creatorManufacturer', OutMode), -) -Media_methods.append(f) - -f = Method(DataHandler, 'GetMediaDataHandler', - (Media, 'theMedia', InMode), - (short, 'index', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaDataHandler', - (Media, 'theMedia', InMode), - (short, 'index', InMode), - (DataHandlerComponent, 'dataHandler', InMode), -) -Media_methods.append(f) - -f = Function(Component, 'GetDataHandler', - (Handle, 'dataRef', InMode), - (OSType, 'dataHandlerSubType', InMode), - (long, 'flags', InMode), -) -functions.append(f) - -f = Method(long, 'GetMediaSampleDescriptionCount', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(void, 'GetMediaSampleDescription', - (Media, 'theMedia', InMode), - (long, 'index', InMode), - (SampleDescriptionHandle, 'descH', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaSampleDescription', - (Media, 'theMedia', InMode), - (long, 'index', InMode), - (SampleDescriptionHandle, 'descH', InMode), -) -Media_methods.append(f) - -f = Method(long, 'GetMediaSampleCount', - (Media, 'theMedia', InMode), -) -Media_methods.append(f) - -f = Method(void, 'SampleNumToMediaTime', - (Media, 'theMedia', InMode), - (long, 'logicalSampleNum', InMode), - (TimeValue, 'sampleTime', OutMode), - (TimeValue, 'sampleDuration', OutMode), -) -Media_methods.append(f) - -f = Method(void, 'MediaTimeToSampleNum', - (Media, 'theMedia', InMode), - (TimeValue, 'time', InMode), - (long, 'sampleNum', OutMode), - (TimeValue, 'sampleTime', OutMode), - (TimeValue, 'sampleDuration', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'AddMediaSample', - (Media, 'theMedia', InMode), - (Handle, 'dataIn', InMode), - (long, 'inOffset', InMode), - (unsigned_long, 'size', InMode), - (TimeValue, 'durationPerSample', InMode), - (SampleDescriptionHandle, 'sampleDescriptionH', InMode), - (long, 'numberOfSamples', InMode), - (short, 'sampleFlags', InMode), - (TimeValue, 'sampleTime', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'AddMediaSampleReference', - (Media, 'theMedia', InMode), - (long, 'dataOffset', InMode), - (unsigned_long, 'size', InMode), - (TimeValue, 'durationPerSample', InMode), - (SampleDescriptionHandle, 'sampleDescriptionH', InMode), - (long, 'numberOfSamples', InMode), - (short, 'sampleFlags', InMode), - (TimeValue, 'sampleTime', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'GetMediaSample', - (Media, 'theMedia', InMode), - (Handle, 'dataOut', InMode), - (long, 'maxSizeToGrow', InMode), - (long, 'size', OutMode), - (TimeValue, 'time', InMode), - (TimeValue, 'sampleTime', OutMode), - (TimeValue, 'durationPerSample', OutMode), - (SampleDescriptionHandle, 'sampleDescriptionH', InMode), - (long, 'sampleDescriptionIndex', OutMode), - (long, 'maxNumberOfSamples', InMode), - (long, 'numberOfSamples', OutMode), - (short, 'sampleFlags', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'GetMediaSampleReference', - (Media, 'theMedia', InMode), - (long, 'dataOffset', OutMode), - (long, 'size', OutMode), - (TimeValue, 'time', InMode), - (TimeValue, 'sampleTime', OutMode), - (TimeValue, 'durationPerSample', OutMode), - (SampleDescriptionHandle, 'sampleDescriptionH', InMode), - (long, 'sampleDescriptionIndex', OutMode), - (long, 'maxNumberOfSamples', InMode), - (long, 'numberOfSamples', OutMode), - (short, 'sampleFlags', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaPreferredChunkSize', - (Media, 'theMedia', InMode), - (long, 'maxChunkSize', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'GetMediaPreferredChunkSize', - (Media, 'theMedia', InMode), - (long, 'maxChunkSize', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaShadowSync', - (Media, 'theMedia', InMode), - (long, 'frameDiffSampleNum', InMode), - (long, 'syncSampleNum', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'GetMediaShadowSync', - (Media, 'theMedia', InMode), - (long, 'frameDiffSampleNum', InMode), - (long, 'syncSampleNum', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'InsertMediaIntoTrack', - (Track, 'theTrack', InMode), - (TimeValue, 'trackStart', InMode), - (TimeValue, 'mediaTime', InMode), - (TimeValue, 'mediaDuration', InMode), - (Fixed, 'mediaRate', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'InsertTrackSegment', - (Track, 'srcTrack', InMode), - (Track, 'dstTrack', InMode), - (TimeValue, 'srcIn', InMode), - (TimeValue, 'srcDuration', InMode), - (TimeValue, 'dstIn', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'InsertMovieSegment', - (Movie, 'srcMovie', InMode), - (Movie, 'dstMovie', InMode), - (TimeValue, 'srcIn', InMode), - (TimeValue, 'srcDuration', InMode), - (TimeValue, 'dstIn', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'InsertEmptyTrackSegment', - (Track, 'dstTrack', InMode), - (TimeValue, 'dstIn', InMode), - (TimeValue, 'dstDuration', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'InsertEmptyMovieSegment', - (Movie, 'dstMovie', InMode), - (TimeValue, 'dstIn', InMode), - (TimeValue, 'dstDuration', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'DeleteTrackSegment', - (Track, 'theTrack', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'duration', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'DeleteMovieSegment', - (Movie, 'theMovie', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'duration', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'ScaleTrackSegment', - (Track, 'theTrack', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'oldDuration', InMode), - (TimeValue, 'newDuration', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'ScaleMovieSegment', - (Movie, 'theMovie', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'oldDuration', InMode), - (TimeValue, 'newDuration', InMode), -) -Movie_methods.append(f) - -f = Method(Movie, 'CutMovieSelection', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(Movie, 'CopyMovieSelection', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'PasteMovieSelection', - (Movie, 'theMovie', InMode), - (Movie, 'src', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'AddMovieSelection', - (Movie, 'theMovie', InMode), - (Movie, 'src', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'ClearMovieSelection', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Function(OSErr, 'PasteHandleIntoMovie', - (Handle, 'h', InMode), - (OSType, 'handleType', InMode), - (Movie, 'theMovie', InMode), - (long, 'flags', InMode), - (ComponentInstance, 'userComp', InMode), -) -functions.append(f) - -f = Method(OSErr, 'PutMovieIntoTypedHandle', - (Movie, 'theMovie', InMode), - (Track, 'targetTrack', InMode), - (OSType, 'handleType', InMode), - (Handle, 'publicMovie', InMode), - (TimeValue, 'start', InMode), - (TimeValue, 'dur', InMode), - (long, 'flags', InMode), - (ComponentInstance, 'userComp', InMode), -) -Movie_methods.append(f) - -f = Method(Component, 'IsScrapMovie', - (Track, 'targetTrack', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'CopyTrackSettings', - (Track, 'srcTrack', InMode), - (Track, 'dstTrack', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'CopyMovieSettings', - (Movie, 'srcMovie', InMode), - (Movie, 'dstMovie', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'AddEmptyTrackToMovie', - (Track, 'srcTrack', InMode), - (Movie, 'dstMovie', InMode), - (Handle, 'dataRef', InMode), - (OSType, 'dataRefType', InMode), - (Track, 'dstTrack', OutMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'AddTrackReference', - (Track, 'theTrack', InMode), - (Track, 'refTrack', InMode), - (OSType, 'refType', InMode), - (long, 'addedIndex', OutMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'DeleteTrackReference', - (Track, 'theTrack', InMode), - (OSType, 'refType', InMode), - (long, 'index', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'SetTrackReference', - (Track, 'theTrack', InMode), - (Track, 'refTrack', InMode), - (OSType, 'refType', InMode), - (long, 'index', InMode), -) -Track_methods.append(f) - -f = Method(Track, 'GetTrackReference', - (Track, 'theTrack', InMode), - (OSType, 'refType', InMode), - (long, 'index', InMode), -) -Track_methods.append(f) - -f = Method(OSType, 'GetNextTrackReferenceType', - (Track, 'theTrack', InMode), - (OSType, 'refType', InMode), -) -Track_methods.append(f) - -f = Method(long, 'GetTrackReferenceCount', - (Track, 'theTrack', InMode), - (OSType, 'refType', InMode), -) -Track_methods.append(f) - -f = Method(OSErr, 'ConvertMovieToFile', - (Movie, 'theMovie', InMode), - (Track, 'onlyTrack', InMode), - (FSSpec_ptr, 'outputFile', InMode), - (OSType, 'fileType', InMode), - (OSType, 'creator', InMode), - (ScriptCode, 'scriptTag', InMode), - (short, 'resID', OutMode), - (long, 'flags', InMode), - (ComponentInstance, 'userComp', InMode), -) -Movie_methods.append(f) - -f = Function(TimeValue, 'TrackTimeToMediaTime', - (TimeValue, 'value', InMode), - (Track, 'theTrack', InMode), -) -functions.append(f) - -f = Method(Fixed, 'GetTrackEditRate', - (Track, 'theTrack', InMode), - (TimeValue, 'atTime', InMode), -) -Track_methods.append(f) - -f = Method(long, 'GetMovieDataSize', - (Movie, 'theMovie', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'duration', InMode), -) -Movie_methods.append(f) - -f = Method(long, 'GetTrackDataSize', - (Track, 'theTrack', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'duration', InMode), -) -Track_methods.append(f) - -f = Method(long, 'GetMediaDataSize', - (Media, 'theMedia', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'duration', InMode), -) -Media_methods.append(f) - -f = Method(Boolean, 'PtInMovie', - (Movie, 'theMovie', InMode), - (Point, 'pt', InMode), -) -Movie_methods.append(f) - -f = Method(Boolean, 'PtInTrack', - (Track, 'theTrack', InMode), - (Point, 'pt', InMode), -) -Track_methods.append(f) - -f = Method(void, 'SetMovieLanguage', - (Movie, 'theMovie', InMode), - (long, 'language', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'GetUserData', - (UserData, 'theUserData', InMode), - (Handle, 'data', InMode), - (OSType, 'udType', InMode), - (long, 'index', InMode), -) -UserData_methods.append(f) - -f = Method(OSErr, 'AddUserData', - (UserData, 'theUserData', InMode), - (Handle, 'data', InMode), - (OSType, 'udType', InMode), -) -UserData_methods.append(f) - -f = Method(OSErr, 'RemoveUserData', - (UserData, 'theUserData', InMode), - (OSType, 'udType', InMode), - (long, 'index', InMode), -) -UserData_methods.append(f) - -f = Method(short, 'CountUserDataType', - (UserData, 'theUserData', InMode), - (OSType, 'udType', InMode), -) -UserData_methods.append(f) - -f = Method(long, 'GetNextUserDataType', - (UserData, 'theUserData', InMode), - (OSType, 'udType', InMode), -) -UserData_methods.append(f) - -f = Method(OSErr, 'AddUserDataText', - (UserData, 'theUserData', InMode), - (Handle, 'data', InMode), - (OSType, 'udType', InMode), - (long, 'index', InMode), - (short, 'itlRegionTag', InMode), -) -UserData_methods.append(f) - -f = Method(OSErr, 'GetUserDataText', - (UserData, 'theUserData', InMode), - (Handle, 'data', InMode), - (OSType, 'udType', InMode), - (long, 'index', InMode), - (short, 'itlRegionTag', InMode), -) -UserData_methods.append(f) - -f = Method(OSErr, 'RemoveUserDataText', - (UserData, 'theUserData', InMode), - (OSType, 'udType', InMode), - (long, 'index', InMode), - (short, 'itlRegionTag', InMode), -) -UserData_methods.append(f) - -f = Function(OSErr, 'NewUserData', - (UserData, 'theUserData', OutMode), -) -functions.append(f) - -f = Function(OSErr, 'NewUserDataFromHandle', - (Handle, 'h', InMode), - (UserData, 'theUserData', OutMode), -) -functions.append(f) - -f = Method(OSErr, 'PutUserDataIntoHandle', - (UserData, 'theUserData', InMode), - (Handle, 'h', InMode), -) -UserData_methods.append(f) - -f = Method(void, 'GetMediaNextInterestingTime', - (Media, 'theMedia', InMode), - (short, 'interestingTimeFlags', InMode), - (TimeValue, 'time', InMode), - (Fixed, 'rate', InMode), - (TimeValue, 'interestingTime', OutMode), - (TimeValue, 'interestingDuration', OutMode), -) -Media_methods.append(f) - -f = Method(void, 'GetTrackNextInterestingTime', - (Track, 'theTrack', InMode), - (short, 'interestingTimeFlags', InMode), - (TimeValue, 'time', InMode), - (Fixed, 'rate', InMode), - (TimeValue, 'interestingTime', OutMode), - (TimeValue, 'interestingDuration', OutMode), -) -Track_methods.append(f) - -f = Method(void, 'GetMovieNextInterestingTime', - (Movie, 'theMovie', InMode), - (short, 'interestingTimeFlags', InMode), - (short, 'numMediaTypes', InMode), - (OSType_ptr, 'whichMediaTypes', InMode), - (TimeValue, 'time', InMode), - (Fixed, 'rate', InMode), - (TimeValue, 'interestingTime', OutMode), - (TimeValue, 'interestingDuration', OutMode), -) -Movie_methods.append(f) - -f = Function(OSErr, 'CreateMovieFile', - (FSSpec_ptr, 'fileSpec', InMode), - (OSType, 'creator', InMode), - (ScriptCode, 'scriptTag', InMode), - (long, 'createMovieFileFlags', InMode), - (short, 'resRefNum', OutMode), - (Movie, 'newmovie', OutMode), -) -functions.append(f) - -f = Function(OSErr, 'OpenMovieFile', - (FSSpec_ptr, 'fileSpec', InMode), - (short, 'resRefNum', OutMode), - (SInt8, 'permission', InMode), -) -functions.append(f) - -f = Function(OSErr, 'CloseMovieFile', - (short, 'resRefNum', InMode), -) -functions.append(f) - -f = Function(OSErr, 'DeleteMovieFile', - (FSSpec_ptr, 'fileSpec', InMode), -) -functions.append(f) - -f = Function(OSErr, 'NewMovieFromFile', - (Movie, 'theMovie', OutMode), - (short, 'resRefNum', InMode), - (dummyshortptr, 'resId', InMode), - (dummyStringPtr, 'resName', InMode), - (short, 'newMovieFlags', InMode), - (Boolean, 'dataRefWasChanged', OutMode), -) -functions.append(f) - -f = Function(OSErr, 'NewMovieFromHandle', - (Movie, 'theMovie', OutMode), - (Handle, 'h', InMode), - (short, 'newMovieFlags', InMode), - (Boolean, 'dataRefWasChanged', OutMode), -) -functions.append(f) - -f = Function(OSErr, 'NewMovieFromDataFork', - (Movie, 'theMovie', OutMode), - (short, 'fRefNum', InMode), - (long, 'fileOffset', InMode), - (short, 'newMovieFlags', InMode), - (Boolean, 'dataRefWasChanged', OutMode), -) -functions.append(f) - -f = Method(OSErr, 'AddMovieResource', - (Movie, 'theMovie', InMode), - (short, 'resRefNum', InMode), - (short, 'resId', OutMode), - (ConstStr255Param, 'resName', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'UpdateMovieResource', - (Movie, 'theMovie', InMode), - (short, 'resRefNum', InMode), - (short, 'resId', InMode), - (ConstStr255Param, 'resName', InMode), -) -Movie_methods.append(f) - -f = Function(OSErr, 'RemoveMovieResource', - (short, 'resRefNum', InMode), - (short, 'resId', InMode), -) -functions.append(f) - -f = Method(Boolean, 'HasMovieChanged', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'ClearMovieChanged', - (Movie, 'theMovie', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'SetMovieDefaultDataRef', - (Movie, 'theMovie', InMode), - (Handle, 'dataRef', InMode), - (OSType, 'dataRefType', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'GetMovieDefaultDataRef', - (Movie, 'theMovie', InMode), - (Handle, 'dataRef', OutMode), - (OSType, 'dataRefType', OutMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'SetMovieColorTable', - (Movie, 'theMovie', InMode), - (CTabHandle, 'ctab', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'GetMovieColorTable', - (Movie, 'theMovie', InMode), - (CTabHandle, 'ctab', OutMode), -) -Movie_methods.append(f) - -f = Method(void, 'FlattenMovie', - (Movie, 'theMovie', InMode), - (long, 'movieFlattenFlags', InMode), - (FSSpec_ptr, 'theFile', InMode), - (OSType, 'creator', InMode), - (ScriptCode, 'scriptTag', InMode), - (long, 'createMovieFileFlags', InMode), - (short, 'resId', OutMode), - (ConstStr255Param, 'resName', InMode), -) -Movie_methods.append(f) - -f = Method(Movie, 'FlattenMovieData', - (Movie, 'theMovie', InMode), - (long, 'movieFlattenFlags', InMode), - (FSSpec_ptr, 'theFile', InMode), - (OSType, 'creator', InMode), - (ScriptCode, 'scriptTag', InMode), - (long, 'createMovieFileFlags', InMode), -) -Movie_methods.append(f) - -f = Function(HandlerError, 'GetVideoMediaGraphicsMode', - (MediaHandler, 'mh', InMode), - (long, 'graphicsMode', OutMode), - (RGBColor, 'opColor', OutMode), -) -functions.append(f) - -f = Function(HandlerError, 'SetVideoMediaGraphicsMode', - (MediaHandler, 'mh', InMode), - (long, 'graphicsMode', InMode), - (RGBColor_ptr, 'opColor', InMode), -) -functions.append(f) - -f = Function(HandlerError, 'GetSoundMediaBalance', - (MediaHandler, 'mh', InMode), - (short, 'balance', OutMode), -) -functions.append(f) - -f = Function(HandlerError, 'SetSoundMediaBalance', - (MediaHandler, 'mh', InMode), - (short, 'balance', InMode), -) -functions.append(f) - -f = Function(ComponentResult, 'FindNextText', - (MediaHandler, 'mh', InMode), - (Ptr, 'text', InMode), - (long, 'size', InMode), - (short, 'findFlags', InMode), - (TimeValue, 'startTime', InMode), - (TimeValue, 'foundTime', OutMode), - (TimeValue, 'foundDuration', OutMode), - (long, 'offset', OutMode), -) -functions.append(f) - -f = Method(OSErr, 'MovieSearchText', - (Movie, 'theMovie', InMode), - (Ptr, 'text', InMode), - (long, 'size', InMode), - (long, 'searchFlags', InMode), - (Track, 'searchTrack', OutMode), - (TimeValue, 'searchTime', OutMode), - (long, 'searchOffset', OutMode), -) -Movie_methods.append(f) - -f = Method(void, 'GetPosterBox', - (Movie, 'theMovie', InMode), - (Rect, 'boxRect', OutMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetPosterBox', - (Movie, 'theMovie', InMode), - (Rect_ptr, 'boxRect', InMode), -) -Movie_methods.append(f) - -f = Method(RgnHandle, 'GetMovieSegmentDisplayBoundsRgn', - (Movie, 'theMovie', InMode), - (TimeValue, 'time', InMode), - (TimeValue, 'duration', InMode), -) -Movie_methods.append(f) - -f = Method(RgnHandle, 'GetTrackSegmentDisplayBoundsRgn', - (Track, 'theTrack', InMode), - (TimeValue, 'time', InMode), - (TimeValue, 'duration', InMode), -) -Track_methods.append(f) - -f = Method(ComponentResult, 'GetTrackStatus', - (Track, 'theTrack', InMode), -) -Track_methods.append(f) - -f = Method(ComponentResult, 'GetMovieStatus', - (Movie, 'theMovie', InMode), - (Track, 'firstProblemTrack', OutMode), -) -Movie_methods.append(f) - -f = Method(MovieController, 'NewMovieController', - (Movie, 'theMovie', InMode), - (Rect_ptr, 'movieRect', InMode), - (long, 'someFlags', InMode), -) -Movie_methods.append(f) - -f = Method(OSErr, 'PutMovieOnScrap', - (Movie, 'theMovie', InMode), - (long, 'movieScrapFlags', InMode), -) -Movie_methods.append(f) - -f = Function(Movie, 'NewMovieFromScrap', - (long, 'newMovieFlags', InMode), -) -functions.append(f) - -f = Method(OSErr, 'GetMediaDataRef', - (Media, 'theMedia', InMode), - (short, 'index', InMode), - (Handle, 'dataRef', OutMode), - (OSType, 'dataRefType', OutMode), - (long, 'dataRefAttributes', OutMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaDataRef', - (Media, 'theMedia', InMode), - (short, 'index', InMode), - (Handle, 'dataRef', InMode), - (OSType, 'dataRefType', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'SetMediaDataRefAttributes', - (Media, 'theMedia', InMode), - (short, 'index', InMode), - (long, 'dataRefAttributes', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'AddMediaDataRef', - (Media, 'theMedia', InMode), - (short, 'index', OutMode), - (Handle, 'dataRef', InMode), - (OSType, 'dataRefType', InMode), -) -Media_methods.append(f) - -f = Method(OSErr, 'GetMediaDataRefCount', - (Media, 'theMedia', InMode), - (short, 'count', OutMode), -) -Media_methods.append(f) - -f = Method(void, 'SetMoviePlayHints', - (Movie, 'theMovie', InMode), - (long, 'flags', InMode), - (long, 'flagsMask', InMode), -) -Movie_methods.append(f) - -f = Method(void, 'SetMediaPlayHints', - (Media, 'theMedia', InMode), - (long, 'flags', InMode), - (long, 'flagsMask', InMode), -) -Media_methods.append(f) - -f = Method(void, 'SetTrackLoadSettings', - (Track, 'theTrack', InMode), - (TimeValue, 'preloadTime', InMode), - (TimeValue, 'preloadDuration', InMode), - (long, 'preloadFlags', InMode), - (long, 'defaultHints', InMode), -) -Track_methods.append(f) - -f = Method(void, 'GetTrackLoadSettings', - (Track, 'theTrack', InMode), - (TimeValue, 'preloadTime', OutMode), - (TimeValue, 'preloadDuration', OutMode), - (long, 'preloadFlags', OutMode), - (long, 'defaultHints', OutMode), -) -Track_methods.append(f) - -f = Method(ComponentResult, 'MCSetMovie', - (MovieController, 'mc', InMode), - (Movie, 'theMovie', InMode), - (WindowPtr, 'movieWindow', InMode), - (Point, 'where', InMode), -) -MovieController_methods.append(f) - -f = Method(Movie, 'MCGetIndMovie', - (MovieController, 'mc', InMode), - (short, 'index', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCRemoveMovie', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCIsPlayerEvent', - (MovieController, 'mc', InMode), - (EventRecord_ptr, 'e', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCDoAction', - (MovieController, 'mc', InMode), - (short, 'action', InMode), - (mcactionparams, 'params', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCSetControllerAttached', - (MovieController, 'mc', InMode), - (Boolean, 'attach', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCIsControllerAttached', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCSetVisible', - (MovieController, 'mc', InMode), - (Boolean, 'visible', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCGetVisible', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCGetControllerBoundsRect', - (MovieController, 'mc', InMode), - (Rect, 'bounds', OutMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCSetControllerBoundsRect', - (MovieController, 'mc', InMode), - (Rect_ptr, 'bounds', InMode), -) -MovieController_methods.append(f) - -f = Method(RgnHandle, 'MCGetControllerBoundsRgn', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(RgnHandle, 'MCGetWindowRgn', - (MovieController, 'mc', InMode), - (WindowPtr, 'w', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCMovieChanged', - (MovieController, 'mc', InMode), - (Movie, 'm', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCSetDuration', - (MovieController, 'mc', InMode), - (TimeValue, 'duration', InMode), -) -MovieController_methods.append(f) - -f = Method(TimeValue, 'MCGetCurrentTime', - (MovieController, 'mc', InMode), - (TimeScale, 'scale', OutMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCNewAttachedController', - (MovieController, 'mc', InMode), - (Movie, 'theMovie', InMode), - (WindowPtr, 'w', InMode), - (Point, 'where', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCDraw', - (MovieController, 'mc', InMode), - (WindowPtr, 'w', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCActivate', - (MovieController, 'mc', InMode), - (WindowPtr, 'w', InMode), - (Boolean, 'activate', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCIdle', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCKey', - (MovieController, 'mc', InMode), - (SInt8, 'key', InMode), - (long, 'modifiers', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCClick', - (MovieController, 'mc', InMode), - (WindowPtr, 'w', InMode), - (Point, 'where', InMode), - (long, 'when', InMode), - (long, 'modifiers', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCEnableEditing', - (MovieController, 'mc', InMode), - (Boolean, 'enabled', InMode), -) -MovieController_methods.append(f) - -f = Method(long, 'MCIsEditingEnabled', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(Movie, 'MCCopy', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(Movie, 'MCCut', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCPaste', - (MovieController, 'mc', InMode), - (Movie, 'srcMovie', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCClear', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCUndo', - (MovieController, 'mc', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCPositionController', - (MovieController, 'mc', InMode), - (Rect_ptr, 'movieRect', InMode), - (Rect_ptr, 'controllerRect', InMode), - (long, 'someFlags', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCGetControllerInfo', - (MovieController, 'mc', InMode), - (long, 'someFlags', OutMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCSetClip', - (MovieController, 'mc', InMode), - (RgnHandle, 'theClip', InMode), - (RgnHandle, 'movieClip', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCGetClip', - (MovieController, 'mc', InMode), - (RgnHandle, 'theClip', OutMode), - (RgnHandle, 'movieClip', OutMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCDrawBadge', - (MovieController, 'mc', InMode), - (RgnHandle, 'movieRgn', InMode), - (RgnHandle, 'badgeRgn', OutMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCSetUpEditMenu', - (MovieController, 'mc', InMode), - (long, 'modifiers', InMode), - (MenuHandle, 'mh', InMode), -) -MovieController_methods.append(f) - -f = Method(ComponentResult, 'MCGetMenuString', - (MovieController, 'mc', InMode), - (long, 'modifiers', InMode), - (short, 'item', InMode), - (Str255, 'aString', InMode), -) -MovieController_methods.append(f) - -f = Function(TimeBase, 'NewTimeBase', -) -functions.append(f) - -f = Method(void, 'SetTimeBaseValue', - (TimeBase, 'tb', InMode), - (TimeValue, 't', InMode), - (TimeScale, 's', InMode), -) -TimeBase_methods.append(f) - -f = Method(Fixed, 'GetTimeBaseRate', - (TimeBase, 'tb', InMode), -) -TimeBase_methods.append(f) - -f = Method(void, 'SetTimeBaseRate', - (TimeBase, 'tb', InMode), - (Fixed, 'r', InMode), -) -TimeBase_methods.append(f) - -f = Method(long, 'GetTimeBaseFlags', - (TimeBase, 'tb', InMode), -) -TimeBase_methods.append(f) - -f = Method(void, 'SetTimeBaseFlags', - (TimeBase, 'tb', InMode), - (long, 'timeBaseFlags', InMode), -) -TimeBase_methods.append(f) - -f = Method(TimeBase, 'GetTimeBaseMasterTimeBase', - (TimeBase, 'tb', InMode), -) -TimeBase_methods.append(f) - -f = Method(ComponentInstance, 'GetTimeBaseMasterClock', - (TimeBase, 'tb', InMode), -) -TimeBase_methods.append(f) - -f = Method(Fixed, 'GetTimeBaseEffectiveRate', - (TimeBase, 'tb', InMode), -) -TimeBase_methods.append(f) - diff --git a/Mac/Modules/qt/qtscan.py b/Mac/Modules/qt/qtscan.py deleted file mode 100644 index 020c48786c..0000000000 --- a/Mac/Modules/qt/qtscan.py +++ /dev/null @@ -1,112 +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 - -LONG = "QuickTime" -SHORT = "qt" -OBJECTS = ("Movie", "Track", "Media", "UserData", "TimeBase", "MovieController") - -def main(): - input = "Movies.h" - output = SHORT + "gen.py" - defsoutput = 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/Python/macapplet.c b/Mac/Python/macapplet.c deleted file mode 100644 index 47f3b02529..0000000000 --- a/Mac/Python/macapplet.c +++ /dev/null @@ -1,35 +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(); - -main() { - PyMac_InitApplet(); -} diff --git a/Mac/Python/macapplication.c b/Mac/Python/macapplication.c deleted file mode 100644 index 5d7bc830eb..0000000000 --- a/Mac/Python/macapplication.c +++ /dev/null @@ -1,41 +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(); - -main() { -#if defined(USE_GUSI) - GUSIDefaultSetup(); -#endif -#if defined(__MWERKS__) && defined(__CFM68K__) - printf("Hello, world!\n"); -#endif - PyMac_InitApplication(); -} diff --git a/Mac/Python/macgetargv.c b/Mac/Python/macgetargv.c deleted file mode 100644 index 90cdb5a698..0000000000 --- a/Mac/Python/macgetargv.c +++ /dev/null @@ -1,335 +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; - -#if defined(__MWERKS__) && defined(__CFM68K__) - return -1; /* get_folder_parent doesn't work */ -#endif - 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); - } - } -} - -/* 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 -} -/* Get the argv vector, return argc */ - -int -PyMac_GetArgv(pargv) - char ***pargv; -{ - init_mac_world(); - - 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 d93172b930..0000000000 --- a/Mac/Python/macgetcompiler.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Return a string representing the compiler name */ - -#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 * -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 d97dd4eb01..0000000000 --- a/Mac/Python/macgetpath.c +++ /dev/null @@ -1,265 +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 * -getpythonpath() -{ - /* 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; - extern char *PyMac_GetPythonDir(); -#ifndef USE_BUILTIN_PATH - extern 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 -*/ -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 -*/ -char * -PyMac_GetPythonDir() -{ - static char name[256]; - AliasHandle handle; - FSSpec dirspec; - Boolean modified = 0; - short oldrh, prefrh; - - /* - ** Remember old resource file and try to open preferences file - ** in the preferences folder. - */ - oldrh = CurResFile(); - 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); - } - 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 -char * -PyMac_GetPythonPath(dir) -char *dir; -{ - FSSpec dirspec; - short oldrh, prefrh = -1; - short prefdirRefNum; - long prefdirDirID; - char *rv; - int i, newlen; - Str255 pathitem; - - /* - ** 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"); - for(i=1; ; i++) { - GetIndString(pathitem, PYTHONPATH_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 { - /* 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 */ - diff --git a/Mac/Python/macgetplatform.c b/Mac/Python/macgetplatform.c deleted file mode 100644 index a4542143bc..0000000000 --- a/Mac/Python/macgetplatform.c +++ /dev/null @@ -1,7 +0,0 @@ - -char * -getplatform() -{ - return "mac"; -} - diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c deleted file mode 100644 index 23415eb8b5..0000000000 --- a/Mac/Python/macglue.c +++ /dev/null @@ -1,759 +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 "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 -#include -#ifdef THINK_C -#include /* For EvQElPtr */ -#endif -#ifdef __MWERKS__ -#include -#endif - -#ifndef HAVE_UNIVERSAL_HEADERS -#define GetResourceSizeOnDisk(x) SizeResource(x) -typedef DlgHookYDProcPtr DlgHookYDUPP; -#define NewDlgHookYDProc(userRoutine) ((DlgHookYDUPP) (userRoutine)) -typedef FileFilterYDProcPtr FileFilterYDUPP; -#endif - -#include -#include - -/* -** 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; - - -/* 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); -} - -/* 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; -{ -#if defined(__MWERKS__) && defined(__CFM68K__) - return; /* No GetEvQHdr yet */ -#else - register EvQElPtr q; - - q = (EvQElPtr) GetEvQHdr()->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; - } - } -#endif -} - -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 -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 ) { -#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 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); -} - -/* 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 f6b1dee4d9..0000000000 --- a/Mac/Python/macmain.c +++ /dev/null @@ -1,344 +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 - -#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 *getversion Py_PROTO((void)); -extern char *getcopyright Py_PROTO((void)); - - -/* For getprogramname(); set by main() */ -static char *argv0; - -/* For 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; - -#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; - -#ifdef USE_MAC_SHARED_LIBRARY - PyMac_AddLibResources(); -#endif -#ifdef USE_SIOUX - SIOUXSettings.asktosaveonclose = 0; - SIOUXSettings.showstatusline = 0; - SIOUXSettings.tabspaces = 4; -#endif - 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; - -#ifdef USE_MAC_SHARED_LIBRARY - PyMac_AddLibResources(); -#endif -#ifdef USE_SIOUX - SIOUXSettings.asktosaveonclose = 0; - SIOUXSettings.showstatusline = 0; - SIOUXSettings.tabspaces = 4; -#endif - 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); - } - } - 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) -{ - KeyMap rmap; - unsigned char *map; - short item, type; - ControlHandle handle; - DialogPtr dialog; - Rect rect; - - 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; - } - - /* Set keep-open-on-error */ - GetDialogItem(dialog, OPT_KEEPERROR, &type, (Handle *)&handle, &rect); - SetCtlValue(handle, *keep_error); - - while (1) { - handle = NULL; - ModalDialog(NULL, &item); - if ( item == OPT_OK ) - break; - if ( item == OPT_CANCEL ) { - DisposDialog(dialog); - exit(0); - } -#define OPT_ITEM(num, var) \ - if ( item == (num) ) { \ - *(var) = !*(var); \ - GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \ - SetCtlValue(handle, (short)*(var)); \ - } - - OPT_ITEM(OPT_INSPECT, inspect); - OPT_ITEM(OPT_VERBOSE, verbose); - OPT_ITEM(OPT_SUPPRESS, suppress_print); - OPT_ITEM(OPT_UNBUFFERED, unbuffered); - OPT_ITEM(OPT_DEBUGGING, debugging); - OPT_ITEM(OPT_KEEPNORMAL, keep_normal); - OPT_ITEM(OPT_KEEPERROR, keep_error); - -#undef OPT_ITEM - } - DisposDialog(dialog); -} -/* Main program */ - -int -Py_Main(argc, argv) - int argc; - char **argv; -{ - int sts; - char *command = NULL; - char *filename = NULL; - FILE *fp = stdin; - int inspect = 0; - int unbuffered = 0; - - orig_argc = argc; /* For getargcargv() */ - orig_argv = argv; - argv0 = argv[0]; /* For getprogramname() */ - - PyMac_InteractiveOptions(&inspect, &Py_VerboseFlag, &Py_SuppressPrintingFlag, - &unbuffered, &Py_DebugFlag, &keep_normal, &keep_error); - - if (unbuffered) { -#ifndef MPW - setbuf(stdout, (char *)NULL); - setbuf(stderr, (char *)NULL); -#else - /* On MPW (3.2) unbuffered seems to hang */ - setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ); - setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ); -#endif - } - - filename = argv[1]; - - if (Py_VerboseFlag || - command == NULL && filename == NULL && isatty((int)fileno(fp))) - fprintf(stderr, "Python %s\n%s\n", - getversion(), getcopyright()); - - if (filename != NULL) { - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "%s: can't open file '%s'\n", - argv[0], filename); - PyMac_Exit(2); - } - } - - Py_Initialize(); - - PySys_SetArgv(argc-1, argv+1); - - if (filename == NULL && isatty((int)fileno(fp))) { - FILE *fp = fopen(STARTUP, "r"); - if (fp != NULL) { - (void) PyRun_SimpleFile(fp, STARTUP); - PyErr_Clear(); - fclose(fp); - } - } - sts = PyRun_AnyFile( - fp, filename == NULL ? "" : 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 -*/ -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ÇterminatedÈ"); - } - 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 * -getprogramname() -{ - return argv0; -} - - -/* Make the *original* argc/argv available to other modules. - This is rare, but it is needed by the secureware extension. */ - -void -getargcargv(argc,argv) - int *argc; - char ***argv; -{ - *argc = orig_argc; - *argv = orig_argv; -} 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 aa4cfb78a6..0000000000 --- a/Mac/Python/macshlglue.c +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Mac shared lib glue. -*/ - -#include -#include -#include -#include -#include - -#ifdef __MWERKS__ -/* -** This part is copied from MW Startup.c, which is -** Copyright © 1993 metrowerks inc. All Rights Reserved. -*/ -#include -#include - -/* void *__local_destructor_chain; /* chain of local objects that need destruction */ - - /* public data */ - -QDGlobals qd; /* define the Quickdraw globals here! */ -jmp_buf __program_exit; /* exit() does a longjmp() to here */ -void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */ -void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */ -int __aborting; /* abort() sets this and longjmps to __program_exit */ -#endif - -/* -** 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 -PythonCore_init(InitBlockPtr data) -{ - 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/README b/Mac/README deleted file mode 100644 index f11e34339f..0000000000 --- a/Mac/README +++ /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/ReadMeOrSuffer b/Mac/ReadMeOrSuffer deleted file mode 100644 index 93cf29a1f1..0000000000 --- a/Mac/ReadMeOrSuffer +++ /dev/null @@ -1,124 +0,0 @@ -How to install Python 1.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. - -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. - -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. I don't fully understand yet why the mac freezes instead of doing -something a little less drastic. - -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 - try using the applescript in the PlugIns folder to create the aliases. - If that also fails: examine the script and create the aliases by hand - (and tell me what you did to make either of these two 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. -- RunLibScript allows you to run any script as __main__ after setting arguments, - changing stdin/stdout/workdir, etc. -- 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 "Read me files" 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. Especially the Relnotes-1.3 file contains some interesting -tidbits. - -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 Tools folder has all the (automatically generated) interfaces to toolboxes -available, and some simple test programs. See the scripts mentioned above for how -to use them. NOTE: the organization of the toolbox stuff is likely to change, -maybe even before the real 1.3 distribution. Until that time you will have to -use addpack or imp to import these files in your program. - -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 -