C#: Update C# code-generation to use a new ICustomMarshaler in some string…

Authored by lucas on Feb 28 2020, 7:58 AM.


C#: Update C# code-generation to use a new ICustomMarshaler in some string usages that were leaking

When C calls a function that return/has an out string and it was overwritten by C# inherit class the C portion
wasn't cleaning its copy. Now, when a C calls a C# delegate function, Strings that are out values or return
values use a new marshaler (specific to this case) that uses Eina short lived strings (Eina_Slstr) instead of
duplicating it with strdup, so at some point, the string passed to C is deleted.

To do so, a direction_context (a new Context at generation_contexts.hh) was created. It is only used when a C#
delegate is being called from C (so this context is only set in function_definition.hh and property_definition.hh,
where it is set to native_to_manage to indicate that it is a native call to a managed function).

When this direction_context is set and the String being marshaled is not marked with an @move tag and it is an
out or return value, the new StringOutMarshaler (implemented at iwrapper.cs) is used (instead of

When marshaling a managed data to native this marshaler uses eina short lived string (Eina_Slstr) that will be
automatically deleted. This delete is bounded to "the loop of the current thread or until the clear function is called
explicitly" as said at src/lib/eina/eina_slstr.h.

Reviewed-by: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Differential Revision: https://phab.enlightenment.org/D11434