Changeset 63962 in webkit
- Timestamp:
- Jul 23, 2010 4:58:54 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r63961 r63962 1 2010-07-23 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: error info propagation in InspectorBackendDispatch should be improved 6 https://bugs.webkit.org/show_bug.cgi?id=42873 7 8 * inspector/CodeGeneratorInspector.pm: report wrong parameter count and wrong 9 parametere type errror to the dispatch method caller 10 1 11 2010-07-23 Pavel Feldman <pfeldman@chromium.org> 2 12 -
trunk/WebCore/inspector/CodeGeneratorInspector.pm
r63952 r63962 173 173 $backendTypes{"Array"} = 1; 174 174 175 generateBackendPrivateFunctions(); 175 176 generateFunctions($interface); 176 177 } … … 223 224 } 224 225 226 sub generateBackendPrivateFunctions 227 { 228 my $privateFunctions = << "EOF"; 229 static String formatWrongArgumentsCountMessage(unsigned expected, unsigned actual) 230 { 231 return String::format(\"Wrong number of parameters: %d (expected: %d)\", actual, expected); 232 } 233 234 static String formatWrongArgumentTypeMessage(unsigned position, const char* name, const char* expectedType) 235 { 236 return String::format(\"Failed to convert parameter %d (%s) to %s\", position, name, expectedType); 237 } 238 EOF 239 push(@backendMethodsImpl, $privateFunctions); 240 } 241 225 242 sub generateBackendFunction 226 243 { … … 234 251 my $arguments = join(", ", map($typeTransform{$_->type}->{"param"} . " " . $_->name, @argsFiltered)); 235 252 236 my $signature = " void ${functionName}(PassRefPtr<InspectorArray> args );";253 my $signature = " void ${functionName}(PassRefPtr<InspectorArray> args, String* exception);"; 237 254 !$backendMethods{${signature}} || die "Duplicate function was detected for signature '$signature'."; 238 255 $backendMethods{${signature}} = $functionName; 239 256 240 257 my @function; 241 # Skip parameter name if no arguments in the array. Just to avoid unused parameter warning. 242 push(@function, "void ${backendClassName}::${functionName}(PassRefPtr<InspectorArray>" . ( scalar(@argsFiltered) ? " args)" : ")")); 258 push(@function, "void ${backendClassName}::${functionName}(PassRefPtr<InspectorArray> args, String* exception)"); 243 259 push(@function, "{"); 244 260 my $i = 1; # zero element is the method name. 261 my $expectedParametersCount = scalar(@argsFiltered); 262 push(@function, " if (args->length() != $expectedParametersCount) {"); 263 push(@function, " *exception = formatWrongArgumentsCountMessage(args->length(), $expectedParametersCount);"); 264 push(@function, " ASSERT_NOT_REACHED();"); 265 push(@function, " return;"); 266 push(@function, " }"); 267 245 268 foreach my $parameter (@argsFiltered) { 246 push(@function, " " . $typeTransform{$parameter->type}->{"retVal"} . " " . $parameter->name . ";"); 247 push(@function, " if (!args->get(" . $i . ")->as" . $typeTransform{$parameter->type}->{"accessorSuffix"} . "(&" . $parameter->name . ")) {"); 269 my $parameterType = $parameter->type; 270 push(@function, " " . $typeTransform{$parameterType}->{"retVal"} . " " . $parameter->name . ";"); 271 push(@function, " if (!args->get(" . $i . ")->as" . $typeTransform{$parameterType}->{"accessorSuffix"} . "(&" . $parameter->name . ")) {"); 272 push(@function, " *exception = formatWrongArgumentTypeMessage($i, \"" . $parameter->name . "\", \"$parameterType\");"); 248 273 push(@function, " ASSERT_NOT_REACHED();"); 249 274 push(@function, " return;"); … … 265 290 push(@body, "void ${backendClassName}::dispatch(const String& message, String* exception)"); 266 291 push(@body, "{"); 267 push(@body, " typedef void (${backendClassName}::*CallHandler)(PassRefPtr<InspectorArray> args );");292 push(@body, " typedef void (${backendClassName}::*CallHandler)(PassRefPtr<InspectorArray> args, String* exception);"); 268 293 push(@body, " typedef HashMap<String, CallHandler> DispatchMap;"); 269 294 push(@body, " DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );"); … … 302 327 push(@body, " if (it == dispatchMap.end()) {"); 303 328 push(@body, " ASSERT_NOT_REACHED();"); 304 push(@body, " String::format(\"Error: Invalid method name. '%s' wasn't found.\", methodName.utf8().data());");329 push(@body, " *exception = String::format(\"Error: Invalid method name. '%s' wasn't found.\", methodName.utf8().data());"); 305 330 push(@body, " return;"); 306 331 push(@body, " }"); 307 332 push(@body, ""); 308 push(@body, " ((*this).*it->second)(messageArray );");333 push(@body, " ((*this).*it->second)(messageArray, exception);"); 309 334 push(@body, "}"); 310 335 return @body;
Note: See TracChangeset
for help on using the changeset viewer.