1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

r5440: Some more generalizations

This commit is contained in:
Jelmer Vernooij 2005-02-18 11:11:21 +00:00 committed by Gerald (Jerry) Carter
parent 0a78a1f908
commit cf12084712

View File

@ -212,19 +212,10 @@ sub find_sibling($$)
$name = $1; $name = $1;
} }
if ($fn->{TYPE} eq "FUNCTION") {
for my $e2 (@{$fn->{ELEMENTS}}) { for my $e2 (@{$fn->{ELEMENTS}}) {
if ($e2->{NAME} eq $name) { return $e2 if ($e2->{NAME} eq $name);
return $e2;
}
}
} }
for my $e2 (@{$fn->{ELEMENTS}}) {
if ($e2->{NAME} eq $name) {
return $e2;
}
}
die "invalid sibling '$name'"; die "invalid sibling '$name'";
} }
@ -238,13 +229,9 @@ sub ParseExpr($$$)
my($fn) = $e->{PARENT}; my($fn) = $e->{PARENT};
if (util::is_constant($size)) { return $size if (util::is_constant($size));
return $size;
}
if ($size =~ /ndr->|\(/) { return $size if ($size =~ /ndr->|\(/);
return $size;
}
my $prefix = ""; my $prefix = "";
@ -262,9 +249,11 @@ sub ParseExpr($$$)
if (util::has_property($e2, "in") && util::has_property($e2, "out")) { if (util::has_property($e2, "in") && util::has_property($e2, "out")) {
return $prefix . "$var_prefix$size"; return $prefix . "$var_prefix$size";
} }
if (util::has_property($e2, "in")) { if (util::has_property($e2, "in")) {
return $prefix . "r->in.$size"; return $prefix . "r->in.$size";
} }
if (util::has_property($e2, "out")) { if (util::has_property($e2, "out")) {
return $prefix . "r->out.$size"; 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 # work out is a parse function should be declared static or not
sub fn_prefix($) sub fn_prefix($)
@ -315,7 +303,6 @@ sub fn_prefix($)
return "static "; return "static ";
} }
################################################################### ###################################################################
# setup any special flags for an element or structure # setup any special flags for an element or structure
sub start_flags($) sub start_flags($)
@ -913,9 +900,7 @@ sub ParseStructPush($)
{ {
my($struct) = shift; my($struct) = shift;
if (! defined $struct->{ELEMENTS}) { return unless defined($struct->{ELEMENTS});
return;
}
start_flags($struct); start_flags($struct);
@ -1112,10 +1097,11 @@ $typefamily{BITMAP} = {
sub ParseStructPrint($) sub ParseStructPrint($)
{ {
my($struct) = shift; my($struct) = shift;
my($name) = $struct->{PARENT}->{NAME};
if (! defined $struct->{ELEMENTS}) { return unless defined $struct->{ELEMENTS};
return;
} pidl "ndr_print_struct(ndr, name, \"$name\");";
start_flags($struct); start_flags($struct);
@ -1135,9 +1121,7 @@ sub ParseStructPull($)
my($struct) = shift; my($struct) = shift;
my $conform_e; my $conform_e;
if (! defined $struct->{ELEMENTS}) { return unless defined $struct->{ELEMENTS};
return;
}
# see if the structure contains a conformant array. If it # see if the structure contains a conformant array. If it
# does, then it must be the last element of the structure, and # does, then it must be the last element of the structure, and
@ -1324,7 +1308,9 @@ sub ParseUnionPrint($)
{ {
my $e = shift; my $e = shift;
my $have_default = 0; my $have_default = 0;
my($name) = $e->{PARENT}->{NAME};
pidl "ndr_print_union(ndr, name, level, \"$name\");";
start_flags($e); start_flags($e);
pidl "switch (level) {"; pidl "switch (level) {";
@ -1525,31 +1511,23 @@ sub ParseTypedefPrint($)
if ($e->{DATA}->{TYPE} eq "STRUCT") { if ($e->{DATA}->{TYPE} eq "STRUCT") {
pidl "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, struct $e->{NAME} *r)"; 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") { 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 "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") { if ($e->{DATA}->{TYPE} eq "ENUM") {
pidl "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, enum $e->{NAME} r)"; 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") { if ($e->{DATA}->{TYPE} eq "BITMAP") {
my $type_decl = util::bitmap_type_decl($e->{DATA}); 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 "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}); $typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($e->{DATA});
deindent; deindent;
pidl "}"; pidl "}";