Example #1
0
                private static Eina.Error read(System.IntPtr obj, System.IntPtr pd, ref Eina.RwSlice rw_slice)
                {
                    Eina.Log.Debug("function efl_io_reader_read was called");
                    var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                    if (ws != null)
                    {
                        Eina.Error _ret_var = default(Eina.Error);
                        try
                        {
                            _ret_var = ((IReader)ws.Target).Read(ref rw_slice);
                        }
                        catch (Exception e)
                        {
                            Eina.Log.Warning($"Callback error: {e.ToString()}");
                            Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                        }

                        return(_ret_var);
                    }
                    else
                    {
                        return(efl_io_reader_read_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), ref rw_slice));
                    }
                }
                private static Eina.Error seek(System.IntPtr obj, System.IntPtr pd, long offset, Efl.Io.PositionerWhence whence)
                {
                    Eina.Log.Debug("function efl_io_positioner_seek was called");
                    var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                    if (ws != null)
                    {
                        Eina.Error _ret_var = default(Eina.Error);
                        try
                        {
                            _ret_var = ((IPositioner)ws.Target).Seek(offset, whence);
                        }
                        catch (Exception e)
                        {
                            Eina.Log.Warning($"Callback error: {e.ToString()}");
                            Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                        }

                        return(_ret_var);
                    }
                    else
                    {
                        return(efl_io_positioner_seek_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), offset, whence));
                    }
                }
Example #3
0
        /// <summary>Creates a new future that is already rejected to a specified error using the <see cref="Efl.LoopConsumer.GetLoop"/>.
        /// This function creates a new future with an already known error, that will be resolved and dispatched by the loop scheduler as usual.
        ///
        /// This is a helper that behaves the same as @ref eina_future_rejected.
        /// (Since EFL 1.22)</summary>
        /// <param name="error">An Eina_Error value</param>
        /// <returns>The future or <c>NULL</c> on error.</returns>
        virtual public Eina.Future FutureRejected(Eina.Error error)
        {
            var _ret_var = Efl.LoopConsumer.NativeMethods.efl_loop_future_rejected_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), error);

            Eina.Error.RaiseIfUnhandledException();
            return(_ret_var);
        }
Example #4
0
            private static Eina.Error property_string_add(System.IntPtr obj, System.IntPtr pd, System.String name, System.String definition, System.String not_ready, System.String on_error)
            {
                Eina.Log.Debug("function efl_view_model_property_string_add was called");
                var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                if (ws != null)
                {
                    Eina.Error _ret_var = default(Eina.Error);
                    try
                    {
                        _ret_var = ((ViewModel)ws.Target).AddPropertyString(name, definition, not_ready, on_error);
                    }
                    catch (Exception e)
                    {
                        Eina.Log.Warning($"Callback error: {e.ToString()}");
                        Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                    }

                    return(_ret_var);
                }
                else
                {
                    return(efl_view_model_property_string_add_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), name, definition, not_ready, on_error));
                }
            }
Example #5
0
 public static void basic_test()
 {
     Eina.Error.Clear();
     Eina.Error.Set(Eina.Error.ENOENT);
     Eina.Error err = Eina.Error.Get();
     Test.AssertEquals(err, Eina.Error.ENOENT);
 }
Example #6
0
        public static void test_object_promise_cancel()
        {
            Efl.Loop loop = Efl.App.AppMain;
            var      obj  = new Dummy.TestObject();

            Eina.Future future = obj.GetFuture();

            bool callbackCalled = false;

            Eina.Error receivedError = -1;
            Eina.Error sentError     = 120;
            future.Then((Eina.Value value) => {
                callbackCalled = true;
                Test.AssertEquals(value.GetValueType(), Eina.ValueType.Error);
                value.Get(out receivedError);

                return(value);
            });

            obj.RejectPromise(sentError);

            loop.Iterate();
            Test.Assert(callbackCalled, "Future callback must have been called.");
            Test.AssertEquals(receivedError, sentError);
        }
Example #7
0
            private static Eina.Error property_logic_add(System.IntPtr obj, System.IntPtr pd, System.String property, IntPtr get_data, EflViewModelPropertyGetInternal get, EinaFreeCb get_free_cb, IntPtr set_data, EflViewModelPropertySetInternal set, EinaFreeCb set_free_cb, System.IntPtr binded)
            {
                Eina.Log.Debug("function efl_view_model_property_logic_add was called");
                var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                if (ws != null)
                {
                    var _in_binded = new Eina.Iterator <System.String>(binded, false, false);
                    EflViewModelPropertyGetWrapper get_wrapper = new EflViewModelPropertyGetWrapper(get, get_data, get_free_cb);
                    EflViewModelPropertySetWrapper set_wrapper = new EflViewModelPropertySetWrapper(set, set_data, set_free_cb);
                    Eina.Error _ret_var = default(Eina.Error);
                    try
                    {
                        _ret_var = ((ViewModel)ws.Target).AddPropertyLogic(property, get_wrapper.ManagedCb, set_wrapper.ManagedCb, _in_binded);
                    }
                    catch (Exception e)
                    {
                        Eina.Log.Warning($"Callback error: {e.ToString()}");
                        Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                    }

                    return(_ret_var);
                }
                else
                {
                    return(efl_view_model_property_logic_add_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), property, get_data, get, get_free_cb, set_data, set, set_free_cb, binded));
                }
            }
Example #8
0
        public static void test_async_reject()
        {
            Efl.Loop loop = Efl.App.AppMain;
            var      obj  = new Dummy.TestObject();

            Task <Eina.Value> task = obj.GetFutureAsync();

            Eina.Error sentError = 1337;
            obj.RejectPromise(sentError);

            loop.Iterate();

            bool raised = false;

            try
            {
                Eina.Value v = task.Result;
            }
            catch (AggregateException ae)
            {
                raised = true;
                ae.Handle((x) =>
                {
                    Test.Assert(x is Efl.FutureException, "AggregateException must have been TaskCanceledException");
                    Efl.FutureException ex = x as Efl.FutureException;
                    Test.AssertEquals(ex.Error, sentError);
                    return(true);
                });
            }

            Test.Assert(raised, "AggregateException must have been raised.");
        }
Example #9
0
            private static Eina.Error property_logic_del(System.IntPtr obj, System.IntPtr pd, System.String property)
            {
                Eina.Log.Debug("function efl_view_model_property_logic_del was called");
                var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                if (ws != null)
                {
                    Eina.Error _ret_var = default(Eina.Error);
                    try
                    {
                        _ret_var = ((ViewModel)ws.Target).DelPropertyLogic(property);
                    }
                    catch (Exception e)
                    {
                        Eina.Log.Warning($"Callback error: {e.ToString()}");
                        Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                    }

                    return(_ret_var);
                }
                else
                {
                    return(efl_view_model_property_logic_del_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), property));
                }
            }
Example #10
0
        public static void test_simple_reject()
        {
            bool callbackCalled = false;

            Eina.Error received_error = Eina.Error.NO_ERROR;

            Efl.Loop     loop    = Efl.App.AppMain;
            Eina.Promise promise = new Eina.Promise();
            Eina.Future  future  = new Eina.Future(promise);

            future = future.Then((Eina.Value value) => {
                callbackCalled = true;
                value.Get(out received_error);
                return(value);
            });

            promise.Reject(Eina.Error.EPERM);

            loop.Iterate();

            Test.Assert(callbackCalled, "Future callback should have been called.");
            Test.AssertEquals(received_error, Eina.Error.EPERM);

            Test.AssertRaises <ObjectDisposedException>(() => { promise.Resolve(null); });
            Test.AssertRaises <ObjectDisposedException>(future.Cancel);
        }
Example #11
0
                private static Eina.Error file_set(System.IntPtr obj, System.IntPtr pd, System.String file)
                {
                    Eina.Log.Debug("function efl_file_set was called");
                    var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                    if (ws != null)
                    {
                        Eina.Error _ret_var = default(Eina.Error);
                        try
                        {
                            _ret_var = ((Layout)ws.Target).SetFile(file);
                        }
                        catch (Exception e)
                        {
                            Eina.Log.Warning($"Callback error: {e.ToString()}");
                            Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                        }

                        return(_ret_var);
                    }
                    else
                    {
                        return(efl_file_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), file));
                    }
                }
                private static Eina.Error property_bind(System.IntPtr obj, System.IntPtr pd, System.String key, System.String property)
                {
                    Eina.Log.Debug("function efl_ui_property_bind was called");
                    var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                    if (ws != null)
                    {
                        Eina.Error _ret_var = default(Eina.Error);
                        try
                        {
                            _ret_var = ((WidgetFactory)ws.Target).PropertyBind(key, property);
                        }
                        catch (Exception e)
                        {
                            Eina.Log.Warning($"Callback error: {e.ToString()}");
                            Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                        }

                        return(_ret_var);
                    }
                    else
                    {
                        return(efl_ui_property_bind_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), key, property));
                    }
                }
Example #13
0
 public static void TestErrorSimple()
 {
     using (Eina.Value v = new Eina.Value(Eina.ValueType.Error)) {
         Eina.Error error = new Eina.Error(Eina.Error.NO_ERROR);
         Test.Assert(v.Set(error));
         Eina.Error x;
         Test.Assert(v.Get(out x));
         Test.AssertEquals(error, x);
     }
 }
Example #14
0
        // return eina_error
        public static void eina_error_return()
        {
            var obj = new Dummy.TestObject();

            Eina.Error expected = 42;
            obj.SetErrorRet(expected);
            Eina.Error error = obj.ReturnsError();

            Test.AssertEquals(expected, error);

            expected = 0;
            obj.SetErrorRet(expected);
            error = obj.ReturnsError();

            Test.AssertEquals(expected, error);
        }
Example #15
0
        public static void event_with_error_payload()
        {
            var obj = new Dummy.TestObject();

            Eina.Error received_error = 0;

            obj.EvtWithErrorEvent += (object sender, Dummy.TestObjectEvtWithErrorEventArgs e) => {
                received_error = e.arg;
            };

            Eina.Error sent_error = -2001;

            obj.EmitEventWithError(sent_error);

            Test.AssertEquals(sent_error, received_error);
        }
Example #16
0
        public static void eina_error_return_from_inherited_virtual()
        {
            var obj = new ReturnOverride();

            Eina.Error expected = 42;
            obj.SetErrorRet(expected);
            Eina.Error error = obj.ReturnsError();

            Test.AssertEquals(new Eina.Error(expected * 2), error);

            expected = 0;
            obj.SetErrorRet(expected);
            error = obj.ReturnsError();

            Test.AssertEquals(new Eina.Error(expected * 2), error);
        }
Example #17
0
 private static Eina.Error resize(System.IntPtr obj, System.IntPtr pd, ulong size)
 {
     Eina.Log.Debug("function efl_io_sizer_resize was called");
     Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
     if (wrapper != null)
     {
         Eina.Error _ret_var = default(Eina.Error);
         try {
             _ret_var = ((ISizerConcrete)wrapper).Resize(size);
         } catch (Exception e) {
             Eina.Log.Warning($"Callback error: {e.ToString()}");
             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
         }
         return(_ret_var);
     }
     else
     {
         return(efl_io_sizer_resize_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), size));
     }
 }
Example #18
0
 private static Eina.Error load(System.IntPtr obj, System.IntPtr pd)
 {
     Eina.Log.Debug("function efl_file_load was called");
     Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
     if (wrapper != null)
     {
         Eina.Error _ret_var = default(Eina.Error);
         try {
             _ret_var = ((Layout)wrapper).Load();
         } catch (Exception e) {
             Eina.Log.Warning($"Callback error: {e.ToString()}");
             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
         }
         return(_ret_var);
     }
     else
     {
         return(efl_file_load_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))));
     }
 }
Example #19
0
 private static Eina.Error write(System.IntPtr obj, System.IntPtr pd, ref Eina.Slice slice, ref Eina.Slice remaining)
 {
     Eina.Log.Debug("function efl_io_writer_write was called");
     Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
     if (wrapper != null)
     {
         remaining = default(Eina.Slice);                      Eina.Error _ret_var = default(Eina.Error);
         try {
             _ret_var = ((Writer)wrapper).Write(ref slice, ref remaining);
         } catch (Exception e) {
             Eina.Log.Warning($"Callback error: {e.ToString()}");
             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
         }
         return(_ret_var);
     }
     else
     {
         return(efl_io_writer_write_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), ref slice, ref remaining));
     }
 }
Example #20
0
 private static Eina.Error mmap_set(System.IntPtr obj, System.IntPtr pd, Eina.File f)
 {
     Eina.Log.Debug("function efl_file_mmap_set was called");
     Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
     if (wrapper != null)
     {
         Eina.Error _ret_var = default(Eina.Error);
         try {
             _ret_var = ((IFileConcrete)wrapper).SetMmap(f);
         } catch (Exception e) {
             Eina.Log.Warning($"Callback error: {e.ToString()}");
             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
         }
         return(_ret_var);
     }
     else
     {
         return(efl_file_mmap_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), f));
     }
 }
Example #21
0
        public static void test_simple_future_cancel()
        {
            bool callbackCalled        = false;
            bool promiseCallbackCalled = false;

            Eina.Error received_error = Eina.Error.NO_ERROR;

            Eina.Promise promise = new Eina.Promise(() => { promiseCallbackCalled = true; });
            Eina.Future  future  = new Eina.Future(promise);

            future = future.Then((Eina.Value value) => {
                callbackCalled = true;
                value.Get(out received_error);
                return(value);
            });

            future.Cancel();

            Test.Assert(promiseCallbackCalled, "Promise cancel callback should have been called.");
            Test.Assert(callbackCalled, "Future callback should have been called.");
            Test.AssertEquals(received_error, Eina.Error.ECANCELED);
        }
Example #22
0
 internal static extern void efl_mono_thread_safe_promise_reject(IntPtr scheduler, Eina.Error reason);
Example #23
0
 internal static extern void eina_promise_reject(IntPtr scheduler, Eina.Error reason);
Example #24
0
 /// <summary>
 /// Rejects a promise.
 ///
 /// The future chain attached to this promise will be called with an Eina.Value of type
 /// Eina.ValueType.Error and payload Eina.Error.ECANCELED.
 /// </summary>
 public void Reject(Eina.Error reason)
 {
     SanityChecks();
     eina_promise_reject(this.Handle, reason);
     this.Handle = IntPtr.Zero;
 }
Example #25
0
 public override void SetErrorRet(Eina.Error err)
 {
     code = 2 * err;
 }
Example #26
0
            private static Eina.Future future_rejected(System.IntPtr obj, System.IntPtr pd, Eina.Error error)
            {
                Eina.Log.Debug("function efl_loop_future_rejected was called");

                var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);

                if (ws != null)
                {
                    Eina.Future _ret_var = default(Eina.Future);
                    try
                    {
                        _ret_var = ((LoopConsumer)ws.Target).FutureRejected(error);
                    }
                    catch (Exception e)
                    {
                        Eina.Log.Warning($"Callback error: {e.ToString()}");
                        Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
                    }

                    return(_ret_var);
                }
                else
                {
                    return(efl_loop_future_rejected_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), error));
                }
            }
Example #27
0
 /// <summary>Async wrapper for <see cref="FutureRejected" />.</summary>
 /// <param name="error">An Eina_Error value</param>
 /// <param name="token">Token to notify the async operation of external request to cancel.</param>
 /// <returns>An async task wrapping the result of the operation.</returns>
 public System.Threading.Tasks.Task <Eina.Value> FutureRejectedAsync(Eina.Error error, System.Threading.CancellationToken token = default(System.Threading.CancellationToken))
 {
     Eina.Future future = FutureRejected(error);
     return(Efl.Eo.Globals.WrapAsync(future, token));
 }
Example #28
0
 /// <summary>
 /// Sets a native environment variable.
 ///
 /// <para>Since EFL 1.24.</para>
 /// </summary>
 /// <param name="name">The name of the variable</param>
 /// <param name="value">The value to be set.</param>
 /// <param name="overwrite"><c>true</c> if an existing variable must be overwritten.</param>
 public static void SetEnv(string name, string value, bool overwrite = true)
 {
     Eina.Error error = Eina.NativeCustomExportFunctions.efl_mono_native_setenv(name, value, overwrite ? 1 : 0);
     Eina.Error.Raise(error);
 }