mirror of https://github.com/mono/CppSharp.git
28 changed files with 0 additions and 5405 deletions
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
using System; |
||||
|
||||
public enum Access { |
||||
@private, |
||||
@protected, |
||||
@public |
||||
} |
||||
|
||||
|
@ -1,82 +0,0 @@
@@ -1,82 +0,0 @@
|
||||
//
|
||||
// Class.cs: Represents a C++ class
|
||||
//
|
||||
// Author:
|
||||
// Alexander Corrado (alexander.corrado@gmail.com)
|
||||
// Andreia Gaita (shana@spoiledcat.net)
|
||||
// Zoltan Varga <vargaz@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
using Mono.Cxxi; |
||||
|
||||
public class Class : Namespace { |
||||
|
||||
public Class (Node n) |
||||
: base (n) |
||||
{ |
||||
BaseClasses = new List<Class> (); |
||||
Fields = new List<Field> (); |
||||
Properties = new List<Property> (); |
||||
Methods = new List<Method> (); |
||||
NestedClasses = new List<Class> (); |
||||
NestedEnums = new List<Enumeration> (); |
||||
} |
||||
|
||||
public List<Class> BaseClasses { |
||||
get; set; |
||||
} |
||||
|
||||
public List<Class> NestedClasses { |
||||
get; set; |
||||
} |
||||
|
||||
public List<Enumeration> NestedEnums { |
||||
get; set; |
||||
} |
||||
|
||||
public List<Field> Fields { |
||||
get; set; |
||||
} |
||||
|
||||
public List<Property> Properties { |
||||
get; set; |
||||
} |
||||
|
||||
public List<Method> Methods { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public CppType MangleType { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool Disable { |
||||
get; set; |
||||
} |
||||
|
||||
} |
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
public class Enumeration : Namespace { |
||||
|
||||
public struct Item { |
||||
public string Name; |
||||
public int Value; |
||||
} |
||||
|
||||
public Enumeration (Node n) |
||||
: base (n) |
||||
{ |
||||
this.Items = new List<Item> (); |
||||
} |
||||
|
||||
public List<Item> Items { |
||||
get; set; |
||||
} |
||||
} |
||||
|
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
//
|
||||
// Field.cs: Represents a field of a C++ class
|
||||
//
|
||||
// Author:
|
||||
// Alexander Corrado (alexander.corrado@gmail.com)
|
||||
// Andreia Gaita (shana@spoiledcat.net)
|
||||
// Zoltan Varga <vargaz@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using Mono.Cxxi; |
||||
|
||||
public class Field { |
||||
|
||||
public Field (string name, CppType type, Access access) { |
||||
Name = name; |
||||
Type = type; |
||||
Access = access; |
||||
} |
||||
|
||||
public string Name { |
||||
get; set; |
||||
} |
||||
|
||||
public CppType Type { |
||||
get; set; |
||||
} |
||||
|
||||
public Access Access { |
||||
get; set; |
||||
} |
||||
} |
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
using System; |
||||
using System.Linq; |
||||
using System.Xml.Linq; |
||||
using System.Collections.Generic; |
||||
|
||||
public enum FilterMode { |
||||
Include, |
||||
Exclude, |
||||
External |
||||
} |
||||
|
||||
public enum ImplementationType { |
||||
@class, |
||||
@struct |
||||
} |
||||
|
||||
public struct Filter { |
||||
|
||||
public string TypeName { get; set; } |
||||
public FilterMode Mode { get; set; } |
||||
public ImplementationType ImplType { get; set; } |
||||
|
||||
public static Dictionary<string, Filter> Load (XDocument doc, out FilterMode @default) |
||||
{ |
||||
string value; |
||||
@default = (value = (string)doc.Root.Attribute ("default")) != null ? (FilterMode)Enum.Parse (typeof (FilterMode), value) : FilterMode.Include; |
||||
|
||||
var rules = from rule in doc.Root.Elements () |
||||
let mode = (FilterMode)Enum.Parse (typeof (FilterMode), rule.Name.LocalName) |
||||
let impl = (value = (string)rule.Attribute ("implementation")) != null ? (ImplementationType)Enum.Parse (typeof (ImplementationType), value) : ImplementationType.@class |
||||
select new Filter { TypeName = rule.Value, Mode = mode, ImplType = impl }; |
||||
|
||||
|
||||
return rules.ToDictionary<Filter,string> (r => r.TypeName); |
||||
} |
||||
} |
@ -1,622 +0,0 @@
@@ -1,622 +0,0 @@
|
||||
//
|
||||
// Generator.cs: C++ Interop Code Generator
|
||||
//
|
||||
//
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Diagnostics; |
||||
using System.Collections.Generic; |
||||
using System.Xml; |
||||
using System.Xml.Linq; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
|
||||
using Templates; |
||||
using NDesk.Options; |
||||
using Mono.Cxxi; |
||||
|
||||
public class Generator { |
||||
|
||||
// Command line arguments
|
||||
public string InputFileName { get; set; } |
||||
public string OutputDir { get; set; } |
||||
public string FilterFile { get; set; } |
||||
|
||||
// In the future we might support more than one of these at once...
|
||||
public Lib Lib { get; set; } |
||||
|
||||
// Classes to generate code for
|
||||
public Dictionary<Node, Namespace> NodeToNamespace { get; set; } |
||||
|
||||
private FilterMode default_filter_mode; |
||||
public FilterMode DefaultFilterMode { get { return default_filter_mode; } set { default_filter_mode = value; } } |
||||
public Dictionary<string, Filter> Filters { get; set; } |
||||
|
||||
// Code templates
|
||||
public LibsBase LibsTemplate { get; set; } |
||||
public ClassBase ClassTemplate { get; set; } |
||||
public EnumBase EnumTemplate { get; set; } |
||||
|
||||
public static int Main (String[] args) { |
||||
var generator = new Generator (); |
||||
generator.Run (args); |
||||
return 0; |
||||
} |
||||
|
||||
void Run (String[] args) { |
||||
Lib = new Lib (); |
||||
NodeToNamespace = new Dictionary<Node, Namespace> (); |
||||
|
||||
if (ParseArguments (args) != 0) { |
||||
Environment.Exit (1); |
||||
} |
||||
|
||||
Node root = LoadXml (InputFileName); |
||||
|
||||
if (FilterFile != null) |
||||
Filters = Filter.Load (XDocument.Load (FilterFile), out default_filter_mode); |
||||
|
||||
CreateTypes (root); |
||||
|
||||
CreateMembers (); |
||||
|
||||
GenerateCode (); |
||||
} |
||||
|
||||
int ParseArguments (String[] args) { |
||||
bool help = false; |
||||
|
||||
var p = new OptionSet { |
||||
{ "h|?|help", "Show this help message", v => help = v != null }, |
||||
{ "o=|out=", "Set the output directory", v => OutputDir = v }, |
||||
{ "ns=|namespace=", "Set the namespace of the generated code", v => Lib.BaseNamespace = v }, |
||||
{ "lib=", "The base name of the C++ library, i.e. 'qt' for libqt.so", v =>Lib.BaseName = v }, |
||||
{ "filters=", "A file containing filter directives for filtering classes", v => FilterFile = v }, |
||||
{ "inline=", "Inline methods in lib are: notpresent (default), present, surrogatelib (present in %lib%-inline)", v => Lib.InlinePolicy = (InlineMethods)Enum.Parse (typeof (InlineMethods), v, true) } |
||||
}; |
||||
|
||||
try { |
||||
args = p.Parse (args).ToArray (); |
||||
} catch (OptionException) { |
||||
Console.WriteLine ("Try `generator --help' for more information."); |
||||
return 1; |
||||
} |
||||
|
||||
if (help) { |
||||
p.WriteOptionDescriptions (Console.Error); |
||||
return 1; |
||||
} |
||||
|
||||
if (args.Length != 1) { |
||||
Console.WriteLine ("Usage: generator <options> <input xml file>"); |
||||
return 1; |
||||
} |
||||
|
||||
// Code templates
|
||||
LibsTemplate = new CSharpLibs (); |
||||
ClassTemplate = new CSharpClass (); |
||||
EnumTemplate = new CSharpEnum (); |
||||
|
||||
InputFileName = args [0]; |
||||
|
||||
if (Lib.BaseName == null) { |
||||
Console.WriteLine ("The --lib= option is required."); |
||||
return 1; |
||||
} |
||||
|
||||
if (Lib.BaseNamespace == null) { |
||||
Lib.BaseNamespace = Path.GetFileNameWithoutExtension (Lib.BaseName); |
||||
} |
||||
|
||||
if (OutputDir == null) |
||||
OutputDir = "output"; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
Node LoadXml (string file) { |
||||
XmlReader reader = XmlReader.Create (file, new XmlReaderSettings ()); |
||||
|
||||
Node[] parents = new Node [1024]; |
||||
|
||||
Node root = null; |
||||
|
||||
while (reader.Read()) { |
||||
if (reader.IsStartElement ()) { |
||||
string type = reader.Name; |
||||
|
||||
var attributes = new Dictionary<string, string> (); |
||||
while (reader.MoveToNextAttribute ()) { |
||||
attributes [reader.Name] = reader.Value; |
||||
} |
||||
|
||||
Node n = new Node { |
||||
Id = "", |
||||
Type = type, |
||||
Attributes = attributes, |
||||
Children = new List<Node> () |
||||
}; |
||||
|
||||
if (attributes.ContainsKey ("id")) { |
||||
n.Id = attributes ["id"]; |
||||
Node.IdToNode [n.Id] = n; |
||||
} |
||||
|
||||
if (attributes.ContainsKey ("name")) |
||||
n.Name = attributes ["name"]; |
||||
|
||||
if (parents [reader.Depth - 1] != null) { |
||||
//Console.WriteLine (parents [reader.Depth - 1].type + " -> " + e.type);
|
||||
parents [reader.Depth - 1].Children.Add (n); |
||||
} |
||||
parents [reader.Depth] = n; |
||||
|
||||
if (n.Type == "GCC_XML" && root == null) |
||||
root = n; |
||||
} |
||||
} |
||||
|
||||
return root; |
||||
} |
||||
|
||||
void CreateTypes (Node root) { |
||||
|
||||
foreach (Node n in root.Children) { |
||||
if (n.IsTrue ("incomplete") || !n.HasValue ("name") || n.Attributes ["name"] == "::") |
||||
continue; |
||||
|
||||
Namespace ns; |
||||
switch (n.Type) { |
||||
|
||||
case "Class": |
||||
case "Struct": |
||||
ns = new Class (n); |
||||
break; |
||||
|
||||
case "Enumeration": |
||||
ns = new Enumeration (n); |
||||
break; |
||||
|
||||
case "Namespace": |
||||
ns = new Namespace (n); |
||||
break; |
||||
|
||||
default: |
||||
continue; |
||||
|
||||
} |
||||
|
||||
NodeToNamespace [n] = ns; |
||||
Lib.Namespaces.Add (ns); |
||||
} |
||||
|
||||
for (var i = 0; i < Lib.Namespaces.Count; i++) { |
||||
Namespace ns = Lib.Namespaces [i]; |
||||
SetParentNamespace (ns); |
||||
|
||||
var filter = GetFilterOrDefault (ns); |
||||
if (filter.Mode == FilterMode.Exclude) |
||||
NodeToNamespace.Remove (ns.Node); |
||||
|
||||
if (filter.Mode != FilterMode.Include) { |
||||
Lib.Namespaces.RemoveAt (i); |
||||
i--; |
||||
continue; |
||||
} |
||||
|
||||
var klass = ns as Class; |
||||
if (klass == null) |
||||
continue; |
||||
|
||||
// Compute bases
|
||||
foreach (Node bn in klass.Node.Children.Where (o => o.Type == "Base")) { |
||||
Class baseClass = NodeToNamespace [bn.NodeForAttr ("type")] as Class; |
||||
Debug.Assert (baseClass != null); |
||||
klass.BaseClasses.Add (baseClass); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void SetParentNamespace (Namespace ns) |
||||
{ |
||||
Namespace parent = null; |
||||
if (ns.Node.HasValue ("context") && NodeToNamespace.TryGetValue (Node.IdToNode [ns.Node.Attributes ["context"]], out parent)) |
||||
{ |
||||
SetParentNamespace (parent); |
||||
ns.ParentNamespace = parent; |
||||
} |
||||
} |
||||
|
||||
void CreateMembers () { |
||||
|
||||
foreach (var ns in Lib.Namespaces) { |
||||
|
||||
var parentClass = ns.ParentNamespace as Class; |
||||
|
||||
var @enum = ns as Enumeration; |
||||
if (@enum != null) { |
||||
if (parentClass != null) |
||||
parentClass.NestedEnums.Add (@enum); |
||||
|
||||
foreach (var enumValue in @enum.Node.Children.Where (o => o.Type == "EnumValue")) { |
||||
int val; |
||||
var item = new Enumeration.Item { Name = enumValue.Attributes ["name"] }; |
||||
|
||||
if (enumValue.HasValue ("init") && int.TryParse (enumValue.Attributes ["init"], out val)) |
||||
item.Value = val; |
||||
|
||||
@enum.Items.Add (item); |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
var klass = ns as Class; |
||||
if (klass == null || !klass.Node.HasValue ("members")) |
||||
continue; |
||||
|
||||
klass.MangleType = GetType (klass.Node); |
||||
|
||||
if (parentClass != null) |
||||
parentClass.NestedClasses.Add (klass); |
||||
|
||||
int fieldCount = 0; |
||||
foreach (Node n in klass.Node ["members"].Split (new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select (id => Node.IdToNode [id])) { |
||||
bool ctor = false; |
||||
bool dtor = false; |
||||
bool skip = false; |
||||
|
||||
switch (n.Type) { |
||||
case "Field": |
||||
var fieldType = GetType (GetTypeNode (n)); |
||||
if (fieldType.ElementType == CppTypes.Unknown && fieldType.ElementTypeName == null) |
||||
fieldType = new CppType (CppTypes.Void, CppModifiers.Pointer); |
||||
|
||||
string fieldName; |
||||
if (n.Name != "") |
||||
fieldName = n.Name; |
||||
else |
||||
fieldName = "field" + fieldCount++; |
||||
|
||||
klass.Fields.Add (new Field (fieldName, fieldType, (Access)Enum.Parse (typeof (Access), n ["access"]))); |
||||
break; |
||||
|
||||
case "Constructor": |
||||
ctor = true; |
||||
break; |
||||
case "Destructor": |
||||
dtor = true; |
||||
break; |
||||
case "Method": |
||||
break; |
||||
default: |
||||
continue; |
||||
} |
||||
|
||||
if ((!dtor && n.HasValue ("overrides") && CheckPrimaryBases (klass, b => b.Node.CheckValueList ("members", n.Attributes ["overrides"]))) || // excl. virtual methods from primary base (except dtor)
|
||||
(!n.IsTrue ("extern") && !n.IsTrue ("inline"))) |
||||
continue; |
||||
|
||||
if (n.IsTrue ("inline") && Lib.InlinePolicy == InlineMethods.NotPresent) |
||||
skip = true; |
||||
|
||||
string name = dtor ? "Destruct" : n.Name; |
||||
|
||||
var method = new Method (n) { |
||||
Name = name, |
||||
Access = (Access)Enum.Parse (typeof (Access), n.Attributes ["access"]), |
||||
IsVirtual = n.IsTrue ("virtual"), |
||||
IsStatic = n.IsTrue ("static"), |
||||
IsConst = n.IsTrue ("const"), |
||||
IsInline = n.IsTrue ("inline"), |
||||
IsArtificial = n.IsTrue ("artificial"), |
||||
IsConstructor = ctor, |
||||
IsDestructor = dtor |
||||
}; |
||||
|
||||
if (method.Access == Access.@private) |
||||
skip = true; |
||||
|
||||
if (dtor || method.IsArtificial) |
||||
method.GenWrapperMethod = false; |
||||
|
||||
CppType retType; |
||||
if (n.HasValue ("returns")) |
||||
retType = GetType (n.NodeForAttr ("returns")); |
||||
else |
||||
retType = CppTypes.Void; |
||||
if (retType.ElementType == CppTypes.Unknown) { |
||||
retType = CppTypes.Void; |
||||
skip = true; |
||||
} |
||||
if (CppTypeToManaged (retType) == null) { |
||||
//Console.WriteLine ("\t\tS: " + retType);
|
||||
retType = CppTypes.Void; |
||||
skip = true; |
||||
} |
||||
|
||||
method.ReturnType = retType; |
||||
|
||||
int c = 0; |
||||
var argTypes = new List<CppType> (); |
||||
foreach (Node arg in n.Children.Where (o => o.Type == "Argument")) { |
||||
string argname; |
||||
if (arg.Name == null || arg.Name == "") |
||||
argname = "arg" + c; |
||||
else |
||||
argname = arg.Name; |
||||
|
||||
var argtype = GetType (GetTypeNode (arg)); |
||||
if (argtype.ElementType == CppTypes.Unknown) { |
||||
//Console.WriteLine ("Skipping method " + klass.Name + "::" + member.Name + " () because it has an argument with unknown type '" + TypeNodeToString (arg) + "'.");
|
||||
argtype = new CppType (CppTypes.Void, CppModifiers.Pointer); |
||||
skip = true; |
||||
} |
||||
|
||||
if (CppTypeToManaged (argtype) == null) { |
||||
//Console.WriteLine ("\t\tS: " + argtype);
|
||||
argtype = new CppType (CppTypes.Void, CppModifiers.Pointer); |
||||
skip = true; |
||||
} |
||||
|
||||
method.Parameters.Add (new Parameter (argname, argtype)); |
||||
argTypes.Add (argtype); |
||||
|
||||
c++; |
||||
} |
||||
if (skip && !method.IsVirtual) |
||||
continue; |
||||
else if (skip && method.IsVirtual) |
||||
method.GenWrapperMethod = false; |
||||
|
||||
// FIXME: More complete type name check
|
||||
if (ctor && argTypes.Count == 1 && argTypes [0].ElementType == CppTypes.Class && argTypes [0].ElementTypeName == klass.Name && argTypes [0].Modifiers.Count == 2 && argTypes [0].Modifiers.Contains (CppModifiers.Const) && argTypes [0].Modifiers.Contains (CppModifiers.Reference)) |
||||
method.IsCopyCtor = true; |
||||
|
||||
Console.WriteLine ("\t" + klass.Name + "." + method.Name); |
||||
|
||||
klass.Methods.Add (method); |
||||
} |
||||
|
||||
foreach (var method in klass.Methods) { |
||||
if (AddAsProperty (klass, method)) |
||||
method.GenWrapperMethod = false; |
||||
} |
||||
|
||||
Field f2 = klass.Fields.FirstOrDefault (f => f.Type.ElementType == CppTypes.Unknown); |
||||
if (f2 != null) { |
||||
Console.WriteLine ("Skipping " + klass.Name + " because field " + f2.Name + " has unknown type."); |
||||
klass.Disable = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
//
|
||||
// Property support
|
||||
//
|
||||
bool AddAsProperty (Class klass, Method method) { |
||||
// 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 (method.IsConst && !method.ReturnType.Equals (CppTypes.Void) && !method.Parameters.Any () && |
||||
klass.Methods.Count (o => o.Name == method.Name) == 1) { |
||||
Property property; |
||||
|
||||
property = klass.Properties.Where (o => o.Name == method.FormattedName).FirstOrDefault (); |
||||
if (property != null) { |
||||
property.GetMethod = method; |
||||
} else { |
||||
property = new Property (method.FormattedName, method.ReturnType) { GetMethod = method }; |
||||
klass.Properties.Add (property); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
// 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 (method.Name.ToLower ().StartsWith ("set") && method.ReturnType.Equals (CppTypes.Void) && |
||||
method.Parameters.Count == 1 && klass.Methods.Count (o => o.Name == method.Name) == 1) { |
||||
string getterName = method.Name.Substring (3).TrimStart ('_').ToLower (); |
||||
|
||||
string pname = method.FormattedName.Substring (3); |
||||
Property property = null; |
||||
|
||||
// ...AND there is a corresponding getter method that returns the right type, then assume it's a property setter
|
||||
bool doIt = false; |
||||
property = klass.Properties.Where (o => o.Name == pname).FirstOrDefault (); |
||||
if (property != null) { |
||||
doIt = property.GetMethod != null && property.GetMethod.ReturnType.Equals (method.Parameters[0].Type); |
||||
} else { |
||||
Method getter = klass.Methods.Where (o => o.Name == getterName).FirstOrDefault (); |
||||
doIt = getter != null && getter.ReturnType.Equals (method.Parameters[0].Type); |
||||
} |
||||
if (doIt) { |
||||
if (property != null) { |
||||
property.SetMethod = method; |
||||
} else { |
||||
property = new Property (pname, method.Parameters [0].Type) { SetMethod = method }; |
||||
klass.Properties.Add (property); |
||||
} |
||||
|
||||
// set the method's arg name to "value" so that the prop setter works right
|
||||
var valueParam = method.Parameters[0]; |
||||
valueParam.Name = "value"; |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
// Checks klass's primary base, primary base's primary base, and so on up the hierarchy
|
||||
public bool CheckPrimaryBases (Class klass, Func<Class, bool> predicate) |
||||
{ |
||||
if (klass.BaseClasses.Count == 0) |
||||
return false; |
||||
var primaryBase = klass.BaseClasses [0]; |
||||
return predicate (primaryBase) || CheckPrimaryBases (primaryBase, predicate); |
||||
} |
||||
|
||||
// Return a CppType for the type node N, return CppTypes.Unknown for unknown types
|
||||
CppType GetType (Node n) { |
||||
return GetType (n, new CppType ()); |
||||
} |
||||
|
||||
CppType GetType (Node n, CppType modifiers) { |
||||
var fundamental = CppTypes.Unknown; |
||||
|
||||
switch (n.Type) { |
||||
case "Typedef": |
||||
return GetType (GetTypeNode (n), modifiers); |
||||
case "ArrayType": |
||||
CppModifiers mod = null; |
||||
if (n.Attributes ["max"] != null && n.Attributes ["min"] != null) |
||||
mod = new CppModifiers.ArrayModifier (int.Parse (n.Attributes ["max"].TrimEnd ('u')) - int.Parse (n.Attributes ["min"].TrimEnd ('u')) + 1); |
||||
else |
||||
mod = CppModifiers.Array; |
||||
return GetType (GetTypeNode (n), modifiers.Modify (mod)); |
||||
case "PointerType": |
||||
return GetType (GetTypeNode (n), modifiers.Modify (CppModifiers.Pointer)); |
||||
case "ReferenceType": |
||||
return GetType (GetTypeNode (n), modifiers.Modify (CppModifiers.Reference)); |
||||
case "FundamentalType": |
||||
return modifiers.CopyTypeFrom (new CppType (n.Name)); |
||||
case "CvQualifiedType": |
||||
if (n.IsTrue ("const")) |
||||
return GetType (GetTypeNode (n), modifiers.Modify (CppModifiers.Const)); |
||||
else |
||||
throw new NotImplementedException (); |
||||
case "Class": |
||||
fundamental = CppTypes.Class; |
||||
break; |
||||
case "Struct": |
||||
fundamental = CppTypes.Struct; |
||||
break; |
||||
case "Enumeration": |
||||
fundamental = CppTypes.Enum; |
||||
break; |
||||
default: |
||||
return CppTypes.Unknown; |
||||
} |
||||
|
||||
if (!NodeToNamespace.ContainsKey (n)) { |
||||
// FIXME: Do something better
|
||||
return CppTypes.Unknown; |
||||
} |
||||
|
||||
return modifiers.CopyTypeFrom (new CppType (fundamental, string.Join ("::", NodeToNamespace [n].FullyQualifiedName))); |
||||
} |
||||
|
||||
Node GetTypeNode (Node n) { |
||||
return Node.IdToNode [n.Attributes ["type"]]; |
||||
} |
||||
|
||||
// Return the System.Type name corresponding to T, or null
|
||||
// Returned as a string, because other wrappers do not have System.Types yet
|
||||
public string CppTypeToManaged (CppType t) { |
||||
|
||||
Type mtype = t.ToManagedType (); |
||||
if (mtype != null && mtype != typeof (ICppObject)) { |
||||
return mtype.FullName; |
||||
} |
||||
|
||||
switch (t.ElementType) { |
||||
|
||||
case CppTypes.Class: |
||||
case CppTypes.Struct: |
||||
case CppTypes.Enum: |
||||
|
||||
var filter = GetFilterOrDefault (t); |
||||
var qname = filter.TypeName.Replace ("::", "."); |
||||
|
||||
if (filter.ImplType == ImplementationType.@struct && !IsByVal (t)) |
||||
return qname + "&"; |
||||
else |
||||
return qname; |
||||
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
void GenerateCode () { |
||||
Directory.CreateDirectory (OutputDir); |
||||
|
||||
// Generate Libs file
|
||||
using (TextWriter w = File.CreateText (Path.Combine (OutputDir, "Libs.cs"))) { |
||||
LibsTemplate.Generator = this; |
||||
LibsTemplate.Libs = new[] { Lib }; |
||||
w.Write (LibsTemplate.TransformText ()); |
||||
} |
||||
|
||||
|
||||
// Generate user types
|
||||
foreach (Namespace ns in Lib.Namespaces) { |
||||
if (ns.ParentNamespace is Class) |
||||
continue; |
||||
|
||||
var klass = ns as Class; |
||||
if (klass != null) { |
||||
if (klass.Disable) |
||||
continue; |
||||
|
||||
using (TextWriter w = File.CreateText (Path.Combine (OutputDir, klass.Name + ".cs"))) { |
||||
ClassTemplate.Generator = this; |
||||
ClassTemplate.Class = klass; |
||||
ClassTemplate.Nested = false; |
||||
w.Write (ClassTemplate.TransformText ()); |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
var @enum = ns as Enumeration; |
||||
if (@enum != null) { |
||||
|
||||
using (TextWriter w = File.CreateText (Path.Combine (OutputDir, @enum.Name + ".cs"))) { |
||||
EnumTemplate.Generator = this; |
||||
EnumTemplate.Enum = @enum; |
||||
EnumTemplate.Nested = false; |
||||
w.Write (EnumTemplate.TransformText ()); |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
static public bool IsByVal (CppType t) |
||||
{ |
||||
return ((t.ElementType == CppTypes.Class || t.ElementType == CppTypes.Struct) && |
||||
!t.Modifiers.Contains (CppModifiers.Pointer) && |
||||
!t.Modifiers.Contains (CppModifiers.Reference) && |
||||
!t.Modifiers.Contains (CppModifiers.Array)); |
||||
} |
||||
|
||||
Filter GetFilterOrDefault (Namespace ns) |
||||
{ |
||||
return GetFilterOrDefault (string.Join ("::", ns.FullyQualifiedName)); |
||||
} |
||||
|
||||
public Filter GetFilterOrDefault (CppType cpptype) |
||||
{ |
||||
var fqn = cpptype.ElementTypeName; |
||||
if (cpptype.Namespaces != null) |
||||
fqn = string.Join ("::", cpptype.Namespaces) + "::" + fqn; |
||||
|
||||
var newtype = new CppType (fqn, cpptype.Modifiers.Where (m => m == CppModifiers.Template)); |
||||
return GetFilterOrDefault (newtype.ToString ().Replace (" ", "")); |
||||
} |
||||
|
||||
Filter GetFilterOrDefault (string fqn) |
||||
{ |
||||
Filter result; |
||||
if (Filters != null && Filters.TryGetValue (fqn, out result)) |
||||
return result; |
||||
|
||||
return new Filter { TypeName = fqn, Mode = default_filter_mode }; |
||||
} |
||||
} |
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
using Mono.Cxxi; |
||||
|
||||
public class Lib { |
||||
|
||||
public Lib () |
||||
{ |
||||
Namespaces = new List<Namespace> (); |
||||
} |
||||
|
||||
public string BaseName { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public InlineMethods InlinePolicy { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public string BaseNamespace { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public IList<Namespace> Namespaces { |
||||
get; |
||||
set; |
||||
} |
||||
} |
||||
|
@ -1,106 +0,0 @@
@@ -1,106 +0,0 @@
|
||||
|
||||
EXTRA_DIST = m4/expansions.m4 |
||||
|
||||
if ENABLE_DEBUG |
||||
ASSEMBLY_COMPILER_COMMAND = mcs |
||||
ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG" |
||||
BUILD_DIR = $(top_srcdir)/bin/Debug |
||||
|
||||
ASSEMBLY = $(BUILD_DIR)/generator.exe |
||||
ASSEMBLY_MDB = $(ASSEMBLY).mdb |
||||
|
||||
MONO_CXXI_DLL_SOURCE=$(BUILD_DIR)/Mono.Cxxi.dll |
||||
MONO_CXXI_DLL=$(BUILD_DIR)/Mono.Cxxi.dll |
||||
GENERATOR_EXE_MDB_SOURCE=$(BUILD_DIR)/generator.exe.mdb |
||||
GENERATOR_EXE_MDB=$(BUILD_DIR)/generator.exe.mdb |
||||
|
||||
endif |
||||
|
||||
if ENABLE_RELEASE |
||||
ASSEMBLY_COMPILER_COMMAND = mcs |
||||
ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize+ |
||||
BUILD_DIR = $(top_srcdir)/bin/Release |
||||
|
||||
ASSEMBLY = $(BUILD_DIR)/generator.exe |
||||
ASSEMBLY_MDB = |
||||
|
||||
MONO_CXXI_DLL_SOURCE=$(BUILD_DIR)/Mono.Cxxi.dll |
||||
MONO_CXXI_DLL=$(BUILD_DIR)/Mono.Cxxi.dll |
||||
GENERATOR_EXE_MDB= |
||||
|
||||
endif |
||||
|
||||
COMPILE_TARGET = exe |
||||
|
||||
AL=al2 |
||||
SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll |
||||
|
||||
PROGRAMFILES = \
|
||||
$(MONO_CXXI_DLL) \
|
||||
$(GENERATOR_EXE_MDB) |
||||
|
||||
BINARIES = \
|
||||
$(GENERATOR) |
||||
|
||||
|
||||
RESGEN=resgen2 |
||||
|
||||
all: $(ASSEMBLY) $(PROGRAMFILES) $(BINARIES) |
||||
|
||||
FILES = \
|
||||
Access.cs \
|
||||
Class.cs \
|
||||
Enumeration.cs \
|
||||
Field.cs \
|
||||
Filter.cs \
|
||||
Generator.cs \
|
||||
Lib.cs \
|
||||
Method.cs \
|
||||
Namespace.cs \
|
||||
Node.cs \
|
||||
Options.cs \
|
||||
Parameter.cs \
|
||||
Property.cs \
|
||||
Templates/Base.cs \
|
||||
Templates/BaseMembers.cs \
|
||||
Templates/Context.cs \
|
||||
Templates/CSharp/CSharpClass.cs \
|
||||
Templates/CSharp/CSharpEnum.cs \
|
||||
Templates/CSharp/CSharpLanguage.cs \
|
||||
Templates/CSharp/CSharpLibs.cs |
||||
|
||||
DATA_FILES = |
||||
|
||||
RESOURCES = |
||||
|
||||
EXTRAS = \
|
||||
generator.in |
||||
|
||||
REFERENCES = \
|
||||
../../bin/Debug/Mono.Cxxi.dll \
|
||||
System \
|
||||
System.Core \
|
||||
System.Xml \
|
||||
System.Xml.Linq |
||||
|
||||
DLL_REFERENCES = |
||||
|
||||
CLEANFILES = $(PROGRAMFILES) $(BINARIES) |
||||
|
||||
include $(top_srcdir)/Makefile.include |
||||
|
||||
GENERATOR = $(BUILD_DIR)/generator |
||||
|
||||
$(eval $(call emit-deploy-target,MONO_CXXI_DLL)) |
||||
$(eval $(call emit-deploy-wrapper,GENERATOR,generator,x)) |
||||
|
||||
|
||||
$(eval $(call emit_resgen_targets)) |
||||
$(build_xamlg_list): %.xaml.g.cs: %.xaml |
||||
xamlg '$<' |
||||
|
||||
$(ASSEMBLY_MDB): $(ASSEMBLY) |
||||
|
||||
$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list) |
||||
mkdir -p $(shell dirname $(ASSEMBLY)) |
||||
$(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$(ASSEMBLY) -target:$(COMPILE_TARGET) $(build_sources_embed) $(build_resources_embed) $(build_references_ref) |
@ -1,105 +0,0 @@
@@ -1,105 +0,0 @@
|
||||
//
|
||||
// Method.cs: Represents a C++ method
|
||||
//
|
||||
// Author:
|
||||
// Alexander Corrado (alexander.corrado@gmail.com)
|
||||
// Andreia Gaita (shana@spoiledcat.net)
|
||||
// Zoltan Varga <vargaz@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
using Mono.Cxxi; |
||||
|
||||
public class Method { |
||||
|
||||
public Method (Node node) { |
||||
Node = node; |
||||
Parameters = new List<Parameter> (); |
||||
GenWrapperMethod = true; |
||||
} |
||||
|
||||
public Node Node { |
||||
get; set; |
||||
} |
||||
|
||||
public Access Access { |
||||
get; set; |
||||
} |
||||
|
||||
public string Name { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsVirtual { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsStatic { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsConst { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsInline { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsArtificial { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsConstructor { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsDestructor { |
||||
get; set; |
||||
} |
||||
|
||||
public bool IsCopyCtor { |
||||
get; set; |
||||
} |
||||
|
||||
public bool GenWrapperMethod { |
||||
get; set; |
||||
} |
||||
|
||||
public CppType ReturnType { |
||||
get; set; |
||||
} |
||||
|
||||
public List<Parameter> Parameters { |
||||
get; set; |
||||
} |
||||
|
||||
// The C# method name
|
||||
public string FormattedName { |
||||
get { |
||||
return "" + Char.ToUpper (Name [0]) + Name.Substring (1); |
||||
} |
||||
} |
||||
} |
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
public class Namespace { |
||||
|
||||
public Namespace (string name) |
||||
{ |
||||
this.Name = name; |
||||
} |
||||
|
||||
public Namespace (Node node) |
||||
: this (node.Name) |
||||
{ |
||||
this.Node = node; |
||||
} |
||||
|
||||
public Node Node { |
||||
get; set; |
||||
} |
||||
|
||||
// Back ref to enclosing namespace (may be null)
|
||||
public Namespace ParentNamespace { |
||||
get; set; |
||||
} |
||||
|
||||
public string Name { |
||||
get; set; |
||||
} |
||||
|
||||
private string [] fullyQualifiedName; |
||||
public string [] FullyQualifiedName { |
||||
get { |
||||
if (fullyQualifiedName == null) { |
||||
|
||||
if (ParentNamespace == null) { |
||||
fullyQualifiedName = new string[] { Name }; |
||||
} else { |
||||
var parentFqn = ParentNamespace.FullyQualifiedName; |
||||
fullyQualifiedName = new string[parentFqn.Length + 1]; |
||||
Array.Copy (parentFqn, fullyQualifiedName, parentFqn.Length); |
||||
fullyQualifiedName [parentFqn.Length] = Name; |
||||
} |
||||
} |
||||
return fullyQualifiedName; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
//
|
||||
// Node.cs:
|
||||
//
|
||||
//
|
||||
// Author:
|
||||
// Alexander Corrado (alexander.corrado@gmail.com)
|
||||
// Andreia Gaita (shana@spoiledcat.net)
|
||||
// Zoltan Varga <vargaz@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
using System.Collections.Generic; |
||||
|
||||
|
||||
//
|
||||
// This class represents an XML node read from the output of gccxml
|
||||
//
|
||||
public class Node { |
||||
|
||||
// The XML element type
|
||||
public string Type { |
||||
get; set; |
||||
} |
||||
|
||||
// The value of the 'id' attribute
|
||||
public string Id { |
||||
get; set; |
||||
} |
||||
|
||||
// The value of the 'name' attribute or null
|
||||
public string Name { |
||||
get; set; |
||||
} |
||||
|
||||
// Attributes
|
||||
public Dictionary<string, string> Attributes { |
||||
get; set; |
||||
} |
||||
|
||||
// The children nodes of this node
|
||||
public List<Node> Children { |
||||
get; set; |
||||
} |
||||
|
||||
public string this [string key] { |
||||
get { |
||||
return Attributes [key]; |
||||
} |
||||
} |
||||
|
||||
// Maps ids to nodes
|
||||
public static Dictionary<string, Node> IdToNode = new Dictionary <string, Node> (); |
||||
|
||||
// For an attribute which contains an id, return the corresponding Node
|
||||
public Node NodeForAttr (string attr) { |
||||
return IdToNode [Attributes [attr]]; |
||||
} |
||||
|
||||
public bool IsTrue (string key) { |
||||
return Attributes.ContainsKey (key) && Attributes[key] == "1"; |
||||
} |
||||
|
||||
public bool HasValue (string key) { |
||||
return Attributes.ContainsKey (key) && Attributes[key] != ""; |
||||
} |
||||
|
||||
public bool CheckValue (string key, string name) { |
||||
return Attributes.ContainsKey (key) && Attributes[key].Trim () == name.Trim (); |
||||
} |
||||
|
||||
public bool CheckValueList (string key, string name) { |
||||
return Attributes.ContainsKey (key) && Attributes[key].Split (' ').Contains (name.Trim ()); |
||||
} |
||||
} |
@ -1,42 +0,0 @@
@@ -1,42 +0,0 @@
|
||||
// Author:
|
||||
// Zoltan Varga <vargaz@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using Mono.Cxxi; |
||||
|
||||
public class Parameter |
||||
{ |
||||
public Parameter (String name, CppType type) { |
||||
Name = name; |
||||
Type = type; |
||||
} |
||||
|
||||
public string Name { |
||||
get; set; |
||||
} |
||||
|
||||
public CppType Type { |
||||
get; set; |
||||
} |
||||
} |
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
//
|
||||
// Property.cs: Represents a C++ property
|
||||
//
|
||||
// Author:
|
||||
// Zoltan Varga <vargaz@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
using Mono.Cxxi; |
||||
|
||||
public class Property { |
||||
|
||||
public Property (string name, CppType type) { |
||||
Name = name; |
||||
Type = type; |
||||
} |
||||
|
||||
public string Name { |
||||
get; set; |
||||
} |
||||
|
||||
public CppType Type { |
||||
get; set; |
||||
} |
||||
|
||||
public Method GetMethod { |
||||
get; set; |
||||
} |
||||
|
||||
public Method SetMethod { |
||||
get; set; |
||||
} |
||||
} |
@ -1,181 +0,0 @@
@@ -1,181 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
namespace Templates { |
||||
using System; |
||||
|
||||
|
||||
public partial class Base : BaseBase { |
||||
|
||||
public virtual string TransformText() { |
||||
this.GenerationEnvironment = null; |
||||
|
||||
#line 2 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/Base.tt"
|
||||
/* This is a dummy template that language-specific templates may inherit from */ |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return this.GenerationEnvironment.ToString(); |
||||
} |
||||
|
||||
protected virtual void Initialize() { |
||||
} |
||||
} |
||||
|
||||
public class BaseBase { |
||||
|
||||
private global::System.Text.StringBuilder builder; |
||||
|
||||
private global::System.Collections.Generic.IDictionary<string, object> session; |
||||
|
||||
private global::System.CodeDom.Compiler.CompilerErrorCollection errors; |
||||
|
||||
private string currentIndent = string.Empty; |
||||
|
||||
private global::System.Collections.Generic.Stack<int> indents; |
||||
|
||||
private ToStringInstanceHelper _toStringHelper = new ToStringInstanceHelper(); |
||||
|
||||
public virtual global::System.Collections.Generic.IDictionary<string, object> Session { |
||||
get { |
||||
return this.session; |
||||
} |
||||
set { |
||||
this.session = value; |
||||
} |
||||
} |
||||
|
||||
public global::System.Text.StringBuilder GenerationEnvironment { |
||||
get { |
||||
if ((this.builder == null)) { |
||||
this.builder = new global::System.Text.StringBuilder(); |
||||
} |
||||
return this.builder; |
||||
} |
||||
set { |
||||
this.builder = value; |
||||
} |
||||
} |
||||
|
||||
protected global::System.CodeDom.Compiler.CompilerErrorCollection Errors { |
||||
get { |
||||
if ((this.errors == null)) { |
||||
this.errors = new global::System.CodeDom.Compiler.CompilerErrorCollection(); |
||||
} |
||||
return this.errors; |
||||
} |
||||
} |
||||
|
||||
public string CurrentIndent { |
||||
get { |
||||
return this.currentIndent; |
||||
} |
||||
} |
||||
|
||||
private global::System.Collections.Generic.Stack<int> Indents { |
||||
get { |
||||
if ((this.indents == null)) { |
||||
this.indents = new global::System.Collections.Generic.Stack<int>(); |
||||
} |
||||
return this.indents; |
||||
} |
||||
} |
||||
|
||||
public ToStringInstanceHelper ToStringHelper { |
||||
get { |
||||
return this._toStringHelper; |
||||
} |
||||
} |
||||
|
||||
public void Error(string message) { |
||||
this.Errors.Add(new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message)); |
||||
} |
||||
|
||||
public void Warning(string message) { |
||||
global::System.CodeDom.Compiler.CompilerError val = new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message); |
||||
val.IsWarning = true; |
||||
this.Errors.Add(val); |
||||
} |
||||
|
||||
public string PopIndent() { |
||||
if ((this.Indents.Count == 0)) { |
||||
return string.Empty; |
||||
} |
||||
int lastPos = (this.currentIndent.Length - this.Indents.Pop()); |
||||
string last = this.currentIndent.Substring(lastPos); |
||||
this.currentIndent = this.currentIndent.Substring(0, lastPos); |
||||
return last; |
||||
} |
||||
|
||||
public void PushIndent(string indent) { |
||||
this.Indents.Push(indent.Length); |
||||
this.currentIndent = (this.currentIndent + indent); |
||||
} |
||||
|
||||
public void ClearIndent() { |
||||
this.currentIndent = string.Empty; |
||||
this.Indents.Clear(); |
||||
} |
||||
|
||||
public void Write(string textToAppend) { |
||||
this.GenerationEnvironment.Append(textToAppend); |
||||
} |
||||
|
||||
public void Write(string format, params object[] args) { |
||||
this.GenerationEnvironment.AppendFormat(format, args); |
||||
} |
||||
|
||||
public void WriteLine(string textToAppend) { |
||||
this.GenerationEnvironment.Append(this.currentIndent); |
||||
this.GenerationEnvironment.AppendLine(textToAppend); |
||||
} |
||||
|
||||
public void WriteLine(string format, params object[] args) { |
||||
this.GenerationEnvironment.Append(this.currentIndent); |
||||
this.GenerationEnvironment.AppendFormat(format, args); |
||||
this.GenerationEnvironment.AppendLine(); |
||||
} |
||||
|
||||
public class ToStringInstanceHelper { |
||||
|
||||
private global::System.IFormatProvider formatProvider = global::System.Globalization.CultureInfo.InvariantCulture; |
||||
|
||||
public global::System.IFormatProvider FormatProvider { |
||||
get { |
||||
return this.formatProvider; |
||||
} |
||||
set { |
||||
if ((this.formatProvider == null)) { |
||||
throw new global::System.ArgumentNullException("formatProvider"); |
||||
} |
||||
this.formatProvider = value; |
||||
} |
||||
} |
||||
|
||||
public string ToStringWithCulture(object objectToConvert) { |
||||
if ((objectToConvert == null)) { |
||||
throw new global::System.ArgumentNullException("objectToConvert"); |
||||
} |
||||
global::System.Type type = objectToConvert.GetType(); |
||||
global::System.Type iConvertibleType = typeof(global::System.IConvertible); |
||||
if (iConvertibleType.IsAssignableFrom(type)) { |
||||
return ((global::System.IConvertible)(objectToConvert)).ToString(this.formatProvider); |
||||
} |
||||
global::System.Reflection.MethodInfo methInfo = type.GetMethod("ToString", new global::System.Type[] { |
||||
iConvertibleType}); |
||||
if ((methInfo != null)) { |
||||
return ((string)(methInfo.Invoke(objectToConvert, new object[] { |
||||
this.formatProvider}))); |
||||
} |
||||
return objectToConvert.ToString(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
<#@ template language="C#" #> |
||||
<# /* This is a dummy template that language-specific templates may inherit from */ #> |
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Templates { |
||||
|
||||
public interface ITemplate<T> { |
||||
Generator Generator { get; set; } |
||||
T Current { get; set; } |
||||
bool Nested { get; set; } |
||||
string TransformText (); |
||||
} |
||||
|
||||
public partial class LibsBase : Base, ITemplate<ICollection<Lib>> { |
||||
|
||||
public Generator Generator { get; set; } |
||||
public ICollection<Lib> Current { get; set; } |
||||
public bool Nested { get; set; } |
||||
public ICollection<Lib> Libs { get { return Current; } set { Current = value; } } |
||||
} |
||||
|
||||
public partial class ClassBase : Base, ITemplate<Class> { |
||||
|
||||
public Generator Generator { get; set; } |
||||
public Class Current { get; set; } |
||||
public bool Nested { get; set; } |
||||
public Class Class { get { return Current; } set { Current = value; } } |
||||
} |
||||
|
||||
public partial class EnumBase : Base, ITemplate<Enumeration> { |
||||
|
||||
public Generator Generator { get; set; } |
||||
public Enumeration Current { get; set; } |
||||
public bool Nested { get; set; } |
||||
public Enumeration Enum { get { return Current; } set { Current = value; } } |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,404 +0,0 @@
@@ -1,404 +0,0 @@
|
||||
<#@ template language="C#" inherits="ClassBase" #> |
||||
<#@ import namespace="System.IO" #> |
||||
<#@ import namespace="System.Linq" #> |
||||
<#@ import namespace="System.Collections.Generic" #> |
||||
<#@ import namespace="Mono.Cxxi" #> |
||||
<# |
||||
var hasBase = Class.BaseClasses.Count > 0; |
||||
var wrapper = Class.Name; |
||||
var iface = "I" + Class.Name; |
||||
var layout = "_" + Class.Name; |
||||
var layoutClass = (hasBase? "\t: base (impl.TypeInfo)\n\t\t{" : "{") + "\n\t\t\t__cxxi_LayoutClass ();"; |
||||
var overrideInitBases = Generator.CheckPrimaryBases (Class, c => c.BaseClasses.Count > 1); |
||||
var initBases = ((overrideInitBases || Class.BaseClasses.Count > 1) ? "\t__cxxi_InitBases ();\n\t\t}" : "}"); |
||||
var @namespace = Generator.Lib.BaseNamespace + (Class.ParentNamespace != null? "." + string.Join (".", Class.ParentNamespace.FullyQualifiedName) : ""); |
||||
|
||||
if (!Nested) { |
||||
#> |
||||
// ------------------------------------------------------------------------- |
||||
// Managed wrapper for <#= Class.Name #> |
||||
// Generated from <#= Path.GetFileName (Generator.InputFileName) #> on <#= DateTime.Now #> |
||||
// |
||||
// This file was auto generated. Do not edit. |
||||
// ------------------------------------------------------------------------- |
||||
|
||||
using System; |
||||
using Mono.Cxxi; |
||||
|
||||
namespace <#= @namespace #> { |
||||
<# } /* if !Nested */ #> |
||||
public partial class <#= wrapper #> : <#= GetBaseString () #> { |
||||
|
||||
private static readonly <#= iface #> impl = Libs.<#= Generator.Lib.BaseName #>.GetClass<<#= iface + "," + layout + "," + wrapper #>> ("<#= Class.Name #>"); |
||||
<# if (!hasBase) { #> |
||||
public CppInstancePtr Native { get; protected set; } |
||||
<# } #> |
||||
|
||||
<# /* Interface */ #> |
||||
[MangleAs ("<#= Class.MangleType.ToString () #>")] |
||||
public partial interface <#= iface #> : ICppClassOverridable<<#= wrapper #>> { |
||||
<# PushIndent ("\t\t\t"); |
||||
foreach (var method in Class.Methods) { |
||||
Write (CurrentIndent); |
||||
|
||||
if (method.IsVirtual) Write ("[Virtual] "); |
||||
if (method.IsStatic) Write ("[Static] "); |
||||
if (method.IsArtificial) Write ("[Artificial] "); |
||||
if (method.IsInline) Write ("[Inline] "); |
||||
if (method.IsConst) Write ("[Const] "); |
||||
if (method.IsConstructor) Write ("[Constructor] "); |
||||
if (method.IsDestructor) Write ("[Destructor] "); |
||||
if (method.IsCopyCtor) Write ("[CopyConstructor] "); |
||||
|
||||
if (Generator.IsByVal (method.ReturnType)) { |
||||
Write ("[return: ByVal] "); |
||||
} |
||||
if (method.IsConstructor) |
||||
Write ("CppInstancePtr"); |
||||
else |
||||
Write (CSharpLanguage.TypeName (Generator.CppTypeToManaged (method.ReturnType), Context.Interface | Context.Return)); |
||||
Write (" "); |
||||
Write (CSharpLanguage.SafeIdentifier (method.Name)); |
||||
|
||||
Write (" ("); |
||||
if (!method.IsStatic) { |
||||
Write ("CppInstancePtr @this"); |
||||
if (method.Parameters.Count != 0) |
||||
Write (", "); |
||||
} |
||||
|
||||
WriteParameters (method.Parameters, true, !method.IsVirtual); |
||||
Write (");\n"); |
||||
} |
||||
foreach (var field in Class.Fields.Where (f => f.Access != Access.@private)) { |
||||
WriteLine ("CppField<{0}> {1} {{ get; }}", CSharpLanguage.TypeName (Generator.CppTypeToManaged (field.Type), Context.Interface | Context.Generic), CSharpLanguage.SafeIdentifier (field.Name)); |
||||
} |
||||
PopIndent (); #> |
||||
} |
||||
<# /* Native layout */ #> |
||||
public unsafe struct <#= layout #> { |
||||
<# PushIndent ("\t\t\t"); |
||||
foreach (var field in Class.Fields) { |
||||
// handle byval fields |
||||
var fieldType = CSharpLanguage.TypeName (Generator.CppTypeToManaged (field.Type), Context.Generic); |
||||
if (Generator.GetFilterOrDefault (field.Type).ImplType == ImplementationType.@class && Generator.IsByVal (field.Type)) |
||||
fieldType = fieldType + "._" + fieldType; |
||||
|
||||
// handle fixed-length arrays |
||||
var array = field.Type.Modifiers.OfType<CppModifiers.ArrayModifier> ().SingleOrDefault (); //FIXME: Handle more than one? |
||||
if (array != null && array.Size.HasValue) { |
||||
fieldType = fieldType.TrimEnd ('[',']'); |
||||
WriteLine ("public fixed {0} {1} [{2}];", fieldType, CSharpLanguage.SafeIdentifier (field.Name), array.Size.Value); |
||||
} else { |
||||
WriteLine ("public {0} {1};", fieldType, CSharpLanguage.SafeIdentifier (field.Name)); |
||||
} |
||||
} |
||||
PopIndent (); #> |
||||
} |
||||
|
||||
<# /* Native fields */ #> |
||||
<# PushIndent ("\t\t"); |
||||
foreach (var field in Class.Fields.Where (f => f.Access != Access.@private)) { |
||||
var fieldName = CSharpLanguage.SafeIdentifier (field.Name); |
||||
WriteLine ("{0} {1} {2} {{", field.Access, CSharpLanguage.TypeName (Generator.CppTypeToManaged (field.Type), Context.Wrapper | Context.Return), fieldName); #> |
||||
get { |
||||
return impl.<#= fieldName #> [Native]; |
||||
} |
||||
set { |
||||
impl.<#= fieldName #> [Native] = value; |
||||
} |
||||
} |
||||
<# } PopIndent(); #> |
||||
|
||||
<# /* Nested classes */ #> |
||||
<# foreach (var klass in Class.NestedClasses) { |
||||
var nestedTempl = new CSharpClass { |
||||
Generator = this.Generator, |
||||
Class = klass, |
||||
Nested = true |
||||
}; |
||||
Write (nestedTempl.TransformText ()); |
||||
} #> |
||||
|
||||
<# /* Nested enums */ #> |
||||
<# foreach (var @enum in Class.NestedEnums) { |
||||
Generator.EnumTemplate.Generator = Generator; |
||||
Generator.EnumTemplate.Enum = @enum; |
||||
Generator.EnumTemplate.Nested = true; |
||||
Write (Generator.EnumTemplate.TransformText ()); |
||||
} #> |
||||
|
||||
<# /* Subclass constructor */ #> |
||||
public <#= wrapper #> (CppTypeInfo subClass) |
||||
<#= layoutClass #> |
||||
subClass.AddBase (impl.TypeInfo); |
||||
} |
||||
|
||||
<# /* Native constructor */ #> |
||||
public <#= wrapper #> (CppInstancePtr native) |
||||
<#= layoutClass #> |
||||
Native = native; |
||||
<#= initBases #> |
||||
|
||||
<# /* Wrapper methods */ #> |
||||
<# PushIndent ("\t\t"); |
||||
foreach (var method in Class.Methods.Where (m => m.GenWrapperMethod)) { |
||||
var methodName = CSharpLanguage.SafeIdentifier (method.Name); |
||||
WriteMethodHeader (method, layoutClass, false, false); |
||||
|
||||
if (method.IsConstructor) |
||||
Write ("Native = "); |
||||
|
||||
Write ("impl.{0} (", methodName); |
||||
if (!method.IsStatic) { |
||||
if (method.IsConstructor) |
||||
Write ("impl.Alloc (this)"); |
||||
else |
||||
Write ("Native"); |
||||
if (method.Parameters.Count != 0) |
||||
Write (", "); |
||||
} |
||||
|
||||
WriteParameters (method.Parameters, false, false); |
||||
Write (");\n"); |
||||
PopIndent (); |
||||
|
||||
if (method.IsConstructor) |
||||
WriteLine (initBases); |
||||
else |
||||
WriteLine ("}"); |
||||
} |
||||
PopIndent (); #> |
||||
|
||||
<# /* Wrapper properties */ #> |
||||
<# PushIndent ("\t\t"); |
||||
foreach (var prop in Class.Properties) { |
||||
var propName = CSharpLanguage.SafeIdentifier (prop.Name); |
||||
var type = CSharpLanguage.TypeName (Generator.CppTypeToManaged (prop.Type), Context.Wrapper | Context.Return); |
||||
|
||||
Write (CurrentIndent + "public "); |
||||
|
||||
if ((prop.GetMethod == null || prop.GetMethod.IsVirtual) && |
||||
(prop.SetMethod == null || prop.SetMethod.IsVirtual)) |
||||
Write ("virtual "); |
||||
|
||||
Write (type); |
||||
Write (" "); |
||||
Write (propName); |
||||
Write (" {\n"); |
||||
|
||||
PushIndent ("\t"); |
||||
Write (CurrentIndent); |
||||
|
||||
if (prop.GetMethod != null) { |
||||
if (prop.GetMethod.IsVirtual) |
||||
Write ("[OverrideNative (\"{0}\")] ", prop.GetMethod.Name); |
||||
|
||||
Write ("get {\n"); |
||||
PushIndent ("\t"); |
||||
WriteLine ("return impl.{0} (Native);", prop.GetMethod.Name); |
||||
PopIndent (); |
||||
WriteLine ("}"); |
||||
} |
||||
if (prop.SetMethod != null) { |
||||
if (prop.SetMethod.IsVirtual) |
||||
Write ("[OverrideNative (\"{0}\")] ", prop.SetMethod.Name); |
||||
|
||||
WriteLine ("set {"); |
||||
PushIndent ("\t"); |
||||
WriteLine ("impl.{0} (Native, value);", prop.SetMethod.Name); |
||||
PopIndent (); |
||||
WriteLine ("}"); |
||||
} |
||||
|
||||
PopIndent (); |
||||
WriteLine ("}\n"); |
||||
} |
||||
PopIndent (); #> |
||||
|
||||
partial void BeforeDestruct (); |
||||
partial void AfterDestruct (); |
||||
|
||||
public <#= hasBase? "override" : "virtual" #> void Dispose () |
||||
{ |
||||
BeforeDestruct (); |
||||
<# if (Class.Methods.Any (m => m.IsDestructor && !m.IsArtificial)) { #> |
||||
impl.Destruct (Native); |
||||
<# } #> |
||||
Native.Dispose (); |
||||
AfterDestruct (); |
||||
} |
||||
|
||||
private void __cxxi_LayoutClass () |
||||
{ |
||||
<# foreach (var npBase in Class.BaseClasses.Skip (1)) { #> |
||||
new <#= npBase.Name #> (impl.TypeInfo); |
||||
<# } #> |
||||
impl.TypeInfo.CompleteType (); |
||||
} |
||||
|
||||
<# /* Make this wrapper castable to non-primary bases */ |
||||
foreach (var npBase in Class.BaseClasses.Skip (1)) { #> |
||||
|
||||
#region Non-primary base class implementation for <#= npBase.Name #> |
||||
private class <#= wrapper + "__" + npBase.Name #> : <#= npBase.Name #> { |
||||
public <#= wrapper #> instance; |
||||
public <#= wrapper + "__" + npBase.Name #> (<#= wrapper #> instance) |
||||
: base (<#= wrapper #>.impl.TypeInfo.Cast (instance, typeof (<#= npBase.Name #>))) |
||||
{ |
||||
<#= wrapper #>.impl.TypeInfo.InitNonPrimaryBase (this, instance, typeof (<#= npBase.Name #>)); |
||||
this.instance = instance; |
||||
} |
||||
|
||||
<# PushIndent ("\t\t\t"); |
||||
foreach (var method in npBase.Methods.Where (m => m.IsVirtual)) { |
||||
|
||||
if (!method.GenWrapperMethod || Class.Methods.Any (m => m.Node.CheckValue ("overrides", method.Node.Id))) |
||||
continue; |
||||
|
||||
/* this is the managed override that has to call the subclass's method */ |
||||
WriteMethodHeader (method, null, true, false); |
||||
|
||||
Write ("instance.{0} (", npBase.Name + "__" + method.FormattedName); |
||||
|
||||
WriteParameters (method.Parameters, false, false); |
||||
PopIndent (); |
||||
Write (");\n{0}}}\n\n", CurrentIndent); |
||||
|
||||
/* this is the method that calls the base implementation that the subclass will use */ |
||||
WriteMethodHeader (method, npBase.Name + "__" + method.FormattedName, true, false); |
||||
|
||||
Write ("base.{0} (", method.FormattedName); |
||||
|
||||
WriteParameters (method.Parameters, false, false); |
||||
PopIndent (); |
||||
Write (");\n{0}}}\n\n", CurrentIndent); |
||||
} |
||||
PopIndent (); #> |
||||
} |
||||
private <#= wrapper #>__<#= npBase.Name #> __cxxi_<#= npBase.Name #>; |
||||
public <#= npBase.Name #> <#= npBase.Name #> { get { return __cxxi_<#= npBase.Name #>; } } |
||||
public static implicit operator <#= npBase.Name #>(<#= wrapper #> subClass) |
||||
{ |
||||
return subClass.<#= npBase.Name #>; |
||||
} |
||||
public static explicit operator <#= wrapper #>(<#= npBase.Name #> baseClass) |
||||
{ |
||||
if (baseClass == null) return null; |
||||
var obj = baseClass as <#= wrapper + "__" + npBase.Name #>; |
||||
if (obj == null) throw new InvalidCastException (); |
||||
return obj.instance; |
||||
} |
||||
|
||||
<# /* Add virtual methods of non-primary bases to this class proper so they can be overridden */ #> |
||||
<# PushIndent ("\t\t"); |
||||
foreach (var method in npBase.Methods.Where (m => m.IsVirtual)) { |
||||
|
||||
if (!method.GenWrapperMethod || Class.Methods.Any (m => m.Node.CheckValue ("overrides", method.Node.Id))) |
||||
continue; |
||||
|
||||
WriteMethodHeader (method, npBase.Name + "__" + method.FormattedName, true, true); |
||||
|
||||
Write ("{0}.{1} (", "__cxxi_" + npBase.Name, npBase.Name + "__" + method.FormattedName); |
||||
|
||||
WriteParameters (method.Parameters, false, false); |
||||
PopIndent (); |
||||
Write (");\n{0}}}\n\n", CurrentIndent); |
||||
} |
||||
PopIndent (); |
||||
WriteLine ("#endregion"); |
||||
} |
||||
|
||||
if (overrideInitBases || Class.BaseClasses.Count > 1) { #> |
||||
protected <#= overrideInitBases ? "override" : "virtual" #> void __cxxi_InitBases () |
||||
{ |
||||
<#= overrideInitBases? "base.__cxxi_InitBases ();" : "" #> |
||||
<# foreach (var npBase in Class.BaseClasses.Skip (1)) { #> |
||||
__cxxi_<#= npBase.Name #> = new <#= wrapper + "__" + npBase.Name #> (this); |
||||
<# } #> |
||||
} |
||||
<# } #> |
||||
} |
||||
<# if (!Nested) { #> |
||||
} |
||||
<# } #> |
||||
|
||||
<#+ |
||||
private void WriteMethodHeader (Method method, string layoutClass, bool isNonPrimaryOverride, bool @protected) |
||||
{ |
||||
var returnType = CSharpLanguage.TypeName (Generator.CppTypeToManaged (method.ReturnType), Context.Wrapper | Context.Return); |
||||
|
||||
if (!isNonPrimaryOverride && method.IsVirtual) |
||||
WriteLine ("[OverrideNative (\"{0}\")]", method.Name); |
||||
|
||||
Write (CurrentIndent + (@protected? "protected" : method.Access.ToString ()) + " "); |
||||
if (method.IsConstructor) { |
||||
Write (method.FormattedName); |
||||
} else { |
||||
if (method.IsStatic) Write ("static "); |
||||
if (method.IsVirtual && (!isNonPrimaryOverride || layoutClass != null)) Write ("virtual "); |
||||
else if (isNonPrimaryOverride) Write ("override "); |
||||
// ...? |
||||
Write (returnType); |
||||
Write (" "); |
||||
Write (isNonPrimaryOverride && layoutClass != null? layoutClass : method.FormattedName); |
||||
} |
||||
|
||||
Write (" ("); |
||||
WriteParameters (method.Parameters, true, false); |
||||
Write (")\n"); |
||||
|
||||
if (method.IsConstructor && layoutClass != null) |
||||
WriteLine (layoutClass); |
||||
else |
||||
WriteLine ("{"); |
||||
|
||||
PushIndent ("\t"); |
||||
Write (CurrentIndent); |
||||
|
||||
if (returnType != "void") |
||||
Write ("return "); |
||||
} |
||||
|
||||
private void WriteParameters (IList<Parameter> parameters, bool writeType, bool writeAttributes) |
||||
{ |
||||
for (var i = 0; i < parameters.Count; i++) { |
||||
if (i != 0) |
||||
Write (", "); |
||||
|
||||
var type = CSharpLanguage.TypeName (Generator.CppTypeToManaged (parameters [i].Type), Context.Parameter); |
||||
|
||||
if (writeAttributes) { |
||||
var mangleAs = parameters [i].Type.ToString (); |
||||
if (mangleAs != "" && mangleAs != type) |
||||
Write ("[MangleAs (\"{0}\")] ", mangleAs); |
||||
if (Generator.IsByVal (parameters [i].Type)) |
||||
Write ("[ByVal] "); |
||||
} |
||||
|
||||
if (writeType) { |
||||
Write (type); |
||||
Write (" "); |
||||
} else { |
||||
if (type.StartsWith ("ref ")) |
||||
Write ("ref "); |
||||
} |
||||
|
||||
Write (CSharpLanguage.SafeIdentifier (parameters [i].Name)); |
||||
} |
||||
} |
||||
|
||||
private string GetBaseString () |
||||
{ |
||||
if (Class.BaseClasses.Count == 0) |
||||
return "ICppObject"; |
||||
|
||||
var str = Class.BaseClasses [0].Name; |
||||
if (Class.BaseClasses.Count > 1) { |
||||
str = string.Format ("{0} /*, {1} */", str, string.Join (", ", Class.BaseClasses.Skip (1).Select (bc => bc.Name).ToArray ())); |
||||
} |
||||
|
||||
return str; |
||||
} |
||||
|
||||
#> |
@ -1,184 +0,0 @@
@@ -1,184 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
namespace Templates { |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Collections.Generic; |
||||
using Mono.Cxxi; |
||||
using System; |
||||
|
||||
|
||||
public partial class CSharpEnum : EnumBase { |
||||
|
||||
public override string TransformText() { |
||||
this.GenerationEnvironment = null; |
||||
|
||||
#line 6 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
|
||||
var @namespace = Generator.Lib.BaseNamespace + (Enum.ParentNamespace != null? "." + string.Join (".", Enum.ParentNamespace.FullyQualifiedName) : ""); |
||||
|
||||
if (!Nested) { |
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 11 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write("\n// -------------------------------------------------------------------------\n// Managed enum for "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 13 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( Enum.Name )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 13 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write("\n// Generated from "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 14 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( Path.GetFileName (Generator.InputFileName) )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 14 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(" on "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 14 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( DateTime.Now )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 14 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write("\n//\n// This file was auto generated. Do not edit.\n// -------------------------------------------------------------------------\n\nnamespace "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 19 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( @namespace )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 19 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(" {\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 20 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
} /* if !Nested */ |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 21 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write("\tpublic enum "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 21 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( Enum.Name )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 21 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(" {\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 22 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
foreach (var item in Enum.Items) { |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write("\t\t"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( item.Name )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(" = "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( item.Value )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write(",\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 24 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
} |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 25 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write("\t}\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 26 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
if (!Nested) { |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 27 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
this.Write("}\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 28 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpEnum.tt"
|
||||
} |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return this.GenerationEnvironment.ToString(); |
||||
} |
||||
|
||||
protected override void Initialize() { |
||||
base.Initialize(); |
||||
} |
||||
} |
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
<#@ template language="C#" inherits="EnumBase" #> |
||||
<#@ import namespace="System.IO" #> |
||||
<#@ import namespace="System.Linq" #> |
||||
<#@ import namespace="System.Collections.Generic" #> |
||||
<#@ import namespace="Mono.Cxxi" #> |
||||
<# |
||||
var @namespace = Generator.Lib.BaseNamespace + (Enum.ParentNamespace != null? "." + string.Join (".", Enum.ParentNamespace.FullyQualifiedName) : ""); |
||||
|
||||
if (!Nested) { |
||||
#> |
||||
|
||||
// ------------------------------------------------------------------------- |
||||
// Managed enum for <#= Enum.Name #> |
||||
// Generated from <#= Path.GetFileName (Generator.InputFileName) #> on <#= DateTime.Now #> |
||||
// |
||||
// This file was auto generated. Do not edit. |
||||
// ------------------------------------------------------------------------- |
||||
|
||||
namespace <#= @namespace #> { |
||||
<# } /* if !Nested */ #> |
||||
public enum <#= Enum.Name #> { |
||||
<# foreach (var item in Enum.Items) { #> |
||||
<#= item.Name #> = <#= item.Value #>, |
||||
<# } #> |
||||
} |
||||
<# if (!Nested) { #> |
||||
} |
||||
<# } #> |
@ -1,73 +0,0 @@
@@ -1,73 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
using Mono.Cxxi; |
||||
|
||||
namespace Templates { |
||||
public static class CSharpLanguage { |
||||
|
||||
// from https://github.com/mono/mono/blob/master/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs
|
||||
private static string[] keywords = new string[] { |
||||
"abstract","event","new","struct","as","explicit","null","switch","base","extern", |
||||
"this","false","operator","throw","break","finally","out","true", |
||||
"fixed","override","try","case","params","typeof","catch","for", |
||||
"private","foreach","protected","checked","goto","public", |
||||
"unchecked","class","if","readonly","unsafe","const","implicit","ref", |
||||
"continue","in","return","using","virtual","default", |
||||
"interface","sealed","volatile","delegate","internal","do","is", |
||||
"sizeof","while","lock","stackalloc","else","static","enum", |
||||
"namespace", |
||||
"object","bool","byte","float","uint","char","ulong","ushort", |
||||
"decimal","int","sbyte","short","double","long","string","void", |
||||
"partial", "yield", "where" |
||||
}; |
||||
|
||||
public static string SafeIdentifier (string proposedName) |
||||
{ |
||||
proposedName = new string (((IEnumerable<char>)proposedName).Select (c => char.IsLetterOrDigit (c)? c : '_').ToArray ()); |
||||
return keywords.Contains (proposedName)? "@" + proposedName : proposedName; |
||||
} |
||||
|
||||
public static string TypeName (string str, Context context) |
||||
{ |
||||
switch (str) { |
||||
case "System.Void": return "void"; |
||||
case "System.Boolean": return "bool"; |
||||
case "System.Byte": return "byte"; |
||||
case "System.SByte": return "sbyte"; |
||||
case "System.Char": return "char"; |
||||
case "System.Int16": return "short"; |
||||
case "System.UInt16": return "ushort"; |
||||
case "System.Decimal": return "decimal"; |
||||
case "System.Single": return "float"; |
||||
case "System.Double": return "double"; |
||||
case "System.Int32": return "int"; |
||||
case "System.UInt32": return "uint"; |
||||
case "System.Int64": return "long"; |
||||
case "System.UInt64": return "ulong"; |
||||
case "System.Object": return "object"; |
||||
case "System.String": return "string"; |
||||
} |
||||
|
||||
if (str.EndsWith ("&")) { |
||||
if (context.Is (Context.Parameter)) |
||||
return "ref " + TypeName (str.TrimEnd ('&'), context); |
||||
if (context.Is (Context.Return)) |
||||
return (context.Is (Context.Interface)? "[return: ByRef] " : "") + TypeName (str.TrimEnd ('&'), context); |
||||
if (context.Is (Context.Generic)) |
||||
return "IntPtr"; |
||||
} |
||||
|
||||
// we are using System by default
|
||||
var lastDot = str.LastIndexOf ('.'); |
||||
if (str.StartsWith ("System") && lastDot == "System".Length) |
||||
return str.Substring (lastDot + 1); |
||||
|
||||
return str; |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
||||
|
@ -1,116 +0,0 @@
@@ -1,116 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
namespace Templates { |
||||
using System; |
||||
|
||||
|
||||
public partial class CSharpLibs : LibsBase { |
||||
|
||||
public override string TransformText() { |
||||
this.GenerationEnvironment = null; |
||||
|
||||
#line 2 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write("// -------------------------------------------------------------------------\n// C++ library declarations\n// Generated on "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 4 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( DateTime.Now )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 4 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write("\n//\n// This file was auto generated. Do not edit.\n// -------------------------------------------------------------------------\n\nusing System;\nusing Mono.Cxxi;\n\nnamespace "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 12 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( Generator.Lib.BaseNamespace )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 12 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(" {\n\n\tpublic static partial class Libs {\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 15 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
foreach (var lib in Libs) { |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 16 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write("\t\tpublic static readonly CppLibrary "); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 16 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( CSharpLanguage.SafeIdentifier (lib.BaseName) )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 16 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(" = new CppLibrary (\""); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 16 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( lib.BaseName )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 16 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write("\", InlineMethods."); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 16 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( lib.InlinePolicy )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 16 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write(");\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 17 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
} |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 18 "/Users/alex/OpenSource/cppinterop/src/generator/Templates/CSharp/CSharpLibs.tt"
|
||||
this.Write("\t}\n}\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return this.GenerationEnvironment.ToString(); |
||||
} |
||||
|
||||
protected override void Initialize() { |
||||
base.Initialize(); |
||||
} |
||||
} |
||||
} |
@ -1,19 +0,0 @@
@@ -1,19 +0,0 @@
|
||||
<#@ template language="C#" inherits="LibsBase" #> |
||||
// ------------------------------------------------------------------------- |
||||
// C++ library declarations |
||||
// Generated on <#= DateTime.Now #> |
||||
// |
||||
// This file was auto generated. Do not edit. |
||||
// ------------------------------------------------------------------------- |
||||
|
||||
using System; |
||||
using Mono.Cxxi; |
||||
|
||||
namespace <#= Generator.Lib.BaseNamespace #> { |
||||
|
||||
public static partial class Libs { |
||||
<# foreach (var lib in Libs) { #> |
||||
public static readonly CppLibrary <#= CSharpLanguage.SafeIdentifier (lib.BaseName) #> = new CppLibrary ("<#= lib.BaseName #>", InlineMethods.<#= lib.InlinePolicy #>); |
||||
<# } #> |
||||
} |
||||
} |
@ -1,19 +0,0 @@
@@ -1,19 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace Templates { |
||||
[Flags] |
||||
public enum Context { |
||||
Generic = 0, |
||||
Parameter = 1 << 0, |
||||
Return = 1 << 1, |
||||
Interface = 1 << 2, |
||||
Wrapper = 1 << 3 |
||||
} |
||||
public static class ContextExtensions { |
||||
public static bool Is (this Context bits, Context bit) |
||||
{ |
||||
return (bits & bit) == bit; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,151 +0,0 @@
@@ -1,151 +0,0 @@
|
||||
<?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> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProductVersion>8.0.50727</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{AD0F9378-789C-4AF1-B0DD-6DD9A63C3401}</ProjectGuid> |
||||
<OutputType>Exe</OutputType> |
||||
<AssemblyName>generator</AssemblyName> |
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
<FileUpgradeFlags> |
||||
</FileUpgradeFlags> |
||||
<UpgradeBackupLocation> |
||||
</UpgradeBackupLocation> |
||||
<OldToolsVersion>2.0</OldToolsVersion> |
||||
<PublishUrl>http://localhost/generator/</PublishUrl> |
||||
<Install>true</Install> |
||||
<InstallFrom>Web</InstallFrom> |
||||
<UpdateEnabled>true</UpdateEnabled> |
||||
<UpdateMode>Foreground</UpdateMode> |
||||
<UpdateInterval>7</UpdateInterval> |
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits> |
||||
<UpdatePeriodically>false</UpdatePeriodically> |
||||
<UpdateRequired>false</UpdateRequired> |
||||
<MapFileExtensions>true</MapFileExtensions> |
||||
<ApplicationRevision>0</ApplicationRevision> |
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> |
||||
<IsWebBootstrapper>true</IsWebBootstrapper> |
||||
<UseApplicationTrust>false</UseApplicationTrust> |
||||
<BootstrapperEnabled>true</BootstrapperEnabled> |
||||
<RootNamespace>Templates</RootNamespace> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>full</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>..\..\bin\Debug</OutputPath> |
||||
<DefineConstants>DEBUG</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugType>none</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>..\..\bin\Release</OutputPath> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Options.cs" /> |
||||
<Compile Include="Class.cs" /> |
||||
<Compile Include="Field.cs" /> |
||||
<Compile Include="Generator.cs" /> |
||||
<Compile Include="Method.cs" /> |
||||
<Compile Include="Node.cs" /> |
||||
<Compile Include="Parameter.cs" /> |
||||
<Compile Include="Property.cs" /> |
||||
<Compile Include="Templates\Base.cs"> |
||||
<DependentUpon>Base.tt</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Templates\BaseMembers.cs" /> |
||||
<Compile Include="Templates\CSharp\CSharpClass.cs"> |
||||
<DependentUpon>CSharpClass.tt</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Templates\CSharp\CSharpLibs.cs"> |
||||
<DependentUpon>CSharpLibs.tt</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Access.cs" /> |
||||
<Compile Include="Templates\CSharp\CSharpLanguage.cs" /> |
||||
<Compile Include="Templates\Context.cs" /> |
||||
<Compile Include="Filter.cs" /> |
||||
<Compile Include="Enumeration.cs" /> |
||||
<Compile Include="Lib.cs" /> |
||||
<Compile Include="Templates\CSharp\CSharpEnum.cs"> |
||||
<DependentUpon>CSharpEnum.tt</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Namespace.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System"> |
||||
</Reference> |
||||
<Reference Include="System.Xml"> |
||||
</Reference> |
||||
<Reference Include="System.Xml.Linq" /> |
||||
<Reference Include="System.Core" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
||||
<ItemGroup> |
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5"> |
||||
<Visible>False</Visible> |
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> |
||||
<Install>false</Install> |
||||
</BootstrapperPackage> |
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> |
||||
<Visible>False</Visible> |
||||
<ProductName>.NET Framework 3.5 SP1</ProductName> |
||||
<Install>true</Install> |
||||
</BootstrapperPackage> |
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> |
||||
<Visible>False</Visible> |
||||
<ProductName>Windows Installer 3.1</ProductName> |
||||
<Install>true</Install> |
||||
</BootstrapperPackage> |
||||
</ItemGroup> |
||||
<ProjectExtensions> |
||||
<MonoDevelop> |
||||
<Properties> |
||||
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am" SyncReferences="true" IsAutotoolsProject="true" RelativeConfigureInPath="../.."> |
||||
<BuildFilesVar Sync="true" Name="FILES" /> |
||||
<DeployFilesVar /> |
||||
<ResourcesVar Sync="true" Name="RESOURCES" /> |
||||
<OthersVar /> |
||||
<GacRefVar Sync="true" Name="REFERENCES" /> |
||||
<AsmRefVar Sync="true" Name="REFERENCES" /> |
||||
<ProjectRefVar Sync="true" Name="REFERENCES" /> |
||||
</MonoDevelop.Autotools.MakefileInfo> |
||||
</Properties> |
||||
</MonoDevelop> |
||||
</ProjectExtensions> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\Mono.Cxxi\Mono.Cxxi.csproj"> |
||||
<Project>{4A864586-93C5-4DC1-8A80-F094A88506D7}</Project> |
||||
<Name>Mono.Cxxi</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="Templates\CSharp\CSharpClass.tt"> |
||||
<Generator>TextTemplatingFilePreprocessor</Generator> |
||||
<LastGenOutput>CSharpClass.cs</LastGenOutput> |
||||
</None> |
||||
<None Include="Templates\CSharp\CSharpLibs.tt"> |
||||
<Generator>TextTemplatingFilePreprocessor</Generator> |
||||
<LastGenOutput>CSharpLibs.cs</LastGenOutput> |
||||
</None> |
||||
<None Include="Templates\Base.tt"> |
||||
<Generator>TextTemplatingFilePreprocessor</Generator> |
||||
<LastGenOutput>Base.cs</LastGenOutput> |
||||
</None> |
||||
<None Include="Templates\CSharp\CSharpEnum.tt"> |
||||
<Generator>TextTemplatingFilePreprocessor</Generator> |
||||
<LastGenOutput>CSharpEnum.cs</LastGenOutput> |
||||
</None> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Templates\" /> |
||||
<Folder Include="Templates\CSharp\" /> |
||||
</ItemGroup> |
||||
</Project> |
@ -1,3 +0,0 @@
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh |
||||
|
||||
exec mono "@expanded_libdir@/@PACKAGE@/generator.exe" "$@" |
@ -1,20 +0,0 @@
@@ -1,20 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# Visual Studio 2005 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "generator", "generator.csproj", "{AD0F9378-789C-4AF1-B0DD-6DD9A63C3401}" |
||||
EndProject |
||||
Global |
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
Debug|Any CPU = Debug|Any CPU |
||||
Release|Any CPU = Release|Any CPU |
||||
EndGlobalSection |
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
{AD0F9378-789C-4AF1-B0DD-6DD9A63C3401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{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 |
||||
EndGlobalSection |
||||
GlobalSection(MonoDevelopProperties) = preSolution |
||||
StartupItem = generator.csproj |
||||
EndGlobalSection |
||||
EndGlobal |
Loading…
Reference in new issue