From b6f651b45cc16f25221bacb703169d776d0db409 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 16 Apr 2019 16:50:05 +0100 Subject: [PATCH] Deduplicate function names --- Generator/CodeParser/CodeParser.Class.cs | 23 +++++++++++++++++++++++ Generator/CodeParser/ParseClasses.cs | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Generator/CodeParser/CodeParser.Class.cs b/Generator/CodeParser/CodeParser.Class.cs index afc2192..d9d59a0 100644 --- a/Generator/CodeParser/CodeParser.Class.cs +++ b/Generator/CodeParser/CodeParser.Class.cs @@ -46,6 +46,29 @@ internal Function AddFunction( string funcName, string returnType, string args ) return f; } + + public void PostProcess() + { + var LastName = ""; + var DuplicateCount = 0; + + for (int i=0; i< Functions.Count; i++ ) + { + var ThisName = Functions[i].Name; + + if ( Functions[i].Name == LastName) + { + DuplicateCount++; + Functions[i].Name += $"{DuplicateCount + 1}"; + } + else + { + DuplicateCount = 0; + } + + LastName = ThisName; + } + } } } diff --git a/Generator/CodeParser/ParseClasses.cs b/Generator/CodeParser/ParseClasses.cs index 9392cee..df1dd46 100644 --- a/Generator/CodeParser/ParseClasses.cs +++ b/Generator/CodeParser/ParseClasses.cs @@ -54,7 +54,7 @@ public void ProcessClass( string fulldef, string classname, string inner ) if ( line.Trim().StartsWith( "public:" ) ) continue; if ( line.Trim().StartsWith( "//" ) ) continue; - var callresult = Regex.Match( line, @"STEAM_CALL_RESULT\( (.+?) \)" ); + var callresult = Regex.Match( line, @"STEAM_CALL_RESULT\((.+?)\)" ); if ( callresult.Success ) { lastCallResult = callresult.Groups[1].Value.Trim(); @@ -89,6 +89,7 @@ public void ProcessClass( string fulldef, string classname, string inner ) } } + c.PostProcess(); Classes.Add( c ); }