Browse Source

indentation and cosmetic fixes, also .gitignore

pull/1/head
Andreia Gaita 15 years ago
parent
commit
eb3e32d163
  1. 16
      .gitignore
  2. 1
      build/Mono.VisualC.Code.dll
  3. 1
      build/Mono.VisualC.Code.dll.mdb
  4. 1
      build/Mono.VisualC.Interop.dll
  5. 1
      build/Mono.VisualC.Interop.dll.mdb
  6. 1
      build/generator
  7. 1
      build/generator.exe
  8. 1
      build/generator.exe.mdb
  9. 43
      src/CPPInterop.sln
  10. 2
      src/CPPTestLib/CPPTestLib.cproj
  11. 7
      src/Mono.VisualC.Code/Mono.VisualC.Code.csproj
  12. 7
      src/Mono.VisualC.Interop/Mono.VisualC.Interop.csproj
  13. 7
      src/QtBindings/QtBindings.csproj
  14. 7
      src/QtTest/QtTest.csproj
  15. 7
      src/Tests/Tests.csproj
  16. 204
      src/generator/Main.cs
  17. 1
      tests/Mono.VisualC.Code.dll
  18. 1
      tests/Mono.VisualC.Code.dll.mdb
  19. 1
      tests/Mono.VisualC.Interop.dll
  20. 1
      tests/Mono.VisualC.Interop.dll.mdb
  21. 1
      tests/generator.exe
  22. 1
      tests/generator.exe.mdb
  23. 16
      tests/output/Lib_Lib.cs
  24. BIN
      tests/qttests/bin/Debug/Mono.VisualC.Code.dll
  25. BIN
      tests/qttests/bin/Debug/Mono.VisualC.Code.dll.mdb
  26. BIN
      tests/qttests/bin/Debug/Mono.VisualC.Interop.dll
  27. BIN
      tests/qttests/bin/Debug/Mono.VisualC.Interop.dll.mdb
  28. 7
      tests/qttests/qttests.csproj
  29. BIN
      tests/qttests/qttests.pidb

16
.gitignore vendored

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
*.pidb
configure
install-sh
aclocal.m4
config.status
config.log
autom4te.cache
missing
*Makefile
*Makefile.in
*.dll
*.exe
bin/
*.userprefs
tests/output
src/generator/generator

1
build/Mono.VisualC.Code.dll

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Code/bin/Debug/Mono.VisualC.Code.dll

1
build/Mono.VisualC.Code.dll.mdb

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Code/bin/Debug/Mono.VisualC.Code.dll.mdb

1
build/Mono.VisualC.Interop.dll

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Interop/bin/Debug/Mono.VisualC.Interop.dll

1
build/Mono.VisualC.Interop.dll.mdb

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Interop/bin/Debug/Mono.VisualC.Interop.dll.mdb

1
build/generator

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/generator/bin/Debug/generator

1
build/generator.exe

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/generator/bin/Debug/generator.exe

1
build/generator.exe.mdb

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/generator/bin/Debug/generator.exe.mdb

43
src/CPPInterop.sln

@ -23,23 +23,22 @@ Global @@ -23,23 +23,22 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Release|Any CPU.Build.0 = Release|Any CPU
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Release|Any CPU.Build.0 = Release|Any CPU
{3C290CBE-CA39-47F6-B3A0-ACD16C5A38C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C290CBE-CA39-47F6-B3A0-ACD16C5A38C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C290CBE-CA39-47F6-B3A0-ACD16C5A38C8}.Release|Any CPU.Build.0 = Release|Any CPU
{3EE6B50E-58FB-4391-AF01-3FCB1A29B0D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3EE6B50E-58FB-4391-AF01-3FCB1A29B0D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EE6B50E-58FB-4391-AF01-3FCB1A29B0D7}.Release|Any CPU.Build.0 = Release|Any CPU
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A864586-93C5-4DC1-8A80-F094A88506D7}.Release|Any CPU.Build.0 = Release|Any CPU
{66212CA6-B8C2-4307-ADDE-DAFEAAB339B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66212CA6-B8C2-4307-ADDE-DAFEAAB339B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66212CA6-B8C2-4307-ADDE-DAFEAAB339B9}.Release|Any CPU.Build.0 = Release|Any CPU
{8DBA7E4A-7736-499A-85AC-0524535B880A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DBA7E4A-7736-499A-85AC-0524535B880A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DBA7E4A-7736-499A-85AC-0524535B880A}.Release|Any CPU.Build.0 = Release|Any CPU
{A22BF9D9-BBCB-4462-BE08-0F4D5280B180}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A22BF9D9-BBCB-4462-BE08-0F4D5280B180}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A22BF9D9-BBCB-4462-BE08-0F4D5280B180}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -48,21 +47,15 @@ Global @@ -48,21 +47,15 @@ Global
{AD0F9378-789C-4AF1-B0DD-6DD9A63C3401}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD0F9378-789C-4AF1-B0DD-6DD9A63C3401}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD0F9378-789C-4AF1-B0DD-6DD9A63C3401}.Release|Any CPU.Build.0 = Release|Any CPU
{8DBA7E4A-7736-499A-85AC-0524535B880A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DBA7E4A-7736-499A-85AC-0524535B880A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DBA7E4A-7736-499A-85AC-0524535B880A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B01E6282-144E-481A-8E1F-95F708DFBC2D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = QtTest\QtTest.csproj
Policies = $0
$0.TextStylePolicy = $1
$1.NoTabsAfterNonTabs = True
$1.RemoveTrailingWhitespace = True
$1.inheritsSet = Mono
$1.inheritsScope = text/plain
$1.inheritsSet = null
$1.scope = text/x-csharp
$0.CSharpFormattingPolicy = $2
$2.NamespaceBraceStyle = EndOfLine
@ -70,12 +63,22 @@ Global @@ -70,12 +63,22 @@ Global
$2.InterfaceBraceStyle = EndOfLine
$2.StructBraceStyle = EndOfLine
$2.EnumBraceStyle = EndOfLine
$2.SpacesAfterTypecast = True
$2.inheritsSet = Mono
$2.inheritsScope = text/x-csharp
$2.scope = text/x-csharp
$0.StandardHeader = $3
$3.Text =
$3.inheritsSet = Apache2License
$0.TextStylePolicy = $4
$4.FileWidth = 120
$4.TabWidth = 4
$4.RemoveTrailingWhitespace = True
$4.inheritsSet = Mono
$4.inheritsScope = text/plain
$4.scope = text/plain
name = CPPInterop
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

2
src/CPPTestLib/CPPTestLib.cproj

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

7
src/Mono.VisualC.Code/Mono.VisualC.Code.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -91,11 +91,6 @@ @@ -91,11 +91,6 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" />
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
<ProjectReference Include="..\Mono.VisualC.Interop\Mono.VisualC.Interop.csproj">
<Project>{4A864586-93C5-4DC1-8A80-F094A88506D7}</Project>

7
src/Mono.VisualC.Interop/Mono.VisualC.Interop.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -101,9 +101,4 @@ @@ -101,9 +101,4 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" />
</MonoDevelop>
</ProjectExtensions>
</Project>

7
src/QtBindings/QtBindings.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -100,9 +100,4 @@ @@ -100,9 +100,4 @@
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" />
</MonoDevelop>
</ProjectExtensions>
</Project>

7
src/QtTest/QtTest.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -60,11 +60,6 @@ @@ -60,11 +60,6 @@
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" />
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
<ProjectReference Include="..\QtBindings\QtBindings.csproj">
<Project>{66212CA6-B8C2-4307-ADDE-DAFEAAB339B9}</Project>

7
src/Tests/Tests.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -72,11 +72,6 @@ @@ -72,11 +72,6 @@
<Compile Include="Support\VirtualMethodTestClass.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" />
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
<ProjectReference Include="..\CPPTestLib\CPPTestLib.cproj">
<Project>{B01E6282-144E-481A-8E1F-95F708DFBC2D}</Project>

204
src/generator/Main.cs

@ -25,10 +25,10 @@ namespace Mono.VisualC.Tools.Generator { @@ -25,10 +25,10 @@ namespace Mono.VisualC.Tools.Generator {
public static readonly string [] genericTypeArgs = new string [] { "T", "U", "V", "W", "X", "Y", "Z" };
public string Source { get; set; }
public string Dir {get; set;}
public string Dir { get; set; }
public bool AbiTest { get; set; }
public bool Validation { get; set; }
public string Library {get; set;}
public string Library { get; set; }
private string nspace;
public string Namespace {
@ -51,33 +51,24 @@ namespace Mono.VisualC.Tools.Generator { @@ -51,33 +51,24 @@ namespace Mono.VisualC.Tools.Generator {
//private CodeUnit currentUnit;
//private CodeUnit enumerations;
//private CodeUnit unions;
private Dictionary<string,Property> properties;
private Dictionary<string, Property> properties;
private int enumCount = 0;
private int unionCount = 0;
private HashSet<string> fileList;
public static void Main (string[] args)
public static void Main (string [] args)
{
bool help = false;
Generator gen = new Generator ();
gen.Validation = true;
var p = new OptionSet () {
{ "h|?|help", "Show this help message", v => help = v != null },
{ "f=", "Set the xml outputted by gccxml to parse", v => gen.Source = v },
{ "o=", "Set the output directory", v => gen.Dir = v },
{ "ns=", "Set the namespace", v => gen.Namespace = v },
{ "lib=", "Additional reference libraries", v => gen.Library = v },
{ "lang=", "Language of the outputted library (C#, VB, etc)", v => gen.Provider = CodeDomProvider.CreateProvider (v) },
{ "testabi", "Test the Itanium name mangling abi against the bindings", v => gen.AbiTest = v != null },
{ "n", "Don't validate", v => gen.Validation = !(v != null) },
};
var p = new OptionSet { { "h|?|help", "Show this help message", v => help = v != null }, { "f=", "Set the xml outputted by gccxml to parse", v => gen.Source = v }, { "o=", "Set the output directory", v => gen.Dir = v }, { "ns=", "Set the namespace", v => gen.Namespace = v }, { "lib=", "Additional reference libraries", v => gen.Library = v }, { "lang=", "Language of the outputted library (C#, VB, etc)", v => gen.Provider = CodeDomProvider.CreateProvider (v) }, { "testabi", "Test the Itanium name mangling abi against the bindings", v => gen.AbiTest = v != null }, { "n", "Don't validate", v => gen.Validation = !(v != null) } };
List<string> extra = null;
try {
extra = p.Parse(args);
} catch (OptionException){
extra = p.Parse (args);
} catch (OptionException) {
Console.WriteLine ("Try `generator --help' for more information.");
return;
}
@ -107,16 +98,14 @@ namespace Mono.VisualC.Tools.Generator { @@ -107,16 +98,14 @@ namespace Mono.VisualC.Tools.Generator {
if (gen.Provider == null)
gen.Provider = new CSharpCodeProvider ();
gen.Options = new CodeGeneratorOptions () {
BlankLinesBetweenMembers = false
};
gen.Options = new CodeGeneratorOptions { BlankLinesBetweenMembers = false };
gen.Run ();
}
public Generator ()
{
Classes = new Dictionary<string, string>();
Classes = new Dictionary<string, string> ();
UnknownTypes = new HashSet<string> ();
Tree = new CodeUnit { ManagedNamespace = Namespace };
@ -189,25 +178,20 @@ namespace Mono.VisualC.Tools.Generator { @@ -189,25 +178,20 @@ namespace Mono.VisualC.Tools.Generator {
XmlNode node = xmldoc.SelectSingleNode ("/GCC_XML");
Entry.typelist = new Dictionary<string, Dictionary<string, Entry>> ();
Entry.idlist = new Dictionary<string, Entry> ();
return Preprocess(node);
return Preprocess (node);
}
int typecount = 0;
List<Entry> Preprocess(XmlNode parent)
List<Entry> Preprocess (XmlNode parent)
{
List<Entry> data = new List<Entry> ();
foreach (XmlNode node in parent.ChildNodes) {
Dictionary<string, string> entry = new Dictionary<string, string>();
Dictionary<string, string> entry = new Dictionary<string, string> ();
foreach (XmlAttribute att in node.Attributes) {
entry[att.Name] = att.Value;
}
Entry e = new Entry () {
id = "",
type = node.Name,
name = "",
reftype = "",
attributes = entry };
Entry e = new Entry { id = "", type = node.Name, name = "", reftype = "", attributes = entry };
if (entry.ContainsKey ("name"))
e.id = e.name = entry["name"];
@ -242,17 +226,12 @@ namespace Mono.VisualC.Tools.Generator { @@ -242,17 +226,12 @@ namespace Mono.VisualC.Tools.Generator {
void PreprocessClasses (List<Entry> entries)
{
entries.RemoveAll (o => (o.type == "Class" || o.type == "Struct") &&
(o.IsTrue ("incomplete") ||
!o.HasValue ("name") ||
(Entry.idlist[o["file"]].name.StartsWith ("/"))
));
entries.RemoveAll (o => (o.type == "Class" || o.type == "Struct") && (o.IsTrue ("incomplete") || !o.HasValue ("name") || (Entry.idlist[o["file"]].name.StartsWith ("/"))));
}
void ProcessClasses (List<Entry> entries)
{
foreach (Entry clas in entries.Where (o => o.type == "Class" || o.type == "Struct"))
{
foreach (Entry clas in entries.Where (o => o.type == "Class" || o.type == "Struct")) {
//onsole.WriteLine (clas.name);
//bool bb;
//if (clas.name.StartsWith ("QGraphicsBlurEffect"))
@ -266,7 +245,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -266,7 +245,7 @@ namespace Mono.VisualC.Tools.Generator {
// FIXME: better way to do this (GCC-XML output doesn't seem to leave much choice)
CppType[] replaceArgs = null;
CppType [] replaceArgs = null;
var templated = currentType.Modifiers.OfType<CppModifiers.TemplateModifier> ().SingleOrDefault ();
if (templated != null) {
clas.isTemplate = true;
@ -276,25 +255,19 @@ namespace Mono.VisualC.Tools.Generator { @@ -276,25 +255,19 @@ namespace Mono.VisualC.Tools.Generator {
replaceArgs = templated.Types;
string[] ras = new string[replaceArgs.Length];
string[] letters = new string[replaceArgs.Length];
string [] ras = new string[replaceArgs.Length];
string [] letters = new string[replaceArgs.Length];
for (int i = 0; i < replaceArgs.Length; i++) {
letters[i] = genericTypeArgs[i];
ras[i] = string.Format ("{0} with {1}", replaceArgs[i].ToString (), letters[i]);
}
Console.Error.WriteLine ("Warning: Creating generic type {0}<{1}> from the instantiated template {2} by replacing {3} (very buggy!!!)",
baseName,
string.Join (",", letters),
clas.computedName,
string.Join (", ", ras));
Console.Error.WriteLine ("Warning: Creating generic type {0}<{1}> from the instantiated template {2} by replacing {3} (very buggy!!!)", baseName, string.Join (",", letters), clas.computedName, string.Join (", ", ras));
clas.computedName = baseName;
} else if (IsCreated (currentType, true, out nested))
continue;
clas.atom = new Class (clas.computedName) {
StaticCppLibrary = string.Format ("{0}.Libs.{1}", Namespace, Library)
};
clas.atom = new Class (clas.computedName) { StaticCppLibrary = string.Format ("{0}.Libs.{1}", Namespace, Library) };
GetContainer (clas, Tree).Atoms.AddLast (clas.atom);
@ -311,13 +284,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -311,13 +284,7 @@ namespace Mono.VisualC.Tools.Generator {
// FIXME: Handle when base class name is fully qualified
foreach (Entry bs in clas.children.Where (o => o.type == "Base")) {
clas.Class.Bases.Add (new Class.BaseClass {
Name = bs.Base.name,
Access = bs.CheckValue ("access", "public") ? Access.Public :
bs.CheckValue ("access", "protected") ? Access.Protected :
Access.Private,
IsVirtual = bs.IsTrue ("virtual")
});
clas.Class.Bases.Add (new Class.BaseClass { Name = bs.Base.name, Access = bs.CheckValue ("access", "public") ? Access.Public : bs.CheckValue ("access", "protected") ? Access.Protected : Access.Private, IsVirtual = bs.IsTrue ("virtual") });
}
Dictionary<MethodSignature, string> methods = new Dictionary<MethodSignature, string> ();
@ -349,9 +316,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -349,9 +316,7 @@ namespace Mono.VisualC.Tools.Generator {
// Now we're processing a method...
if (!member.CheckValue ("access", "public") ||
(member.HasValue ("overrides") && !dtor) ||
!member.IsTrue ("extern"))
if (!member.CheckValue ("access", "public") || (member.HasValue ("overrides") && !dtor) || !member.IsTrue ("extern"))
continue;
string mname = member.name;
@ -363,18 +328,11 @@ namespace Mono.VisualC.Tools.Generator { @@ -363,18 +328,11 @@ namespace Mono.VisualC.Tools.Generator {
retType = replaceType (retType, replaceArgs[i], genericTypeArgs[i]);
}
var methodAtom = new Method (dtor ? "Destruct" : mname) {
RetType = retType,
IsVirtual = member.IsTrue ("virtual"),
IsStatic = member.IsTrue ("static"),
IsConst = member.IsTrue ("const"),
IsConstructor = ctor,
IsDestructor = dtor
};
var methodAtom = new Method (dtor ? "Destruct" : mname) { RetType = retType, IsVirtual = member.IsTrue ("virtual"), IsStatic = member.IsTrue ("static"), IsConst = member.IsTrue ("const"), IsConstructor = ctor, IsDestructor = dtor };
if (AbiTest)
methodAtom.Mangled = new NameTypePair<Type> { Name = member.attributes["mangled"], Type = typeof (ItaniumAbi) };
methodAtom.Mangled = new NameTypePair<Type> { Name = member.attributes["mangled"], Type = typeof(ItaniumAbi) };
List<CppType> argTypes = new List<CppType> ();
int c = 0;
@ -421,8 +379,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -421,8 +379,7 @@ namespace Mono.VisualC.Tools.Generator {
// if it's const, returns a value, has no parameters, and there is no other method with the same name
// in this class assume it's a property getter (for now?)
if (methodAtom.IsConst && !retType.Equals (CppTypes.Void) && !methodAtom.Parameters.Any () &&
clas.Members.Where (o => o.name == mname).FirstOrDefault() == null) {
if (methodAtom.IsConst && !retType.Equals (CppTypes.Void) && !methodAtom.Parameters.Any () && clas.Members.Where (o => o.name == mname).FirstOrDefault () == null) {
var pname = methodAtom.FormattedName;
Property propertyAtom;
@ -439,8 +396,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -439,8 +396,7 @@ namespace Mono.VisualC.Tools.Generator {
// if it's name starts with "set", does not return a value, and has one arg (besides this ptr)
// and there is no other method with the same name...
if (mname.ToLower ().StartsWith ("set") && retType.Equals (CppTypes.Void) && methodAtom.Parameters.Count == 1 &&
clas.Members.Where (o => o.name == mname).FirstOrDefault () == null) {
if (mname.ToLower ().StartsWith ("set") && retType.Equals (CppTypes.Void) && methodAtom.Parameters.Count == 1 && clas.Members.Where (o => o.name == mname).FirstOrDefault () == null) {
string getterName = mname.Substring (3).TrimStart ('_').ToLower ();
@ -715,13 +671,8 @@ namespace Mono.VisualC.Tools.Generator { @@ -715,13 +671,8 @@ namespace Mono.VisualC.Tools.Generator {
Assembly Validate ()
{
var compileParams = new CompilerParameters {
GenerateInMemory = true,
IncludeDebugInformation = true,
WarningLevel = 0,
TreatWarningsAsErrors = false
};
compileParams.ReferencedAssemblies.Add (typeof (CppLibrary).Assembly.Location);
var compileParams = new CompilerParameters { GenerateInMemory = true, IncludeDebugInformation = true, WarningLevel = 0, TreatWarningsAsErrors = false };
compileParams.ReferencedAssemblies.Add (typeof(CppLibrary).Assembly.Location);
CompilerResults results = Provider.CompileAssemblyFromFile (compileParams, fileList.ToArray ());
var errors = results.Errors.Cast<CompilerError> ().Where (e => !e.IsWarning);
@ -750,8 +701,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -750,8 +701,7 @@ namespace Mono.VisualC.Tools.Generator {
void TestAbi (Assembly assembly)
{
var classes = assembly.GetExportedTypes ().Select (t => new { Name = Regex.Replace (t.Name, "\\`.$", ""), Interface = t.GetNestedType ("I" + t.Name)})
.Where (k => k.Interface != null);
var classes = assembly.GetExportedTypes ().Select (t => new { Name = Regex.Replace (t.Name, "\\`.$", ""), Interface = t.GetNestedType ("I" + t.Name) }).Where (k => k.Interface != null);
var abi = new ItaniumAbi ();
foreach (var klass in classes) {
@ -759,7 +709,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -759,7 +709,7 @@ namespace Mono.VisualC.Tools.Generator {
foreach (var method in klass.Interface.GetMethods ()) {
var testAttribute = (AbiTestAttribute)method.GetCustomAttributes (typeof (AbiTestAttribute), false).FirstOrDefault ();
var testAttribute = (AbiTestAttribute)method.GetCustomAttributes (typeof(AbiTestAttribute), false).FirstOrDefault ();
string expected = testAttribute.MangledName;
string actual = abi.GetMangledMethodName (klass.Name, method);
@ -784,8 +734,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -784,8 +734,7 @@ namespace Mono.VisualC.Tools.Generator {
Entry ns = entry.Namespace;
if (ns.type == "Namespace")
nsname = ns.name;
else if (ns.type == "Class" || ns.type == "Struct")
nsname = ns.name; else if (ns.type == "Class" || ns.type == "Struct")
nsname = new CppType (ns.name).ElementTypeName;
else
throw new NotSupportedException ("Unknown context: " + ns.type);
@ -833,8 +782,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -833,8 +782,7 @@ namespace Mono.VisualC.Tools.Generator {
Entry ns = entry.Namespace;
if (ns.type == "Namespace")
nsname = ns.name;
else if (ns.type == "Class" || ns.type == "Struct")
nsname = ns.name; else if (ns.type == "Class" || ns.type == "Struct")
nsname = new CppType (ns.name).ElementTypeName;
else
throw new NotSupportedException ("Unknown context: " + ns.type);
@ -922,7 +870,8 @@ namespace Mono.VisualC.Tools.Generator { @@ -922,7 +870,8 @@ namespace Mono.VisualC.Tools.Generator {
enumAtom.Items.Add (new Enumeration.Item { Name = m.name, Value = Convert.ToInt32 (m.attributes["init"]) });
}
CodeContainer nested = GetContainer (entry, Tree);//GetContainer (root, enm, currentUnit);
CodeContainer nested = GetContainer (entry, Tree);
//GetContainer (root, enm, currentUnit);
nested.Atoms.AddLast (enumAtom);
}
@ -987,7 +936,8 @@ namespace Mono.VisualC.Tools.Generator { @@ -987,7 +936,8 @@ namespace Mono.VisualC.Tools.Generator {
unionAtom.Atoms.AddLast (field);
}
CodeContainer nested = GetContainer (entry, Tree);//GetContainer (root, union, currentUnit);
CodeContainer nested = GetContainer (entry, Tree);
//GetContainer (root, union, currentUnit);
nested.Atoms.AddLast (unionAtom);
if (orphans != null) {
@ -1058,15 +1008,8 @@ namespace Mono.VisualC.Tools.Generator { @@ -1058,15 +1008,8 @@ namespace Mono.VisualC.Tools.Generator {
var ccu = new CodeCompileUnit ();
var ns = new CodeNamespace (Namespace);
var cls = new CodeTypeDeclaration ("Libs") {
TypeAttributes = TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.Class,
IsPartial = true,
IsClass = true
};
var field = new CodeMemberField (typeof (CppLibrary), Library) {
Attributes = MemberAttributes.Public | MemberAttributes.Static,
InitExpression = new CodeObjectCreateExpression (typeof (CppLibrary), new CodePrimitiveExpression (Library))
};
var cls = new CodeTypeDeclaration ("Libs") { TypeAttributes = TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.Class, IsPartial = true, IsClass = true };
var field = new CodeMemberField (typeof(CppLibrary), Library) { Attributes = MemberAttributes.Public | MemberAttributes.Static, InitExpression = new CodeObjectCreateExpression (typeof(CppLibrary), new CodePrimitiveExpression (Library)) };
cls.Members.Add (field);
ns.Types.Add (cls);
ccu.Namespaces.Add (ns);
@ -1075,7 +1018,8 @@ namespace Mono.VisualC.Tools.Generator { @@ -1075,7 +1018,8 @@ namespace Mono.VisualC.Tools.Generator {
}
void GenerateUnknownTypeStubs ()
{/*
{
/*
var ccu = new CodeCompileUnit ();
var ns = new CodeNamespace (Namespace);
@ -1092,7 +1036,6 @@ namespace Mono.VisualC.Tools.Generator { @@ -1092,7 +1036,6 @@ namespace Mono.VisualC.Tools.Generator {
ccu.Namespaces.Add (ns);
SaveFile (ccu, "UnknownTypes");
*/
var ukt = UnknownTypes.ToArray ();
foreach (var unknownType in ukt) {
CodeContainer container = Tree;
@ -1111,9 +1054,9 @@ namespace Mono.VisualC.Tools.Generator { @@ -1111,9 +1054,9 @@ namespace Mono.VisualC.Tools.Generator {
foreach (var param in type.Modifiers.OfType<CppModifiers.TemplateModifier> ()) {
if (param.Types != null) {
foreach (var t in param.Types)
atom.TemplateArguments.Add (genericTypeArgs [i++]);
atom.TemplateArguments.Add (genericTypeArgs[i++]);
} else
atom.TemplateArguments.Add (genericTypeArgs [i++]);
atom.TemplateArguments.Add (genericTypeArgs[i++]);
}
if (orphans != null) {
@ -1151,16 +1094,12 @@ namespace Mono.VisualC.Tools.Generator { @@ -1151,16 +1094,12 @@ namespace Mono.VisualC.Tools.Generator {
static CppType replaceType (CppType inType, CppType toReplace, string tn)
{
// FIXME: The order of some modifiers is not significant.. is this a problem?
if (/* inType.ElementType == toReplace.ElementType && */
((inType.Namespaces != null && toReplace.Namespaces != null && inType.Namespaces.SequenceEqual (toReplace.Namespaces)) ||
inType.Namespaces == null && toReplace.Namespaces == null) &&
inType.ElementTypeName == toReplace.ElementTypeName &&
inType.Modifiers.StartsWith (toReplace.Modifiers))
if ( /* inType.ElementType == toReplace.ElementType && */((inType.Namespaces != null && toReplace.Namespaces != null && inType.Namespaces.SequenceEqual (toReplace.Namespaces)) || inType.Namespaces == null && toReplace.Namespaces == null) && inType.ElementTypeName == toReplace.ElementTypeName && inType.Modifiers.StartsWith (toReplace.Modifiers))
return new CppType (CppTypes.Typename, tn, inType.Modifiers.Skip (toReplace.Modifiers.Count).ToArray ());
foreach (var tempMod in inType.Modifiers.OfType<CppModifiers.TemplateModifier> ())
for (int i = 0; i < tempMod.Types.Length; i++)
tempMod.Types [i] = replaceType (tempMod.Types [i], toReplace, tn);
tempMod.Types[i] = replaceType (tempMod.Types[i], toReplace, tn);
return inType;
}
@ -1184,7 +1123,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -1184,7 +1123,7 @@ namespace Mono.VisualC.Tools.Generator {
bool typeFound = false;
type.ElementType = CppTypes.Unknown;
for (int i = 0; i < type.Modifiers.Count; i++) {
if (type.Modifiers [i] != CppModifiers.Template)
if (type.Modifiers[i] != CppModifiers.Template)
type.Modifiers.RemoveAt (i);
}
@ -1196,9 +1135,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -1196,9 +1135,7 @@ namespace Mono.VisualC.Tools.Generator {
place = GetPath (type.Namespaces);
if (place != null) {
typeFound = place.Atoms.OfType<Class> ().Where (c => c.Name == type.ElementTypeName).Any () ||
place.Atoms.OfType<Enumeration> ().Where (e => e.Name == type.ElementTypeName).Any () ||
place.Atoms.OfType<Union> ().Where (u => u.Name == type.ElementTypeName).Any ();
typeFound = place.Atoms.OfType<Class> ().Where (c => c.Name == type.ElementTypeName).Any () || place.Atoms.OfType<Enumeration> ().Where (e => e.Name == type.ElementTypeName).Any () || place.Atoms.OfType<Union> ().Where (u => u.Name == type.ElementTypeName).Any ();
var sameNamedNamespace = place.Atoms.OfType<Namespace> ().Where (ns => ns.Name == type.ElementTypeName).SingleOrDefault ();
if (sameNamedNamespace != null) {
@ -1278,29 +1215,38 @@ namespace Mono.VisualC.Tools.Generator { @@ -1278,29 +1215,38 @@ namespace Mono.VisualC.Tools.Generator {
string name = entry.name == "" ? "unknown" : entry.name;
switch (entry.type) {
case "ArrayType": return findType (entry.Base, modifiers.Modify (CppModifiers.Array));
case "PointerType": return findType (entry.Base, modifiers.Modify (CppModifiers.Pointer));
case "ReferenceType": return findType (entry.Base, modifiers.Modify (CppModifiers.Reference));
case "ArrayType":
return findType (entry.Base, modifiers.Modify (CppModifiers.Array));
case "PointerType":
return findType (entry.Base, modifiers.Modify (CppModifiers.Pointer));
case "ReferenceType":
return findType (entry.Base, modifiers.Modify (CppModifiers.Reference));
case "CvQualifiedType":
return findType (entry.Base,
modifiers.Modify ((from c in entry.attributes
return findType (entry.Base, modifiers.Modify ((from c in entry.attributes
where c.Key == "const" && c.Value == "1"
select CppModifiers.Const)
.DefaultIfEmpty (CppModifiers.Volatile)
.First()));
case "Typedef": return findType (entry.Base, modifiers);
case "FundamentalType": return modifiers.CopyTypeFrom (new CppType (name));
case "Class": return modifiers.CopyTypeFrom (new CppType (CppTypes.Class, name));
case "Struct": return modifiers.CopyTypeFrom (new CppType (CppTypes.Struct, name));
case "Union": return modifiers.CopyTypeFrom (ProcessUnion (entry));
case "Enumeration": return modifiers.CopyTypeFrom (ProcessEnum (entry));
select CppModifiers.Const).DefaultIfEmpty (CppModifiers.Volatile).First ()));
case "Typedef":
return findType (entry.Base, modifiers);
case "FundamentalType":
return modifiers.CopyTypeFrom (new CppType (name));
case "Class":
return modifiers.CopyTypeFrom (new CppType (CppTypes.Class, name));
case "Struct":
return modifiers.CopyTypeFrom (new CppType (CppTypes.Struct, name));
case "Union":
return modifiers.CopyTypeFrom (ProcessUnion (entry));
case "Enumeration":
return modifiers.CopyTypeFrom (ProcessEnum (entry));
// FIXME: support function pointers betters
case "FunctionType": return modifiers.CopyTypeFrom (CppTypes.Void);
case "MethodType": return modifiers.CopyTypeFrom (CppTypes.Void);
case "Constructor": return CppTypes.Unknown;
case "FunctionType":
return modifiers.CopyTypeFrom (CppTypes.Void);
case "MethodType":
return modifiers.CopyTypeFrom (CppTypes.Void);
case "Constructor":
return CppTypes.Unknown;
}
throw new NotImplementedException ("Unknown type node: " + entry.type);
@ -1350,7 +1296,7 @@ namespace Mono.VisualC.Tools.Generator { @@ -1350,7 +1296,7 @@ namespace Mono.VisualC.Tools.Generator {
string fname (string name)
{
return name.Replace ("<", "_").Replace (">", "_").Replace(":", "_").Replace("*", "_").Replace (",", "_").Replace(" ", "_") + "." + Provider.FileExtension;
return name.Replace ("<", "_").Replace (">", "_").Replace (":", "_").Replace ("*", "_").Replace (",", "_").Replace (" ", "_") + "." + Provider.FileExtension;
}
}
}

1
tests/Mono.VisualC.Code.dll

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Code/bin/Debug/Mono.VisualC.Code.dll

1
tests/Mono.VisualC.Code.dll.mdb

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Code/bin/Debug/Mono.VisualC.Code.dll.mdb

1
tests/Mono.VisualC.Interop.dll

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Interop/bin/Debug/Mono.VisualC.Interop.dll

1
tests/Mono.VisualC.Interop.dll.mdb

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/Mono.VisualC.Interop/bin/Debug/Mono.VisualC.Interop.dll.mdb

1
tests/generator.exe

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/generator/bin/Debug/generator.exe

1
tests/generator.exe.mdb

@ -1 +0,0 @@ @@ -1 +0,0 @@
../src/generator/bin/Debug/generator.exe.mdb

16
tests/output/Lib_Lib.cs

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
namespace Wrappers {
internal sealed partial class Libs {
public static Mono.VisualC.Interop.CppLibrary Lib = new Mono.VisualC.Interop.CppLibrary("Lib");
}
}

BIN
tests/qttests/bin/Debug/Mono.VisualC.Code.dll

Binary file not shown.

BIN
tests/qttests/bin/Debug/Mono.VisualC.Code.dll.mdb

Binary file not shown.

BIN
tests/qttests/bin/Debug/Mono.VisualC.Interop.dll

Binary file not shown.

BIN
tests/qttests/bin/Debug/Mono.VisualC.Interop.dll.mdb

Binary file not shown.

7
tests/qttests/qttests.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -96,9 +96,4 @@ @@ -96,9 +96,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" xmlns="" />
</MonoDevelop>
</ProjectExtensions>
</Project>

BIN
tests/qttests/qttests.pidb

Binary file not shown.
Loading…
Cancel
Save