[mono/gtk-sharp] [2 commits] bc498ff6: generator: Add support for suppressing the Equals(T) method in structs
| Newsgroups | gmane.comp.gnome.mono.patches |
|---|---|
| Message-ID | <00000141a2cef0fd-0d458d7a-5865-4c4e-9543-9cd734afe710-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/gtk-sharp
Compare: https://github.com/mono/gtk-sharp/compare/90e834327e83...5f8e0953cf92
Commit: bc498ff65006ccf27db80dcf1f313f60aa22ca36
Author: Bertrand Lorentz <[email protected]> (bl8)
Date: 2013-10-10 14:27:13 GMT
URL: https://github.com/mono/gtk-sharp/commit/bc498ff65006ccf27db80dcf1f313f60aa22ca36
generator: Add support for suppressing the Equals(T) method in structs
Similarly to what exists for GetHashCode, add a noequals attribute to
indicate we don't want the default Equals implementation.
Changed paths:
M gapi.xsd
M generator/StructBase.cs
Modified: gapi.xsd
===================================================================
@@ -77,6 +77,7 @@
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="opaque" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
+ <xs:attribute name="noequals" type="xs:boolean" use="optional"/>
<xs:attribute name="nohash" type="xs:boolean" use="optional"/>
</xs:complexType>
Modified: generator/StructBase.cs
===================================================================
@@ -123,8 +123,6 @@ protected void GenEqualsAndHash (StreamWriter sw)
StringBuilder hashcode = new StringBuilder ();
StringBuilder equals = new StringBuilder ();
- sw.WriteLine ("\t\tpublic bool Equals ({0} other)", Name);
- sw.WriteLine ("\t\t{");
hashcode.Append ("this.GetType ().FullName.GetHashCode ()");
equals.Append ("true");
@@ -156,15 +154,20 @@ protected void GenEqualsAndHash (StreamWriter sw)
hashcode.Append (".GetHashCode ()");
}
}
- sw.WriteLine ("\t\t\treturn {0};", equals.ToString ());
- sw.WriteLine ("\t\t}");
- sw.WriteLine ();
+
+ if (!Elem.GetAttributeAsBoolean ("noequals")) {
+ sw.WriteLine ("\t\tpublic bool Equals ({0} other)", Name);
+ sw.WriteLine ("\t\t{");
+ sw.WriteLine ("\t\t\treturn {0};", equals.ToString ());
+ sw.WriteLine ("\t\t}");
+ sw.WriteLine ();
+ }
sw.WriteLine ("\t\tpublic override bool Equals (object other)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\treturn other is {0} && Equals (({0}) other);", Name);
sw.WriteLine ("\t\t}");
sw.WriteLine ();
- if (Elem.GetAttribute ("nohash") == "true")
+ if (Elem.GetAttributeAsBoolean ("nohash"))
return;
sw.WriteLine ("\t\tpublic override int GetHashCode ()");
sw.WriteLine ("\t\t{");
Commit: 5f8e0953cf92464b884dca9bd9ee03e84f951e9d
Author: Bertrand Lorentz <[email protected]> (bl8)
Date: 2013-10-10 14:28:37 GMT
URL: https://github.com/mono/gtk-sharp/commit/5f8e0953cf92464b884dca9bd9ee03e84f951e9d
gtk: Use native function for GtkTextIter.Equals(GtkTextIter)
As GtkTextIter has no public properties, the default generated Equals
implementation would be "return true;". We now suppress that and with a
fix-up now use the native gtk_text_iter_equal to implement the Equals
method.
Changed paths:
M gtk/Gtk.metadata
Modified: gtk/Gtk.metadata
===================================================================
@@ -35,9 +35,11 @@
<attr path="/api/namespace/boxed[@cname='GtkTargetEntry']" name="opaque">false</attr>
<attr path="/api/namespace/boxed[@cname='GtkTargetEntry']/field[@cname='flags']" name="type">GtkTargetFlags</attr>
<attr path="/api/namespace/boxed[@cname='GtkTextAttributes']/field[@cname='appearance']" name="hidden">1</attr>
+ <attr path="/api/namespace/boxed[@cname='GtkTextIter']" name="noequals">true</attr>
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='BackwardFindChar']/*/*[@name='pred']" name="scope">call</attr>
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='BackwardSearch']/*/*[@type='GtkTextIter*']" name="pass_as">out</attr>
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='Copy']" name="deprecated">1</attr>
+ <attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@cname='gtk_text_iter_equal']" name="name">Equals</attr>
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='ForwardFindChar']/*/*[@name='pred']" name="scope">call</attr>
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='ForwardSearch']/*/*[@type='GtkTextIter*']" name="pass_as">out</attr>
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='GetChar']" name="hidden">1</attr>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches