Rev 11543: Remove name argument,
more refactoring. in file:///home/jelmer/bzr.samba/SAMBA_4_0/
Jelmer Vernooij
jelmer at samba.org
Tue Feb 20 01:24:51 GMT 2007
At file:///home/jelmer/bzr.samba/SAMBA_4_0/
------------------------------------------------------------
revno: 11543
revision-id: jelmer at samba.org-20070220012443-ky7aj0q1ra0t1ivl
parent: svn-v2:21458 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Tue 2007-02-20 02:24:43 +0100
message:
Remove name argument, more refactoring.
modified:
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/tests/samba-ndr.pl svn-v2:20637 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2ftests%2fsamba%2dndr.pl
=== modified file 'source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm'
--- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2007-02-19 23:11:01 +0000
+++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2007-02-20 01:24:43 +0000
@@ -1236,9 +1236,9 @@
pidl "}";
}
-sub ParseStructPushPrimitives($$$$)
+sub ParseStructPushPrimitives($$$)
{
- my ($struct, $name, $varname, $env) = @_;
+ my ($struct, $varname, $env) = @_;
# see if the structure contains a conformant array. If it
# does, then it must be the last element of the structure, and
@@ -1279,9 +1279,9 @@
ParseElementPush($_, "ndr", $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
}
-sub ParseStructPushDeferred($$$$)
+sub ParseStructPushDeferred($$$)
{
- my ($struct, $name, $varname, $env) = @_;
+ my ($struct, $varname, $env) = @_;
if (defined($struct->{PROPERTIES}{relative_base})) {
# retrieve the current offset as base for relative pointers
# based on the toplevel struct/union
@@ -1292,9 +1292,9 @@
#####################################################################
# parse a struct
-sub ParseStructPush($$$)
+sub ParseStructPush($$)
{
- my ($struct, $name, $varname) = @_;
+ my ($struct, $varname) = @_;
return unless defined($struct->{ELEMENTS});
@@ -1308,13 +1308,13 @@
pidl "if (ndr_flags & NDR_SCALARS) {";
indent;
- ParseStructPushPrimitives($struct, $name, $varname, $env);
+ ParseStructPushPrimitives($struct, $varname, $env);
deindent;
pidl "}";
pidl "if (ndr_flags & NDR_BUFFERS) {";
indent;
- ParseStructPushDeferred($struct, $name, $varname, $env);
+ ParseStructPushDeferred($struct, $varname, $env);
deindent;
pidl "}";
@@ -1323,9 +1323,9 @@
#####################################################################
# generate a push function for an enum
-sub ParseEnumPush($$$)
+sub ParseEnumPush($$)
{
- my($enum,$name,$varname) = @_;
+ my($enum,$varname) = @_;
my($type_fn) = $enum->{BASE_TYPE};
start_flags($enum);
@@ -1335,9 +1335,9 @@
#####################################################################
# generate a pull function for an enum
-sub ParseEnumPull($$$)
+sub ParseEnumPull($$)
{
- my($enum,$name,$varname) = @_;
+ my($enum,$varname) = @_;
my($type_fn) = $enum->{BASE_TYPE};
my($type_v_decl) = mapTypeName($type_fn);
@@ -1396,9 +1396,9 @@
#####################################################################
# generate a push function for a bitmap
-sub ParseBitmapPush($$$)
+sub ParseBitmapPush($$)
{
- my($bitmap,$name,$varname) = @_;
+ my($bitmap,$varname) = @_;
my($type_fn) = $bitmap->{BASE_TYPE};
start_flags($bitmap);
@@ -1410,9 +1410,9 @@
#####################################################################
# generate a pull function for an bitmap
-sub ParseBitmapPull($$$)
+sub ParseBitmapPull($$)
{
- my($bitmap,$name,$varname) = @_;
+ my($bitmap,$varname) = @_;
my $type_fn = $bitmap->{BASE_TYPE};
my($type_decl) = mapTypeName($bitmap->{BASE_TYPE});
@@ -1559,9 +1559,9 @@
}
}
-sub ParseStructPullPrimitives($$$$)
+sub ParseStructPullPrimitives($$$)
{
- my($struct,$name,$varname,$env) = @_;
+ my($struct,$varname,$env) = @_;
if (defined $struct->{SURROUNDING_ELEMENT}) {
pidl "NDR_CHECK(ndr_pull_array_size(ndr, &$varname->$struct->{SURROUNDING_ELEMENT}->{NAME}));";
@@ -1580,9 +1580,9 @@
add_deferred();
}
-sub ParseStructPullDeferred($$$$)
+sub ParseStructPullDeferred($$$)
{
- my ($struct,$name,$varname,$env) = @_;
+ my ($struct,$varname,$env) = @_;
if (defined($struct->{PROPERTIES}{relative_base})) {
# retrieve the current offset as base for relative pointers
@@ -1598,9 +1598,9 @@
#####################################################################
# parse a struct - pull side
-sub ParseStructPull($$$)
+sub ParseStructPull($$)
{
- my($struct,$name,$varname) = @_;
+ my($struct,$varname) = @_;
return unless defined $struct->{ELEMENTS};
@@ -1617,12 +1617,12 @@
pidl "if (ndr_flags & NDR_SCALARS) {";
indent;
- ParseStructPullPrimitives($struct,$name,$varname,$env);
+ ParseStructPullPrimitives($struct,$varname,$env);
deindent;
pidl "}";
pidl "if (ndr_flags & NDR_BUFFERS) {";
indent;
- ParseStructPullDeferred($struct,$name,$varname,$env);
+ ParseStructPullDeferred($struct,$varname,$env);
deindent;
pidl "}";
@@ -1677,21 +1677,13 @@
pidl "return ndr_size_union($varname, flags, level, (ndr_push_flags_fn_t)ndr_push_$name);";
}
-#####################################################################
-# parse a union - push side
-sub ParseUnionPush($$$)
+sub ParseUnionPushPrimitives($$)
{
- my ($e,$name,$varname) = @_;
+ my ($e, $varname) = @_;
+
my $have_default = 0;
- pidl "int level;";
-
- start_flags($e);
-
- pidl "level = ndr_push_get_switch_value(ndr, $varname);";
-
- pidl "if (ndr_flags & NDR_SCALARS) {";
- indent;
+ pidl "int level = ndr_push_get_switch_value(ndr, $varname);";
if (defined($e->{SWITCH_TYPE})) {
pidl "NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}(ndr, NDR_SCALARS, level));";
@@ -1726,10 +1718,15 @@
}
deindent;
pidl "}";
- deindent;
- pidl "}";
- pidl "if (ndr_flags & NDR_BUFFERS) {";
- indent;
+}
+
+sub ParseUnionPushDeferred($$)
+{
+ my ($e, $varname) = @_;
+
+ my $have_default = 0;
+
+ pidl "int level = ndr_push_get_switch_value(ndr, $varname);";
if (defined($e->{PROPERTIES}{relative_base})) {
# retrieve the current offset as base for relative pointers
# based on the toplevel struct/union
@@ -1738,6 +1735,10 @@
pidl "switch (level) {";
indent;
foreach my $el (@{$e->{ELEMENTS}}) {
+ if ($el->{CASE} eq "default") {
+ $have_default = 1;
+ }
+
pidl "$el->{CASE}:";
if ($el->{TYPE} ne "EMPTY") {
indent;
@@ -1753,7 +1754,25 @@
}
deindent;
pidl "}";
-
+}
+
+#####################################################################
+# parse a union - push side
+sub ParseUnionPush($$)
+{
+ my ($e,$varname) = @_;
+ my $have_default = 0;
+
+ start_flags($e);
+
+ pidl "if (ndr_flags & NDR_SCALARS) {";
+ indent;
+ ParseUnionPushPrimitives($e, $varname);
+ deindent;
+ pidl "}";
+ pidl "if (ndr_flags & NDR_BUFFERS) {";
+ indent;
+ ParseUnionPushDeferred($e, $varname);
deindent;
pidl "}";
end_flags($e);
@@ -1802,15 +1821,15 @@
end_flags($e);
}
-sub ParseUnionPullPrimitives($$$$)
+sub ParseUnionPullPrimitives($$$)
{
- my ($e,$name,$varname,$switch_type) = @_;
+ my ($e,$varname,$switch_type) = @_;
my $have_default = 0;
if (defined($switch_type)) {
pidl "NDR_CHECK(ndr_pull_$switch_type(ndr, NDR_SCALARS, &_level));";
pidl "if (_level != level) {";
- pidl "\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $name\", _level);";
+ pidl "\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname\", _level);";
pidl "}";
}
@@ -1846,9 +1865,9 @@
pidl "}";
}
-sub ParseUnionPullDeferred($$$)
+sub ParseUnionPullDeferred($$)
{
- my ($e,$name,$varname) = @_;
+ my ($e,$varname) = @_;
my $have_default = 0;
if (defined($e->{PROPERTIES}{relative_base})) {
@@ -1884,9 +1903,9 @@
#####################################################################
# parse a union - pull side
-sub ParseUnionPull($$$)
+sub ParseUnionPull($$)
{
- my ($e,$name,$varname) = @_;
+ my ($e,$varname) = @_;
my $switch_type = $e->{SWITCH_TYPE};
pidl "int level;";
@@ -1911,13 +1930,13 @@
pidl "if (ndr_flags & NDR_SCALARS) {";
indent;
- ParseUnionPullPrimitives($e,$name,$varname,$switch_type);
+ ParseUnionPullPrimitives($e,$varname,$switch_type);
deindent;
pidl "}";
pidl "if (ndr_flags & NDR_BUFFERS) {";
indent;
- ParseUnionPullDeferred($e,$name,$varname);
+ ParseUnionPullDeferred($e,$varname);
deindent;
pidl "}";
@@ -1949,20 +1968,20 @@
#####################################################################
# parse a typedef - push side
-sub ParseTypedefPush($$$)
+sub ParseTypedefPush($$)
{
- my($e,$name,$varname) = @_;
+ my($e,$varname) = @_;
- $typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($e->{DATA}, $name, $varname);
+ $typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($e->{DATA}, $varname);
}
#####################################################################
# parse a typedef - pull side
-sub ParseTypedefPull($$$)
+sub ParseTypedefPull($$)
{
- my($e,$name,$varname) = @_;
+ my($e,$varname) = @_;
- $typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($e->{DATA}, $name, $varname);
+ $typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($e->{DATA}, $varname);
}
#####################################################################
@@ -2428,7 +2447,7 @@
# save the old relative_base_offset
pidl "uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);" if defined(has_property($e, "relative_base"));
- $typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($e, $e->{NAME}, $varname);
+ $typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($e, $varname);
# restore the old relative_base_offset
pidl "ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset);" if defined(has_property($e, "relative_base"));
}
@@ -2455,7 +2474,7 @@
# save the old relative_base_offset
pidl "uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr);" if defined(has_property($e, "relative_base"));
- $typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($e, $e->{NAME}, $varname);
+ $typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($e, $varname);
# restore the old relative_base_offset
pidl "ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset);" if defined(has_property($e, "relative_base"));
}
=== modified file 'source/pidl/tests/samba-ndr.pl'
--- a/source/pidl/tests/samba-ndr.pl 2007-02-19 19:42:51 +0000
+++ b/source/pidl/tests/samba-ndr.pl 2007-02-20 01:24:43 +0000
@@ -259,7 +259,7 @@
TYPE => "STRUCT",
PROPERTIES => {},
ALIGN => 4,
- ELEMENTS => [ ]}, "mystruct", "x");
+ ELEMENTS => [ ]}, "x");
is($res, "if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
}
@@ -282,7 +282,7 @@
PROPERTIES => {},
ALIGN => 4,
SURROUNDING_ELEMENT => $e,
- ELEMENTS => [ $e ]}, "mystruct", "x");
+ ELEMENTS => [ $e ]}, "x");
is($res, "if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1)));
NDR_CHECK(ndr_push_align(ndr, 4));
More information about the samba-cvs
mailing list