From 862ea14832a408101e8a155bcd44dfc99f3848cc Mon Sep 17 00:00:00 2001 From: Yeongjong Lee Date: Wed, 19 Jun 2019 15:59:54 +0900 Subject: [PATCH] efl_mono: support multilevel inheritance of NativeClass Summary: When it creates multilevel class of NativeClass, internal c function is not called because eo vtables aren't created Test Plan: Check "MyBox2 UpdateLayout" printed. ``` //mcs test_box.cs -out:test_box.exe `pkg-config --libs efl-mono` //mono test_box.exe using System; public class MyBox2 : MyBox { public MyBox2(Efl.Object parent, string style = null) : base(parent, style) { } public override void UpdateLayout() { Eina.Log.Error("MyBox2 UpdateLayout"); base.UpdateLayout(); } } public class MyBox : Efl.Ui.Box { public MyBox(Efl.Object parent, string style = null) : base(parent, style) { } public override void UpdateLayout() { Eina.Log.Error("MyBox UpdateLayout"); base.UpdateLayout(); } } public class Example : Efl.Csharp.Application { protected override void OnInitialize(Eina.Array args) { Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain); var box = new MyBox(win); box.SetHintSizeMin(new Eina.Size2D(360, 240)); win.SetContent(box); var box2 = new MyBox2(win); box2.SetHintSizeMin(new Eina.Size2D(360, 240)); box2.Pack(box); var button = new Efl.Ui.Button(box); button.SetText("Click"); button.ClickedEvt += (object sender, Efl.Ui.IClickableClickedEvt_Args e) => { box.CalculateGroup(); box2.CalculateGroup(); }; box.Pack(button); } public static void Main() { var example = new Example(); example.Launch(); } } ``` Reviewers: segfaultxavi, vitor.sousa, felipealmeida, lauromoura, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9079 --- src/bindings/mono/eo_mono/iwrapper.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs index 9e73ca4..5fe1daa 100644 --- a/src/bindings/mono/eo_mono/iwrapper.cs +++ b/src/bindings/mono/eo_mono/iwrapper.cs @@ -334,7 +334,16 @@ public class Globals public static byte class_initializer_call(IntPtr klass, System.Type type) { Eina.Log.Debug($"called with 0x{klass.ToInt64():x} {type}"); - Efl.Eo.NativeClass nativeClass = GetNativeClass(type.BaseType); + var derived = type.BaseType; + Efl.Eo.NativeClass nativeClass = GetNativeClass(derived); + + while (nativeClass == null) + { + derived = derived.BaseType; + if (derived == null) + break; + nativeClass = GetNativeClass(derived); + } if (nativeClass != null) { -- 2.7.4