svn commit: samba r10734 - in
branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3: .
jelmer at samba.org
jelmer at samba.org
Wed Oct 5 17:13:30 GMT 2005
Author: jelmer
Date: 2005-10-05 17:13:29 +0000 (Wed, 05 Oct 2005)
New Revision: 10734
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10734
Log:
Generate ptr, size, offset, and length elements in unions just once.
Modified:
branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Header.pm
branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Parser.pm
Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Header.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Header.pm 2005-10-05 15:30:52 UTC (rev 10733)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Header.pm 2005-10-05 17:13:29 UTC (rev 10734)
@@ -15,7 +15,10 @@
$VERSION = '0.01';
my $res = "";
-sub pidl($) { my $x = shift; $res .= "$x\n"; }
+my $tabs = "";
+sub indent() { $tabs.="\t"; }
+sub deindent() { $tabs = substr($tabs, 1); }
+sub pidl($) { $res .= $tabs.(shift)."\n"; }
sub fatal($$) { my ($e,$s) = @_; die("$e->{FILE}:$e->{LINE}: $s\n"); }
sub warning($$) { my ($e,$s) = @_; warn("$e->{FILE}:$e->{LINE}: $s\n"); }
@@ -101,7 +104,11 @@
{
my ($if,$u,$n) = @_;
- my $extra = {"switch_value" => 1};
+ my $extra = {};
+
+ unless (has_property($u, "nodiscriminant")) {
+ $extra->{switch_value} = 1;
+ }
foreach my $e (@{$u->{ELEMENTS}}) {
foreach my $l (@{$e->{LEVELS}}) {
@@ -121,10 +128,17 @@
}
pidl "typedef struct $if->{NAME}_$n\_ctr {";
- pidl "\tuint32 $_;" foreach (keys %$extra);
- pidl "\tunion {";
- ParseElement($_) foreach (@{$u->{ELEMENTS}});
- pidl "\t} u;";
+ indent;
+ pidl "uint32 $_;" foreach (keys %$extra);
+ pidl "union {";
+ indent;
+ foreach (@{$u->{ELEMENTS}}) {
+ next if ($_->{TYPE} eq "EMPTY");
+ pidl "\t" . DeclShort($_) . ";";
+ }
+ deindent;
+ pidl "} u;";
+ deindent;
pidl "} ".uc("$if->{NAME}_$n\_ctr") .";";
pidl "";
}
@@ -185,6 +199,7 @@
my($ndr,$filename) = @_;
$res = "";
+ $tabs = "";
pidl "/*";
pidl " * Unix SMB/CIFS implementation.";
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Parser.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Parser.pm 2005-10-05 15:30:52 UTC (rev 10733)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/Parser.pm 2005-10-05 17:13:29 UTC (rev 10734)
@@ -75,6 +75,7 @@
if ($l->{IS_ZERO_TERMINATED}) {
fatal($e, "[string] attribute not supported for Samba3 yet");
+
#FIXME
}
@@ -123,12 +124,6 @@
{
my ($e,$l,$nl,$env,$varname,$what) = @_;
- if ($what == PRIMITIVES) {
- pidl "if (!prs_uint32(\"level\", ps, depth, &" . ParseExpr("level_$e->{NAME}", $env) . "))";
- pidl "\treturn False;";
- pidl "";
- }
-
ParseElementLevel($e,$nl,$env,$varname,$what);
}
@@ -353,6 +348,14 @@
pidl "\treturn False;";
pidl "";
+ if (has_property($u, "nodiscriminant")) {
+ pidl "if (!prs_uint32(\"switch_value\", ps, depth, &v->switch_value))";
+ pidl "\treturn False;";
+ pidl "";
+ }
+
+ # Maybe check here that level and v->switch_value are equal?
+
pidl "switch (level) {";
indent;
More information about the samba-cvs
mailing list