Page MenuHomePhabricator

csharp: Make classes abstract and rework casting
ClosedPublic

Authored by lauromoura on Apr 3 2019, 2:40 PM.

Details

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

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
lauromoura created this revision.Apr 3 2019, 2:40 PM
lauromoura requested review of this revision.Apr 3 2019, 2:40 PM
segfaultxavi accepted this revision.Apr 4 2019, 4:12 AM

Awesome! I cannot comment on the code, but the ui_content.cs tutorial changes from:

Efl.IContentConcrete.static_cast(vsplit.GetPart("first")).SetContent(box);

to:

(vsplit.GetPart("first") as Efl.IContent).SetContent(box);

Or even:

((Efl.IContent)vsplit.GetPart("first")).SetContent(box);

So we remove both static_cast and the Concrete suffix. I am happy, and the users will probably be too.

This revision is now accepted and ready to land.Apr 4 2019, 4:12 AM
vitor.sousa requested changes to this revision.Apr 4 2019, 12:52 PM

Awesome.
Just a comment:

src/bindings/mono/eo_mono/iwrapper.cs
605

I think this loop is kind of redundant.

This revision now requires changes to proceed.Apr 4 2019, 12:52 PM
lauromoura updated this revision to Diff 21226.Apr 4 2019, 1:15 PM

Update removing the while loop. (It falls there only if it is a generated class. And all generated classes have the IntPtr constructor.)

lauromoura marked an inline comment as done.Apr 4 2019, 1:31 PM
vitor.sousa accepted this revision.Apr 4 2019, 1:31 PM

Amazing

This revision is now accepted and ready to land.Apr 4 2019, 1:31 PM
vitor.sousa accepted this revision.Apr 5 2019, 3:42 PM
This revision was automatically updated to reflect the committed changes.