Browse Source

Merge pull request #36 from ddobrev/safe_identifiers

Ensure safe property and variable names
pull/37/merge
João Matos 12 years ago
parent
commit
5933a85bdf
  1. 4
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 4
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

4
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -311,9 +311,9 @@ namespace CppSharp.Generators.CSharp @@ -311,9 +311,9 @@ namespace CppSharp.Generators.CSharp
type.IsPrimitiveType(PrimitiveType.WideChar))
{
Context.Return.Write("Marshal.StringToHGlobalAnsi({0})",
Context.Parameter.Name);
Helpers.SafeIdentifier(Context.Parameter.Name));
CSharpContext.Cleanup.WriteLine("Marshal.FreeHGlobal({0});",
Context.ArgName);
Helpers.SafeIdentifier(Context.ArgName));
return true;
}

4
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -887,7 +887,7 @@ namespace CppSharp.Generators.CSharp @@ -887,7 +887,7 @@ namespace CppSharp.Generators.CSharp
if (prop.Ignore) continue;
PushBlock(CSharpBlockKind.Property);
WriteLine("public {0} {1}", prop.Type, prop.Name);
WriteLine("public {0} {1}", prop.Type, SafeIdentifier(prop.Name));
WriteStartBraceIndent();
if (prop.Field != null)
@ -915,7 +915,7 @@ namespace CppSharp.Generators.CSharp @@ -915,7 +915,7 @@ namespace CppSharp.Generators.CSharp
private void GenerateVariable(Class @class, Type type, Variable variable)
{
PushBlock(CSharpBlockKind.Variable);
WriteLine("public static {0} {1}", type, variable.Name);
WriteLine("public static {0} {1}", type, SafeIdentifier(variable.Name));
WriteStartBraceIndent();
GeneratePropertyGetter(variable, @class);

Loading…
Cancel
Save