summaryrefslogtreecommitdiff
path: root/source4/build/pidl/ndr.pm
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-02-21 00:21:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:49 -0500
commite770d5696ee0265661fd6cc2fa24a24b19a0b889 (patch)
tree9f7005147e14250a35859288173bce1f529a87e8 /source4/build/pidl/ndr.pm
parent0dd7f645a4d6a1c7cc6a5fb1f82d12546dd5a40c (diff)
downloadsamba-e770d5696ee0265661fd6cc2fa24a24b19a0b889.tar.gz
samba-e770d5696ee0265661fd6cc2fa24a24b19a0b889.tar.bz2
samba-e770d5696ee0265661fd6cc2fa24a24b19a0b889.zip
r5478: Bunch of small optimizations and generalizations.
(This used to be commit fd8fc22a79ec5fb7d5902605ca3984c4f8f463d0)
Diffstat (limited to 'source4/build/pidl/ndr.pm')
-rw-r--r--source4/build/pidl/ndr.pm46
1 files changed, 26 insertions, 20 deletions
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index da2086e765..0d9b38d07b 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -719,11 +719,6 @@ sub ParseElementPullSwitch($$$$)
my $type_decl = typelist::mapType($e2);
pidl "if (($ndr_flags) & NDR_SCALARS) {";
indent;
- if (typelist::getType($e2->{TYPE})->{DATA}->{TYPE} eq "ENUM") {
- $type_decl = typelist::mapType($e2);
- } elsif (typelist::getType($e2->{TYPE})->{DATA}->{TYPE} eq "BITMAP") {
- $type_decl = typelist::mapType($e2);
- }
pidl "$type_decl _level;";
pidl "NDR_CHECK(ndr_pull_$e2->{TYPE}(ndr, NDR_SCALARS, &_level));";
if ($switch_var =~ /r->in/) {
@@ -1303,16 +1298,10 @@ sub ParseStructNdrSize($)
my $static = fn_prefix($t);
my $sizevar;
- pidl "size_t ndr_size_$t->{NAME}(const struct $t->{NAME} *r, int flags)";
- pidl "{";
- indent;
if (my $flags = util::has_property($t, "flag")) {
pidl "flags |= $flags;";
}
pidl "return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_$t->{NAME});";
- deindent;
- pidl "}";
- pidl "";
}
sub ArgsStructPush($)
@@ -1333,6 +1322,12 @@ sub ArgsStructPull($)
return "struct ndr_pull *ndr, int ndr_flags, struct $e->{NAME} *r";
}
+sub ArgsStructNdrSize($)
+{
+ my $d = shift;
+ return "const struct $d->{NAME} *r, int flags";
+}
+
$typefamily{STRUCT} = {
PUSH_FN_BODY => \&ParseStructPush,
PUSH_FN_ARGS => \&ArgsStructPush,
@@ -1340,7 +1335,8 @@ $typefamily{STRUCT} = {
PULL_FN_ARGS => \&ArgsStructPull,
PRINT_FN_BODY => \&ParseStructPrint,
PRINT_FN_ARGS => \&ArgsStructPrint,
- SIZE_FN => \&ParseStructNdrSize,
+ SIZE_FN_BODY => \&ParseStructNdrSize,
+ SIZE_FN_ARGS => \&ArgsStructNdrSize,
ALIGN => \&find_largest_alignment
};
@@ -1352,16 +1348,10 @@ sub ParseUnionNdrSize($)
my $static = fn_prefix($t);
my $sizevar;
- pidl "size_t ndr_size_$t->{NAME}(const union $t->{NAME} *r, int level, int flags)";
- pidl "{";
- indent;
if (my $flags = util::has_property($t, "flag")) {
pidl "flags |= $flags;";
}
pidl "return ndr_size_union(r, flags, level, (ndr_push_union_fn_t)ndr_push_$t->{NAME});";
- deindent;
- pidl "}";
- pidl "";;
}
#####################################################################
@@ -1560,6 +1550,12 @@ sub ArgsUnionPull($)
return "struct ndr_pull *ndr, int ndr_flags, int level, union $e->{NAME} *r";
}
+sub ArgsUnionNdrSize($)
+{
+ my $d = shift;
+ return "const union $d->{NAME} *r, uint32_t level, int flags";
+}
+
$typefamily{UNION} = {
PUSH_FN_BODY => \&ParseUnionPush,
PUSH_FN_ARGS => \&ArgsUnionPush,
@@ -1567,7 +1563,8 @@ $typefamily{UNION} = {
PULL_FN_ARGS => \&ArgsUnionPull,
PRINT_FN_BODY => \&ParseUnionPrint,
PRINT_FN_ARGS => \&ArgsUnionPrint,
- SIZE_FN => \&ParseUnionNdrSize,
+ SIZE_FN_ARGS => \&ArgsUnionNdrSize,
+ SIZE_FN_BODY => \&ParseUnionNdrSize,
ALIGN => \&find_largest_alignment
};
@@ -1639,7 +1636,16 @@ sub ParseTypedefNdrSize($)
return unless needed::is_needed("ndr_size_$t->{NAME}");
- $typefamily{$t->{DATA}->{TYPE}}->{SIZE_FN}->($t);
+ my $tf = $typefamily{$t->{DATA}->{TYPE}};
+ my $args = $tf->{SIZE_FN_ARGS}->($t);
+
+ pidl "size_t ndr_size_$t->{NAME}($args)";
+ pidl "{";
+ indent;
+ $typefamily{$t->{DATA}->{TYPE}}->{SIZE_FN_BODY}->($t);
+ deindent;
+ pidl "}";
+ pidl "";
}
#####################################################################