Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/ORBit2/ChangeLog,v
retrieving revision 1.426
diff -u -p -r1.426 ChangeLog
--- ChangeLog	16 Oct 2002 09:27:54 -0000	1.426
+++ ChangeLog	16 Oct 2002 13:34:34 -0000
@@ -1,3 +1,17 @@
+2002-10-16  James Henstridge  <james@daa.com.au>
+
+	* src/idl-compiler/orbit-idl-c-imodule.c (ci_build_types): handle
+	types nested within structs and enums.
+
+	* test/everything/client.c (testIInterface): add a test to check
+	that the subnames array of the FixedLengthUnion typecode is
+	correct.
+
+	* src/idl-compiler/orbit-idl-c-typecode.c
+	(orbit_output_tcstruct_anon_subnames_array): when generating the
+	subnames array for unions, repeat the name once for each label
+	associated with the case statement.
+
 2002-10-16  Michael Meeks  <michael@ximian.com>
 
 	* test/everything/client.c (testIInterface):
Index: src/idl-compiler/orbit-idl-c-imodule.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/idl-compiler/orbit-idl-c-imodule.c,v
retrieving revision 1.9
diff -u -p -r1.9 orbit-idl-c-imodule.c
--- src/idl-compiler/orbit-idl-c-imodule.c	2 Oct 2002 07:35:29 -0000	1.9
+++ src/idl-compiler/orbit-idl-c-imodule.c	16 Oct 2002 13:34:35 -0000
@@ -82,12 +82,62 @@ ci_build_types (OIDL_C_Info *ci,
 
 	    break;
 	}
-	case IDLN_TYPE_UNION:
+	case IDLN_TYPE_STRUCT: {
+		gchar *id;
+		IDL_tree l;
+
+		id = orbit_cbe_get_typespec_str (tree);
+
+		fprintf (ci->fh, "\tTC_%s,\n", id);
+		(*count)++;
+
+		g_free (id);
+
+		/* check for nested structs/enums */
+		for (l = IDL_TYPE_STRUCT (tree).member_list; l; l = IDL_LIST (l).next) {
+			IDL_tree dcl;
+
+			g_assert (IDL_NODE_TYPE (IDL_LIST (l).data) == IDLN_MEMBER);
+			dcl = IDL_MEMBER (IDL_LIST (l).data).type_spec;
+
+			/* skip straight declarations */
+			if (IDL_NODE_TYPE(dcl) == IDLN_TYPE_STRUCT ||
+			    IDL_NODE_TYPE(dcl) == IDLN_TYPE_UNION)
+				ci_build_types (ci, dcl, count);
+		}
+		break;
+	};
+	case IDLN_TYPE_UNION: {
+		gchar *id;
+		IDL_tree l;
+
+		id = orbit_cbe_get_typespec_str (tree);
+
+		fprintf (ci->fh, "\tTC_%s,\n", id);
+		(*count)++;
+
+		g_free (id);
+
+		/* if discriminator is an enum, register it */
 		if (IDL_NODE_TYPE (IDL_TYPE_UNION (tree).switch_type_spec) == IDLN_TYPE_ENUM)
 			ci_build_types (
 				ci, IDL_TYPE_UNION (tree).switch_type_spec, count);
 
-	case IDLN_EXCEPT_DCL:       /* drop through */
+		/* check for nested structs/enums */
+		for (l = IDL_TYPE_UNION (tree).switch_body; l; l = IDL_LIST (l).next) {
+			IDL_tree dcl;
+
+			g_assert (IDL_NODE_TYPE (IDL_LIST (l).data) == IDLN_CASE_STMT);
+			dcl = IDL_MEMBER (
+                                IDL_CASE_STMT (IDL_LIST (l).data).element_spec).type_spec;
+
+			if (IDL_NODE_TYPE(dcl) == IDLN_TYPE_STRUCT ||
+			    IDL_NODE_TYPE(dcl) == IDLN_TYPE_UNION)
+				ci_build_types (ci, dcl, count);
+		}
+		break;
+	}
+	case IDLN_EXCEPT_DCL:
 	case IDLN_TYPE_INTEGER:
 	case IDLN_TYPE_ANY:
 	case IDLN_TYPE_STRING:
@@ -98,7 +148,6 @@ ci_build_types (OIDL_C_Info *ci,
 	case IDLN_TYPE_BOOLEAN:
 	case IDLN_TYPE_OCTET:
 	case IDLN_TYPE_SEQUENCE:
-	case IDLN_TYPE_STRUCT:
 	case IDLN_TYPE_ENUM:
 	case IDLN_IDENT:
 	case IDLN_FORWARD_DCL:
