Page MenuHomePhabricator

eolian_mono: reduce duplicated code in OnXXXEvent
ClosedPublic

Authored by YOhoho on Nov 13 2019, 10:38 PM.

Details

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

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
YOhoho created this revision.Nov 13 2019, 10:38 PM
YOhoho requested review of this revision.Nov 13 2019, 10:38 PM
lauromoura accepted this revision.Dec 9 2019, 8:56 AM
This revision is now accepted and ready to land.Dec 9 2019, 8:56 AM
Closed by commit rEFL06c2bbf798ca: eolian_mono: reduce duplicated code in OnXXXEvent (authored by Yeongjong Lee <yj34.lee@samsung.com>, committed by lauromoura). · Explain WhyDec 9 2019, 8:57 AM
This revision was automatically updated to reflect the committed changes.