Re: [Evolution-win32-devel] ORBit2 status: Workaround for hang, but new alignment problems



I wrote:
> True, have to add that. Unions behave like structs in this regard,
> don't they? Will add a test case for that, too, to everything.idl and
> associated test code.

OK, here are my current diffs to src/orb/orb-core/corba-any.c and
tets/everything. I added post-alignment for unions, and an array of
unions test. (Without the union post-alignment, the array of union
test indeed asserted.)

Cheers,
--tml

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 -p -u -4 -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	9 Feb 2005 00:11:43 -0000
@@ -111,26 +111,22 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 	switch (tc->kind) {
 	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;
 	case CORBA_tk_boolean:
@@ -139,17 +135,12 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 		giop_send_buffer_append (buf, *val, sizeof (CORBA_octet));
 		*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));
 
 		giop_send_buffer_append (buf,
@@ -157,48 +148,55 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 					ulval);
 		*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));
 		giop_send_buffer_append (buf, &endian_marker, 2);
@@ -206,15 +204,13 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 		*val = ((guchar *)*val) + sizeof (CORBA_wchar *);
 		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,
 					 sizeof (CORBA_unsigned_long));
@@ -256,14 +252,12 @@ 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;
 	case CORBA_tk_fixed:
@@ -402,9 +396,8 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_short:
 	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;
 		ptr = *val;
@@ -418,9 +411,8 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_long:
 	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;
 		ptr = *val;
@@ -433,9 +425,8 @@ 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;
 		ptr = *val;
@@ -447,9 +438,8 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		break;
 	}
 	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;
 		ptr = *val;
@@ -462,9 +452,8 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		break;
 	}
 	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;
 		ptr = *val;
@@ -478,9 +467,8 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		break;
 	}
 	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;
 		ptr = *val;
@@ -508,9 +496,8 @@ 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))
 			return TRUE;
@@ -519,11 +506,8 @@ 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;
 		if ((buf->cur + sizeof (CORBA_unsigned_long)) > buf->end)
@@ -542,52 +526,58 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		*val = ((guchar *)*val) + sizeof (CORBA_sequence_CORBA_octet);
 		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;
 
 		subtc = ORBit_get_union_tag (tc, (gconstpointer*)&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;
 		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;
 		i = *(CORBA_unsigned_long *)buf->cur;
@@ -603,9 +593,8 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 		break;
 	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;
 		i = *(CORBA_unsigned_long *)buf->cur;
@@ -652,9 +641,8 @@ ORBit_demarshal_value (CORBA_TypeCode  t
 	case CORBA_tk_sequence: {
 		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));
 		if ((buf->cur + sizeof (CORBA_long)) > buf->end)
@@ -796,48 +784,36 @@ ORBit_copy_value_core (gconstpointer *va
 	switch (tc->kind) {
 	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);
 		break;
 	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);
 		break;
@@ -850,10 +826,8 @@ ORBit_copy_value_core (gconstpointer *va
 		break;
 	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);
 		newany->_value = ORBit_copy_value (oldany->_value, oldany->_type);
@@ -862,16 +836,8 @@ ORBit_copy_value_core (gconstpointer *va
 		*newval = ((guchar *)*newval) + 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));
-		*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);
 		((CORBA_Principal *)*newval)->_release = CORBA_TRUE;
@@ -882,57 +848,61 @@ ORBit_copy_value_core (gconstpointer *va
 		*newval = ((guchar *)*newval) + sizeof (CORBA_Principal);
 		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 = GINT_TO_POINTER (GPOINTER_TO_INT (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);
 
-		*val = ((guchar *)*val) + union_size;
-		*newval = ((guchar *)*newval) + union_size;
+		*val = ((guchar *)*val) + ALIGN_VALUE (union_size, union_align);
+		*newval = ((guchar *)*newval) + ALIGN_VALUE (union_size, union_align);
 		break;
 	}
 	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 =
 			((CORBA_Principal *)*val)->_length;
@@ -984,10 +954,8 @@ 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);		\
 		return ret
@@ -1028,10 +996,8 @@ 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);
 		*b = ((guchar *) *b) + sizeof (CORBA_octet);
@@ -1039,10 +1005,8 @@ ORBit_value_equivalent (gpointer *a, gpo
 		return (ba && bb) || (!ba && !bb);
 	}
 
 	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 *);
 		return ret;
@@ -1052,21 +1016,16 @@ ORBit_value_equivalent (gpointer *a, gpo
   		return FALSE;
 
 	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);
 		return ret;
 
 	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);
 
 		ret = ORBit_any_equivalent (any_a, any_b, ev);
@@ -1078,29 +1037,32 @@ 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;
 	}
 
 	case CORBA_tk_sequence: {
 		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;
 
 		if (ap->_length != bp->_length)
@@ -1120,14 +1082,13 @@ 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);
 
@@ -1136,16 +1097,16 @@ 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;
 	}
 
 	case CORBA_tk_array:
Index: test/everything/arrayServer.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/arrayServer.c,v
retrieving revision 1.5
diff -p -u -4 -r1.5 arrayServer.c
--- test/everything/arrayServer.c	9 May 2003 01:10:52 -0000	1.5
+++ test/everything/arrayServer.c	9 Feb 2005 00:11:43 -0000
@@ -72,8 +72,36 @@ 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,
@@ -103,13 +131,63 @@ 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};
 POA_test_ArrayServer__vepv ArrayServer_vepv = { &ArrayServer_base_epv, &ArrayServer_epv };
Index: test/everything/client.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/client.c,v
retrieving revision 1.127
diff -p -u -4 -r1.127 client.c
--- test/everything/client.c	28 Jan 2005 15:46:51 -0000	1.127
+++ test/everything/client.c	9 Feb 2005 00:11:44 -0000
@@ -953,8 +953,79 @@ testMiscUnions (test_TestFactory   facto
   	g_assert (ev->_major == CORBA_NO_EXCEPTION);
 }
 
 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)
 {
   int i;
@@ -1011,8 +1082,37 @@ testOctetArray (test_ArrayServer   objre
   CORBA_free (retn);
 }
 
 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)
 {
   
@@ -1022,27 +1122,23 @@ testFixedLengthArray (test_TestFactory  
   g_assert (ev->_major == CORBA_NO_EXCEPTION);
 
   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]);
 
   for (i=0;i<test_SequenceLen;i++)
@@ -1058,11 +1154,8 @@ testVariableLengthArray (test_TestFactor
         CORBA_free (inoutArg[i]);
 
   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++) {
 	for (n1 = 0; n1 < 3; n1++) {
@@ -1074,8 +1167,80 @@ testVariableLengthArray (test_TestFactor
   CORBA_free (multidim);
 
 }
 
+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, 
 	     CORBA_Environment *ev)
@@ -2275,8 +2440,9 @@ run_tests (test_TestFactory   factory, 
 		testAnySequence (factory, ev);
 		testFixedLengthUnion (factory, ev);
 		testVariableLengthUnion (factory, ev);
 		testMiscUnions (factory, ev);
+		testUnionArray (factory, ev);
 		testFixedLengthArray (factory, ev);
 		testVariableLengthArray (factory, ev);
 		testAnyStrSeq (factory, ev);
 		testAnyLong (factory, ev);
Index: test/everything/everything.idl
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/everything.idl,v
retrieving revision 1.39
diff -p -u -4 -r1.39 everything.idl
--- test/everything/everything.idl	22 Dec 2004 13:24:10 -0000	1.39
+++ test/everything/everything.idl	9 Feb 2005 00:11:44 -0000
@@ -161,14 +161,18 @@ module test {
 	typedef octet OctetArray[SequenceLen];
 	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 {
 		attribute string foo;
@@ -256,8 +260,9 @@ module test {
 	case 22: StrArray2 d;
 	};
 
 	typedef sequence <VariableLengthUnion> unionSeq;
+	typedef FixedLengthUnion FixedLengthUnionArray[SequenceLen];
 
 	interface UnionServer {
 		FixedLengthUnion opFixed (in FixedLengthUnion    inArg, 
 					  inout FixedLengthUnion inoutArg,
@@ -269,8 +274,12 @@ 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 {
 		any opAnyStrSeq();
Index: test/everything/unionServer.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/unionServer.c,v
retrieving revision 1.4
diff -p -u -4 -r1.4 unionServer.c
--- test/everything/unionServer.c	9 May 2003 01:10:52 -0000	1.4
+++ test/everything/unionServer.c	9 Feb 2005 00:11:45 -0000
@@ -114,15 +114,69 @@ 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 = {
 	NULL,
 	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]