r15367: Fix unused function warnings in generated EJS code.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 30 Apr 2006 23:11:59 +0000 (23:11 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:05:27 +0000 (14:05 -0500)
source/pidl/lib/Parse/Pidl/Samba4/EJS.pm

index e1a8feb1cd8add5f897a66b9c643a1a4796c7c2a..218b8823238de1eefff167743b4629b70bf43afc 100644 (file)
@@ -422,15 +422,13 @@ sub EjsPullFunction($)
        # on the non-array elements
        foreach my $e (@{$d->{ELEMENTS}}) {
                next unless (grep(/in/, @{$e->{DIRECTION}}));
-               next if (has_property($e, "length_is") || 
-                        has_property($e, "size_is"));
+               next if (has_property($e, "length_is") || has_property($e, "size_is"));
                EjsPullElementTop($e, $env);
        }
 
        foreach my $e (@{$d->{ELEMENTS}}) {
                next unless (grep(/in/, @{$e->{DIRECTION}}));
-               next unless (has_property($e, "length_is") || 
-                            has_property($e, "size_is"));
+               next unless (has_property($e, "length_is") || has_property($e, "size_is"));
                EjsPullElementTop($e, $env);
        }
 
@@ -760,7 +758,7 @@ sub EjsInterface($$)
 
        foreach my $d (@{$interface->{FUNCTIONS}}) {
                next if not defined($d->{OPNUM});
-               next if Parse::Pidl::Util::has_property($d, "noejs");
+               next if has_property($d, "noejs");
 
                EjsPullFunction($d);
                EjsPushFunction($d);
@@ -846,14 +844,17 @@ sub Parse($$)
 sub NeededFunction($$)
 {
        my ($fn,$needed) = @_;
+
        $needed->{"pull_$fn->{NAME}"} = 1;
        $needed->{"push_$fn->{NAME}"} = 1;
-       foreach my $e (@{$fn->{ELEMENTS}}) {
-               if (grep (/in/, @{$e->{DIRECTION}})) {
-                       $needed->{"pull_$e->{TYPE}"} = 1;
+        
+       foreach (@{$fn->{ELEMENTS}}) {
+               next if (has_property($_, "subcontext")); #FIXME: Support subcontexts
+               if (grep(/in/, @{$_->{DIRECTION}})) {
+                       $needed->{"pull_$_->{TYPE}"} = 1;
                }
-               if (grep (/out/, @{$e->{DIRECTION}})) {
-                       $needed->{"push_$e->{TYPE}"} = 1;
+               if (grep(/out/, @{$_->{DIRECTION}})) {
+                       $needed->{"push_$_->{TYPE}"} = 1;
                }
        }
 }
@@ -861,20 +862,22 @@ sub NeededFunction($$)
 sub NeededTypedef($$)
 {
        my ($t,$needed) = @_;
-       if (Parse::Pidl::Util::has_property($t, "public")) {
-               $needed->{"pull_$t->{NAME}"} = not Parse::Pidl::Util::has_property($t, "noejs");
-               $needed->{"push_$t->{NAME}"} = not Parse::Pidl::Util::has_property($t, "noejs");
-       }
-       if ($t->{DATA}->{TYPE} ne "STRUCT" && 
-           $t->{DATA}->{TYPE} ne "UNION") {
-               return;
+
+       if (has_property($t, "public")) {
+               $needed->{"pull_$t->{NAME}"} = not has_property($t, "noejs");
+               $needed->{"push_$t->{NAME}"} = not has_property($t, "noejs");
        }
-       for my $e (@{$t->{DATA}->{ELEMENTS}}) {
-               if ($needed->{"pull_$t->{NAME}"}) {
-                       $needed->{"pull_$e->{TYPE}"} = 1;
+
+       return if (($t->{DATA}->{TYPE} ne "STRUCT") and 
+                          ($t->{DATA}->{TYPE} ne "UNION"));
+
+       foreach (@{$t->{DATA}->{ELEMENTS}}) {
+               next if (has_property($_, "subcontext")); #FIXME: Support subcontexts
+               unless (defined($needed->{"pull_$_->{TYPE}"})) {
+                       $needed->{"pull_$_->{TYPE}"} = $needed->{"pull_$t->{NAME}"};
                }
-               if ($needed->{"push_$t->{NAME}"}) {
-                       $needed->{"push_$e->{TYPE}"} = 1;
+               unless (defined($needed->{"push_$_->{TYPE}"})) {
+                       $needed->{"push_$_->{TYPE}"} = $needed->{"push_$t->{NAME}"};
                }
        }
 }
@@ -884,12 +887,9 @@ sub NeededTypedef($$)
 sub NeededInterface($$)
 {
        my ($interface,$needed) = @_;
-       foreach my $d (@{$interface->{FUNCTIONS}}) {
-           NeededFunction($d, $needed);
-       }
-       foreach my $d (reverse @{$interface->{TYPES}}) {
-           NeededTypedef($d, $needed);
-       }
+
+       NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}});
+       NeededTypedef($_, $needed) foreach (reverse @{$interface->{TYPES}});
 }
 
 1;