From 51d422a756f01ed31f7b2ff78479342275c32fb6 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 5 Apr 2019 00:19:31 +0300 Subject: [PATCH] Fix invalid C++/CLI generated for anonymous types Signed-off-by: Dimitar Dobrev --- .../Passes/CleanInvalidDeclNamesPass.cs | 8 +++ tests/CSharp/CSharp.h | 66 ------------------- tests/Common/Common.h | 66 +++++++++++++++++++ 3 files changed, 74 insertions(+), 66 deletions(-) diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs index b4dcb990..733b6c1d 100644 --- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs +++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs @@ -4,6 +4,7 @@ using System.Text; using CppSharp.AST; using CppSharp.Generators.CLI; using CppSharp.Generators.CSharp; +using CppSharp.Generators; namespace CppSharp.Passes { @@ -14,6 +15,13 @@ namespace CppSharp.Passes if (!base.VisitClassDecl(@class)) return false; + if (Options.GeneratorKind == GeneratorKind.CLI && + string.IsNullOrEmpty(@class.OriginalName)) + { + @class.ExplicitlyIgnore(); + return true; + } + if (@class.Layout != null) { int order = 0; diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index 81de23ea..c96bd039 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -1307,72 +1307,6 @@ DLL_API void va_listFunction(va_list v); DLL_API char* returnCharPointer(); DLL_API const char* takeConstCharStarRef(const char*& c); -union -{ - struct - { - struct - { - long Capabilities; - } Server; - struct - { - long Capabilities; - } Share; - } Smb2; -} ProtocolSpecific; - -struct DLL_API TestNestedTypes -{ -public: - struct - { - struct - { - }; - }; - struct - { - struct - { - }; - }; - struct - { - struct - { - }; - }; - struct - { - struct - { - }; - }; - - union as_types - { - int as_int; - struct uchars - { - unsigned char blue, green, red, alpha; - } as_uchar; - }; -}; - -class TestNamingAnonymousTypesInUnion -{ -public: - union { - struct { - } argb; - struct { - } ahsv; - struct { - } acmyk; - } ct; -}; - struct { struct { struct { diff --git a/tests/Common/Common.h b/tests/Common/Common.h index f1da8eae..9aa5236c 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -822,6 +822,44 @@ public: DLL_API void va_listFunction(va_list v); +struct DLL_API TestNestedTypes +{ +public: + struct + { + struct + { + }; + }; + struct + { + struct + { + }; + }; + struct + { + struct + { + }; + }; + struct + { + struct + { + }; + }; + + union as_types + { + int as_int; + struct uchars + { + unsigned char blue, green, red, alpha; + } as_uchar; + }; +}; + class DLL_API HasStdString { public: @@ -883,6 +921,19 @@ private: DLL_API bool operator ==(const DifferentConstOverloads& d, const char* s); +class TestNamingAnonymousTypesInUnion +{ +public: + union { + struct { + } argb; + struct { + } ahsv; + struct { + } acmyk; + } ct; +}; + class DLL_API RefTypeClassPassTry { }; void DLL_API funcTryRefTypePtrOut(CS_OUT RefTypeClassPassTry* classTry); @@ -1380,6 +1431,21 @@ inline namespace InlineNamespace } } +union +{ + struct + { + struct + { + long Capabilities; + } Server; + struct + { + long Capabilities; + } Share; + } Smb2; +} ProtocolSpecific; + template using UsingTemplatePtr = _Other *;