From 277dc5c2ac43fcf4a2a3969d1a09c34a18420cab Mon Sep 17 00:00:00 2001 From: duckdoom5 <duckdoom5@users.noreply.github.com> Date: Thu, 27 Feb 2025 10:46:44 +0100 Subject: [PATCH] Misc changes --- CppSharp.sln.DotSettings | 1 + .../Bootstrap/CodeGeneratorHelpers.cs | 24 +++++++++---------- .../Generators/CSharp/CSharpTypePrinter.cs | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CppSharp.sln.DotSettings b/CppSharp.sln.DotSettings index 68fb4a1a..dd0332a7 100644 --- a/CppSharp.sln.DotSettings +++ b/CppSharp.sln.DotSettings @@ -1,5 +1,6 @@ <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CLI/@EntryIndexedValue">CLI</s:String> + <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MD/@EntryIndexedValue">MD</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MSVC/@EntryIndexedValue">MSVC</s:String> <s:Boolean x:Key="/Default/UserDictionary/Words/=diag/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=undefine/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> \ No newline at end of file diff --git a/src/CppParser/Bootstrap/CodeGeneratorHelpers.cs b/src/CppParser/Bootstrap/CodeGeneratorHelpers.cs index 810a6ea4..95033ede 100644 --- a/src/CppParser/Bootstrap/CodeGeneratorHelpers.cs +++ b/src/CppParser/Bootstrap/CodeGeneratorHelpers.cs @@ -47,8 +47,7 @@ namespace CppSharp return true; } - if (property.Name is "beginLoc" or "endLoc" && - @class.Name != "Stmt") + if (property.Name is "beginLoc" or "endLoc" && @class.Name != "Stmt") return true; switch (property.Name) @@ -309,7 +308,7 @@ namespace CppSharp else if (qualifiedName.Contains("Semantics")) qualifiedName = qualifiedName.Replace( typePrinter is CppTypePrinter ? "llvm::APFloatBase::Semantics" : "llvm.APFloatBase.Semantics" - , "FloatSemantics"); + , "FloatSemantics"); return qualifiedName; } @@ -319,11 +318,13 @@ namespace CppSharp private static string CleanClangNamespaceFromName(string qualifiedName) { - qualifiedName = qualifiedName.StartsWith("clang::") ? - qualifiedName.Substring("clang::".Length) : qualifiedName; + qualifiedName = qualifiedName.StartsWith("clang::") + ? qualifiedName.Substring("clang::".Length) + : qualifiedName; - qualifiedName = qualifiedName.StartsWith("clang.") ? - qualifiedName.Substring("clang.".Length) : qualifiedName; + qualifiedName = qualifiedName.StartsWith("clang.") + ? qualifiedName.Substring("clang.".Length) + : qualifiedName; return qualifiedName; } @@ -392,7 +393,8 @@ namespace CppSharp if (typeResult.Type.Contains("MSGuidDecl")) return typePrinter is CppTypePrinter - ? "std::string" : "string"; + ? "std::string" + : "string"; var typeName = typeResult.ToString(); typeName = CleanClangNamespaceFromName(typeName); @@ -436,8 +438,7 @@ namespace CppSharp className = "Declaration"; if (className != null) - return (typePrinter is CppTypePrinter) ? - $"{className}*" : className; + return (typePrinter is CppTypePrinter) ? $"{className}*" : className; return typeName; } @@ -525,8 +526,7 @@ namespace CppSharp while (currentClass != null) { baseClasses.Add(currentClass); - currentClass = currentClass.HasBaseClass ? - currentClass.BaseClass : null; + currentClass = currentClass.HasBaseClass ? currentClass.BaseClass : null; } baseClasses.Reverse(); diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index ba100fc7..095ecde9 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -315,7 +315,7 @@ namespace CppSharp.Generators.CSharp TemplateArgument lastArg = args.Last(); TypePrinterResult typePrinterResult = VisitDeclaration(decl); typePrinterResult.NameSuffix.Append($@"<{string.Join(", ", - args.Concat(Enumerable.Range(0, @class.TemplateParameters.Count - args.Count).Select( + args.Concat(Enumerable.Range(0, @class.TemplateParameters?.Count ?? 0 - args.Count).Select( i => lastArg)).Select(this.VisitTemplateArgument))}>"); return typePrinterResult; }