Change 18193: Add first phase of Carbon support to macperl/ext/.
[email protected] (Chris Nandor) Thu, 28 Nov 2002 16:44:22 -0500
| Newsgroups | perl.perl5.changes.mac |
|---|---|
| Message-ID | <p05200f1fba0c3e1c4e10@[10.0.1.104]> |
Change 18193 by pudge@pudge-mobile on 2002/11/28 03:20:15
Add first phase of Carbon support to macperl/ext/.
Covers Components, Files, Gestalt, Memory, MoreFiles, Notification,
Processes, Resources, Sound, Speech, Types, and the MacPerl module.
Support functions and docs in Carbon/. Added MoreFiles source.
Moved around and began to rewrite some test files.
Affected files ...
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/Carbon.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/Carbon.pm#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/MANIFEST#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/MANIFEST.SKIP#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/Makefile.PL#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/README#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/t/Carbon.t#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/typemap#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/xsubpps/xsubpp-5.6.1#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/xsubpps/xsubpp-5.8.0#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Components/Components.pm#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Components/Components.xs#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Components/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Components/eg/ListComponents.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Components/t/Components.t#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Components/t/ListComponents.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/Files/Files.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Files/Files.xs#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Files/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Files/t/Files.t#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/Gestalt.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/Gestalt.xs#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/t/Gestalt.t#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Memory/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Memory/Memory.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Memory/Memory.xs#5 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Memory/t/Memory.t#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MF.xs#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFiles.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/DirectoryCopy.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/DirectoryCopy.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/FSpCompat.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/FSpCompat.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/FileCopy.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/FileCopy.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/FullPath.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/FullPath.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/IterateDirectory.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/IterateDirectory.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/MoreDesktopMgr.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/MoreDesktopMgr.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/MoreFiles.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/MoreFiles.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/MoreFilesExtras.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/MoreFilesExtras.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/Optimization.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/OptimizationEnd.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/Search.c#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFilesSrc/Search.h#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/eg/Application.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/eg/Iterate.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/t/Application.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/t/Iterate.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/t/MoreFiles.t#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Notification/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Notification/Notification.pm#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Notification/Notification.xs#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Notification/t/Notification.t#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Processes/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Processes/Processes.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Processes/Processes.xs#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Processes/eg/Processes.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Processes/t/Processes.t#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Resources/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Resources/Resources.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Resources/Resources.xs#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Resources/t/Resources.t#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Sound/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Sound/Sound.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Sound/Sound.xs#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Sound/t/Scream.rsrc#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Sound/t/Scream.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/Sound/t/Sound.t#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/Speech.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/Speech.xs#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/Cellist.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/DumpVoices.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/JukeBox.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/Phonemes.plx#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/t/Cellist.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/t/DumpVoices.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/t/JukeBox.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/t/Phonemes.t#2 delete
.... //depot/maint-5.6/macperl/macos/ext/Mac/Speech/t/Speech.t#1 add
.... //depot/maint-5.6/macperl/macos/ext/Mac/Types/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Types/Types.pm#3 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Types/Types.xs#2 edit
.... //depot/maint-5.6/macperl/macos/ext/Mac/Types/t/Types.t#2 edit
.... //depot/maint-5.6/macperl/macos/ext/MacPerl/MacPerl.pm#4 edit
.... //depot/maint-5.6/macperl/macos/ext/MacPerl/MacPerl.xs#4 edit
.... //depot/maint-5.6/macperl/macos/ext/MacPerl/Makefile.PL#2 edit
.... //depot/maint-5.6/macperl/macos/ext/MacPerl/OSA.xs#4 edit
.... //depot/maint-5.6/macperl/macos/ext/MacPerl/t/MacPerl.t#1 add
Differences ...
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/Carbon.h#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/Carbon.h
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/Carbon.h Wed Nov 27 19:20:15 2002
@@ -0,0 +1,277 @@
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Carbon/Carbon.h,v 1.2 2002/11/14 12:47:58 pudge Exp $
+ *
+ * Copyright (c) 2002 Matthias Neeracher, Chris Nandor
+ *
+ * You may distribute under the terms of the Perl Artistic License,
+ * as specified in the README file.
+ *
+ * $Log: Carbon.h,v $
+ * Revision 1.2 2002/11/14 12:47:58 pudge
+ * Cast errno to short
+ *
+ * Revision 1.1 2002/11/13 02:04:50 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
+ *
+ */
+
+#ifndef _MAC_CARBON_H
+#define _MAC_CARBON_H
+
+# ifndef MACOS_TRADITIONAL /* ignore for Mac OS ... Mac OS X only */
+# ifdef MAC_CONTEXT
+
+/* Perl defines Move too */
+#undef Move
+#include <Events.h>
+#include <Dialogs.h>
+#include <Files.h>
+#include <Types.h>
+#include <ConditionalMacros.h>
+
+typedef OSErr MacOSRet;
+typedef Handle HandleRet;
+typedef Ptr RawPtr;
+typedef Ptr PtrRet;
+
+# endif /* MAC_CONTEXT */
+
+#define XS_PUSH_SHORT(ARG) ++sp;\
+ *sp = sv_newmortal();\
+ sv_setiv(*sp, (IV)(ARG) )
+
+#define XS_PUSH_OSTYPE(ARG) ++sp;\
+ *sp = sv_newmortal();\
+ sv_setpvn(*sp, (char *) &(ARG), 4)
+
+#define XS_PUSH_STR255(ARG) ++sp;\
+ *sp = sv_newmortal();\
+ sv_setpvn(*sp, ((char *) (ARG)) + 1, (ARG)[0])
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <errno.h>
+
+/* $! and $^E will both be set together, which is fine (for now?) */
+#define gMacPerl_OSErr (short)errno
+
+/* c string to pascal string */
+static StringPtr MacPerl_CopyC2P(const char * c, StringPtr p)
+{
+ memcpy(p+1, c, *p = strlen(c));
+
+ return p;
+}
+
+/* used by GUSIPath2FSp to decode a GUSIFSp2Encoding-ized FSSpec */
+static bool ReadHex(const char * path, int bytes, char * result)
+{
+ char hexbyte[3];
+ hexbyte[2] = 0;
+ while (bytes--) {
+ hexbyte[0] = *path++; hexbyte[1] = *path++;
+ if (isxdigit(hexbyte[0]) && isxdigit(hexbyte[1])) {
+ *result++ = (char) strtol(hexbyte, nil, 16);
+ } else {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+/* Mac OS and Unix have different epochs (see perlport).
+ * Mac OS is seconds since midnight Jan 1 1904 local time,
+ * Unix is seconds since midnight Jan 1 1970 UTC.
+ *
+ * These routines convert between the two, using Carbons
+ * calls to convert between local time and UTC (taking
+ * TZ and DST into account), and then adjusting with the
+ * known offset constant.
+ */
+
+#define MACOS_OFFSET 2082844800
+
+static UInt32 SecondsMac2Unix(UInt32 macseconds)
+{
+ UInt32 unixseconds;
+
+ ConvertLocalTimeToUTC(macseconds, &unixseconds);
+ unixseconds -= MACOS_OFFSET;
+
+ return unixseconds;
+}
+
+
+static UInt32 SecondsUnix2Mac(UInt32 unixseconds)
+{
+ UInt32 macseconds;
+
+ unixseconds += MACOS_OFFSET;
+ ConvertUTCToLocalTime(unixseconds, &macseconds);
+
+ return macseconds;
+}
+
+
+/* GUSI replacement routines. Currently, we use FS* functions
+ * to convert FSRefs to and from paths and FSSpecs, which works
+ * nicely, except that it only works for existing files.
+ *
+ * There is plenty of room for improvement:
+ *
+ * * Better error handling for odd cases
+ * * Alias resolving? Is that even necessary?
+ * * Using FSRef routines apparently means it is harder to allow
+ * use of filenames that don't exist ... do we care? Maybe for FindFolder() ...
+ * * Probably bugs to fix ...
+ *
+ */
+
+
+/* Returns full POSIX-style path from FSSpec */
+/* Returns empty string on failure, sets gMacPerl_OSErr to nonzero */
+static char * GUSIFSp2FullPath(const FSSpec * spec)
+{
+ FSRef ref;
+ UInt8 * path = NewPtr(2*PATH_MAX); // to be safe
+ UInt32 pathSize = 2*PATH_MAX;
+
+ if ( (gMacPerl_OSErr = FSpMakeFSRef(spec, &ref)) ) { // && (gMacPerl_OSErr != fnfErr) )
+ return "";
+ }
+
+ if (gMacPerl_OSErr = FSRefMakePath(&ref, path, pathSize))
+ return "";
+
+ return path;
+}
+
+/* Returns FSSpec from POSIX-style path, relative or absolute */
+/* or from GUSI-style FSSpec encoding (see GUSIFSp2Encoding) */
+static OSErr GUSIPath2FSp(const char * fileName, FSSpec * spec)
+{
+ FSRef ref;
+
+ // convert from GUSI-style FSSpec encoding (see GUSIFSp2Encoding)
+ if (*fileName == '\021' && fileName[13] == ':') {
+ spec->vRefNum = 0;
+ spec->parID = 0;
+
+ if (
+ !ReadHex(fileName+1, 2, (char *)&spec->vRefNum) || !ReadHex(fileName+5, 4, (char *)&spec->parID)
+ ) {
+ spec->vRefNum = 0;
+ spec->parID = 0;
+ } else {
+ fileName += 13;
+ }
+
+ Str255 path;
+ MacPerl_CopyC2P(fileName, path);
+
+ switch (gMacPerl_OSErr = FSMakeFSSpec(spec->vRefNum, spec->parID, path, spec)) {
+ case fnfErr: // It is OK if file does not exist
+ gMacPerl_OSErr = noErr;
+ return gMacPerl_OSErr;
+ default:
+ return gMacPerl_OSErr;
+ }
+ }
+
+ if (gMacPerl_OSErr = FSPathMakeRef((UInt8 *)fileName, &ref, NULL))
+ return gMacPerl_OSErr;
+
+ gMacPerl_OSErr = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL);
+ return gMacPerl_OSErr;
+}
+
+/* This returns the GUSI-specific text representation of an FSSpec */
+static char * GUSIFSp2Encoding(const FSSpec * spec)
+{
+ char * realSpec = NewPtr(255);
+ char fmt[32];
+
+ sprintf(fmt, "\021%%04hX%%08X:%%%d.%ds", *spec->name, *spec->name);
+ sprintf(realSpec, fmt, spec->vRefNum, spec->parID, spec->name+1);
+
+ return realSpec;
+}
+
+/* This returns an FSSpec of the directory enclosing the given FSSpec */
+static OSErr GUSIFSpUp(FSSpec * spec)
+{
+ if (spec->parID == fsRtParID) {
+ spec->vRefNum = 666;
+ spec->parID = 0;
+ spec->name[0] = 0;
+ } else {
+ if (1) { // CatInfo(-1)
+ gMacPerl_OSErr = FSMakeFSSpec(
+ spec->vRefNum, spec->parID, NULL, spec
+ );
+ }
+ }
+
+ return gMacPerl_OSErr;
+}
+
+/* This returns an FSSpec of the named file in the directory in the given FSSpec */
+/* untested!! */
+static OSErr GUSIFSpDown(FSSpec * spec, ConstStr31Param name)
+{
+ gMacPerl_OSErr = FSMakeFSSpec(
+ spec->vRefNum, spec->parID, name, spec
+ );
+
+ return gMacPerl_OSErr;
+}
+
+/* Finds special folders */
+static OSErr GUSISpecial2FSp(OSType object, short vol, FSSpec * desc)
+{
+ if (gMacPerl_OSErr = FindFolder(vol, object, true, &desc->vRefNum, &desc->parID))
+ return gMacPerl_OSErr;
+
+ return GUSIFSpUp(desc);
+}
+
+
+
+static void fsetfileinfo(char * path, OSType creator, OSType type)
+{
+ FInfo info;
+ FSSpec * spec = (FSSpec *)NewPtr(sizeof(FSSpec));
+
+ if ((gMacPerl_OSErr = GUSIPath2FSp(path, spec)) == 0) {
+ if ((gMacPerl_OSErr = FSpGetFInfo(spec, &info)) == 0) {
+ info.fdType = type;
+ info.fdCreator = creator;
+ info.fdFlags &= ~kHasBeenInited;
+
+ gMacPerl_OSErr = FSpSetFInfo(spec, &info);
+ }
+ }
+ DisposePtr((char *)spec);
+}
+
+static void fgetfileinfo(char * path, OSType * creator, OSType * type)
+{
+ FInfo info;
+ FSSpec * spec = (FSSpec *)NewPtr(sizeof(FSSpec));
+
+ if ((gMacPerl_OSErr = GUSIPath2FSp(path, spec)) == 0) {
+ if ((gMacPerl_OSErr = FSpGetFInfo(spec, &info)) == 0) {
+ if (creator)
+ *creator = info.fdCreator;
+ if (type)
+ *type = info.fdType;
+ }
+ }
+ DisposePtr((char *)spec);
+}
+
+# endif /* MACOS_TRADITIONAL */
+
+#endif /* _MAC_CARBON_H */
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/Carbon.pm#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/Carbon.pm
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/Carbon.pm Wed Nov 27 19:20:15 2002
@@ -0,0 +1,267 @@
+=head1 NAME
+
+Mac::Carbon - Access to Mac OS Carbon API
+
+=head1 SYNOPSIS
+
+ use Mac::Carbon;
+ use Mac::Carbon qw(:files :morefiles);
+
+
+=head1 DESCRIPTION
+
+This module provides documentation of the Mac::Carbon modules, and
+acts as a frontend to them.
+
+Mac::Carbon is a collection of perl modules for accessing the Carbon API
+under Mac OS X. It is a port of the Toolbox modules written by Matthias
+Neeracher for MacPerl.
+
+This module will load in all the Carbon modules, and export all of the
+functions, constants, and other variables. An export tag is set up for
+each module, so they may be selected individually.
+
+This module exists primarily because in Mac OS X, all the Carbon
+functions are imported into a C program with a single header,
+Carbon.h, so Mac OS X users may prefer to load in the entire Carbon
+API with a single module.
+
+For detailed information on the Carbon API (highly recommended, as
+a familiarity with Carbon is assumed in the POD), see apple.com.
+
+ http://developer.apple.com/techpubs/macosx/Carbon/
+
+The modules were written for Mac OS originally, and are in part being
+ported to Carbon. You may also be interested in the original documentation.
+
+ http://developer.apple.com/techpubs/macos8/
+
+
+=head1 TOOLBOX MAPPINGS
+
+Swiped from Mac/Toolbox.pod in the MacPerl distribution.
+
+The Macintosh Operating System provides a rich API with thousands of I<toolbox>
+calls. The MacPerl toolbox modules aim to make as much as possible of this
+functionality available to MacPerl programmers. The mapping of the toolbox
+interfaces into MacPerl is intended to be
+
+=over 4
+
+=item 1.
+
+Convenient to use for Perl programmers.
+
+=item 2.
+
+As close as possible to the C interfaces.
+
+=back
+
+This translates into a mapping strategy which is discussed in the following
+sections.
+
+
+=head2 Function mappings
+
+MacPerl toolbox calls take their input arguments in the same order as the
+corresponding toolbox functions. Output arguments are never passed by reference,
+but returned from the calls. If there are several output arguments, a list is
+returned. If an error occurs, the function returns C<undef> or C<()> and the
+error code is available in the C<$^E> variable.
+
+ $port = GetPort();
+ SetPort($port);
+ $desc = AECreateDesc("TEXT", "Hello, World") or die $^E;
+
+
+=head2 Data structure mappings
+
+Complex data structures are mapped into blessed references. Data fields are
+available through member functions which return the value of a field if called
+without an argument and change the value if called with an argument.
+
+ $rect = Rect->new(10, 20, 110, 220);
+ $rect->top;
+ $rect->right(250);
+
+
+
+=head1 MAC OS X DIFFERENCES
+
+The modules follow the same API under Mac OS X as Mac OS, except that
+the non-Carbon API is not supported (for example, C<NewHandle> is
+supported, but C<NewHandleSys> is not). Calling a function not
+supported by Carbon will generate an exception.
+
+The MacPerl package is automatically bootstrapped in MacPerl; it is
+included here, though functions specific to the application and GUI
+(Answer, Pick, Reply, Quit, etc.) are not supported, and the MacPerl
+package must be loaded explicitly (e.g., C<use MacPerl;>).
+
+The Mac-specific error codes are put in C<$^E> as in MacPerl, but C<$^E>
+does not automatically convert the numeric error into a string in string
+context. See brian d foy's L<Mac::Errors> module on the CPAN for this:
+
+ use Mac::Errors '$MacError';
+ my $info1 = FSpGetCatInfo($file1) or die $^E + 0; # error number
+ my $info2 = FSpGetCatInfo($file2) or die $MacError; # error string
+
+L<Mac::Errors> is not included with or required by Mac::Carbon, but it is
+highly recommended.
+
+C<$!> is set at the same time C<$^E> is set. This is different behavior
+from MacPerl, but similar to other platforms. On MacPerl, C<$^E> is
+signed, and on Unix it is unsigned, so to get the numeric value from
+C<$^E>, just add 0, as above. Could be worse.
+
+Files are passed back and forth using Unix/POSIX filespecs (if you care
+about the gory details, a portion of the GUSI API has been reimplemented
+here, and it handles the conversions). Similarly, times are converted
+back and forth from the Mac OS epoch to the Unix epoch.
+
+The support functions are in F<Carbon.h>. See that file for descriptions
+of the issues, including bugs and possibilities for bugs, involved.
+
+
+=head1 KNOWN BUGS
+
+=over 4
+
+=item *
+
+Docs not updated for Carbon incompatibilities (including changes to
+Processes fields). Generate list of all unsupported functions.
+
+=item *
+
+Deal with xsubpp issues (F<README>).
+
+=item *
+
+Related to xsubpp issues, embedded POD in .xs should somehow be moved
+to .pm files (perhaps the new preprocessor could automatically dump
+the POD into the corresponding .pm file). This currently causes an
+error during the build, and results in man pages not being properly
+created, with all the documentation.
+
+=item *
+
+Test suite needs a lot of work. There are surely bugs to be uncovered
+in a test suite. All modules have been tested to some degree, but more
+exhaustive testing needs to happen.
+
+=item *
+
+Not specific to the Carbon versions: the Mac:: modules define classes
+such as C<Handle> which probably should be something else, like
+C<Mac::Handle> or C<Mac::Carbon::Handle> or C<Mac::Memory::Handle>
+(other examples include C<AEDesc>, C<Point>, C<Rect>). No one has really
+complained before except on principle, but still ...
+
+=item *
+
+In Mac::Processes, there are some issues with unsupported fields in the
+ProcessInfo struct.
+
+=item *
+
+In Mac::MoreFiles, FSpDTGetAPPL is very slow, as it has to fall back on
+CatSearch(). And worse, it doesn't find applications that don't have the
+creator/type in the application, but in the PkgInfo file. If this acceptable,
+then the tied %Application hash should be implemented differently.
+
+=item *
+
+In MacPerl package, perhaps support Ask/Answer/Pick via DoAppleScript.
+
+=item *
+
+Can we support XCMDs etc. via XL? Do we want to?
+
+=back
+
+
+
+=head1 PACKAGES AND EXPORT TAGS
+
+See each individual module for more information on use. See F<README>
+for more information about modules not included here.
+
+ Mac::Components components
+ Mac::Files files
+ Mac::Gestalt gestalt
+ Mac::Memory memory
+ Mac::MoreFiles morefiles
+ Mac::Notification notification
+ Mac::Processes processes
+ Mac::Resources resources
+ Mac::Sound sound
+ Mac::Speech speech
+ Mac::Types types
+ MacPerl macperl
+
+=cut
+
+package Mac::Carbon;
+
+use strict;
+use base 'Exporter';
+use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
+
+$VERSION = '0.02';
+
+# we are just a frontend, so loop over the modules, and
+# suck up everything in @EXPORT
+BEGIN {
+ my @modules = qw(
+ Components
+ Files
+ Gestalt
+ Memory
+ MoreFiles
+ Notification
+ Processes
+ Resources
+ Sound
+ Speech
+ Types
+ );
+
+ # oh oh, it's magic ...
+ for (@modules) {
+ no strict 'refs';
+ eval "use Mac::$_";
+ die if $@;
+ my @export = @{'Mac::' . $_ . '::EXPORT'};
+ push @EXPORT, @export;
+ $EXPORT_TAGS{ lc $_ } = \@export;
+ }
+
+ # MacPerl is special, as almost everything is in EXPORT_OK
+ use MacPerl ':all';
+ push @EXPORT, @MacPerl::EXPORT, @MacPerl::EXPORT_OK;
+ $EXPORT_TAGS{ 'macperl' } = [@MacPerl::EXPORT, @MacPerl::EXPORT_OK];
+
+ @EXPORT_OK = @EXPORT;
+ $EXPORT_TAGS{ 'all' } = \@EXPORT;
+}
+
+1;
+
+__END__
+
+=head1 AUTHOR
+
+The Mac Toolbox modules were written by Matthias Neeracher
+E<lt>[email protected]<gt>. They are currently maintained by Chris
+Nandor E<lt>[email protected]<gt>.
+
+=head1 THANKS
+
+Michael Blakeley E<lt>[email protected]<gt>,
+Dan Sugalksi E<lt>[email protected]<gt>.
+
+=head1 SEE ALSO
+
+perl(1).
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/MANIFEST#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/MANIFEST
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/MANIFEST Wed Nov 27 19:20:15 2002
@@ -0,0 +1,109 @@
+Carbon.h
+Carbon.pm
+Components/Components.c
+Components/Components.pm
+Components/Components.xs
+Components/Makefile.PL
+Components/eg/ListComponents.plx
+Components/t/Components.t
+Components/typemap
+Files/Files.c
+Files/Files.pm
+Files/Files.xs
+Files/Makefile.PL
+Files/t/Files.t
+Files/typemap
+Gestalt/Gestalt.c
+Gestalt/Gestalt.pm
+Gestalt/Gestalt.xs
+Gestalt/Makefile.PL
+Gestalt/t/Gestalt.t
+MANIFEST This list of files
+MANIFEST.SKIP Files to skip
+MacPerl/MacPerl.c
+MacPerl/MacPerl.pm
+MacPerl/MacPerl.xs
+MacPerl/Makefile.PL
+MacPerl/OSA.c
+MacPerl/OSA.xs
+MacPerl/t/MacPerl.t
+Makefile.PL
+Memory/Makefile.PL
+Memory/Memory.c
+Memory/Memory.pm
+Memory/Memory.xs
+Memory/t/Memory.t
+MoreFiles/MF.c
+MoreFiles/MF.xs
+MoreFiles/Makefile.PL
+MoreFiles/MoreFiles.pm
+MoreFiles/MoreFilesSrc/DirectoryCopy.c
+MoreFiles/MoreFilesSrc/DirectoryCopy.h
+MoreFiles/MoreFilesSrc/FSpCompat.c
+MoreFiles/MoreFilesSrc/FSpCompat.h
+MoreFiles/MoreFilesSrc/FileCopy.c
+MoreFiles/MoreFilesSrc/FileCopy.h
+MoreFiles/MoreFilesSrc/FullPath.c
+MoreFiles/MoreFilesSrc/FullPath.h
+MoreFiles/MoreFilesSrc/IterateDirectory.c
+MoreFiles/MoreFilesSrc/IterateDirectory.h
+MoreFiles/MoreFilesSrc/MoreDesktopMgr.c
+MoreFiles/MoreFilesSrc/MoreDesktopMgr.h
+MoreFiles/MoreFilesSrc/MoreFiles.c
+MoreFiles/MoreFilesSrc/MoreFiles.h
+MoreFiles/MoreFilesSrc/MoreFilesExtras.c
+MoreFiles/MoreFilesSrc/MoreFilesExtras.h
+MoreFiles/MoreFilesSrc/Optimization.h
+MoreFiles/MoreFilesSrc/OptimizationEnd.h
+MoreFiles/MoreFilesSrc/Search.c
+MoreFiles/MoreFilesSrc/Search.h
+MoreFiles/eg/Application.plx
+MoreFiles/eg/Iterate.plx
+MoreFiles/t/MoreFiles.t
+Notification/Makefile.PL
+Notification/Notification.c
+Notification/Notification.pm
+Notification/Notification.xs
+Notification/t/Notification.rsrc
+Notification/t/Notification.t
+Notification/typemap
+Processes/Makefile.PL
+Processes/Processes.c
+Processes/Processes.pm
+Processes/Processes.xs
+Processes/eg/Processes.plx
+Processes/t/Processes.t
+Processes/typemap
+QuickDraw/typemap
+README
+Resources/Makefile.PL
+Resources/Resources.c
+Resources/Resources.pm
+Resources/Resources.xs
+Resources/t/Resources.t
+Sound/Makefile.PL
+Sound/Sound.c
+Sound/Sound.pm
+Sound/Sound.xs
+Sound/t/Scream.rsrc
+Sound/t/Sound.t
+Sound/typemap
+Speech/Makefile.PL
+Speech/Speech.c
+Speech/Speech.pm
+Speech/Speech.xs
+Speech/eg/Cellist.plx
+Speech/eg/DumpVoices.plx
+Speech/eg/JukeBox.plx
+Speech/eg/Phonemes.plx
+Speech/t/Speech.t
+Speech/typemap
+Types/Makefile.PL
+Types/Types.c
+Types/Types.pm
+Types/Types.xs
+Types/t/Types.t
+t/Carbon.t
+typemap
+xsubpps/xsubpp-5.6.1
+xsubpps/xsubpp-5.8.0
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/MANIFEST.SKIP#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/MANIFEST.SKIP
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/MANIFEST.SKIP Wed Nov 27 19:20:15 2002
@@ -0,0 +1,4 @@
+CVS
+\.DS_Store
+MacPerl/XL.xs
+MacPerl/AutoInit.pl
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/Makefile.PL#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/Makefile.PL
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -0,0 +1,12 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ 'NAME' => 'Mac::Carbon',
+ 'VERSION_FROM' => 'Carbon.pm',
+ 'PREREQ_PM' => {
+ 'Test::More' => 0,
+ },
+ 'test' => {
+ 'TESTS' => 't/*.t */t/*.t'
+ }
+);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/README#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/README
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/README Wed Nov 27 19:20:15 2002
@@ -0,0 +1,156 @@
+#!perl -w
+# run this document through perl to check its syntax
+use Pod::Checker;
+podchecker(\*DATA);
+__END__
+
+=head1 NAME
+
+README - Carbon API for perl on Mac OS X
+
+=head1 SYNOPSIS
+
+This is B<not release-quality> software. It is still in development, and
+not recommend for use in a production environment.
+
+Mac::Carbon is a collection of perl modules for accessing the Carbon API
+under Mac OS X. It is a port of the Toolbox modules written by Matthias
+Neeracher for MacPerl.
+
+Part of the current strategy is to make Mac::Carbon the intersection of
+the old and new Mac OS APIs. We will not be adding new functionality
+from Carbon, except as needed, for now. This may change over time as
+Mac::Carbon stabilizes.
+
+See the documentation in L<Mac::Carbon> for more implementation details,
+bugs, etc.
+
+
+=head1 HELP ME
+
+There are probably a lot of bugs, especially in F<Carbon.h>. Bugs are listed
+in L<Mac::Carbon/"Known Bugs">; please feel free to report them on the MacPerl bug
+reporting page, in the "Mac Toolbox" category. Patches are welcome,
+too, of course. For large patches, such as stuff for test suites and
+building, please do coordinate with me before spending much time on it.
+
+ http://sf.net/projects/macperl/
+
+
+=head1 REQUIREMENTS
+
+=head2 Mac OS
+
+These modules all build under Mac OS, but it is recommended you build them
+as a part of MacPerl itself, or at least under the MacPerl source. See
+http://dev.macperl.org/ for more information.
+
+Under Mac OS, the full Mac OS API is available, not just the Carbon-compatible
+routines.
+
+=head2 Mac OS X
+
+To build these modules on Mac OS X, the Developer Tools are required.
+
+The Test::More module is required for running tests.
+
+The separate Mac::Errors module is not required, but is highly recommended.
+
+These modules have only been tested with perl 5.6.0 on Mac OS X. See
+the note in L<BUILDING>.
+
+The modules will compile and test remotely (such as via ssh, instead of
+via the Terminal), but some of the tests might not run properly, and
+one of the tests (for Mac::Notification) wants user feedback (though will
+work without it).
+
+
+=head1 BUILDING
+
+Matthias added some extensions to XS for his Toolbox modules; they were
+never fully embraced by p5p, and as a result, we have a separate xsubpp
+for these additional XS macros. There is currently no resolution to this
+problem. Either we write a pre-preprocessor that converts the .xs files
+to be able to be handled by perl's xsubpp, or we modify the .xs so that
+it can be handled by perl's xsubpp, or we distribute a separate xsubpp
+(which is dangerous, as xsubpp changes with versions of perl).
+
+Currently, Mac::Carbon is distributed with the already-processed .c files.
+If you really want to compile with the .xs files, you can use the xsubpp
+programs (either the 5.6 or 5.8 versions) included in the distribution.
+This is only temporary, until we have a permanent resolution to these
+issues.
+
+You might want to run the test suite with C<make test TEST_VERBOSE=1>.
+It's cool.
+
+
+=head1 SUPPORTED MODULES
+
+Currently, only a subset of the modules are supported. The ported
+modules are:
+
+ Mac::Components
+ Mac::Files
+ Mac::Gestalt
+ Mac::Memory
+ Mac::MoreFiles
+ Mac::Notification
+ Mac::Processes
+ Mac::Resources
+ Mac::Sound
+ Mac::Speech
+ Mac::Types
+
+Coming next, hopefully:
+
+ Mac::AppleEvents
+ Mac::OSA
+
+Mac::AppleEvents is going to take more work than the others, as it
+involves some significant API changes.
+
+Following those, the pure-perl modules, which should not take much
+work, as long as the core XS modules they rely on are working:
+
+ Mac::AppleEvents::Simple
+ Mac::OSA::Simple
+ Mac::Glue
+
+And, possibly:
+
+ Mac::InternetConfig
+ Mac::SpeechRecognition
+
+There are currently no plans for the other (GUI) modules, including:
+
+ Mac::Controls
+ Mac::Dialogs
+ Mac::Events
+ Mac::Fonts
+ Mac::Lists
+ Mac::Menus
+ Mac::Movies
+ Mac::Navigation
+ Mac::QDOffScreen
+ Mac::QuickDraw
+ Mac::QuickTimeVR
+ Mac::TextEdit
+ Mac::Windows
+
+We could do these eventually, if there is enough interest. They don't
+port as easily as some of the others, for many reasons, not the least of
+which is that we need a framework to handle events etc., which for
+MacPerl is mostly implemented in F<macish.c> / F<macish.h>.
+
+
+=head1 AUTHOR
+
+The Mac Toolbox modules were written by Matthias Neeracher
+E<lt>[email protected]<gt>. They are currently maintained by Chris
+Nandor E<lt>[email protected]<gt>.
+
+
+=head1 VERSION
+
+$Id: README,v 1.1 2002/11/13 02:04:50 pudge Exp $
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/t/Carbon.t#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/t/Carbon.t
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/t/Carbon.t Wed Nov 27 19:20:15 2002
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 4 }
+
+use Mac::Carbon qw(:resources :files :macperl);
+
+SKIP: {
+# skip "Mac::Carbon", 4;
+ ok(resChanged() == 2, 'resChanged() == 2');
+ ok(defined &FSpGetCatInfo, 'FSpGetCatInfo imported');
+ ok(!defined &RegisterComponentResource, 'RegisterComponentResource not imported');
+ ok(DoAppleScript('get version'), 'DoAppleScript() works');
+}
+
+__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/Carbon/typemap#1 (text) ====
Index: macperl/macos/ext/Mac/Carbon/typemap
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Carbon/typemap Wed Nov 27 19:20:15 2002
@@ -0,0 +1,74 @@
+TYPEMAP
+ConnectionID T_IV
+Str255 T_STR255
+OSType T_OSTYPE
+FSSpec T_FSSPEC
+Handle T_PTROBJ
+Ptr T_PTROBJ
+RawPtr T_IV
+OSErr T_IV
+SInt8 T_IV
+AEDesc T_RECORDOBJ
+AEKeyDesc T_RECORDOBJ
+AESubDesc T_RECORDOBJ
+AEStream T_RECORDOBJ
+MacOSRet T_MACOSRET
+HandleRet T_HANDLERET
+PtrRet T_PTRRET
+NumVersion T_RECORDOBJ
+Fixed T_FIXED
+Boolean T_IV
+time_t T_NV
+INPUT
+T_MACOSRET
+ $var NOT IMPLEMENTED
+T_HANDLERET
+ $var NOT IMPLEMENTED
+T_PTRRET
+ $var NOT IMPLEMENTED
+T_STR255
+ MacPerl_CopyC2P(SvPV_nolen($arg), $var)
+T_OSTYPE
+ memcpy(&$var, SvPV_nolen($arg), sizeof($ntype))
+T_RECORDREF
+ if (SvROK($arg))
+ memcpy(&$var, SvPV_nolen((SV*)SvRV($arg)), sizeof($ntype));
+ else
+ croak(\"$var is not a reference\")
+T_RECORDOBJ
+ if (sv_isa($arg, \"${ntype}\"))
+ memcpy(&$var, SvPV_nolen((SV*)SvRV($arg)), sizeof($ntype));
+ else
+ croak(\"$var is not of type ${ntype}\")
+T_FSSPEC
+ if (GUSIPath2FSp((char *) SvPV_nolen($arg), &$var))
+ croak(\"$var is not a valid file specification\");
+ else
+ 0
+T_FIXED
+ $var = X2Fix(SvNV($arg))
+OUTPUT
+T_MACOSRET
+ sv_setiv($arg, (IV)!(gMacPerl_OSErr = (short)($var)));
+T_HANDLERET
+ if ($var)
+ sv_setref_pv($arg, \"Handle\", (void*)$var);
+ else
+ gMacPerl_OSErr = MemError();
+T_PTRRET
+ if ($var)
+ sv_setref_pv($arg, \"Ptr\", (void*)$var);
+ else
+ gMacPerl_OSErr = MemError();
+T_STR255
+ sv_setpvn($arg, ((char *) $var) + 1, $var\[0\]);
+T_OSTYPE
+ sv_setpvn($arg, (char *) &$var, 4);
+T_RECORDREF
+ sv_setref_pvn($arg, \"${ntype}\", (void*)&$var, sizeof($ntype));
+T_RECORDOBJ
+ sv_setref_pvn($arg, \"${ntype}\", (void*)&$var, sizeof($ntype));
+T_FSSPEC
+ sv_setpv($arg, GUSIFSp2FullPath(&$var));
+T_FIXED
+ sv_setnv($arg, Fix2X($var));
==== //depot/maint-5.6/macperl/macos/ext/Mac/Components/Components.pm#3 (text) ====
Index: macperl/macos/ext/Mac/Components/Components.pm
--- macperl/macos/ext/Mac/Components/Components.pm#2~12323~ Wed Oct 3 11:42:37 2001
+++ macperl/macos/ext/Mac/Components/Components.pm Wed Nov 27 19:20:15 2002
@@ -22,7 +22,7 @@
use DynaLoader;
use vars qw(@ISA @EXPORT $VERSION);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
RegisterComponentResource
==== //depot/maint-5.6/macperl/macos/ext/Mac/Components/Components.xs#2 (text) ====
Index: macperl/macos/ext/Mac/Components/Components.xs
--- macperl/macos/ext/Mac/Components/Components.xs#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Components/Components.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Components/Components.xs,v 1.2 2000/09/09 22:18:26 neeri Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Components/Components.xs,v 1.3 2002/11/13 02:04:50 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Components.xs,v $
+ * Revision 1.3 2002/11/13 02:04:50 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.2 2000/09/09 22:18:26 neeri
* Dynamic libraries compile under 5.6
*
@@ -25,6 +28,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Memory.h>
#include <Components.h>
@@ -168,15 +174,27 @@
HLock(info);
if (!gMacPerl_OSErr)
if (GIMME != G_ARRAY) {
- XS_XPUSH(Str255, (StringPtr)*name);
+ if (*name == NULL) {
+ XS_XPUSH(Str255, "");
+ } else {
+ XS_XPUSH(Str255, (StringPtr)*name);
+ }
} else {
XPUSHs(sv_2mortal(MakeOSSV(desc.componentType)));
XPUSHs(sv_2mortal(MakeOSSV(desc.componentSubType)));
XPUSHs(sv_2mortal(MakeOSSV(desc.componentManufacturer)));
XPUSHs(sv_2mortal(newSViv(desc.componentFlags)));
XPUSHs(sv_2mortal(newSViv(desc.componentFlagsMask)));
- XS_XPUSH(Str255, (StringPtr)*name);
- XS_XPUSH(Str255, (StringPtr)*info);
+ if (*name == NULL) {
+ XS_XPUSH(Str255, "");
+ } else {
+ XS_XPUSH(Str255, (StringPtr)*name);
+ }
+ if (*info == NULL) {
+ XS_XPUSH(Str255, "");
+ } else {
+ XS_XPUSH(Str255, (StringPtr)*info);
+ }
}
DisposeHandle(name);
DisposeHandle(info);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Components/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Components/Makefile.PL
--- macperl/macos/ext/Mac/Components/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Components/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,8 +1,22 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Components),
- 'VERSION_FROM' => 'Components.pm',
+my $mod = 'Components';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- XSPROTOARG => '-noprototypes', # XXX remove later?
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Components/eg/ListComponents.plx#1 (text) ====
Index: macperl/macos/ext/Mac/Components/eg/ListComponents.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Components/eg/ListComponents.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,14 @@
+Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+
+#!perl
+#
+# ListComponents.t - Demonstrate how to list all components. To restrict the listing
+# to one type, pass it on the command line as in
+# ListComponents.t "osa "
+#
+
+use Mac::Components;
+
+for ($comp = 0; $comp = FindNextComponent($comp, $ARGV[0]); ) {
+ printf "%08X: %4s %4s %4s %08X %08X %-25s %s\n", $comp, GetComponentInfo($comp);
+}
==== //depot/maint-5.6/macperl/macos/ext/Mac/Components/t/Components.t#1 (text) ====
Index: macperl/macos/ext/Mac/Components/t/Components.t
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Components/t/Components.t Wed Nov 27 19:20:15 2002
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 1 }
+
+use Mac::Components;
+
+SKIP: {
+# skip "Mac::Components", 1;
+
+# try to open components, get info from them
+
+ my $count = 0;
+ for (my $comp = 0; $comp = FindNextComponent($comp, $ARGV[0]); ) {
+ ++$count;
+ }
+ is($count, CountComponents(), 'count components');
+}
+
+__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/Files/Files.pm#4 (text) ====
Index: macperl/macos/ext/Mac/Files/Files.pm
--- macperl/macos/ext/Mac/Files/Files.pm#3~12965~ Mon Nov 12 21:42:59 2001
+++ macperl/macos/ext/Mac/Files/Files.pm Wed Nov 27 19:20:15 2002
@@ -19,7 +19,7 @@
use vars qw(@ISA @EXPORT $VERSION);
- $VERSION = '1.01';
+ $VERSION = '1.02';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
FSpGetCatInfo
==== //depot/maint-5.6/macperl/macos/ext/Mac/Files/Files.xs#4 (text) ====
Index: macperl/macos/ext/Mac/Files/Files.xs
--- macperl/macos/ext/Mac/Files/Files.xs#3~14587~ Thu Feb 7 10:46:28 2002
+++ macperl/macos/ext/Mac/Files/Files.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Files/Files.xs,v 1.5 2002/01/30 07:43:54 neeri Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Files/Files.xs,v 1.6 2002/11/13 02:04:51 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Files.xs,v $
+ * Revision 1.6 2002/11/13 02:04:51 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.5 2002/01/30 07:43:54 neeri
* Check ownership of CatInfos
*
@@ -44,9 +47,14 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Folders.h>
#include <Files.h>
+#ifdef MACOS_TRADITIONAL
#include <GUSIFileSpec.h>
+#endif
#include <Script.h>
#include <Errors.h>
#include <Aliases.h>
@@ -252,13 +260,19 @@
}
RETVAL->hFileInfo.ioVRefNum = file.vRefNum;
RETVAL->hFileInfo.ioDirID = file.parID;
- RETVAL->hFileInfo.ioFDirIndex = index;
+ RETVAL->hFileInfo.ioFDirIndex = index;
if (!index)
memcpy(RETVAL->hFileInfo.ioNamePtr, file.name, *file.name+1);
if (gMacPerl_OSErr = PBGetCatInfoSync(RETVAL)) {
free(RETVAL);
XSRETURN_UNDEF;
}
+#ifndef MACOS_TRADITIONAL
+ // takes care of Dr time fields too
+ RETVAL->hFileInfo.ioFlCrDat = SecondsMac2Unix(RETVAL->hFileInfo.ioFlCrDat);
+ RETVAL->hFileInfo.ioFlMdDat = SecondsMac2Unix(RETVAL->hFileInfo.ioFlMdDat);
+ RETVAL->hFileInfo.ioFlBkDat = SecondsMac2Unix(RETVAL->hFileInfo.ioFlBkDat);
+#endif
OUTPUT:
RETVAL
@@ -274,6 +288,12 @@
CODE:
info->hFileInfo.ioVRefNum = file.vRefNum;
info->hFileInfo.ioDirID = file.parID;
+#ifndef MACOS_TRADITIONAL
+ // takes care of Dr time fields too
+ info->hFileInfo.ioFlCrDat = SecondsUnix2Mac(info->hFileInfo.ioFlCrDat);
+ info->hFileInfo.ioFlMdDat = SecondsUnix2Mac(info->hFileInfo.ioFlMdDat);
+ info->hFileInfo.ioFlBkDat = SecondsUnix2Mac(info->hFileInfo.ioFlBkDat);
+#endif
memcpy(info->hFileInfo.ioNamePtr, file.name, *file.name+1);
RETVAL = PBSetCatInfoSync(info);
OUTPUT:
@@ -597,7 +617,11 @@
Str255 volName
short vRefNum
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Files::Eject unsupported in Carbon");
+#else
RETVAL = Eject(volName, vRefNum);
+#endif
OUTPUT:
RETVAL
==== //depot/maint-5.6/macperl/macos/ext/Mac/Files/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Files/Makefile.PL
--- macperl/macos/ext/Mac/Files/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Files/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,9 +1,30 @@
use ExtUtils::MakeMaker;
+use File::Spec::Functions;
-WriteMakefile(
- NAME => q(Mac::Files),
- 'VERSION_FROM' => 'Files.pm',
+my $mod = 'Files';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- TYPEMAPS => '::QuickDraw:typemap',
- XSPROTOARG => '-noprototypes', # XXX remove later?
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
+
+ 'TYPEMAPS' => [
+ catfile(updir(), 'QuickDraw', 'typemap'),
+ ],
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+if ($^O eq 'MacOS' && $] < 5.8) { # old makemaker syntax?
+ $args{'TYPEMAPS'} = join ' ', @{$args{'TYPEMAPS'}};
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Files/t/Files.t#2 (text) ====
Index: macperl/macos/ext/Mac/Files/t/Files.t
--- macperl/macos/ext/Mac/Files/t/Files.t#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Files/t/Files.t Wed Nov 27 19:20:15 2002
@@ -1,11 +1,17 @@
-Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
-#!perl
-#
-# Files.t - Demonstrate a few file calls.
-#
+BEGIN { plan tests => 1 }
use Mac::Files;
+
+SKIP: {
+# skip "Mac::Files", 1;
+ ok(1);
+}
+
+__END__
print FindFolder(kOnSystemDisk, kSystemFolderType), "\n";
$info = FSpGetCatInfo("::Makefile.mk");
==== //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/Gestalt.pm#4 (text) ====
Index: macperl/macos/ext/Mac/Gestalt/Gestalt.pm
--- macperl/macos/ext/Mac/Gestalt/Gestalt.pm#3~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Gestalt/Gestalt.pm Wed Nov 27 19:20:15 2002
@@ -29,7 +29,7 @@
use DynaLoader ();
use vars qw($VERSION @ISA @EXPORT %Gestalt);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
Gestalt
==== //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/Gestalt.xs#2 (text) ====
Index: macperl/macos/ext/Mac/Gestalt/Gestalt.xs
--- macperl/macos/ext/Mac/Gestalt/Gestalt.xs#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Gestalt/Gestalt.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Gestalt/Gestalt.xs,v 1.2 2000/09/09 22:18:26 neeri Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Gestalt/Gestalt.xs,v 1.3 2002/11/13 02:04:51 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Gestalt.xs,v $
+ * Revision 1.3 2002/11/13 02:04:51 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.2 2000/09/09 22:18:26 neeri
* Dynamic libraries compile under 5.6
*
@@ -25,6 +28,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Gestalt.h>
MODULE = Mac::Gestalt PACKAGE = Mac::Gestalt
==== //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Gestalt/Makefile.PL
--- macperl/macos/ext/Mac/Gestalt/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Gestalt/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,8 +1,22 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Gestalt),
- 'VERSION_FROM' => 'Gestalt.pm',
+my $mod = 'Gestalt';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- XSPROTOARG => '-noprototypes', # XXX remove later?
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Gestalt/t/Gestalt.t#2 (text) ====
Index: macperl/macos/ext/Mac/Gestalt/t/Gestalt.t
--- macperl/macos/ext/Mac/Gestalt/t/Gestalt.t#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Gestalt/t/Gestalt.t Wed Nov 27 19:20:15 2002
@@ -1,14 +1,40 @@
-Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
-#!perl
-#
-# Gestalt.t - Demostrate the Gestalt call.
-#
+BEGIN { plan tests => 10 }
use Mac::Gestalt;
-print Gestalt(gestaltStandardFileAttr), "\n";
+SKIP: {
+# skip "Mac::Gestalt", 10;
-if ($Gestalt{gestaltCloseViewAttr()} & (1 << gestaltCloseViewEnabled)) {
- print "Hello, fellow four-eye!\n";
-}
\ No newline at end of file
+ my $sel;
+
+ $sel = $Gestalt{'pclk'};
+ ok($sel, sprintf('%s MHz Clock Speed', $sel/1000000));
+
+ ok(gestaltPhysicalRAMSize() eq 'ram ');
+ $sel = $Gestalt{gestaltPhysicalRAMSize()};
+ ok($sel, sprintf('%s MB Physical RAM', $sel/1048576));
+
+ ok(gestaltLogicalRAMSize() eq 'lram');
+ $sel = $Gestalt{gestaltLogicalRAMSize()};
+ ok($sel, sprintf('%s MB Logical RAM', $sel/1048576));
+
+ ok(gestaltSystemVersion() eq 'sysv');
+ $sel = $Gestalt{gestaltSystemVersion()};
+ my @vers = split //, sprintf "%x", $sel;
+ my $vers = sprintf "%s.%s.", pop(@vers), pop(@vers);
+ $vers = join('', @vers) . reverse $vers;
+ ok($sel, "OS v$vers");
+
+ ok(gestaltAUXVersion() eq 'a/ux');
+ $sel = $Gestalt{gestaltAUXVersion()};
+ ok(!$sel, "Not running A/UX");
+
+ $sel = $Gestalt{gestaltAliasMgrAttr()};
+ ok(($sel & (1 << gestaltAliasMgrPresent)) == 1, "Alias manager present");
+}
+
+__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/Memory/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Memory/Makefile.PL
--- macperl/macos/ext/Mac/Memory/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Memory/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,8 +1,22 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Memory),
- 'VERSION_FROM' => 'Memory.pm',
+my $mod = 'Memory';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- XSPROTOARG => '-noprototypes', # XXX remove later?
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Memory/Memory.pm#4 (text) ====
Index: macperl/macos/ext/Mac/Memory/Memory.pm
--- macperl/macos/ext/Mac/Memory/Memory.pm#3~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Memory/Memory.pm Wed Nov 27 19:20:15 2002
@@ -1,6 +1,6 @@
=head1 NAME
-MacOS Memory Manager
+Mac::Memory - MacOS Memory Manager
Provide the MacPerl interface to the memory management routines in the MacOS.
@@ -34,7 +34,7 @@
use DynaLoader ();
use vars qw($VERSION @ISA @EXPORT);
- $VERSION = '1.20';
+ $VERSION = '1.21';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
GetApplLimit
==== //depot/maint-5.6/macperl/macos/ext/Mac/Memory/Memory.xs#5 (text) ====
Index: macperl/macos/ext/Mac/Memory/Memory.xs
--- macperl/macos/ext/Mac/Memory/Memory.xs#4~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Memory/Memory.xs Wed Nov 27 19:20:15 2002
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Memory.xs,v $
+ * Revision 1.8 2002/11/13 02:04:52 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.7 2002/01/23 20:24:58 pudge
* Fix silly error
*
@@ -46,6 +49,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Memory.h>
#include <TextUtils.h>
@@ -414,8 +420,20 @@
=cut
+
+#ifndef MACOS_TRADITIONAL
+
RawPtr
GetApplLimit()
+ CODE:
+ croak("Usage: Mac::Memory::GetApplLimit unsupported in Carbon");
+
+#else
+
+RawPtr
+GetApplLimit()
+
+#endif
=item TopMem
@@ -451,18 +469,42 @@
NewHandle(byteCount)
long byteCount
+#ifndef MACOS_TRADITIONAL
+
+HandleRet
+NewHandleSys(byteCount)
+ long byteCount
+ CODE:
+ croak("Usage: Mac::Memory::NewHandleSys unsupported in Carbon");
+
+#else
+
HandleRet
NewHandleSys(byteCount)
long byteCount
+#endif
+
HandleRet
NewHandleClear(byteCount)
long byteCount
+#ifndef MACOS_TRADITIONAL
+
+HandleRet
+NewHandleSysClear(byteCount)
+ long byteCount
+ CODE:
+ croak("Usage: Mac::Memory::NewHandleSysClear unsupported in Carbon");
+
+#else
+
HandleRet
NewHandleSysClear(byteCount)
long byteCount
+#endif
+
=item NewPtr BYTECOUNT
=item NewPtrSys BYTECOUNT
@@ -485,24 +527,48 @@
CLEANUP:
gMacPerl_OSErr = MemError();
+#ifndef MACOS_TRADITIONAL
+
+PtrRet
+NewPtrSys(byteCount)
+ long byteCount
+ CODE:
+ croak("Usage: Mac::Memory::NewPtrSys unsupported in Carbon");
+
+#else
+
PtrRet
NewPtrSys(byteCount)
long byteCount
CLEANUP:
gMacPerl_OSErr = MemError();
+#endif
+
PtrRet
NewPtrClear(byteCount)
long byteCount
CLEANUP:
gMacPerl_OSErr = MemError();
+#ifndef MACOS_TRADITIONAL
+
+PtrRet
+NewPtrSysClear(byteCount)
+ long byteCount
+ CODE:
+ croak("Usage: Mac::Memory::NewPtrSysClear unsupported in Carbon");
+
+#else
+
PtrRet
NewPtrSysClear(byteCount)
long byteCount
CLEANUP:
gMacPerl_OSErr = MemError();
+#endif
+
=item MaxBlock
=item MaxBlockSys
@@ -518,8 +584,19 @@
long
MaxBlock()
+#ifndef MACOS_TRADITIONAL
+
long
MaxBlockSys()
+ CODE:
+ croak("Usage: Mac::Memory::MaxBlockSys unsupported in Carbon");
+
+#else
+
+long
+MaxBlockSys()
+
+#endif
=item StackSpace
@@ -548,8 +625,19 @@
HandleRet
NewEmptyHandle()
+#ifndef MACOS_TRADITIONAL
+
HandleRet
NewEmptyHandleSys()
+ CODE:
+ croak("Usage: Mac::Memory::NewEmptyHandleSys unsupported in Carbon");
+
+#else
+
+HandleRet
+NewEmptyHandleSys()
+
+#endif
=item HLock HANDLE
@@ -630,7 +718,10 @@
long logicalSize
CODE:
{
- RETVAL = TempNewHandle(logicalSize, &gMacPerl_OSErr);
+ OSErr myErr;
+
+ RETVAL = TempNewHandle(logicalSize, &myErr);
+ gMacPerl_OSErr = myErr;
if (gMacPerl_OSErr) {
XSRETURN_UNDEF;
}
@@ -694,9 +785,21 @@
CompactMem(cbNeeded)
long cbNeeded
+#ifndef MACOS_TRADITIONAL
+
long
CompactMemSys(cbNeeded)
long cbNeeded
+ CODE:
+ croak("Usage: Mac::Memory::CompactMemSys unsupported in Carbon");
+
+#else
+
+long
+CompactMemSys(cbNeeded)
+ long cbNeeded
+
+#endif
=item PurgeMem BYTECOUNT
@@ -721,9 +824,21 @@
PurgeMem(cbNeeded)
long cbNeeded
+#ifndef MACOS_TRADITIONAL
+
void
PurgeMemSys(cbNeeded)
long cbNeeded
+ CODE:
+ croak("Usage: Mac::Memory::PurgeMemSys unsupported in Carbon");
+
+#else
+
+void
+PurgeMemSys(cbNeeded)
+ long cbNeeded
+
+#endif
=item FreeMem
@@ -740,8 +855,19 @@
long
FreeMem()
+#ifndef MACOS_TRADITIONAL
+
long
FreeMemSys()
+ CODE:
+ croak("Usage: Mac::Memory::FreeMemSys unsupported in Carbon");
+
+#else
+
+long
+FreeMemSys()
+
+#endif
=item ReserveMem BYTECOUNT
@@ -761,10 +887,22 @@
ReserveMem(cbNeeded)
long cbNeeded
+#ifndef MACOS_TRADITIONAL
+
+void
+ReserveMemSys(cbNeeded)
+ long cbNeeded
+ CODE:
+ croak("Usage: Mac::Memory::ReserveMemSys unsupported in Carbon");
+
+#else
+
void
ReserveMemSys(cbNeeded)
long cbNeeded
+#endif
+
=item MaxMem
=item MaxMemSys
@@ -796,12 +934,16 @@
MaxMemSys()
PPCODE:
{
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Memory::MaxMemSys unsupported in Carbon");
+#else
long grow;
XS_PUSH(long, MaxMemSys(&grow));
if (GIMME == G_ARRAY) {
XS_PUSH(long, grow);
}
+#endif
}
=item MoveHHi HANDLE
==== //depot/maint-5.6/macperl/macos/ext/Mac/Memory/t/Memory.t#3 (text) ====
Index: macperl/macos/ext/Mac/Memory/t/Memory.t
--- macperl/macos/ext/Mac/Memory/t/Memory.t#2~14076~ Fri Jan 4 12:44:23 2002
+++ macperl/macos/ext/Mac/Memory/t/Memory.t Wed Nov 27 19:20:15 2002
@@ -1,17 +1,37 @@
-Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
-#!perl
-#
-# Memory.t - List some statistics about the heap.
-#
+BEGIN { plan tests => 12 }
use Mac::Memory;
-print <<END;
-Stack Space: @{[StackSpace]}
-Free Memory: @{[FreeMem]}
-Max Memory: @{[MaxMem]}
-END
+SKIP: {
+# skip "Mac::Memory", 12;
+
+# test any of the many other memory functions, seldom-used though they are?
+
+ ok(StackSpace(), 'StackSpace');
+ ok(FreeMem(), 'FreeMem');
+ ok(MaxMem(), 'MaxMem');
+
+ ok(my $h = Handle->new('xyzzy'), 'new handle');
+ is($h->get, 'xyzzy', 'get handle');
+ is($h->size, 5, 'handle size');
+ is($h->get(2, 2), 'zz', 'get handle portion');
+
+ ok($h->append(' wokka wokka'), 'append to handle');
+ is($h->get, 'xyzzy wokka wokka', 'get handle');
+ is($h->size, 17, 'handle size');
+ is($h->get(2, 2), 'zz', 'get handle portion');
+
+ ok(!$h->dispose, 'dispose handle');
+}
+
+
+__END__
+
+Handle->open() doesn't work. Probably never will again.
$h = new Handle("xyzzy");
$r = $h->open("r");
@@ -37,4 +57,3 @@
truncate $r, 0;
# should be " (0)"
printf "%s (%d)\n", $h->get, $h->size;
-__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MF.xs#3 (text) ====
Index: macperl/macos/ext/Mac/MoreFiles/MF.xs
--- macperl/macos/ext/Mac/MoreFiles/MF.xs#2~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/MoreFiles/MF.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/MoreFiles/MF.xs,v 1.4 2002/01/23 05:44:42 pudge Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/MoreFiles/MF.xs,v 1.5 2002/11/13 02:04:52 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: MF.xs,v $
+ * Revision 1.5 2002/11/13 02:04:52 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.4 2002/01/23 05:44:42 pudge
* Update whitespace etc., from Thomas
*
@@ -32,10 +35,15 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Memory.h>
#include <Files.h>
+#ifdef MACOS_TRADITIONAL
#include <GUSIFileSpec.h>
+#endif
#include "MoreFiles.h"
#include "FileCopy.h"
#include "IterateDirectory.h"
==== //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/MoreFiles/Makefile.PL
--- macperl/macos/ext/Mac/MoreFiles/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/MoreFiles/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,10 +1,36 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::MoreFiles),
- 'VERSION_FROM' => 'MoreFiles.pm',
- 'LINKTYPE' => ['static', 'dynamic'],
- XSPROTOARG => '-noprototypes', # XXX remove later?
- 'INC' => '-i "$(PERL_SRC):MoreFiles:CHeaders:"',
- OBJECT => 'MF.c'
+my $mod = 'MoreFiles';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
+ 'LINKTYPE' => 'static dynamic',
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ my $src = 'MoreFilesSrc';
+ # we only compile these separately for Mac OS X right now, so
+ # we keep them in a separate directory and copy them in when needed
+ require File::Copy;
+ opendir my $dh, $src or die $!;
+ File::Copy::copy($_, '.') for map { "$src/$_" } grep { /\.c$/ } readdir($dh);
+ # all our C_FILES are generated or copied into place
+ $args{'clean'} = { FILES => '$(C_FILES)' };
+
+ $args{'INC'} = "-I/Developer/Headers/FlatCarbon/ -I./$src";
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+ $args{'OBJECT'} = '$(O_FILES)';
+}
+if ($^O eq 'MacOS') {
+ $args{'INC'} = '-i "$(PERL_SRC):MoreFiles:CHeaders:"';
+ $args{'OBJECT'} = 'MF.c';
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/MoreFiles.pm#4 (text) ====
Index: macperl/macos/ext/Mac/MoreFiles/MoreFiles.pm
--- macperl/macos/ext/Mac/MoreFiles/MoreFiles.pm#3~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/MoreFiles/MoreFiles.pm Wed Nov 27 19:20:15 2002
@@ -17,11 +17,12 @@
package Mac::MoreFiles;
BEGIN {
+ use MacPerl 'Volumes';
use Exporter ();
use DynaLoader ();
use vars qw($VERSION @ISA @EXPORT %Application);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
FSpCreateMinimum
==== //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/eg/Application.plx#1 (text) ====
Index: macperl/macos/ext/Mac/MoreFiles/eg/Application.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/MoreFiles/eg/Application.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,13 @@
+Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+
+#!perl
+#
+# Application.t - Demonstrate %Application
+#
+
+use Mac::MoreFiles;
+
+print "MacPerl apparently is in $Application{McPL}\n";
+
+die "Oops! You have Microsoft Word on your machine" if $Application{"MSWD"};
+
==== //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/eg/Iterate.plx#1 (text) ====
Index: macperl/macos/ext/Mac/MoreFiles/eg/Iterate.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/MoreFiles/eg/Iterate.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,11 @@
+Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+
+#!perl
+#
+# Iterate.t - Demonstrate FSpIterateDirectory
+#
+
+use Mac::MoreFiles;
+
+FSpIterateDirectory(":", 2, sub { print @_, "\n"; return 0; }, "");
+
==== //depot/maint-5.6/macperl/macos/ext/Mac/MoreFiles/t/MoreFiles.t#1 (text) ====
Index: macperl/macos/ext/Mac/MoreFiles/t/MoreFiles.t
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/MoreFiles/t/MoreFiles.t Wed Nov 27 19:20:15 2002
@@ -0,0 +1,14 @@
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 1 }
+
+use Mac::MoreFiles;
+
+SKIP: {
+# skip "Mac::MoreFiles", 1;
+ ok(1);
+}
+
+__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/Notification/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Notification/Makefile.PL
--- macperl/macos/ext/Mac/Notification/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Notification/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,9 +1,22 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Notification),
- 'VERSION_FROM' => 'Notification.pm',
+my $mod = 'Notification';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- TYPEMAPS => 'typemap',
- XSPROTOARG => '-noprototypes', # XXX remove later?
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Notification/Notification.pm#3 (text) ====
Index: macperl/macos/ext/Mac/Notification/Notification.pm
--- macperl/macos/ext/Mac/Notification/Notification.pm#2~12323~ Wed Oct 3 11:42:37 2001
+++ macperl/macos/ext/Mac/Notification/Notification.pm Wed Nov 27 19:20:15 2002
@@ -23,7 +23,7 @@
use DynaLoader ();
use vars qw($VERSION @ISA @EXPORT);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
NMInstall
==== //depot/maint-5.6/macperl/macos/ext/Mac/Notification/Notification.xs#3 (text) ====
Index: macperl/macos/ext/Mac/Notification/Notification.xs
--- macperl/macos/ext/Mac/Notification/Notification.xs#2~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Notification/Notification.xs Wed Nov 27 19:20:15 2002
@@ -17,6 +17,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Notification.h>
#include <QuickDraw.h>
==== //depot/maint-5.6/macperl/macos/ext/Mac/Notification/t/Notification.t#3 (text) ====
Index: macperl/macos/ext/Mac/Notification/t/Notification.t
--- macperl/macos/ext/Mac/Notification/t/Notification.t#2~12210~ Tue Sep 25 12:28:20 2001
+++ macperl/macos/ext/Mac/Notification/t/Notification.t Wed Nov 27 19:20:15 2002
@@ -1,36 +1,119 @@
-#!perl
+#!/usr/bin/perl -w
+use File::Spec::Functions 'devnull';
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 10 }
use Mac::Notification;
-use Mac::Events;
use Mac::Processes;
-use Mac::Resources;
+use MacPerl 'DoAppleScript';
-sub DoNotify {
- my($notification) = @_;
+local *OLDERR;
- print "Switch me to the background, please!\n";
+SKIP: {
+# skip "Mac::Notification", 10;
- WaitNextEvent while SameProcess(GetCurrentProcess, GetFrontProcess);
- NMInstall($notification);
+ my($process, $name);
+ if ($^O eq 'MacOS') {
+ $name = 'MacPerl';
+ $process = GetCurrentProcess();
+ } else {
+ # current process is "perl"! We want the parent,
+ # e.g., Terminal, as it is hard to put a non-application
+ # process in the "background"
+ my $current = $Process{ GetCurrentProcess() };
+ my $parent = $Process{ $current->processLauncher };
+
+ # if no parent app, get Finder
+ if (!$parent) {
+ while (my($psn, $psi) = each %Process) {
+ $parent = $psi, last if $psi->processName eq 'Finder';
+ }
+ }
+ # we'll use perl if we have to, i suppose ...
+ $current = $parent if $parent;
+
+ $name = $current->processName;
+ $process = $current->processNumber;
+ }
+
+ ok($process, 'process number');
+ ok($name, 'process name');
+
+ if (SameProcess($process, GetFrontProcess())) {
+ ok(my $notification = NMRec->new(
+ nmStr => "Switch $name to the background, please. " .
+ "I'll switch in 30 seconds if you don't."
+ ), 'create notification');
+
+ close_stderr();
+ ok(NMInstall($notification), 'install notification');
+ open_stderr();
+
+ my $count = 0;
+ while (SameProcess($process, GetFrontProcess())) {
+ sleep 1;
+ if (++$count >= 30) {
+ # fails if Finder is not running ... but we don't want to
+ # wait around forever
+ DoAppleScript('tell app "Finder" to activate');
+ last;
+ }
+ }
+ ok(NMRemove($notification), 'remove notification');
+ } else {
+ ok(1, "$name is in background") for 1..3;
+ }
+
+ ok(my $notification = NMRec->new(
+ nmStr => "Please wait a few seconds, I will bring $name to the front.",
+ ), 'create notification');
+
+ close_stderr();
+ ok(NMInstall($notification), 'install notification');
+ open_stderr();
+
+ my $count = 0;
+ until (SameProcess($process, GetFrontProcess())) {
+ sleep 1;
+ last if ++$count >= 5;
+ }
+
+ ok(my $lp = new LaunchParam(
+ launchAppSpec => $Mac::Processes::Process{$process}->processAppSpec,
+ launchControlFlags => launchContinue(),
+ ), 'create launch param');
+ ok(LaunchApplication($lp), 'switching back');
- WaitNextEvent until SameProcess(GetCurrentProcess, GetFrontProcess);
- NMRemove($notification);
+ ok(NMRemove($notification), 'remove notification');
}
-#
-# Notify with dialog, system beep, check mark, application icon
-#
-DoNotify(new NMRec(nmStr=>"Thank you. Please bring MacPerl to the front again."));
+
+
+# Notification manager prints to STDERR
+sub close_stderr {
+ open OLDERR, ">&STDERR";
+ close STDERR;
+}
+
+sub open_stderr {
+ open STDERR, ">&OLDERR";
+}
+
+__END__
+
+# notification with sound is broken. can we fix it? test for it?
+# notification with app icon ... how to specify app icon, when "app"
+# is perl? any way?
#
# Notify with custom sound and application icon only.
# Sample from pitchshifter's _www.pitchshifter.com_ used with
# permission.
#
-chomp($file = `pwd`);
-$file .= "Notification.rsrc";
-print $file, "\n";
-($res = OpenResFile($file)) or die $^E;
+$file = -d 't' ? 't/Notification.rsrc' : 'Notification.rsrc';
+($res = FSpOpenResFile($file, 0)) or die $^E;
$snd = GetResource("snd ", 128);
DoNotify(new NMRec(nmMark=>0, nmSound=>$snd));
CloseResFile($res);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Processes/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Processes/Makefile.PL
--- macperl/macos/ext/Mac/Processes/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Processes/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,9 +1,25 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Processes),
- 'VERSION_FROM' => 'Processes.pm',
+my $mod = 'Processes';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- XSPROTOARG => '-noprototypes', # XXX remove later?
- 'LIBS' => ['"{{MW68KLibraries}}MathLibCFM68K (4i_8d).Lib" "{{MWPPCLibraries}}"MathLib'], # e.g., '-lm'
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+if ($^O eq 'MacOS') {
+ $args{'LIBS'} = ['"{{MW68KLibraries}}MathLibCFM68K (4i_8d).Lib" "{{MWPPCLibraries}}"MathLib'];
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Processes/Processes.pm#4 (text) ====
Index: macperl/macos/ext/Mac/Processes/Processes.pm
--- macperl/macos/ext/Mac/Processes/Processes.pm#3~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Processes/Processes.pm Wed Nov 27 19:20:15 2002
@@ -43,7 +43,7 @@
use vars qw(@ISA @EXPORT %Process $VERSION);
- $VERSION = '1.01';
+ $VERSION = '1.02';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
LaunchApplication
==== //depot/maint-5.6/macperl/macos/ext/Mac/Processes/Processes.xs#3 (text) ====
Index: macperl/macos/ext/Mac/Processes/Processes.xs
--- macperl/macos/ext/Mac/Processes/Processes.xs#2~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Processes/Processes.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Processes/Processes.xs,v 1.4 2002/01/23 05:44:42 pudge Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Processes/Processes.xs,v 1.5 2002/11/13 02:04:52 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Processes.xs,v $
+ * Revision 1.5 2002/11/13 02:04:52 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.4 2002/01/23 05:44:42 pudge
* Update whitespace etc., from Thomas
*
@@ -31,10 +34,15 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Memory.h>
#include <Processes.h>
+#ifdef MACOS_TRADITIONAL
#include <GUSIFileSpec.h>
+#endif
typedef LaunchPBPtr LaunchParam;
typedef ProcessInfoRecPtr ProcessInfo;
@@ -192,9 +200,13 @@
FSSpec spec;
FSSpec * fssp = nil;
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Processes::LaunchDeskAccessory unsupported in Carbon");
+#else
if (SvTRUE(pFileSpec) && GUSIPath2FSp(SvPV_nolen(pFileSpec), &spec))
fssp = &spec;
RETVAL = LaunchDeskAccessory(fssp, pDAName);
+#endif
OUTPUT:
RETVAL
==== //depot/maint-5.6/macperl/macos/ext/Mac/Processes/eg/Processes.plx#1 (text) ====
Index: macperl/macos/ext/Mac/Processes/eg/Processes.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Processes/eg/Processes.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,28 @@
+Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+
+#!perl
+#
+# Processes.t - List all processes, then try to launch MacPerl
+#
+
+use Mac::Processes;
+use Mac::MoreFiles(%Application);
+
+printf "%-20s %-8s %-8s\n", "Process Name", "PSN", "App Spec";
+
+while (($psn, $pi) = each %Process) {
+ printf "%-20s %08X %s\n",
+ $pi->processName, $pi->processNumber, $pi->processAppSpec;
+}
+
+my $app = $Application{McPL};
+if (-e $app) {
+ $Launch = new LaunchParam(
+ launchControlFlags => launchContinue+launchNoFileFlags+launchDontSwitch,
+ launchAppSpec => $app
+ );
+
+ LaunchApplication($Launch) || die $^E+0;
+
+ printf "Launched %X flags %X\n", $Launch->launchProcessSN, $Launch->launchControlFlags;
+}
==== //depot/maint-5.6/macperl/macos/ext/Mac/Processes/t/Processes.t#2 (text) ====
Index: macperl/macos/ext/Mac/Processes/t/Processes.t
--- macperl/macos/ext/Mac/Processes/t/Processes.t#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Processes/t/Processes.t Wed Nov 27 19:20:15 2002
@@ -1,25 +1,23 @@
-Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
-#!perl
-#
-# Processes.t - List all processes, then try to launch MacPerl
-#
+BEGIN { plan tests => 1 }
use Mac::Processes;
-use Mac::MoreFiles(%Application);
-printf "%-20s %-8s %-8s\n", "Process Name", "PSN", "Location";
+SKIP: {
+# skip "Mac::Processes", 1;
-while (($psn, $pi) = each %Process) {
- printf "%-20s %08X @%08X\n",
- $pi->processName, $pi->processNumber, $pi->processLocation;
-}
+# other process tests are in Notification.t
+# we should check struct fields, too
-$Launch = new LaunchParam(
- launchControlFlags => launchContinue+launchNoFileFlags+launchDontSwitch,
- launchAppSpec => $Application{McPL}
-);
+ my $exists = 1;
+ while (my($psn, $pi) = each %Mac::Processes::Process) {
+ $exists = 0, last unless -e $pi->processAppSpec;
+ }
+ ok($exists, 'check process paths');
-LaunchApplication($Launch) || die "$^E";
+}
-printf "Launched %X flags %X\n", $Launch->launchProcessSN, $Launch->launchControlFlags;
+__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/Resources/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Resources/Makefile.PL
--- macperl/macos/ext/Mac/Resources/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Resources/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,8 +1,22 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Resources),
- 'VERSION_FROM' => 'Resources.pm',
+my $mod = 'Resources';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- XSPROTOARG => '-noprototypes', # XXX remove later?
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Resources/Resources.pm#4 (text) ====
Index: macperl/macos/ext/Mac/Resources/Resources.pm
--- macperl/macos/ext/Mac/Resources/Resources.pm#3~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Resources/Resources.pm Wed Nov 27 19:20:15 2002
@@ -25,7 +25,7 @@
use DynaLoader ();
use vars qw($VERSION @ISA @EXPORT);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
CloseResFile
==== //depot/maint-5.6/macperl/macos/ext/Mac/Resources/Resources.xs#3 (text) ====
Index: macperl/macos/ext/Mac/Resources/Resources.xs
--- macperl/macos/ext/Mac/Resources/Resources.xs#2~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Resources/Resources.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Resources/Resources.xs,v 1.3 2002/01/23 05:44:42 pudge Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Resources/Resources.xs,v 1.4 2002/11/13 02:04:52 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Resources.xs,v $
+ * Revision 1.4 2002/11/13 02:04:52 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.3 2002/01/23 05:44:42 pudge
* Update whitespace etc., from Thomas
*
@@ -31,6 +34,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Memory.h>
#include <Resources.h>
@@ -121,12 +127,25 @@
}
=cut
+
+#ifndef MACOS_TRADITIONAL
+
+void
+CreateResFile(fileName)
+ Str255 fileName
+ CODE:
+ croak("Usage: Mac::Resourcecs::CreateResFile unsupported in Carbon");
+
+#else
+
void
CreateResFile(fileName)
Str255 fileName
CLEANUP:
ResErrorReturn;
+#endif
+
=item OpenResFile NAME
The OpenResFile function opens an existing resource file. It also makes this file
@@ -139,12 +158,25 @@
}
=cut
+
+#ifndef MACOS_TRADITIONAL
+
+short
+OpenResFile(fileName)
+ Str255 fileName
+ CODE:
+ croak("Usage: Mac::Resourcecs::OpenResFile unsupported in Carbon");
+
+#else
+
short
OpenResFile(fileName)
Str255 fileName
CLEANUP:
ResErrorCheckRetval;
+#endif
+
=item UseResFile RFD
The UseResFile procedure searches the list of files whose resource forks have
@@ -560,12 +592,25 @@
}
=cut
+
+#ifndef MACOS_TRADITIONAL
+
+long
+RsrcMapEntry(theResource)
+ Handle theResource
+ CODE:
+ croak("Usage: Mac::Resourcecs::CreateResFile unsupported in Carbon");
+
+#else
+
long
RsrcMapEntry(theResource)
Handle theResource
CLEANUP:
ResErrorCheckRetvalNULL;
+#endif
+
=item SetResAttrs HANDLE, ATTRS
Given a handle to a resource, SetResAttrs changes the resource attributes of the
@@ -767,12 +812,26 @@
}
=cut
+
+#ifndef MACOS_TRADITIONAL
+
+Handle
+RGetResource(theType, theID)
+ OSType theType
+ short theID
+ CODE:
+ croak("Usage: Mac::Resourcecs::RGetResource unsupported in Carbon");
+
+#else
+
Handle
RGetResource(theType, theID)
OSType theType
short theID
CLEANUP:
ResErrorCheckRetvalNULL;
+
+#endif
=item FSpOpenResFile SPEC, PERMISSION
==== //depot/maint-5.6/macperl/macos/ext/Mac/Resources/t/Resources.t#3 (text) ====
Index: macperl/macos/ext/Mac/Resources/t/Resources.t
--- macperl/macos/ext/Mac/Resources/t/Resources.t#2~14073~ Fri Jan 4 12:40:11 2002
+++ macperl/macos/ext/Mac/Resources/t/Resources.t Wed Nov 27 19:20:15 2002
@@ -1,3 +1,18 @@
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 1 }
+
+use Mac::Resources;
+
+SKIP: {
+# skip "Mac::Resources", 1;
+ ok(1);
+}
+
+__END__
+
Perl -Sx "{0}" {"Parameters"}; Exit {Status}
#!perl
==== //depot/maint-5.6/macperl/macos/ext/Mac/Sound/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Sound/Makefile.PL
--- macperl/macos/ext/Mac/Sound/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Sound/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,10 +1,33 @@
use ExtUtils::MakeMaker;
+use File::Spec::Functions;
-WriteMakefile(
- NAME => q(Mac::Sound),
- 'VERSION_FROM' => 'Sound.pm',
+my $mod = 'Sound';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- TYPEMAPS => '::QuickDraw:typemap',
- XSPROTOARG => '-noprototypes', # XXX remove later?
- 'MACLIBS_SHARED' => '"{{SharedLibraries}}"SoundLib', # e.g., '-lm'
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
+
+ 'TYPEMAPS' => [
+ catfile(updir(), 'QuickDraw', 'typemap'),
+ ],
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+if ($^O eq 'MacOS') {
+ $args{'MACLIBS_SHARED'} = '"{{SharedLibraries}}"SoundLib';
+}
+if ($^O eq 'MacOS' && $] < 5.8) { # old makemaker syntax?
+ $args{'TYPEMAPS'} = join ' ', @{$args{'TYPEMAPS'}};
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Sound/Sound.pm#4 (text) ====
Index: macperl/macos/ext/Mac/Sound/Sound.pm
--- macperl/macos/ext/Mac/Sound/Sound.pm#3~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Sound/Sound.pm Wed Nov 27 19:20:15 2002
@@ -24,7 +24,7 @@
use Mac::Memory();
use vars qw($VERSION @ISA @EXPORT);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
twelfthRootTwo
==== //depot/maint-5.6/macperl/macos/ext/Mac/Sound/Sound.xs#3 (text) ====
Index: macperl/macos/ext/Mac/Sound/Sound.xs
--- macperl/macos/ext/Mac/Sound/Sound.xs#2~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Sound/Sound.xs Wed Nov 27 19:20:15 2002
@@ -17,6 +17,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Sound.h>
@@ -156,10 +159,14 @@
short id
SndCommand &cmd
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Sound::SndControl unsupported in Carbon");
+#else
RETVAL = cmd;
if (gMacPerl_OSErr = SndControl(id, &RETVAL)) {
XSRETURN_UNDEF;
}
+#endif
OUTPUT:
RETVAL
@@ -176,12 +183,33 @@
SV * theCompletion
Boolean async
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Sound::SndStartFilePlay unsupported in Carbon");
+#else
RETVAL =
SndStartFilePlay(
chan, fRefNum, resNum, bufferSize, nil, &theSelection, nil, async);
+#endif
OUTPUT:
RETVAL
+#ifndef MACOS_TRADITIONAL
+
+MacOSRet
+SndPauseFilePlay(chan)
+ SndChannel chan
+ CODE:
+ croak("Usage: Mac::Sound::SndPauseFilePlay unsupported in Carbon");
+
+MacOSRet
+SndStopFilePlay(chan, quietNow)
+ SndChannel chan
+ Boolean quietNow
+ CODE:
+ croak("Usage: Mac::Sound::SndStopFilePlay unsupported in Carbon");
+
+#else
+
MacOSRet
SndPauseFilePlay(chan)
SndChannel chan
@@ -191,6 +219,8 @@
SndChannel chan
Boolean quietNow
+#endif
+
SCStatus
SndChannelStatus(chan)
SndChannel chan
@@ -232,9 +262,20 @@
=cut
+#ifndef MACOS_TRADITIONAL
+
+NumVersion
+MACEVersion()
+ CODE:
+ croak("Usage: Mac::Sound::MACEVersion unsupported in Carbon");
+
+#else
+
NumVersion
MACEVersion()
+#endif
+
void
Comp3to1(inBuffer, inState=NO_INIT, numChannels=1, whichChannel=1)
SV * inBuffer
@@ -243,6 +284,9 @@
unsigned long whichChannel
PPCODE:
{
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Sound::Comp3to1 unsupported in Carbon");
+#else
unsigned long cnt = SvCUR(inBuffer);
SV * outBuffer = newSVpv("", cnt / 3);
StateBlock outState;
@@ -253,6 +297,7 @@
if (GIMME == G_ARRAY) {
XS_PUSH(StateBlock, outState);
}
+#endif
}
void
@@ -263,6 +308,9 @@
unsigned long whichChannel
PPCODE:
{
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Sound::Exp1to3 unsupported in Carbon");
+#else
unsigned long cnt = SvCUR(inBuffer) / 2;
SV * outBuffer = newSVpv("", cnt*6);
StateBlock outState;
@@ -273,6 +321,7 @@
if (GIMME == G_ARRAY) {
XS_PUSH(StateBlock, outState);
}
+#endif
}
void
@@ -283,6 +332,9 @@
unsigned long whichChannel
PPCODE:
{
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Sound::Comp6to1 unsupported in Carbon");
+#else
unsigned long cnt = SvCUR(inBuffer);
SV * outBuffer = newSVpv("", cnt / 6);
StateBlock outState;
@@ -293,6 +345,7 @@
if (GIMME == G_ARRAY) {
XS_PUSH(StateBlock, outState);
}
+#endif
}
void
@@ -303,6 +356,9 @@
unsigned long whichChannel
PPCODE:
{
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Sound::Exp1to6 unsupported in Carbon");
+#else
unsigned long cnt = SvCUR(inBuffer);
SV * outBuffer = newSVpv("", cnt * 6);
StateBlock outState;
@@ -313,6 +369,7 @@
if (GIMME == G_ARRAY) {
XS_PUSH(StateBlock, outState);
}
+#endif
}
long
@@ -511,7 +568,11 @@
OSType quality
short fRefNum
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: Mac::Sound::SndRecordToFile unsupported in Carbon");
+#else
RETVAL = SndRecordToFile(nil, corner, quality, fRefNum);
+#endif
OUTPUT:
RETVAL
@@ -563,11 +624,25 @@
SPB &inParamPtr
Boolean asynchFlag
+#ifndef MACOS_TRADITIONAL
+
MacOSRet
SPBRecordToFile(fRefNum, inParamPtr, asynchFlag=false)
short fRefNum
SPB &inParamPtr
Boolean asynchFlag
+ CODE:
+ croak("Usage: Mac::Sound::SPBRecordToFile unsupported in Carbon");
+
+#else
+
+MacOSRet
+SPBRecordToFile(fRefNum, inParamPtr, asynchFlag=false)
+ short fRefNum
+ SPB &inParamPtr
+ Boolean asynchFlag
+
+#endif
MacOSRet
SPBPauseRecording(inRefNum)
==== //depot/maint-5.6/macperl/macos/ext/Mac/Sound/t/Scream.rsrc#1 (apple) ====
==== //depot/maint-5.6/macperl/macos/ext/Mac/Sound/t/Sound.t#1 (text) ====
Index: macperl/macos/ext/Mac/Sound/t/Sound.t
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Sound/t/Sound.t Wed Nov 27 19:20:15 2002
@@ -0,0 +1,89 @@
+#!/usr/bin/perl -w
+use File::Spec::Functions;
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 14 }
+
+use Mac::Resources;
+use Mac::Sound;
+
+SKIP: {
+# skip "Mac::Sound Beeps", 4;
+
+ my $vol = GetDefaultOutputVolume();
+ ok(defined($vol), 'get current volume');
+ SysBeep(30);
+ sleep(1); # allow user to hear
+
+ ok(SetDefaultOutputVolume(2**32), 'set high volume');
+ SysBeep(30);
+ sleep(1);
+
+ ok(SetDefaultOutputVolume(0), 'set low volume');
+ SysBeep(30);
+ sleep(1);
+
+ ok(SetDefaultOutputVolume($vol), 'set default volume');
+ SysBeep(30);
+ sleep(1);
+}
+
+
+SKIP: {
+# skip "Mac::Sound Resource", 10;
+
+ my $ofil = 'Scream.rsrc';
+ my $otyp = soundListRsrc();
+ my $oid = 129;
+ my $onam = 'Original';
+
+ my $file1 = catfile(curdir(), 't', $ofil);
+ my $file2 = catfile(curdir(), 'Sound', 't', $ofil);
+ my $file = -e $ofil ? $ofil
+ : -e $file1 ? $file1
+ : -e $file2 ? $file2
+ : '';
+
+ my($res, $snd);
+ $res = FSpOpenResFile($file, 0) if $file;
+
+ if ($res) {
+ ok($res, 'open resource file');
+ is(CurResFile(), $res, 'check current resource file');
+
+ is(Count1Resources($otyp), 1, 'count resources');
+ ok($snd = GetResource($otyp, $oid), 'get resource');
+
+ my($id, $type, $name) = GetResInfo($snd);
+ is($type, $otyp, 'resource type');
+ is($id, $oid, 'resource id');
+ is($name, $onam, 'resource name');
+ }
+
+ else {
+ ok(1, "Can't open $ofil") for 1..2;
+
+ my $n = Count1Resources($otyp);
+ ok($n, "count resources: $n");
+ ok($snd = GetIndResource($otyp, $n), 'get resource');
+
+ my($id, $type, $name) = GetResInfo($snd);
+ TODO: {
+ local $TODO = "For some reason, it is not getting the type back"
+ if $^O eq 'darwin';
+ is($type, $otyp, "resource type: $type");
+ }
+ ok($id, "resource id: $id");
+
+ ok(1, "Can't open $ofil");
+ }
+
+ ok(my $chan = SndNewChannel(0, 0), 'new sound channel');
+ ok(SndPlay($chan, $snd, 0), 'play sound');
+ ok(SndDisposeChannel($chan, 0), 'dispose sound');
+
+ CloseResFile($res) if $res;
+}
+
+__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Speech/Makefile.PL
--- macperl/macos/ext/Mac/Speech/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Speech/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,9 +1,26 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Speech),
- 'VERSION_FROM' => 'Speech.pm',
+my $mod = 'Speech';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- XSPROTOARG => '-noprototypes', # XXX remove later?
- MACLIBS_SHARED => '"{{SharedLibraries}}"SpeechLib', # e.g., '-lm'
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+if ($^O eq 'MacOS') {
+ $args{'MACLIBS_SHARED'} = '"{{SharedLibraries}}"SpeechLib';
+
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/Speech.pm#4 (text) ====
Index: macperl/macos/ext/Mac/Speech/Speech.pm
--- macperl/macos/ext/Mac/Speech/Speech.pm#3~14394~ Wed Jan 23 12:00:35 2002
+++ macperl/macos/ext/Mac/Speech/Speech.pm Wed Nov 27 19:20:15 2002
@@ -24,7 +24,7 @@
use DynaLoader ();
use vars qw($VERSION @ISA @EXPORT %Voice);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
SpeechManagerVersion
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/Speech.xs#2 (text) ====
Index: macperl/macos/ext/Mac/Speech/Speech.xs
--- macperl/macos/ext/Mac/Speech/Speech.xs#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Speech/Speech.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Speech/Speech.xs,v 1.2 2000/09/09 22:18:28 neeri Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Speech/Speech.xs,v 1.3 2002/11/13 02:04:53 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Speech.xs,v $
+ * Revision 1.3 2002/11/13 02:04:53 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.2 2000/09/09 22:18:28 neeri
* Dynamic libraries compile under 5.6
*
@@ -31,6 +34,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Memory.h>
#include <Speech.h>
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/Cellist.plx#1 (text) ====
Index: macperl/macos/ext/Mac/Speech/eg/Cellist.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Speech/eg/Cellist.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,22 @@
+#!perl
+#
+# Say something in Cello
+#
+
+use Mac::Speech;
+
+$count = CountVoices();
+
+for ($i = 0; $i++ < $count; ) {
+ $voice = GetIndVoice($i);
+ $desc = ${GetVoiceDescription($voice)};
+ if ($desc =~ /Cello/) {
+ $channel = NewSpeechChannel($voice) or die $^E;
+ SpeakText $channel, "Do you like my Cello Voice?" or die $^E;
+ while (SpeechBusy()) {}
+ SetSpeechPitch $channel, 1.2*GetSpeechPitch($channel);
+ SpeakText $channel, "Wanna take you higher" or die $^E;
+ while (SpeechBusy()) {}
+ DisposeSpeechChannel $channel;
+ }
+}
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/DumpVoices.plx#1 (text) ====
Index: macperl/macos/ext/Mac/Speech/eg/DumpVoices.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Speech/eg/DumpVoices.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,18 @@
+#!perl
+#
+# Dump all avaliable voices
+#
+
+use Mac::Speech;
+
+$count = CountVoices();
+
+for ($i = 0; $i++ < $count; ) {
+ $voice = GetIndVoice($i);
+ $desc = ${GetVoiceDescription($voice)};
+ ($synt, $id, $version,$nlen,$name,$clen,$comment,$gender,$age,$script,$language,$region)
+ = unpack("x4 a4 l l C a63 C a255 s s s s s", $desc);
+ $name = substr $name, 0, $nlen;
+ $comment = substr $comment, 0, $clen;
+ printf "%4s %2X %3X %-10s %d %4d %s\n", $synt, $id, $version, $name, $gender, $age, $comment;
+}
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/JukeBox.plx#1 (text) ====
Index: macperl/macos/ext/Mac/Speech/eg/JukeBox.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Speech/eg/JukeBox.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,21 @@
+#!perl
+#
+# Demonstrate all avaliable voices
+#
+
+use Mac::Speech;
+
+$count = CountVoices();
+
+for ($i = 0; $i++ < $count; ) {
+ $voice = GetIndVoice($i);
+ $desc = ${GetVoiceDescription($voice)};
+ ($synt, $id, $version,$nlen,$name,$clen,$comment,$gender,$age,$script,$language,$region)
+ = unpack("x4 a4 l l C a63 C a255 s s s s s", $desc);
+ $name = substr $name, 0, $nlen;
+ $comment = substr $comment, 0, $clen;
+ $channel = NewSpeechChannel($voice) or die $^E;
+ SpeakText $channel, $comment or die $^E;
+ while (SpeechBusy()) {}
+ DisposeSpeechChannel $channel;
+}
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/eg/Phonemes.plx#1 (text) ====
Index: macperl/macos/ext/Mac/Speech/eg/Phonemes.plx
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Speech/eg/Phonemes.plx Wed Nov 27 19:20:15 2002
@@ -0,0 +1,19 @@
+#!perl
+#
+# Say something in Cello
+#
+
+use Mac::Speech;
+
+$count = CountVoices();
+
+for ($i = 0; $i++ < $count; ) {
+ $voice = GetIndVoice($i);
+ $desc = ${GetVoiceDescription($voice)};
+ if ($desc =~ /Cello/) {
+ $channel = NewSpeechChannel($voice) or die $^E;
+ $phon = TextToPhonemes($channel, "Stop all the clocks disconnect the phone");
+ print $phon;
+ DisposeSpeechChannel $channel;
+ }
+}
==== //depot/maint-5.6/macperl/macos/ext/Mac/Speech/t/Speech.t#1 (text) ====
Index: macperl/macos/ext/Mac/Speech/t/Speech.t
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/Mac/Speech/t/Speech.t Wed Nov 27 19:20:15 2002
@@ -0,0 +1,43 @@
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 8 }
+
+use Mac::Files;
+use Mac::Speech;
+
+SKIP: {
+# skip "Mac::Speech", 8;
+
+ my @voicefiles;
+ my $voicedir = FindFolder(kOnSystemDisk, kVoicesFolderType);
+ if (opendir(my $dh, $voicedir)) {
+ @voicefiles = grep /\w/, readdir $dh;
+ closedir $dh;
+ }
+
+ # this can fail if some voices don't load, or if there are
+ # non-voice files installed in the directory
+ cmp_ok(CountVoices(), '>=', scalar @voicefiles, 'count voices');
+
+ ok(my $voice = $Mac::Speech::Voice{Cello}, 'load voice');
+ ok(my $channel = NewSpeechChannel($voice), 'new channel');
+ ok(SpeakText($channel, "Do you like my Cello Voice?"),
+ 'speak');
+ sleep 1 while SpeechBusy();
+
+ ok(SetSpeechPitch($channel, 1.2*GetSpeechPitch($channel)),
+ 'adjust pitch');
+ ok(SpeakText($channel, "Wanna take you higher"),
+ 'speak!');
+ sleep 1 while SpeechBusy();
+
+ is(TextToPhonemes($channel, 'Stop all the clocks disconnect the phone'),
+ '_st1AAp _1AOl ~DAX _kl1AAks _d2IHskAXn1EHkt ~DAX _f1OWn',
+ 'phonemes');
+
+ ok(DisposeSpeechChannel($channel), 'dispose channel');
+}
+
+__END__
==== //depot/maint-5.6/macperl/macos/ext/Mac/Types/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/Mac/Types/Makefile.PL
--- macperl/macos/ext/Mac/Types/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Types/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,8 +1,22 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => q(Mac::Types),
- 'VERSION_FROM' => 'Types.pm',
+my $mod = 'Types';
+my %args = (
+ 'NAME' => "Mac::$mod",
+ 'VERSION_FROM' => "$mod.pm",
'LINKTYPE' => 'static dynamic',
- XSPROTOARG => '-noprototypes', # XXX remove later?
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/Mac/Types/Types.pm#3 (text) ====
Index: macperl/macos/ext/Mac/Types/Types.pm
--- macperl/macos/ext/Mac/Types/Types.pm#2~12323~ Wed Oct 3 11:42:37 2001
+++ macperl/macos/ext/Mac/Types/Types.pm Wed Nov 27 19:20:15 2002
@@ -17,13 +17,15 @@
package Mac::Types;
+use MacPerl 'MakeFSSpec';
+
BEGIN {
use Exporter ();
use DynaLoader ();
use Carp;
use vars qw($VERSION @ISA @EXPORT %MacPack %MacUnpack);
- $VERSION = '1.00';
+ $VERSION = '1.01';
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
==== //depot/maint-5.6/macperl/macos/ext/Mac/Types/Types.xs#2 (text) ====
Index: macperl/macos/ext/Mac/Types/Types.xs
--- macperl/macos/ext/Mac/Types/Types.xs#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Types/Types.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Types/Types.xs,v 1.2 2000/09/09 22:18:29 neeri Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Types/Types.xs,v 1.3 2002/11/13 02:04:53 pudge Exp $
*
* Copyright (c) 1996 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: Types.xs,v $
+ * Revision 1.3 2002/11/13 02:04:53 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.2 2000/09/09 22:18:29 neeri
* Dynamic libraries compile under 5.6
*
@@ -25,6 +28,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
MODULE = Mac::Types PACKAGE = Mac::Types
==== //depot/maint-5.6/macperl/macos/ext/Mac/Types/t/Types.t#2 (text) ====
Index: macperl/macos/ext/Mac/Types/t/Types.t
--- macperl/macos/ext/Mac/Types/t/Types.t#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/Mac/Types/t/Types.t Wed Nov 27 19:20:15 2002
@@ -1,16 +1,26 @@
-Perl -Sx "{0}" {"Parameters"}; Exit {Status}
+#!/usr/bin/perl -w
+use Test::More;
+use strict;
-#!perl
-#
-# Types.t - Demostrate MacPack and MacUnpack.
-#
+BEGIN { plan tests => 4 }
+use Mac::Files;
use Mac::Types;
+use MacPerl 'MakeFSSpec';
-$p = MacPack("STR ", "Hello");
+SKIP: {
+# skip "Mac::Types", 4;
-print $p, " ", length($p), "\n";
+ my $s = "Hello";
+ my $p = MacPack("STR ", $s);
+ is($p, (chr(length $s) . $s), 'pascal string');
+ my $u = MacUnpack("STR ", "$p dskjkjkdsjk");
+ is($u, $s, 'regular string');
+
+ my $path = MakeFSSpec(FindFolder(kOnSystemDisk, kApplicationSupportFolderType));
+ my $fss = MacPack('fss ', $path);
+ isnt($path, $fss, 'to real FSSpec');
+ is($path, MacUnpack('fss ', $fss), 'back to string FSSpec');
+}
-$u = MacUnpack("STR ", "$p dskjkjkdsjk");
-
-print $u, " ", length($u), "\n";
+__END__
==== //depot/maint-5.6/macperl/macos/ext/MacPerl/MacPerl.pm#4 (text) ====
Index: macperl/macos/ext/MacPerl/MacPerl.pm
--- macperl/macos/ext/MacPerl/MacPerl.pm#3~14075~ Fri Jan 4 12:42:06 2002
+++ macperl/macos/ext/MacPerl/MacPerl.pm Wed Nov 27 19:20:15 2002
@@ -2,6 +2,8 @@
require Exporter;
+$VERSION = '1.01';
+
@ISA = qw(Exporter);
@EXPORT = qw(
@@ -36,12 +38,40 @@
%EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
-# bootstrap MacPerl is already implicitly done by your MacPerl binary
-
sub kMacPerlNeverQuit () { 0; }
sub kMacPerlQuitIfRuntime () { 1; }
sub kMacPerlAlwaysQuit () { 2; }
sub kMacPerlQuitIfFirstScript () { 3; }
+
+# bootstrap MacPerl is already implicitly done by your MacPerl binary
+unless ($^O eq 'MacOS') {
+ # use Config;
+ # my $dl_dlext = $Config::Config{'dlext'};
+ my $dl_dlext = 'bundle';
+
+ require DynaLoader;
+ push @ISA, 'DynaLoader';
+ bootstrap MacPerl;
+
+ # because OSA is in MacPerl.bundle, not OSA.bundle
+ my $file = "auto/MacPerl/MacPerl.$dl_dlext";
+ foreach (@INC) {
+ $dir = "$_/auto/MacPerl";
+ next unless -d $dir;
+ my $try = "$dir/MacPerl.$dl_dlext";
+ last if $file = -f $try && $try;
+ }
+
+ for my $mod (qw(OSA)) {
+ my($xs, $symref);
+ for (@DynaLoader::dl_librefs) {
+ last if $symref = DynaLoader::dl_find_symbol($_, "boot_$mod");
+ }
+ next unless $symref;
+ $xs = DynaLoader::dl_install_xsub("${mod}::bootstrap", $symref, $file);
+ &$xs($mod);
+ }
+}
1;
==== //depot/maint-5.6/macperl/macos/ext/MacPerl/MacPerl.xs#4 (text) ====
Index: macperl/macos/ext/MacPerl/MacPerl.xs
--- macperl/macos/ext/MacPerl/MacPerl.xs#3~12325~ Wed Oct 3 11:51:28 2001
+++ macperl/macos/ext/MacPerl/MacPerl.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/MacPerl/MacPerl.xs,v 1.3 2001/09/02 00:38:40 pudge Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/MacPerl/MacPerl.xs,v 1.4 2002/11/13 02:04:53 pudge Exp $
*
* Copyright (c) 1995 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: MacPerl.xs,v $
+ * Revision 1.4 2002/11/13 02:04:53 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.3 2001/09/02 00:38:40 pudge
* Sync with perforce
*
@@ -34,11 +37,16 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <QuickDraw.h>
#include <Dialogs.h>
#include <Lists.h>
+#ifdef MACOS_TRADITIONAL
#include <GUSIFileSpec.h>
+#endif
#include <PLStringFuncs.h>
#include <Files.h>
#include <Fonts.h>
@@ -117,6 +125,8 @@
static char gMacPerlScratch[256];
#define gMacPerlScratchString ((StringPtr) gMacPerlScratch)
+#ifdef MACOS_TRADITIONAL
+
static ControlHandle GetDlgCtrl(DialogPtr dlg, short item)
{
short kind;
@@ -300,6 +310,8 @@
#define uMacListFilter MacListFilter
#endif
+#endif /* MACOS_TRADITIONAL */
+
static OSErr GetVolInfo(short volume, Boolean indexed, FSSpec * spec)
{
OSErr err;
@@ -367,6 +379,9 @@
MP_Ask(prompt, ...)
char * prompt
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: MacPerl::Ask unsupported in Carbon");
+#else
{
short item;
DialogPtr dlg;
@@ -394,11 +409,15 @@
}
DisposeDialog(dlg);
}
+#endif
int
MP_Answer(prompt, ...)
char * prompt
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: MacPerl::Answer unsupported in Carbon");
+#else
{
short item;
DialogPtr dlg;
@@ -427,6 +446,7 @@
RETVAL = (items > 1) ? items - item - 1 : 0;
}
+#endif
OUTPUT:
RETVAL
@@ -466,6 +486,9 @@
MP_Pick(prompt, ...)
char * prompt
PPCODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: MacPerl::Pick unsupported in Carbon");
+#else
{
short itemHit;
STRLEN len;
@@ -532,22 +555,31 @@
gPickList = nil;
DisposeDialog(dlg);
}
+#endif
int
MP_Quit(...)
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: MacPerl::Quit unsupported in Carbon");
+#else
if (items > 0)
gMacPerl_Quit = SvIV(ST(0));
RETVAL = gMacPerl_Quit;
+#endif
OUTPUT:
RETVAL
int
MP_ErrorFormat(...)
CODE:
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: MacPerl::ErrorFormat unsupported in Carbon");
+#else
if (items > 0)
gMacPerl_ErrorFormat = SvIV(ST(0));
RETVAL = gMacPerl_ErrorFormat;
+#endif
OUTPUT:
RETVAL
@@ -557,6 +589,9 @@
unsigned cmd
PPCODE:
{
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: MacPerl::FAccess unsupported in Carbon");
+#else
unsigned uarg;
Rect rarg;
SelectionRecord sarg;
@@ -686,6 +721,7 @@
default:
croak("MacPerl::FAccess() can't handle this command");
}
+#endif
}
void
@@ -735,6 +771,8 @@
BOOT:
{
+/* This is all MacPerl-specific stuff */
+#ifdef MACOS_TRADITIONAL
extern int StandAlone;
VersRecHndl vers = (VersRecHndl) GetResource('vers', 1);
int versLen = *(*vers)->shortVersion;
@@ -757,4 +795,5 @@
sv_setpv(cc, CC);
SvREADONLY_on(cc);
+#endif
}
==== //depot/maint-5.6/macperl/macos/ext/MacPerl/Makefile.PL#2 (text) ====
Index: macperl/macos/ext/MacPerl/Makefile.PL
--- macperl/macos/ext/MacPerl/Makefile.PL#1~11243~ Mon Jul 9 15:16:12 2001
+++ macperl/macos/ext/MacPerl/Makefile.PL Wed Nov 27 19:20:15 2002
@@ -1,9 +1,28 @@
use ExtUtils::MakeMaker;
-WriteMakefile(
- 'NAME' => q(MacPerl),
- 'LINKTYPE' => ['static'],
- SKIP => [qw(dynamic dynamic_lib dynamic_bs)],
- 'OBJECT' => 'MacPerl.c XL.c OSA.c',
- 'INC' => "-i :::::XL:"
+my %args = (
+ 'NAME' => 'MacPerl',
+ 'VERSION_FROM' => 'MacPerl.pm',
+ 'XSPROTOARG' => '-noprototypes', # XXX remove later?
);
+
+# disable tests if set up outside current dir
+use Cwd;
+if ($ENV{PWD} && $ENV{PWD} ne cwd()) {
+ *MY::test = sub { "test ::\n\t\@\$(NOOP)" };
+}
+
+if ($^O eq 'darwin') {
+ $args{'LINKTYPE'} = 'dynamic';
+ $args{'OBJECT'} = 'MacPerl.o OSA.o';
+ $args{'INC'} = '-I/Developer/Headers/FlatCarbon/';
+ $args{'LDDLFLAGS'} = '-bundle -flat_namespace -undefined suppress -framework Carbon';
+}
+if ($^O eq 'MacOS') {
+ $args{'LINKTYPE'} = 'static';
+ $args{'SKIP'} = [qw(dynamic dynamic_lib dynamic_bs)];
+ $args{'OBJECT'} = 'MacPerl.c XL.c OSA.c';
+ $args{'INC'} = "-i :::::XL:";
+}
+
+WriteMakefile(%args);
==== //depot/maint-5.6/macperl/macos/ext/MacPerl/OSA.xs#4 (text) ====
Index: macperl/macos/ext/MacPerl/OSA.xs
--- macperl/macos/ext/MacPerl/OSA.xs#3~14075~ Fri Jan 4 12:42:06 2002
+++ macperl/macos/ext/MacPerl/OSA.xs Wed Nov 27 19:20:15 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/MacPerl/OSA.xs,v 1.3 2001/12/19 22:54:15 pudge Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/MacPerl/OSA.xs,v 1.4 2002/11/13 02:04:53 pudge Exp $
*
* Copyright (c) 1995 Matthias Neeracher
*
@@ -6,6 +6,9 @@
* as specified in the README file.
*
* $Log: OSA.xs,v $
+ * Revision 1.4 2002/11/13 02:04:53 pudge
+ * Aieeeeee! Big ol' Carbon update.
+ *
* Revision 1.3 2001/12/19 22:54:15 pudge
* Make DoAppleScript return errors in $@
*
@@ -28,6 +31,9 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#ifndef MACOS_TRADITIONAL
+#include "../Carbon.h"
+#endif
#include <Types.h>
#include <Components.h>
#include <AppleEvents.h>
@@ -93,10 +99,14 @@
char * reply
CODE:
{
+#ifndef MACOS_TRADITIONAL
+ croak("Usage: MacPerl::Reply unsupported in Carbon");
+#else
if (gMacPerl_Reply)
DisposeHandle(gMacPerl_Reply);
- /**/
+
PtrToHand(reply, &gMacPerl_Reply, strlen(reply));
+#endif
}
void
@@ -104,70 +114,98 @@
SV * script
CODE:
{
- AEDesc source;
- AEDesc result;
- char * scriptText;
- STRLEN len;
OSAError myOSAErr;
- AEDesc source_errs;
- AEDesc result_errs;
- char * errorText;
- STRLEN errorLen;
- /**/
+ char * scriptText;
+ STRLEN scriptTextLen;
+ AEDesc scriptTextDesc;
+ AEDesc scriptResultDesc;
+
if (!gScriptingComponent && InitAppleScript())
croak("MacPerl::DoAppleScript couldn't initialize AppleScript");
- /**/
+
sv_setpvn(ERRSV, "", 0);
- scriptText = (char*) SvPV(ST(0), len);
- AECreateDesc(typeChar, scriptText, len, &source);
- /**/
+ scriptText = (char*) SvPV(ST(0), scriptTextLen);
+ AECreateDesc(typeChar, scriptText, scriptTextLen, &scriptTextDesc);
+
myOSAErr = OSADoScript(
gScriptingComponent,
- &source,
+ &scriptTextDesc,
kOSANullScript,
typeChar,
kOSAModeCanInteract,
- &result
+ &scriptResultDesc
);
- if (!myOSAErr)
- {
- AEDisposeDesc(&source);
- /**/
- if (!AECoerceDesc(&result, typeChar, &source)) {
- HLock(source.dataHandle);
- ST(0) = sv_2mortal(newSVpv(*source.dataHandle,GetHandleSize(source.dataHandle)));
- AEDisposeDesc(&source);
+ AEDisposeDesc(&scriptTextDesc);
+
+ if (!myOSAErr) {
+ char * scriptResultData;
+ STRLEN scriptResultLen;
+ AEDesc scriptResultDataDesc;
+
+ if (!AECoerceDesc(&scriptResultDesc, typeChar, &scriptResultDataDesc)) {
+#ifdef MACOS_TRADITIONAL
+ HLock(scriptResultDataDesc.dataHandle);
+ scriptResultLen = GetHandleSize(scriptResultDataDesc.dataHandle);
+ scriptResultData = *scriptResultDataDesc.dataHandle;
+#else
+ scriptResultLen = AEGetDescDataSize(&scriptResultDataDesc);
+ scriptResultData = NewPtr(scriptResultLen);
+ AEGetDescData(&scriptResultDataDesc, scriptResultData, scriptResultLen);
+#endif
+
+ ST(0) = sv_2mortal(newSVpv(scriptResultData, scriptResultLen));
+
+ AEDisposeDesc(&scriptResultDataDesc);
+#ifndef MACOS_TRADITIONAL
+ DisposePtr(scriptResultData);
+#endif
} else
ST(0) = &PL_sv_undef;
- /**/
- AEDisposeDesc(&result);
- } else {
- AEDisposeDesc(&source);
+
+ AEDisposeDesc(&scriptResultDesc);
+ }
+
+ else {
if (myOSAErr == errOSAScriptError) {
+ AEDesc errorDesc;
+ AEDesc errorDataDesc;
+
OSAScriptError(
gScriptingComponent,
kOSAErrorMessage,
typeChar,
- &result_errs
+ &errorDesc
);
- AEDisposeDesc(&source_errs);
- if (!AECoerceDesc(&result_errs, typeChar, &source_errs)) {
- errorText = "";
- HLock(source_errs.dataHandle);
- /* set $@ */
- errorLen = GetHandleSize(source_errs.dataHandle);
- strcpy(errorText, *source_errs.dataHandle);
- if (strchr(errorText+errorLen-1, '.')) {
+ if (!AECoerceDesc(&errorDesc, typeChar, &errorDataDesc)) {
+ char * errorData;
+ STRLEN errorLen;
+#ifdef MACOS_TRADITIONAL
+ HLock(errorDataDesc.dataHandle);
+ errorLen = GetHandleSize(errorDataDesc.dataHandle);
+ errorData = *errorDataDesc.dataHandle;
+#else
+ errorLen = AEGetDescDataSize(&errorDataDesc);
+ errorData = NewPtr(errorLen);
+ AEGetDescData(&errorDataDesc, errorData, errorLen);
+#endif
+
+ /* AppleScript errors end in '.', we don't want it */
+ if (strchr(errorData+errorLen-1, '.')) {
errorLen--;
}
- sv_setpvn(ERRSV, errorText, errorLen);
- AEDisposeDesc(&source_errs);
+ /* set $@ */
+ sv_setpvn(ERRSV, errorData, errorLen);
+
+ AEDisposeDesc(&errorDataDesc);
+#ifndef MACOS_TRADITIONAL
+ DisposePtr(errorData);
+#endif
}
- AEDisposeDesc(&result_errs);
+ AEDisposeDesc(&errorDesc);
}
- /**/
+
ST(0) = &PL_sv_undef;
}
}
==== //depot/maint-5.6/macperl/macos/ext/MacPerl/t/MacPerl.t#1 (text) ====
Index: macperl/macos/ext/MacPerl/t/MacPerl.t
--- /dev/null Tue May 5 13:32:27 1998
+++ macperl/macos/ext/MacPerl/t/MacPerl.t Wed Nov 27 19:20:15 2002
@@ -0,0 +1,88 @@
+#!/usr/bin/perl -w
+use File::Spec::Functions;
+use Test::More;
+use strict;
+
+BEGIN { plan tests => 10 }
+
+use MacPerl ':all';
+
+SKIP: {
+# skip "MacPerl", 10;
+
+ my @volumes = Volumes();
+ ok(@volumes, 'Volumes: ' . join(', ', @volumes));
+
+ # convert FSSpecs to paths
+ my $exists = 1;
+ my @paths;
+ for (@volumes) {
+ push @paths, my $path = MakePath($_);
+ $exists = 0 unless -d $path;
+ }
+ ok($exists, 'MakePath: ' . join(', ', map { MakePath($_) } @paths));
+
+ # go back!
+ $_ = MakeFSSpec($_) for @paths;
+ ok(eq_array(\@volumes, \@paths), 'MakeFSSpec');
+
+ # AppleScript / Finder version; will fail if Finder is not
+ # running or is unavailable
+ (my $version = DoAppleScript(<<'EOS')) =~ s/^"(.+)"$/$1/;
+tell application "Finder"
+ get version
+end tell
+EOS
+
+ my($finder, $mtype, $mcrea);
+ # Mac OS X
+ if ($^O eq 'darwin') {
+ ok($version >= 10, "Finder v$version");
+ $finder = '/System/Library/CoreServices/Finder';
+ $mcrea = $mtype = "\0\0\0\0";
+ }
+
+ # Mac OS / Classic
+ elsif ($^O eq 'MacOS') {
+ if ($version >= 10) {
+ ok(1, "Finder v$version (Classic)");
+ } else {
+ ok($version >=7, "Finder v$version");
+ }
+ $finder = MakePath($volumes[0]) . "System Folder:Finder";
+ $mcrea = 'R*ch';
+ $mtype = 'TEXT';
+ }
+
+ else {
+ ok(0, "huh?");
+ }
+
+ # file info get/set
+ my($crea, $type) = GetFileInfo($finder);
+ is($crea, 'MACS', "creator of '$finder'");
+ is($type, 'FNDR', "type of '$finder'");
+
+ my $testfile = catfile(curdir(), "foo");
+ unlink $testfile;
+ if (open(my $fh, ">", $testfile)) {
+ close $fh;
+ ($crea, $type) = GetFileInfo($testfile);
+ # could fail under Mac OS if local GUSI resource changed
+ # so new files are not R*ch/TEXT; we could read
+ # the resource instead ... (and old versions of MacPerl
+ # used MPS /TEXT)
+ is($crea, $mcrea, "creator of '$testfile'");
+ is($type, $mtype, "type of '$testfile'");
+
+ SetFileInfo('McPL', 'TEXT', $testfile);
+ ($crea, $type) = GetFileInfo($testfile);
+ is($crea, 'McPL', "creator of '$testfile'");
+ is($type, 'TEXT', "type of '$testfile'");
+ } else {
+ ok(0, "No file '$testfile'") for 1..4;
+ }
+ unlink $testfile;
+}
+
+__END__
End of Patch.