Browse Source

Renamed a few functions and factored out the SDL transforms.

pull/1/head
triton 14 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 @@
using System; using Cxxi.Templates;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Cxxi; namespace Cxxi
using Cxxi.Templates; {
public partial class Generator public partial class Generator
{ {
public List<ModuleTransform> Transformations { get; set; } public List<ModuleTransform> Transformations { get; set; }
@ -239,3 +239,4 @@ public partial class Generator
} }
} }
} }
}

13
src/Generator/Program.cs

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

7
src/Generator/SDL.cs

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

16
src/Generator/Transform.cs

@ -1,14 +1,23 @@
using Cxxi; using System;
using System;
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Cxxi
{
/// <summary> /// <summary>
/// Used to massage the library types into something more .NET friendly. /// Used to massage the library types into something more .NET friendly.
/// </summary> /// </summary>
public interface LibraryTransform 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> /// <summary>
@ -260,3 +269,4 @@ public partial class Generator
} }
} }
}
Loading…
Cancel
Save