Bug 825150 - Remove const_casts by adding some const-ness to nsICommandLineRunner.init(). r=karlt, sr=bsmedberg.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 03 Jan 2013 13:52:32 -0800
changeset 126929 dc39c417062244c5e9cff510148ce00b78f81342
parent 126928 3e5ec076ceb218ab8b6a408316761fe95c33a20c
child 126930 4436a72b4f2cbdfcc4f48b913ba0c4d776d884b6
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, bsmedberg
bugs825150
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 825150 - Remove const_casts by adding some const-ness to nsICommandLineRunner.init(). r=karlt, sr=bsmedberg.
toolkit/components/commandlines/nsCommandLine.cpp
toolkit/components/commandlines/nsICommandLineRunner.idl
toolkit/components/remote/nsXRemoteService.cpp
toolkit/xre/MacApplicationDelegate.mm
widget/android/nsAppShell.cpp
--- a/toolkit/components/commandlines/nsCommandLine.cpp
+++ b/toolkit/components/commandlines/nsCommandLine.cpp
@@ -437,17 +437,17 @@ nsCommandLine::resolveShortcutURL(nsIFil
   rv = fph->ReadURLFile(aFile, getter_AddRefs(uri));
   if (NS_FAILED(rv))
     return;
 
   uri->GetSpec(outURL);
 }
 
 NS_IMETHODIMP
-nsCommandLine::Init(int32_t argc, char** argv, nsIFile* aWorkingDir,
+nsCommandLine::Init(int32_t argc, const char* const* argv, nsIFile* aWorkingDir,
                     uint32_t aState)
 {
   NS_ENSURE_ARG_MIN(aState, 0);
   NS_ENSURE_ARG_MAX(aState, 2);
 
   int32_t i;
 
   mWorkingDir = aWorkingDir;
--- a/toolkit/components/commandlines/nsICommandLineRunner.idl
+++ b/toolkit/components/commandlines/nsICommandLineRunner.idl
@@ -1,42 +1,42 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsICommandLine.idl"
 
-[ptr] native nsCharPtrArray(char*);
+[ptr] native nsArgvArray(const char* const);
 
 /**
  * Extension of nsICommandLine that allows for initialization of new command lines
  * and running the command line actions by processing the command line handlers.
  *
  * @status INTERNAL - This interface is not meant for use by embedders, and is
  *                    not intended to be frozen. If you are an embedder and need
  *                    functionality provided by this interface, talk to Benjamin
  *                    Smedberg <benjamin@smedbergs.us>.
  */
 
-[uuid(c1f4cfbf-a41f-4628-aa6c-9fb914478af8)]
+[uuid(c9f2996c-b25a-4d3d-821f-4cd0c4bc8afb)]
 interface nsICommandLineRunner : nsICommandLine
 {
   /**
    * This method assumes a native character set, and is meant to be called
    * with the argc/argv passed to main(). Talk to bsmedberg if you need to
    * create a command line using other data. argv will not be altered in any
    * way.
    *
    * On Windows, the "native" character set is UTF-8, not the native codepage.
    *
    * @param workingDir The working directory for resolving file and URI paths.
    * @param state      The nsICommandLine.state flag.
    */
-  void init(in long argc, in nsCharPtrArray argv,
+  void init(in long argc, in nsArgvArray argv,
             in nsIFile workingDir, in unsigned long state);
 
   /**
    * Set the windowContext parameter.
    */
   void setWindowContext(in nsIDOMWindow aWindow);
 
   /**
--- a/toolkit/components/remote/nsXRemoteService.cpp
+++ b/toolkit/components/remote/nsXRemoteService.cpp
@@ -273,18 +273,17 @@ nsXRemoteService::HandleCommand(char* aC
   if (!command.EqualsLiteral("ping")) {
     nsAutoCString desktopStartupID;
     nsDependentCString cmd(aCommand);
     FindExtensionParameterInCommand("DESKTOP_STARTUP_ID",
                                     cmd, '\n',
                                     &desktopStartupID);
 
     const char* argv[3] = {"dummyappname", "-remote", aCommand};
-    rv = cmdline->Init(3, const_cast<char**>(argv), nullptr,
-                       nsICommandLine::STATE_REMOTE_EXPLICIT);
+    rv = cmdline->Init(3, argv, nullptr, nsICommandLine::STATE_REMOTE_EXPLICIT);
     if (NS_FAILED(rv))
       return "509 internal error";
 
     if (aWindow)
       cmdline->SetWindowContext(aWindow);
 
     if (sRemoteImplementation)
       sRemoteImplementation->SetDesktopStartupIDOrTimestamp(desktopStartupID, aTimestamp);
--- a/toolkit/xre/MacApplicationDelegate.mm
+++ b/toolkit/xre/MacApplicationDelegate.mm
@@ -220,17 +220,17 @@ ProcessPendingGetURLAppleEvents()
     return NO;
 
   nsCOMPtr<nsIFile> workingDir;
   rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir));
   if (NS_FAILED(rv))
     return NO;
 
   const char *argv[3] = {nullptr, "-file", filePath.get()};
-  rv = cmdLine->Init(3, const_cast<char**>(argv), workingDir, nsICommandLine::STATE_REMOTE_EXPLICIT);
+  rv = cmdLine->Init(3, argv, workingDir, nsICommandLine::STATE_REMOTE_EXPLICIT);
   if (NS_FAILED(rv))
     return NO;
 
   if (NS_SUCCEEDED(cmdLine->Run()))
     return YES;
 
   return NO;
 
@@ -362,17 +362,17 @@ ProcessPendingGetURLAppleEvents()
       NS_ERROR("Couldn't create command line!");
       return;
     }
     nsCOMPtr<nsIFile> workingDir;
     nsresult rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir));
     if (NS_FAILED(rv))
       return;
     const char *argv[3] = {nullptr, "-url", [urlString UTF8String]};
-    rv = cmdLine->Init(3, const_cast<char**>(argv), workingDir, nsICommandLine::STATE_REMOTE_EXPLICIT);
+    rv = cmdLine->Init(3, argv, workingDir, nsICommandLine::STATE_REMOTE_EXPLICIT);
     if (NS_FAILED(rv))
       return;
     rv = cmdLine->Run();
   }
   else if ([event eventClass] == kCoreEventClass && [event eventID] == kAEOpenDocuments) {
     NSAppleEventDescriptor* fileListDescriptor = [event paramDescriptorForKeyword:keyDirectObject];
     if (!fileListDescriptor)
       return;
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -468,17 +468,17 @@ nsAppShell::ProcessNextNativeEvent(bool 
         char *flag = ToNewUTF8String(curEvent->CharactersExtra());
 
         const char *argv[4] = {
             "dummyappname",
             "-url",
             uri,
             flag ? flag : ""
         };
-        nsresult rv = cmdline->Init(4, const_cast<char **>(argv), nullptr, nsICommandLine::STATE_REMOTE_AUTO);
+        nsresult rv = cmdline->Init(4, argv, nullptr, nsICommandLine::STATE_REMOTE_AUTO);
         if (NS_SUCCEEDED(rv))
             cmdline->Run();
         nsMemory::Free(uri);
         if (flag)
             nsMemory::Free(flag);
         break;
     }