Bug 77289 - Web Inspector: CodeGeneratorInspector.py: reimplement generated array types
Summary: Web Inspector: CodeGeneratorInspector.py: reimplement generated array types
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: 72861
  Show dependency treegraph
 
Reported: 2012-01-28 14:33 PST by Peter Rybin
Modified: 2012-01-31 07:35 PST (History)
13 users (show)

See Also:


Attachments
Patch (23.25 KB, patch)
2012-01-28 14:48 PST, Peter Rybin
no flags Details | Formatted Diff | Diff
Original InspectorFrontend.h (167.63 KB, text/plain)
2012-01-28 15:04 PST, Peter Rybin
no flags Details
Original InspectorFrontend.cpp (41.84 KB, text/plain)
2012-01-28 15:05 PST, Peter Rybin
no flags Details
New InspectorFrontend.h (160.41 KB, text/plain)
2012-01-28 15:06 PST, Peter Rybin
no flags Details
New InspectorFrontend.cpp (42.30 KB, text/plain)
2012-01-28 15:06 PST, Peter Rybin
no flags Details
Patch (22.76 KB, patch)
2012-01-30 15:41 PST, Peter Rybin
vsevik: review+
Details | Formatted Diff | Diff
New InspectorFrontend.h (162.80 KB, text/plain)
2012-01-30 15:43 PST, Peter Rybin
no flags Details
New InspectorFrontend.cpp (42.36 KB, text/plain)
2012-01-30 15:44 PST, Peter Rybin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Rybin 2012-01-28 14:33:48 PST
Array type should be rendered more of a helper kind, rather than the current first class citizen kind (when it gets its name from parameter name and incapsulates more important item type).
Comment 1 Peter Rybin 2012-01-28 14:48:48 PST
Created attachment 124452 [details]
Patch
Comment 2 Peter Rybin 2012-01-28 15:04:47 PST
Created attachment 124453 [details]
Original InspectorFrontend.h
Comment 3 Peter Rybin 2012-01-28 15:05:17 PST
Created attachment 124454 [details]
Original InspectorFrontend.cpp
Comment 4 Peter Rybin 2012-01-28 15:06:04 PST
Created attachment 124455 [details]
New InspectorFrontend.h
Comment 5 Peter Rybin 2012-01-28 15:06:34 PST
Created attachment 124456 [details]
New InspectorFrontend.cpp
Comment 6 Andrey Kosyakov 2012-01-30 10:10:04 PST
Comment on attachment 124452 [details]
Patch

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

> Source/WebCore/inspector/CodeGeneratorInspector.py:1580
> +template<typename T>
> +class ArrayItemHelper {
> +public:
> +    typedef typename T::ItemTraits Traits;
> +};

Why not use T::ItemTraits directly?

> Source/WebCore/inspector/CodeGeneratorInspector.py:1583
> +class ArrayOf : public InspectorArray {

We don't normally use Of in container type names, e.g. it's map or vector, not mapOf or VectorOf.

> Source/WebCore/inspector/CodeGeneratorInspector.py:1609
> +class StructItemTraits {
> +public:

just struct?

> Source/WebCore/inspector/CodeGeneratorInspector.py:1610
> +    static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorObject> value)

why do we need to include type into method name, i.e. why not just push()?

> Source/WebCore/inspector/CodeGeneratorInspector.py:1618
> +    template<typename T>
> +    static void assertCorrectValue(InspectorValue* value) {
> +        T::assertCorrectValue(value);
> +    }

Why do we need this wrapper?

> Source/WebCore/inspector/CodeGeneratorInspector.py:1625
> +class ArrayItemHelper<String> {
> +public:
> +    class Traits {
> +    public:

just struct?

> Source/WebCore/inspector/CodeGeneratorInspector.py:1626
> +        static void pushRaw(InspectorArray* array, const String& value)

just push()?

> Source/WebCore/inspector/CodeGeneratorInspector.py:1637
> +class ArrayItemHelper<InspectorObject> {
> +public:
> +    class Traits {
> +    public:

ditto

> Source/WebCore/inspector/CodeGeneratorInspector.py:2115
> +        ArrayItemHelper<T>::Traits::template assertCorrectValue<T>(array->get(i).get());

Does this compile?
Comment 7 Peter Rybin 2012-01-30 15:11:36 PST
> > Source/WebCore/inspector/CodeGeneratorInspector.py:1580
> > +template<typename T>
> > +class ArrayItemHelper {
> > +public:
> > +    typedef typename T::ItemTraits Traits;
> > +};
> Why not use T::ItemTraits directly?

This template type is a point where C++ specialization takes part. This class is only a default implementation.
I added a comment.

> > Source/WebCore/inspector/CodeGeneratorInspector.py:1583
> > +class ArrayOf : public InspectorArray {

> We don't normally use Of in container type names, e.g. it's map or vector, not mapOf or VectorOf.

Get rid of "of"? It's cleaner? Thanks Sean! :)

> > Source/WebCore/inspector/CodeGeneratorInspector.py:1609
> > +class StructItemTraits {
> > +public:
> just struct?
Done

> > Source/WebCore/inspector/CodeGeneratorInspector.py:1610
> > +    static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorObject> value)
> why do we need to include type into method name, i.e. why not just push()?

There is a template/specialization machinery with "T"/"RefPtr<T>" method overloading here, plus the entire code is generated. I would prefer to at least dismiss internal method overloading in favor of keeping it cleaner. So I have 2 explicitly named methods. This is not user-facing.

> > Source/WebCore/inspector/CodeGeneratorInspector.py:1618
> > +    template<typename T>
> > +    static void assertCorrectValue(InspectorValue* value) {
> > +        T::assertCorrectValue(value);
> > +    }

> Why do we need this wrapper?
> > Source/WebCore/inspector/CodeGeneratorInspector.py:1625
> > +class ArrayItemHelper<String> {
> > +public:
> > +    class Traits {
> > +    public:
> just struct?

Done

> > Source/WebCore/inspector/CodeGeneratorInspector.py:1626
> > +        static void pushRaw(InspectorArray* array, const String& value)
> just push()?

See above.

> > Source/WebCore/inspector/CodeGeneratorInspector.py:1637
> > +class ArrayItemHelper<InspectorObject> {
> > +public:
> > +    class Traits {
> > +    public:
> ditto

Done

> > Source/WebCore/inspector/CodeGeneratorInspector.py:2115
> > +        ArrayItemHelper<T>::Traits::template assertCorrectValue<T>(array->get(i).get());
> Does this compile?
Yes. Why?
Comment 8 Peter Rybin 2012-01-30 15:41:20 PST
Created attachment 124614 [details]
Patch
Comment 9 Peter Rybin 2012-01-30 15:43:06 PST
Created attachment 124615 [details]
New InspectorFrontend.h
Comment 10 Peter Rybin 2012-01-30 15:44:06 PST
Created attachment 124616 [details]
New InspectorFrontend.cpp
Comment 11 Andrey Kosyakov 2012-01-31 06:11:14 PST
Comment on attachment 124614 [details]
Patch

LGTM
Comment 12 Vsevolod Vlasov 2012-01-31 06:59:38 PST
Comment on attachment 124614 [details]
Patch

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

> Source/WebCore/inspector/CodeGeneratorInspector.py:1712
> +

Extra line.

> Source/WebCore/inspector/CodeGeneratorInspector.py:2204
> +    for (unsigned i = 0; i < array->length(); i++) {

Please remove braces.
Comment 13 Vsevolod Vlasov 2012-01-31 07:35:30 PST
Committed r106360: <http://trac.webkit.org/changeset/106360>