summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-02-18 11:11:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:45 -0500
commit5772a99832eef167c2f9510867736b2ab57f61c0 (patch)
treeb47a7def28db527f35e023bcb02540b1aeed65c4
parent8f65c54a81e1b3d32c3c693e1599720f830fa96f (diff)
downloadsamba-5772a99832eef167c2f9510867736b2ab57f61c0.tar.gz
samba-5772a99832eef167c2f9510867736b2ab57f61c0.tar.bz2
samba-5772a99832eef167c2f9510867736b2ab57f61c0.zip
r5440: Some more generalizations
(This used to be commit cf1208471247e2d734f90008d29827541f177952)
-rw-r--r--source4/build/pidl/ndr.pm54
1 files changed, 16 insertions, 38 deletions
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index 7a2fc850ce..419ee5e9cc 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -212,19 +212,10 @@ sub find_sibling($$)
$name = $1;
}
- if ($fn->{TYPE} eq "FUNCTION") {
- for my $e2 (@{$fn->{ELEMENTS}}) {
- if ($e2->{NAME} eq $name) {
- return $e2;
- }
- }
- }
-
for my $e2 (@{$fn->{ELEMENTS}}) {
- if ($e2->{NAME} eq $name) {
- return $e2;
- }
+ return $e2 if ($e2->{NAME} eq $name);
}
+
die "invalid sibling '$name'";
}
@@ -238,13 +229,9 @@ sub ParseExpr($$$)
my($fn) = $e->{PARENT};
- if (util::is_constant($size)) {
- return $size;
- }
+ return $size if (util::is_constant($size));
- if ($size =~ /ndr->|\(/) {
- return $size;
- }
+ return $size if ($size =~ /ndr->|\(/);
my $prefix = "";
@@ -262,9 +249,11 @@ sub ParseExpr($$$)
if (util::has_property($e2, "in") && util::has_property($e2, "out")) {
return $prefix . "$var_prefix$size";
}
+
if (util::has_property($e2, "in")) {
return $prefix . "r->in.$size";
}
+
if (util::has_property($e2, "out")) {
return $prefix . "r->out.$size";
}
@@ -295,7 +284,6 @@ sub check_null_pointer_void($)
}
}
-
#####################################################################
# work out is a parse function should be declared static or not
sub fn_prefix($)
@@ -315,7 +303,6 @@ sub fn_prefix($)
return "static ";
}
-
###################################################################
# setup any special flags for an element or structure
sub start_flags($)
@@ -913,9 +900,7 @@ sub ParseStructPush($)
{
my($struct) = shift;
- if (! defined $struct->{ELEMENTS}) {
- return;
- }
+ return unless defined($struct->{ELEMENTS});
start_flags($struct);
@@ -1112,10 +1097,11 @@ $typefamily{BITMAP} = {
sub ParseStructPrint($)
{
my($struct) = shift;
+ my($name) = $struct->{PARENT}->{NAME};
- if (! defined $struct->{ELEMENTS}) {
- return;
- }
+ return unless defined $struct->{ELEMENTS};
+
+ pidl "ndr_print_struct(ndr, name, \"$name\");";
start_flags($struct);
@@ -1135,9 +1121,7 @@ sub ParseStructPull($)
my($struct) = shift;
my $conform_e;
- if (! defined $struct->{ELEMENTS}) {
- return;
- }
+ return unless defined $struct->{ELEMENTS};
# see if the structure contains a conformant array. If it
# does, then it must be the last element of the structure, and
@@ -1324,7 +1308,9 @@ sub ParseUnionPrint($)
{
my $e = shift;
my $have_default = 0;
+ my($name) = $e->{PARENT}->{NAME};
+ pidl "ndr_print_union(ndr, name, level, \"$name\");";
start_flags($e);
pidl "switch (level) {";
@@ -1525,31 +1511,23 @@ sub ParseTypedefPrint($)
if ($e->{DATA}->{TYPE} eq "STRUCT") {
pidl "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, struct $e->{NAME} *r)";
- pidl "{";
- indent;
- pidl "ndr_print_struct(ndr, name, \"$e->{NAME}\");";
}
if ($e->{DATA}->{TYPE} eq "UNION") {
pidl "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, int level, union $e->{NAME} *r)";
- pidl "{";
- indent;
- pidl "ndr_print_union(ndr, name, level, \"$e->{NAME}\");";
}
if ($e->{DATA}->{TYPE} eq "ENUM") {
pidl "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, enum $e->{NAME} r)";
- pidl "{";
- indent;
}
if ($e->{DATA}->{TYPE} eq "BITMAP") {
my $type_decl = util::bitmap_type_decl($e->{DATA});
pidl "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, $type_decl r)";
- pidl "{";
- indent;
}
+ pidl "{";
+ indent;
$typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($e->{DATA});
deindent;
pidl "}";