Changeset 58510 in webkit


Ignore:
Timestamp:
Apr 29, 2010 6:49:52 AM (14 years ago)
Author:
xan@webkit.org
Message:

2010-04-29 Xan Lopez <xlopez@igalia.com>

Reviewed by Gustavo Noronha.

[GTK] GObject DOM bindings
https://bugs.webkit.org/show_bug.cgi?id=33590

Do not generate unneeded boilerplate in {get,set}_property methods
when there are no properties to generate code for. This gets rid
of lots of compiler warnings.

  • bindings/scripts/CodeGeneratorGObject.pm:
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58507 r58510  
     12010-04-29  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        [GTK] GObject DOM bindings
     6        https://bugs.webkit.org/show_bug.cgi?id=33590
     7
     8        Do not generate unneeded boilerplate in {get,set}_property methods
     9        when there are no properties to generate code for. This gets rid
     10        of lots of compiler warnings.
     11
     12        * bindings/scripts/CodeGeneratorGObject.pm:
     13
    1142010-04-29  Simon Hausmann  <simon.hausmann@nokia.com>
    215
  • trunk/WebCore/bindings/scripts/CodeGeneratorGObject.pm

    r58345 r58510  
    272272}
    273273
     274sub GetReadableProperties {
     275    my $properties = shift;
     276
     277    my @result = ();
     278
     279    foreach my $property (@{$properties}) {
     280        if (!SkipAttribute($property)) {
     281            push(@result, $property);
     282        }
     283    }
     284
     285    return @result;
     286}
     287
     288sub GetWriteableProperties {
     289    my $properties = shift;
     290    my @result = ();
     291
     292    foreach my $property (@{$properties}) {
     293        my $writeable = $property->type !~ /^readonly/;
     294        my $gtype = GetGValueTypeName($property->signature->type);
     295        my $hasGtypeSignature = ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" ||
     296                                 $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" ||
     297                                 $gtype eq "uint" || $gtype eq "ushort" || $gtype eq "uchar" ||
     298                                 $gtype eq "char" || $gtype eq "string");
     299        if ($writeable && $hasGtypeSignature) {
     300            push(@result, $property);
     301        }
     302    }
     303
     304    return @result;
     305}
     306
    274307sub GenerateProperties {
    275308    my ($object, $interfaceName, $dataNode) = @_;
     
    292325    my @txtGetProps = ();
    293326
     327    my @readableProperties = GetReadableProperties($dataNode->attributes);
     328
    294329    my $privFunction = GetCoreObject($interfaceName, "coreSelf", "self");
    295330
     
    297332static void ${lowerCaseIfaceName}_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
    298333{
     334EOF
     335    push(@txtGetProps, $txtGetProp);
     336    if (scalar @readableProperties > 0) {
     337        $txtGetProp = << "EOF";
    299338    ${className}* self = WEBKIT_DOM_${clsCaps}(object);
    300339    $privFunction
    301 
     340EOF
     341    push(@txtGetProps, $txtGetProp);
     342    }
     343
     344    $txtGetProp = << "EOF";
    302345    switch (prop_id) {
    303346EOF
    304347    push(@txtGetProps, $txtGetProp);
     348
     349    my @writeableProperties = GetWriteableProperties(\@readableProperties);
    305350
    306351    my $txtSetProps = << "EOF";
    307352static void ${lowerCaseIfaceName}_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
    308353{
     354EOF
     355    push(@txtSetProps, $txtSetProps);
     356
     357    if (scalar @writeableProperties > 0) {
     358        $txtSetProps = << "EOF";
    309359    ${className} *self = WEBKIT_DOM_${clsCaps}(object);
    310360    $privFunction
    311 
     361EOF
     362        push(@txtSetProps, $txtSetProps);
     363    }
     364
     365    $txtSetProps = << "EOF";
    312366    switch (prop_id) {
    313367EOF
     
    317371    # each one of them.
    318372  SKIPENUM:
    319     foreach my $attribute (@{$dataNode->attributes}) {
    320         if (SkipAttribute($attribute)) {
    321             next SKIPENUM;
    322         }
    323 
     373    foreach my $attribute (@readableProperties) {
    324374        my $camelPropName = $attribute->signature->name;
    325375        my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName);
     
    379429        }
    380430
    381         if ($writeable && ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" ||
    382                            $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" ||
    383                            $gtype eq "uint" || $gtype eq "ushort" || $gtype eq "uchar" ||
    384                            $gtype eq "char" || $gtype eq "string")) {
    385 
     431        if (grep {$_ eq $attribute} @writeableProperties) {
    386432            push(@txtSetProps, "   case ${propEnum}:\n    {\n");
    387433            push(@txtSetProps, "        WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
Note: See TracChangeset for help on using the changeset viewer.