pidl: don't warn for compatible scalar types in unions
authorAndrew Tridgell <tridge@samba.org>
Mon, 12 Oct 2009 23:03:27 +0000 (10:03 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 12 Oct 2009 23:03:27 +0000 (10:03 +1100)
When we have an enum that is used as a union discriminator, what
matters is that the scalar mappings are the same, not if the types are
the same (otherwise we get warnings about uint1632).

Thanks to gd for noticing this.

pidl/lib/Parse/Pidl/NDR.pm

index 249b778389dce45866ea6a4ab4bb1b14c69d723a..4e680b336f1bdf4646c31ca46f6883bdec4919a7 100644 (file)
@@ -39,7 +39,7 @@ $VERSION = '0.01';
 
 use strict;
 use Parse::Pidl qw(warning fatal);
 
 use strict;
 use Parse::Pidl qw(warning fatal);
-use Parse::Pidl::Typelist qw(hasType getType expandAlias);
+use Parse::Pidl::Typelist qw(hasType getType expandAlias mapScalarType);
 use Parse::Pidl::Util qw(has_property property_matches);
 
 # Alignment of the built-in scalar types
 use Parse::Pidl::Util qw(has_property property_matches);
 
 # Alignment of the built-in scalar types
@@ -1010,13 +1010,13 @@ sub ValidElement($)
                        my $discriminator_type = has_property($type->{DATA}, "switch_type");
                        $discriminator_type = "uint32" unless defined ($discriminator_type);
 
                        my $discriminator_type = has_property($type->{DATA}, "switch_type");
                        $discriminator_type = "uint32" unless defined ($discriminator_type);
 
-                       my $t1 = mapToScalar($discriminator_type);
+                       my $t1 = mapScalarType(mapToScalar($discriminator_type));
 
                        if (not defined($t1)) {
                                fatal($e, el_name($e) . ": unable to map discriminator type '$discriminator_type' to scalar");
                        }
 
 
                        if (not defined($t1)) {
                                fatal($e, el_name($e) . ": unable to map discriminator type '$discriminator_type' to scalar");
                        }
 
-                       my $t2 = mapToScalar($e2->{TYPE});
+                       my $t2 = mapScalarType(mapToScalar($e2->{TYPE}));
                        if (not defined($t2)) {
                                fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar");
                        }
                        if (not defined($t2)) {
                                fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar");
                        }