generator: Use parent structure fields whene generating ABI for fieldless structures
This commit is contained in:
parent
7d7036c9c6
commit
c02ee2eb1a
2 changed files with 21 additions and 5 deletions
|
@ -224,12 +224,24 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\t\tstatic public " + _new + "GLib.AbiStruct " + info_name + " {");
|
sw.WriteLine ("\t\tstatic public " + _new + "GLib.AbiStruct " + info_name + " {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\tif (_" + info_name + " == null)");
|
sw.WriteLine ("\t\t\t\tif (_" + info_name + " == null)");
|
||||||
sw.WriteLine ("\t\t\t\t\t_" + info_name + " = new GLib.AbiStruct (new List<GLib.AbiField>{ ");
|
|
||||||
|
|
||||||
// Generate Tests
|
// Generate Tests
|
||||||
if (_fields.Count > 0 && gen_info.CAbiWriter != null) {
|
var using_parent_fields = false;
|
||||||
gen_info.CAbiWriter.WriteLine("\tg_print(\"\\\"sizeof({0})\\\": \\\"%\" G_GOFFSET_FORMAT \"\\\"\\n\", sizeof({0}));", structname);
|
if (_fields.Count > 0) {
|
||||||
gen_info.AbiWriter.WriteLine("\t\t\tConsole.WriteLine(\"\\\"sizeof({0})\\\": \\\"\" + {1}.{2}." + info_name + ".Size + \"\\\"\");", structname, NS, Name);
|
sw.WriteLine ("\t\t\t\t\t_" + info_name + " = new GLib.AbiStruct (new List<GLib.AbiField>{ ");
|
||||||
|
|
||||||
|
if (gen_info.CAbiWriter != null) {
|
||||||
|
gen_info.CAbiWriter.WriteLine("\tg_print(\"\\\"sizeof({0})\\\": \\\"%\" G_GOFFSET_FORMAT \"\\\"\\n\", sizeof({0}));", structname);
|
||||||
|
gen_info.AbiWriter.WriteLine("\t\t\tConsole.WriteLine(\"\\\"sizeof({0})\\\": \\\"\" + {1}.{2}." + info_name + ".Size + \"\\\"\");", structname, NS, Name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (cs_parent_struct != "") {
|
||||||
|
sw.WriteLine ("\t\t\t\t\t_" + info_name + " = new GLib.AbiStruct ({0}.{1}.Fields);", cs_parent_struct, info_name);
|
||||||
|
using_parent_fields = true;
|
||||||
|
} else {
|
||||||
|
sw.WriteLine ("\t\t\t\t\t_" + info_name + " = new GLib.AbiStruct (new List<GLib.AbiField>{ ");
|
||||||
|
using_parent_fields = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StructABIField prev = null;
|
StructABIField prev = null;
|
||||||
|
@ -255,7 +267,8 @@ namespace GtkSharp.Generation {
|
||||||
gen_info.CAbiWriter.Flush();
|
gen_info.CAbiWriter.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("\t\t\t\t\t});");
|
if (!using_parent_fields)
|
||||||
|
sw.WriteLine ("\t\t\t\t\t});");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t\t\treturn _" + info_name + ";");
|
sw.WriteLine ("\t\t\t\treturn _" + info_name + ";");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
|
|
|
@ -35,6 +35,9 @@ namespace GLib {
|
||||||
public class AbiStruct {
|
public class AbiStruct {
|
||||||
public OrderedDictionary Fields = null;
|
public OrderedDictionary Fields = null;
|
||||||
|
|
||||||
|
public AbiStruct(OrderedDictionary fields) {
|
||||||
|
Fields = fields;
|
||||||
|
}
|
||||||
public AbiStruct(List<GLib.AbiField> fields) {
|
public AbiStruct(List<GLib.AbiField> fields) {
|
||||||
Fields = new OrderedDictionary();
|
Fields = new OrderedDictionary();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue