Bug 133983 - [GTK] Add support for constants in GObject DOM bindings
Summary: [GTK] Add support for constants in GObject DOM bindings
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2014-06-17 08:16 PDT by Carlos Garcia Campos
Modified: 2014-06-26 00:46 PDT (History)
3 users (show)

See Also:


Attachments
Patch (6.36 KB, patch)
2014-06-17 08:19 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (14.54 KB, patch)
2014-06-20 01:57 PDT, Carlos Garcia Campos
mrobinson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2014-06-17 08:16:40 PDT
We don't expose any constant.
Comment 1 Carlos Garcia Campos 2014-06-17 08:19:17 PDT
Created attachment 233230 [details]
Patch

The support for constants in .symbols files and the docs is added in bug #93002, I'll update this patch once that bug is fixed.
Comment 2 Carlos Garcia Campos 2014-06-20 01:57:53 PDT
Created attachment 233415 [details]
Updated patch

Patch updated now that both bug #133726 and #93002 are fixed.
Comment 3 Martin Robinson 2014-06-25 09:29:01 PDT
Comment on attachment 233415 [details]
Updated patch

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

> Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm:896
> +    push(@hBody, $implContent);
> +
> +    if ($isStableClass) {
> +        push(@symbols, "GType ${lowerCaseIfaceName}_get_type(void)\n");
> +    }
> +
> +    if (@{$interface->constants}) {
> +        my @constants = @{$interface->constants};
> +        foreach my $constant (@constants) {
> +            my $conditionalString = $codeGenerator->GenerateConditionalString($constant);
> +            my $constantName = "WEBKIT_DOM_${clsCaps}_" . $constant->name;
> +            my $constantValue = $constant->value;
> +            my $isStableSymbol = grep {$_ eq $constantName} @stableSymbols;
> +            if ($isStableSymbol) {
> +                push(@symbols, "$constantName\n");
> +            }
> +
> +            my @constantHeader = ();
> +            push(@constantHeader, "#if ${conditionalString}") if $conditionalString;
> +            push(@constantHeader, "/**");
> +            push(@constantHeader, " * ${constantName}:");
> +            push(@constantHeader, " */");
> +            push(@constantHeader, "#define $constantName $constantValue");
> +            push(@constantHeader, "#endif /* ${conditionalString} */") if $conditionalString;
> +            push(@constantHeader, "\n");
> +
> +            if ($isStableSymbol or !$isStableClass) {
> +                push(@hBody, join("\n", @constantHeader));
> +            } else {
> +                push(@hBodyUnstable, join("\n", @constantHeader));
> +            }
> +        }
> +    }
> +

I think it makes sense to move this to a helper. We don't do that a lot, but these files need serious cleanup.
Comment 4 Carlos Garcia Campos 2014-06-26 00:46:12 PDT
Committed r170475: <http://trac.webkit.org/changeset/170475>