Added support for marshaling .NET strings.
This commit is contained in:
Родитель
3886b6e6ae
Коммит
34b9cf584a
|
@ -17,6 +17,31 @@ namespace MonoManagedToNative.Generators
|
|||
public CMarshalManagedToNative(MarshalContext marshalContext)
|
||||
: base(marshalContext)
|
||||
{
|
||||
}
|
||||
|
||||
bool HandleSpecialCILType(CILType cilType)
|
||||
{
|
||||
var type = cilType.Type;
|
||||
|
||||
if (type == typeof(string))
|
||||
{
|
||||
var stringId = CGenerator.GenId("string");
|
||||
Context.SupportBefore.WriteLine("char* {0} = mono_string_to_utf8(" +
|
||||
"(MonoString*) {1});", stringId, Context.ArgName);
|
||||
|
||||
Context.Return.Write("{0}", stringId);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool VisitCILType(CILType type, TypeQualifiers quals)
|
||||
{
|
||||
if (HandleSpecialCILType(type))
|
||||
return true;
|
||||
|
||||
return base.VisitCILType(type, quals);
|
||||
}
|
||||
|
||||
public override bool VisitBuiltinType(BuiltinType builtin,
|
||||
|
|
Загрузка…
Ссылка в новой задаче