Commit Graph

124 Commits

Author SHA1 Message Date
Lauro Moura 7daa2cffea csharp: Fix docs and hide stuff from stringshare.
Summary: ref T8293

Reviewers: segfaultxavi, brunobelo, felipealmeida, woohyun

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10325
2019-10-10 10:25:56 +02:00
Lauro Moura a3a72d5f17 csharp: Document eina_value.cs
Summary:
Added more docs alongside the since information.

For items that should be skipped from the end user of the binding but
must stay public for generated code,
`EditorBrowsable(EditorBrowsableState.Never)` was used.

ref T8293

Reviewers: brunobelo, felipealmeida, woohyun, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10313
2019-10-10 10:18:42 +02:00
Bruno da Silva Belo d9595d840d csharp: updating eina_iterator docs and hide api.
Summary: ref T8293

Reviewers: felipealmeida, lauromoura, segfaultxavi, woohyun

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10330
2019-10-10 01:47:38 -03:00
Bruno da Silva Belo 5e6a965a79 csharp: updating eina_inlist docs and hide api.
Summary: ref T8293

Reviewers: lauromoura, felipealmeida, segfaultxavi, woohyun

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10329
2019-10-10 01:16:46 -03:00
Bruno da Silva Belo fe93c519ab csharp: updating eina_inarray docs and hide api.
Reviewers: lauromoura, felipealmeida, segfaultxavi, woohyun

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10328
2019-10-10 01:06:06 -03:00
Bruno da Silva Belo 85c57500ea csharp: updating eina_binbuf docs and hide api.
Reviewers: felipealmeida, lauromoura, segfaultxavi, woohyun

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10310
2019-10-08 22:06:20 -03:00
Bruno da Silva Belo 3f4c7637db csharp: updating eina_accessor docs and hide api.
Reviewers: felipealmeida, lauromoura, segfaultxavi, woohyun

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10308
2019-10-08 21:52:14 -03:00
Bruno da Silva Belo 78cd5df179 csharp: removing extra //
Summary: dotnet warning about extras /

Reviewers: lauromoura, felipealmeida

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10282
2019-10-08 18:01:11 -03:00
Bruno da Silva Belo 04a49f5875 csharp: Standardizing doc tag.
Reviewers: felipealmeida, brunobelo, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10280
2019-10-04 08:51:04 +02:00
Bruno da Silva Belo 7b4a58313b csharp: More updated docs to 1.23.
Summary: eina_config and eina_common updated to 1.23.

Reviewers: lauromoura, felipealmeida, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10263
2019-10-02 12:03:35 +02:00
Lauro Moura b19953fe3a csharp: Add missing since docs to a bunch of classes.
Summary:
Proper documentation will come in later commits.

ref T8293

Reviewers: woohyun, felipealmeida, segfaultxavi, brunobelo

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10260
2019-10-01 00:10:15 -03:00
Bruno da Silva Belo 5ae7d92a1b csharp: add since 1.23 to eina_accessor.
Summary: updating to  since 1.23.

Reviewers: lauromoura, felipealmeida

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10257
2019-09-30 23:23:41 -03:00
Bruno da Silva Belo 33f5167089 mono_docs:adding and updating eina_binbuf.cs.
Summary: Generating docs and setting to 1.23.

Reviewers: lauromoura, felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10252
2019-09-30 23:15:27 -03:00
Bruno da Silva Belo 0194ba8420 mono-docs: adding and updating docs for eina_array.
Summary: Generating docs and setting to 1.23 for eina_array.cs

Reviewers: lauromoura, felipealmeida

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10251
2019-09-30 23:13:48 -03:00
Lauro Moura 465b049d5b csharp: Document Eina.List
Summary:
Also added Since 1.23 info

Depends on D10253o

ref T8293

Test Plan: Check docs

Reviewers: segfaultxavi, brunobelo, felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10254
2019-09-30 23:11:53 -03:00
Lauro Moura 74e79b5ae2 csharp: Allow improved cbs in eina comparators
Summary:
Instead of receiving a callback that compares two intptrs (which is
still used internally), expose a more C#-friendly delegate which is
wrapped into the native one.

Test Plan: run test suite

Reviewers: felipealmeida, segfaultxavi, brunobelo

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10253
2019-09-30 23:09:29 -03:00
Lauro Moura 16e21c3314 csharp: Document Eina.Log
Summary: ref T8293

Reviewers: brunobelo, segfaultxavi, felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10255
2019-09-30 23:06:06 -03:00
Lauro Moura 774bc73320 csharp: Add since to Eina.Promise
Summary: ref T8293

Reviewers: segfaultxavi, felipealmeida, brunobelo

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10256
2019-09-30 23:04:34 -03:00
Lauro Moura e973b87bf8 csharp: Fix Hash.DelByValue
Summary:
The C function `eina_hash_del_by_data` requires the same value that was
passed to the `add` function. As C# hashes store stuff through pointers
due to marshalling, this makes it hard to pass the same pointer for it.

So this functionality is implemented at C# level instead of relying on
the native function directly.

Fixes T8198

Thanks to @brunobelo and @singh.amitesh for the test case.

Reviewers: singh.amitesh, felipealmeida, brunobelo

Reviewed By: brunobelo

Subscribers: cedric, #reviewers, #committers, singh.amitesh, brunobelo

Tags: #efl

Maniphest Tasks: T8198

Differential Revision: https://phab.enlightenment.org/D9853
2019-09-13 19:22:39 -03:00
Bruno da Silva Belo 50a1572c09 csharp: Adding ToString methods to Strbuf and custommarshaler.
Summary:
WIN32 should use a allocator and deallocator different from EFL, sometimes, when
freeing a pointer, it should use win32_free. To stardardize, A custommarshaler
is used to fix this problem.

Fixes T8201

Reviewers: lauromoura, felipealmeida

Reviewed By: lauromoura

Subscribers: cedric, brunobelo, felipealmeida, #reviewers, lauromoura, #committers

Tags: #efl

Maniphest Tasks: T8201

Differential Revision: https://phab.enlightenment.org/D9842
2019-09-10 17:42:19 -03:00
Vitor Sousa c1b76d3008 csharp: fix ownership of value types in arrays and lists
Summary:
`eolian_mono` now considers the implicit ownership of value types in arrays and
lists when generating ownership flags.

Also, update manual bindings for arrays and lists to no longer free elements
in the `Dispose` method when the container has ownership of the elements
but C# itself does not have ownership of the container; the elements will be
freed by whoever owns the container.
Modifying and removing elements will still free them though.

Re-enabled unit tests that required ownership of value type elements.

Reviewers: felipealmeida, q66, vitor.sousa

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9457
2019-08-05 19:15:35 -03:00
Lauro Moura 29d24aa409 csharp: Add marshal support for Eina.ValueType
Summary:
It uses a custom marshaler and a helper boxing class to convert between
the managed enum values and the native Eina_Value_Type pointers.

To be used by future MVVM machinery.

Reviewers: vitor.sousa, felipealmeida

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9443
2019-07-30 11:47:07 -03:00
Lauro Moura 3b5d050353 csharp: Enable conversion of container Eina.Values
Summary:
When creating a new Value with any IEnumerable of a supported type, the IEnumerable
will be copied into an Eina.Value of type EINA_VALUE_ARRAY_TYPE.

Similarly, `Unwrap()` on a Eina.Value container will create a new
System.Collections.List<T> and return it.

Depends on D9272

Reviewers: felipealmeida, vitor.sousa, segfaultxavi

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl, #expertise_solutions

Differential Revision: https://phab.enlightenment.org/D9273
2019-07-11 15:57:32 -03:00
Lauro Moura 6be38caeae csharp: Add helpers to get/set Values from Objects
Summary:
The user can construct an `Eina.Value` from a plain C# `object`, using
reflection to get the correct type of object and construct the correct
underlying C value.

Also added the `Unwrap()` method to return a C# object representing the
wrapped value.

Both operations are useful when using `Eina.Value` to
Get/Set values from `PropertyInfo` targets as in

```
var v = new Eina.Value(propInfo.GetValue(sourceObj));
...
propInfo.SetValue(targetObj, v.Unwrap());
```

Currently, containers are not supported. It will be added in a following
commit.

Depends on D9270

Reviewers: felipealmeida, vitor.sousa, segfaultxavi

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9272
2019-07-11 15:55:04 -03:00
Vitor Sousa ec501a6623 csharp: fix some build warnings related with incorrect and missing documentation
Summary:
Some parameter names, tag names and cref identifiers in the documentation were
incorrect and causing warnings during compilation.
There were also warnings related with missing documentation in publicly
visible elements in the manual binding.

This commit fixes these incorrections and adds documentation to the manual
binding in order to solve these compilation warnings.

Warnings related with missing documentation in `.eo` files are still present.

Test Plan: Just compile with mono binding.

Reviewers: lauromoura, felipealmeida, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9243
2019-07-08 17:20:08 +02:00
Lauro Moura 00a1a203a5 csharp: Fix Future callback lifetime
Assigning a method directly to a field expecting a delegate creates a
delegate on the fly. This delegate can be collected normally as any
collectable object. In dotnet the GC is more aggressive, causing this
delegate to be collected and C trying to call an invalid function.

To avoid this, we create a static delegate that will be passed to C. Its
lifetime will be tied to the static method it wraps.
2019-07-05 09:57:23 +09:00
Vitor Sousa 229b363f01 csharp: fix some compilation warnings
Fix unused variable warnings in eina_mono and unit test files.
2019-06-28 10:58:24 -03:00
Vitor Sousa 4496022a3c csharp: fix Eina_Stringshare support in containers for manual and generated API
Summary:
Both C strings and eina stringshares are bound as regular strings in EFL#, as
working directly with these types would demand unnecessary hassle from the user
viewpoint.
But for eina containers this distinction is important, and since C# generics
do not provide a convenient way of dealing with the same type requiring a
different management based on some other condition (at least not without
compromising the usability for other types), we added a simple `System.String`
wrapper named `Eina.Stringshare` that works as a placeholder for signaling
this distinction.

Working with this class should be transparent in most use cases because it
converts to and from `System.String` implicitly.
It also implements equality/inequality methods for easier comparison with
strings and other stringshare objects.

Add new methods and a new container element trait for dealing specifically
with `Eina_Stringshare` elements.

Adapt eolian_mono to identify and generate the proper placeholder in methods
that require stringshare containers.

Remove some direct uses of DllImport-ed functions in favor of more flexible
manual binding methods.

Move `Eina.Stringshare` DllImport directives to a static class named
`NativeMethods`, in accordance with the code design warning CA1060.
Also add a TODO comment to move all other DllImport directives to this class.

Change parameter of the method `Efl.Csharp.Application.OnInitialize` from
`Eina.Array<System.String>` to `string[]`.
This will make this API more similar with the default C# way of receiving
command line arguments.

Add tests for containers storing stringshare elements.

Reviewers: felipealmeida, lauromoura, segfaultxavi, bu5hm4n

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9178
2019-06-28 10:44:52 -03:00
Lauro Moura ef185e5e28 efl-mono: Fix value forwarding in promises/async
Summary:
Values returned from C# Then callbacks must release ownership of the
underlying native value, so Eina code can clean it up nicely and avoid
the Wrapper flushing it early.

The same issue applied to the Async wrappers. In this case the value
passed as the Task parameter could be released by an `using` block
awaiting the value.

Also Future creation was then-ing the wrong handle.

Also add better exception messages.

Reviewers: vitor.sousa, felipealmeida

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9197
2019-06-27 19:31:55 -03:00
Lauro Moura 967e32d27a csharp: Update after iterator changes
Summary:
Iterator and Accessors are views only, not owning the data they point
to.

Also updated the tests by handling some test data that were leaking.

Fixes T8036

Reviewers: vitor.sousa, felipealmeida

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers, segfaultxavi, q66

Tags: #efl

Maniphest Tasks: T8036

Differential Revision: https://phab.enlightenment.org/D9189
2019-06-27 14:07:33 -03:00
Felipe Magno de Almeida 907bdad065 efl-mono: Add object type support for Eina.Value
Summary:
C# `Eina.Value` now has builtin support for `EINA_VALUE_TYPE_OBJECT`.

To avoid ambiguity with the `Set` method overloads, explicit casting
operators were used for wrapping/unwrapping `Efl.Object` instead of
implicit ones like for other value types.

Thus, to initialize an `Eina.Value` from an object, you can use the
following:

`var v = (Eina.Value)myObj;`

Reviewers: felipealmeida, vitor.sousa, segfaultxavi, Jaehyun_Cho

Reviewed By: Jaehyun_Cho

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9164
2019-06-25 19:11:23 +09:00
Vitor Sousa fcf5f1d2e2 csharp: Refactor wrapper lifetime.
Summary:
This commit makes use of the `ownership,shared` and `ownership,unique`
events from Efl.Object in order to avoid the C# wrapper from being
collected while C code holds a reference to the object.

For example, creating a list of items in a for loop and attaching events to
them would fails without this commit, as the C# GC may collect the wrapper.

The basic idea is that we use a `WrapperSupervisor`, which is stored in
the Eo data storage, with a GCHandle allocated for the lifetime of the
underlying Eo object. This supervisor takes care of holding either a
weak C# reference (when in unique mode, allowing the wrapper to be GC'd)
or a hard C# reference (when in shared mode, making the wrapper
non-collectable while the Eo has extra references).

One limitation is that object graphs can leak if a shared object in the
graph - an Eo child for example - stores a hard reference to another
object in the graph as a C# field. In this example, this causes the
parent to always have a hard C# reference (from the child) as the child
is non-collectable due to the parent holding an Eo reference to it.

Depends on D8678

Test Plan: `ninja test` and `make test`

Reviewers: lauromoura, felipealmeida, woohyun, segfaultxavi

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9014
2019-05-31 17:44:12 -03:00
Lauro Moura d775b58a63 csharp: Fix free_cb calling under dotnet.
Summary:
dotnet's GC seems to be more agressive, showing some issues that usually
do not appear when running under Mono's.

This commit uses for free_cb's the same scheme we already use for
regular Eo refs, using a GC handle to keep the cleaning callback alive.

Reviewers: vitor.sousa, felipealmeida, woohyun

Reviewed By: vitor.sousa

Subscribers: segfaultxavi, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8593
2019-04-15 15:24:29 -03:00
Vitor Sousa 1c22a3d819 efl-csharp: fix resource deallocation causing errors everywhere
Summary:
This commit mainly fixes errors caused by deallocating resources in the garbage
collector thread. Using `ecore_main_loop_thread_safe_call_async` to queue
resource deallocation in the main thread seems to solve it.

Also, some `efl_ref` calls are added in places they were missing, mainly
objects that unref in the destructor thus taking ownership if efl_ref is not
called.

Also fix improper resource deallocation in tests that were causing it to crash,
enabling it to call Efl.All.Shutdown again. This allocation and the deallocation
process was moved from the Eo class constructor to static class methods that are
called in the test 'set up' and 'tear down' methods.

Queuing resource deallocation in the main thread make it mandatory that tests
call `Efl.App.AppMain.Iterate()` if they want to check proper resource
deallocation (like TestFunctionPointers.set_callback_inherited_called_from_c).

Extras:
Remove duplicated declaration of 'eflcustomexportsmono' in meson in order to fix
some linking problems.

Remove some unused code around deallocation functions that had to be reworked.

Object allocation is now supplied with the call site information it expects
(file name and line for _efl_add_start).

Depends on D8550

Test Plan: meson test

Reviewers: felipealmeida, lauromoura, cedric, segfaultxavi

Reviewed By: lauromoura

Subscribers: segfaultxavi

Tags: #efl_language_bindings, #do_not_merge

Differential Revision: https://phab.enlightenment.org/D8431
2019-04-05 19:58:19 -03:00
Lauro Moura 1e22db1150 csharp: Make classes abstract and rework casting
Summary:
Abstract Eo classes are now proper C# abstract classes.

As a side effect, returning Eo instances from native code was reworked
to return instances of their actual Eo classes instead of previous
behavior of returning a generic Efl.Object and using static_cast.

Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());`
Use `var window = widget.GetParent() as Efl.Ui.Win;`

Another side effect was that `efl_constructor` was removed from the list
of supported `Efl.Object` overrides. It is invoked inside
`efl_add_internal_start`, before the bindings makes the association of
the newly created EoId with the C# instance that created it, making the
managed delegate meaningless. C# users then can use regular C#
constructors to initialize fields.

Also changed to set the private data of C#-inherited classes before the
call to constructing methods (aka constructor parameters) so C# classes
can override them correctly.

Fixes T7778
Fixes T7757

Reviewers: vitor.sousa, felipealmeida, segfaultxavi

Reviewed By: vitor.sousa, segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7778, T7757, T7702

Differential Revision: https://phab.enlightenment.org/D8550
2019-04-05 19:56:42 -03:00
Jaehyun Cho 0d37e8ff49 mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules  : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules  : SA1500, SA1501, SA1502, SA1503, SA1513

Indentation is also applied.

Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 16:57:52 +02:00
Lauro Moura 731db8b644 csharp: Raise exception when Array is null.
Reviewers: felipealmeida, vitor.sousa, segfaultxavi

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8499
2019-04-02 16:48:39 +02:00
Xavi Artigas 68a7567d26 mono-docs: Minor ammendments to Eina.Value 2019-03-29 09:51:56 +01:00
Lauro Moura 0860c4f1d7 csharp: Remove missing doc warning by filling them.
Summary:
Added basic documentation for things that were missing.

Some other files are silent due to a pragma disabling CS1591. They
should be handled later.

Also, removed `Efl.Io.Positioner` from the blacklist as it is referenced
from the `Efl.Io.Reader.eos` event documentation.

Reviewers: segfaultxavi

Reviewed By: segfaultxavi

Subscribers: felipealmeida, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8370
2019-03-20 11:35:58 +01:00
Vitor Sousa 00fdbb340f efl_csharp: remove warnings caused by unused or unnecessary code
Reviewers: lauromoura, segfaultxavi, cedric

Reviewed By: lauromoura

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8234
2019-03-07 17:08:20 -03:00
Vitor Sousa 4a306ec39b eina_csharp: fix memory leak in Eina.Hash.Set method
Reviewed-by: Lauro Neto <Lauro Moura <lauromoura@expertisesolutions.com.br>>
Differential Revision: https://phab.enlightenment.org/D8236
2019-03-07 09:59:02 -08:00
Felipe Magno de Almeida f392c5a436 efl-mono: Add support for dotnet core
Summary:
This commits adds dotnet as a supported C# platform for EFL# bindings.

Due to differences between Mono and Dotnet regarding DllImport, the
bindings now are using an imperative approach to load the function
pointers through the NativeModule and FunctionWrapper classes. These
classes handle the dlopen/LoadLibrary and dlsym/GetProcAddress calls.

Also, the previous caching of non-owned strings returned to native code
was removed until further memory checks.

We also had to create workaround for bool and chars in Structs for C#
marshaling. Going through System.Byte instead and Marshaling manually
to their respective types.

In order to actually build efl_mono.dll with dotnet right now,
issue #4782 from Meson should be fixed to make it properly detect and
used the Dotnet compiler. Also use "-Ddotnet=true" when running meson.

Fixes T7394

Reviewers: felipealmeida, vitor.sousa, bu5hm4n

Reviewed By: vitor.sousa

Subscribers: cedric

Tags: #efl

Maniphest Tasks: T7394

Differential Revision: https://phab.enlightenment.org/D8069
2019-03-01 23:58:56 -03:00
Lauro Moura dd89eb2fd1 efl-mono: Add support for Efl.Class
Efl.Class (in practice, the return from the *_class_get() functions) can
be used as argument to functions, like in Efl.Object.provider_find and
Efl.Ui.Widget_Factory.item_class(get/set).

This commits adds support by representing Efl.Class instances
as System.Type in the C# API, allowing someone to do things like:

`factory.ItemClass == typeof(MyFramework.MyButton)`

It also supports user-defined classes that inherit from efl classes.
2019-03-01 23:04:08 -03:00
Lauro Moura 850b7309b0 efl-csharp: Fix Eina.Value containing arrays and lists
Summary:
It was marshalling erroneously data into and out of arrays and lists.

Instead of passing data by value (or by address of correct size), it was
stuffing data into IntPtr and trying to parse out afterwards.

This commit changes the binding to use the same approach of plain
Get/Set, with proper overloads.

Reviewers: vitor.sousa, segfaultxavi, felipealmeida

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8057
2019-03-01 19:24:12 -03:00
Marcel Hollerbach 66824da950 efl_mono: move Eina.Error.Init() to a static constructor
this removes the need for the calling a Init function.

Reviewed-by: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Differential Revision: https://phab.enlightenment.org/D7556
2019-01-16 14:24:12 +01:00
Marcel Hollerbach 1e2faf8527 efl_mono: move Eina.Log.Init to class consturctor
Summary:
This removes the need to explicitly init the log class.
Depends on D7495

Reviewers: felipealmeida, lauromoura, segfaultxavi

Reviewed By: felipealmeida, segfaultxavi

Subscribers: segfaultxavi, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7555
2019-01-16 14:16:01 +01:00
Lauro Moura e2589e3b48 efl-mono: Only raise exception for managed errors.
Summary:
Previously, any unhandled Eina_Error would cause an exception
to be thrown when the control returned to C#.

This commit changes this behavior to only raise it when an exception
went unhandled from a C# callback back to C, like in an event handler,
for example.

Test Plan: run tests

Reviewers: segfaultxavi, Jaehyun_Cho, felipealmeida

Reviewed By: Jaehyun_Cho

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7537
2019-01-15 17:51:20 +09:00
Xavi Artigas 48b303eeb5 efl-mono: Add extra constructors to Eina.Value
Summary:
new Eina.Value(0) is a special case. The 0 is silently converted
to an enum (Eina.ValueType) and therefore the call is ambiguous
with the 0 being first converted to an Eina.Value via the implicit
conversion operator (calling the Eina.Value deep copy constructor).
Adding constructors for all supported types solves the problem because
they have higher priority. Also, they avoid one deep copy of the
Eina.Value.

Includes test case to catch this problem in the future. This was discovered
in the tutorials, where new Eina.Value(0) is being used.

Test Plan:
The src/efl_reference_core_event.exe example from the examples repo was
not compiling before, and now it is.
make check and make examples still work as expected.

Reviewers: lauromoura

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7598
2019-01-11 14:51:22 +01:00
Lauro Moura 3b7efdc80f efl-csharp: Add implicit conversions for Eina.Value
Summary:
For basic types, this will make it easier to pass Eina.Values into
functions, without requiring to setup and later Set() or Get() calls.

As discussed on irc, this seems to be a better way to improve the Value
C# API than using method chaining.

Fixes T7388

Test Plan: run tests

Reviewers: segfaultxavi, felipealmeida

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7388

Differential Revision: https://phab.enlightenment.org/D7526
2018-12-30 17:08:25 +01:00
Lauro Moura c6509aee0f efl-mono: Remove Flush from C# Value API.
Summary: Fixes T7387

Test Plan: run tests

Reviewers: segfaultxavi, felipealmeida

Reviewed By: segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7387

Differential Revision: https://phab.enlightenment.org/D7521
2018-12-28 18:22:43 +01:00
Marcel Hollerbach 20ddd4c679 efl_app: introduce app_main for getting the app object
This brings in the possibility to receive the app object from bindings.
With the app object you can listen to pause / args / terminate / resume
events.

fix T7509

Differential Revision: https://phab.enlightenment.org/D7480
2018-12-20 12:56:54 +01:00
Lauro Moura 3623753c1d csharp: Change to new class API.
Summary:
As discussed in T7204:

- Eo Interfaces/mixins -> C# Interfaces with concrete class
  implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods

Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.

Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.

Summary of API Changes:

- Merged Inherit/Concrete classes. (These suffixes disappear from
  regular classes).
- Interface still have implementations with 'Concrete' suffix for when
  they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
  naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass

Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)

Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.

Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.

Still need to work:

- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
  from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
  the interface and implemented "namespaced" in the classes,
  requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
  commit.

Depends on D7260

Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7451, T7336

Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 21:29:48 -02:00
Marcel Hollerbach 6f9761ff54 meson: time for the c-sharp build
The tests are added and build. For running C# code please see the wiki.

you can enable -Dmono=true

Differential Revision: https://phab.enlightenment.org/D7203
2018-10-24 12:05:58 +02:00
Lauro Moura 103ba3668e csharp: Fix missing override keyword
Reviewers: vitor.sousa

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7136
2018-10-04 14:24:03 -03:00
Lauro Moura 89a537b4d1 efl-csharp: Add copy constructor for eina.Value.
Summary: This will allow deep copying the given value from C#.

Reviewers: felipealmeida, vitor.sousa, segfaultxavi

Reviewed By: vitor.sousa, segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7017
2018-09-11 11:41:38 -03:00
Xavi Artigas 40d03dbef8 efl-mono: Make eina_list return the list
Summary:
eina_list_reverse() returns the list, the C# version should do the same.
This fixes the reference/csharp/eina/src/eina_list.cs example.

Fixes T7112

Test Plan: The eina_list.cs example works after this change.

Reviewers: lauromoura, vitor.sousa, felipealmeida

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7112

Differential Revision: https://phab.enlightenment.org/D6995
2018-09-06 12:20:29 -03:00
Lauro Moura 840613235d efl-csharp: Use value_new/free for wrapped values
Summary:
Using malloc/free as it was used before would cause double frees and
other issues when mixing with eina_values created from the value
mempool inside Eina.

Fixes T7359

Reviewers: felipealmeida, vitor.sousa, segfaultxavi

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7359

Differential Revision: https://phab.enlightenment.org/D6958
2018-09-03 17:39:38 -03:00
Lauro Moura 54f1e56b34 efl_mono: Generate support for accessors in .eos
Summary: Depends on D6190

Reviewers: felipealmeida, vitor.sousa

Reviewed By: vitor.sousa

Subscribers: cedric, #committers, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6191
2018-05-23 18:59:26 -03:00
Lauro Moura cfafd01bbe efl_mono: Initial support for Accessors.
Summary:
Plain conversion to IEnumerable, which is the base of LINQ
Depends on D6189

Reviewers: felipealmeida, vitor.sousa

Reviewed By: vitor.sousa

Subscribers: cedric, #committers, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6190
2018-05-23 18:59:26 -03:00
Lauro Moura 2bbaada66e efl_mono: Reject the promise when it's disposed.
Summary:
As futures are tied to a given promises and are usually handled in
a 'attach and forget' scheme, we can't cancel them as it would cancel
the whole chain.

Reviewers: felipealmeida, vitor.sousa

Reviewed By: vitor.sousa

Subscribers: cedric, #committers, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6189
2018-05-23 18:59:26 -03:00
Lauro Moura c8fbc31ee2 efl_mono: Start generating eina future in eolian_mono.
Summary:
Besides the normal methods returning Futures, we now generate
a wrapper with the "Async" suffix. This wrapper returns a
Systems.Threading.Tasks.Task which can be awaited on and reflect the
status of the Future.

When an eina.Future fails with ECANCELED, TaskCanceledException is
raised in the Task. Otherwise, an efl.FutureException(eina.Error) is
raised.
Depends on D6174

Reviewers: felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6175
2018-05-17 16:56:31 -03:00
Lauro Moura fff0c86d99 efl_mono: Initial support for Futures/Promises
Summary:
Promise/Future cleanup:

In the promises, we use a wrapper Eina_Promise_Cancel_Cb to
invalidate the wrapper if it ever gets cancelled from outside. When
invalidating from C#, we can do it directly.

For the futures, likewise, in order to be able to invalidate the
wrapper when the chain it belongs to gets resolved we then() an
internal future with a callback to invalidate the wrapper we return to
C#. The return of this intermediate then() is the future we actually
return to the user.

Also added ECANCELED to the list of default eina.Errors
Depends on D6173

Reviewers: felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6174
2018-05-17 16:56:25 -03:00
Lauro Moura f8a033fd70 efl_mono: Add support for Eina.Error/Empty in eina.Value
Summary:
eina.Value.Empty now means that we have an zeroed (empty) eina value.
For optional values that are empty use eina.Value.OptionalEmpty.

This was required to support the empty values passed with
EINA_VALUE_EMPTY in some Ecore futures.

Also, returning an eina_value by value is not supported in eolian
for safety reasons, so we removed some tests that tried to use this
behavior.
Depends on D6171

Reviewers: felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6172
2018-05-17 16:56:11 -03:00
Lauro Moura da6f5932f1 efl_mono: Support type aliases.
Summary:
Due to the absence of typedef from C#, we generate thin structs with
implicit operators to allow reference the data from their typedef'd name
from C#.

The other alternatives would be always converting to the lowest base on
the alias stack (losing the meaningfulness of the typedef name) or using
the 'using' directive. The latter has the restriction that it makes an
alias visible only in the file they are declared.

Reviewers: felipealmeida, cedric, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6157
2018-05-11 11:01:59 -03:00
Lauro Moura 4636d6e0eb efl_mono: Change generated classes naming scheme
Summary:
Now the generated classes use an approach more familiar to C#
developers:

Interfaces: efl.Object -> efl.IObject

Concrete (implementation) classes: efl.ObjectConcrete -> efl.Object.

During this change, some methods that could clash with the
implementation class name (CS0542) had the prefix "Do" added (like in
efl.Duplicate.Duplicate() and efl.Pack.Pack()).
Depends on D6049

Reviewers: felipealmeida, vitor.sousa

Reviewed By: vitor.sousa

Subscribers: cedric

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6050
2018-05-03 18:04:41 -03:00
Lauro Moura 3fd1566a08 csharp: Provisionally fix conversion of eina.Value
When we have an eina.Value_Native (representing an Eina_Value passed by
value) and assign it to an eina.Value (a class with an IntPtr to an
underlying Eina_Value) we copy it so the eina.Value can take ownership
and free the data normally.

A possibly better alternative would be adding an extra flag to
eina.Value (something like OwnsPointer) to check whether we should free
the struct we point to or not.
2018-04-03 17:29:41 -03:00
Lauro Moura e2fafe5b0c efl_mono: Initial version of Strbuf support.
Also moved the ValueOwnership enum from eina value to eina.Ownership. It
can be shared among the eina structures if needed.
2018-04-03 17:29:41 -03:00
Lauro Moura 7c543d3c86 csharp: Change policy on ptr(struct) owned calls
When transferring the ownership of a ptr(struct) from Unamanaged to
managed, we should marshal the reference-typed fields or they can point
to Managed memory that would make no sense to access from C (for
example, strings would return garbage).

The downside is that it can cause potential leaks if the receiver of the
memory do not free it. In the current state of the EFL api this can
happen in two places:

- Efl.Ui.List.SegArray::remove
return -> ptr(Efl.Ui.List.LayoutItem) @owned
- Efl.Ui.Focus.Manager::fetch
return -> ptr(Efl.Ui.Focus.Relations) @owned

The resources copied by both structs may leak when those functions are
overriden in C# and the values returned to the C code.

Also hide some internal stuff instead of exporting it and generate
implicit conversion operators for struct external/internal.
2018-03-16 11:12:49 -03:00
Lauro Moura 17b9f00f7e eina_mono: Avoid calling eina_init directly from the modules.
They must be initialized from the eina.Config.Init() method.
2018-02-08 10:49:47 -03:00
Lauro Moura 46b202b86c eolian-mono: Add documentation generation support
This commit adds the "documentation" generator, which gets the
documentation_def attribute of the given item and generates xml comments
to be exported by MCS.

For items requiring some customization of the generated comments (e.g.
functions and its parameters), the helpers to generate the preamble
(summary), body (paragraphs) and epilogue (currently just the @since
tag) were added.

Currently we do not support converting Eolian references into xmldoc
references.

As we explicitly generate Get/Set methods for properties, for now the
generator tries to get the get/set specific documentation first. If it
is not present, fallback to the common docs.

Later this could be changed to generate the common one as paragraphs of
the Get/Set.

Also some generated code like the wrappers for calling C# methods
from C can be private. This will cleanup the introspection results
and warnings when generating documentation.

Due to this visibility change, the binbuf tests had to be changed
to add redirect calls to the native methods instead of directly
calling the DllImport'd methods.
2017-12-20 19:57:17 -02:00
Vitor Sousa 00fb5b228a eolian_mono: fix handling of regular ptr() types 2017-12-15 22:26:30 -02:00
Vitor Sousa acd99be98b efl_mono: tests and better support for structs, plus some other fixes
Fix several integer binding type deduction based in its size on C.

Generation for function pointers no longer use modified argument name
which is different from the parameter name.

New generation context for structs.

bool from UnmanagedType.I1 to UnmanagedType.U1 (correct use
inside structs according to mono documentation).

byte (signed char) and int8 now is correctly represented by
sbyte in C#.

Check parameter direction in some out generators in parameter.hh.

Add efl_libs.csv to gitignore.

Make eina.Value pointer constructor public.

Add missing fields to efl.kw_event.Description struct.

Remove eina.File workaround (let struct gen handle it).

Remove is_function_ptr bool from regular_type_def and
add a typedecl_type enum to it. Also add some helper
methods for easier comparison.

Left some test cases commented for when pointer parameters
are properly working.
2017-12-15 22:26:29 -02:00
Lauro Moura 3c5efa1e8d efl_mono: Fix eina_value_set.
Instead of messing around with varargs, create individual wrappers for
each type supported.

The va_list approach was getting problems with float/double on Windows.
2017-12-04 15:47:52 -03:00
Lauro Moura 9391407319 efl_mono: Adding support code for the C# binding
This is the C# manual code for the binding. Buildsystem integration will
come in a future commit.
2017-12-04 15:47:49 -03:00