svn commit: samba r7159 - in branches/SAMBA_4_0/source: build/pidl librpc/idl rpc_server/echo torture/rpc

jelmer at samba.org jelmer at samba.org
Wed Jun 1 00:00:58 GMT 2005


Author: jelmer
Date: 2005-06-01 00:00:50 +0000 (Wed, 01 Jun 2005)
New Revision: 7159

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

Log:
Improve the messages from pidl's validator module.
Change the IDL file for the echo interface to match the one we use for 
Windows. The only thing different between the two files currently is the 
names of the scalar types and the handling of strings.

Modified:
   branches/SAMBA_4_0/source/build/pidl/pidl.1.xml
   branches/SAMBA_4_0/source/build/pidl/validator.pm
   branches/SAMBA_4_0/source/librpc/idl/echo.idl
   branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c
   branches/SAMBA_4_0/source/torture/rpc/echo.c


Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/pidl.1.xml
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/pidl.1.xml	2005-06-01 00:00:08 UTC (rev 7158)
+++ branches/SAMBA_4_0/source/build/pidl/pidl.1.xml	2005-06-01 00:00:50 UTC (rev 7159)
@@ -19,15 +19,17 @@
 		<arg choice="opt">--output OUTNAME</arg>
 		<arg choice="opt">--parse</arg>
 		<arg choice="opt">--dump</arg>
-		<arg choice="opt">--header</arg>
-		<arg choice="opt">--parser</arg>
+		<arg choice="opt">--header[=OUTPUT]</arg>
+		<arg choice="opt">--parser[=OUTPUT]</arg>
 		<arg choice="opt">--server</arg>
 		<arg choice="opt">--template</arg>
-		<arg choice="opt">--eth-parser</arg>
-		<arg choice="opt">--eth-header</arg>
+		<arg choice="opt">--eth-parser[=OUTPUT]</arg>
+		<arg choice="opt">--eth-header[=OUTPUT]</arg>
 		<arg choice="opt">--diff</arg>
 		<arg choice="opt">--keep</arg>
 		<arg choice="req">idlfile</arg>
+		<arg choice="opt">idlfile2</arg>
+		<arg choice="opt">...</arg>
 	</cmdsynopsis>
 </refsynopsisdiv>
 
@@ -49,16 +51,17 @@
 		dissectors that can parse data sent over the 
 		wire by these interfaces. </para>
 
-	<para>pidl takes IDL files in the same format that is used by midl, 
+	<para>pidl takes IDL files in the same format as is used by midl, 
 		converts it to a .pidl file (which contains pidl's internal representation of the interface) and can then generate whatever output you need.
 		.pidl files should be used for debugging purposes only. Write your 
-		interface definitions in (midl) .idl format.
+		interface definitions in .idl format.
 	</para>
 
 	<para>
 		The goal of pidl is to implement a IDL compiler that can be used 
 		while developing the RPC subsystem in Samba (for 
-		both marshalling/un-marshalling and debugging purposes).</para>
+		both marshalling/unmarshalling and debugging purposes).
+	</para>
 
 </refsect1>
 
@@ -378,12 +381,6 @@
 	</refsect2>
 
 	<refsect2>
-		<title>Pointers</title>
-
-		<para>Pidl does not support "full" pointers in the DCE meaning of the word. However, its "unique" pointer is compatible with MIDL's full ("ptr") pointer support. </para>
-	</refsect2>
-
-	<refsect2>
 		<title>Datagram support</title>
 
 		<para>ncadg is not supported yet.</para>

Modified: branches/SAMBA_4_0/source/build/pidl/validator.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/validator.pm	2005-06-01 00:00:08 UTC (rev 7158)
+++ branches/SAMBA_4_0/source/build/pidl/validator.pm	2005-06-01 00:00:50 UTC (rev 7159)
@@ -149,6 +149,25 @@
 	}
 }
 
+sub mapToScalar($)
+{
+	my $t = shift;
+	my $ti = typelist::getType($t);
+
+	if (not defined ($ti)) {
+		return undef;
+	} elsif ($ti->{DATA}->{TYPE} eq "ENUM") {
+		return typelist::enum_type_fn($ti->{DATA});
+	} elsif ($ti->{DATA}->{TYPE} eq "BITMAP") {
+		return typelist::enum_type_fn($ti->{DATA});
+	} elsif ($ti->{DATA}->{TYPE} eq "SCALAR") {
+		return $t;
+	}
+
+	return undef;
+}
+
+
 #####################################################################
 # parse a struct
 sub ValidElement($)
@@ -174,9 +193,20 @@
 			my $discriminator_type = util::has_property($type, "switch_type");
 			$discriminator_type = "uint32" unless defined ($discriminator_type);
 
-			if ($e2->{TYPE} ne $discriminator_type) {
-				print el_name($e) . ": Warning: switch_is() is of type $e2->{TYPE}, while discriminator type for union $type->{NAME} is $discriminator_type\n";
+			my $t1 = mapToScalar($discriminator_type);
+
+			if (not defined($t1)) {
+				fatal($e, el_name($e) . ": unable to map discriminator type '$discriminator_type' to scalar");
 			}
+
+			my $t2 = mapToScalar($e2->{TYPE});
+			if (not defined($t2)) {
+				fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar");
+			}
+
+			if ($t1 ne $t2) {
+				nonfatal($e, el_name($e) . ": switch_is() is of type $e2->{TYPE} ($t2), while discriminator type for union $type->{NAME} is $discriminator_type ($t1)");
+			}
 		}
 	}
 

Modified: branches/SAMBA_4_0/source/librpc/idl/echo.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/echo.idl	2005-06-01 00:00:08 UTC (rev 7158)
+++ branches/SAMBA_4_0/source/librpc/idl/echo.idl	2005-06-01 00:00:50 UTC (rev 7159)
@@ -5,7 +5,6 @@
   uuid("60a15ec5-4de8-11d7-a637-005056a20182"),
   endpoint("ncacn_np:[\\pipe\\rpcecho]", "ncacn_ip_tcp:", "ncalrpc:"),
   pointer_default(unique),
-  pointer_default_top(unique),
   version(1.0),
   helpstring("Simple echo pipe")
 ]
@@ -13,7 +12,8 @@
 {
 	/* Add one to an integer */
 	void echo_AddOne(
-		[in,out,ref] uint32 *v
+		[in] uint32 in_data,
+		[out] uint32 *out_data
 	);
 	/* Echo an array of bytes back at the caller */
 	void echo_EchoData(
@@ -24,15 +24,14 @@
 	/* Sink data to the server */
 	void echo_SinkData(
 		[in] uint32 len,
-		[in,ref,size_is(len)] uint8 *data
+		[in,size_is(len)] uint8 data[]
 	);
 	/* Source data from server */
 	void echo_SourceData(
 		[in] uint32 len,
-		[out,ref,size_is(len)] uint8 *data
+		[out,size_is(len)] uint8 data[]
 	);
 
-
 	/* test strings */
  	void echo_TestCall (
 		[in]       unistr *s1,
@@ -67,10 +66,6 @@
 		echo_info1 info1;
 	} echo_info6;
 
-	typedef union {
-		[case(1)]  echo_info1 info1;
-	} echo_XXX;
-
 	typedef struct {
 		uint8 v1;
 		echo_info4 info4;
@@ -110,7 +105,7 @@
 		echo_Enum1_32 e2;
 	} echo_Enum2;
 
-	typedef [switch_type(echo_Enum1)] union {
+	typedef [switch_type(uint16)] union {
 		[case(ECHO_ENUM1)] echo_Enum1 e1;
 		[case(ECHO_ENUM2)] echo_Enum2 e2;
 	} echo_Enum3;
@@ -130,5 +125,5 @@
 		[in,out,ref] echo_Surrounding *data
 	);
 
-	uint16 echo_TestDoublePointer([in,ref] uint16 ***data);
+	uint16 echo_TestDoublePointer([in] uint16 ***data);
 }

Modified: branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c	2005-06-01 00:00:08 UTC (rev 7158)
+++ branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c	2005-06-01 00:00:50 UTC (rev 7159)
@@ -30,7 +30,7 @@
 
 static NTSTATUS echo_AddOne(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_AddOne *r)
 {
-	*r->out.v = *r->in.v + 1;
+	*r->out.out_data = r->in.in_data + 1;
 	return NT_STATUS_OK;
 }
 

Modified: branches/SAMBA_4_0/source/torture/rpc/echo.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/echo.c	2005-06-01 00:00:08 UTC (rev 7158)
+++ branches/SAMBA_4_0/source/torture/rpc/echo.c	2005-06-01 00:00:50 UTC (rev 7159)
@@ -39,8 +39,8 @@
 	for (i=0;i<10;i++) {
 		uint32_t n = i;
 		struct echo_AddOne r;
-		r.in.v = &n;
-		r.out.v = &n;
+		r.in.in_data = n;
+		r.out.out_data = &n;
 		status = dcerpc_echo_AddOne(p, mem_ctx, &r);
 		if (!NT_STATUS_IS_OK(status)) {
 			printf("AddOne(%d) failed - %s\n", i, nt_errstr(status));



More information about the samba-cvs mailing list