svn commit: samba r8268 - in branches/SAMBA_4_0/source: build/pidl/Parse/Pidl/Samba librpc librpc/idl

tridge at samba.org tridge at samba.org
Sun Jul 10 00:08:48 GMT 2005


Author: tridge
Date: 2005-07-10 00:08:48 +0000 (Sun, 10 Jul 2005)
New Revision: 8268

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8268

Log:
added the 'needed' logic to ehs generation, so we don't generate
functions we don't need. That is a lot of functions, as ejs is only
client side, so it only needs push functions for [out] vars, and pull
functions for [in] vars

added irpc and srvsvc IDL to list of available pipes.


Modified:
   branches/SAMBA_4_0/source/build/pidl/Parse/Pidl/Samba/EJS.pm
   branches/SAMBA_4_0/source/librpc/config.mk
   branches/SAMBA_4_0/source/librpc/idl/irpc.idl


Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/Parse/Pidl/Samba/EJS.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/Parse/Pidl/Samba/EJS.pm	2005-07-09 23:37:11 UTC (rev 8267)
+++ branches/SAMBA_4_0/source/build/pidl/Parse/Pidl/Samba/EJS.pm	2005-07-10 00:08:48 UTC (rev 8268)
@@ -122,11 +122,12 @@
 
 	return if (Parse::Pidl::Util::has_property($e, "value"));
 
-	$var = get_pointer_to($var);
-	# have to handle strings specially :(
-	if ($e->{TYPE} eq "string") {
-		$var = get_pointer_to($var);
-	}
+        my $pl = Parse::Pidl::NDR::GetPrevLevel($e, $l);
+        $var = get_pointer_to($var);
+        # have to handle strings specially :(
+        if ($e->{TYPE} eq "string" && $pl && $pl->{TYPE} eq "POINTER") {
+                $var = get_pointer_to($var);
+        }
 	pidl "NDR_CHECK(ejs_pull_$e->{TYPE}(ejs, v, $name, $var));";
 }
 
@@ -369,7 +370,11 @@
 sub EjsPushScalar($$$$$)
 {
 	my ($e, $l, $var, $name, $env) = @_;
-	$var = get_pointer_to($var);
+        # have to handle strings specially :(
+        my $pl = Parse::Pidl::NDR::GetPrevLevel($e, $l);
+        if ($e->{TYPE} ne "string" || ($pl && $pl->{TYPE} eq "POINTER")) {
+                $var = get_pointer_to($var);
+        }
 	pidl "NDR_CHECK(ejs_push_$e->{TYPE}(ejs, v, $name, $var));";
 }
 
@@ -645,17 +650,17 @@
 
 #####################################################################
 # parse the interface definitions
-sub EjsInterface($)
+sub EjsInterface($$)
 {
-	my($interface) = shift;
+	my($interface,$needed) = @_;
 	my @fns = ();
 	my $name = $interface->{NAME};
 
 	%constants = ();
 
 	foreach my $d (@{$interface->{TYPEDEFS}}) {
-		EjsTypedefPush($d);
-		EjsTypedefPull($d);
+		($needed->{"push_$d->{NAME}"}) && EjsTypedefPush($d);
+		($needed->{"pull_$d->{NAME}"}) && EjsTypedefPull($d);
 	}
 
 	foreach my $d (@{$interface->{FUNCTIONS}}) {
@@ -722,13 +727,68 @@
 #include \"$ejs_hdr\"
 
 ";
+
+    my %needed = ();
+
     foreach my $x (@{$ndr}) {
-	    if ($x->{TYPE} eq "INTERFACE") {
-		    ($x->{TYPE} eq "INTERFACE") && EjsInterface($x);
-	    }
+	    ($x->{TYPE} eq "INTERFACE") && NeededInterface($x, \%needed);
     }
 
+    foreach my $x (@{$ndr}) {
+	    ($x->{TYPE} eq "INTERFACE") && EjsInterface($x, \%needed);
+    }
+
     return $res;
 }
 
+
+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;
+		}
+		if (grep (/out/, @{$e->{DIRECTION}})) {
+			$needed->{"push_$e->{TYPE}"} = 1;
+		}
+	}
+}
+
+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;
+	}
+	for my $e (@{$t->{DATA}->{ELEMENTS}}) {
+		if ($needed->{"pull_$t->{NAME}"}) {
+			$needed->{"pull_$e->{TYPE}"} = 1;
+		}
+		if ($needed->{"push_$t->{NAME}"}) {
+			$needed->{"push_$e->{TYPE}"} = 1;
+		}
+	}
+}
+
+#####################################################################
+# work out what parse functions are needed
+sub NeededInterface($$)
+{
+	my ($interface,$needed) = @_;
+	foreach my $d (@{$interface->{FUNCTIONS}}) {
+	    NeededFunction($d, $needed);
+	}
+	foreach my $d (reverse @{$interface->{TYPEDEFS}}) {
+	    NeededTypedef($d, $needed);
+	}
+}
+
 1;

Modified: branches/SAMBA_4_0/source/librpc/config.mk
===================================================================
--- branches/SAMBA_4_0/source/librpc/config.mk	2005-07-09 23:37:11 UTC (rev 8267)
+++ branches/SAMBA_4_0/source/librpc/config.mk	2005-07-10 00:08:48 UTC (rev 8268)
@@ -629,10 +629,22 @@
 REQUIRED_SUBSYSTEMS = RPC NDR_NETLOGON
 NOPROTO = YES
 
+[SUBSYSTEM::RPC_EJS_SVCCTL]
+INIT_FUNCTION = ejs_init_svcctl
+OBJ_FILES = librpc/gen_ndr/ndr_svcctl_ejs.o
+REQUIRED_SUBSYSTEMS = RPC NDR_SVCCTL
+NOPROTO = YES
+
+[SUBSYSTEM::RPC_EJS_IRPC]
+INIT_FUNCTION = ejs_init_irpc
+OBJ_FILES = librpc/gen_ndr/ndr_irpc_ejs.o
+REQUIRED_SUBSYSTEMS = RPC NDR_IRPC
+NOPROTO = YES
+
 ################################################
 # Start SUBSYSTEM RPC_EJS
 [SUBSYSTEM::RPC_EJS]
 REQUIRED_SUBSYSTEMS = RPC_EJS_ECHO RPC_EJS_MISC RPC_EJS_SAMR RPC_EJS_SECURITY \
-	RPC_EJS_LSA 
+	RPC_EJS_LSA RPC_EJS_SRVSVC RPC_EJS_SVCCTL RPC_EJS_IRPC
 # End SUBSYSTEM RPC_EJS
 ################################################

Modified: branches/SAMBA_4_0/source/librpc/idl/irpc.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/irpc.idl	2005-07-09 23:37:11 UTC (rev 8267)
+++ branches/SAMBA_4_0/source/librpc/idl/irpc.idl	2005-07-10 00:08:48 UTC (rev 8268)
@@ -13,7 +13,7 @@
 		IRPC_FLAG_REPLY    = 0x0001
 	} irpc_flags;
 
-	typedef [public] struct {
+	typedef [public,noejs] struct {
 		GUID uuid;
 		uint32 if_version;
 		uint32 callnum;



More information about the samba-cvs mailing list