diff --git a/examples/Hello/Hello.Tests.cs b/examples/Hello/Hello.Tests.cs new file mode 100644 index 00000000..3f4f217c --- /dev/null +++ b/examples/Hello/Hello.Tests.cs @@ -0,0 +1,13 @@ +using System; + +public class HelloTests +{ + public static void Main (String[] args) + { + var hello = new Hello(); + hello.PrintHello("Hello world"); + + Console.WriteLine("True =" + hello.test1(3, 3.0f).ToString()); + Console.WriteLine("False =" + hello.test1(2, 3.0f).ToString()); + } +} diff --git a/examples/Hello/Hello.cs b/examples/Hello/Hello.cs index d3910aa0..1b7aae5d 100644 --- a/examples/Hello/Hello.cs +++ b/examples/Hello/Hello.cs @@ -1,14 +1,54 @@ -using System; -using CppCsBind; - -public class HelloExample -{ - public static void Main (String[] args) { - var h = new Hello(); - h.PrintHello ("Hello world"); - Console.WriteLine("True =" + h.test1(3, 3.0f).ToString()); - Console.WriteLine("False =" + h.test1(2, 3.0f).ToString()); - } -} - - \ No newline at end of file +using Cxxi.Generators; +using Cxxi.Passes; + +namespace Cxxi.Tests +{ + class Hello : ILibrary + { + private LanguageGeneratorKind kind; + + public Hello(LanguageGeneratorKind kind) + { + this.kind = kind; + } + + public void Setup(DriverOptions options) + { + options.LibraryName = "Hello"; + options.GeneratorKind = kind; + options.OutputDir = kind == LanguageGeneratorKind.CPlusPlusCLI ? + "cli" : "cs"; + options.Headers.Add("Hello.h"); + options.IncludeDirs.Add("../../../examples/Hello"); + } + + public void Preprocess(Library lib) + { + } + + public void Postprocess(Library lib) + { + } + + public void SetupPasses(Driver driver, PassBuilder p) + { + } + + public void GenerateStart(TextTemplate template) + { + } + + public void GenerateAfterNamespaces(TextTemplate template) + { + } + + static class Program + { + public static void Main(string[] args) + { + Driver.Run(new Hello(LanguageGeneratorKind.CPlusPlusCLI)); + Driver.Run(new Hello(LanguageGeneratorKind.CSharp)); + } + } + } +} diff --git a/examples/Hello/Hello.h b/examples/Hello/Hello.h index d1b2bd41..9b3cbefe 100644 --- a/examples/Hello/Hello.h +++ b/examples/Hello/Hello.h @@ -1,16 +1,11 @@ -// Just try out that system include headers can be included - no need for them in this code. #include #include - -#ifndef WIN32 - #error "Generator should understand defines as well" -#endif - -class Hello -{ -public: - Hello (); - - void PrintHello(const char* s); - bool test1(int i, float f); -}; + +class Hello +{ +public: + Hello (); + + void PrintHello(const char* s); + bool test1(int i, float f); +}; diff --git a/examples/Hello/premake4.lua b/examples/Hello/premake4.lua index 0cc81ab0..db4a0484 100644 --- a/examples/Hello/premake4.lua +++ b/examples/Hello/premake4.lua @@ -1,34 +1,7 @@ -project "Hello" +SetupTestGeneratorProject("Hello", "Hello.cs") +SetupTestNativeProject("Hello.Native", { "Hello.cpp", "Hello.h" }) +SetupTestProject("Hello.Tests", { "Hello.Tests.cs"}, "Hello") - SetupNativeProject() - kind "SharedLib" - language "C++" - flags { common_flags, "Managed" } - - files { "**.h", "**.cpp", "./*.lua" } - - -- Autogenerated files, so not available on first build - specify them manually - excludes { "CppCsBind/*.*" } - files { "CppCsBind/hello_wrapper.h", "CppCsBind/hello_wrapper.cpp" } - - configuration "hello.h" - buildrule { - description = "Compiling $(InputFile)...", - commands = { - '..\\..\\bin\\generator.exe -D=WIN32 -vs=10 -ns=CppCsBind -outdir=CppCsBind -I. hello.h', - }, - outputs = { "CppCsBind\\hello_wrapper.cpp" } - } - -project "SayHello" - - kind "ConsoleApp" - language "C#" - location "." - - files { "**.cs", "./*.lua" } - - links { "Hello" } diff --git a/examples/SDL/SDL.cs b/examples/SDL/SDL.cs index c051245c..4731a112 100644 --- a/examples/SDL/SDL.cs +++ b/examples/SDL/SDL.cs @@ -12,7 +12,7 @@ namespace Cxxi { options.LibraryName = "SDL"; options.Headers.Add("SDL.h"); - options.IncludeDirs.Add("SDL-2.0/include"); + options.IncludeDirs.Add("../../../examples/SDL/SDL-2.0/include"); options.OutputDir = "SDL"; } @@ -32,11 +32,11 @@ namespace Cxxi lib.GenerateEnumFromMacros("AlphaState", "SDL_ALPHA_(.*)"); lib.GenerateEnumFromMacros("HatState", "SDL_HAT_(.*)"); - lib.IgnoreModulessWithName("SDL_atomic*"); - lib.IgnoreModulessWithName("SDL_endian*"); - lib.IgnoreModulessWithName("SDL_main*"); - lib.IgnoreModulessWithName("SDL_mutex*"); - lib.IgnoreModulessWithName("SDL_stdinc*"); + lib.IgnoreHeadersWithName("SDL_atomic*"); + lib.IgnoreHeadersWithName("SDL_endian*"); + lib.IgnoreHeadersWithName("SDL_main*"); + lib.IgnoreHeadersWithName("SDL_mutex*"); + lib.IgnoreHeadersWithName("SDL_stdinc*"); //lib.IgnoreModuleWithName("SDL_error"); lib.IgnoreEnumWithMatchingItem("SDL_ENOMEM");