From bd63f64062e3454e80e4500e7a7a86e4cb931d03 Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 5 Sep 2012 22:17:40 +0100 Subject: [PATCH] Added a new file with SDL library related transformations. --- src/Generator/SDL.cs | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/Generator/SDL.cs diff --git a/src/Generator/SDL.cs b/src/Generator/SDL.cs new file mode 100644 index 00000000..737751ba --- /dev/null +++ b/src/Generator/SDL.cs @@ -0,0 +1,58 @@ + +namespace Cxxi +{ + /// + /// Transform the SDL library declarations to something more .NET friendly. + /// + class SDLTransforms : LibraryTransform + { + public override void Transform(Generator g) + { + g.IgnoreEnumWithMatchingItem("SDL_FALSE"); + g.IgnoreEnumWithMatchingItem("DUMMY_ENUM_VALUE"); + + g.SetNameOfEnumWithMatchingItem("SDL_SCANCODE_UNKNOWN", "ScanCode"); + g.SetNameOfEnumWithMatchingItem("SDLK_UNKNOWN", "Key"); + g.SetNameOfEnumWithMatchingItem("KMOD_NONE", "KeyModifier"); + g.SetNameOfEnumWithMatchingItem("SDL_LOG_CATEGORY_CUSTOM", "LogCategory"); + + g.GenerateEnumFromMacros("InitFlags", "SDL_INIT_(.*)").SetFlags(); + g.GenerateEnumFromMacros("Endianness", "SDL_(.*)_ENDIAN"); + g.GenerateEnumFromMacros("KeyState", "SDL_RELEASED", "SDL_PRESSED"); + + g.GenerateEnumFromMacros("AlphaState", "SDL_ALPHA_(.*)"); + + g.GenerateEnumFromMacros("HatState", "SDL_HAT_(.*)"); + + g.IgnoreModuleWithName("SDL_atomic*"); + g.IgnoreModuleWithName("SDL_endian*"); + g.IgnoreModuleWithName("SDL_main*"); + g.IgnoreModuleWithName("SDL_mutex*"); + g.IgnoreModuleWithName("SDL_stdinc*"); + + //g.IgnoreModuleWithName("SDL_error"); + + g.IgnoreEnumWithMatchingItem("SDL_ENOMEM"); + g.IgnoreFunctionWithName("SDL_Error"); + + g.RemovePrefix("SDL_"); + g.RemovePrefix("SCANCODE_"); + g.RemovePrefix("SDLK_"); + g.RemovePrefix("KMOD_"); + g.RemovePrefix("LOG_CATEGORY_"); + + g.Process(); + + g.SetNameOfEnumWithName("PIXELTYPE", "PixelType"); + g.SetNameOfEnumWithName("BITMAPORDER", "BitmapOrder"); + g.SetNameOfEnumWithName("PACKEDORDER", "PackedOrder"); + g.SetNameOfEnumWithName("ARRAYORDER", "ArrayOrder"); + g.SetNameOfEnumWithName("PACKEDLAYOUT", "PackedLayout"); + g.SetNameOfEnumWithName("PIXELFORMAT", "PixelFormats"); + g.SetNameOfEnumWithName("assert_state", "AssertState"); + g.SetNameOfClassWithName("assert_data", "AssertData"); + + //gen.SetNameOfEnumWithName("LOG_CATEGORY", "LogCategory"); + } + } +}