Commit Graph

29 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
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 f510d536a4 efl_mono: Fixes after efl_part/del changes.
Reviewed-by: Cedric BAIL <cedric@osg.samsung.com>
2018-05-24 16:02:19 -07:00
Cedric BAIL 8a513a522e efl: major rewrite of efl_part.
The interface efl_part_get should not be directly called from C, but the efl_part
wrapper should. It rely on efl_noref to properly destroy the object. Binding can
control the lifecycle of the reference the way they want by either calling the
wrapper or efl_part_get directly. It also means that the ugly ___efl_auto_unref_set
doesn't need to be exposed outside of EFL anymore.

Differential Revision: https://phab.enlightenment.org/D6098
2018-05-24 16:02:18 -07:00
Cedric BAIL ccb5642eb9 Revert "efl_add_ref - fis to use efl_add properly with a parent."
This reverts commit 2fb5cc3ad0.

Most of this change where wrong as they didn't affect the destruction
of the object. efl_add_ref allow for manual handling of the lifecycle
of the object and make sure it is still alive during destructor. efl_add
will not allow you to access an object after invalidate also efl.parent.get
will always return NULL once the object is invalidated.

Differential Revision: https://phab.enlightenment.org/D6062
2018-05-24 16:02:17 -07: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 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 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 ff1fda829d efl_mono: Actually test events by passing things by value and structs
Summary:
While the test events were declared as by value, the support code passed
by reference, which was - wrongly - the only implementation supported in
event code.

Also added test with Eina_Bool and structs (passed by pointer to events,
while not having the ptr modifier explicitly.
Depends on D5995

Reviewers: felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5996
2018-04-26 10:55:18 -03:00
Lauro Moura 8e151023b9 efl_mono: Instantiate parts in constructor in test
Summary:
Don't try to lazily create the parts when getting them, as it would
modify the owner inside its @const Efl.Part.part.
Depends on D5993

Reviewers: felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5994
2018-04-26 10:55:18 -03:00
Lauro Moura 1179058017 efl_mono: Fix after prop get const change 2018-04-19 14:06:02 -03: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 eac568f6dc csharp: Silence test build warnings.
Was trying to modify const strings.
2018-04-03 17:29:41 -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 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
Felipe Magno de Almeida ca45ee9a9f efl-mono: Fix test not include'ing Ecore.h 2018-04-03 17:26:28 -03:00
Carsten Haitzler 2fb5cc3ad0 efl_add_ref - fis to use efl_add properly with a parent.
fixes bc18b7e7ad and
168849e8a0
2018-03-29 13:30:55 +09:00
Cedric BAIL 4c4177ac20 efl: use efl_add_ref to create objects which have no parent
Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2018-03-20 17:20:56 -07: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 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 cf03e35766 efl_mono: Remove unneeded code from tests 2018-01-25 15:27:05 -03:00
Lauro Moura eaf41d9bce eolian_mono: Fix event argument for strings 2018-01-25 15:27:05 -03:00
Vincent Torri f5b01ac5ce all: Simplify definition of EAPI
This will help in the transition from Autotools to Meson. This has been
tested on Windows for which EFL_XXX_BUILD were first introduced.
2018-01-18 18:04:03 +09: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 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
Jean-Philippe Andre b3435831f7 c#: Fix test case
return -1 in a void function breaks the build for me (clang)
2017-12-05 15:06:34 +09:00
Lauro Moura 345336c46d efl_mono: Added test files for the C# bindings.
Buildsystem integration will come in a future commit.
2017-12-04 15:47:50 -03:00