1563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#!/usr/bin/perl -w 2563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 3563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 4563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 5563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# Redistribution and use in source and binary forms, with or without 6563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# modification, are permitted provided that the following conditions 7563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# are met: 8563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 9563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 1. Redistributions of source code must retain the above copyright 10563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# notice, this list of conditions and the following disclaimer. 11563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 2. Redistributions in binary form must reproduce the above copyright 12563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# notice, this list of conditions and the following disclaimer in the 13563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# documentation and/or other materials provided with the distribution. 14563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# its contributors may be used to endorse or promote products derived 16563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# from this software without specific prior written permission. 17563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 18563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 29563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# Script to do a rename in JavaScriptCore, WebCore, and WebKit. 30563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 31563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkuse strict; 32545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 33545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochuse File::Find; 34563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkuse FindBin; 35545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochuse Getopt::Long qw(:config pass_through); 36545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 37563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkuse lib $FindBin::Bin; 38563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkuse webkitdirs; 39643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockuse VCSUtils; 40563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 41563af33bc48281d19dce701398dbb88cb54fd7ecCary ClarksetConfiguration(); 42563af33bc48281d19dce701398dbb88cb54fd7ecCary ClarkchdirWebKit(); 43563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 44545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy $showHelp; 45545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy $verbose; 46545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 47545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy $programName = basename($0); 48545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy $usage = <<EOF; 49545e470e52f0ac6a3a072bf559c796b42c6066b6Ben MurdochUsage: $programName [options] 50545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch -h|--help Show this help message 51545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch -v|--verbose More verbose output 52545e470e52f0ac6a3a072bf559c796b42c6066b6Ben MurdochEOF 53545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 54545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy $getOptionsResult = GetOptions( 55545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 'help|h' => \$showHelp, 56545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 'verbose|v' => \$verbose, 57545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch); 58545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 59545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochif (!$getOptionsResult || $showHelp) { 60545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch print STDERR $usage; 61545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch exit 1; 62545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch} 63545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 64545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy @directoriesToIgnoreList = ( 65545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch "icu", 66545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch); 67545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy %directoriesToIgnore = map { $_ => 1 } @directoriesToIgnoreList; 68563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 69563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# find all files we want to process 70563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 71563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkmy @paths; 72cad810f21b803229eb11403f9209855525a25d57Steve Blockfind(\&wanted, "Source/JavaScriptCore"); 73cad810f21b803229eb11403f9209855525a25d57Steve Blockfind(\&wanted, "Source/JavaScriptGlue"); 74cad810f21b803229eb11403f9209855525a25d57Steve Blockfind(\&wanted, "Source/WebCore"); 752fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockfind(\&wanted, "Source/WebKit"); 7665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochfind(\&wanted, "Source/WebKit2"); 77cad810f21b803229eb11403f9209855525a25d57Steve Blockfind(\&wanted, "Tools/DumpRenderTree"); 78563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 79563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarksub wanted 80563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{ 81563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark my $file = $_; 82563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 83545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch # Ignore excluded and hidden files/directories. 84545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch if ($directoriesToIgnore{$file} or $file =~ /^\../ or $file =~ /^ChangeLog/) { 85545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch print "Ignoring $File::Find::name\n" if $verbose; 86563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark $File::Find::prune = 1; 87563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark return; 88563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark } 89563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 90563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark return if -d $file; 91563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 92563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark push @paths, $File::Find::name; 93563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark} 946c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen 956c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen# Setting isDOMTypeRename to 1 rather than 0 expands the regexps used 966c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen# below to handle custom JavaScript bindings. 97545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdochmy $isDOMTypeRename = 0; 98563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkmy %renames = ( 99545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch # Renames go here in the form of: 1002daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch "MediaControls" => "MediaControlRootElement", 101563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark); 102563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 103563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkmy %renamesContemplatedForTheFuture = ( 104d0825bca7fe65beaee391d30da42e937db621564Steve Block "HTMLPlugInImageElement" => "HTMLEmbeddedObjectElement", 105d0825bca7fe65beaee391d30da42e937db621564Steve Block 106563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "DOMObject" => "JSDOMObject", 107563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 108563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtimeObjectGetter" => "pluginElementGetter", 109563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtimeObjectPropertyGetter" => "pluginElementPropertyGetter", 110563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtimeObjectCustomGetOwnPropertySlot" => "pluginElementCustomGetOwnPropertySlot", 111563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtimeObjectCustomPut" => "pluginElementCustomPut", 112563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtimeObjectImplementsCall" => "pluginElementImplementsCall", 113563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtimeObjectCallAsFunction" => "pluginElementCallAsFunction", 114563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 115563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "CLONE_CONTENTS" => "Clone", 116563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "DELETE_CONTENTS" => "Delete", 117563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "EXTRACT_CONTENTS" => "Extract", 118563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 119563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "DateInstance" => "JSDate", 120563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "ErrorInstance" => "JSError", 121563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 122563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "KURL" => "URL", 123563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "KURLCFNet" => "URLCF", 124563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "KURLHash" => "URLHash", 125563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "KURLMac" => "URLMac", 126563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "KURL_h" => "URL_h", 127563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 128563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "TreeShared" => "TreeRefCounted", 129563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 130563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "StringImpl" => "SharedString", 131563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 132563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "RenderView" => "RenderViewport", 133563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 134563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "ObjcFallbackObjectImp" => "ObjCFallbackObject", 135563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "RuntimeObjectImp" => "ForeignObject", 136563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 137563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtime_array" => "BridgedArray", 138563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtime_method" => "BridgedFunction", 139563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "runtime_object" => "BridgedObject", 140563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "objc_runtime" => "ObjCBridge", 141563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 142563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "equalIgnoringCase" => "equalFoldingCase", 143563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 144563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "FTPDirectoryTokenizer" => "FTPDirectoryDocumentBuilder", 145563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "HTMLTokenizer" => "HTMLDocumentBuilder", 146563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "ImageTokenizer" => "ImageDocumentBuilder", 147563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "PluginTokenizer" => "PluginDocumentBuilder", 148563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "TextTokenizer" => "TextDocumentBuilder", 149563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "Tokenizer" => "DocumentBuilder", 150563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "Tokenizer_h" => "DocumentBuilder_h", 151563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "XMLTokenizer" => "XMLDocumentBuilder", 152563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "isHTMLTokenizer" => "isHTMLDocumentBuilder", 153563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "m_tokenizer" => "m_builder", 154563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "createTokenizer" => "createBuilder", 155563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "tokenizerProcessedData" => "documentBuilderProcessedData", 156563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 157563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "WTF_UNICODE_H" => "Unicode_h", 158563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "WTF_UNICODE_ICU_H" => "UnicodeICU_h", 159563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "WTF_UNICODE_QT4_H" => "UnicodeQt4_h", 160563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "UnicodeIcu" => "UnicodeICU", 161563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 162563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark "m_invertibleCTM" => "m_transformIsInvertible", 163563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 1640bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch "NativeFunctionWrapper_h" => "JSHostFunction_h", 1650bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch "NativeFunctionWrapper" => "JSHostFunction", 1660bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch "nativeFunctionThunk" => "hostFunctionThunk", 1670bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch "nativeFunction" => "hostFunction", 1680bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch "NativeFunction" => "HostFunction", 169563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark); 170563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 1716c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen# Sort the keys of the renames hash in order of decreasing length. This 1726c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen# handles the case where some of the renames are substrings of others; 1736c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen# i.e., "Foo" => "Bar" and "FooBuffer" => "BarBuffer". 1746c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenmy @sortedRenameKeys = sort { length($b) - length($a) } keys %renames; 1756c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen 176563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# rename files 177563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 1786c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsensub renameFile 1796c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen{ 1806c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen my $file = shift; 1816c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen 1826c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen if ($isDOMTypeRename) { 1836c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen # Find the longest key in %renames which matches this more permissive regexp. 1846c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen # (The old regexp would match ".../Foo.cpp" but not ".../JSFooCustom.cpp".) 1856c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen # This handles renaming of custom JavaScript bindings even when some of the 1866c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen # renames are substrings of others. The only reason we don't do this all the 1876c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen # time is to avoid accidental file renamings for short, non-DOM renames. 1886c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen for my $key (@sortedRenameKeys) { 1896c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen my $newFile = ""; 1906c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen $newFile = "$1$renames{$2}$3" if $file =~ /^(.*\/\w*)($key)(\w*\.\w+)$/; 1916c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen if ($newFile ne "") { 1926c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen return $newFile; 1936c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen } 1946c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen } 1956c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen } else { 1966c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen $file = "$1$renames{$2}$3" if $file =~ /^(.*\/)(\w+)(\.\w+)$/ && $renames{$2}; 1976c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen } 1986c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen return $file; 1996c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen} 2006c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen 201563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkmy %newFile; 202563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkfor my $file (sort @paths) { 2036c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen my $f = renameFile($file); 204563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark if ($f ne $file) { 205563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark $newFile{$file} = $f; 206563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark } 207563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark} 208563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 209563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkfor my $file (sort @paths) { 210563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark if ($newFile{$file}) { 211563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark my $newFile = $newFile{$file}; 212563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark print "Renaming $file to $newFile\n"; 213a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch scmMoveOrRenameFile($file, $newFile); 214563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark } 215563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark} 216563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 217563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# change all file contents 218563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 219563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkfor my $file (sort @paths) { 220563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark $file = $newFile{$file} if $newFile{$file}; 221563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark my $contents; 222563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark { 223563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark local $/; 224545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch open FILE, $file or die "Failed to open $file"; 225563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark $contents = <FILE>; 226563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark close FILE; 227563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark } 228563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark my $newContents = $contents; 229563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 230643ca7872b450ea4efacab6188849e5aac2ba161Steve Block if ($isDOMTypeRename) { 2316c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen for my $from (@sortedRenameKeys) { 2326c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen # Handle JavaScript custom bindings. 2336c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen $newContents =~ s/\b(JS|V8|to|)$from/$1$renames{$from}/g; 234643ca7872b450ea4efacab6188849e5aac2ba161Steve Block } 235643ca7872b450ea4efacab6188849e5aac2ba161Steve Block } else { 2366c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen for my $from (@sortedRenameKeys) { 237643ca7872b450ea4efacab6188849e5aac2ba161Steve Block $newContents =~ s/\b$from(?!["\w])/$renames{$from}/g; # this " unconfuses Xcode syntax highlighting 238643ca7872b450ea4efacab6188849e5aac2ba161Steve Block } 239563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark } 240563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 241563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark if ($newContents ne $contents) { 242545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch open FILE, ">", $file or die "Failed to open $file"; 243563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark print FILE $newContents; 244563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark close FILE; 245563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark } 246563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark} 247