svn commit: samba r5449 - in branches/SAMBA_4_0/source/build/pidl: .
jelmer at samba.org
jelmer at samba.org
Fri Feb 18 21:49:11 GMT 2005
Author: jelmer
Date: 2005-02-18 21:49:11 +0000 (Fri, 18 Feb 2005)
New Revision: 5449
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5449
Log:
More array handling cleanups. This should make the code more
readable. (Output C and header files have not changed, just internal pidl
changes)
Modified:
branches/SAMBA_4_0/source/build/pidl/ndr.pm
Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/ndr.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/ndr.pm 2005-02-18 21:10:31 UTC (rev 5448)
+++ branches/SAMBA_4_0/source/build/pidl/ndr.pm 2005-02-18 21:49:11 UTC (rev 5449)
@@ -110,7 +110,8 @@
sub is_conformant_array($)
{
my $e = shift;
- return defined($e->{CONFORMANT_SIZE});
+ return 1 if (util::has_property($e, "size_is"));
+ return 0;
}
# return 1 if this is a inline array
@@ -132,6 +133,17 @@
return 0;
}
+sub is_surrounding_array($)
+{
+ my $e = shift;
+
+ return ($e->{POINTERS} == 0
+ and defined $e->{ARRAY_LEN}
+ and $e->{ARRAY_LEN} eq "*"
+ and $e == $e->{PARENT}->{ELEMENTS}[-1]
+ and $e->{PARENT}->{TYPE} ne "FUNCTION");
+}
+
sub array_type($)
{
my $e = shift;
@@ -430,14 +442,15 @@
my $size = ParseExpr($e, util::array_size($e), $var_prefix);
- if (is_conformant_array($e) ) {
+ if (is_surrounding_array($e)) {
# the conformant size has already been pushed
} elsif (!is_inline_array($e)) {
# we need to emit the array size
pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));";
}
- if (my $length = util::has_property($e, "length_is")) {
+ if (is_varying_array($e)) {
+ my $length = util::has_property($e, "length_is");
$length = ParseExpr($e, $length, $var_prefix);
pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));";
pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $length));";
@@ -478,8 +491,8 @@
my $e = shift;
my $var_prefix = shift;
- if (!is_conformant_array($e) &&
- util::has_property($e, "size_is")) {
+ if (!is_surrounding_array($e) &&
+ is_conformant_array($e)) {
my $size = ParseExpr($e, util::array_size($e), $var_prefix);
pidl "if ($var_prefix$e->{NAME}) {";
indent;
@@ -489,14 +502,15 @@
pidl "}";
}
- if (my $length = util::has_property($e, "length_is")) {
+ if (is_varying_array($e)) {
+ my $length = util::has_property($e, "length_is");
$length = ParseExpr($e, $length, $var_prefix);
pidl "if ($var_prefix$e->{NAME}) {";
indent;
check_null_pointer($length);
pidl "NDR_CHECK(ndr_check_array_length(ndr, (void*)&$var_prefix$e->{NAME}, $length));";
deindent;
- pidl "}";
+ pidl "}"
}
}
@@ -513,7 +527,7 @@
# if this is a conformant array then we use that size to allocate, and make sure
# we allocate enough to pull the elements
- if (is_conformant_array($e)) {
+ if (is_conformant_array($e) and is_surrounding_array($e)) {
$alloc_size = $e->{CONFORMANT_SIZE};
check_null_pointer($size);
pidl "if ($size > $alloc_size) {";
@@ -964,7 +978,7 @@
# the wire before the structure (and even before the structure
# alignment)
my $e = $struct->{ELEMENTS}[-1];
- if (defined $e->{ARRAY_LEN} && $e->{ARRAY_LEN} eq "*") {
+ if (is_conformant_array($e) and is_surrounding_array($e)) {
my $size = ParseExpr($e, util::array_size($e), "r->");
$e->{CONFORMANT_SIZE} = $size;
check_null_pointer($size);
@@ -1228,7 +1242,7 @@
# the wire before the structure (and even before the structure
# alignment)
my $e = $struct->{ELEMENTS}[-1];
- if (defined $e->{ARRAY_LEN} && $e->{ARRAY_LEN} eq "*") {
+ if (is_conformant_array($e) and is_surrounding_array($e)) {
$conform_e = $e;
}
@@ -1238,7 +1252,6 @@
}
if (defined $conform_e) {
- $conform_e = $e;
pidl "uint32_t _conformant_size;";
$conform_e->{CONFORMANT_SIZE} = "_conformant_size";
}
More information about the samba-cvs
mailing list