Browse Source

Renamed a few functions and factored out the SDL transforms.

pull/1/head
triton 13 years ago
parent
commit
b84196c0b7
  1. 9
      src/Generator/Generator.cs
  2. 13
      src/Generator/Program.cs
  3. 7
      src/Generator/SDL.cs
  4. 16
      src/Generator/Transform.cs

9
src/Generator/Generator.cs

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
using System;
using Cxxi.Templates;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using Cxxi;
using Cxxi.Templates;
namespace Cxxi
{
public partial class Generator
{
public List<ModuleTransform> Transformations { get; set; }
@ -239,3 +239,4 @@ public partial class Generator @@ -239,3 +239,4 @@ public partial class Generator
}
}
}
}

13
src/Generator/Program.cs

@ -69,14 +69,20 @@ class Program @@ -69,14 +69,20 @@ class Program
Library library;
Options options;
public void GenerateCode()
public void GenerateCode(LibraryTransform libTransform)
{
Console.WriteLine("Generating wrapper code...");
if (library.Modules.Count > 0)
{
var gen = new Generator(library, options);
TransformSDL(gen);
libTransform.Preprocess(gen);
gen.Process();
libTransform.Postprocess(gen);
gen.Generate();
}
}
@ -126,7 +132,8 @@ class Program @@ -126,7 +132,8 @@ class Program
library = new Library(options.OutputNamespace);
ParseCode();
GenerateCode();
GenerateCode(new SDLTransforms());
}
static void Main(String[] args)

7
src/Generator/SDL.cs

@ -6,7 +6,7 @@ namespace Cxxi @@ -6,7 +6,7 @@ namespace Cxxi
/// </summary>
class SDLTransforms : LibraryTransform
{
public override void Transform(Generator g)
public void Preprocess(Generator g)
{
g.IgnoreEnumWithMatchingItem("SDL_FALSE");
g.IgnoreEnumWithMatchingItem("DUMMY_ENUM_VALUE");
@ -40,9 +40,10 @@ namespace Cxxi @@ -40,9 +40,10 @@ namespace Cxxi
g.RemovePrefix("SDLK_");
g.RemovePrefix("KMOD_");
g.RemovePrefix("LOG_CATEGORY_");
}
g.Process();
public void Postprocess(Generator g)
{
g.SetNameOfEnumWithName("PIXELTYPE", "PixelType");
g.SetNameOfEnumWithName("BITMAPORDER", "BitmapOrder");
g.SetNameOfEnumWithName("PACKEDORDER", "PackedOrder");

16
src/Generator/Transform.cs

@ -1,14 +1,23 @@ @@ -1,14 +1,23 @@
using Cxxi;
using System;
using System;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Cxxi
{
/// <summary>
/// Used to massage the library types into something more .NET friendly.
/// </summary>
public interface LibraryTransform
{
public void Transform(Generator g);
/// <summary>
/// Do transformations that should happen before processing here.
/// </summary>
void Preprocess(Generator g);
/// <summary>
/// Do transformations that should happen after processing here.
/// </summary>
void Postprocess(Generator g);
}
/// <summary>
@ -260,3 +269,4 @@ public partial class Generator @@ -260,3 +269,4 @@ public partial class Generator
}
}
}
Loading…
Cancel
Save