-sub generateArgumentGetters
-{
- my $type = shift;
- my $declarations = shift;
- my $json = $typeTransform{$type}{"JSONType"};
- my $variable = $typeTransform{$type}{"variable"};
- my $return = $typeTransform{$type}{"return"} ? $typeTransform{$type}{"return"} : $typeTransform{$type}{"param"};
-
- my $typeString = $type;
- $typeString =~ s/\b(\w)/\U$1/g;
- $typeString =~ s/ //g;
-
- push(@{$declarations}, " static $return get$typeString(InspectorObject* object, const String& name, InspectorArray* protocolErrors);");
- my $getterBody = << "EOF";
-
-$return InspectorBackendDispatcher::get$typeString(InspectorObject* object, const String& name, InspectorArray* protocolErrors)
-{
- ASSERT(object);
- ASSERT(protocolErrors);
-
- $variable value;
- InspectorObject::const_iterator end = object->end();
- InspectorObject::const_iterator valueIterator = object->find(name);
-
- if (valueIterator == end)
- protocolErrors->pushString(String::format("Protocol Error: Argument '\%s' with type '$json' was not found.", name.utf8().data()));
- else {
- if (!valueIterator->second->as$json(&value))
- protocolErrors->pushString(String::format("Protocol Error: Argument '\%s' has wrong type. It should be '$json'.", name.utf8().data()));
- }
- return value;
-}
-EOF
-
- return split("\n", $getterBody);
-}