Page MenuHomePhabricator

C#: Make possible to call C# constructors from C's `efl_add`
Closed, ResolvedPublic


When passing C#-implemented classes to EFL through Efl.Class parameters (like in factories), the native code may want to instantiate it. The binding must provide a way to call the C# constructors correctly from C's efl_add in a transparent way.

The solution should also keep C# constructors working normally when invoked from C#.

lauromoura triaged this task as High priority.
vitor.sousa added a comment.EditedMay 24 2019, 4:44 PM

I guess we have two options here.

We could add a boolean in the private data of the object to flag whether it is being constructed from C or from C#, and check for that in every method that the C# object overrides.
If the flag is true, and thus an C# wrapper needs to be constructed, we construct one on site calling the user constructor and them follow with the method call (and sets the flag to false to signal that it has a wrapper already).
The user could override the efl_finalize method to ensure a C# wrapper will always be created just as efl_add is called.

Or we could add one more flag to _efl_add_internal_start so we can suppress the call of efl_constructor.
This way we can register a custom efl_constructor that creates a new C# wrapper and ensured its creation before any method call.
When the object creation starts from C# we just suppress the call of this constructor; in this case, the C# binding will call efl_constructor explicitly (instead of Eo) passing efl_super in order to avoid the call of the base efl_constructor and the creation of a duplicated C# wrapper.


vitor.sousa claimed this task.EditedJun 28 2019, 7:36 AM
vitor.sousa closed this task as Resolved.

Fixed by D9071