summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-12-08 22:04:16 +0000
committerTim Potter <tpot@samba.org>2001-12-08 22:04:16 +0000
commitae87ee3ccd33e56519974cea6adc60fa752229b1 (patch)
treef5d03cbf3dfb814dc2c521adcc073326b698b08d
parent6ec1278d16a34973dae42e51cd089d9411e25467 (diff)
downloadsamba-ae87ee3ccd33e56519974cea6adc60fa752229b1.tar.gz
samba-ae87ee3ccd33e56519974cea6adc60fa752229b1.tar.bz2
samba-ae87ee3ccd33e56519974cea6adc60fa752229b1.zip
Removed old commented-out code.
Generate code for parsing arrays. We're nearly ready to start generating real code! (This used to be commit f6f5b8a7189b579eaf1fbf8db91c9ba11b96ac57)
-rw-r--r--source4/build/pidl/eparser.pm79
1 files changed, 30 insertions, 49 deletions
diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm
index a2ad3c2d0e..791d8ee05b 100644
--- a/source4/build/pidl/eparser.pm
+++ b/source4/build/pidl/eparser.pm
@@ -35,7 +35,7 @@ sub has_property($$)
return 1, if ($d eq "in,out" && ($p eq "in" || $p eq "out"));
} else {
foreach my $k (keys %{$d}) {
- $res .= "[$k($d->{$k})] ";
+ return $d->{$k}, if ($k eq $p);
}
}
}
@@ -60,25 +60,31 @@ sub ParseProperties($)
}
#####################################################################
-# parse a structure element
-sub ParseElement($$)
+# parse an array - called in buffers context
+sub ParseArray($)
{
my($elt) = shift;
- my($flags) = shift;
-# (defined $elt->{PROPERTIES}) && ParseProperties($elt->{PROPERTIES});
-# ParseType($elt->{TYPE});
+ $res .= "\tfor (i = 0; i < count; i++) {\n";
+ if (is_scalar_type($elt)) {
+ $res .= "\t\tprs_$elt->{NAME}(tvb, offset, pinfo, tree, \"$elt->{NAME});\n";
+ $res .= "\t}\n\n";
+ } else {
+ $res .= "\t\tprs_$elt->{NAME}(tvb, offset, pinfo, tree, \"PARSE_SCALARS\", \"$elt->{NAME}\");\n";
+ $res .= "\t}\n\n";
-# $res .= "/* ";
-# if ($elt->{POINTERS}) {
-# for (my($i)=0; $i < $elt->{POINTERS}; $i++) {
-# $res .= "*";
-# }
-# }
-# $res .= "$elt->{NAME}";
-# (defined $elt->{ARRAY_LEN}) && ($res .= "[$elt->{ARRAY_LEN}]");
+ $res .= "\tfor (i = 0; i < count; i++) {\n";
+ $res .= "\t\tprs_$elt->{NAME}(tvb, offset, pinfo, tree, \"PARSE_BUFFERS\", \"$elt->{NAME}\");\n";
+ $res .= "\t}\n\n";
+ }
+}
-# $res .= "*/\n\n";
+#####################################################################
+# parse a structure element
+sub ParseElement($$)
+{
+ my($elt) = shift;
+ my($flags) = shift;
# Arg is a policy handle
@@ -104,7 +110,9 @@ sub ParseElement($$)
}
}
- } else {
+ }
+
+ if ($flags =~ /buffers/) {
# Scalars are not buffers, except if they are pointed to
@@ -116,8 +124,12 @@ sub ParseElement($$)
$res .= "\t\tif (ptr_$elt->{NAME}) {\n\t";
}
- $res .= "\t\tprs_$elt->{TYPE}(tvb, offset, pinfo, tree, flags, \"$elt->{NAME}\");\n\n";
-
+ if (has_property($elt->{PROPERTIES}, "size_is")) {
+ ParseArray($elt);
+ } else {
+ $res .= "\t\tprs_$elt->{TYPE}(tvb, offset, pinfo, tree, flags, \"$elt->{NAME}\");\n\n";
+ }
+
if ($elt->{POINTERS}) {
$res .= "\t\t}\n\n";
}
@@ -125,22 +137,6 @@ sub ParseElement($$)
}
return;
-
-# if (is_simple_type($elt->{TYPE})) {
-# if ($flags =~ /scalars/ && !$elt->{POINTERS}) {
-# $res .= "\t\tprs_$elt->{TYPE}(tvb, offset, pinfo, tree, \"$elt->{NAME}}\");\n\n",
-# }
-# } else {
-# if ($flags =~ /buffers/) {
-# if ($elt->{POINTERS}) {
-# $res .= "\t\tif (ptr_$elt->{NAME}) {\n\t";
-# }
-# $res .= "\t\tprs_$elt->{TYPE}(tvb, offset, pinfo, tree, flags, \"$elt->{NAME}\");\n\n";
-# if ($elt->{POINTERS}) {
-# $res .= "\t\t}\n\n";
-# }
-# }
-# }
}
#####################################################################
@@ -157,12 +153,6 @@ sub ParseStruct($)
foreach my $e (@{$struct->{ELEMENTS}}) {
ParseElement($e, "scalars");
-
-# if (defined $e->{POINTERS}) {
-# $res .= "\t\toffset = prs_ptr(tvb, offset, pinfo, tree, &ptr_$e->{NAME}, \"$e->{NAME}\");\n";
-# } else {
-# $res .= "\t\toffset = prs_$e->{TYPE}(tvb, offset, pinfo, tree, \"$e->{NAME}\");\n";
-# }
}
$res .= "\t}\n\n";
@@ -173,8 +163,6 @@ sub ParseStruct($)
foreach my $e (@{$struct->{ELEMENTS}}) {
ParseElement($e, "buffers");
-# $res .= "\t\tif (ptr_$e->{NAME})\n\t\t\toffset = prs_$e->{TYPE}(tvb, offset, pinfo, tree, \"$e->{NAME}\");\n\n",
-# if (defined $e->{POINTERS});
}
$res .= "\t}\n\n";
@@ -188,16 +176,9 @@ sub ParseUnionElement($)
{
my($element) = shift;
-# $res .= "int prs_$element->{DATA}->{TYPE}()\n{\n";
-
-# $res .= "}\n\n";
-
$res .= "\tcase $element->{DATA}->{NAME}: \n";
$res .= "\t\toffset = prs_$element->{DATA}->{TYPE}(tvb, offset, pinfo, tree, \"$element->{DATA}->{NAME}\");\n\t\tbreak;\n";
-# $res .= "[case($element->{CASE})] ";
-# ParseElement($element->{DATA});
-# $res .= ";\n";
}
#####################################################################