pyldb: avoid segfault when adding an element with no name
[kai/samba-autobuild/.git] / pidl / lib / Parse / Pidl / NDR.pm
index db776ae3ef371751806d833b84e4407a74786cc1..003156e3a11ef7efce7195afe0cb4e12c4ba183d 100644 (file)
@@ -35,7 +35,7 @@ use vars qw($VERSION);
 $VERSION = '0.01';
 @ISA = qw(Exporter);
 @EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe ContainsString);
-@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array);
+@EXPORT_OK = qw(GetElementLevelTable ParseElement ReturnTypeElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array);
 
 use strict;
 use Parse::Pidl qw(warning fatal);
@@ -171,6 +171,7 @@ sub GetElementLevelTable($$$)
                my $is_string = 0;
                my $is_fixed = 0;
                my $is_inline = 0;
+               my $is_to_null = 0;
 
                if ($d eq "*") {
                        $is_conformant = 1;
@@ -208,6 +209,10 @@ sub GetElementLevelTable($$$)
                        delete($e->{PROPERTIES}->{string});
                }
 
+               if (has_property($e, "to_null")) {
+                       $is_to_null = 1;
+               }
+
                push (@$order, {
                        TYPE => "ARRAY",
                        SIZE_IS => $size,
@@ -218,7 +223,8 @@ sub GetElementLevelTable($$$)
                        IS_VARYING => $is_varying,
                        IS_CONFORMANT => $is_conformant,
                        IS_FIXED => $is_fixed,
-                       IS_INLINE => $is_inline
+                       IS_INLINE => $is_inline,
+                       IS_TO_NULL => $is_to_null
                });
        }
 
@@ -799,6 +805,25 @@ sub ParseFunction($$$$)
                };
 }
 
+sub ReturnTypeElement($)
+{
+       my ($fn) = @_;
+
+       return undef unless defined($fn->{RETURN_TYPE});
+
+       my $e = {
+               "NAME" => "result",
+               "TYPE" => $fn->{RETURN_TYPE},
+               "PROPERTIES" => undef,
+               "POINTERS" => 0,
+               "ARRAY_LEN" => [],
+               "FILE" => $fn->{FILE},
+               "LINE" => $fn->{LINE},
+       };
+
+       return ParseElement($e, 0, 0);
+}
+
 sub CheckPointerTypes($$)
 {
        my ($s,$default) = @_;
@@ -885,7 +910,8 @@ sub ParseInterface($)
                FUNCTIONS => \@functions,
                CONSTS => \@consts,
                TYPES => \@types,
-               ENDPOINTS => \@endpoints
+               ENDPOINTS => \@endpoints,
+               ORIGINAL => $idl
        };
 }
 
@@ -946,9 +972,19 @@ sub ContainsString($)
        if (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
                return 1;
        }
+       if (exists($e->{LEVELS}) and $e->{LEVELS}->[0]->{TYPE} eq "ARRAY" and
+               ($e->{LEVELS}->[0]->{IS_FIXED} or $e->{LEVELS}->[0]->{IS_INLINE}) and
+               has_property($e, "charset"))
+       {
+               return 1;
+       }
+
        foreach my $l (@{$e->{LEVELS}}) {
                return 1 if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED});
        }
+       if (property_matches($e, "charset", ".*DOS.*")) {
+               return 1;
+       }
 
        return 0;
 }
@@ -1067,6 +1103,8 @@ my %property_list = (
        "noprint"               => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT", "PIPE"],
        "nopython"              => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
        "todo"                  => ["FUNCTION"],
+       "skip"                  => ["ELEMENT"],
+       "skip_noinit"           => ["ELEMENT"],
 
        # union
        "switch_is"             => ["ELEMENT"],
@@ -1102,6 +1140,7 @@ my %property_list = (
        "noheader"              => ["ELEMENT"],
        "charset"               => ["ELEMENT"],
        "length_is"             => ["ELEMENT"],
+       "to_null"               => ["ELEMENT"],
 );
 
 #####################################################################