[Mono-devel-list] CodeGenerator doesn't support C Unions

Daniel Espinosa esodan at gmail.com
Thu Apr 14 13:09:50 EDT 2005


I try to know why there's a problem with Gda.Value; and searching I
found that some one change the code made from CodeGenerator to use
FieldOffset in cero for each element in the union that exist in
GdaValue struct:

typedef struct GdaValue {
   GdaValueType type;
   union {
                gint64 v_bigint;
 	        guint64 v_biguint;
		gpointer v_binary;
		GdaBlob v_blob;
		gboolean v_boolean;
		GdaDate v_date;
		gdouble v_double;
		GdaGeometricPoint v_point;
		GObject *v_gobj;
		gint v_integer;
		GdaValueList *v_list;
		GdaMoney v_money;
		GdaNumeric v_numeric;
		gfloat v_single;
		gshort v_smallint;
 	        gushort v_smalluint;
		gchar *v_string;
		GdaTime v_time;
		GdaTimestamp v_timestamp;
		gchar v_tinyint;
 	        guchar v_tinyuint;
		GdaValueType v_type;
		guint v_uinteger;
	} value;
}

There's no code to generate a union like in C# using CodeGenerator.

The StructBase object write the code but define:

[StructLayout(LayoutKind.Sequential)]

And in the case of union mus be:

[StructLayout(LayoutKind.Explicit)]

Then may need to create a UnionBase class to write the correct code,
or modify the StructBase class to admit in the constructor an argument
telling him the type of object (struct or union) and write the correct
sentence.

But now, the Field class, must have a metod to write the FiledOffset
attribute (allways in cero) to have a C union in C#.



More information about the Mono-devel-list mailing list