3 # Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 # its contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # Script to do a rename in JavaScriptCore, WebCore, and WebKit.
33 use lib $FindBin::Bin;
43 # find all files we want to process
46 find(\&wanted, "JavaScriptCore");
47 find(\&wanted, "JavaScriptGlue");
48 find(\&wanted, "WebCore");
49 find(\&wanted, "WebKit");
56 $File::Find::prune = 1;
60 if ($file =~ /^\../) {
61 $File::Find::prune = 1;
65 return if $file =~ /^ChangeLog/;
68 push @paths, $File::Find::name;
70 my $isDOMTypeRename = 0;
72 "m_sel" => "m_selection",
75 my %renamesContemplatedForTheFuture = (
76 "HTMLPlugInImageElement" => "HTMLEmbeddedObjectElement",
78 "DOMObject" => "JSDOMObject",
80 "runtimeObjectGetter" => "pluginElementGetter",
81 "runtimeObjectPropertyGetter" => "pluginElementPropertyGetter",
82 "runtimeObjectCustomGetOwnPropertySlot" => "pluginElementCustomGetOwnPropertySlot",
83 "runtimeObjectCustomPut" => "pluginElementCustomPut",
84 "runtimeObjectImplementsCall" => "pluginElementImplementsCall",
85 "runtimeObjectCallAsFunction" => "pluginElementCallAsFunction",
87 "CLONE_CONTENTS" => "Clone",
88 "DELETE_CONTENTS" => "Delete",
89 "EXTRACT_CONTENTS" => "Extract",
91 "DateInstance" => "JSDate",
92 "ErrorInstance" => "JSError",
95 "KURLCFNet" => "URLCF",
96 "KURLHash" => "URLHash",
97 "KURLMac" => "URLMac",
100 "ThreadSafeSharedBase" => "ThreadSafeRefCountedBase",
101 "ThreadSafeShared" => "ThreadSafeRefCounted",
102 "TreeShared" => "TreeRefCounted",
104 "StringImpl" => "SharedString",
106 "RenderView" => "RenderViewport",
108 "ObjcFallbackObjectImp" => "ObjCFallbackObject",
109 "RuntimeObjectImp" => "ForeignObject",
111 "runtime_array" => "BridgedArray",
112 "runtime_method" => "BridgedFunction",
113 "runtime_object" => "BridgedObject",
114 "objc_runtime" => "ObjCBridge",
116 "equalIgnoringCase" => "equalFoldingCase",
118 "FTPDirectoryTokenizer" => "FTPDirectoryDocumentBuilder",
119 "HTMLTokenizer" => "HTMLDocumentBuilder",
120 "ImageTokenizer" => "ImageDocumentBuilder",
121 "PluginTokenizer" => "PluginDocumentBuilder",
122 "TextTokenizer" => "TextDocumentBuilder",
123 "Tokenizer" => "DocumentBuilder",
124 "Tokenizer_h" => "DocumentBuilder_h",
125 "XMLTokenizer" => "XMLDocumentBuilder",
126 "isHTMLTokenizer" => "isHTMLDocumentBuilder",
127 "m_tokenizer" => "m_builder",
128 "createTokenizer" => "createBuilder",
129 "tokenizerProcessedData" => "documentBuilderProcessedData",
131 "WTF_UNICODE_H" => "Unicode_h",
132 "WTF_UNICODE_ICU_H" => "UnicodeICU_h",
133 "WTF_UNICODE_QT4_H" => "UnicodeQt4_h",
134 "UnicodeIcu" => "UnicodeICU",
136 "m_invertibleCTM" => "m_transformIsInvertible",
138 "NativeFunctionWrapper_h" => "JSHostFunction_h",
139 "NativeFunctionWrapper" => "JSHostFunction",
140 "nativeFunctionThunk" => "hostFunctionThunk",
141 "nativeFunction" => "hostFunction",
142 "NativeFunction" => "HostFunction",
148 for my $file (sort @paths) {
150 $f = "$1$renames{$2}$3" if $f =~ /^(.*\/)(\w+)(\.\w+)$/ && $renames{$2};
152 $newFile{$file} = $f;
159 for my $file (sort @paths) {
160 if ($newFile{$file}) {
161 my $newFile = $newFile{$file};
162 print "Renaming $file to $newFile\n";
164 system "git mv $file $newFile";
166 system "svn move $file $newFile";
171 # change all file contents
173 for my $file (sort @paths) {
174 $file = $newFile{$file} if $newFile{$file};
178 open FILE, $file or die;
182 my $newContents = $contents;
184 if ($isDOMTypeRename) {
185 for my $from (keys %renames) {
186 $newContents =~ s/\b$from/$renames{$from}/g;
189 for my $from (keys %renames) {
190 $newContents =~ s/\b$from(?!["\w])/$renames{$from}/g; # this " unconfuses Xcode syntax highlighting
194 if ($newContents ne $contents) {
195 open FILE, ">", $file or die;
196 print FILE $newContents;