generator: Mark instance_offset field as static

Those are per class and should not be overriden ever
This commit is contained in:
Thibault Saunier 2017-09-21 13:11:57 -03:00 committed by Harry
parent 9539c0b17b
commit d1457f6e03
2 changed files with 5 additions and 3 deletions

View file

@ -190,10 +190,12 @@ namespace GtkSharp.Generation {
protected virtual void WriteInstanceOffsetMethod(StreamWriter sw,
string cs_parent_struct) {
string cs_parent = SymbolTable.Table.GetCSType(Elem.GetAttribute("parent"));
if (cs_parent_struct == "")
sw.WriteLine ("\t\tpublic virtual uint instance_offset { get { return 0; }}");
sw.WriteLine ("\t\tpublic static uint instance_offset { get { return 0; }}");
else
sw.WriteLine ("\t\tpublic override uint instance_offset {{ get {{ return ((uint) Marshal.SizeOf(typeof ({0})) + base.instance_offset); }} }}", cs_parent_struct);
sw.WriteLine ("\t\tpublic static uint instance_offset {{ get {{ return ((uint) Marshal.SizeOf(typeof ({0})) + {1}.instance_offset); }} }}", cs_parent_struct, cs_parent);
}
protected void GenerateStructureABI (GenerationInfo gen_info)

View file

@ -823,7 +823,7 @@ namespace GLib {
public IntPtr g_class;
}
public virtual uint instance_offset { get { return 0; }}
public static uint instance_offset { get { return 0; }}
public uint GetFieldOffset(string field) { throw new NotImplementedException(); return 0; }
public struct GObject {
public GTypeInstance type_instance;