Rev 11525: Initial work on supporting enum without typedef. in file:///home/jelmer/bzr.samba/4.0-nestedpidl/

Jelmer Vernooij jelmer at samba.org
Sun Feb 18 20:44:23 GMT 2007


At file:///home/jelmer/bzr.samba/4.0-nestedpidl/

------------------------------------------------------------
revno: 11525
revision-id: jelmer at samba.org-20070218204407-5l5ol1h0x0z4le4l
parent: svn-v2:21433 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 4.0-nestedpidl
timestamp: Sun 2007-02-18 21:44:07 +0100
message:
  Initial work on supporting enum without typedef.
modified:
  source/librpc/idl/echo.idl     svn-v2:6 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flibrpc%2fidl%2fecho.idl
  source/pidl/lib/Parse/Pidl/NDR.pm svn-v2:9460 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fNDR.pm
  source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm svn-v2:12463 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fSamba4%2fNDR%2fParser.pm
  source/pidl/lib/Parse/Pidl/Typelist.pm svn-v2:9460 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fTypelist.pm
=== modified file 'source/librpc/idl/echo.idl'
--- a/source/librpc/idl/echo.idl	2006-09-18 21:52:00 +0000
+++ b/source/librpc/idl/echo.idl	2007-02-18 20:44:07 +0000
@@ -88,10 +88,10 @@
 		[in] uint32 seconds
 		);
 
-	typedef enum {
+	enum echo_Enum1 {
 		ECHO_ENUM1 = 1,
 		ECHO_ENUM2 = 2
-	} echo_Enum1;
+	} ;
 
 	typedef [v1_enum] enum {
 		ECHO_ENUM1_32 = 1,
@@ -109,7 +109,7 @@
 	} echo_Enum3;
 
 	void echo_TestEnum(
-		[in,out,ref] echo_Enum1 *foo1,
+		[in,out,ref] enum echo_Enum1 *foo1,
 		[in,out,ref] echo_Enum2 *foo2,
 		[in,out,ref,switch_is(*foo1)] echo_Enum3 *foo3
 		);

=== modified file 'source/pidl/lib/Parse/Pidl/NDR.pm'
--- a/source/pidl/lib/Parse/Pidl/NDR.pm	2007-02-18 16:21:28 +0000
+++ b/source/pidl/lib/Parse/Pidl/NDR.pm	2007-02-18 20:44:07 +0000
@@ -345,7 +345,9 @@
 	    return 4;
 	}
 
-	my $dt = getType($e)->{DATA};
+	my $dt = getType($e);
+
+	if ($dt->{TYPE} eq "TYPEDEF") { $dt = $dt->{DATA}; }
 
 	if ($dt->{TYPE} eq "ENUM") {
 		return align_type(Parse::Pidl::Typelist::enum_type_fn($dt));
@@ -862,14 +864,16 @@
 	my $t = shift;
 	my $ti = getType($t);
 
-	if (not defined ($ti)) {
-		return undef;
-	} elsif ($ti->{DATA}->{TYPE} eq "ENUM") {
-		return Parse::Pidl::Typelist::enum_type_fn($ti->{DATA});
-	} elsif ($ti->{DATA}->{TYPE} eq "BITMAP") {
-		return Parse::Pidl::Typelist::enum_type_fn($ti->{DATA});
-	} elsif ($ti->{DATA}->{TYPE} eq "SCALAR") {
-		return $t;
+	return undef if (not defined ($ti));
+	
+	if ($ti->{TYPE} eq "TYPEDEF") { $ti = $ti->{DATA}; }
+
+	if ($ti->{TYPE} eq "ENUM") {
+		return Parse::Pidl::Typelist::enum_type_fn($ti);
+	} elsif ($ti->{TYPE} eq "BITMAP") {
+		return Parse::Pidl::Typelist::enum_type_fn($ti);
+	} elsif ($ti->{TYPE} eq "SCALAR") {
+		return $ti->{NAME};
 	}
 
 	return undef;

=== modified file 'source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm'
--- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm	2007-02-18 18:44:56 +0000
+++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm	2007-02-18 20:44:07 +0000
@@ -2582,19 +2582,22 @@
 		$needed->{"print_$t->{NAME}"} = 1;
 	}
 
-	if ($t->{DATA}->{TYPE} eq "STRUCT" or $t->{DATA}->{TYPE} eq "UNION") {
+	my $name = $t->{NAME};
+	if ($t->{TYPE} eq "TYPEDEF") { $t = $t->{DATA}; }
+
+	if ($t->{TYPE} eq "STRUCT" or $t->{TYPE} eq "UNION") {
 		if (has_property($t, "gensize")) {
-			$needed->{"ndr_size_$t->{NAME}"} = 1;
+			$needed->{"ndr_size_$name"} = 1;
 		}
 
-		for my $e (@{$t->{DATA}->{ELEMENTS}}) {
-			$e->{PARENT} = $t->{DATA};
+		for my $e (@{$t->{ELEMENTS}}) {
+			$e->{PARENT} = $t;
 			if (has_property($e, "compression")) { 
 				$needed->{"compression"} = 1;
 			}
-			NeededElement($e, "pull", $needed) if ($needed->{"pull_$t->{NAME}"});
-			NeededElement($e, "push", $needed) if ($needed->{"push_$t->{NAME}"});
-			NeededElement($e, "print", $needed) if ($needed->{"print_$t->{NAME}"});
+			NeededElement($e, "pull", $needed) if ($needed->{"pull_$name"});
+			NeededElement($e, "push", $needed) if ($needed->{"push_$name"});
+			NeededElement($e, "print", $needed) if ($needed->{"print_$name"});
 		}
 	}
 }

=== modified file 'source/pidl/lib/Parse/Pidl/Typelist.pm'
--- a/source/pidl/lib/Parse/Pidl/Typelist.pm	2007-02-18 18:44:56 +0000
+++ b/source/pidl/lib/Parse/Pidl/Typelist.pm	2007-02-18 20:44:07 +0000
@@ -96,7 +96,14 @@
 {
 	my $t = shift;
 	return undef if not hasType($t);
-	return $types{$t};
+	if (ref($t) eq "HASH") {
+		my $dt = $types{$t->{NAME}};
+		die ("type tag changed: expected $t->{TYPE}, got: $dt->{TYPE}") 
+			if ($dt->{TYPE} ne $t->{TYPE});
+		return $dt;
+	} else {
+		return $types{$t};
+	}
 }
 
 sub typeIs($$)
@@ -110,6 +117,9 @@
 sub hasType($)
 {
 	my $t = shift;
+	if (ref($t) eq "HASH") {
+		$t = $t->{NAME};
+	}
 	return 1 if defined($types{$t});
 	return 0;
 }



More information about the samba-cvs mailing list