summaryrefslogtreecommitdiff
path: root/source4/build/pidl/parser.pm
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-11-16 21:07:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:53 -0500
commit46badf19089668e470e9bb5b2300017f8948b49e (patch)
tree5625999d4333c30f6cedce7cbfc73ced1b2791ef /source4/build/pidl/parser.pm
parent83d29e9bac43f643eb4ab11871425019f2ea9421 (diff)
downloadsamba-46badf19089668e470e9bb5b2300017f8948b49e.tar.gz
samba-46badf19089668e470e9bb5b2300017f8948b49e.tar.bz2
samba-46badf19089668e470e9bb5b2300017f8948b49e.zip
r3790: use a registration function that is called from dcerpc_*_init functions
rather then a large table in librpc/gen_ndr/tables.c. This will allow us to only link in only the required gen_ndr files (speeds up linking quite a bit, makes binaries smaller). Each gen_ndr_* file now has a init function that calls the init functions of the interfaces it contains. I did it this way to keep pidl's code simple, though it might hurt startup time a bit. I'd be happy to change it if people like one function better. (This used to be commit 3c436590ae95b58ad6d00e72d6fdd08a4d80f208)
Diffstat (limited to 'source4/build/pidl/parser.pm')
-rw-r--r--source4/build/pidl/parser.pm48
1 files changed, 44 insertions, 4 deletions
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index e55e5ecd9c..5be538b2cf 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -1480,9 +1480,7 @@ sub FunctionTable($)
if ($d->{TYPE} eq "FUNCTION") { $count++; }
}
- if ($count == 0) {
- return;
- }
+ return if ($count == 0);
pidl "static const struct dcerpc_interface_call $interface->{NAME}\_calls[] = {\n";
foreach my $d (@{$data}) {
@@ -1525,8 +1523,12 @@ sub FunctionTable($)
pidl "\t$interface->{NAME}\_calls,\n";
pidl "\t&$interface->{NAME}\_endpoints\n";
pidl "};\n\n";
-}
+ pidl "static NTSTATUS dcerpc_ndr_$interface->{NAME}_init(void)\n";
+ pidl "{\n";
+ pidl "\treturn librpc_register_interface(&dcerpc_table_$interface->{NAME});\n";
+ pidl "}\n\n";
+}
#####################################################################
# parse the interface definitions
@@ -1570,7 +1572,43 @@ sub ParseInterface($)
}
FunctionTable($interface);
+}
+
+sub RegistrationFunction($$)
+{
+ my $idl = shift;
+ my $filename = shift;
+ $filename =~ /.*\/ndr_(.*).c/;
+ my $basename = $1;
+ pidl "NTSTATUS dcerpc_$basename\_init(void)\n";
+ pidl "{\n";
+ pidl "\tNTSTATUS status = NT_STATUS_OK;\n";
+ foreach my $interface (@{$idl}) {
+ next if $interface->{TYPE} ne "INTERFACE";
+
+ my $data = $interface->{INHERITED_DATA};
+ my $count = 0;
+ foreach my $d (@{$data}) {
+ if ($d->{TYPE} eq "FUNCTION") { $count++; }
+ }
+
+ next if ($count == 0);
+
+ pidl "\tstatus = dcerpc_ndr_$interface->{NAME}_init();\n";
+ pidl "\tif (NT_STATUS_IS_ERR(status)) {\n";
+ pidl "\t\treturn status;\n";
+ pidl "\t}\n\n";
+
+ if (util::has_property($interface, "object")) {
+ pidl "\tstatus = dcom_$interface->{NAME}_init();\n";
+ pidl "\tif (NT_STATUS_IS_ERR(status)) {\n";
+ pidl "\t\treturn status;\n";
+ pidl "\t}\n\n";
+ }
+ }
+ pidl "\treturn status;\n";
+ pidl "}\n\n";
}
#####################################################################
@@ -1604,6 +1642,8 @@ sub Parse($$)
}
}
+ RegistrationFunction($idl, $filename);
+
close(OUT);
}