Browse Source

Update the examples.

pull/1/head
triton 13 years ago
parent
commit
207354a688
  1. 13
      examples/Hello/Hello.Tests.cs
  2. 60
      examples/Hello/Hello.cs
  3. 5
      examples/Hello/Hello.h
  4. 33
      examples/Hello/premake4.lua
  5. 12
      examples/SDL/SDL.cs

13
examples/Hello/Hello.Tests.cs

@ -0,0 +1,13 @@ @@ -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());
}
}

60
examples/Hello/Hello.cs

@ -1,14 +1,54 @@ @@ -1,14 +1,54 @@
using System;
using CppCsBind;
using Cxxi.Generators;
using Cxxi.Passes;
public class HelloExample
namespace Cxxi.Tests
{
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());
}
}
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));
}
}
}
}

5
examples/Hello/Hello.h

@ -1,11 +1,6 @@ @@ -1,11 +1,6 @@
// Just try out that system include headers can be included - no need for them in this code.
#include <iostream>
#include <fstream>
#ifndef WIN32
#error "Generator should understand defines as well"
#endif
class Hello
{
public:

33
examples/Hello/premake4.lua

@ -1,34 +1,7 @@ @@ -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" }

12
examples/SDL/SDL.cs

@ -12,7 +12,7 @@ namespace Cxxi @@ -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 @@ -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");

Loading…
Cancel
Save