Page MenuHomePhabricator

eolian_mono: reduce duplicated code in OnXXXEvent
Needs ReviewPublic

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

Details

Reviewers
lauromoura
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
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 14502
Build 9974: arc lint + arc unit