Bug 80923 - Web Inspector: CodeGeneratorInspector.py: refactor copy-paste getter methods
Summary: Web Inspector: CodeGeneratorInspector.py: refactor copy-paste getter methods
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-12 18:35 PDT by Peter Rybin
Modified: 2012-03-13 09:04 PDT (History)
11 users (show)

See Also:


Attachments
Patch (10.83 KB, patch)
2012-03-12 18:47 PDT, Peter Rybin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Rybin 2012-03-12 18:35:24 PDT
Generator contains several very similar getter methods for InspectorBackendDispatcher.cpp file. Combine them into one method.
Comment 1 Peter Rybin 2012-03-12 18:47:35 PDT
Created attachment 131486 [details]
Patch
Comment 2 Ilya Tikhonovsky 2012-03-13 01:02:24 PDT
Comment on attachment 131486 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=131486&action=review

> Source/WebCore/inspector/CodeGeneratorInspector.py:2030
> +struct AsMethodBridges {
> +    static bool asInt(InspectorValue* value, int* output) { return value->asNumber(output); }
> +    static bool asString(InspectorValue* value, String* output) { return value->asString(output); }
> +    static bool asBoolean(InspectorValue* value, bool* output) { return value->asBoolean(output); }
> +    static bool asObject(InspectorValue* value, RefPtr<InspectorObject>* output) { return value->asObject(output); }
> +    static bool asArray(InspectorValue* value, RefPtr<InspectorArray>* output) { return value->asArray(output); }
> +};

Looks like you can use function overloading here or template with specialization.
As result it would be possible to drop as_method argument from getPropertyValueImpl.

> Source/WebCore/inspector/CodeGeneratorInspector.py:2036
> +int InspectorBackendDispatcherImpl::getInt(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
> +{
> +    return getPropertyValueImpl<int, int, int>(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asInt, "Number");
> +}
>  

inline it?

> Source/WebCore/inspector/CodeGeneratorInspector.py:2039
> +String InspectorBackendDispatcherImpl::getString(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
> +{
> +    return getPropertyValueImpl<String, String, String>(object, name, valueFound, protocolErrors, "", AsMethodBridges::asString, "String");

ditto
Comment 3 Yury Semikhatsky 2012-03-13 01:57:32 PDT
Comment on attachment 131486 [details]
Patch

Please address Ilya's comments before landing.
Comment 4 WebKit Review Bot 2012-03-13 09:04:02 PDT
Comment on attachment 131486 [details]
Patch

Clearing flags on attachment: 131486

Committed r110572: <http://trac.webkit.org/changeset/110572>
Comment 5 WebKit Review Bot 2012-03-13 09:04:07 PDT
All reviewed patches have been landed.  Closing bug.