Changeset 63561 in webkit
- Timestamp:
- Jul 16, 2010 10:16:56 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r63560 r63561 1 2010-07-16 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 WebInspector: The current implementation of generator is not ready 6 for generation Backend part of Inspector interface. The full patch 7 with Backend is quite big and I've split it. 8 https://bugs.webkit.org/show_bug.cgi?id=42462 9 10 * inspector/CodeGeneratorInspector.pm: 11 * inspector/Inspector.idl: 12 * inspector/InspectorValues.cpp: 13 (WebCore::InspectorArray::get): 14 * inspector/InspectorValues.h: 15 (WebCore::InspectorArray::length): 16 1 17 2010-07-15 Rob Buis <rwlbuis@gmail.com> 2 18 -
trunk/WebCore/inspector/CodeGeneratorInspector.pm
r63198 r63561 7 7 use strict; 8 8 9 use Class::Struct; 9 10 use File::stat; 10 11 … … 22 23 "forward" => "InspectorObject", 23 24 "header" => "InspectorValues.h", 24 " push" => "push"25 "accessorSuffix" => "" 25 26 }; 26 27 $typeTransform{"Array"} = { … … 29 30 "forward" => "InspectorArray", 30 31 "header" => "InspectorValues.h", 31 " push" => "push"32 "accessorSuffix" => "" 32 33 }; 33 34 $typeTransform{"Value"} = { … … 36 37 "forward" => "InspectorValue", 37 38 "header" => "InspectorValues.h", 38 " push" => "push"39 "accessorSuffix" => "" 39 40 }; 40 41 $typeTransform{"String"} = { … … 43 44 "forward" => "String", 44 45 "header" => "PlatformString.h", 45 " push" => "pushString"46 "accessorSuffix" => "String" 46 47 }; 47 48 $typeTransform{"long"} = { … … 50 51 "forward" => "", 51 52 "header" => "", 52 " push" => "pushNumber"53 "accessorSuffix" => "Number" 53 54 }; 54 55 $typeTransform{"int"} = { … … 57 58 "forward" => "", 58 59 "header" => "", 59 " push" => "pushNumber"60 "accessorSuffix" => "Number", 60 61 }; 61 62 $typeTransform{"unsigned long"} = { … … 64 65 "forward" => "", 65 66 "header" => "", 66 " push" => "pushNumber"67 "accessorSuffix" => "Number" 67 68 }; 68 69 $typeTransform{"boolean"} = { … … 71 72 "forward" => "", 72 73 "header" => "", 73 " push" => "pushBool"74 "accessorSuffix" => "Bool" 74 75 }; 75 76 $typeTransform{"void"} = { … … 93 94 94 95 my $namespace; 96 95 97 my $frontendClassName; 96 my %discoveredTypes; 97 my %generatedFunctions; 98 99 my @frontendClassDeclaration; 100 my @functionDefinitions; 101 102 sub typeSpec 103 { 104 my $param = shift; 105 my $retValue = shift; 106 107 my $type = $typeTransform{$param->type}->{$retValue ? "retVal" : "param"}; 108 $discoveredTypes{$param->type} = 1; 109 $type or die "invalid type specification \"" . $param->type ."\""; 110 return $type; 111 } 98 my %frontendTypes; 99 my %frontendMethods; 100 my @frontendMethodsImpl; 101 my $frontendConstructor; 102 my $frontendFooter; 103 104 my $callId = new domSignature(); # it is just structure for describing parameters from IDLStructure.pm. 105 $callId->type("long"); 106 $callId->name("callId"); 112 107 113 108 # Default constructor … … 146 141 147 142 my $className = $interface->name; 143 148 144 $frontendClassName = "Remote" . $className . "Frontend"; 149 150 $discoveredTypes{"String"} = 1; 151 $discoveredTypes{"InspectorClient"} = 1; 152 $discoveredTypes{"PassRefPtr"} = 1; 153 154 push(@frontendClassDeclaration, "class $frontendClassName {"); 155 push(@frontendClassDeclaration, "public:"); 156 push(@frontendClassDeclaration, " $frontendClassName(InspectorClient* inspectorClient) : m_inspectorClient(inspectorClient) { }"); 157 push(@frontendClassDeclaration, ""); 158 push(@frontendClassDeclaration, generateFunctions($interface, $frontendClassName)); 159 push(@frontendClassDeclaration, ""); 160 push(@frontendClassDeclaration, "private:"); 161 push(@frontendClassDeclaration, " InspectorClient* m_inspectorClient;"); 162 push(@frontendClassDeclaration, "};"); 145 $frontendConstructor = " ${frontendClassName}(InspectorClient* inspectorClient) : m_inspectorClient(inspectorClient) { }"; 146 $frontendFooter = " InspectorClient* m_inspectorClient;"; 147 $frontendTypes{"String"} = 1; 148 $frontendTypes{"InspectorClient"} = 1; 149 $frontendTypes{"PassRefPtr"} = 1; 150 151 generateFunctions($interface); 163 152 } 164 153 … … 166 155 { 167 156 my $interface = shift; 157 158 foreach my $function (@{$interface->functions}) { 159 generateFrontendFunction($function); 160 } 161 } 162 163 sub generateFrontendFunction 164 { 165 my $function = shift; 166 167 my $functionName; 168 my $notify = $function->signature->extendedAttributes->{"notify"}; 169 if ($notify) { 170 $functionName = $function->signature->name; 171 } else { 172 my $customResponse = $function->signature->extendedAttributes->{"customResponse"}; 173 $functionName = $customResponse ? $customResponse : "did" . ucfirst($function->signature->name); 174 } 175 176 my @argsFiltered = grep($_->direction eq "out", @{$function->parameters}); # just keep only out parameters for frontend interface. 177 unshift(@argsFiltered, $callId) if !$notify; # Add callId as the first argument for all frontend did* methods. 178 map($frontendTypes{$_->type} = 1, @argsFiltered); # register required types. 179 my $arguments = join(", ", map($typeTransform{$_->type}->{"param"} . " " . $_->name, @argsFiltered)); # prepare arguments for function signature. 180 my @pushArguments = map(" arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @argsFiltered); 181 182 my $signature = " void ${functionName}(${arguments});"; 183 if (!$frontendMethods{${signature}}) { 184 $frontendMethods{${signature}} = 1; 185 186 my @function; 187 push(@function, "void ${frontendClassName}::${functionName}(${arguments})"); 188 push(@function, "{"); 189 push(@function, " RefPtr<InspectorArray> arguments = InspectorArray::create();"); 190 push(@function, " arguments->pushString(\"$functionName\");"); 191 push(@function, @pushArguments); 192 push(@function, " m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());"); 193 push(@function, "}"); 194 push(@function, ""); 195 push(@frontendMethodsImpl, @function); 196 } 197 } 198 199 sub generateHeader 200 { 168 201 my $className = shift; 169 170 my @functionDeclarations; 171 foreach my $function (@{$interface->functions}) { 172 my $functionName; 173 my $argumentsDirectionFilter; 174 my $arguments; 175 my @functionBody; 176 push(@functionBody, " RefPtr<InspectorArray> arguments = InspectorArray::create();"); 177 if ($function->signature->extendedAttributes->{"notify"}) { 178 $functionName = $function->signature->name; 179 $argumentsDirectionFilter = "in"; 180 $arguments = ""; 181 push(@functionBody, " arguments->pushString(\"$functionName\");"); 182 } else { 183 my $customResponse = $function->signature->extendedAttributes->{"customResponse"}; 184 $functionName = $customResponse ? $customResponse : "did" . ucfirst($function->signature->name); 185 $argumentsDirectionFilter = "out"; 186 $arguments = "long callId"; 187 push(@functionBody, " arguments->pushString(\"$functionName\");"); 188 push(@functionBody, " arguments->pushNumber(callId);"); 189 } 190 191 foreach my $parameter (@{$function->parameters}) { 192 if ($parameter->direction eq $argumentsDirectionFilter) { 193 $parameter->name or die "empty argument name specified for function ${frontendClassName}::$functionName and argument type " . $parameter->type; 194 $arguments = $arguments . ", " if ($arguments); 195 $arguments = $arguments . typeSpec($parameter) . " " . $parameter->name; 196 my $pushFunctionName = $typeTransform{$parameter->type}->{"push"}; 197 push(@functionBody, " arguments->$pushFunctionName(" . $parameter->name . ");"); 198 } 199 } 200 push(@functionBody, " m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());"); 201 202 my $signature = " " . typeSpec($function->signature, 1) . " $functionName($arguments);"; 203 if (!$generatedFunctions{${signature}}) { 204 $generatedFunctions{${signature}} = 1; 205 push(@functionDeclarations, $signature); 206 207 my @function; 208 push(@function, typeSpec($function->signature, 1) . " " . $className . "::" . $functionName . "(" . $arguments . ")"); 209 push(@function, "{"); 210 push(@function, @functionBody); 211 push(@function, "}"); 212 push(@function, ""); 213 push(@functionDefinitions, @function); 214 } 215 } 216 return @functionDeclarations; 217 } 218 219 sub generateHeader 220 { 221 my @headerContent = split("\r", $licenseTemplate); 222 push(@headerContent, "#ifndef ${frontendClassName}_h"); 223 push(@headerContent, "#define ${frontendClassName}_h"); 224 push(@headerContent, ""); 225 226 my @forwardHeaders; 227 foreach my $type (keys %discoveredTypes) { 228 push(@forwardHeaders, "#include <" . $typeTransform{$type}->{"forwardHeader"} . ">") if !$typeTransform{$type}->{"forwardHeader"} eq ""; 229 } 230 push(@headerContent, sort @forwardHeaders); 231 push(@headerContent, ""); 232 push(@headerContent, "namespace $namespace {"); 233 push(@headerContent, ""); 234 235 my @forwardDeclarations; 236 foreach my $type (keys %discoveredTypes) { 237 push(@forwardDeclarations, "class " . $typeTransform{$type}->{"forward"} . ";") if !$typeTransform{$type}->{"forward"} eq ""; 238 } 239 push(@headerContent, sort @forwardDeclarations); 240 241 push(@headerContent, ""); 242 push(@headerContent, @frontendClassDeclaration); 243 push(@headerContent, ""); 244 push(@headerContent, "} // namespace $namespace"); 245 push(@headerContent, ""); 246 push(@headerContent, "#endif // !defined(${frontendClassName}_h)"); 247 push(@headerContent, ""); 248 return @headerContent; 202 my $types = shift; 203 my $constructor = shift; 204 my $methods = shift; 205 my $footer = shift; 206 207 my $forwardHeaders = join("\n", sort(map("#include <" . $typeTransform{$_}->{"forwardHeader"} . ">", grep($typeTransform{$_}->{"forwardHeader"}, keys %{$types})))); 208 my $forwardDeclarations = join("\n", sort(map("class " . $typeTransform{$_}->{"forward"} . ";", grep($typeTransform{$_}->{"forward"}, keys %{$types})))); 209 my $methodsDeclarations = join("\n", keys %{$methods}); 210 211 my $headerBody = << "EOF"; 212 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 213 // Use of this source code is governed by a BSD-style license that can be 214 // found in the LICENSE file. 215 #ifndef ${className}_h 216 #define ${className}_h 217 218 ${forwardHeaders} 219 220 namespace $namespace { 221 222 $forwardDeclarations 223 224 class $className { 225 public: 226 $constructor 227 228 $methodsDeclarations 229 230 private: 231 $footer 232 }; 233 234 } // namespace $namespace 235 #endif // !defined(${className}_h) 236 237 EOF 238 return $headerBody; 249 239 } 250 240 251 241 sub generateSource 252 242 { 243 my $className = shift; 244 my $types = shift; 245 my $methods = shift; 246 253 247 my @sourceContent = split("\r", $licenseTemplate); 254 248 push(@sourceContent, "\n#include \"config.h\""); 255 push(@sourceContent, "#include \"$ frontendClassName.h\"");249 push(@sourceContent, "#include \"$className.h\""); 256 250 push(@sourceContent, ""); 257 251 push(@sourceContent, "#if ENABLE(INSPECTOR)"); … … 259 253 260 254 my %headers; 261 foreach my $type (keys % discoveredTypes) {255 foreach my $type (keys %{$types}) { 262 256 $headers{"#include \"" . $typeTransform{$type}->{"header"} . "\""} = 1 if !$typeTransform{$type}->{"header"} eq ""; 263 257 } … … 266 260 push(@sourceContent, "namespace $namespace {"); 267 261 push(@sourceContent, ""); 268 push(@sourceContent, @ functionDefinitions);262 push(@sourceContent, @{$methods}); 269 263 push(@sourceContent, ""); 270 264 push(@sourceContent, "} // namespace $namespace"); … … 280 274 281 275 open(my $SOURCE, ">$outputDir/$frontendClassName.cpp") || die "Couldn't open file $outputDir/$frontendClassName.cpp"; 282 open(my $HEADER, ">$outputDir/$frontendClassName.h") || die "Couldn't open file $outputDir/$frontendClassName.h"; 283 284 print $SOURCE join("\n", generateSource()); 276 print $SOURCE join("\n", generateSource($frontendClassName, \%frontendTypes, \@frontendMethodsImpl)); 285 277 close($SOURCE); 286 278 undef($SOURCE); 287 279 288 print $HEADER join("\n", generateHeader()); 280 open(my $HEADER, ">$outputDir/$frontendClassName.h") || die "Couldn't open file $outputDir/$frontendClassName.h"; 281 print $HEADER generateHeader($frontendClassName, \%frontendTypes, $frontendConstructor, \%frontendMethods, $frontendFooter); 289 282 close($HEADER); 290 283 undef($HEADER); 284 291 285 } 292 286 -
trunk/WebCore/inspector/Inspector.idl
r63309 r63561 33 33 module core { 34 34 interface [Conditional=INSPECTOR] Inspector { 35 [notify] void addRecordToTimeline( inObject record);36 [notify] void addNodesToSearchResult( inArray nodeIds);37 [notify] void attributesUpdated( in long id, inArray attributes);38 [notify] void childNodeCountUpdated( in long id, inint newValue);39 [notify] void childNodeInserted( in long parentId, in long prevId, inObject node);40 [notify] void childNodeRemoved( in long parentId, inlong id);41 [notify] void setChildNodes( in long parentId, inArray nodes);42 [notify] void setDetachedRoot( inObject root);43 [notify] void setDocument( inValue root);35 [notify] void addRecordToTimeline(out Object record); 36 [notify] void addNodesToSearchResult(out Array nodeIds); 37 [notify] void attributesUpdated(out long id, out Array attributes); 38 [notify] void childNodeCountUpdated(out long id, out int newValue); 39 [notify] void childNodeInserted(out long parentId, out long prevId, out Object node); 40 [notify] void childNodeRemoved(out long parentId, out long id); 41 [notify] void setChildNodes(out long parentId, out Array nodes); 42 [notify] void setDetachedRoot(out Object root); 43 [notify] void setDocument(out Value root); 44 44 45 45 void storeLastActivePanel(in String panelName); … … 56 56 void enableResourceTracking(in boolean always); 57 57 void disableResourceTracking(in boolean always); 58 void getResourceContent(in unsigned long identifier);58 void getResourceContent(in long callId, in unsigned long identifier); 59 59 void reloadPage(); 60 60 … … 66 66 void disableDebugger(in boolean always); 67 67 68 void setBreakpoint(in String sourceID, in unsigned long lineNumber, in boolean enabled, in String condition);68 void setBreakpoint(in long callId, in String sourceID, in unsigned long lineNumber, in boolean enabled, in String condition); 69 69 void removeBreakpoint(in String sourceID, in unsigned long lineNumber); 70 70 void activateBreakpoints(); … … 80 80 void setPauseOnExceptionsState(in long pauseOnExceptionsState); 81 81 82 void editScriptSource(in String sourceID, in String newContent);83 void getScriptSource(in String sourceID);82 void editScriptSource(in long callId, in String sourceID, in String newContent); 83 void getScriptSource(in long callId, in String sourceID); 84 84 85 85 void enableProfiler(in boolean always); … … 89 89 void stopProfiling(); 90 90 91 void getProfileHeaders( );92 void getProfile(in unsigned long uid);91 void getProfileHeaders(in long callId); 92 void getProfile(in long callId, in unsigned long uid); 93 93 94 94 void removeProfile(in unsigned long uid); … … 98 98 #endif 99 99 void setInjectedScriptSource(in String scriptSource); 100 void dispatchOnInjectedScript(in long injectedScriptId, in String methodName, in String arguments, in boolean async);100 void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in String methodName, in String arguments, in boolean async); 101 101 102 102 void addScriptToEvaluateOnLoad(in String scriptSource); 103 103 void removeAllScriptsToEvaluateOnLoad(); 104 104 105 void getChildNodes(in long nodeId);106 [customResponse=didApplyDomChange] void setAttribute(in long elementId, in String name, in String value, out boolean success);107 [customResponse=didApplyDomChange] void removeAttribute(in long elementId, in String name, out boolean success);108 void setTextNodeValue(in long nodeId, in String value);109 void getEventListenersForNode(in long nodeId, out long nodeId, out Array listenersArray);105 void getChildNodes(in long callId, in long nodeId); 106 [customResponse=didApplyDomChange] void setAttribute(in long callId, in long elementId, in String name, in String value, out boolean success); 107 [customResponse=didApplyDomChange] void removeAttribute(in long callId, in long elementId, in String name, out boolean success); 108 void setTextNodeValue(in long callId, in long nodeId, in String value); 109 void getEventListenersForNode(in long callId, in long nodeId, out long nodeId, out Array listenersArray); 110 110 void copyNode(in long nodeId); 111 void removeNode(in long nodeId, out long nodeId);112 void changeTagName(in long nodeId, in String newTagName, out long nodeId);113 void getOuterHTML(in long nodeId, out String outerHTML);114 void setOuterHTML(in long nodeId, in String outerHTML, out long nodeId);111 void removeNode(in long callId, in long nodeId, out long nodeId); 112 void changeTagName(in long callId, in long nodeId, in String newTagName, out long nodeId); 113 void getOuterHTML(in long callId, in long nodeId, out String outerHTML); 114 void setOuterHTML(in long callId, in long nodeId, in String outerHTML, out long nodeId); 115 115 void addInspectedNode(in long nodeId); 116 116 void performSearch(in String query, in boolean runSynchronously); 117 117 void searchCanceled(); 118 void pushNodeByPathToFrontend(in String path, out long nodeId);118 void pushNodeByPathToFrontend(in long callId, in String path, out long nodeId); 119 119 120 120 void clearConsoleMessages(); … … 123 123 void hideDOMNodeHighlight(); 124 124 125 void getStyles(in long nodeId, in boolean authOnly, out Value styles);126 void getAllStyles( out Array styles);127 void getInlineStyle(in long nodeId, out Value style);128 void getComputedStyle(in long nodeId, out Value style);129 void getStyleSheet(in long styleSheetId, out Value styleSheet);130 void getRuleRangesForStyleSheetId(in long styleSheetId);131 void applyStyleText(in long styleId, in String styleText, in String propertyName, out boolean success, out Value style, out Array changedProperties);132 void setStyleText(in long styleId, in String styleText, out boolean success);133 void setStyleProperty(in long styleId, in String name, in String value, out boolean success);134 void toggleStyleEnabled(in long styleId, in String propertyName, in boolean disabled, out Value style);135 void setRuleSelector(in long ruleId, in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode);136 void addRule(in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode);125 void getStyles(in long callId, in long nodeId, in boolean authOnly, out Value styles); 126 void getAllStyles(in long callId, out Array styles); 127 void getInlineStyle(in long callId, in long nodeId, out Value style); 128 void getComputedStyle(in long callId, in long nodeId, out Value style); 129 void getStyleSheet(in long callId, in long styleSheetId, out Value styleSheet); 130 void getRuleRangesForStyleSheetId(in long callId, in long styleSheetId); 131 void applyStyleText(in long callId, in long styleId, in String styleText, in String propertyName, out boolean success, out Value style, out Array changedProperties); 132 void setStyleText(in long callId, in long styleId, in String styleText, out boolean success); 133 void setStyleProperty(in long callId, in long styleId, in String name, in String value, out boolean success); 134 void toggleStyleEnabled(in long callId, in long styleId, in String propertyName, in boolean disabled, out Value style); 135 void setRuleSelector(in long callId, in long ruleId, in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode); 136 void addRule(in long callId, in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode); 137 137 138 void getCookies( );138 void getCookies(in long callId); 139 139 void deleteCookie(in String cookieName, in String domain); 140 140 141 141 #if defined(ENABLE_OFFLINE_WEB_APPLICATIONS) && ENABLE_OFFLINE_WEB_APPLICATIONS 142 void getApplicationCaches( );142 void getApplicationCaches(in long callId); 143 143 #endif 144 144 145 145 void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup); 146 void didEvaluateForTestInFrontend(in String jsonResult);146 void didEvaluateForTestInFrontend(in long callId, in String jsonResult); 147 147 148 148 #if defined(ENABLE_DATABASE) && ENABLE_DATABASE 149 void getDatabaseTableNames(in long databaseId);149 void getDatabaseTableNames(in long callId, in long databaseId); 150 150 #endif 151 151 152 152 #if defined(ENABLE_DOM_STORAGE) && ENABLE_DOM_STORAGE 153 void getDOMStorageEntries(in long storageId);154 void setDOMStorageItem(in long storageId, in String key, in String value);155 void removeDOMStorageItem(in long storageId, in String key);153 void getDOMStorageEntries(in long callId, in long storageId); 154 void setDOMStorageItem(in long callId, in long storageId, in String key, in String value); 155 void removeDOMStorageItem(in long callId, in long storageId, in String key); 156 156 #endif 157 157 }; -
trunk/WebCore/inspector/InspectorValues.cpp
r61414 r63561 651 651 } 652 652 653 PassRefPtr<InspectorValue> InspectorArray::get(size_t index) 654 { 655 ASSERT(index < m_data.size()); 656 return m_data[index]; 657 } 658 653 659 } // namespace WebCore 654 660 -
trunk/WebCore/inspector/InspectorValues.h
r61414 r63561 199 199 void pushString(const String&); 200 200 void push(PassRefPtr<InspectorValue>); 201 unsigned length() { return m_data.size(); } 201 unsigned length() const { return m_data.size(); } 202 203 PassRefPtr<InspectorValue> get(size_t index); 202 204 203 205 virtual void writeJSON(Vector<UChar>* output) const;
Note: See TracChangeset
for help on using the changeset viewer.