Skip to content

Commit

Permalink
Restructuring of CLI string marshaling code.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Jan 12, 2016
1 parent 900956c commit 4bc7c78
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Generator/Generators/CLI/CLIMarshal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,17 @@ private string MarshalStringToManaged(string varName, BuiltinType type)
if (Equals(encoding, Encoding.ASCII))
encoding = Context.Driver.Options.Encoding;

string param;
if (Equals(encoding, Encoding.ASCII))
return string.Format("clix::marshalString<clix::E_UTF8>({0})", varName);

if (Equals(encoding, Encoding.Unicode) ||
Equals(encoding, Encoding.BigEndianUnicode))
return string.Format("clix::marshalString<clix::E_UTF16>({0})", varName);
param = "E_UTF8";
else if (Equals(encoding, Encoding.Unicode) ||
Equals(encoding, Encoding.BigEndianUnicode))
param = "E_UTF16";
else
throw new NotSupportedException(string.Format("{0} is not supported yet.",
Context.Driver.Options.Encoding.EncodingName));

throw new NotSupportedException(string.Format("{0} is not supported yet.",
Context.Driver.Options.Encoding.EncodingName));
return string.Format("clix::marshalString<clix::{1}>({0})", varName, param);
}

public override bool VisitMemberPointerType(MemberPointerType member,
Expand Down

0 comments on commit 4bc7c78

Please sign in to comment.