* generator/Field.cs (Validate): new, to check that a field has a
valid type (or is hidden). * generator/StructBase.cs (Validate): new, to check that all of the struct fields have valid types * generator/BoxedGen.cs (Generate): * generator/StructGen.cs: (Generate): Call Validate() and bail out if it fails; it's no good to generate a struct with the wrong layout. * gdk/gdk-symbols.xml: add a line for GdkKey -> Gdk.Key. (There's no actual C type GdkKey, but we can use metadata to change uints to GdkKeys, which will then become Gdk.Keys.) * gtk/AccelKey.custom: remove the "Key" field (which was being added in the wrong place in the struct), since it's properly generated now. * gtk/Gtk.metadata: Fix the line that renames AccelKey.AccelKey to AccelKey.Key * gnomevfs/Gnomevfs.metadata: hide the (mis-parsed) "action" field in MimeAction, leaving the struct in the same broken state it was in with the old generator code svn path=/trunk/gtk-sharp/; revision=41104
This commit is contained in:
parent
65edda888f
commit
eb4269562f
9 changed files with 72 additions and 15 deletions
38
ChangeLog
38
ChangeLog
|
@ -1,3 +1,41 @@
|
|||
2005-02-17 Dan Winship <danw@novell.com>
|
||||
|
||||
* generator/Field.cs (Validate): new, to check that a field has a
|
||||
valid type (or is hidden).
|
||||
|
||||
* generator/StructBase.cs (Validate): new, to check that all of
|
||||
the struct fields have valid types
|
||||
|
||||
* generator/BoxedGen.cs (Generate):
|
||||
* generator/StructGen.cs: (Generate): Call Validate() and bail out
|
||||
if it fails; it's no good to generate a struct with the wrong
|
||||
layout.
|
||||
|
||||
* gdk/gdk-symbols.xml: add a line for GdkKey -> Gdk.Key. (There's
|
||||
no actual C type GdkKey, but we can use metadata to change uints
|
||||
to GdkKeys, which will then become Gdk.Keys.)
|
||||
|
||||
* gtk/AccelKey.custom: remove the "Key" field (which was being
|
||||
added in the wrong place in the struct), since it's properly
|
||||
generated now.
|
||||
|
||||
* gtk/Gtk.metadata: Fix the line that renames AccelKey.AccelKey
|
||||
to AccelKey.Key
|
||||
|
||||
* gnomevfs/Gnomevfs.metadata: hide the (mis-parsed) "action" field
|
||||
in MimeAction, leaving the struct in the same broken state it was
|
||||
in with the old generator code
|
||||
|
||||
* parser/gapi2xml.pl: add a hack to allow "foo_bar_get_type()"
|
||||
rather than "FOO_TYPE_BAR" in G_TYPE_CHECK_INSTANCE_CAST macros,
|
||||
allowing large parts of libgda that were previously misparsed to
|
||||
be parsed correctly
|
||||
|
||||
* gda/gda-api.raw: Regen
|
||||
|
||||
* gda/Gda.metadata: Make Gda.Value opaque, since it's mostly a
|
||||
union and we're horribly butchering its layout.
|
||||
|
||||
2005-02-22 Raja R Harinath <rharinath@novell.com>
|
||||
|
||||
* Makefile.include: Use $(top_builddir)/ instead of ../ so that it
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
<symbol type="manual" cname="GdkEventSetting" name="Gdk.EventSetting"/>
|
||||
<symbol type="manual" cname="GdkEventVisibility" name="Gdk.EventVisibility"/>
|
||||
<symbol type="manual" cname="GdkEventWindowState" name="Gdk.EventWindowState"/>
|
||||
<symbol type="simple" cname="GdkKey" name="Gdk.Key"/>
|
||||
</api>
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public override void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
if (!Validate ())
|
||||
return;
|
||||
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||
base.Generate (gen_info);
|
||||
sw.WriteLine ("\t\t[DllImport(\"glibsharpglue-2\")]");
|
||||
|
|
|
@ -147,16 +147,20 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public bool Generate (StreamWriter sw)
|
||||
public bool Validate ()
|
||||
{
|
||||
if (Hidden)
|
||||
return true;
|
||||
|
||||
if (CSType == "") {
|
||||
Console.WriteLine ("Field has unknown Type {0}", CType);
|
||||
if (CSType == "" && !Hidden) {
|
||||
Console.Write ("Field has unknown Type {0} ", CType);
|
||||
Statistics.ThrottledCount++;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw)
|
||||
{
|
||||
if (Hidden)
|
||||
return;
|
||||
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
|
||||
|
@ -218,8 +222,6 @@ namespace GtkSharp.Generation {
|
|||
} else {
|
||||
sw.WriteLine ("\t\tpublic {0} {1};", CSType, StudlyName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// GtkSharp.Generation.StructBase.cs - The Structure/Object Base Class.
|
||||
// GtkSharp.Generation.StructBase.cs - The Structure/Boxed Base Class.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
|
@ -40,7 +40,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
switch (node.Name) {
|
||||
case "field":
|
||||
fields.Add (member);
|
||||
fields.Add (new Field (member));
|
||||
break;
|
||||
|
||||
case "callback":
|
||||
|
@ -116,8 +116,7 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
Field.bitfields = 0;
|
||||
bool need_field = true;
|
||||
foreach (XmlElement field_elem in fields) {
|
||||
Field field = new Field (field_elem);
|
||||
foreach (Field field in fields) {
|
||||
if (field.IsBit) {
|
||||
if (need_field)
|
||||
need_field = false;
|
||||
|
@ -129,6 +128,18 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public bool Validate ()
|
||||
{
|
||||
foreach (Field field in fields) {
|
||||
if (!field.Validate ()) {
|
||||
Console.WriteLine ("in Struct " + QualifiedName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
bool need_close = false;
|
||||
|
|
|
@ -31,6 +31,9 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public override void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
if (!Validate ())
|
||||
return;
|
||||
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||
base.Generate (gen_info);
|
||||
if (GetMethod ("GetType") == null && GetMethod ("GetGType") == null) {
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<attr path="/api/namespace/struct[@cname='GnomeVFSInetConnection']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GnomeVFSMethod']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GnomeVFSMimeAction']" name="name">MimeAction</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GnomeVFSMimeAction']/field[@cname='action']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GnomeVFSMimeApplication']" name="name">MimeApplication</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GnomeVFSMimeSniffBuffer']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GnomeVFSModuleCallbackAdditionalHeadersIn']" name="hidden">1</attr>
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
public Gdk.Key Key;
|
||||
|
||||
public AccelKey (Gdk.Key key, Gdk.ModifierType mods, Gtk.AccelFlags flags)
|
||||
{
|
||||
this.Key = key;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<metadata>
|
||||
<attr path="/api/namespace/struct[@cname='GtkAccelKey']/field[@cname='accel_key']" name="type">GdkKey</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GtkAccelKey']/field[@cname='key']" name="cname">key</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GtkAccelKey']/field[@cname='accel_key']" name="name">Key</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GtkAccelKey']/field[@cname='accel_mods']" name="type">GdkModifierType</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GtkAccelKey']/field[@cname='accel_flags']" name="type">GtkAccelFlags</attr>
|
||||
<attr path="/api/namespace/struct[@cname='GtkActionEntry']" name="hidden">1</attr>
|
||||
|
|
Loading…
Reference in a new issue