eolian_mono: reduce duplicated code in OnXXXEvent
authorYeongjong Lee <yj34.lee@samsung.com>
Mon, 9 Dec 2019 16:45:56 +0000 (13:45 -0300)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 9 Dec 2019 21:06:32 +0000 (06:06 +0900)
commit5784b57bfb4bdffb3106c32d8d38fa6c675771fd
tree7558ee97278adc18a59f7f461f693d47c3263d87
parent6bef2c2cb28214e0ef68a0da05938028c8b8e5ec
eolian_mono: reduce duplicated code in OnXXXEvent

Summary:
`CallNativeEventCallback` is used to reduce duplicated code.

E.g.

Before
```
protected virtual void OnFullscreenChangedEvent(Efl.Ui.WinFullscreenChangedEventArgs e)
{
    var key = "_EFL_UI_WIN_EVENT_FULLSCREEN_CHANGED";
    IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Elementary, key);
    if (desc == IntPtr.Zero)
    {
        Eina.Log.Error($"Failed to get native event {key}");
        return;
    }

    IntPtr info = Eina.PrimitiveConversion.ManagedToPointerAlloc(e.arg ? (byte) 1 : (byte) 0);
    try
    {
        Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
    }
    finally
    {
        Marshal.FreeHGlobal(info);
    }
}
```

After
```
protected virtual void OnFullscreenChangedEvent(Efl.Ui.WinFullscreenChangedEventArgs e)
{
    IntPtr info = Eina.PrimitiveConversion.ManagedToPointerAlloc(e.arg ? (byte) 1 : (byte) 0);
    CallNativeEventCallback("elementary", "_EFL_UI_WIN_EVENT_FULLSCREEN_CHANGED", info, (p) => Marshal.FreeHGlobal(p));
}
```

Test Plan: meson setup -Dbindings=mono,cxx -Dmono-beta=true

Reviewers: lauromoura

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10661
src/bin/eolian_mono/eolian/mono/events.hh
src/bindings/mono/eo_mono/EoWrapper.cs