TODO CONTAINS_NON_FIXED
[metze/samba/wip.git] / pidl / lib / Parse / Pidl / NDR.pm
index d65cbe7037268e1bde919034bebdba0038aea99a..c3f6796f9aa0a5ee0994e32fe7d70c0f9d1ed4c7 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);
@@ -364,6 +364,7 @@ sub GetElementLevelTable($$$)
                DATA_TYPE => $e->{TYPE},
                IS_DEFERRED => $is_deferred,
                CONTAINS_DEFERRED => can_contain_deferred($e->{TYPE}),
+               CONTAINS_NON_FIXED => can_contain_non_fixed($e->{TYPE}),
                IS_SURROUNDING => 0 #FIXME
        });
 
@@ -414,6 +415,28 @@ sub can_contain_deferred($)
        return 0;
 }
 
+sub can_contain_non_fixed($)
+{
+       sub can_contain_non_fixed($);
+       my ($type) = @_;
+
+       return 1 if can_contain_deferred($type);
+
+       $type = getType($type);
+
+       return 0 if (is_fixed_size_scalar($type));
+
+       return can_contain_non_fixed($type->{DATA}) if ($type->{TYPE} eq "TYPEDEF");
+
+       return 0 unless defined($type->{ELEMENTS});
+
+       foreach (@{$type->{ELEMENTS}}) {
+               return 1 if ($_->{POINTERS});
+               return 1 if (can_contain_non_fixed ($_->{TYPE}));
+       }
+
+       return 0;
+}
 sub pointer_type($)
 {
        my $e = shift;
@@ -805,6 +828,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) = @_;
@@ -891,7 +933,8 @@ sub ParseInterface($)
                FUNCTIONS => \@functions,
                CONSTS => \@consts,
                TYPES => \@types,
-               ENDPOINTS => \@endpoints
+               ENDPOINTS => \@endpoints,
+               ORIGINAL => $idl
        };
 }
 
@@ -1084,6 +1127,7 @@ my %property_list = (
        "nopython"              => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
        "todo"                  => ["FUNCTION"],
        "skip"                  => ["ELEMENT"],
+       "skip_noinit"           => ["ELEMENT"],
 
        # union
        "switch_is"             => ["ELEMENT"],