Skip to content

Commit f185be7

Browse files
committed
Code Generation project was becoming too bloated. I've splitted it in logical units, and separated extension builders into its own libraries. Hopefully, this would make adding more extensions easier.
1 parent cd861ac commit f185be7

File tree

79 files changed

+3149
-2860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3149
-2860
lines changed

SharpGLTF.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpGLTF.Ext.Agi", "src\Sh
7979
EndProject
8080
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpGLTF.Ext.3DTiles.Tests", "tests\SharpGLTF.Ext.3DTiles.Tests\SharpGLTF.Ext.3DTiles.Tests.csproj", "{373DF570-9782-419E-9AED-04BF2F1B2D89}"
8181
EndProject
82+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpGLTF.CodeGen.Core", "build\SharpGLTF.CodeGen.Core\SharpGLTF.CodeGen.Core.csproj", "{35553DE5-C37C-431A-B6E9-A72D84AABDB9}"
83+
EndProject
84+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpGLTF.codeGen.Extensions.Khronos", "build\SharpGLTF.codeGen.Extensions.Khronos\SharpGLTF.codeGen.Extensions.Khronos.csproj", "{688D381F-262F-48CF-B3B7-10EC757C3854}"
85+
EndProject
86+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpGLTF.CodeGen.Extensions.AGI", "build\SharpGLTF.CodeGen.Extensions.AGI\SharpGLTF.CodeGen.Extensions.AGI.csproj", "{9F601A55-5AD0-4323-824F-AF7AC4ABEA7F}"
87+
EndProject
88+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpGLTF.CodeGen.Extensions.Cesium", "build\SharpGLTF.CodeGen.Extensions.Cesium\SharpGLTF.CodeGen.Extensions.Cesium.csproj", "{93100BDB-1DDF-42B9-8C0D-816A0306A5EE}"
89+
EndProject
8290
Global
8391
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8492
Debug|Any CPU = Debug|Any CPU
@@ -161,6 +169,22 @@ Global
161169
{373DF570-9782-419E-9AED-04BF2F1B2D89}.Debug|Any CPU.Build.0 = Debug|Any CPU
162170
{373DF570-9782-419E-9AED-04BF2F1B2D89}.Release|Any CPU.ActiveCfg = Release|Any CPU
163171
{373DF570-9782-419E-9AED-04BF2F1B2D89}.Release|Any CPU.Build.0 = Release|Any CPU
172+
{35553DE5-C37C-431A-B6E9-A72D84AABDB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
173+
{35553DE5-C37C-431A-B6E9-A72D84AABDB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
174+
{35553DE5-C37C-431A-B6E9-A72D84AABDB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
175+
{35553DE5-C37C-431A-B6E9-A72D84AABDB9}.Release|Any CPU.Build.0 = Release|Any CPU
176+
{688D381F-262F-48CF-B3B7-10EC757C3854}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
177+
{688D381F-262F-48CF-B3B7-10EC757C3854}.Debug|Any CPU.Build.0 = Debug|Any CPU
178+
{688D381F-262F-48CF-B3B7-10EC757C3854}.Release|Any CPU.ActiveCfg = Release|Any CPU
179+
{688D381F-262F-48CF-B3B7-10EC757C3854}.Release|Any CPU.Build.0 = Release|Any CPU
180+
{9F601A55-5AD0-4323-824F-AF7AC4ABEA7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
181+
{9F601A55-5AD0-4323-824F-AF7AC4ABEA7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
182+
{9F601A55-5AD0-4323-824F-AF7AC4ABEA7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
183+
{9F601A55-5AD0-4323-824F-AF7AC4ABEA7F}.Release|Any CPU.Build.0 = Release|Any CPU
184+
{93100BDB-1DDF-42B9-8C0D-816A0306A5EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
185+
{93100BDB-1DDF-42B9-8C0D-816A0306A5EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
186+
{93100BDB-1DDF-42B9-8C0D-816A0306A5EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
187+
{93100BDB-1DDF-42B9-8C0D-816A0306A5EE}.Release|Any CPU.Build.0 = Release|Any CPU
164188
EndGlobalSection
165189
GlobalSection(SolutionProperties) = preSolution
166190
HideSolutionNode = FALSE
@@ -185,6 +209,10 @@ Global
185209
{F98E7E4B-EF27-48A0-BA56-730F14CEEEE1} = {072B725F-773F-4751-9616-E9778897C1D2}
186210
{6AB07AED-3DCE-422D-BE87-9379806F685C} = {072B725F-773F-4751-9616-E9778897C1D2}
187211
{373DF570-9782-419E-9AED-04BF2F1B2D89} = {0CBF510D-D836-40BA-95EC-E93FDBB90632}
212+
{35553DE5-C37C-431A-B6E9-A72D84AABDB9} = {D7D51F42-D08C-4DDA-88DA-AF008F10B644}
213+
{688D381F-262F-48CF-B3B7-10EC757C3854} = {D7D51F42-D08C-4DDA-88DA-AF008F10B644}
214+
{9F601A55-5AD0-4323-824F-AF7AC4ABEA7F} = {D7D51F42-D08C-4DDA-88DA-AF008F10B644}
215+
{93100BDB-1DDF-42B9-8C0D-816A0306A5EE} = {D7D51F42-D08C-4DDA-88DA-AF008F10B644}
188216
EndGlobalSection
189217
GlobalSection(ExtensibilityGlobals) = postSolution
190218
SolutionGuid = {1D7BBAD9-834C-4981-AC96-0AA5226FC43F}
Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,92 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
6-
namespace SharpGLTF.CodeGen
7-
{
8-
/// <summary>
9-
/// Text processing extensions to facilitate source code emission.
10-
/// </summary>
11-
static class CodeEmitUtils
12-
{
13-
public static string Indent(this string text, int indent)
14-
{
15-
while (indent > 0) { text = $"\t{text}"; --indent; }
16-
17-
return text;
18-
}
19-
20-
public static void EmitLine(this StringBuilder sb, int indent, string text)
21-
{
22-
text = text.Indent(indent);
23-
sb.AppendLine(text);
24-
}
25-
26-
public static void EmitBlock(this StringBuilder sb, int indent, string body)
27-
{
28-
sb.EmitLine(indent, "{");
29-
30-
var lines = body.Split(new[] { "\r\n", "\r", "\n" },StringSplitOptions.None);
31-
32-
foreach (var line in lines)
33-
{
34-
sb.EmitLine(indent + 1, line);
35-
}
36-
37-
sb.EmitLine(indent, "}");
38-
}
39-
40-
public static IEnumerable<string> AsCodeBlock(this IEnumerable<string> lines)
41-
{
42-
yield return "{";
43-
44-
foreach (var l in lines) yield return $"\t{l}";
45-
46-
yield return "}";
47-
}
48-
49-
public static IEnumerable<string> Indent(this IEnumerable<string> lines, int indent)
50-
{
51-
foreach (var l in lines) yield return l.Indent(indent);
52-
}
53-
54-
public static IEnumerable<string> EmitSummary(this string description, int indent)
55-
{
56-
if (string.IsNullOrWhiteSpace(description)) yield break;
57-
58-
description = _ReplaceDescriptionKeywords(description);
59-
60-
var lines = description
61-
.Split(" ")
62-
.Select(item => item.Trim())
63-
.ToList();
64-
65-
yield return "/// <summary>".Indent(indent);
66-
foreach(var l in lines) yield return $"/// {l}";
67-
yield return "/// </summary>".Indent(indent);
68-
}
69-
70-
private static string _ReplaceDescriptionKeywords(string description)
71-
{
72-
while(true)
73-
{
74-
var (start, len) = _FindDescriptionKeyword(description);
75-
if (start < 0) return description;
76-
77-
var block = description.Substring(start , len);
78-
var name = block.Substring(2, block.Length - 4);
79-
80-
description = description.Replace(block, $"<see cref=\"{name}\"/>", StringComparison.Ordinal);
81-
}
82-
}
83-
84-
private static (int start,int len) _FindDescriptionKeyword(string description)
85-
{
86-
int start = description.IndexOf("`\"");
87-
var end = description.IndexOf("\"`");
88-
if (start < 0 || end < 0 || start >= end) return (-1, -1);
89-
return (start, end - start + 2);
90-
}
91-
}
92-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace SharpGLTF.CodeGen
7+
{
8+
/// <summary>
9+
/// Text processing extensions to facilitate source code emission.
10+
/// </summary>
11+
static class CodeEmitUtils
12+
{
13+
public static string Indent(this string text, int indent)
14+
{
15+
while (indent > 0) { text = $"\t{text}"; --indent; }
16+
17+
return text;
18+
}
19+
20+
public static void EmitLine(this StringBuilder sb, int indent, string text)
21+
{
22+
text = text.Indent(indent);
23+
sb.AppendLine(text);
24+
}
25+
26+
public static void EmitBlock(this StringBuilder sb, int indent, string body)
27+
{
28+
sb.EmitLine(indent, "{");
29+
30+
var lines = body.Split(new[] { "\r\n", "\r", "\n" },StringSplitOptions.None);
31+
32+
foreach (var line in lines)
33+
{
34+
sb.EmitLine(indent + 1, line);
35+
}
36+
37+
sb.EmitLine(indent, "}");
38+
}
39+
40+
public static IEnumerable<string> AsCodeBlock(this IEnumerable<string> lines)
41+
{
42+
yield return "{";
43+
44+
foreach (var l in lines) yield return $"\t{l}";
45+
46+
yield return "}";
47+
}
48+
49+
public static IEnumerable<string> Indent(this IEnumerable<string> lines, int indent)
50+
{
51+
foreach (var l in lines) yield return l.Indent(indent);
52+
}
53+
54+
public static IEnumerable<string> EmitSummary(this string description, int indent)
55+
{
56+
if (string.IsNullOrWhiteSpace(description)) yield break;
57+
58+
description = _ReplaceDescriptionKeywords(description);
59+
60+
var lines = description
61+
.Split(" ")
62+
.Select(item => item.Trim())
63+
.ToList();
64+
65+
yield return "/// <summary>".Indent(indent);
66+
foreach(var l in lines) yield return $"/// {l}";
67+
yield return "/// </summary>".Indent(indent);
68+
}
69+
70+
private static string _ReplaceDescriptionKeywords(string description)
71+
{
72+
while(true)
73+
{
74+
var (start, len) = _FindDescriptionKeyword(description);
75+
if (start < 0) return description;
76+
77+
var block = description.Substring(start , len);
78+
var name = block.Substring(2, block.Length - 4);
79+
80+
description = description.Replace(block, $"<see cref=\"{name}\"/>", StringComparison.Ordinal);
81+
}
82+
}
83+
84+
private static (int start,int len) _FindDescriptionKeyword(string description)
85+
{
86+
int start = description.IndexOf("`\"");
87+
var end = description.IndexOf("\"`");
88+
if (start < 0 || end < 0 || start >= end) return (-1, -1);
89+
return (start, end - start + 2);
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)