Skip to content

Commit 310f111

Browse files
committed
Handled any level of nesting when generating internals for specialisations in C#.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 5ca9345 commit 310f111

File tree

3 files changed

+57
-19
lines changed

3 files changed

+57
-19
lines changed

src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -725,26 +725,26 @@ namespace Rep
725725
public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C
726726
{
727727
[FieldOffset(0)]
728-
internal global::Std.BasicString.Rep._.__Internal _;
728+
internal global::Std.BasicString.Rep._.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C _;
729729
}
730730

731-
732-
public unsafe partial struct _
731+
namespace _
733732
{
734733
[StructLayout(LayoutKind.Explicit, Size = 12)]
735-
public partial struct __Internal
734+
public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C
736735
{
737736
[FieldOffset(0)]
738-
internal global::Std.BasicString.Long.__Internal __l;
737+
internal global::Std.BasicString.Long.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C __l;
739738

740739
[FieldOffset(0)]
741-
internal global::Std.BasicString.Short.__Internal __s;
740+
internal global::Std.BasicString.Short.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C __s;
742741

743742
[FieldOffset(0)]
744-
internal global::Std.BasicString.Raw.__Internal __r;
743+
internal global::Std.BasicString.Raw.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C __r;
745744
}
746745

747746
}
747+
748748
}
749749

750750
namespace Long
@@ -770,17 +770,16 @@ namespace Short
770770
public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C
771771
{
772772
[FieldOffset(0)]
773-
internal global::Std.BasicString.Short._.__Internal _;
773+
internal global::Std.BasicString.Short._.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C _;
774774

775775
[FieldOffset(1)]
776776
internal fixed sbyte __data_[11];
777777
}
778778

779-
780-
public unsafe partial struct _
779+
namespace _
781780
{
782781
[StructLayout(LayoutKind.Explicit, Size = 1)]
783-
public partial struct __Internal
782+
public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C
784783
{
785784
[FieldOffset(0)]
786785
internal byte __size_;
@@ -790,6 +789,7 @@ public partial struct __Internal
790789
}
791790

792791
}
792+
793793
}
794794

795795
namespace Raw

src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,23 @@ public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_
728728
internal global::Std.BasicString.Rep._.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C _;
729729
}
730730

731+
namespace _
732+
{
733+
[StructLayout(LayoutKind.Explicit, Size = 24)]
734+
public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C
735+
{
736+
[FieldOffset(0)]
737+
internal global::Std.BasicString.Long.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C __l;
738+
739+
[FieldOffset(0)]
740+
internal global::Std.BasicString.Short.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C __s;
741+
742+
[FieldOffset(0)]
743+
internal global::Std.BasicString.Raw.__Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C __r;
744+
}
745+
746+
}
747+
731748
}
732749

733750
namespace Long
@@ -759,6 +776,20 @@ public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_
759776
internal fixed sbyte __data_[23];
760777
}
761778

779+
namespace _
780+
{
781+
[StructLayout(LayoutKind.Explicit, Size = 1)]
782+
public unsafe partial struct __Internalc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C
783+
{
784+
[FieldOffset(0)]
785+
internal byte __size_;
786+
787+
[FieldOffset(0)]
788+
internal sbyte __lx;
789+
}
790+
791+
}
792+
762793
}
763794

764795
namespace Raw

src/Generator/Generators/CSharp/CSharpSources.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,26 @@ classTemplate.OriginalNamespace is Class ?
271271
GenerateClassInternals(specialization);
272272

273273
foreach (var group in generated.SelectMany(s => s.Classes).GroupBy(c => c.Name))
274-
{
275-
WriteLine($"namespace {group.Key}");
276-
WriteStartBraceIndent();
277-
foreach (var nestedClass in group)
278-
GenerateClassInternals(nestedClass);
279-
WriteCloseBraceIndent();
280-
NewLine();
281-
}
274+
GenerateNestedInternals(group.Key, group);
282275

283276
WriteCloseBraceIndent();
284277
PopBlock(NewLineKind.BeforeNextBlock);
285278
}
286279

280+
private void GenerateNestedInternals(string name, IEnumerable<Class> nestedClasses)
281+
{
282+
WriteLine($"namespace {name}");
283+
WriteStartBraceIndent();
284+
foreach (var nestedClass in nestedClasses)
285+
{
286+
GenerateClassInternals(nestedClass);
287+
foreach (var nestedInNested in nestedClass.Classes)
288+
GenerateNestedInternals(nestedInNested.Name, new[] { nestedInNested });
289+
}
290+
WriteCloseBraceIndent();
291+
NewLine();
292+
}
293+
287294
private IEnumerable<ClassTemplateSpecialization> GetGenerated(
288295
IList<ClassTemplateSpecialization> specializations)
289296
{

0 commit comments

Comments
 (0)