Commit Graph

17 Commits

Author SHA1 Message Date
Lauro Moura 77207f9b58 csharp: Fix running headless tests in dotnet
Summary:
CoreCLR, the runtime of dotnet, has some issues regarding storing
environment variables (see dotnet/coreclr issue #15812), keeping them in
a local cache instead of flushing to the native `setenv`.

This commit replaces the usage of
`System.Environment.SetEnvironmentVariable` with a `setenv` wrapper.

Test Plan: Run without DISPLAY set and with dotnet.

Reviewers: felipealmeida, brunobelo, segfaultxavi, YOhoho

Reviewed By: brunobelo

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10619
2019-11-07 22:46:15 -03:00
Lauro Moura 40a980174b csharp: Add licensing information.
Summary:
C# bindings will be lincensed under Apache Sofware License 2.0.

This commit adds the license text to the licenses folder and a copyright
notice to the binding files.

Fixes T8039

Reviewers: woohyun, felipealmeida, vitor.sousa

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8039

Differential Revision: https://phab.enlightenment.org/D9414
2019-10-24 10:10:56 -03:00
Lauro Moura da6f25bee0 csharp: Add Efl.Model implementations to internal model
Summary:
CollectionView tries to access some properties from the base model so we
need to provide some implementation of the property getter/setter.

Reviewers: SanghyeonLee, cedric, felipealmeida

Reviewed By: SanghyeonLee

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10300
2019-10-17 11:11:00 -03:00
Lauro Moura 4867c4bdaf csharp: Add some docs to MVVM infrastructure
Reviewers: SanghyeonLee, felipealmeida, cedric, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10301
2019-10-08 10:24:17 +02:00
Daniel Kolesa 81441638db eolian: enable unimplemented function errors for stable API 2019-09-17 12:36:50 +02:00
Lauro Moura 40def3eac9 efl-mono: Add Model manual implementation to C# and MVVM factories
Summary: Depends on D9273, D9270

Test Plan: Run added testcases.

Reviewers: cedric, bu5hm4n, zmike, SanghyeonLee, felipealmeida, segfaultxavi

Reviewed By: cedric

Subscribers: cedric

Tags: #expertise_solutions, #efl_language_bindings

Differential Revision: https://phab.enlightenment.org/D8080
2019-08-05 10:18:18 -04: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
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
Vitor Sousa b7fa7d48ac csharp: make inherited C# classes constructible from native C
Summary:
With this commit it is now possible for a class that inherits from a C# binding
class to be instantiated from native C code. It only has to provide a
constructor that receives an `Efl.Eo.EoWrapper.ConstructingHandle` struct,
and which calls the base binding constructor passing it.
For example:

`private Type(ConstructingHandle ch) : base(ch) {}`.

Add some test files to validate the proper behavior of this feature.

Add some small fixes in generation contexts in order to properly
generate base constructors.

Depends on D9070

Test Plan: `meson test` and `make check`

Reviewers: lauromoura, felipealmeida, segfaultxavi, woohyun, YOhoho

Reviewed By: YOhoho

Subscribers: YOhoho, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9071
2019-06-28 10:38:57 -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
Vitor Sousa 7c28762f15 efl-csharp: fix crash when events trigger after C# object `Dispose`
Summary:
Rework general event handling to check individually each event call, if the
object is not alive then the event will not be propagated.
WeakReferences (and lambdas capturing those WeakRefs) are used to ensure this.

Dispose methods in object now take care of checking if efl libraries are still
initialized and thread-safely unregister each event before performing an
efl_unref on the Eo object.

Event handling in C# is now centered around a single dictionary inside the
object: `EoEvents`.

C# event triggers now properly trigger events on C too.

Standardize C# event-triggering methods names (remove underscores).

Some diminished use of static memory due events no longer requiring static key
objects to be registered/unregistered.

Some fixing of white space generation for generated events.

Depends on D8431

Reviewers: lauromoura, felipealmeida, segfaultxavi

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8564
2019-04-05 19:59:47 -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 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
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 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 8b1a72e972 efl_mono: Add native support library
Buildsystem integration will come in a future commit
2017-12-04 15:47:51 -03:00