Port xpcom to 64-bit Mac OS X, part 1. b=478687 r=mstange sr=bsmedberg
authorJosh Aas <joshmoz@gmail.com>
Fri, 06 Mar 2009 12:32:57 -0600
changeset 25814 c460743a79d72e8badf584aad783542506affe26
parent 25813 07d7d6a3bc9c579aeaf01f5e2f234f9078e241fd
child 25815 dead5b94920f65bf4b33fd955a064500bc117794
push idunknown
push userunknown
push dateunknown
reviewersmstange, bsmedberg
bugs478687
milestone1.9.2a1pre
Port xpcom to 64-bit Mac OS X, part 1. b=478687 r=mstange sr=bsmedberg
js/src/plify_jsdhash.sed
rdf/datasource/src/nsFileSystemDataSource.cpp
toolkit/xre/MacApplicationDelegate.mm
toolkit/xre/nsCommandLineServiceMac.cpp
toolkit/xre/nsCommandLineServiceMac.h
xpcom/glue/pldhash.c
xpcom/glue/pldhash.h
xpcom/io/nsAppFileLocationProvider.cpp
xpcom/io/nsILocalFileMac.idl
xpcom/io/nsLocalFileOSX.mm
xpcom/reflect/xptinfo/public/xptinfo.h
xpcom/reflect/xptinfo/src/xptiprivate.h
--- a/js/src/plify_jsdhash.sed
+++ b/js/src/plify_jsdhash.sed
@@ -1,32 +1,36 @@
 / * Double hashing implementation./a\
- * GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!!
+\ * GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!!
 / * Double hashing, a la Knuth 6./a\
- * GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!!
+\ * GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!!
 s/jsdhash_h___/pldhash_h___/
 s/jsdhash\.bigdump/pldhash.bigdump/
 s/jstypes\.h/nscore.h/
 s/jsbit\.h/prbit.h/
 s/jsdhash\.h/pldhash.h/
 s/jsdhash\.c/pldhash.c/
 s/jsdhash:/pldhash:/
 s/jsutil\.h/nsDebug.h/
 s/JS_DHASH/PL_DHASH/g
 s/JS_DHash/PL_DHash/g
 s/JSDHash/PLDHash/g
 s/JSHash/PLHash/g
+s/uint8  /PRUint8/g
+s/uint16  /PRUint16/g
 s/uint32  /PRUint32/g
-s/\([^U]\)int32  /\1PRInt32/g
-s/uint16  /PRUint16/g
+s/\([^U]\)int8  /\1PRInt8/g
 s/\([^U]\)int16  /\1PRInt16/g
+s/\([^U]\)int32  /\1PRInt32/g
+s/uint8/PRUint8/g
+s/uint16/PRUint16/g
 s/uint32/PRUint32/g
+s/\([^U]\)int8/\1PRInt8/g
+s/\([^U]\)int16/\1PRInt16/g
 s/\([^U]\)int32/\1PRInt32/g
-s/uint16/PRUint16/g
-s/\([^U]\)int16/\1PRInt16/g
 s/JSBool/PRBool/g
 s/extern JS_PUBLIC_API(\([^()]*\))/NS_COM_GLUE \1/
 s/JS_PUBLIC_API(\([^()]*\))/\1/
 s/JS_NewDHashTable/PL_NewDHashTable/
 s/JS_ASSERT(0)/NS_NOTREACHED("0")/
 s/\( *\)JS_ASSERT(\(.*\));/\1NS_ASSERTION(\2,\n\1             "\2");/
 s/JSDHASH_ONELINE_ASSERT(\(.*\));/NS_ASSERTION(\1, "\1");/
 s/JS_UNLIKELY/NS_UNLIKELY/g
--- a/rdf/datasource/src/nsFileSystemDataSource.cpp
+++ b/rdf/datasource/src/nsFileSystemDataSource.cpp
@@ -894,43 +894,16 @@ FileSystemDataSource::GetVolumeList(nsIS
     nsresult rv;
     nsCOMPtr<nsISupportsArray> volumes;
 
     rv = NS_NewISupportsArray(getter_AddRefs(volumes));
     if (NS_FAILED(rv)) return rv;
 
     nsCOMPtr<nsIRDFResource> vol;
 
-#ifdef  XP_MAC
-    StrFileName     fname;
-    HParamBlockRec  pb;
-    for (int16 volNum = 1; ; volNum++)
-    {
-        pb.volumeParam.ioCompletion = NULL;
-        pb.volumeParam.ioVolIndex = volNum;
-        pb.volumeParam.ioNamePtr = (StringPtr)fname;
-        if (PBHGetVInfo(&pb,FALSE) != noErr)
-            break;
-        FSSpec fss(pb.volumeParam.ioVRefNum, fsRtParID, fname);
-        nsCOMPtr<nsILocalFileMac> lf;
-        NS_NewLocalFileWithFSSpec(fss, true, getter_AddRefs(lf));
-
-        nsCOMPtr<nsIURI> furi;
-        NS_NewFileURI(getter_AddRefs(furi), lf); 
-
-        nsXPIDLCString spec;
-        furi->GetSpec(getter_Copies(spec);
-
-        rv = mRDFService->GetResource(spec, getter_AddRefs(vol));
-        if (NS_FAILED(rv)) return rv;
-
-        volumes->AppendElement(vol);
-    }
-#endif
-
 #if defined (XP_WIN) && !defined (WINCE)
 
     PRInt32         driveType;
     PRUnichar       drive[32];
     PRInt32         volNum;
     char            *url;
 
     for (volNum = 0; volNum < 26; volNum++)
--- a/toolkit/xre/MacApplicationDelegate.mm
+++ b/toolkit/xre/MacApplicationDelegate.mm
@@ -153,65 +153,53 @@ SetupMacApplicationDelegate()
 // The method that NSApplication calls when documents are requested to be opened.
 // It will be called once for each selected document.
 
 - (BOOL)application:(NSApplication*)theApplication openFile:(NSString*)filename
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   FSRef ref;
-  FSSpec spec;
   // The cast is kind of freaky, but apparently it's what all the beautiful people do.
   OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL);
   if (status != noErr) {
     NS_WARNING("FSPathMakeRef in openFile failed, skipping file open");
     return NO;
   }
-  status = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
-  if (status != noErr) {
-    NS_WARNING("FSGetCatalogInfo in openFile failed, skipping file open");
-    return NO;
-  }
 
   // Take advantage of the existing "command line" code for Macs.
   nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
   // We don't actually care about Mac filetypes in this context, just pass a placeholder.
-  cmdLine.HandleOpenOneDoc(spec, 'abcd');
+  cmdLine.HandleOpenOneDoc(&ref, 'abcd');
 
   return YES;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
 }
 
 // The method that NSApplication calls when documents are requested to be printed
 // from the Finder (under the "File" menu).
 // It will be called once for each selected document.
 
 - (BOOL)application:(NSApplication*)theApplication printFile:(NSString*)filename
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   FSRef ref;
-  FSSpec spec;
   // The cast is kind of freaky, but apparently it's what all the beautiful people do.
   OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL);
   if (status != noErr) {
     NS_WARNING("FSPathMakeRef in printFile failed, skipping printing");
     return NO;
   }
-  status = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
-  if (status != noErr) {
-    NS_WARNING("FSGetCatalogInfo in printFile failed, skipping printing");
-    return NO;
-  }
 
   // Take advantage of the existing "command line" code for Macs.
   nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
   // We don't actually care about Mac filetypes in this context, just pass a placeholder.
-  cmdLine.HandlePrintOneDoc(spec, 'abcd');
+  cmdLine.HandlePrintOneDoc(&ref, 'abcd');
 
   return YES;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
 }
 
 // Drill down from nsIXULWindow and get an NSWindow. We get passed nsISupports
 // because that's what nsISimpleEnumerator returns.
--- a/toolkit/xre/nsCommandLineServiceMac.cpp
+++ b/toolkit/xre/nsCommandLineServiceMac.cpp
@@ -207,26 +207,20 @@ nsresult nsMacCommandLine::AddToCommandL
     return NS_ERROR_OUT_OF_MEMORY;
   mArgs[mArgsUsed++] = temp2;
   mArgs[mArgsUsed] = nsnull;
   return NS_OK;
 }
 
 
 //----------------------------------------------------------------------------------------
-nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec)
+nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FSRef* inFSRef)
 //----------------------------------------------------------------------------------------
 {
-  // Convert the filespec to a URL.  Avoid using xpcom because this may be
-  // called before xpcom startup.
-  FSRef fsRef;
-  if (::FSpMakeFSRef(&inFileSpec, &fsRef) != noErr)
-    return NS_ERROR_FAILURE;
-
-  CFURLRef url = ::CFURLCreateFromFSRef(nsnull, &fsRef);
+  CFURLRef url = ::CFURLCreateFromFSRef(nsnull, inFSRef);
   if (!url)
     return NS_ERROR_FAILURE;
 
   CFStringRef string = ::CFURLGetString(url);
   if (!string) {
     ::CFRelease(url);
     return NS_ERROR_FAILURE;
   }
@@ -259,21 +253,21 @@ nsresult nsMacCommandLine::AddToEnvironm
 //----------------------------------------------------------------------------------------
 {
   (void)PR_SetEnv(inArgText);
   return NS_OK;
 }
 
 
 //----------------------------------------------------------------------------------------
-OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType)
+OSErr nsMacCommandLine::HandleOpenOneDoc(const FSRef* inFSRef, OSType inFileType)
 //----------------------------------------------------------------------------------------
 {
   nsCOMPtr<nsILocalFileMac> inFile;
-  nsresult rv = NS_NewLocalFileWithFSSpec(&inFileSpec, PR_TRUE, getter_AddRefs(inFile));
+  nsresult rv = NS_NewLocalFileWithFSRef(inFSRef, PR_TRUE, getter_AddRefs(inFile));
   if (NS_FAILED(rv))
     return errAEEventNotHandled;
 
   if (!mStartedUp)
   {
     // Is it the right type to be a command-line file?
     if (inFileType == 'TEXT' || inFileType == 'CMDL')
     {
@@ -308,17 +302,17 @@ OSErr nsMacCommandLine::HandleOpenOneDoc
         if (foundArgs || foundEnv)
           return noErr;
       }
     }
     // If it's not a command-line argument, and we are starting up the application,
     // add a command-line "-url" argument to the global list. This means that if
     // the app is opened with documents on the mac, they'll be handled the same
     // way as if they had been typed on the command line in Unix or DOS.
-    rv = AddToCommandLine("-url", inFileSpec);
+    rv = AddToCommandLine("-url", inFSRef);
     return (NS_SUCCEEDED(rv)) ? noErr : errAEEventNotHandled;
   }
 
   // Final case: we're not just starting up, use the arg as a -file <arg>
   nsCOMPtr<nsICommandLineRunner> cmdLine
     (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
   if (!cmdLine) {
     NS_ERROR("Couldn't create command line!");
@@ -338,25 +332,25 @@ OSErr nsMacCommandLine::HandleOpenOneDoc
   rv = cmdLine->Init(3, const_cast<char**>(argv), workingDir, nsICommandLine::STATE_REMOTE_EXPLICIT);
   if (NS_FAILED(rv))
     return errAEEventNotHandled;
   rv = cmdLine->Run();
   return (NS_SUCCEEDED(rv)) ? noErr : errAEEventNotHandled;
 }
 
 //----------------------------------------------------------------------------------------
-OSErr nsMacCommandLine::HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType)
+OSErr nsMacCommandLine::HandlePrintOneDoc(const FSRef* inFSRef, OSType fileType)
 //----------------------------------------------------------------------------------------
 {
   // If  we are starting up the application,
   // add a command-line "-print" argument to the global list. This means that if
   // the app is opened with documents on the mac, they'll be handled the same
   // way as if they had been typed on the command line in Unix or DOS.
   if (!mStartedUp)
-    return AddToCommandLine("-print", inFileSpec);
+    return AddToCommandLine("-print", inFSRef);
   
   // Final case: we're not just starting up. How do we handle this?
   NS_NOTYETIMPLEMENTED("Write Me");
   return errAEEventNotHandled;
 }
 
 
 //----------------------------------------------------------------------------------------
--- a/toolkit/xre/nsCommandLineServiceMac.h
+++ b/toolkit/xre/nsCommandLineServiceMac.h
@@ -60,21 +60,21 @@ public:
 
                   nsMacCommandLine();
                   ~nsMacCommandLine();
 
   nsresult        Initialize(int& argc, char**& argv);
   void            SetupCommandLine(int& argc, char**& argv);
   
   nsresult        AddToCommandLine(const char* inArgText);
-  nsresult        AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec);
+  nsresult        AddToCommandLine(const char* inOptionString, const FSRef* inFSRef);
   nsresult        AddToEnvironmentVars(const char* inArgText);
 
-  OSErr           HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType);
-  OSErr           HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType);
+  OSErr           HandleOpenOneDoc(const FSRef* inFSRef, OSType inFileType);
+  OSErr           HandlePrintOneDoc(const FSRef* inFSRef, OSType fileType);
 
 	OSErr						DispatchURLToNewBrowser(const char* url);
 
 protected:
 
   OSErr           OpenURL(const char* aURL);
 
   nsresult        OpenWindow(const char *chrome, const PRUnichar *url);
--- a/xpcom/glue/pldhash.c
+++ b/xpcom/glue/pldhash.c
@@ -253,18 +253,18 @@ PL_DHashTableInit(PLDHashTable *table, c
         capacity = PL_DHASH_MIN_SIZE;
 
     PR_CEILING_LOG2(log2, capacity);
 
     capacity = PR_BIT(log2);
     if (capacity >= PL_DHASH_SIZE_LIMIT)
         return PR_FALSE;
     table->hashShift = PL_DHASH_BITS - log2;
-    table->maxAlphaFrac = (uint8)(0x100 * PL_DHASH_DEFAULT_MAX_ALPHA);
-    table->minAlphaFrac = (uint8)(0x100 * PL_DHASH_DEFAULT_MIN_ALPHA);
+    table->maxAlphaFrac = (PRUint8)(0x100 * PL_DHASH_DEFAULT_MAX_ALPHA);
+    table->minAlphaFrac = (PRUint8)(0x100 * PL_DHASH_DEFAULT_MIN_ALPHA);
     table->entrySize = entrySize;
     table->entryCount = table->removedCount = 0;
     table->generation = 0;
     nbytes = capacity * entrySize;
 
     table->entryStore = (char *) ops->allocTable(table,
                                                  nbytes + ENTRY_STORE_EXTRA);
     if (!table->entryStore)
@@ -321,18 +321,18 @@ PL_DHashTableSetAlphaBounds(PLDHashTable
      */
     NS_ASSERTION(minAlpha < maxAlpha / 2,
                  "minAlpha < maxAlpha / 2");
     if (minAlpha >= maxAlpha / 2) {
         size = PL_DHASH_TABLE_SIZE(table);
         minAlpha = (size * maxAlpha - PR_MAX(size / 256, 1)) / (2 * size);
     }
 
-    table->maxAlphaFrac = (uint8)(maxAlpha * 256);
-    table->minAlphaFrac = (uint8)(minAlpha * 256);
+    table->maxAlphaFrac = (PRUint8)(maxAlpha * 256);
+    table->minAlphaFrac = (PRUint8)(minAlpha * 256);
 }
 
 /*
  * Double hashing needs the second hash code to be relatively prime to table
  * size, so we simply make hash2 odd.
  */
 #define HASH1(hash0, shift)         ((hash0) >> (shift))
 #define HASH2(hash0,log2,shift)     ((((hash0) << (log2)) >> (shift)) | 1)
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -191,18 +191,18 @@ struct PLDHashEntryHdr {
  * The moral of this story: there is no one-size-fits-all hash table scheme,
  * but for small table entry size, and assuming entry address stability is not
  * required, double hashing wins.
  */
 struct PLDHashTable {
     const PLDHashTableOps *ops;         /* virtual operations, see below */
     void                *data;          /* ops- and instance-specific data */
     PRInt16             hashShift;      /* multiplicative hash shift */
-    uint8               maxAlphaFrac;   /* 8-bit fixed point max alpha */
-    uint8               minAlphaFrac;   /* 8-bit fixed point min alpha */
+    PRUint8             maxAlphaFrac;   /* 8-bit fixed point max alpha */
+    PRUint8             minAlphaFrac;   /* 8-bit fixed point min alpha */
     PRUint32            entrySize;      /* number of bytes in an entry */
     PRUint32            entryCount;     /* number of entries in table */
     PRUint32            removedCount;   /* removed entry sentinels in table */
     PRUint32            generation;     /* entry storage generation number */
     char                *entryStore;    /* entry storage */
 #ifdef PL_DHASHMETER
     struct PLDHashStats {
         PRUint32        searches;       /* total number of table searches */
@@ -452,17 +452,17 @@ PL_DHashTableSetAlphaBounds(PLDHashTable
 #define PL_DHASH_DEFAULT_MAX_ALPHA 0.75
 #define PL_DHASH_DEFAULT_MIN_ALPHA 0.25
 
 #define PL_DHASH_CAP(entryCount, maxAlpha)                                    \
     ((PRUint32)((double)(entryCount) / (maxAlpha)))
 
 #define PL_DHASH_CAPACITY(entryCount, maxAlpha)                               \
     (PL_DHASH_CAP(entryCount, maxAlpha) +                                     \
-     (((PL_DHASH_CAP(entryCount, maxAlpha) * (uint8)(0x100 * (maxAlpha)))     \
+     (((PL_DHASH_CAP(entryCount, maxAlpha) * (PRUint8)(0x100 * (maxAlpha)))     \
        >> 8) < (entryCount)))
 
 #define PL_DHASH_DEFAULT_CAPACITY(entryCount)                                 \
     PL_DHASH_CAPACITY(entryCount, PL_DHASH_DEFAULT_MAX_ALPHA)
 
 /*
  * Finalize table's data, free its entry storage using table->ops->freeTable,
  * and leave its members unchanged from their last live values (which leaves
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -89,17 +89,16 @@
 
 // Locally defined keys used by nsAppDirectoryEnumerator
 #define NS_ENV_PLUGINS_DIR          "EnvPlugins"    // env var MOZ_PLUGIN_PATH
 #define NS_USER_PLUGINS_DIR         "UserPlugins"
 
 #ifdef XP_MACOSX
 #define NS_MACOSX_USER_PLUGIN_DIR   "OSXUserPlugins"
 #define NS_MACOSX_LOCAL_PLUGIN_DIR  "OSXLocalPlugins"
-#define NS_MAC_CLASSIC_PLUGIN_DIR   "MacSysPlugins"
 #elif XP_UNIX
 #define NS_SYSTEM_PLUGINS_DIR       "SysPlugins"
 #endif
 
 #define DEFAULTS_DIR_NAME           NS_LITERAL_CSTRING("defaults")
 #define DEFAULTS_PREF_DIR_NAME      NS_LITERAL_CSTRING("pref")
 #define DEFAULTS_PROFILE_DIR_NAME   NS_LITERAL_CSTRING("profile")
 #define RES_DIR_NAME                NS_LITERAL_CSTRING("res")
@@ -131,19 +130,17 @@ nsAppFileLocationProvider::GetFile(const
     nsCOMPtr<nsILocalFile>  localFile;
     nsresult rv = NS_ERROR_FAILURE;
 
     NS_ENSURE_ARG(prop);
     *_retval = nsnull;
     *persistent = PR_TRUE;
 
 #ifdef XP_MACOSX
-    short foundVRefNum;
-    long foundDirID;
-    FSSpec fileSpec;
+    FSRef fileRef;
     nsCOMPtr<nsILocalFileMac> macFile;
 #endif
     
     if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0)
     {
         rv = GetProductDirectory(getter_AddRefs(localFile));
     }
     else if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0)
@@ -201,43 +198,26 @@ nsAppFileLocationProvider::GetFile(const
     {
         rv = CloneMozBinDirectory(getter_AddRefs(localFile));
         if (NS_SUCCEEDED(rv))
             rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
     }
 #ifdef XP_MACOSX
     else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
     {
-        if (!(::FindFolder(kUserDomain,
-                           kInternetPlugInFolderType,
-                           kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
-            !(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
-            rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
+        if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
+            rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile));
             if (NS_SUCCEEDED(rv))
                 localFile = macFile;
         }
     }
     else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0)
     {
-        if (!(::FindFolder(kLocalDomain,
-                           kInternetPlugInFolderType,
-                           kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
-            !(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
-            rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
-            if (NS_SUCCEEDED(rv))
-                localFile = macFile;
-        }
-    }
-    else if (nsCRT::strcmp(prop, NS_MAC_CLASSIC_PLUGIN_DIR) == 0)
-    {
-        if (!(::FindFolder(kOnAppropriateDisk,
-                           kInternetPlugInFolderType,
-                           kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
-            !(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
-            rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
+        if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
+            rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile));
             if (NS_SUCCEEDED(rv))
                 localFile = macFile;
         }
     }
 #else
     else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0)
     {
         NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). "
@@ -574,27 +554,17 @@ nsAppFileLocationProvider::GetFiles(cons
 {
     NS_ENSURE_ARG_POINTER(_retval);
     *_retval = nsnull;
     nsresult rv = NS_ERROR_FAILURE;
     
     if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
     {
 #ifdef XP_MACOSX
-        static const char* osXKeys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR, NS_MACOSX_LOCAL_PLUGIN_DIR, nsnull };
-        static const char* os9Keys[] = { NS_APP_PLUGINS_DIR, NS_MAC_CLASSIC_PLUGIN_DIR, nsnull };
-        static const char** keys;
-        
-        if (!keys) {
-            OSErr err;
-            long response;
-            err = ::Gestalt(gestaltSystemVersion, &response); 
-            keys = (!err && response >= 0x00001000) ? osXKeys : os9Keys;
-        }
-
+        static const char* keys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR, NS_MACOSX_LOCAL_PLUGIN_DIR, nsnull };
         *_retval = new nsAppDirectoryEnumerator(this, keys);
 #else
 #ifdef XP_UNIX
         static const char* keys[] = { nsnull, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, NS_SYSTEM_PLUGINS_DIR, nsnull };
 #else
         static const char* keys[] = { nsnull, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, nsnull };
 #endif
         if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_PLUGIN_PATH"))) {
--- a/xpcom/io/nsILocalFileMac.idl
+++ b/xpcom/io/nsILocalFileMac.idl
@@ -46,17 +46,17 @@
 
       native OSType(OSType);
       native FSSpec(FSSpec);
 [ptr] native FSSpecPtr(FSSpec);
       native FSRef(FSRef);
 [ptr] native FSRefPtr(FSRef);
       native CFURLRef(CFURLRef);
 
-[scriptable, uuid(748f3ffe-27d9-4402-9de9-494badbeebf4)]
+[scriptable, uuid(7224E826-3F6C-4BB2-9C6E-02DA44575743)]
 interface nsILocalFileMac : nsILocalFile
 {
    /**
     * initWithCFURL
     *
     * Init this object with a CFURLRef
     *
     * NOTE: Supported only for XP_MACOSX or TARGET_CARBON
@@ -75,27 +75,16 @@ interface nsILocalFileMac : nsILocalFile
     * NOTE: Supported only for XP_MACOSX or TARGET_CARBON
     *
     * @param   aFSRef         the native file spec
     *
     */
   [noscript] void initWithFSRef([const] in FSRefPtr aFSRef);
 
    /**
-    * initWithFSSpec
-    *
-    * Init this object with an FSSpec
-    * Legacy method - leaving in place for now
-    *
-    * @param   aFileSpec       the native file spec
-    *
-    */
-  [noscript] void initWithFSSpec([const] in FSSpecPtr aFileSpec);
-
-   /**
     * initToAppWithCreatorCode
     *
     * Init this object to point to an application having the given
     * creator code. If this app is missing, this will fail. It will first
     * look for running application with the given creator.
     *
     * @param   aAppCreator     the signature of the app
     *
@@ -244,19 +233,11 @@ interface nsILocalFileMac : nsILocalFile
     * returns the identifier of the bundle
     */
    readonly attribute AUTF8String bundleIdentifier;
 };
 
 %{C++
 extern "C"
 {
-
-#ifndef XP_MACOSX
-NS_EXPORT const char* NS_TruncNodeName(const char *aNode, char *outBuf);
-#endif
-
-NS_EXPORT nsresult NS_NewLocalFileWithFSSpec(const FSSpec* inSpec, PRBool followSymlinks, nsILocalFileMac* *result);
-
-// NS_NewLocalFileWithFSRef is available since Mozilla 1.8.1.
 NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, PRBool aFollowSymlinks, nsILocalFileMac** result);
 }
 %}
--- a/xpcom/io/nsLocalFileOSX.mm
+++ b/xpcom/io/nsLocalFileOSX.mm
@@ -752,57 +752,58 @@ NS_IMETHODIMP nsLocalFile::Remove(PRBool
       rv = NSRESULT_FOR_ERRNO();
   }
 
   return rv;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
+// Only send back permissions bits: maybe we want to send back the whole
+// mode_t to permit checks against other file types?
+#define NORMALIZE_PERMS(mode)    ((mode)& (S_IRWXU | S_IRWXG | S_IRWXO))
+
 NS_IMETHODIMP nsLocalFile::GetPermissions(PRUint32 *aPermissions)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   NS_ENSURE_ARG_POINTER(aPermissions);
-  
-  FSRef fsRef;
-  nsresult rv = GetFSRefInternal(fsRef);
-  if (NS_FAILED(rv))
-    return rv;
-    
-  FSCatalogInfo catalogInfo;
-  OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo,
-                  nsnull, nsnull, nsnull);
-  if (err != noErr)
-    return MacErrorMapper(err);
-  FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions;
-  *aPermissions = permPtr->mode;
-  return NS_OK;
+
+  CHECK_mBaseRef();
+
+  NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
+  NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:[(NSURL*)mBaseRef path] traverseLink:YES];
+  if (fileAttributes) {
+    NSNumber *permissions = [fileAttributes objectForKey:NSFilePosixPermissions];
+    if (permissions) {
+      *aPermissions = NORMALIZE_PERMS([permissions unsignedLongValue]);
+      [ap release];
+      return NS_OK;
+    }
+  }
+  [ap release];
+
+  return NS_ERROR_FAILURE;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::SetPermissions(PRUint32 aPermissions)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  FSRef fsRef;
-  nsresult rv = GetFSRefInternal(fsRef);
-  if (NS_FAILED(rv))
-    return rv;
-  
-  FSCatalogInfo catalogInfo;
-  OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo,
-                  nsnull, nsnull, nsnull);
-  if (err != noErr)
-    return MacErrorMapper(err);
-  FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions;
-  permPtr->mode = (UInt16)aPermissions;
-  err = ::FSSetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo);
-  return MacErrorMapper(err);
+  CHECK_mBaseRef();
+
+  NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
+  NSNumber* pNumber = [NSNumber numberWithUnsignedInt:aPermissions];
+  NSDictionary* fileAttributes = [NSDictionary dictionaryWithObject:pNumber forKey:NSFilePosixPermissions];
+  // changeFileAttributes:atPath: follows symbolic links though the documentation doesn't mention it
+  BOOL success = [[NSFileManager defaultManager] changeFileAttributes:fileAttributes atPath:[(NSURL*)mBaseRef path]];
+  [ap release];
+  return (success ? NS_OK : NS_ERROR_FAILURE);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsLocalFile::GetPermissionsOfLink(PRUint32 *aPermissionsOfLink)
 {
     NS_ERROR("NS_ERROR_NOT_IMPLEMENTED");
     return NS_ERROR_NOT_IMPLEMENTED;
@@ -927,17 +928,17 @@ NS_IMETHODIMP nsLocalFile::SetFileSize(P
   // Check we are correctly initialized.
   CHECK_mBaseRef();
 
   FSRef fsRef;
   nsresult rv = GetFSRefInternal(fsRef);
   if (NS_FAILED(rv))
     return rv;
   
-  SInt16 refNum;    
+  FSIORefNum refNum;    
   OSErr err = ::FSOpenFork(&fsRef, 0, nsnull, fsWrPerm, &refNum);
   if (err != noErr)
     return MacErrorMapper(err);
   err = ::FSSetForkSize(refNum, fsFromStart, aFileSize);
   ::FSCloseFork(refNum);  
   
   return MacErrorMapper(err);
 
@@ -1726,32 +1727,16 @@ NS_IMETHODIMP nsLocalFile::InitWithFSRef
     ::CFRelease(newURLRef);
     rv = NS_OK;
   }
   return rv;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
-NS_IMETHODIMP nsLocalFile::InitWithFSSpec(const FSSpec *aFileSpec)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
-  NS_ENSURE_ARG(aFileSpec);
-
-  FSRef fsRef;
-  OSErr err = ::FSpMakeFSRef(aFileSpec, &fsRef);
-  if (err == noErr)
-    return InitWithFSRef(&fsRef);
-
-  return MacErrorMapper(err);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
-}
-
 NS_IMETHODIMP nsLocalFile::InitToAppWithCreatorCode(OSType aAppCreator)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   FSRef fsRef;
   OSErr err = ::LSFindApplicationForInfo(aAppCreator, nsnull, nsnull, &fsRef, nsnull);
   if (err != noErr)
     return MacErrorMapper(err);
@@ -2345,34 +2330,16 @@ nsresult NS_NewLocalFile(const nsAString
     return NS_OK;
 }
 
 nsresult NS_NewNativeLocalFile(const nsACString& path, PRBool followLinks, nsILocalFile **result)
 {
     return NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), followLinks, result);
 }
 
-nsresult NS_NewLocalFileWithFSSpec(const FSSpec* inSpec, PRBool followLinks, nsILocalFileMac **result)
-{
-    nsLocalFile* file = new nsLocalFile();
-    if (file == nsnull)
-        return NS_ERROR_OUT_OF_MEMORY;
-    NS_ADDREF(file);
-
-    file->SetFollowLinks(followLinks);
-
-    nsresult rv = file->InitWithFSSpec(inSpec);
-    if (NS_FAILED(rv)) {
-        NS_RELEASE(file);
-        return rv;
-    }
-    *result = file;
-    return NS_OK;
-}
-
 nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, PRBool aFollowLinks, nsILocalFileMac** result)
 {
     nsLocalFile* file = new nsLocalFile();
     if (file == nsnull)
         return NS_ERROR_OUT_OF_MEMORY;
     NS_ADDREF(file);
 
     file->SetFollowLinks(aFollowLinks);
--- a/xpcom/reflect/xptinfo/public/xptinfo.h
+++ b/xpcom/reflect/xptinfo/public/xptinfo.h
@@ -54,26 +54,26 @@ class nsXPTType : public XPTTypeDescript
 {
 // NO DATA - this a flyweight wrapper
 public:
     nsXPTType()
         {}    // random contents
     nsXPTType(const XPTTypeDescriptorPrefix& prefix)
         {*(XPTTypeDescriptorPrefix*)this = prefix;}
 
-    nsXPTType(const uint8& prefix)
-        {*(uint8*)this = prefix;}
+    nsXPTType(const PRUint8& prefix)
+        {*(PRUint8*)this = prefix;}
 
-    nsXPTType& operator=(uint8 val)
+    nsXPTType& operator=(PRUint8 val)
         {flags = val; return *this;}
 
     nsXPTType& operator=(const nsXPTType& other)
         {flags = other.flags; return *this;}
 
-    operator uint8() const
+    operator PRUint8() const
         {return flags;}
 
     PRBool IsPointer() const
         {return 0 != (XPT_TDP_IS_POINTER(flags));}
 
     PRBool IsUniquePointer() const
         {return 0 != (XPT_TDP_IS_UNIQUE_POINTER(flags));}
 
@@ -106,18 +106,18 @@ public:
              case T_INTERFACE_IS:
              case TD_ARRAY:
              case T_PSTRING_SIZE_IS:
              case T_PWSTRING_SIZE_IS:
                return PR_TRUE;
            }
         }
 
-    uint8 TagPart() const
-        {return (uint8) (flags & XPT_TDP_TAGMASK);}
+    PRUint8 TagPart() const
+        {return (PRUint8) (flags & XPT_TDP_TAGMASK);}
 
     enum
     {
         T_I8                = TD_INT8             ,
         T_I16               = TD_INT16            ,
         T_I32               = TD_INT32            ,
         T_I64               = TD_INT64            ,
         T_U8                = TD_UINT8            ,
@@ -177,19 +177,19 @@ public:
         {*(XPTMethodDescriptor*)this = desc;}
 
     PRBool IsGetter()      const {return 0 != (XPT_MD_IS_GETTER(flags) );}
     PRBool IsSetter()      const {return 0 != (XPT_MD_IS_SETTER(flags) );}
     PRBool IsNotXPCOM()    const {return 0 != (XPT_MD_IS_NOTXPCOM(flags));}
     PRBool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags)   );}
     PRBool IsHidden()      const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
     const char* GetName()  const {return name;}
-    uint8 GetParamCount()  const {return num_args;}
+    PRUint8 GetParamCount()  const {return num_args;}
     /* idx was index before I got _sick_ of the warnings on Unix, sorry jband */
-    const nsXPTParamInfo GetParam(uint8 idx) const
+    const nsXPTParamInfo GetParam(PRUint8 idx) const
         {
             NS_PRECONDITION(idx < GetParamCount(),"bad arg");
             return params[idx];
         }
     const nsXPTParamInfo GetResult() const
         {return *result;}
 private:
     nsXPTMethodInfo();  // no implementation
--- a/xpcom/reflect/xptinfo/src/xptiprivate.h
+++ b/xpcom/reflect/xptinfo/src/xptiprivate.h
@@ -116,33 +116,33 @@ class xptiWorkingSet;
 /***************************************************************************/
 
 class xptiTypelib
 {
 public:
     // No ctors or dtors so that we can be in a union in xptiInterfaceInfo.
     // Allow automatic shallow copies.
 
-    uint16 GetFileIndex()    const {return mFileIndex;}
-    uint16 GetZipItemIndex() const {return mZipItemIndex;}
+    PRUint16 GetFileIndex()    const {return mFileIndex;}
+    PRUint16 GetZipItemIndex() const {return mZipItemIndex;}
 
     enum {NOT_ZIP = 0xffff};
 
     PRBool IsZip() const {return mZipItemIndex != NOT_ZIP;}
 
-    void Init(uint16 aFileIndex, uint16 aZipItemIndex = NOT_ZIP)
+    void Init(PRUint16 aFileIndex, PRUint16 aZipItemIndex = NOT_ZIP)
         {mFileIndex = aFileIndex; mZipItemIndex = aZipItemIndex;}
 
     PRBool Equals(const xptiTypelib& r) const
         {return mFileIndex == r.mFileIndex && 
                 mZipItemIndex == r.mZipItemIndex;}
 
 private:
-    uint16 mFileIndex;
-    uint16 mZipItemIndex;
+    PRUint16 mFileIndex;
+    PRUint16 mZipItemIndex;
 };
 
 /***************************************************************************/
 
 // No virtuals.
 // These are always constructed in the struct arena using placement new.
 // dtor need not be called.
 
@@ -443,18 +443,18 @@ public:
     PRUint32*       mZipItemMergeOffsetMap; // always in an arena
 };
 
 /***************************************************************************/
 
 class xptiInterfaceGuts
 {
 public:
-    uint16                      mMethodBaseIndex;
-    uint16                      mConstantBaseIndex;
+    PRUint16                    mMethodBaseIndex;
+    PRUint16                    mConstantBaseIndex;
     xptiInterfaceEntry*         mParent;
     XPTInterfaceDescriptor*     mDescriptor;
     xptiTypelib                 mTypelib;
     xptiWorkingSet*             mWorkingSet;
 
     static xptiInterfaceGuts* NewGuts(XPTInterfaceDescriptor* aDescriptor,
                                       const xptiTypelib&      aTypelib,
                                       xptiWorkingSet*         aWorkingSet)
@@ -485,45 +485,45 @@ private:
 
 // This class exists to help xptiInterfaceInfo store a 4-state (2 bit) value 
 // and a set of bitflags in one 8bit value. See below.
 
 class xptiInfoFlags
 {
     enum {STATE_MASK = 3};
 public:
-    xptiInfoFlags(uint8 n) : mData(n) {}
+    xptiInfoFlags(PRUint8 n) : mData(n) {}
     xptiInfoFlags(const xptiInfoFlags& r) : mData(r.mData) {}
 
-    static uint8 GetStateMask()
-        {return uint8(STATE_MASK);}
+    static PRUint8 GetStateMask()
+        {return PRUint8(STATE_MASK);}
     
     void Clear()
         {mData = 0;}
 
-    uint8 GetData() const
+    PRUint8 GetData() const
         {return mData;}
 
-    uint8 GetState() const 
+    PRUint8 GetState() const 
         {return mData & GetStateMask();}
 
-    void SetState(uint8 state) 
+    void SetState(PRUint8 state) 
         {mData &= ~GetStateMask(); mData |= state;}                                   
 
-    void SetFlagBit(uint8 flag, PRBool on) 
+    void SetFlagBit(PRUint8 flag, PRBool on) 
         {if(on)
             mData |= ~GetStateMask() & flag;
          else
             mData &= GetStateMask() | ~flag;}
 
-    PRBool GetFlagBit(uint8 flag) const 
+    PRBool GetFlagBit(PRUint8 flag) const 
         {return (mData & flag) ? PR_TRUE : PR_FALSE;}
 
 private:
-    uint8 mData;    
+    PRUint8 mData;    
 };
 
 /****************************************************/
 
 // No virtual methods.
 // We always create in the struct arena and construct using "placement new".
 // No members need dtor calls.
 
@@ -545,20 +545,20 @@ public:
         PARTIALLY_RESOLVED    = 1,
         FULLY_RESOLVED        = 2,
         RESOLVE_FAILED        = 3
     };
     
     // Additional bit flags...
     enum {SCRIPTABLE = 4};
 
-    uint8 GetResolveState() const {return mFlags.GetState();}
+    PRUint8 GetResolveState() const {return mFlags.GetState();}
     
     PRBool IsFullyResolved() const 
-        {return GetResolveState() == (uint8) FULLY_RESOLVED;}
+        {return GetResolveState() == (PRUint8) FULLY_RESOLVED;}
 
     PRBool HasInterfaceRecord() const
         {int s = (int) GetResolveState(); 
          return (s == PARTIALLY_RESOLVED || s == FULLY_RESOLVED) && mInterface;}
 
     const xptiTypelib&  GetTypelibRecord() const
         {return HasInterfaceRecord() ? mInterface->mTypelib : mTypelib;}
 
@@ -574,19 +574,19 @@ public:
                     return GetScriptableFlag();
                 return !GetScriptableFlag();
             }
          return PR_TRUE;
         }
 #endif
 
     void   SetScriptableFlag(PRBool on)
-                {mFlags.SetFlagBit(uint8(SCRIPTABLE),on);}
+                {mFlags.SetFlagBit(PRUint8(SCRIPTABLE),on);}
     PRBool GetScriptableFlag() const
-                {return mFlags.GetFlagBit(uint8(SCRIPTABLE));}
+                {return mFlags.GetFlagBit(PRUint8(SCRIPTABLE));}
 
     const nsID* GetTheIID()  const {return &mIID;}
     const char* GetTheName() const {return mName;}
 
     PRBool EnsureResolved(xptiWorkingSet* aWorkingSet = nsnull)
         {return IsFullyResolved() ? PR_TRUE : Resolve(aWorkingSet);}
 
     PRBool PartiallyResolveLocked(XPTInterfaceDescriptor*  aDescriptor,
@@ -640,17 +640,17 @@ private:
     xptiInterfaceEntry(const xptiInterfaceEntry& r,
                        size_t nameLength,
                        const xptiTypelib& typelib);
     ~xptiInterfaceEntry();
 
     void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
 
     void SetResolvedState(int state) 
-        {mFlags.SetState(uint8(state));}
+        {mFlags.SetState(PRUint8(state));}
 
     PRBool Resolve(xptiWorkingSet* aWorkingSet = nsnull);
 
     // We only call these "*Locked" variants after locking. This is done to 
     // allow reentrace as files are loaded and various interfaces resolved 
     // without having to worry about the locked state.
 
     PRBool EnsureResolvedLocked(xptiWorkingSet* aWorkingSet = nsnull)
@@ -659,17 +659,17 @@ private:
 
     // private helpers
 
     nsresult GetEntryForParam(PRUint16 methodIndex, 
                               const nsXPTParamInfo * param,
                               xptiInterfaceEntry** entry);
 
     nsresult GetTypeInArray(const nsXPTParamInfo* param,
-                            uint16 dimension,
+                            PRUint16 dimension,
                             const XPTTypeDescriptor** type);
 
 private:
     union {
         xptiTypelib         mTypelib;     // Valid only until resolved.
         xptiInterfaceGuts*  mInterface;   // Valid only after resolved.
     };
     xptiInterfaceInfo*      mInfo;        // May come and go.