mirror of https://github.com/mono/CppSharp.git
5 changed files with 85 additions and 64 deletions
@ -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()); |
||||
} |
||||
} |
@ -1,14 +1,54 @@
@@ -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()); |
||||
} |
||||
} |
||||
|
||||
|
||||
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)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,16 +1,11 @@
@@ -1,16 +1,11 @@
|
||||
// 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: |
||||
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); |
||||
}; |
||||
|
@ -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" } |
||||
|
||||
|
||||
|
Loading…
Reference in new issue