summaryrefslogtreecommitdiff
path: root/source4/build/pidl/needed.pm
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-11-01 05:25:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:08 -0500
commit2c52f52e02ca1e7286d0faa15d5031f2a4ac11ed (patch)
tree4da99bdf8b7211c15158bae19a4b76b1e42df862 /source4/build/pidl/needed.pm
parent38ee8f04ef945f9b109f8cdb39dc7c3c5ee90dd3 (diff)
downloadsamba-2c52f52e02ca1e7286d0faa15d5031f2a4ac11ed.tar.gz
samba-2c52f52e02ca1e7286d0faa15d5031f2a4ac11ed.tar.bz2
samba-2c52f52e02ca1e7286d0faa15d5031f2a4ac11ed.zip
r3423: auto-generate prototypes for all external functions in pidl
(This used to be commit 009488dfe55f5219b24c30222b1a8bf411a7e939)
Diffstat (limited to 'source4/build/pidl/needed.pm')
-rw-r--r--source4/build/pidl/needed.pm92
1 files changed, 92 insertions, 0 deletions
diff --git a/source4/build/pidl/needed.pm b/source4/build/pidl/needed.pm
new file mode 100644
index 0000000000..301b85e51c
--- /dev/null
+++ b/source4/build/pidl/needed.pm
@@ -0,0 +1,92 @@
+###################################################
+# Samba4 parser generator for IDL structures
+# Copyright tridge@samba.org 2000-2004
+# Copyright jelmer@samba.org 2004
+# released under the GNU GPL
+
+package needed;
+
+use strict;
+
+# the list of needed functions
+my %needed;
+
+sub NeededFunction($)
+{
+ my $fn = shift;
+ $needed{"pull_$fn->{NAME}"} = 1;
+ $needed{"push_$fn->{NAME}"} = 1;
+ foreach my $e (@{$fn->{DATA}}) {
+ $e->{PARENT} = $fn;
+ $needed{"pull_$e->{TYPE}"} = 1;
+ $needed{"push_$e->{TYPE}"} = 1;
+ }
+}
+
+sub NeededTypedef($)
+{
+ my $t = shift;
+ if (util::has_property($t->{DATA}, "public")) {
+ $needed{"pull_$t->{NAME}"} = 1;
+ $needed{"push_$t->{NAME}"} = 1;
+ }
+
+ if ($t->{DATA}->{TYPE} eq "STRUCT") {
+ if (util::has_property($t->{DATA}, "gensize")) {
+ $needed{"ndr_size_$t->{NAME}"} = 1;
+ }
+
+ for my $e (@{$t->{DATA}->{ELEMENTS}}) {
+ $e->{PARENT} = $t->{DATA};
+ if ($needed{"pull_$t->{NAME}"}) {
+ $needed{"pull_$e->{TYPE}"} = 1;
+ }
+ if ($needed{"push_$t->{NAME}"}) {
+ $needed{"push_$e->{TYPE}"} = 1;
+ }
+ if ($needed{"ndr_size_$t->{NAME}"}) {
+ $needed{"ndr_size_$e->{TYPE}"} = 1;
+ }
+ }
+ }
+ if ($t->{DATA}->{TYPE} eq "UNION") {
+ for my $e (@{$t->{DATA}->{DATA}}) {
+ $e->{PARENT} = $t->{DATA};
+ if ($e->{TYPE} eq "UNION_ELEMENT") {
+ if ($needed{"pull_$t->{NAME}"}) {
+ $needed{"pull_$e->{DATA}->{TYPE}"} = 1;
+ }
+ if ($needed{"push_$t->{NAME}"}) {
+ $needed{"push_$e->{DATA}->{TYPE}"} = 1;
+ }
+ if ($needed{"ndr_size_$t->{NAME}"}) {
+ $needed{"ndr_size_$e->{DATA}->{TYPE}"} = 1;
+ }
+ }
+ }
+ }
+}
+
+#####################################################################
+# work out what parse functions are needed
+sub BuildNeeded($)
+{
+ my($interface) = shift;
+ my($data) = $interface->{DATA};
+ foreach my $d (@{$data}) {
+ ($d->{TYPE} eq "FUNCTION") &&
+ NeededFunction($d);
+ }
+ foreach my $d (reverse @{$data}) {
+ ($d->{TYPE} eq "TYPEDEF") &&
+ NeededTypedef($d);
+ }
+}
+
+sub is_needed($)
+{
+ my $name = shift;
+ return $needed{$name};
+}
+
+1;