Commit Graph

33 Commits

Author SHA1 Message Date
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
Xavi Artigas 7a97e5fc7f C# bindings: Make efl_loop_timer.eo available to bindings
Summary:
This file contains both legacy and new API code, this makes it a little
difficult to deploy.
In Makefile_Ecore.am files can be marked either as legacy or public.
If it is not in legacy, make distcheck fails because Ecore_Legacy.h includes
efl_loop_timer.eo.h.
If it is not in public, bindings are not generated for it.
It cannot be in both places, or make install fails, refusing to install the
same file twice.

Fortunately, there is an ugly place to put files like this one, and it's
already full of other outcasts, so...

Fixes T7114

Test Plan: make distcheck still works, and C# bindings are generated for efl_loop_timer.eo

Reviewers: zmike, bu5hm4n, devilhorns

Reviewed By: zmike

Subscribers: vitor.sousa, cedric, #committers

Tags: #efl

Maniphest Tasks: T7114

Differential Revision: https://phab.enlightenment.org/D6527
2018-07-06 15:00:51 -04: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 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
Stefan Schmidt 51f5419292 eolian_mono: remove non existing file references for distcheck
These three files do no longer exist in tree and are failing distcheck
when preparing the dist tarball.
2018-04-27 11:22:19 +02:00
Lauro Moura edf05278ed efl_mono: Names fixes after the big rename
Summary: Depends on D5997

Reviewers: felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5998
2018-04-26 10:55:18 -03:00
Lauro Moura a413914c18 efl_mono: Move event generators to its own header.
Summary:
Making it easier to share code between self and inherited events.

During this move, the namespace and keyword headers were merged into the
name_helpers header.

Also added the first seed of a generic namespace reducer function,
to be used by other functions in later commits.
Depends on D5994

Reviewers: felipealmeida

Reviewed By: felipealmeida

Subscribers: segfaultxavi, cedric

Differential Revision: https://phab.enlightenment.org/D5995
2018-04-26 10:55:18 -03:00
Xavi Artigas a217d4b455 Efl.Canvas.Vg.Object (from Efl.Canvas.Vg)
Also, Efl.Canvas.Vg.* (from Efl.Canvas.VG.*)
Ref https://phab.enlightenment.org/T6847

Reviewed-by: Cedric Bail <cedric@osg.samsung.com>
2018-04-24 09:03:30 -07:00
Lauro Moura 65f868786a efl_mono: Proper support for @class methods.
Previously, class methods were implemented as regular instance methods.
This commits generates C# static methods for @class methods on the
*Concrete classes (and their childs).
2018-04-12 21:23:42 -03:00
Lauro Moura bffe42e71b csharp: Support argument marshalling in func ptrs
Function pointers now go through the same argument marshalling pipeline
as normal functions.

This will enable interfaces like Efl.Ui.Format to work properly.
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
Felipe Magno de Almeida be06c27762 efl-mono: Fix compile flags, .config files and class_name in description 2018-04-03 14:01:29 -03:00
Lauro Moura f9586a831b csharp: Add support for efl parts as Properties
Instead of
   var bg = efl.ui.Background.static_cast(myobj.Part("background"));

Now do
   var bg = myobj.Background;

Also a couple helper functions were added.
2018-03-20 16:50:30 -03:00
Lauro Moura 7fc20c08ee csharp: Use the library mapping on linux too.
Now the generated DllImport call will have the actual library name
instead of placeholders on Linux. Before we relied on dlsym being able
to search for the symbols on all loaded so's while Windows needed you to
specify the correct library to call GetProcAddress.

This fixes the case when someone call an function from an efl interface
defined in efl.so (e.g. efl_part) and the library is not loaded yet.
2018-03-20 16:50:30 -03:00
Lauro Moura 2705ea8531 csharp: Fix support for ptr(structs)
In general, ptr(struct) parameters behavior depends whether the
parameter has the @owned modifier or not.

If there is no @owned parameter (meaning no transfer of ownership
happens) and it is a "complex" struct, with reference type fields
(like strings), the struct is converted to the respective
<Struct>Internal struct and passed with "ref" to the DllImport'd
function. For @in parameters, after the function it returns, this
intermediate struct is converted to the public struct type and
assigned to the original parameter, updating it to the external
world.

When we have ownership transfers, the structure is copied to unmanaged
memory and given to the callee. We can't send managed memory directly as
the callee may try to free it. On the managed side, the original struct
is left to be garbage collected normally.
2018-03-16 11:12:49 -03:00
Lauro Moura 067a8baffa csharp: generate helper constructors for structs.
Summary:
C# does not have a literal form for structs (like C++'s {} aggregate
initialization). Before this commit the user would need to explicitly
instantiate a struct and assign the required values to it, like:

   eina.Size2D size;
   size.W = width;
   size.H = height;
   widget.SetSize(size);

As a workaround, this commit generates helper constructor with
parameters corresponding to the struct fields in the order they are
declared. These parameters have default values if one does not want to
explicitly initialize all fields directly. With these constructs, the
above code could be translated to:

   widget.SetSize(new eina.Size2D(width, height));

It should be noted that the constructed struct will live on the managed
memory (GC) instead of the stack.

Test Plan: run "make check"

Reviewers: felipealmeida

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5838

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2018-03-08 15:46:45 -08:00
Lauro Moura 2fc4c91917 mono: Whitelist some interfaces and classes
Summary: Among them, IO interfaces are needed by the new efl.Task.

Test Plan: Run make check

Reviewers: felipealmeida

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5821
2018-02-22 20:33:46 -03:00
Mike Blumenkrantz f85325d924 interfaces: remove Efl.Text.Properties
this is provided in Efl.Text.Font
2018-02-12 16:38:51 -05:00
Lauro Moura 9a4b8f3800 efl_mono: Distcheck fixes
- Export required sources
- Avoid generated sources being passed as static ones
2018-02-08 10:50:04 -03:00
Vitor Sousa 359a6cdc0e efl_mono: fix DLL instalation path on efl-mono.pc.in
Destination of libefl_mono.dll is OS dependent, this was not translated
to efl-mono.pc.in. This commit fix this issue.
2018-01-25 16:03:12 -03:00
Lauro Moura b56a02602a mono: Fix AM_TESTS_ENVIRONMENT
The export commands were messing up with the elm_suite, causing the
layout do fail to be loaded.
2018-01-25 15:27:05 -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
Lauro Moura 8f14f1610e examples: Add C# buttons/popup example. 2017-12-19 17:51:51 -02:00
Vitor Sousa b55542889b efl_mono: fix test and example compilation on Windows 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
Felipe Magno de Almeida fe8c5f8269 efl-mono: Fix installation in out-of-tree compilation 2017-12-15 13:29:19 +09:00
Vitor Sousa e8edf882bf efl-mono: Fix examples Makefiles for mono examples 2017-12-14 17:42:42 -02:00
Felipe Magno de Almeida e67d6484b8 efl-cxx: Fixes to make dist 2017-12-13 14:13:09 -02:00
Lauro Moura 86f2e0f8ce efl_mono: Fix dll.config paths 2017-12-12 22:34:05 -02:00
Felipe Magno de Almeida ff9293827f efl-mono: Fix automake files in C# binding search with buggy mono version 2017-12-11 14:45:57 -02:00
Vitor Sousa e7803cc429 efl_mono: fix switched reference to generated and non-generated source file in build system 2017-12-04 18:02:36 -02:00
Lauro Moura b97d3438eb efl_mono: Add buildystem integration.
The C# bindings are built using the --enable-csharp-bindings (disabled
by default).
2017-12-04 15:47:51 -03:00