Skip to content

Commit ef69bf1

Browse files
committed
Made the case-renaming pass non-optional for Mono/.NET generators.
1 parent 1a84b35 commit ef69bf1

File tree

7 files changed

+90
-82
lines changed

7 files changed

+90
-82
lines changed

src/CppParser/ParserGen/ParserGen.cs

-4
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ public void Preprocess(Driver driver, ASTContext ctx)
182182

183183
public void Postprocess(Driver driver, ASTContext ctx)
184184
{
185-
new CaseRenamePass(
186-
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate |
187-
RenameTargets.Field | RenameTargets.Variable,
188-
RenameCasePattern.UpperCamelCase).VisitASTContext(driver.Context.ASTContext);
189185
}
190186

191187
public static void Main(string[] args)

src/Generator/Driver.cs

+6
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ public void SetupPasses(ILibrary library)
338338

339339
TranslationUnitPasses.AddPass(new GetterSetterToPropertyPass());
340340
TranslationUnitPasses.AddPass(new StripUnusedSystemTypesPass());
341+
if (Options.GeneratorKind == GeneratorKind.CLI ||
342+
Options.GeneratorKind == GeneratorKind.CSharp)
343+
TranslationUnitPasses.AddPass(new CaseRenamePass(
344+
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property |
345+
RenameTargets.Delegate | RenameTargets.Field | RenameTargets.Variable,
346+
RenameCasePattern.UpperCamelCase));
341347
}
342348

343349
public void ProcessCode()

src/Generator/Passes/RenamePass.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,20 @@ public bool IsRenameableDecl(Declaration decl)
8383
}
8484
if (decl is Parameter) return true;
8585
if (decl is Enumeration) return true;
86-
if (decl is Property) return true;
86+
var property = decl as Property;
87+
if (property != null) return !property.IsIndexer;
8788
if (decl is Event) return true;
8889
if (decl is TypedefDecl) return true;
8990
if (decl is Namespace && !(decl is TranslationUnit)) return true;
9091
if (decl is Variable) return true;
92+
var field = decl as Field;
93+
if (field != null)
94+
{
95+
var fieldProperty = ((Class) field.Namespace).Properties.FirstOrDefault(
96+
p => p.Field == field);
97+
return (fieldProperty != null &&
98+
fieldProperty.IsInRefTypeAndBackedByValueClassField());
99+
}
91100
return false;
92101
}
93102

tests/CLI/CLI.Tests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public void TestToStringOverride()
2323
[Test]
2424
public void TestStdString()
2525
{
26-
Assert.AreEqual("test_test", new Date(0, 0, 0).testStdString("test"));
26+
Assert.AreEqual("test_test", new Date(0, 0, 0).TestStdString("test"));
2727
}
2828
}

tests/CSharp/CSharp.cs

-3
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ public override void Preprocess(Driver driver, ASTContext ctx)
169169

170170
public override void Postprocess(Driver driver, ASTContext ctx)
171171
{
172-
new CaseRenamePass(
173-
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Variable,
174-
RenameCasePattern.UpperCamelCase).VisitASTContext(driver.Context.ASTContext);
175172
}
176173

177174
public static void Main(string[] args)

0 commit comments

Comments
 (0)