summaryrefslogtreecommitdiff
path: root/source4
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
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')
-rw-r--r--source4/build/pidl/header.pm15
-rw-r--r--source4/build/pidl/ndr.pm46
-rw-r--r--source4/build/pidl/typelist.pm10
3 files changed, 39 insertions, 32 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index b192efb699..ba73570dab 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -212,19 +212,15 @@ sub HeaderTypedefProto($)
{
my($d) = shift;
+ my $tf = NdrParser::get_typefamily($d->{DATA}{TYPE});
+
if (needed::is_needed("ndr_size_$d->{NAME}")) {
- if ($d->{DATA}{TYPE} eq "STRUCT") {
- pidl "size_t ndr_size_$d->{NAME}(const struct $d->{NAME} *r, int flags);\n";
- }
- if ($d->{DATA}{TYPE} eq "UNION") {
- pidl "size_t ndr_size_$d->{NAME}(const union $d->{NAME} *r, uint32_t level, int flags);\n";
- }
+ my $size_args = $tf->{SIZE_FN_ARGS}->($d);
+ pidl "size_t ndr_size_$d->{NAME}($size_args);\n";
}
return unless util::has_property($d, "public");
- my $tf = NdrParser::get_typefamily($d->{DATA}{TYPE});
-
my $pull_args = $tf->{PULL_FN_ARGS}->($d);
my $push_args = $tf->{PUSH_FN_ARGS}->($d);
my $print_args = $tf->{PRINT_FN_ARGS}->($d);
@@ -281,7 +277,6 @@ sub HeaderFunctionInOut_needed($$)
return undef;
}
-
#####################################################################
# parse a function
sub HeaderFunction($)
@@ -347,7 +342,6 @@ sub HeaderFnProto($$)
pidl "\n";
}
-
#####################################################################
# generate vtable structure for DCOM interface
sub HeaderVTable($)
@@ -365,7 +359,6 @@ sub HeaderVTable($)
pidl "};\n\n";
}
-
#####################################################################
# parse the interface definitions
sub HeaderInterface($)
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 "";
}
#####################################################################
diff --git a/source4/build/pidl/typelist.pm b/source4/build/pidl/typelist.pm
index f1ece68d8d..2d38d1f18d 100644
--- a/source4/build/pidl/typelist.pm
+++ b/source4/build/pidl/typelist.pm
@@ -126,6 +126,7 @@ sub mapType($)
return mapScalarType($e->{TYPE}) if ($dt->{DATA}->{TYPE} eq "SCALAR");
return "enum $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "ENUM");
return "struct $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "STRUCT");
+ return "struct $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "INTERFACE");
return "union $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "UNION");
return mapScalarType(bitmap_type_fn($dt->{DATA})) if ($dt->{DATA}->{TYPE} eq "BITMAP");
@@ -138,7 +139,14 @@ sub LoadIdl($)
foreach my $x (@{$idl}) {
next if $x->{TYPE} ne "INTERFACE";
- addType($x);
+
+ # DCOM interfaces can be types as well
+ addType({
+ NAME => $x->{NAME},
+ TYPE => "TYPEDEF",
+ DATA => $x
+ }) if (util::has_property($x, "object"));
+
foreach my $y (@{$x->{DATA}}) {
addType($y) if (
$y->{TYPE} eq "TYPEDEF"