r12484: Initial work on supporting non-typedeffed types
authorJelmer Vernooij <jelmer@samba.org>
Sun, 25 Dec 2005 17:12:52 +0000 (17:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:47:44 +0000 (13:47 -0500)
(This used to be commit e7ac6c708dde7afb4c92a8cc4dea7a95b7054e3e)

source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
source4/pidl/lib/Parse/Pidl/NDR.pm
source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm
source4/pidl/lib/Parse/Pidl/Samba4/EJSHeader.pm
source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

index b400d1ade062f34832089627f4872ab81df0e38c..0b81536795f86561460b8235286576ce0ca9ebc2 100644 (file)
@@ -112,7 +112,7 @@ sub Interface($)
 {
        my($interface) = @_;
        Const($_,$interface->{NAME}) foreach (@{$interface->{CONSTS}});
-       Typedef($_,$interface->{NAME}) foreach (@{$interface->{TYPEDEFS}});
+       Typedef($_,$interface->{NAME}) foreach (@{$interface->{TYPES}});
        Function($_,$interface->{NAME}) foreach (@{$interface->{FUNCTIONS}});
 }
 
index e7b790d1e5599d5ab8d35acd3d8409fe39993042..0dd1ab4dd25e0e0d487878c8870ff1a93434a09d 100644 (file)
@@ -330,8 +330,9 @@ sub find_largest_alignment($)
 
 #####################################################################
 # align a type
-sub align_type
+sub align_type($)
 {
+       sub align_type($);
        my $e = shift;
 
        unless (hasType($e)) {
@@ -369,9 +370,9 @@ sub ParseElement($)
        };
 }
 
-sub ParseStruct($)
+sub ParseStruct($$)
 {
-       my $struct = shift;
+       my ($ndr,$struct) = @_;
        my @elements = ();
        my $surrounding = undef;
 
@@ -405,9 +406,9 @@ sub ParseStruct($)
        };
 }
 
-sub ParseUnion($)
+sub ParseUnion($$)
 {
-       my $e = shift;
+       my ($ndr,$e) = @_;
        my @elements = ();
        my $switch_type = has_property($e, "switch_type");
        unless (defined($switch_type)) { $switch_type = "uint32"; }
@@ -444,9 +445,9 @@ sub ParseUnion($)
        };
 }
 
-sub ParseEnum($)
+sub ParseEnum($$)
 {
-       my $e = shift;
+       my ($ndr,$e) = @_;
 
        return {
                TYPE => "ENUM",
@@ -457,9 +458,9 @@ sub ParseEnum($)
        };
 }
 
-sub ParseBitmap($)
+sub ParseBitmap($$)
 {
-       my $e = shift;
+       my ($ndr,$e) = @_;
 
        return {
                TYPE => "BITMAP",
@@ -470,26 +471,34 @@ sub ParseBitmap($)
        };
 }
 
-sub ParseTypedef($$)
+sub ParseType($$)
 {
-       my ($ndr,$d) = @_;
-       my $data;
+       my ($ndr, $d) = @_;
 
-       if ($d->{DATA}->{TYPE} eq "STRUCT" or $d->{DATA}->{TYPE} eq "UNION") {
-               CheckPointerTypes($d->{DATA}, $ndr->{PROPERTIES}->{pointer_default});
+       if ($d->{TYPE} eq "STRUCT" or $d->{TYPE} eq "UNION") {
+               CheckPointerTypes($d, $ndr->{PROPERTIES}->{pointer_default});
        }
 
-       if (defined($d->{PROPERTIES}) && !defined($d->{DATA}->{PROPERTIES})) {
-               $d->{DATA}->{PROPERTIES} = $d->{PROPERTIES};
-       }
-
-       $data = {
+       my $data = {
                STRUCT => \&ParseStruct,
                UNION => \&ParseUnion,
                ENUM => \&ParseEnum,
-               BITMAP => \&ParseBitmap
-       }->{$d->{DATA}->{TYPE}}->($d->{DATA});
+               BITMAP => \&ParseBitmap,
+               TYPEDEF => \&ParseTypedef,
+       }->{$d->{TYPE}}->($ndr, $d);
+
+       return $data;
+}
+
+sub ParseTypedef($$)
+{
+       my ($ndr,$d) = @_;
 
+       if (defined($d->{PROPERTIES}) && !defined($d->{DATA}->{PROPERTIES})) {
+               $d->{DATA}->{PROPERTIES} = $d->{PROPERTIES};
+       }
+
+       my $data = ParseType($ndr, $d->{DATA});
        $data->{ALIGN} = align_type($d->{NAME});
 
        return {
@@ -563,7 +572,7 @@ sub CheckPointerTypes($$)
 sub ParseInterface($)
 {
        my $idl = shift;
-       my @typedefs = ();
+       my @types = ();
        my @consts = ();
        my @functions = ();
        my @endpoints;
@@ -582,20 +591,14 @@ sub ParseInterface($)
        }
 
        foreach my $d (@{$idl->{DATA}}) {
-               if ($d->{TYPE} eq "TYPEDEF") {
-                       push (@typedefs, ParseTypedef($idl, $d));
-               }
-
                if ($d->{TYPE} eq "DECLARE") {
                        push (@declares, $d);
-               }
-
-               if ($d->{TYPE} eq "FUNCTION") {
+               } elsif ($d->{TYPE} eq "FUNCTION") {
                        push (@functions, ParseFunction($idl, $d, \$opnum));
-               }
-
-               if ($d->{TYPE} eq "CONST") {
+               } elsif ($d->{TYPE} eq "CONST") {
                        push (@consts, ParseConst($idl, $d));
+               } else {
+                       push (@types, ParseType($idl, $d));
                }
        }
 
@@ -620,7 +623,7 @@ sub ParseInterface($)
                PROPERTIES => $idl->{PROPERTIES},
                FUNCTIONS => \@functions,
                CONSTS => \@consts,
-               TYPEDEFS => \@typedefs,
+               TYPES => \@types,
                DECLARES => \@declares,
                ENDPOINTS => \@endpoints
        };
index b49e64c337231f34d4224e9fc47cc572b5ab23be..fb02120a42e5ab62c82885d13dcd267078d6c09c 100644 (file)
@@ -183,7 +183,7 @@ sub ParseInterface($)
 
        pidl "";
 
-       foreach (@{$if->{TYPEDEFS}}) {
+       foreach (@{$if->{TYPES}}) {
                ParseStruct($if, $_->{DATA}, $_->{NAME}) if ($_->{DATA}->{TYPE} eq "STRUCT");
                ParseEnum($if, $_->{DATA}, $_->{NAME}) if ($_->{DATA}->{TYPE} eq "ENUM");
                ParseBitmap($if, $_->{DATA}, $_->{NAME}) if ($_->{DATA}->{TYPE} eq "BITMAP");
index 9ef8f09dc4efb0d2f79b3037c9a1a345023ccae0..c12f7554e9ad312fe31ad7ad2e82e02b10ced294 100644 (file)
@@ -566,7 +566,7 @@ sub ParseInterface($)
 
        # Structures first 
        pidl "/* $if->{NAME} structures */";
-       foreach (@{$if->{TYPEDEFS}}) {
+       foreach (@{$if->{TYPES}}) {
                ParseStruct($if, $_->{DATA}, $_->{NAME}) if ($_->{DATA}->{TYPE} eq "STRUCT");
                ParseUnion($if, $_->{DATA}, $_->{NAME}) if ($_->{DATA}->{TYPE} eq "UNION");
        }
index 3f7e8ae13447a75a8d989dda19df3d34fc0b2f2d..d1f1032714fb6bdeaee51dcc635c5f2c36ae9460 100644 (file)
@@ -350,7 +350,7 @@ sub LoadTypes($)
        foreach my $if (@{$ndr}) {
                next unless ($if->{TYPE} eq "INTERFACE");
 
-               foreach my $td (@{$if->{TYPEDEFS}}) {
+               foreach my $td (@{$if->{TYPES}}) {
                        my $decl = uc("$if->{NAME}_$td->{NAME}");
 
                        my $init = sub {
index f5aea73d12f7e3e58946d191fc5def0e93183a95..8c576c44f93f9fde656016cede6491bc71c91ecd 100644 (file)
@@ -706,7 +706,7 @@ sub EjsInterface($$)
 
        %constants = ();
 
-       foreach my $d (@{$interface->{TYPEDEFS}}) {
+       foreach my $d (@{$interface->{TYPES}}) {
                ($needed->{"push_$d->{NAME}"}) && EjsTypedefPush($d);
                ($needed->{"pull_$d->{NAME}"}) && EjsTypedefPull($d);
        }
@@ -831,7 +831,7 @@ sub NeededInterface($$)
        foreach my $d (@{$interface->{FUNCTIONS}}) {
            NeededFunction($d, $needed);
        }
-       foreach my $d (reverse @{$interface->{TYPEDEFS}}) {
+       foreach my $d (reverse @{$interface->{TYPES}}) {
            NeededTypedef($d, $needed);
        }
 }
index a204ee7a56db4208a1bf0777c4b5b360b9beafd7..eae7ddce5f9a1d14141e9ef2d16c0d81ac25293b 100644 (file)
@@ -54,9 +54,7 @@ sub HeaderInterface($)
 
        pidl "\n";
 
-       foreach my $d (@{$interface->{TYPEDEFS}}) {
-               HeaderTypedefProto($d);
-       }
+       HeaderTypedefProto($_) foreach (@{$interface->{TYPES}});
 
        pidl "\n";
        pidl "#endif /* _HEADER_EJS_$interface->{NAME} */\n";
index 2242323747192653dd4d5591e933a34debe7a9b9..bb9d32487a4105bd12643a5ec0cba3919c23451c 100644 (file)
@@ -2313,7 +2313,7 @@ sub ParseInterface($$)
        HeaderInterface($interface);
 
        # Typedefs
-       foreach my $d (@{$interface->{TYPEDEFS}}) {
+       foreach my $d (@{$interface->{TYPES}}) {
                ($needed->{"push_$d->{NAME}"}) && ParseTypedefPush($d);
                ($needed->{"pull_$d->{NAME}"}) && ParseTypedefPull($d);
                ($needed->{"print_$d->{NAME}"}) && ParseTypedefPrint($d);
@@ -2456,7 +2456,7 @@ sub NeededInterface($$)
 {
        my ($interface,$needed) = @_;
        NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}});
-       NeededTypedef($_, $needed) foreach (reverse @{$interface->{TYPEDEFS}});
+       NeededTypedef($_, $needed) foreach (reverse @{$interface->{TYPES}});
 }
 
 1;