From d1457f6e031e7f30518d839eb9579f472409fa26 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 21 Sep 2017 13:11:57 -0300 Subject: [PATCH] generator: Mark instance_offset field as static Those are per class and should not be overriden ever --- Source/generator/ClassBase.cs | 6 ++++-- Source/glib/Object.cs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/generator/ClassBase.cs b/Source/generator/ClassBase.cs index fb6a6e86a..09a84b6d1 100644 --- a/Source/generator/ClassBase.cs +++ b/Source/generator/ClassBase.cs @@ -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) diff --git a/Source/glib/Object.cs b/Source/glib/Object.cs index 3e995ac1f..7adb3dc4b 100644 --- a/Source/glib/Object.cs +++ b/Source/glib/Object.cs @@ -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;