mirror of https://github.com/mono/CppSharp.git
22 changed files with 2 additions and 1513 deletions
@ -1,2 +1,2 @@
@@ -1,2 +1,2 @@
|
||||
|
||||
SUBDIRS = Mono.VisualC.Interop Mono.VisualC.Code generator |
||||
SUBDIRS = Mono.VisualC.Interop generator |
||||
|
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
using System; |
||||
namespace Mono.VisualC.Code { |
||||
public enum Access { |
||||
Public, |
||||
Protected, |
||||
Private |
||||
} |
||||
} |
||||
|
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("Mono.VisualC.Code")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("")] |
||||
[assembly: AssemblyCopyright("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")] |
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
||||
[assembly: CLSCompliant(true)] |
@ -1,265 +0,0 @@
@@ -1,265 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
|
||||
using System.CodeDom; |
||||
using Mono.VisualC.Interop; |
||||
using Mono.VisualC.Code; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
|
||||
public class Class : CodeContainer { |
||||
|
||||
// FIXME: This should be moved into Mono.VisualC.Interop and an attribute
|
||||
// for name mangling purposes (MSVC mangles differently depending on defined as class or struct).
|
||||
public enum Definition { |
||||
Class, |
||||
Struct |
||||
} |
||||
public struct BaseClass { |
||||
public string Name; |
||||
public Access Access; |
||||
public bool IsVirtual; |
||||
} |
||||
|
||||
public string StaticCppLibrary { get; set; } |
||||
public Definition DefinedAs { get; set; } |
||||
|
||||
public IList<BaseClass> Bases { get; set; } |
||||
public IList<string> TemplateArguments { get; set; } |
||||
public string GenericName {get; set;} |
||||
public CppType OriginalType {get; set;} |
||||
|
||||
public Class (string name) |
||||
{ |
||||
Name = name; |
||||
Bases = new List<BaseClass> (); |
||||
TemplateArguments = new List<string> (); |
||||
} |
||||
|
||||
internal protected override object InsideCodeNamespace (CodeNamespace ns) |
||||
{ |
||||
ns.Types.Add (CreateWrapperClass ()); |
||||
return null; |
||||
} |
||||
|
||||
internal protected override object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
if (!decl.IsClass) |
||||
return null; |
||||
|
||||
decl.Members.Add (CreateWrapperClass ()); |
||||
return null; |
||||
} |
||||
|
||||
public CodeTypeDeclaration CreateWrapperClass () |
||||
{ |
||||
var wrapper = new CodeTypeDeclaration (Name) { |
||||
Attributes = MemberAttributes.Public, |
||||
TypeAttributes = TypeAttributes.Public |
||||
}; |
||||
foreach (var arg in TemplateArguments) |
||||
wrapper.TypeParameters.Add (arg); |
||||
|
||||
if (Atoms.Count == 0) { |
||||
wrapper.Comments.Add (new CodeCommentStatement ("FIXME: This type is a stub.")); |
||||
string m = CreateBaseImplementation (wrapper); |
||||
wrapper.BaseTypes.Add (m); |
||||
wrapper.Members.Add (new CodeMemberMethod { Name = "Dispose", Attributes = MemberAttributes.Public}); |
||||
|
||||
var ctor = new CodeConstructor { |
||||
Name = this.Name, |
||||
Attributes = MemberAttributes.Assembly |
||||
}; |
||||
ctor.Parameters.Add (new CodeParameterDeclarationExpression (typeof (CppTypeInfo).Name, "subClass")); |
||||
|
||||
wrapper.Members.Add (ctor); |
||||
return wrapper; |
||||
} |
||||
|
||||
var iface = CreateInterface (wrapper); |
||||
wrapper.Members.Add (iface); |
||||
|
||||
var native = CreateNativeLayout (); |
||||
wrapper.Members.Add (native); |
||||
|
||||
// FIXME: For now, we'll have the managed wrapper extend from the first public base class
|
||||
string managedBase = Bases.Where (b => b.Access == Access.Public).Select (b => b.Name).FirstOrDefault (); |
||||
bool hasOverrides = true; |
||||
|
||||
if (managedBase == null) { |
||||
hasOverrides = false; |
||||
managedBase = CreateBaseImplementation (wrapper); |
||||
} |
||||
wrapper.BaseTypes.Add (managedBase); |
||||
|
||||
// add static impl field
|
||||
var implField = new CodeMemberField (iface.TypeReference (), "impl") { Attributes = MemberAttributes.Static | MemberAttributes.Private }; |
||||
if (StaticCppLibrary != null) { |
||||
CodeTypeReference [] types = new CodeTypeReference [] { |
||||
iface.TypeReference (), |
||||
native.TypeReference (), |
||||
wrapper.TypeReference () |
||||
}; |
||||
var getClassMethod = new CodeMethodReferenceExpression (new CodeTypeReferenceExpression (new CodeTypeReference (StaticCppLibrary, CodeTypeReferenceOptions.GlobalReference)), "GetClass", types); |
||||
implField.InitExpression = new CodeMethodInvokeExpression (getClassMethod, new CodePrimitiveExpression (Name)); |
||||
} |
||||
wrapper.Members.Add (implField); |
||||
|
||||
// always add native subclass ctor
|
||||
wrapper.Members.Add (CreateNativeSubclassConstructor (hasOverrides)); |
||||
|
||||
CodeMemberMethod dispose = null; |
||||
foreach (var atom in Atoms) { |
||||
Method method = atom as Method; |
||||
if (method != null && method.IsDestructor) { |
||||
dispose = (CodeMemberMethod)method.InsideCodeTypeDeclaration (wrapper); |
||||
atom.Visit (dispose); |
||||
} else |
||||
atom.Visit (wrapper); |
||||
} |
||||
|
||||
if (dispose == null) { |
||||
dispose = CreateDestructorlessDispose (); |
||||
wrapper.Members.Add (dispose); |
||||
} |
||||
|
||||
if (hasOverrides) |
||||
dispose.Attributes |= MemberAttributes.Override; |
||||
|
||||
return wrapper; |
||||
} |
||||
|
||||
string CreateBaseImplementation (CodeTypeDeclaration wrapper) |
||||
{ |
||||
string managedBase = typeof (ICppObject).Name; |
||||
|
||||
// Add Native property
|
||||
var nativeField = new CodeMemberField (typeof (CppInstancePtr).Name, "native_ptr") { Attributes = MemberAttributes.Family }; |
||||
var nativeProperty = new CodeMemberProperty { |
||||
Name = "Native", |
||||
Type = new CodeTypeReference (typeof (CppInstancePtr).Name), |
||||
HasSet = false, |
||||
Attributes = MemberAttributes.Public | MemberAttributes.Final |
||||
}; |
||||
nativeProperty.GetStatements.Add (new CodeMethodReturnStatement (new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), nativeField.Name))); |
||||
|
||||
wrapper.Members.Add (nativeField); |
||||
wrapper.Members.Add (nativeProperty); |
||||
return managedBase; |
||||
} |
||||
|
||||
public CodeTypeDeclaration CreateInterface () |
||||
{ |
||||
return CreateInterface (null); |
||||
} |
||||
public CodeTypeDeclaration CreateInterface (CodeTypeDeclaration wrapper) |
||||
{ |
||||
var iface = new CodeTypeDeclaration ("I" + Name) { |
||||
TypeAttributes = TypeAttributes.Interface | (wrapper != null? TypeAttributes.NestedPublic : TypeAttributes.Public), |
||||
Attributes = MemberAttributes.Public, |
||||
IsInterface = true |
||||
}; |
||||
|
||||
foreach (var arg in TemplateArguments) |
||||
iface.TypeParameters.Add (arg); |
||||
|
||||
if (wrapper != null) |
||||
iface.BaseTypes.Add (new CodeTypeReference (typeof (ICppClassOverridable<>).Name, wrapper.TypeReference ())); |
||||
else |
||||
iface.BaseTypes.Add (new CodeTypeReference (typeof (ICppClass).Name)); |
||||
|
||||
foreach (var atom in Atoms) |
||||
atom.Visit (iface); |
||||
|
||||
return iface; |
||||
} |
||||
|
||||
public CodeTypeDeclaration CreateNativeLayout () |
||||
{ |
||||
var native = new CodeTypeDeclaration ("_" + Name) { |
||||
TypeAttributes = TypeAttributes.NestedPrivate | TypeAttributes.SequentialLayout, |
||||
Attributes = MemberAttributes.Private, |
||||
IsStruct = true |
||||
}; |
||||
|
||||
foreach (var atom in Atoms) |
||||
atom.Visit (native); |
||||
|
||||
return native; |
||||
} |
||||
|
||||
private CodeConstructor CreateNativeSubclassConstructor (bool callBase) |
||||
{ |
||||
var ctor = new CodeConstructor { |
||||
Name = this.Name, |
||||
Attributes = MemberAttributes.Assembly |
||||
}; |
||||
ctor.Parameters.Add (new CodeParameterDeclarationExpression (typeof (CppTypeInfo).Name, "subClass")); |
||||
|
||||
// FIXME: Again, will this always work?
|
||||
var implTypeInfo = new CodeFieldReferenceExpression (new CodeFieldReferenceExpression { FieldName = "impl" }, "TypeInfo"); |
||||
|
||||
if (callBase) |
||||
ctor.BaseConstructorArgs.Add (implTypeInfo); |
||||
|
||||
var addBase = new CodeMethodInvokeExpression (new CodeArgumentReferenceExpression ("subClass"), "AddBase", implTypeInfo); |
||||
ctor.Statements.Add (addBase); |
||||
|
||||
return ctor; |
||||
} |
||||
|
||||
private CodeMemberMethod CreateDestructorlessDispose () |
||||
{ |
||||
var dispose = new CodeMemberMethod { |
||||
Name = "Dispose", |
||||
Attributes = MemberAttributes.Public |
||||
}; |
||||
|
||||
var warning = new CodeCommentStatement ("FIXME: Check for inline destructor for this class."); |
||||
dispose.Statements.Add (warning); |
||||
|
||||
var native = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), "Native"); |
||||
dispose.Statements.Add (new CodeMethodInvokeExpression (native, "Dispose")); |
||||
|
||||
return dispose; |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
string declarator = (DefinedAs == Definition.Class? "class" : "struct"); |
||||
writer.Write ("{0} {1}", declarator, Name); |
||||
|
||||
var bce = Bases.GetEnumerator (); |
||||
|
||||
if (bce.MoveNext ()) { |
||||
writer.Write (" : "); |
||||
|
||||
while (true) { |
||||
var baseClass = bce.Current; |
||||
|
||||
if (baseClass.IsVirtual) writer.Write ("virtual "); |
||||
switch (baseClass.Access) { |
||||
case Access.Public: writer.Write ("public "); break; |
||||
case Access.Protected: writer.Write ("protected "); break; |
||||
case Access.Private: writer.Write ("private "); break; |
||||
} |
||||
|
||||
writer.Write (baseClass.Name); |
||||
|
||||
if (!bce.MoveNext ()) |
||||
break; |
||||
|
||||
writer.Write (", "); |
||||
} |
||||
} |
||||
|
||||
writer.WriteLine (" {"); |
||||
base.Write (writer); |
||||
writer.WriteLine ("};"); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,61 +0,0 @@
@@ -1,61 +0,0 @@
|
||||
using System; |
||||
using System.Linq; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Collections.Generic; |
||||
|
||||
using System.CodeDom; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
public class Enumeration : CodeAtom { |
||||
|
||||
public struct Item { |
||||
public string Name; |
||||
public int Value; |
||||
} |
||||
|
||||
public string Name { get; set; } |
||||
public IList<Item> Items { get; set; } |
||||
|
||||
public Enumeration (string name) |
||||
{ |
||||
Name = name; |
||||
Items = new List<Item> (); |
||||
} |
||||
|
||||
internal protected override object InsideCodeNamespace (CodeNamespace ns) |
||||
{ |
||||
ns.Types.Add (CreateEnumType ()); |
||||
return null; |
||||
} |
||||
|
||||
internal protected override object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
if (!decl.IsClass) |
||||
return null; |
||||
|
||||
decl.Members.Add (CreateEnumType ()); |
||||
return null; |
||||
} |
||||
|
||||
public CodeTypeDeclaration CreateEnumType () |
||||
{ |
||||
var type = new CodeTypeDeclaration (Name) { |
||||
Attributes = MemberAttributes.Public, |
||||
TypeAttributes = TypeAttributes.Public, |
||||
IsEnum = true |
||||
}; |
||||
|
||||
foreach (Item i in Items) |
||||
type.Members.Add (new CodeMemberField (typeof (int), i.Name) { InitExpression = new CodePrimitiveExpression (i.Value) }); |
||||
|
||||
return type; |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
throw new NotImplementedException (); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,69 +0,0 @@
@@ -1,69 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.CodeDom; |
||||
|
||||
using Mono.VisualC.Interop; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
public class Field : CodeAtom { |
||||
|
||||
public string Name { get; set; } |
||||
public CppType Type { get; set; } |
||||
|
||||
public Field (string name, CppType type) |
||||
{ |
||||
Name = name; |
||||
Type = type; |
||||
} |
||||
|
||||
internal protected override object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
// FIXME: eventually this could add CppFields to the interface so they could be
|
||||
// so they could be accessed as properties in the managed api
|
||||
if (!decl.IsStruct) |
||||
return null; |
||||
|
||||
CodeMemberField field = new CodeMemberField { Name = this.Name }; |
||||
CodeTypeReference typeRef = TypeReference; |
||||
|
||||
if (typeRef == null) { |
||||
field.Comments.Add (new CodeCommentStatement ("FIXME: Unknown type \"" + Type.ToString () + "\" for field \"" + Name + ".\" Assuming IntPtr.")); |
||||
field.Type = new CodeTypeReference (typeof (IntPtr)); |
||||
} else |
||||
field.Type = typeRef; |
||||
|
||||
decl.Members.Add (field); |
||||
return field; |
||||
} |
||||
|
||||
// FIXME: Handle fixed size arrays? Can't really see a good way to do that yet.
|
||||
public CodeTypeReference TypeReference { |
||||
get { |
||||
|
||||
if (Type.Modifiers.Count > 0) { |
||||
CppModifiers lastModifier = Type.Modifiers [Type.Modifiers.Count - 1]; |
||||
if (lastModifier == CppModifiers.Pointer || lastModifier == CppModifiers.Reference) |
||||
return new CodeTypeReference (typeof (IntPtr)); |
||||
} |
||||
|
||||
if (Type.ElementType == CppTypes.Enum || Type.ElementType == CppTypes.Union) |
||||
return Type.TypeReference (); |
||||
|
||||
if (Type.ElementType == CppTypes.Typename) |
||||
return new CodeTypeReference (Type.ElementTypeName, CodeTypeReferenceOptions.GenericTypeParameter); |
||||
|
||||
Type managedType = Type.ToManagedType (); |
||||
if (managedType != null) |
||||
return new CodeTypeReference (managedType); |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
writer.WriteLine ("{0} {1};", Type.ToString (), Name); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,311 +0,0 @@
@@ -1,311 +0,0 @@
|
||||
using System; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.IO; |
||||
using System.Collections.Generic; |
||||
using System.CodeDom; |
||||
|
||||
using Mono.VisualC.Interop; |
||||
using Mono.VisualC.Interop.ABI; |
||||
using Mono.VisualC.Interop.Util; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
|
||||
public class Method : CodeContainer { |
||||
|
||||
public Access Access { get; set; } |
||||
public bool IsVirtual { get; set; } |
||||
public bool IsStatic { get; set; } |
||||
public bool IsConst { get; set; } |
||||
public bool IsConstructor { get; set; } |
||||
public bool IsDestructor { get; set; } |
||||
|
||||
public CppType RetType { get; set; } |
||||
|
||||
public IList<NameTypePair<CppType>> Parameters { get; set; } |
||||
public Class Klass { get; set; } |
||||
|
||||
private string formatted_name; |
||||
|
||||
// for testing:
|
||||
// FIXME: make this Nullable, auto implemented property and remove bool field once this won't cause gmcs to crash
|
||||
public NameTypePair<Type> Mangled { |
||||
get { |
||||
if (!hasMangledInfo) throw new InvalidOperationException ("No mangle info present."); |
||||
return mangled; |
||||
} |
||||
set { |
||||
mangled = value; |
||||
hasMangledInfo = true; |
||||
} |
||||
|
||||
} |
||||
private NameTypePair<Type> mangled; |
||||
private bool hasMangledInfo = false; |
||||
|
||||
|
||||
public Method (string name) |
||||
{ |
||||
Name = name; |
||||
Parameters = new List<NameTypePair<CppType>> (); |
||||
} |
||||
|
||||
internal protected override object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
if (decl.IsClass) { |
||||
var method = CreateWrapperMethod (); |
||||
|
||||
if (method == null || CommentedOut) |
||||
return null; |
||||
|
||||
if (Comment != null) |
||||
method.Comments.Add (new CodeCommentStatement (Comment)); |
||||
|
||||
decl.Members.Add (method); |
||||
return method; |
||||
|
||||
} else if (decl.IsInterface) { |
||||
CodeTypeMember method = CreateInterfaceMethod (); |
||||
CodeTypeMember member; |
||||
|
||||
if (CommentedOut) { |
||||
member = new CodeSnippetTypeMember (); |
||||
member.Comments.Add (new CodeCommentStatement (method.CommentOut (current_code_provider))); |
||||
|
||||
} else |
||||
member = method; |
||||
|
||||
if (Comment != null) |
||||
member.Comments.Insert (0, new CodeCommentStatement (Comment)); |
||||
|
||||
decl.Members.Add (member); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
internal protected override object InsideCodeStatementCollection (CodeStatementCollection stmts) |
||||
{ |
||||
List<CodeExpression> arguments = new List<CodeExpression> (); |
||||
var native = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), "Native"); |
||||
var native_ptr = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), "native_ptr"); |
||||
|
||||
if (!IsStatic) |
||||
arguments.Add (native); |
||||
|
||||
foreach (var param in Parameters) { |
||||
// FIXME: handle typenames better
|
||||
if (param.Type.ElementType != CppTypes.Typename) { |
||||
Type managedType = param.Type.ToManagedType (); |
||||
if (managedType != null && managedType.IsByRef) { |
||||
arguments.Add (new CodeDirectionExpression (FieldDirection.Ref, new CodeArgumentReferenceExpression (param.Name))); |
||||
continue; |
||||
} |
||||
} |
||||
arguments.Add (new CodeArgumentReferenceExpression (param.Name)); |
||||
} |
||||
|
||||
// FIXME: Does just specifying the field name work for all code generators?
|
||||
var impl = new CodeFieldReferenceExpression { FieldName = "impl" }; |
||||
|
||||
|
||||
if (IsConstructor) { |
||||
var alloc = new CodeMethodInvokeExpression (impl, "Alloc", new CodeThisReferenceExpression ()); |
||||
stmts.Add (new CodeAssignStatement (native_ptr, alloc)); |
||||
} |
||||
|
||||
var invoke = new CodeMethodInvokeExpression (impl, Name, arguments.ToArray ()); |
||||
|
||||
if (RetType.Equals (CppTypes.Void) || IsConstructor) |
||||
stmts.Add (invoke); |
||||
else |
||||
stmts.Add (new CodeMethodReturnStatement (invoke)); |
||||
|
||||
if (IsDestructor) |
||||
stmts.Add (new CodeMethodInvokeExpression (native, "Dispose")); |
||||
|
||||
return null; |
||||
} |
||||
|
||||
private CodeMemberMethod CreateInterfaceMethod () |
||||
{ |
||||
var returnType = ReturnTypeReference; |
||||
var method = new CodeMemberMethod { |
||||
Name = this.Name, |
||||
ReturnType = returnType |
||||
}; |
||||
|
||||
if (returnType == null) { |
||||
Comment = "FIXME: Unknown return type \"" + RetType.ToString () + "\" for method \"" + Name + "\"";; |
||||
CommentedOut = true; |
||||
method.ReturnType = new CodeTypeReference (typeof (void)); |
||||
} |
||||
|
||||
if (IsVirtual) method.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (VirtualAttribute).Name)); |
||||
if (IsConstructor) method.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (ConstructorAttribute).Name)); |
||||
if (IsDestructor) method.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (DestructorAttribute).Name)); |
||||
if (IsConst) method.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (ConstAttribute).Name)); |
||||
|
||||
if (IsStatic) |
||||
method.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (StaticAttribute).Name)); |
||||
else |
||||
method.Parameters.Add (new CodeParameterDeclarationExpression (typeof (CppInstancePtr).Name, "this")); |
||||
|
||||
if (hasMangledInfo) |
||||
method.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (AbiTestAttribute).Name, |
||||
new CodeAttributeArgument (new CodePrimitiveExpression (Mangled.Name)), |
||||
new CodeAttributeArgument ("Abi", new CodeTypeOfExpression (Mangled.Type)))); |
||||
for (int i = 0; i < Parameters.Count; i++) { |
||||
var param = GenerateParameterDeclaration (Parameters [i]); |
||||
string paramStr = Parameters [i].Type.ToString (); |
||||
|
||||
if (param == null) { |
||||
Comment = "FIXME: Unknown parameter type \"" + paramStr + "\" to method \"" + Name + "\""; |
||||
CommentedOut = true; |
||||
method.Parameters.Add (new CodeParameterDeclarationExpression (paramStr, Parameters [i].Name)); |
||||
continue; |
||||
} |
||||
|
||||
// FIXME: Only add MangleAs attribute if the managed type chosen would mangle differently by default
|
||||
if (!IsVirtual && !paramStr.Equals (string.Empty)) |
||||
param.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (MangleAsAttribute).Name, new CodeAttributeArgument (new CodePrimitiveExpression (paramStr)))); |
||||
|
||||
method.Parameters.Add (param); |
||||
} |
||||
|
||||
return method; |
||||
} |
||||
|
||||
private CodeMemberMethod CreateWrapperMethod () |
||||
{ |
||||
CodeMemberMethod method; |
||||
|
||||
if (IsConstructor) { |
||||
var ctor = new CodeConstructor { |
||||
Name = FormattedName, |
||||
Attributes = MemberAttributes.Public |
||||
}; |
||||
if (Klass.Bases.Count > 0) { |
||||
var typeInfo = new CodeFieldReferenceExpression (new CodeFieldReferenceExpression { FieldName = "impl" }, "TypeInfo"); |
||||
ctor.BaseConstructorArgs.Add (typeInfo); |
||||
// The first public base class can use the subclass ctor as above, but for the rest, we do this to get the right CppTypeInfo
|
||||
foreach (Class.BaseClass bc in Klass.Bases.Where (b => b.Access == Access.Public).Skip (1)) { |
||||
// FIXME: This won't work if one of the base classes ends up being generic
|
||||
ctor.Statements.Add (new CodeObjectCreateExpression (bc.Name, typeInfo)); |
||||
} |
||||
ctor.Statements.Add (new CodeMethodInvokeExpression (typeInfo, "CompleteType")); |
||||
} |
||||
method = ctor; |
||||
} else if (IsDestructor) |
||||
method = new CodeMemberMethod { |
||||
Name = "Dispose", |
||||
Attributes = MemberAttributes.Public |
||||
}; |
||||
else |
||||
method = new CodeMemberMethod { |
||||
Name = FormattedName, |
||||
Attributes = MemberAttributes.Public, |
||||
ReturnType = ReturnTypeReference |
||||
}; |
||||
|
||||
if (IsStatic) |
||||
method.Attributes |= MemberAttributes.Static; |
||||
else if (!IsVirtual && !IsDestructor) |
||||
// I'm only making methods that are virtual in C++ virtual in managed code.
|
||||
// I think it is the right thing to do because the consumer of the API might not
|
||||
// get the intended effect if the managed method is overridden and the native method is not.
|
||||
method.Attributes |= MemberAttributes.Final; |
||||
else if (IsVirtual && !IsDestructor) |
||||
method.CustomAttributes.Add (new CodeAttributeDeclaration (typeof (OverrideNativeAttribute).Name)); |
||||
|
||||
for (int i = 0; i < Parameters.Count; i++) { |
||||
var param = GenerateParameterDeclaration (Parameters [i]); |
||||
if (param == null) |
||||
return null; |
||||
|
||||
method.Parameters.Add (param); |
||||
} |
||||
|
||||
return method; |
||||
} |
||||
|
||||
public CodeTypeReference ReturnTypeReference { |
||||
get { |
||||
CodeTypeReference returnType; |
||||
|
||||
if (RetType.ElementType == CppTypes.Typename) |
||||
returnType = new CodeTypeReference (RetType.ElementTypeName, CodeTypeReferenceOptions.GenericTypeParameter); |
||||
else { |
||||
Type managedType = RetType.ToManagedType (); |
||||
if (managedType != null && managedType.IsByRef) |
||||
returnType = new CodeTypeReference (typeof (IntPtr)); |
||||
else if (managedType != null && managedType != typeof (ICppObject)) |
||||
returnType = new CodeTypeReference (managedType); |
||||
else |
||||
returnType = RetType.TypeReference (); |
||||
} |
||||
|
||||
return returnType; |
||||
} |
||||
} |
||||
|
||||
private CodeParameterDeclarationExpression GenerateParameterDeclaration (NameTypePair<CppType> param) |
||||
{ |
||||
CodeParameterDeclarationExpression paramDecl; |
||||
|
||||
if (param.Type.ElementType == CppTypes.Typename) |
||||
paramDecl = new CodeParameterDeclarationExpression (param.Type.ElementTypeName, param.Name); |
||||
|
||||
else { |
||||
Type managedType = param.Type.ToManagedType (); |
||||
CodeTypeReference typeRef = param.Type.TypeReference (); |
||||
|
||||
if (managedType != null && managedType.IsByRef) |
||||
paramDecl = new CodeParameterDeclarationExpression (managedType.GetElementType (), param.Name) { Direction = FieldDirection.Ref }; |
||||
|
||||
else if (managedType != null && managedType != typeof (ICppObject)) |
||||
paramDecl = new CodeParameterDeclarationExpression (managedType, param.Name); |
||||
|
||||
else if (typeRef != null) |
||||
paramDecl = new CodeParameterDeclarationExpression (typeRef, param.Name); |
||||
|
||||
else |
||||
return null; |
||||
|
||||
} |
||||
|
||||
return paramDecl; |
||||
} |
||||
|
||||
public string FormattedName { |
||||
get { |
||||
if (formatted_name == null) { |
||||
string upper = Name.ToUpper (); |
||||
StringBuilder sb = new StringBuilder (Name.Length); |
||||
|
||||
for (int i = 0; i < Name.Length; i++) { |
||||
if (i == 0) |
||||
sb.Append (upper [0]); |
||||
else if (Name [i] == '_') |
||||
sb.Append (upper [++i]); |
||||
else |
||||
sb.Append (Name [i]); |
||||
} |
||||
formatted_name = sb.ToString (); |
||||
if (formatted_name == Klass.Name) |
||||
formatted_name += "1"; |
||||
} |
||||
return formatted_name; |
||||
} |
||||
set { |
||||
formatted_name = value; |
||||
} |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
throw new NotImplementedException (); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.CodeDom; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
public class Namespace : CodeContainer { |
||||
|
||||
public Namespace (string name) |
||||
{ |
||||
Name = name; |
||||
} |
||||
|
||||
internal protected override object InsideCodeCompileUnit (CodeCompileUnit ccu) |
||||
{ |
||||
CreateNamespace (ccu, Name); |
||||
return null; |
||||
} |
||||
|
||||
internal protected override object InsideCodeNamespace (CodeNamespace ns) |
||||
{ |
||||
CodeCompileUnit ccu = ns.UserData ["CodeCompileUnit"] as CodeCompileUnit; |
||||
if (ccu == null) |
||||
throw new NotSupportedException ("Invalid CodeNamespace"); |
||||
|
||||
CreateNamespace (ccu, ns.Name + "." + Name); |
||||
return null; |
||||
} |
||||
|
||||
private void CreateNamespace (CodeCompileUnit ccu, string name) |
||||
{ |
||||
CodeNamespace ns = new CodeNamespace (name); |
||||
ns.Imports.Add (new CodeNamespaceImport ("System")); |
||||
ns.Imports.Add (new CodeNamespaceImport ("System.Runtime.InteropServices")); |
||||
ns.Imports.Add (new CodeNamespaceImport ("Mono.VisualC.Interop")); |
||||
|
||||
ns.UserData ["CodeCompileUnit"] = ccu; |
||||
|
||||
foreach (var atom in Atoms) |
||||
atom.Visit (ns); |
||||
|
||||
ccu.Namespaces.Add (ns); |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
writer.WriteLine ("namespace {0} {{", Name); |
||||
base.Write (writer); |
||||
writer.WriteLine ("}"); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,81 +0,0 @@
@@ -1,81 +0,0 @@
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Linq; |
||||
using System.IO; |
||||
|
||||
using System.CodeDom; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
|
||||
// FIXME: support conditional compilation
|
||||
public class PoundDefine<T> : CodeAtom { |
||||
public string Name {get; set;} |
||||
public T Value {get; set;} |
||||
private bool value_set = false; |
||||
|
||||
public PoundDefine(string name) { |
||||
Name = name; |
||||
} |
||||
public PoundDefine (string name, T value) { |
||||
Name = name; |
||||
Value = value; |
||||
value_set = true; |
||||
} |
||||
public override void Write (TextWriter writer) { |
||||
if (value_set) |
||||
writer.WriteLine ("#define {0} {1}", Name, Value); |
||||
else |
||||
writer.WriteLine ("#define {0}", Name); |
||||
} |
||||
|
||||
internal protected override object InsideCodeNamespace (CodeNamespace ns) |
||||
{ |
||||
if (!value_set) |
||||
return null; |
||||
|
||||
// create a new type Constants if it does not exist
|
||||
CodeTypeDeclaration constants = (from type in ns.Types.Cast<CodeTypeDeclaration> () |
||||
where type.Name.Equals ("Constants") select type).SingleOrDefault (); |
||||
if (constants == null) { |
||||
constants = new CodeTypeDeclaration ("Constants"); |
||||
constants.TypeAttributes = TypeAttributes.Public | TypeAttributes.Sealed; |
||||
ns.Types.Add (constants); |
||||
} |
||||
|
||||
return constants; |
||||
} |
||||
|
||||
internal protected override object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
if (!value_set) |
||||
return null; |
||||
|
||||
var constant = new CodeMemberField (typeof (T), Name); |
||||
constant.Attributes = MemberAttributes.Public | MemberAttributes.Const; |
||||
constant.InitExpression = new CodePrimitiveExpression (Value); |
||||
decl.Members.Add (constant); |
||||
|
||||
return constant; |
||||
} |
||||
} |
||||
|
||||
public class PoundIfDef : CodeContainer { |
||||
public enum Condition { |
||||
Defined, |
||||
NotDefined |
||||
} |
||||
public Condition IfCondition {get; set;} |
||||
public PoundIfDef (Condition condition, string name) { |
||||
IfCondition = condition; |
||||
Name = name; |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) { |
||||
string directive = (IfCondition == Condition.Defined ? "#ifdef {0}" : "#ifndef {0}"); |
||||
writer.WriteLine (directive, Name); |
||||
base.Write (writer); |
||||
writer.WriteLine ("#endif"); |
||||
} |
||||
} |
||||
} |
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.CodeDom; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
public class Property : CodeAtom { |
||||
|
||||
public string Name { get; set; } |
||||
public Method Getter { get; set; } |
||||
public Method Setter { get; set; } |
||||
|
||||
public Property (string name) |
||||
{ |
||||
Name = name; |
||||
} |
||||
|
||||
internal protected override object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
// if getter is omitted, just output the setter like a method
|
||||
if (decl.IsInterface || Getter == null) { |
||||
if (Getter != null) |
||||
Getter.Visit (decl); |
||||
if (Setter != null) |
||||
Setter.Visit (decl); |
||||
return null; |
||||
} else if (!decl.IsClass) |
||||
return null; |
||||
|
||||
var prop = new CodeMemberProperty { |
||||
Name = this.Name, |
||||
// FIXME: For now, no properties will be virtual... change this at some point?
|
||||
Attributes = MemberAttributes.Public | MemberAttributes.Final, |
||||
Type = Getter.ReturnTypeReference |
||||
}; |
||||
|
||||
Getter.Visit (prop.GetStatements); |
||||
|
||||
if (Setter != null) |
||||
Setter.Visit (prop.SetStatements); |
||||
|
||||
decl.Members.Add (prop); |
||||
return prop; |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
throw new NotImplementedException (); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,62 +0,0 @@
@@ -1,62 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.CodeDom; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
namespace Mono.VisualC.Code.Atoms { |
||||
|
||||
public class Union : CodeContainer { |
||||
|
||||
public Union (string name) |
||||
{ |
||||
Name = name; |
||||
} |
||||
|
||||
public CodeTypeDeclaration CreateUnionType () |
||||
{ |
||||
var union = new CodeTypeDeclaration (Name) { |
||||
Attributes = MemberAttributes.Public, |
||||
TypeAttributes = TypeAttributes.Public, |
||||
IsStruct = true |
||||
}; |
||||
// var explicitLayout = new CodeAttributeArgument (new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (typeof (short)), (short)LayoutKind.Explicit));
|
||||
union.CustomAttributes.Add (new CodeAttributeDeclaration (new CodeTypeReference (typeof (StructLayoutAttribute)), new CodeAttributeArgument (new CodePrimitiveExpression ((short)LayoutKind.Explicit)))); |
||||
|
||||
foreach (var atom in Atoms) { |
||||
Field field = atom as Field; |
||||
if (field == null) |
||||
throw new Exception ("Only Fields allowed in Union."); |
||||
|
||||
CodeMemberField cmf = field.InsideCodeTypeDeclaration (union) as CodeMemberField; |
||||
if (cmf != null) |
||||
cmf.CustomAttributes.Add (new CodeAttributeDeclaration (new CodeTypeReference (typeof (FieldOffsetAttribute)), new CodeAttributeArgument (new CodePrimitiveExpression (0)))); |
||||
} |
||||
|
||||
return union; |
||||
} |
||||
|
||||
internal protected override object InsideCodeNamespace (CodeNamespace ns) |
||||
{ |
||||
ns.Types.Add (CreateUnionType ()); |
||||
return null; |
||||
} |
||||
|
||||
internal protected override object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
if (!decl.IsClass) |
||||
return null; |
||||
|
||||
decl.Members.Add (CreateUnionType ()); |
||||
return null; |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
writer.WriteLine ("union {0} {{", Name); |
||||
base.Write (writer); |
||||
writer.WriteLine ("}"); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
using System; |
||||
using System.Linq; |
||||
using System.IO; |
||||
using System.Collections.Generic; |
||||
|
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
|
||||
namespace Mono.VisualC.Code { |
||||
|
||||
public abstract class CodeAtom { |
||||
|
||||
public string Comment { get; set; } |
||||
public bool CommentedOut { get; set; } |
||||
|
||||
[ThreadStatic] |
||||
protected static CodeDomProvider current_code_provider; |
||||
|
||||
internal protected virtual void Visit (object obj) |
||||
{ |
||||
object result = obj; |
||||
|
||||
while (result != null) { |
||||
if (result is CodeCompileUnit) { result = InsideCodeCompileUnit (result as CodeCompileUnit); continue; } |
||||
if (result is CodeNamespace) { result = InsideCodeNamespace (result as CodeNamespace); continue; } |
||||
if (result is CodeTypeDeclaration) { result = InsideCodeTypeDeclaration (result as CodeTypeDeclaration); continue; } |
||||
if (result is CodeMemberMethod) { result = InsideCodeStatementCollection (((CodeMemberMethod)result).Statements); continue; } |
||||
if (result is CodeStatementCollection) { result = InsideCodeStatementCollection (result as CodeStatementCollection); continue; } |
||||
break; |
||||
} |
||||
} |
||||
|
||||
internal protected virtual object InsideCodeCompileUnit (CodeCompileUnit ccu) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
internal protected virtual object InsideCodeNamespace (CodeNamespace ns) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
internal protected virtual object InsideCodeTypeDeclaration (CodeTypeDeclaration decl) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
internal protected virtual object InsideCodeStatementCollection (CodeStatementCollection stmts) |
||||
{ |
||||
return null; |
||||
} |
||||
public abstract void Write (TextWriter writer); |
||||
} |
||||
} |
||||
|
@ -1,57 +0,0 @@
@@ -1,57 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Collections.Generic; |
||||
|
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
|
||||
using Mono.VisualC.Code.Atoms; |
||||
|
||||
namespace Mono.VisualC.Code { |
||||
|
||||
public abstract class CodeContainer : CodeAtom { |
||||
|
||||
private LinkedList<CodeAtom> containedAtoms; |
||||
public string IndentString {get; set;} |
||||
public string Name { get; set; } |
||||
|
||||
public CodeContainer (string indentString) |
||||
{ |
||||
containedAtoms = new LinkedList<CodeAtom> (); |
||||
IndentString = indentString; |
||||
} |
||||
|
||||
public CodeContainer() : this("\t") |
||||
{ |
||||
} |
||||
|
||||
public virtual LinkedList<CodeAtom> Atoms { |
||||
get { return containedAtoms; } |
||||
} |
||||
|
||||
|
||||
// Convenience method
|
||||
public virtual void AddToNamespace (string name, CodeAtom atom) |
||||
{ |
||||
Namespace ns = Atoms.OfType<Namespace> ().Where (n => n.Name == name).SingleOrDefault (); |
||||
if (ns == null) { |
||||
ns = new Namespace (name); |
||||
Atoms.AddLast (ns); |
||||
} |
||||
|
||||
ns.Atoms.AddLast (atom); |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
IndentedTextWriter itw = new IndentedTextWriter (writer, IndentString); |
||||
itw.Indent = 1; |
||||
foreach (CodeAtom atom in containedAtoms) { |
||||
atom.Write (itw); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
@ -1,77 +0,0 @@
@@ -1,77 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
|
||||
using Mono.VisualC.Interop; |
||||
|
||||
namespace Mono.VisualC.Code { |
||||
|
||||
internal delegate void CodeGenMethod<T> (T codeObject, TextWriter writer, CodeGeneratorOptions cgo); |
||||
public static class CodeDomExtensions { |
||||
|
||||
public static CodeComment CommentOut (this CodeTypeMember code, CodeDomProvider provider) |
||||
{ |
||||
// FIXME: Not implemented in mono
|
||||
try { |
||||
return CommentOut (provider.GenerateCodeFromMember, code); |
||||
} catch (NotImplementedException) {} |
||||
|
||||
return new CodeComment (); |
||||
} |
||||
public static CodeComment CommentOut (this CodeStatement code, CodeDomProvider provider) |
||||
{ |
||||
return CommentOut (provider.GenerateCodeFromStatement, code); |
||||
} |
||||
public static CodeComment CommentOut (this CodeExpression code, CodeDomProvider provider) |
||||
{ |
||||
return CommentOut (provider.GenerateCodeFromExpression, code); |
||||
} |
||||
|
||||
private static CodeComment CommentOut<T> (CodeGenMethod<T> method, T codeObject) |
||||
{ |
||||
StringWriter output = new StringWriter (); |
||||
CodeGeneratorOptions opts = new CodeGeneratorOptions (); |
||||
|
||||
method (codeObject, output, opts); |
||||
|
||||
return new CodeComment (output.ToString ()); |
||||
} |
||||
|
||||
public static CodeTypeReference TypeReference (this CodeTypeDeclaration ctd) |
||||
{ |
||||
return new CodeTypeReference (ctd.Name, ctd.TypeParameterReferences ()); |
||||
} |
||||
|
||||
public static CodeTypeReference TypeReference (this CppType t) |
||||
{ |
||||
return t.TypeReference (false); |
||||
} |
||||
|
||||
public static CodeTypeReference TypeReference (this CppType t, bool useManagedType) |
||||
{ |
||||
var tempParm = from m in t.Modifiers.OfType<CppModifiers.TemplateModifier> () |
||||
from p in m.Types |
||||
select p.TypeReference (true); |
||||
|
||||
Type managedType = useManagedType && (t.ElementType != CppTypes.Typename)? t.ToManagedType () : null; |
||||
|
||||
if ((managedType == null || managedType == typeof (ICppObject)) && t.ElementTypeName != null) { |
||||
string qualifiedName = t.Namespaces != null? string.Join (".", t.Namespaces) + "." + t.ElementTypeName : t.ElementTypeName; |
||||
return new CodeTypeReference (qualifiedName, tempParm.ToArray ()); |
||||
} else if (managedType != null) |
||||
return new CodeTypeReference (managedType.FullName, tempParm.ToArray ()); |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public static CodeTypeReference [] TypeParameterReferences (this CodeTypeDeclaration ctd) |
||||
{ |
||||
return ctd.TypeParameters.Cast<CodeTypeParameter> ().Select (p => new CodeTypeReference (p)).ToArray (); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
@ -1,79 +0,0 @@
@@ -1,79 +0,0 @@
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Collections.Generic; |
||||
|
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
|
||||
namespace Mono.VisualC.Code { |
||||
public class CodeUnit : CodeContainer { |
||||
|
||||
public string ManagedNamespace { get; set; } |
||||
|
||||
public CodeUnit () : base (string.Empty) |
||||
{ |
||||
} |
||||
|
||||
public virtual CodeCompileUnit WrapperToCodeDom (CodeDomProvider provider) |
||||
{ |
||||
CodeCompileUnit ccu = new CodeCompileUnit (); |
||||
ccu.UserData ["CodeAtom"] = this; |
||||
|
||||
current_code_provider = provider; |
||||
Visit (ccu); |
||||
current_code_provider = null; |
||||
|
||||
return ccu; |
||||
} |
||||
|
||||
internal protected override object InsideCodeCompileUnit (CodeCompileUnit ccu) |
||||
{ |
||||
CodeNamespace ns = new CodeNamespace (ManagedNamespace); |
||||
ns.Imports.Add (new CodeNamespaceImport ("System")); |
||||
ns.Imports.Add (new CodeNamespaceImport ("System.Runtime.InteropServices")); |
||||
ns.Imports.Add (new CodeNamespaceImport ("Mono.VisualC.Interop")); |
||||
|
||||
ns.UserData ["CodeCompileUnit"] = ccu; |
||||
|
||||
ccu.Namespaces.Add (ns); |
||||
return ns; |
||||
} |
||||
|
||||
internal protected override object InsideCodeNamespace (CodeNamespace ns) |
||||
{ |
||||
foreach (var atom in Atoms) |
||||
atom.Visit (ns); |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public override string ToString () |
||||
{ |
||||
StringWriter str = new StringWriter (); |
||||
Write (str); |
||||
return str.ToString (); |
||||
} |
||||
|
||||
public override void Write (TextWriter writer) |
||||
{ |
||||
writer.WriteLine ("//------------------------------------------------------------------------------"); |
||||
writer.WriteLine ("// <auto-generated>"); |
||||
writer.WriteLine ("// This code was generated by a tool."); |
||||
writer.WriteLine ("// Runtime Version:{0}{1}//", Environment.Version, writer.NewLine); |
||||
writer.WriteLine ("// Changes to this file may cause incorrect behavior and will be lost if"); |
||||
writer.WriteLine ("// the code is regenerated."); |
||||
writer.WriteLine ("// </auto-generated>"); |
||||
writer.WriteLine ("//------------------------------------------------------------------------------{0}", writer.NewLine); |
||||
|
||||
base.Write (writer); |
||||
} |
||||
|
||||
public virtual void Save (string fileName) |
||||
{ |
||||
using (StreamWriter stream = File.CreateText (fileName)) { |
||||
Write (stream); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,100 +0,0 @@
@@ -1,100 +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)/Mono.VisualC.Code.dll |
||||
ASSEMBLY_MDB = $(ASSEMBLY).mdb |
||||
|
||||
MONO_VISUALC_INTEROP_DLL_SOURCE=$(BUILD_DIR)/Mono.VisualC.Interop.dll |
||||
MONO_VISUALC_INTEROP_DLL=$(BUILD_DIR)/Mono.VisualC.Interop.dll |
||||
MONO_VISUALC_CODE_DLL_MDB_SOURCE=$(BUILD_DIR)/Mono.VisualC.Code.dll.mdb |
||||
MONO_VISUALC_CODE_DLL_MDB=$(BUILD_DIR)/Mono.VisualC.Code.dll.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)/Mono.VisualC.Code.dll |
||||
ASSEMBLY_MDB = |
||||
|
||||
MONO_VISUALC_INTEROP_DLL_SOURCE=$(BUILD_DIR)/Mono.VisualC.Interop.dll |
||||
MONO_VISUALC_INTEROP_DLL=$(BUILD_DIR)/Mono.VisualC.Interop.dll |
||||
MONO_VISUALC_CODE_DLL_MDB= |
||||
|
||||
endif |
||||
|
||||
COMPILE_TARGET = library |
||||
|
||||
AL=al2 |
||||
SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll |
||||
|
||||
PROGRAMFILES = \
|
||||
$(MONO_VISUALC_INTEROP_DLL) \
|
||||
$(MONO_VISUALC_CODE_DLL_MDB) |
||||
|
||||
LINUX_PKGCONFIG = \
|
||||
$(MONO_VISUALC_CODE_PC) |
||||
|
||||
|
||||
RESGEN=resgen2 |
||||
|
||||
all: $(ASSEMBLY) $(PROGRAMFILES) $(LINUX_PKGCONFIG) |
||||
|
||||
FILES = \
|
||||
Access.cs \
|
||||
AssemblyInfo.cs \
|
||||
Atoms/Class.cs \
|
||||
Atoms/Enumeration.cs \
|
||||
Atoms/Field.cs \
|
||||
Atoms/Method.cs \
|
||||
Atoms/Namespace.cs \
|
||||
Atoms/Preprocessor.cs \
|
||||
Atoms/Property.cs \
|
||||
Atoms/Union.cs \
|
||||
CodeAtom.cs \
|
||||
CodeContainer.cs \
|
||||
CodeDomExtensions.cs \
|
||||
CodeUnit.cs \
|
||||
NameTypePair.cs |
||||
|
||||
DATA_FILES = |
||||
|
||||
RESOURCES = |
||||
|
||||
EXTRAS = \
|
||||
Atoms \
|
||||
mono.visualc.code.pc.in |
||||
|
||||
REFERENCES = \
|
||||
../../bin/Debug/Mono.VisualC.Interop.dll \
|
||||
System \
|
||||
System.Core |
||||
|
||||
DLL_REFERENCES = |
||||
|
||||
CLEANFILES = $(PROGRAMFILES) $(LINUX_PKGCONFIG) |
||||
|
||||
include $(top_srcdir)/Makefile.include |
||||
|
||||
MONO_VISUALC_CODE_PC = $(BUILD_DIR)/mono.visualc.code.pc |
||||
|
||||
$(eval $(call emit-deploy-target,MONO_VISUALC_INTEROP_DLL)) |
||||
$(eval $(call emit-deploy-wrapper,MONO_VISUALC_CODE_PC,mono.visualc.code.pc)) |
||||
|
||||
|
||||
$(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,112 +0,0 @@
@@ -1,112 +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>{A22BF9D9-BBCB-4462-BE08-0F4D5280B180}</ProjectGuid> |
||||
<OutputType>Library</OutputType> |
||||
<AssemblyName>Mono.VisualC.Code</AssemblyName> |
||||
<RootNamespace>Mono.VisualC.Code</RootNamespace> |
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
<FileUpgradeFlags> |
||||
</FileUpgradeFlags> |
||||
<UpgradeBackupLocation> |
||||
</UpgradeBackupLocation> |
||||
<OldToolsVersion>2.0</OldToolsVersion> |
||||
<PublishUrl>http://localhost/Mono.VisualC.Code/</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> |
||||
</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> |
||||
<ConsolePause>false</ConsolePause> |
||||
<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> |
||||
<ConsolePause>false</ConsolePause> |
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core" /> |
||||
<Reference Include="Mono.VisualC.Interop, Version=1.0.4164.32915, Culture=neutral, PublicKeyToken=null"> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<HintPath>..\..\bin\Debug\Mono.VisualC.Interop.dll</HintPath> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
<Compile Include="CodeAtom.cs" /> |
||||
<Compile Include="Atoms\Preprocessor.cs" /> |
||||
<Compile Include="CodeContainer.cs" /> |
||||
<Compile Include="Atoms\Class.cs" /> |
||||
<Compile Include="CodeUnit.cs" /> |
||||
<Compile Include="Access.cs" /> |
||||
<Compile Include="Atoms\Method.cs" /> |
||||
<Compile Include="Atoms\Enumeration.cs" /> |
||||
<Compile Include="CodeDomExtensions.cs" /> |
||||
<Compile Include="Atoms\Property.cs" /> |
||||
<Compile Include="Atoms\Field.cs" /> |
||||
<Compile Include="Atoms\Union.cs" /> |
||||
<Compile Include="NameTypePair.cs" /> |
||||
<Compile Include="Atoms\Namespace.cs" /> |
||||
</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> |
||||
</Project> |
@ -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}") = "Mono.VisualC.Code", "Mono.VisualC.Code.csproj", "{A22BF9D9-BBCB-4462-BE08-0F4D5280B180}" |
||||
EndProject |
||||
Global |
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
Debug|Any CPU = Debug|Any CPU |
||||
Release|Any CPU = Release|Any CPU |
||||
EndGlobalSection |
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
{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 |
||||
{A22BF9D9-BBCB-4462-BE08-0F4D5280B180}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
EndGlobalSection |
||||
GlobalSection(MonoDevelopProperties) = preSolution |
||||
StartupItem = Mono.VisualC.Code.csproj |
||||
EndGlobalSection |
||||
EndGlobal |
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
using System; |
||||
namespace Mono.VisualC.Code { |
||||
|
||||
public struct NameTypePair<TType> { |
||||
public string Name; |
||||
public TType Type; |
||||
} |
||||
} |
||||
|
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
Name: Mono.VisualC.Code |
||||
Description: Mono.VisualC.Code |
||||
Version: 0.1 |
||||
|
||||
Requires: |
||||
Libs: -r:@expanded_libdir@/@PACKAGE@/Mono.VisualC.Code.dll |
Loading…
Reference in new issue