generic marshalling re-work ...



Hi guys,

	So - I did a little more testing / reading of Tor's great work, I fixed
a number of dynany problems, and I tested it on:

	x86, x86_64, Sparc 32 & Tor (I assume) did on Win32 :-)

	More testing on other architectures much appreciated ( a simple make
check in HEAD ORBit2 would help ) I'm particularly interested in

	Sparc 64 & PPC

	PPC has had problems before - perhaps these changes fix them - Dobey
any chance of a test there ?

	To emphasise this changes perhaps one of the hottest code-paths in the
ORB, that we've had the most difficulty getting right in the past so ...

	Patch attached - as committed to HEAD ORBit2.

	Thanks,

		Michael.

-- 
 michael meeks novell com  <><, Pseudo Engineer, itinerant idiot
? orbit2-zip
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/ORBit2/ChangeLog,v
retrieving revision 1.688
diff -u -p -u -r1.688 ChangeLog
--- ChangeLog	8 Feb 2005 22:11:19 -0000	1.688
+++ ChangeLog	11 Feb 2005 15:15:25 -0000
@@ -1,3 +1,30 @@
+2005-02-11  Michael Meeks  <michael meeks novel com>
+
+	* src/orb/dynamic/dynany.c
+	(DynamicAny_DynStruct_get_members),
+	(DynamicAny_DynStruct_set_members): add field
+	alignment logic now missing from ORBit_copy_value etc.
+
+2005-02-11  Tor Lillqvist  <tml novell com>
+
+	* src/orb/orb-core/corba-any.c
+	(ORBit_marshal_value, ORBit_demarshal_value),
+	(ORBit_copy_value_core, ORBit_value_equivalent):
+	re-work, bin pre-align: assume incoming ABI walking
+	data is aligned, do alignment only on outgoing
+	data & during struct/union walking.
+
+	* test/everything/arrayServer.c
+	(ArrayServer_opAlignHoleStructArray),
+	(ArrayServer_opStrArray): add.
+	* test/everything/unionServer.c
+	(UnionServer_opFixedLengthUnionArray): add
+
+	* test/everything/client.c (testUnionArray, testStrArray),
+	(testFixedLengthStructArray, testAlignHoleStructArray),
+	(testVariableLengthArray): add more beef to the regression
+	test suite.
+
 2005-02-08  Tor Lillqvist  <tml novell com>
 
 	* orbit2-zip.in: New file, expands to a script to be used for
Index: src/orb/dynamic/dynany.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/dynamic/dynany.c,v
retrieving revision 1.24
diff -u -p -u -r1.24 dynany.c
--- src/orb/dynamic/dynany.c	2 Feb 2005 15:28:04 -0000	1.24
+++ src/orb/dynamic/dynany.c	11 Feb 2005 15:15:25 -0000
@@ -1383,6 +1383,7 @@ DynamicAny_DynStruct_get_members (Dynami
 {
 	DynAny *dynany;
 	int i;
+	guint offset = 0;
 	gconstpointer src;
 	DynamicAny_NameValuePairSeq *retval;
 	CORBA_TypeCode tc;
@@ -1412,6 +1413,7 @@ DynamicAny_DynStruct_get_members (Dynami
 		CORBA_any      *any;
 		CORBA_TypeCode  subtc = tc->subtypes [i];
 		gpointer        to;
+		gconstpointer   tmpsrc;
 
 		retval->_buffer [i].id = CORBA_string_dup (tc->subnames [i]);
 		any = &retval->_buffer [i].value;
@@ -1419,8 +1421,10 @@ DynamicAny_DynStruct_get_members (Dynami
 		any->_type = (CORBA_TypeCode) CORBA_Object_duplicate (
 			(CORBA_Object) subtc, ev);
 		to = any->_value = ORBit_alloc_by_tc (subtc);
-		
-		ORBit_copy_value_core (&src, &to, subtc);
+		offset = ALIGN_VALUE (offset, subtc->c_align);
+		tmpsrc = src + offset;
+		ORBit_copy_value_core (&tmpsrc, &to, subtc);
+		offset += ORBit_gather_alloc_info (subtc);
 	}
 
 	return retval;
@@ -1433,6 +1437,7 @@ DynamicAny_DynStruct_set_members (Dynami
 {
 	DynAny *dynany;
 	int i;
+	guint offset = 0;
 	gpointer dest;
 	CORBA_TypeCode tc;
 
@@ -1477,8 +1482,13 @@ DynamicAny_DynStruct_set_members (Dynami
 	for (i = 0; i < value->_length; i++) {
 		DynamicAny_NameValuePair current = value->_buffer [i];
 		gconstpointer src = current.value._value;
+		CORBA_TypeCode subtc = tc->subtypes [i];
+		gpointer tmpdest;
 
-		ORBit_copy_value_core (&src, &dest, tc->subtypes [i]);
+		offset = ALIGN_VALUE (offset, subtc->c_align);
+		tmpdest = dest + offset;
+		ORBit_copy_value_core (&src, &tmpdest, subtc);
+		offset += ORBit_gather_alloc_info (subtc);
 	}
 }
 
@@ -1518,6 +1528,7 @@ DynamicAny_DynStruct_get_members_as_dyn_
 
 		retval->_buffer [i].id = CORBA_string_dup (tc->subnames [i]);
 
+		/* FIXME: this looks broken to me - why does src not advance ? */
 		retval->_buffer [i].value = dynany_create (subtc, src, dynany, ev);
 	}
 
Index: src/orb/orb-core/corba-any.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/corba-any.c,v
retrieving revision 1.63
diff -u -p -u -r1.63 corba-any.c
--- src/orb/orb-core/corba-any.c	17 Dec 2004 12:39:42 -0000	1.63
+++ src/orb/orb-core/corba-any.c	11 Feb 2005 15:15:25 -0000
@@ -40,10 +40,10 @@ ORBit_gather_alloc_info (CORBA_TypeCode 
 		int i, sum;
 
 		for (sum = i = 0; i < tc->sub_parts; i++) {
-			sum = GPOINTER_TO_INT (ALIGN_ADDRESS (sum, tc->subtypes[i]->c_align));
+			sum = ALIGN_VALUE (sum, tc->subtypes[i]->c_align);
 			sum += ORBit_gather_alloc_info (tc->subtypes[i]);
 		}
-		sum = GPOINTER_TO_INT (ALIGN_ADDRESS (sum, tc->c_align));
+		sum = ALIGN_VALUE (sum, tc->c_align);
 
 		return sum;
 	}
@@ -61,9 +61,9 @@ ORBit_gather_alloc_info (CORBA_TypeCode 
 			prev = MAX (prev, ORBit_gather_alloc_info (tc->subtypes[i]));
 		}
 		if (n >= 0)
-			sum = GPOINTER_TO_INT (ALIGN_ADDRESS (sum, tc->subtypes[n]->c_align));
+		  sum = ALIGN_VALUE (sum, tc->subtypes[n]->c_align);
 		sum += prev;
-		sum = GPOINTER_TO_INT (ALIGN_ADDRESS (sum, tc->c_align));
+		sum = ALIGN_VALUE (sum, tc->c_align);
 		return sum;
 	}
 	case CORBA_tk_wstring:
@@ -112,24 +112,20 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 	case CORBA_tk_wchar:
 	case CORBA_tk_ushort:
 	case CORBA_tk_short:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_SHORT);
 		giop_send_buffer_append_aligned (buf, *val, sizeof (CORBA_short));
 		*val = ((guchar *)*val) + sizeof (CORBA_short);
 		break;
 	case CORBA_tk_enum:
 	case CORBA_tk_long:
 	case CORBA_tk_ulong:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG);
 		giop_send_buffer_append_aligned (buf, *val, sizeof (CORBA_long));
 		*val = ((guchar *)*val) + sizeof (CORBA_long);
 		break;
 	case CORBA_tk_float:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_FLOAT);
 		giop_send_buffer_append_aligned (buf, *val, sizeof (CORBA_float));
 		*val = ((guchar *)*val) + sizeof (CORBA_float);
 		break;
 	case CORBA_tk_double:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_DOUBLE);
 		giop_send_buffer_append_aligned (buf, *val, sizeof (CORBA_double));
 		*val = ((guchar *)*val) + sizeof (CORBA_double);
 		break;
@@ -140,15 +136,10 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 		*val = ((guchar *)*val) + sizeof (CORBA_octet);
 		break;
 	case CORBA_tk_any:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_ANY);
 		ORBit_marshal_any (buf, *val);
 		*val = ((guchar *)*val) + sizeof (CORBA_any);
 		break;
 	case CORBA_tk_Principal:
-		*val = ALIGN_ADDRESS (*val, MAX (MAX (ORBIT_ALIGNOF_CORBA_LONG,
-						    ORBIT_ALIGNOF_CORBA_STRUCT),
-						    ORBIT_ALIGNOF_CORBA_POINTER));
-
 		ulval = *(CORBA_unsigned_long *) (*val);
 		giop_send_buffer_append (buf, *val, sizeof (CORBA_unsigned_long));
 
@@ -158,46 +149,53 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 		*val = ((guchar *)*val) + sizeof (CORBA_Principal);
 		break;
 	case CORBA_tk_objref:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		ORBit_marshal_object (buf, *(CORBA_Object *)*val);
 		*val = ((guchar *)*val) + sizeof (CORBA_Object);
 		break;
 	case CORBA_tk_TypeCode:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		ORBit_encode_CORBA_TypeCode (*(CORBA_TypeCode *)*val, buf);
 		*val = ((guchar *)*val) + sizeof (CORBA_TypeCode);
 		break;
 	case CORBA_tk_except:
-	case CORBA_tk_struct:
-		*val = ALIGN_ADDRESS (*val, tc->c_align);
-		for (i = 0; i < tc->sub_parts; i++)
+	case CORBA_tk_struct: {
+		gconstpointer val0 = *val;
+		int offset;
+		for (i = offset = 0; i < tc->sub_parts; i++) {
+			offset = ALIGN_VALUE (offset, tc->subtypes[i]->c_align);
+			*val = val0 + offset;
 			ORBit_marshal_value (buf, val, tc->subtypes[i]);
-		*val = ALIGN_ADDRESS (*val, tc->c_align);
+			offset += ORBit_gather_alloc_info (tc->subtypes[i]);
+		}
+		offset = ALIGN_VALUE (offset, tc->c_align);
+		*val = val0 + offset;
 		break;
+	}
 	case CORBA_tk_union: {
+		gconstpointer   val0 = *val;
 		gconstpointer	discrim, body;
 		CORBA_TypeCode 	subtc;
 		int             sz = 0;
 
-		discrim = *val = ALIGN_ADDRESS (*val, MAX (tc->discriminator->c_align, tc->c_align));
+		discrim = *val;
 		ORBit_marshal_value (buf, val, tc->discriminator);
 
 		subtc = ORBit_get_union_tag (tc, &discrim, FALSE);
 		for (i = 0; i < tc->sub_parts; i++)
 			sz = MAX (sz, ORBit_gather_alloc_info (tc->subtypes[i]));
 
-		body = *val = ALIGN_ADDRESS (*val, tc->c_align);
+		*val = val0 + ALIGN_VALUE (ORBit_gather_alloc_info (tc->discriminator),
+					   tc->c_align);
+		body = *val;
 		ORBit_marshal_value (buf, &body, subtc);
 		/* FIXME:
 		 * WATCHOUT: end of subtc may not be end of union
 		 */
-		*val = ((guchar *)*val) + sz;
+		*val = *val + ALIGN_VALUE (sz, tc->c_align);
 		break;
 	}
 	case CORBA_tk_wstring: {
 		CORBA_wchar endian_marker = 0xfeff;
 
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		ulval = (CORBA_wstring_len (*(CORBA_wchar **)*val) + 1) * 2;
 		giop_send_buffer_append_aligned (buf, &ulval,
 						 sizeof (CORBA_unsigned_long));
@@ -207,13 +205,11 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 		break;
 	}
 	case CORBA_tk_string:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		giop_send_buffer_append_string (buf, *(char **)*val);
 		*val = ((guchar *)*val) + sizeof (char *);
 		break;
 	case CORBA_tk_sequence: {
 		const CORBA_sequence_CORBA_octet *sval;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_SEQ);
 		sval = *val;
 		giop_send_buffer_align (buf, sizeof (CORBA_unsigned_long));
 		giop_send_buffer_append (buf, &sval->_length,
@@ -257,12 +253,10 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 		break;
 	case CORBA_tk_longlong:
 	case CORBA_tk_ulonglong:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG_LONG);
 		giop_send_buffer_append_aligned (buf, *val, sizeof (CORBA_long_long));
 		*val = ((guchar *)*val) + sizeof (CORBA_long_long);
 		break;
 	case CORBA_tk_longdouble:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG_DOUBLE);
 		giop_send_buffer_append_aligned (buf, *val, sizeof (CORBA_long_double));
 		*val = ((guchar *)*val) + sizeof (CORBA_long_double);
 		break;
@@ -403,7 +397,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_ushort:
 	case CORBA_tk_wchar: {
 		CORBA_unsigned_short *ptr;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_SHORT);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_short));
 		if ((buf->cur + sizeof (CORBA_short)) > buf->end)
 			return TRUE;
@@ -419,7 +412,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_ulong:
 	case CORBA_tk_enum: {
 		CORBA_unsigned_long *ptr;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_long));
 		if ((buf->cur + sizeof (CORBA_long)) > buf->end)
 			return TRUE;
@@ -434,7 +426,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_longlong:
 	case CORBA_tk_ulonglong: {
 		CORBA_unsigned_long_long *ptr;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG_LONG);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_long_long));
 		if ((buf->cur + sizeof (CORBA_long_long)) > buf->end)
 			return TRUE;
@@ -448,7 +439,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	}
 	case CORBA_tk_longdouble: {
 		CORBA_long_double *ptr;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG_DOUBLE);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_long_double));
 		if ((buf->cur + sizeof (CORBA_long_double)) > buf->end)
 			return TRUE;
@@ -463,7 +453,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	}
 	case CORBA_tk_float: {
 		CORBA_float *ptr;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_FLOAT);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_float));
 		if ((buf->cur + sizeof (CORBA_float)) > buf->end)
 			return TRUE;
@@ -479,7 +468,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	}
 	case CORBA_tk_double: {
 		CORBA_double *ptr;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_DOUBLE);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_double));
 		if ((buf->cur + sizeof (CORBA_double)) > buf->end)
 			return TRUE;
@@ -509,7 +497,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_any: {
 		CORBA_any *decoded;
 
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_ANY);
 		decoded = *val;
 		decoded->_release = CORBA_FALSE;
 		if (ORBit_demarshal_any (buf, decoded, orb))
@@ -520,9 +507,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_Principal: {
 		CORBA_Principal *p;
 
-		*val = ALIGN_ADDRESS (*val, MAX (ORBIT_ALIGNOF_CORBA_STRUCT,
-						 MAX (ORBIT_ALIGNOF_CORBA_LONG, ORBIT_ALIGNOF_CORBA_POINTER)));
-
 		p = *val;
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_long));
 		p->_release = TRUE;
@@ -543,33 +527,38 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		break;
 	}
 	case CORBA_tk_objref:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		if (ORBit_demarshal_object ((CORBA_Object *)*val, buf, orb))
 			return TRUE;
 		*val = ((guchar *)*val) + sizeof (CORBA_Object);
 		break;
 	case CORBA_tk_TypeCode:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		if (ORBit_decode_CORBA_TypeCode (*val, buf))
 			return TRUE;
 		*val = ((guchar *)*val) + sizeof (CORBA_TypeCode);
 		break;
 	case CORBA_tk_except:
-	case CORBA_tk_struct:
-		*val = ALIGN_ADDRESS (*val, tc->c_align);
-		for (i = 0; i < tc->sub_parts; i++) {
+	case CORBA_tk_struct: {
+		int offset;
+		gpointer val0 = *val;
+		for (i = offset = 0; i < tc->sub_parts; i++) {
+			offset = ALIGN_VALUE (offset, tc->subtypes[i]->c_align);
+			*val = val0 + offset;
 			if (ORBit_demarshal_value (tc->subtypes[i], val, buf, orb))
 				return TRUE;
+			offset += ORBit_gather_alloc_info (tc->subtypes[i]);
 		}
-		*val = ALIGN_ADDRESS (*val, tc->c_align);
+		offset = ALIGN_VALUE (offset, tc->c_align);
+		*val = val0 + offset;
 		break;
+	}
 	case CORBA_tk_union: {
+		gconstpointer   val0 = *val;
 		CORBA_TypeCode  subtc;
 		gpointer        discrim;
 		gpointer        body;
 		int	        sz = 0;
 
-		discrim = *val = ALIGN_ADDRESS (*val, MAX (tc->discriminator->c_align, tc->c_align));
+		discrim = *val;
 		if (ORBit_demarshal_value (tc->discriminator, val, buf, orb))
 			return TRUE;
 
@@ -577,16 +566,17 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		for (i = 0; i < tc->sub_parts; i++)
 			sz = MAX (sz, ORBit_gather_alloc_info (tc->subtypes[i]));
 
-		body = *val = ALIGN_ADDRESS (*val, tc->c_align);
+		*val = val0 + ALIGN_VALUE (ORBit_gather_alloc_info (tc->discriminator),
+					   tc->c_align);
+		body = *val;
 		if (ORBit_demarshal_value (subtc, &body, buf, orb))
 			return TRUE;
 
 		/* WATCHOUT: end subtc body may not be end of union */
-		*val = ((guchar *)*val) + sz;
+		*val = *val + ALIGN_VALUE (sz, tc->c_align);
 		break;
 	}
 	case CORBA_tk_string:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_long));
 		if ((buf->cur + sizeof (CORBA_long)) > buf->end)
 			return TRUE;
@@ -604,7 +594,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_wstring: {
 		CORBA_wchar endian_marker = 0, *ptr;
 
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_long));
 		if ((buf->cur + sizeof (CORBA_long)) > buf->end)
 			return TRUE;
@@ -653,7 +642,6 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		CORBA_sequence_CORBA_octet *p;
 		gpointer subval;
 
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_SEQ);
 		p = *val;
 		p->_release = TRUE;
 		buf->cur = ALIGN_ADDRESS (buf->cur, sizeof (CORBA_long));
@@ -797,8 +785,6 @@ ORBit_copy_value_core (gconstpointer *va
 	case CORBA_tk_wchar:
 	case CORBA_tk_short:
 	case CORBA_tk_ushort:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_SHORT);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_SHORT);
 		*(CORBA_short *)*newval = *(CORBA_short *)*val;
 		*val = ((guchar *)*val) + sizeof (CORBA_short);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_short);
@@ -806,37 +792,27 @@ ORBit_copy_value_core (gconstpointer *va
 	case CORBA_tk_enum:
 	case CORBA_tk_long:
 	case CORBA_tk_ulong:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_LONG);
 		*(CORBA_long *)*newval = *(CORBA_long *)*val;
 		*val = ((guchar *)*val) + sizeof (CORBA_long);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_long);
 		break;
 	case CORBA_tk_longlong:
 	case CORBA_tk_ulonglong:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG_LONG);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_LONG_LONG);
 		*(CORBA_long_long *)*newval = *(CORBA_long_long *)*val;
 		*val = ((guchar *)*val) + sizeof (CORBA_long_long);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_long_long);
 		break;
 	case CORBA_tk_longdouble:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_LONG_DOUBLE);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_LONG_DOUBLE);
 		*(CORBA_long_double *)*newval = *(CORBA_long_double *)*val;
 		*val = ((guchar *)*val) + sizeof (CORBA_long_double);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_long_double);
 		break;
 	case CORBA_tk_float:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_FLOAT);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_FLOAT);
 		*(CORBA_long *)*newval = *(CORBA_long *)*val;
 		*val = ((guchar *)*val) + sizeof (CORBA_float);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_float);
 		break;
 	case CORBA_tk_double:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_DOUBLE);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_DOUBLE);
 		*(CORBA_double *)*newval = *(CORBA_double *)*val;
 		*val = ((guchar *)*val) + sizeof (CORBA_double);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_double);
@@ -851,8 +827,6 @@ ORBit_copy_value_core (gconstpointer *va
 	case CORBA_tk_any: {
 		const CORBA_any *oldany;
 		CORBA_any *newany;
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_ANY);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_ANY);
 		oldany = *val;
 		newany = *newval;
 		newany->_type = ORBit_RootObject_duplicate (oldany->_type);
@@ -863,14 +837,6 @@ ORBit_copy_value_core (gconstpointer *va
 		break;
 	}
 	case CORBA_tk_Principal:
-		*val = ALIGN_ADDRESS (*val,
-				     MAX (MAX (ORBIT_ALIGNOF_CORBA_LONG,
-					     ORBIT_ALIGNOF_CORBA_STRUCT),
-					 ORBIT_ALIGNOF_CORBA_POINTER));
-		*newval = ALIGN_ADDRESS (*newval,
-					MAX (MAX (ORBIT_ALIGNOF_CORBA_LONG,
-						ORBIT_ALIGNOF_CORBA_STRUCT),
-					    ORBIT_ALIGNOF_CORBA_POINTER));
 		*(CORBA_Principal *)*newval = *(CORBA_Principal *)*val;
 		((CORBA_Principal *)*newval)->_buffer =
 			CORBA_sequence_CORBA_octet_allocbuf (((CORBA_Principal *)*newval)->_length);
@@ -883,36 +849,45 @@ ORBit_copy_value_core (gconstpointer *va
 		break;
 	case CORBA_tk_TypeCode:
 	case CORBA_tk_objref:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_POINTER);
 		*(CORBA_Object *)*newval = ORBit_RootObject_duplicate (*(CORBA_Object *)*val);
 		*val = ((guchar *)*val) + sizeof (CORBA_Object);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_Object);
 		break;
 	case CORBA_tk_struct:
-	case CORBA_tk_except:
-		*val = ALIGN_ADDRESS (*val, tc->c_align);
-		*newval = ALIGN_ADDRESS (*newval, tc->c_align);
-		for (i = 0; i < tc->sub_parts; i++)
+	case CORBA_tk_except: {
+		int offset;
+		gconstpointer val0 = *val;
+		gpointer newval0 = *newval;
+
+		for (i = offset = 0; i < tc->sub_parts; i++) {
+			offset = ALIGN_VALUE (offset, tc->subtypes[i]->c_align);
+			*val = val0 + offset;
+			*newval = ((guchar *)newval0 + offset);
 			ORBit_copy_value_core (val, newval, tc->subtypes[i]);
-		*val = ALIGN_ADDRESS (*val, tc->c_align);
-		*newval = ALIGN_ADDRESS (*newval, tc->c_align);
+			offset += ORBit_gather_alloc_info (tc->subtypes[i]);
+		}
+		offset = ALIGN_VALUE (offset, tc->c_align);
+		*val = val0 + offset;
+		*newval = newval0 + offset;
 		break;
+	}
 	case CORBA_tk_union: {
+		gconstpointer val0 = *val;
+		gpointer newval0 = *newval;
 		CORBA_TypeCode utc;
 		gint	       union_align = tc->c_align;
-		gint	       discrim_align = MAX (tc->discriminator->c_align, tc->c_align);
 		size_t	       union_size = ORBit_gather_alloc_info (tc);
 
-		pval1 = *val = ALIGN_ADDRESS (*val, discrim_align);
-		pval2 = *newval = ALIGN_ADDRESS (*newval, discrim_align);
+		pval1 = *val;
+		pval2 = *newval;
 
 		utc = ORBit_get_union_tag (tc, (gconstpointer *)val, FALSE);
 
 		ORBit_copy_value_core (&pval1, &pval2, tc->discriminator);
 
-		pval1 = ALIGN_ADDRESS (pval1, union_align);
-		pval2 = ALIGN_ADDRESS (pval2, union_align);
+		pval1 = val0 + ALIGN_VALUE (ORBit_gather_alloc_info (tc->discriminator),
+					    union_align);
+		pval2 = newval0 + (pval1 - val0);
 
 		ORBit_copy_value_core (&pval1, &pval2, utc);
 
@@ -922,16 +897,11 @@ ORBit_copy_value_core (gconstpointer *va
 	}
 	case CORBA_tk_wstring:
 	case CORBA_tk_string:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_POINTER);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_POINTER);
-	
 		*(CORBA_char **)*newval = CORBA_string_dup (*(CORBA_char **)*val);
 		*val = ((guchar *)*val) + sizeof (CORBA_char *);
 		*newval = ((guchar *)*newval) + sizeof (CORBA_char *);
 		break;
 	case CORBA_tk_sequence:
-		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_SEQ);
-		*newval = ALIGN_ADDRESS (*newval, ORBIT_ALIGNOF_CORBA_SEQ);
 		((CORBA_Principal *)*newval)->_release = CORBA_TRUE;
 		((CORBA_Principal *)*newval)->_length =
 			((CORBA_Principal *)*newval)->_maximum =
@@ -985,8 +955,6 @@ CORBA_any__copy (CORBA_any *out, const C
 
 #define ALIGN_COMPARE(a,b,tk,type,align)	\
 	case CORBA_tk_##tk:			\
-		*a = ALIGN_ADDRESS (*a, align);	\
-		*b = ALIGN_ADDRESS (*b, align);	\
 		ret = *(CORBA_##type *) *a == *(CORBA_##type *) *b;	\
 		*a = ((guchar *) *a) + sizeof (CORBA_##type);		\
 		*b = ((guchar *) *b) + sizeof (CORBA_##type);		\
@@ -1029,8 +997,6 @@ ORBit_value_equivalent (gpointer *a, gpo
 	case CORBA_tk_boolean: {
 		gboolean ba, bb;
 
-		*a = ALIGN_ADDRESS (*a, ORBIT_ALIGNOF_CORBA_OCTET);
-		*b = ALIGN_ADDRESS (*b, ORBIT_ALIGNOF_CORBA_OCTET);
 		ba = *(CORBA_octet *) *a;
 		bb = *(CORBA_octet *) *b;
 		*a = ((guchar *) *a) + sizeof (CORBA_octet);
@@ -1040,8 +1006,6 @@ ORBit_value_equivalent (gpointer *a, gpo
 	}
 
 	case CORBA_tk_string:
-		*a = ALIGN_ADDRESS (*a, ORBIT_ALIGNOF_CORBA_POINTER);
-		*b = ALIGN_ADDRESS (*b, ORBIT_ALIGNOF_CORBA_POINTER);
 		ret = !strcmp (*(char **)*a, *(char **)*b);
 		*a = ((guchar *) *a) + sizeof (CORBA_char *);
 		*b = ((guchar *) *b) + sizeof (CORBA_char *);
@@ -1053,8 +1017,6 @@ ORBit_value_equivalent (gpointer *a, gpo
 
 	case CORBA_tk_TypeCode:
 	case CORBA_tk_objref:
-		*a = ALIGN_ADDRESS (*a, ORBIT_ALIGNOF_CORBA_POINTER);
-		*b = ALIGN_ADDRESS (*b, ORBIT_ALIGNOF_CORBA_POINTER);
 		ret = CORBA_Object_is_equivalent (*a, *b, ev);
 		*a = ((guchar *) *a) + sizeof (CORBA_Object);
 		*b = ((guchar *) *b) + sizeof (CORBA_Object);
@@ -1063,9 +1025,6 @@ ORBit_value_equivalent (gpointer *a, gpo
 	case CORBA_tk_any: {
 		CORBA_any *any_a, *any_b;
 
-		*a = ALIGN_ADDRESS (*a, ORBIT_ALIGNOF_CORBA_POINTER);
-		*b = ALIGN_ADDRESS (*b, ORBIT_ALIGNOF_CORBA_POINTER);
-
 		any_a = *((CORBA_any **) *a);
 		any_b = *((CORBA_any **) *b);
 
@@ -1079,17 +1038,23 @@ ORBit_value_equivalent (gpointer *a, gpo
 
 	case CORBA_tk_struct:
 	case CORBA_tk_except: {
+		int offset;
+		gpointer a0 = *a;
+		gpointer b0 = *b;
 		int i;
 
-		*a = ALIGN_ADDRESS (*a, tc->c_align);
-		*b = ALIGN_ADDRESS (*b, tc->c_align);
-
-		for (i = 0; i < tc->sub_parts; i++)
+		for (i = offset = 0; i < tc->sub_parts; i++) {
+			offset = ALIGN_VALUE (offset, tc->subtypes[i]->c_align);
+			*a = a0 + offset;
+			*b = b0 + offset;
 			if (!ORBit_value_equivalent (a, b, tc->subtypes [i], ev))
 				return FALSE;
+			offset += ORBit_gather_alloc_info (tc->subtypes[i]);
+		}
 
-		*a = ALIGN_ADDRESS (*a, tc->c_align);
-		*b = ALIGN_ADDRESS (*b, tc->c_align);
+		offset = ALIGN_VALUE (offset, tc->c_align);
+		*a = a0 + offset;
+		*b = b0 + offset;
 		return TRUE;
 	}
 
@@ -1097,9 +1062,6 @@ ORBit_value_equivalent (gpointer *a, gpo
 		CORBA_Principal *ap, *bp;
 		gpointer a_val, b_val;
 
-		*a = ALIGN_ADDRESS (*a, ORBIT_ALIGNOF_CORBA_SEQ);
-		*b = ALIGN_ADDRESS (*b, ORBIT_ALIGNOF_CORBA_SEQ);
-			
 		ap = (CORBA_Principal *) *a;
 		bp = (CORBA_Principal *) *b;
 
@@ -1121,12 +1083,11 @@ ORBit_value_equivalent (gpointer *a, gpo
 	case CORBA_tk_union: {
 		CORBA_TypeCode utc_a, utc_b;
 		gint           union_align = tc->c_align;
-		gint           discrim_align = MAX (tc->discriminator->c_align, tc->c_align);
 		size_t         union_size = ORBit_gather_alloc_info (tc);
 		gpointer       a_orig, b_orig;
 
-		a_orig = *a = ALIGN_ADDRESS (*a, discrim_align);
-		b_orig = *b = ALIGN_ADDRESS (*b, discrim_align);
+		a_orig = *a;
+		b_orig = *b;
 
 		utc_a = ORBit_get_union_tag (tc, (gconstpointer *)a, FALSE);
 		utc_b = ORBit_get_union_tag (tc, (gconstpointer *)b, FALSE);
@@ -1137,14 +1098,14 @@ ORBit_value_equivalent (gpointer *a, gpo
 		if (!ORBit_value_equivalent (a, b, tc->discriminator, ev))
 			return FALSE;
 
-		*a = ALIGN_ADDRESS (*a, union_align);
-		*b = ALIGN_ADDRESS (*b, union_align);
-
+		*a = a_orig + ALIGN_VALUE (ORBit_gather_alloc_info (tc->discriminator),
+					   union_align);
+		*b = b_orig + (*a - a_orig);
 		if (!ORBit_value_equivalent (a, b, utc_a, ev))
 			return FALSE;
 
-		*a = ((guchar *) a_orig) + union_size;
-		*b = ((guchar *) b_orig) + union_size;
+		*a = ((guchar *) a_orig) + ALIGN_VALUE (union_size, union_align);
+		*b = ((guchar *) b_orig) + ALIGN_VALUE (union_size, union_align);
 		return TRUE;
 	}
 
Index: test/everything/arrayServer.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/arrayServer.c,v
retrieving revision 1.5
diff -u -p -u -r1.5 arrayServer.c
--- test/everything/arrayServer.c	9 May 2003 01:10:52 -0000	1.5
+++ test/everything/arrayServer.c	11 Feb 2005 15:15:25 -0000
@@ -73,13 +73,42 @@ ArrayServer_opOctetArray (PortableServer
   return retn; 
 }
 
+static test_FixedLengthStructArray_slice *
+ArrayServer_opFixedLengthStructArray(PortableServer_Servant _servant,
+				     const test_FixedLengthStructArray inArg,
+				     test_FixedLengthStructArray inoutArg,
+				     test_FixedLengthStructArray outArg,
+				     CORBA_Environment *ev){
+  int i;
+  test_FixedLengthStructArray_slice *retn;
+
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inArg[i].a==constants_SEQ_OCTET_IN[i]);
+
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inoutArg[i].a==constants_SEQ_OCTET_INOUT_IN[i]);
+
+  for(i=0;i<test_SequenceLen;i++)
+	inoutArg[i].a = constants_SEQ_OCTET_INOUT_OUT[i];
+  
+  for(i=0;i<test_SequenceLen;i++)
+	outArg[i].a = constants_SEQ_OCTET_OUT[i];
+	
+  retn = test_FixedLengthStructArray__alloc();
+
+  for(i=0;i<test_SequenceLen;i++)
+	retn[i].a = constants_SEQ_OCTET_RETN[i];
+      
+  return retn; 
+}
 
 static test_StrArray_slice *
 ArrayServer_opStrArray(PortableServer_Servant _servant,
 					   const test_StrArray inArg,
 					   test_StrArray inoutArg,
 					   test_StrArray_slice ** outArg,
-					   CORBA_Environment * ev){
+					   CORBA_Environment * ev)
+{
   int i;
   test_StrArray_slice *retn;
   for(i=0;i<test_SequenceLen;i++)
@@ -104,11 +133,62 @@ ArrayServer_opStrArray(PortableServer_Se
   return retn;  
 }
 
+static test_AlignHoleStructArray_slice *
+ArrayServer_opAlignHoleStructArray(PortableServer_Servant _servant,
+				   const test_AlignHoleStructArray inArg,
+				   test_AlignHoleStructArray inoutArg,
+				   test_AlignHoleStructArray outArg,
+				   CORBA_Environment * ev)
+{
+  int i;
+  test_AlignHoleStructArray_slice *retn;
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inArg[i].a.a==constants_SEQ_OCTET_IN[i]);
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inArg[i].a.b==constants_SEQ_OCTET_IN[i]);
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inArg[i].b==constants_SEQ_OCTET_IN[i]);
+
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inoutArg[i].a.a==constants_SEQ_OCTET_INOUT_IN[i]);
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inoutArg[i].a.b==constants_SEQ_OCTET_INOUT_IN[i]);
+  for(i=0;i<test_SequenceLen;i++)
+	g_assert(inoutArg[i].b==constants_SEQ_OCTET_INOUT_IN[i]);
+
+  for(i=0;i<test_SequenceLen;i++)
+	inoutArg[i].a.a = constants_SEQ_OCTET_INOUT_OUT[i];
+  for(i=0;i<test_SequenceLen;i++)
+	inoutArg[i].a.b = constants_SEQ_OCTET_INOUT_OUT[i];
+  for(i=0;i<test_SequenceLen;i++)
+	inoutArg[i].b = constants_SEQ_OCTET_INOUT_OUT[i];
+  
+  for(i=0;i<test_SequenceLen;i++)
+	outArg[i].a.a = constants_SEQ_OCTET_OUT[i];
+  for(i=0;i<test_SequenceLen;i++)
+	outArg[i].a.b = constants_SEQ_OCTET_OUT[i];
+  for(i=0;i<test_SequenceLen;i++)
+	outArg[i].b = constants_SEQ_OCTET_OUT[i];
+	
+  retn = test_AlignHoleStructArray__alloc();
+
+  for(i=0;i<test_SequenceLen;i++)
+	retn[i].a.a = constants_SEQ_OCTET_RETN[i];
+  for(i=0;i<test_SequenceLen;i++)
+	retn[i].a.b = constants_SEQ_OCTET_RETN[i];
+  for(i=0;i<test_SequenceLen;i++)
+	retn[i].b = constants_SEQ_OCTET_RETN[i];
+      
+  return retn;
+}
+
 POA_test_ArrayServer__epv ArrayServer_epv = {
   NULL,
   ArrayServer_opLongArray,
   ArrayServer_opOctetArray,
+  ArrayServer_opFixedLengthStructArray,
   ArrayServer_opStrArray,
+  ArrayServer_opAlignHoleStructArray,
 };
 
 PortableServer_ServantBase__epv ArrayServer_base_epv = {NULL, simple_finalize, NULL};
Index: test/everything/client.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/client.c,v
retrieving revision 1.127
diff -u -p -u -r1.127 client.c
--- test/everything/client.c	28 Jan 2005 15:46:51 -0000	1.127
+++ test/everything/client.c	11 Feb 2005 15:15:25 -0000
@@ -954,6 +954,77 @@ testMiscUnions (test_TestFactory   facto
 }
 
 static void
+testUnionArray (test_TestFactory   factory, 
+	        CORBA_Environment *ev)
+{
+	test_UnionServer                  obj;
+	test_FixedLengthUnionArray_slice *retn;
+	test_FixedLengthUnionArray        inArg;
+	test_FixedLengthUnionArray        inoutArg;
+	test_FixedLengthUnionArray        outArg;
+
+	d_print ("Testing union array...\n");
+	obj = test_TestFactory_getUnionServer (factory, ev);
+	g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+	inArg[0]._d = 'a';
+	inArg[0]._u.x = constants_LONG_IN;
+	inArg[1]._d = 'b';
+	inArg[1]._u.y = constants_CHAR_IN;
+	inArg[2]._d = 'c';
+	inArg[3]._d = 'e';
+	inArg[3]._u.v.a = constants_SHORT_IN;
+
+	inoutArg[0]._d = 'a';
+	inoutArg[0]._u.x = constants_LONG_INOUT_IN;
+	inoutArg[1]._d = 'b';
+	inoutArg[1]._u.y = constants_CHAR_INOUT_IN;
+	inoutArg[2]._d = 'c';
+	inoutArg[3]._d = 'e';
+	inoutArg[3]._u.v.a = constants_SHORT_INOUT_IN;
+	
+	retn = test_UnionServer_opFixedLengthUnionArray (obj, inArg, inoutArg, outArg, ev);
+	g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+	g_assert (inArg[0]._d == 'a');
+	g_assert (inArg[0]._u.x == constants_LONG_IN);
+	g_assert (inArg[1]._d == 'b');
+	g_assert (inArg[1]._u.y == constants_CHAR_IN);
+	g_assert (inArg[2]._d == 'c');
+	g_assert (inArg[3]._d == 'e');
+	g_assert (inArg[3]._u.v.a == constants_SHORT_IN);
+
+	g_assert (inoutArg[0]._d == 'a');
+	g_assert (inoutArg[0]._u.x == constants_LONG_INOUT_OUT);
+	g_assert (inoutArg[1]._d == 'b');
+	g_assert (inoutArg[1]._u.y == constants_CHAR_INOUT_OUT);
+	g_assert (inoutArg[2]._d == 'c');
+	g_assert (inoutArg[3]._d == 'e');
+	g_assert (inoutArg[3]._u.v.a == constants_SHORT_INOUT_OUT);
+	
+	g_assert (outArg[0]._d == 'a');
+	g_assert (outArg[0]._u.x == constants_LONG_OUT);
+	g_assert (outArg[1]._d == 'b');
+	g_assert (outArg[1]._u.y == constants_CHAR_OUT);
+	g_assert (outArg[2]._d == 'c');
+	g_assert (outArg[3]._d == 'e');
+	g_assert (outArg[3]._u.v.a == constants_SHORT_OUT);
+	
+	g_assert (retn[0]._d == 'a');
+	g_assert (retn[0]._u.x == constants_LONG_RETN);
+	g_assert (retn[1]._d == 'b');
+	g_assert (retn[1]._u.y == constants_CHAR_RETN);
+	g_assert (retn[2]._d == 'c');
+	g_assert (retn[3]._d == 'e');
+	g_assert (retn[3]._u.v.a == constants_SHORT_RETN);
+	
+	CORBA_free (retn);
+	
+	CORBA_Object_release (obj, ev);
+  	g_assert (ev->_major == CORBA_NO_EXCEPTION);
+}
+
+static void
 testLongArray (test_ArrayServer   objref,
 	       CORBA_Environment *ev)
 {
@@ -1012,6 +1083,35 @@ testOctetArray (test_ArrayServer   objre
 }
 
 static void
+testFixedLengthStructArray (test_ArrayServer   objref,
+			    CORBA_Environment *ev)
+{
+  int i;
+  test_FixedLengthStructArray inArg, inoutArg, outArg;
+  test_FixedLengthStructArray_slice *retn;
+
+  for (i=0;i<test_SequenceLen;i++)
+	inArg[i].a = constants_SEQ_OCTET_IN[i];
+
+  for (i=0;i<test_SequenceLen;i++)
+	inoutArg[i].a = constants_SEQ_OCTET_INOUT_IN[i];
+
+  retn = test_ArrayServer_opFixedLengthStructArray (objref, inArg, inoutArg, outArg, ev);
+  g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inArg[i].a==constants_SEQ_OCTET_IN[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inoutArg[i].a==constants_SEQ_OCTET_INOUT_OUT[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (outArg[i].a==constants_SEQ_OCTET_OUT[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (retn[i].a==constants_SEQ_OCTET_RETN[i]);
+
+  CORBA_free (retn);
+}
+
+static void
 testFixedLengthArray (test_TestFactory   factory, 
 		      CORBA_Environment *ev)
 {
@@ -1023,25 +1123,21 @@ testFixedLengthArray (test_TestFactory  
 
   testLongArray (objref, ev);
   testOctetArray (objref, ev);
+  testFixedLengthStructArray (objref, ev);
 
   CORBA_Object_release (objref, ev);
   g_assert (ev->_major == CORBA_NO_EXCEPTION);
 }
 
 static void
-testVariableLengthArray (test_TestFactory   factory, 
-			 CORBA_Environment *ev)
+testStrArray (test_ArrayServer   objref,
+	      CORBA_Environment *ev)
 {
-  test_ArrayServer objref;
   test_StrArray inArg, inoutArg;
   test_StrArray_slice *outArg, *retn;
   test_StrArrayMultiDimensional_slice *multidim;
   int i, n0, n1, n2;
   
-  d_print ("Testing arrays with variable length members...\n");
-  objref = test_TestFactory_getArrayServer (factory, ev);
-  g_assert (ev->_major == CORBA_NO_EXCEPTION);
-
   for (i=0;i<test_SequenceLen;i++)
 	inArg[i] = CORBA_string_dup (constants_SEQ_STRING_IN[i]);
 
@@ -1059,9 +1155,6 @@ testVariableLengthArray (test_TestFactor
 
   CORBA_free (outArg);
   CORBA_free (retn);
-  CORBA_Object_release (objref, ev);
-  g_assert (ev->_major == CORBA_NO_EXCEPTION);
-
   
   multidim = test_StrArrayMultiDimensional__alloc ();
   for (n0 = 0; n0 < 2; n0++) {
@@ -1075,6 +1168,78 @@ testVariableLengthArray (test_TestFactor
 
 }
 
+static void
+testAlignHoleStructArray (test_ArrayServer   objref,
+			  CORBA_Environment *ev)
+{
+  int i;
+  test_AlignHoleStructArray inArg, inoutArg, outArg;
+  test_AlignHoleStructArray_slice *retn;
+
+  for (i=0;i<test_SequenceLen;i++)
+	inArg[i].a.a = constants_SEQ_OCTET_IN[i];
+  for (i=0;i<test_SequenceLen;i++)
+	inArg[i].a.b = constants_SEQ_OCTET_IN[i];
+  for (i=0;i<test_SequenceLen;i++)
+	inArg[i].b = constants_SEQ_OCTET_IN[i];
+
+  for (i=0;i<test_SequenceLen;i++)
+	inoutArg[i].a.a = constants_SEQ_OCTET_INOUT_IN[i];
+  for (i=0;i<test_SequenceLen;i++)
+	inoutArg[i].a.b = constants_SEQ_OCTET_INOUT_IN[i];
+  for (i=0;i<test_SequenceLen;i++)
+	inoutArg[i].b = constants_SEQ_OCTET_INOUT_IN[i];
+
+  retn = test_ArrayServer_opAlignHoleStructArray (objref, inArg, inoutArg, outArg, ev);
+  g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inArg[i].a.a==constants_SEQ_OCTET_IN[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inArg[i].a.b==constants_SEQ_OCTET_IN[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inArg[i].b==(CORBA_char)constants_SEQ_OCTET_IN[i]);
+
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inoutArg[i].a.a==constants_SEQ_OCTET_INOUT_OUT[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inoutArg[i].a.b==constants_SEQ_OCTET_INOUT_OUT[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (inoutArg[i].b==(CORBA_char)constants_SEQ_OCTET_INOUT_OUT[i]);
+
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (outArg[i].a.a==constants_SEQ_OCTET_OUT[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (outArg[i].a.b==constants_SEQ_OCTET_OUT[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (outArg[i].b==(CORBA_char)constants_SEQ_OCTET_OUT[i]);
+
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (retn[i].a.a==constants_SEQ_OCTET_RETN[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (retn[i].a.b==constants_SEQ_OCTET_RETN[i]);
+  for (i=0;i<test_SequenceLen;i++)
+	g_assert (retn[i].b==(CORBA_char)constants_SEQ_OCTET_RETN[i]);
+
+  CORBA_free (retn);
+}
+
+static void
+testVariableLengthArray (test_TestFactory   factory, 
+			 CORBA_Environment *ev)
+{
+  test_ArrayServer objref;
+
+  d_print ("Testing arrays with variable length members...\n");
+  objref = test_TestFactory_getArrayServer (factory, ev);
+  g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+  testStrArray (objref, ev);
+  testAlignHoleStructArray (objref, ev);
+
+  CORBA_Object_release (objref, ev);
+  g_assert (ev->_major == CORBA_NO_EXCEPTION);
+}
 
 static void
 testAnyLong (test_TestFactory   factory, 
@@ -2276,6 +2441,7 @@ run_tests (test_TestFactory   factory, 
 		testFixedLengthUnion (factory, ev);
 		testVariableLengthUnion (factory, ev);
 		testMiscUnions (factory, ev);
+		testUnionArray (factory, ev);
 		testFixedLengthArray (factory, ev);
 		testVariableLengthArray (factory, ev);
 		testAnyStrSeq (factory, ev);
Index: test/everything/everything.idl
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/everything.idl,v
retrieving revision 1.39
diff -u -p -u -r1.39 everything.idl
--- test/everything/everything.idl	22 Dec 2004 13:24:10 -0000	1.39
+++ test/everything/everything.idl	11 Feb 2005 15:15:28 -0000
@@ -162,12 +162,16 @@ module test {
 	typedef long LongArray[SequenceLen];
 	typedef string StrArray[SequenceLen];
 	typedef string StrArrayMultiDimensional[SequenceLen][3][5];
+	typedef FixedLengthStruct FixedLengthStructArray[SequenceLen];
 	typedef VariableLengthStruct VariableLengthStructArray[SequenceLen];
+	typedef AlignHoleStruct AlignHoleStructArray[SequenceLen];
 
 	interface ArrayServer {
 		LongArray opLongArray(in LongArray inArg, inout LongArray inoutArg, out LongArray outArg);
 		OctetArray opOctetArray(in OctetArray inArg, inout OctetArray inoutArg, out OctetArray outArg);
+		FixedLengthStructArray opFixedLengthStructArray(in FixedLengthStructArray inArg, inout FixedLengthStructArray inoutArg, out FixedLengthStructArray outArg);
 		StrArray opStrArray(in StrArray inArg, inout StrArray inoutArg, out StrArray outArg);
+		AlignHoleStructArray opAlignHoleStructArray(in AlignHoleStructArray inArg, inout AlignHoleStructArray inoutArg, out AlignHoleStructArray outArg);
 	};
   
 	interface BasicServer {
@@ -257,6 +261,7 @@ module test {
 	};
 
 	typedef sequence <VariableLengthUnion> unionSeq;
+	typedef FixedLengthUnion FixedLengthUnionArray[SequenceLen];
 
 	interface UnionServer {
 		FixedLengthUnion opFixed (in FixedLengthUnion    inArg, 
@@ -270,6 +275,10 @@ module test {
 		EnumUnion opMisc (in unionSeq     inSeq,
 				  in BooleanUnion inArg,
 				  out ArrayUnion  outArg);
+
+		FixedLengthUnionArray opFixedLengthUnionArray (in FixedLengthUnionArray inArg,
+							       inout FixedLengthUnionArray inoutArg,
+							       out FixedLengthUnionArray outArg);
 	};
 
 	interface AnyServer {
Index: test/everything/unionServer.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/unionServer.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 unionServer.c
--- test/everything/unionServer.c	9 May 2003 01:10:52 -0000	1.4
+++ test/everything/unionServer.c	11 Feb 2005 15:15:28 -0000
@@ -115,6 +115,60 @@ UnionServer_opMisc (PortableServer_Serva
 	return retval;
 }
 
+static test_FixedLengthUnionArray_slice *
+UnionServer_opFixedLengthUnionArray(PortableServer_Servant _servant,
+				    const test_FixedLengthUnionArray inArg,
+				    test_FixedLengthUnionArray inoutArg,
+				    test_FixedLengthUnionArray outArg,
+				    CORBA_Environment *ev)
+{
+  test_FixedLengthUnionArray_slice *retn;
+
+  g_assert (inArg[0]._d == 'a');
+  g_assert (inArg[0]._u.x == constants_LONG_IN);
+  g_assert (inArg[1]._d == 'b');
+  g_assert (inArg[1]._u.y == constants_CHAR_IN);
+  g_assert (inArg[2]._d == 'c');
+  g_assert (inArg[3]._d == 'e');
+  g_assert (inArg[3]._u.v.a == constants_SHORT_IN);
+
+  g_assert (inoutArg[0]._d == 'a');
+  g_assert (inoutArg[0]._u.x == constants_LONG_INOUT_IN);
+  g_assert (inoutArg[1]._d == 'b');
+  g_assert (inoutArg[1]._u.y == constants_CHAR_INOUT_IN);
+  g_assert (inoutArg[2]._d == 'c');
+  g_assert (inoutArg[3]._d == 'e');
+  g_assert (inoutArg[3]._u.v.a == constants_SHORT_INOUT_IN);
+
+  inoutArg[0]._d = 'a';
+  inoutArg[0]._u.x = constants_LONG_INOUT_OUT;
+  inoutArg[1]._d = 'b';
+  inoutArg[1]._u.y = constants_CHAR_INOUT_OUT;
+  inoutArg[2]._d = 'c';
+  inoutArg[3]._d = 'e';
+  inoutArg[3]._u.v.a = constants_SHORT_INOUT_OUT;
+
+  outArg[0]._d = 'a';
+  outArg[0]._u.x = constants_LONG_OUT;
+  outArg[1]._d = 'b';
+  outArg[1]._u.y = constants_CHAR_OUT;
+  outArg[2]._d = 'c';
+  outArg[3]._d = 'e';
+  outArg[3]._u.v.a = constants_SHORT_OUT;
+
+  retn = test_FixedLengthUnionArray__alloc();
+
+  retn[0]._d = 'a';
+  retn[0]._u.x = constants_LONG_RETN;
+  retn[1]._d = 'b';
+  retn[1]._u.y = constants_CHAR_RETN;
+  retn[2]._d = 'c';
+  retn[3]._d = 'e';
+  retn[3]._u.v.a = constants_SHORT_RETN;
+
+  return retn;
+}
+
 PortableServer_ServantBase__epv UnionServer_base_epv = {NULL, simple_finalize, NULL};
 
 POA_test_UnionServer__epv UnionServer_epv = {
@@ -122,6 +176,7 @@ POA_test_UnionServer__epv UnionServer_ep
 	UnionServer_opFixed,
 	UnionServer_opVariable,
 	UnionServer_opMisc,
+	UnionServer_opFixedLengthUnionArray,
 };
 
 POA_test_UnionServer__vepv UnionServer_vepv = {&UnionServer_base_epv, &UnionServer_epv};


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]