mirror of https://github.com/mono/CppSharp.git
4 changed files with 104 additions and 67 deletions
@ -1,67 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|
||||||
<PropertyGroup> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProjectGuid>{3EC927F3-5F8D-4D5D-B230-901ED2BB5D32}</ProjectGuid> |
|
||||||
<OutputType>Library</OutputType> |
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|
||||||
<RootNamespace>Generator.Tests</RootNamespace> |
|
||||||
<AssemblyName>Generator.Tests</AssemblyName> |
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|
||||||
<FileAlignment>512</FileAlignment> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget> |
|
||||||
<DebugSymbols>true</DebugSymbols> |
|
||||||
<DebugType>full</DebugType> |
|
||||||
<Optimize>false</Optimize> |
|
||||||
<OutputPath>bin\</OutputPath> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
<ErrorReport>prompt</ErrorReport> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget> |
|
||||||
<DebugType>pdbonly</DebugType> |
|
||||||
<Optimize>true</Optimize> |
|
||||||
<OutputPath>bin\</OutputPath> |
|
||||||
<DefineConstants>TRACE</DefineConstants> |
|
||||||
<ErrorReport>prompt</ErrorReport> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup> |
|
||||||
<StartupObject /> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<None Include="App.config" /> |
|
||||||
<None Include="packages.config" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="TestCLITypePrinter.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="nunit.framework"> |
|
||||||
<HintPath>..\..\build\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath> |
|
||||||
</Reference> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<ProjectReference Include="..\Bridge\CxxBridge.csproj"> |
|
||||||
<Project>{6beb8fa2-97aa-40b7-ab92-42f6eddc4490}</Project> |
|
||||||
<Name>CxxBridge</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\Generator\Generator.csproj"> |
|
||||||
<Project>{73499B8E-A6A4-42FF-AB8A-754CE2780777}</Project> |
|
||||||
<Name>Generator</Name> |
|
||||||
</ProjectReference> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|
||||||
Other similar extension points exist, see Microsoft.Common.targets. |
|
||||||
<Target Name="BeforeBuild"> |
|
||||||
</Target> |
|
||||||
<Target Name="AfterBuild"> |
|
||||||
</Target> |
|
||||||
--> |
|
||||||
</Project> |
|
@ -0,0 +1,24 @@ |
|||||||
|
project "Generator.Tests" |
||||||
|
|
||||||
|
kind "SharedLib" |
||||||
|
language "C#" |
||||||
|
location "." |
||||||
|
|
||||||
|
files { "**.cs" } |
||||||
|
|
||||||
|
libdirs |
||||||
|
{ |
||||||
|
depsdir .. "/NUnit", |
||||||
|
depsdir .. "/NSubstitute" |
||||||
|
} |
||||||
|
|
||||||
|
links |
||||||
|
{ |
||||||
|
"System", |
||||||
|
"System.Core", |
||||||
|
"Bridge", |
||||||
|
"Generator", |
||||||
|
"Parser", |
||||||
|
"NUnit.Framework", |
||||||
|
"NSubstitute" |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using Cxxi; |
||||||
|
using Cxxi.Types; |
||||||
|
|
||||||
|
namespace Generator.Tests |
||||||
|
{ |
||||||
|
public class HeaderTestFixture |
||||||
|
{ |
||||||
|
protected Library library; |
||||||
|
protected TypeMapDatabase database; |
||||||
|
|
||||||
|
private const string TestsDirectory = @"..\..\..\tests\Native"; |
||||||
|
|
||||||
|
protected void ParseLibrary(string file) |
||||||
|
{ |
||||||
|
ParseLibrary(TestsDirectory, file); |
||||||
|
} |
||||||
|
|
||||||
|
protected void ParseLibrary(string dir, string file) |
||||||
|
{ |
||||||
|
database = new TypeMapDatabase(); |
||||||
|
database.SetupTypeMaps(); |
||||||
|
|
||||||
|
var options = new Options(); |
||||||
|
|
||||||
|
var path = Path.Combine(Directory.GetCurrentDirectory(), dir); |
||||||
|
options.IncludeDirs.Add(path); |
||||||
|
|
||||||
|
var parser = new Parser(options); |
||||||
|
var result = parser.ParseHeader(file); |
||||||
|
|
||||||
|
if (!result.Success) |
||||||
|
throw new Exception("Could not parse file: " + file); |
||||||
|
|
||||||
|
library = result.Library; |
||||||
|
|
||||||
|
foreach (var diag in result.Diagnostics) |
||||||
|
Console.WriteLine(diag.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
using System.Linq; |
||||||
|
using Cxxi; |
||||||
|
|
||||||
|
namespace Generator.Tests |
||||||
|
{ |
||||||
|
public static class LibraryQueryExtensions |
||||||
|
{ |
||||||
|
public static Class Class(this Library library, string name) |
||||||
|
{ |
||||||
|
return library.FindClass(name).ToList().First(); |
||||||
|
} |
||||||
|
|
||||||
|
public static Function Function(this Library library, string name) |
||||||
|
{ |
||||||
|
return library.FindFunction(name).ToList().First(); |
||||||
|
} |
||||||
|
|
||||||
|
public static Enumeration Enum(this Library library, string name) |
||||||
|
{ |
||||||
|
return library.FindEnum(name).ToList().First(); |
||||||
|
} |
||||||
|
|
||||||
|
public static TypedefDecl Typedef(this Library library, string name) |
||||||
|
{ |
||||||
|
return library.FindTypedef(name).ToList().First(); |
||||||
|
} |
||||||
|
|
||||||
|
public static Field Field(this Class @class, string name) |
||||||
|
{ |
||||||
|
return @class.Fields.Find(field => field.Name == name); |
||||||
|
} |
||||||
|
|
||||||
|
public static Parameter Param(this Function function, int index) |
||||||
|
{ |
||||||
|
return function.Parameters[index]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue