pidl: add support for [string] on fixed size arrays.
[ira/wip.git] / pidl / lib / Parse / Pidl / Samba4.pm
index d42e01cdb0424cc51d413fcfa496a934ae534d4e..20c518dcebf66beddd2a319a491819ca7c412445 100644 (file)
@@ -7,12 +7,12 @@ package Parse::Pidl::Samba4;
 
 require Exporter;
 @ISA = qw(Exporter);
-@EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong);
+@EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong ArrayDynamicallyAllocated);
 
 use Parse::Pidl::Util qw(has_property is_constant);
 use Parse::Pidl::NDR qw(GetNextLevel);
 use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
-use Parse::Pidl qw(fatal);
+use Parse::Pidl qw(fatal error);
 use strict;
 
 use vars qw($VERSION);
@@ -36,6 +36,14 @@ sub choose_header($$)
        return "#include <$out>";
 }
 
+sub ArrayDynamicallyAllocated($$)
+{
+       my ($e, $l) = @_;
+       die("Not an array") unless ($l->{TYPE} eq "ARRAY");
+       return 0 if ($l->{IS_FIXED} and not has_property($e, "charset"));
+       return 1;
+}
+
 sub NumStars($;$)
 {
        my ($e, $d) = @_;
@@ -57,11 +65,11 @@ sub NumStars($;$)
 
        foreach my $l (@{$e->{LEVELS}}) {
                next unless ($l->{TYPE} eq "ARRAY");
-               next if ($l->{IS_FIXED}) and not has_property($e, "charset");
+               next unless (ArrayDynamicallyAllocated($e, $l));
                $n++;
        }
 
-       fatal($e->{ORIGINAL}, "Too few pointers $n < $d") if ($n < $d);
+       error($e->{ORIGINAL}, "Too few pointers $n < $d") if ($n < $d);
 
        $n -= $d;
 
@@ -87,7 +95,7 @@ sub ArrayBrackets($)
 
        foreach my $l (@{$e->{LEVELS}}) {
                next unless ($l->{TYPE} eq "ARRAY");
-               next unless ($l->{IS_FIXED}) and not has_property($e, "charset");
+               next if ArrayDynamicallyAllocated($e, $l);
                $res .= "[$l->{SIZE_IS}]";
        }