2004-01-19 Mike Kestner <mkestner@ximian.com>

* art/Art.metadata : correct a couple symbolic array_lens
	* art/art-api.xml : regen
	* gdk/Gdk.metadata : correct a symbolic array_len
	* gdk/gdk-api.xml : regen
	* generator/Field.cs : generate array fields with MarshalAs
	attrs for correct marshaling.

svn path=/trunk/gtk-sharp/; revision=22261
This commit is contained in:
Mike Kestner 2004-01-19 17:05:53 +00:00
parent d1367eb515
commit 13c8647b1e
6 changed files with 36 additions and 9 deletions

View file

@ -1,3 +1,12 @@
2004-01-19 Mike Kestner <mkestner@ximian.com>
* art/Art.metadata : correct a couple symbolic array_lens
* art/art-api.xml : regen
* gdk/Gdk.metadata : correct a symbolic array_len
* gdk/gdk-api.xml : regen
* generator/Field.cs : generate array fields with MarshalAs
attrs for correct marshaling.
2004-01-18 Mike Kestner <mkestner@ximian.com>
* generator/Field.cs : refactored code from StructBase

View file

@ -1,5 +1,7 @@
<?xml version="1.0"?>
<metadata>
<attr path="//class[@cname='ArtAffine_']/method[@name='ToString']" name="name">ToStringArray</attr>
<attr path="//struct[@cname='ArtGradientStop']/field[@cname='color']" name="array_len">17</attr>
<attr path="//struct[@cname='ArtRender']/field[@cname='clear_color']" name="array_len">17</attr>
<attr path="//struct[@cname='ArtVpathDash']" name="opaque">1</attr>
</metadata>

View file

@ -165,7 +165,7 @@
</struct>
<struct name="GradientStop" cname="ArtGradientStop">
<field cname="offset" type="double" />
<field cname="color" array_len="ART_MAX_CHAN + 1" type="ArtPixMaxDepth" />
<field cname="color" type="ArtPixMaxDepth" array_len="17" />
</struct>
<struct name="IRect" cname="ArtIRect">
<field cname="x0" type="int" />
@ -315,7 +315,7 @@
<field cname="depth" type="int" />
<field cname="alpha_type" type="ArtAlphaType" />
<field cname="clear" type="art_boolean" />
<field cname="clear_color" array_len="ART_MAX_CHAN + 1" type="ArtPixMaxDepth" />
<field cname="clear_color" type="ArtPixMaxDepth" array_len="17" />
<field cname="opacity" type="art_u32" />
<field cname="compositing_mode" type="ArtCompositingMode" />
<field cname="alphagamma" type="ArtAlphaGamma*" />

View file

@ -51,6 +51,7 @@
<attr path="//object[@cname='GdkWindow']/method[@name='GetPointer']/*/*[@type='gint*']" name="pass_as">out</attr>
<attr path="//object[@cname='GdkWindow']/method[@name='GetPointer']/*/*[@type='GdkModifierType*']" name="pass_as">out</attr>
<attr path="//struct[@cname='GdkPixmapObject']" name="hidden">1</attr>
<attr path="//struct[@cname='GdkTimeCoord']/field[@cname='axes']" name="array_len">128</attr>
<attr path="//struct[@cname='GdkWindowObject']" name="hidden">1</attr>
</metadata>

View file

@ -2684,7 +2684,7 @@
</struct>
<struct name="TimeCoord" cname="GdkTimeCoord">
<field cname="time" type="guint32" />
<field cname="axes" array_len="GDK_MAX_TIMECOORD_AXES" type="gdouble" />
<field cname="axes" type="gdouble" array_len="128" />
</struct>
<alias name="WChar" cname="GdkWChar" type="guint32" />
<struct name="WindowAttr" cname="GdkWindowAttr">

View file

@ -21,12 +21,28 @@ namespace GtkSharp.Generation {
this.elem = elem;
}
public int ArrayLength {
get {
if (!IsArray)
return 0;
int result;
try {
result = Int32.Parse (elem.GetAttribute("array_len"));
} catch (Exception e) {
Console.Write ("Non-numeric array_len: " + elem.GetAttribute("array_len"));
Console.WriteLine (" warning: array field {0} incorrectly generated", Name);
result = 0;
}
return result;
}
}
public string CSType {
get {
string type = SymbolTable.Table.GetCSType (CType);
if (IsArray)
// FIXME
type = "IntPtr";
type += "[]";
else if (IsBit)
type = "uint";
else if ((IsPointer || SymbolTable.Table.IsOpaque (CType)) && type != "string")
@ -88,7 +104,7 @@ namespace GtkSharp.Generation {
get {
if (IsArray)
// FIXME
return "private";
return "public";
else if (IsBit || IsPadding || SymbolTable.Table.IsCallback (CType))
return "private";
else if ((IsPointer || SymbolTable.Table.IsOpaque (CType)) && CSType != "string")
@ -108,9 +124,8 @@ namespace GtkSharp.Generation {
SymbolTable table = SymbolTable.Table;
// FIXME
if (IsArray)
Console.WriteLine ("warning: array field {0} probably incorrectly generated", Name);
if (IsArray)
sw.WriteLine ("\t\t[MarshalAs (UnmanagedType.ByValArray, SizeConst=" + ArrayLength + ")]");
sw.WriteLine ("\t\t{0} {1} {2};", Protection, CSType, table.MangleName (Name));