Browse Source

Merge pull request #51 from ddobrev/master

Generated abstract methods.
pull/52/merge
João Matos 12 years ago
parent
commit
8e6cf14a37
  1. 16
      src/AST/ClassLayout.cs
  2. 30
      src/AST/Declaration.cs
  3. 17
      src/AST/Function.cs
  4. 20
      src/AST/Method.cs
  5. 4
      src/Generator/AST/Utils.cs
  6. 1
      src/Generator/Generators/CSharp/CSharpMarshal.cs

16
src/AST/ClassLayout.cs

@ -87,6 +87,22 @@ namespace CppSharp.AST
VFTables = new List<VFTableInfo>(); VFTables = new List<VFTableInfo>();
} }
public ClassLayout(ClassLayout classLayout)
: this()
{
ABI = classLayout.ABI;
HasOwnVFPtr = classLayout.HasOwnVFPtr;
VBPtrOffset = classLayout.VBPtrOffset;
PrimaryBase = classLayout.PrimaryBase;
HasVirtualBases = classLayout.HasVirtualBases;
Alignment = classLayout.Alignment;
Size = classLayout.Size;
DataSize = classLayout.DataSize;
VFTables.AddRange(classLayout.VFTables);
Layout = new VTableLayout();
Layout.Components.AddRange(classLayout.Layout.Components);
}
/// <summary> /// <summary>
/// Does this class provide its own virtual-function table /// Does this class provide its own virtual-function table
/// pointer, rather than inheriting one from a primary base /// pointer, rather than inheriting one from a primary base

30
src/AST/Declaration.cs

@ -55,7 +55,11 @@ namespace CppSharp.AST
} }
private string name; private string name;
public virtual string OriginalName { get; set;} public virtual string OriginalName
{
get { return originalName; }
set { originalName = value; }
}
// Name of the declaration. // Name of the declaration.
public virtual string Name public virtual string Name
@ -194,6 +198,7 @@ namespace CppSharp.AST
// Pointer to the original declaration from Clang. // Pointer to the original declaration from Clang.
public IntPtr OriginalPtr; public IntPtr OriginalPtr;
private string originalName;
protected Declaration() protected Declaration()
{ {
@ -205,7 +210,28 @@ namespace CppSharp.AST
protected Declaration(string name) protected Declaration(string name)
: this() : this()
{ {
Name = name; this.name = name;
}
protected Declaration(Declaration declaration)
: this()
{
Namespace = declaration.Namespace;
originalName = declaration.OriginalName;
name = declaration.Name;
Comment = declaration.Comment;
IgnoreFlags = declaration.IgnoreFlags;
Access = declaration.Access;
DebugText = declaration.DebugText;
IsIncomplete = declaration.IsIncomplete;
IsDependent = declaration.IsDependent;
CompleteDeclaration = declaration.CompleteDeclaration;
DefinitionOrder = declaration.DefinitionOrder;
ExcludeFromPasses = new HashSet<System.Type>(
declaration.ExcludeFromPasses);
PreprocessedEntities = new List<PreprocessedEntity>(
declaration.PreprocessedEntities);
OriginalPtr = declaration.OriginalPtr;
} }
public override string ToString() public override string ToString()

17
src/AST/Function.cs

@ -76,6 +76,23 @@ namespace CppSharp.AST
IsInline = false; IsInline = false;
} }
public Function(Function function)
: base(function)
{
Parameters = new List<Parameter>();
ReturnType = function.ReturnType;
IsReturnIndirect = function.IsReturnIndirect;
Parameters.AddRange(function.Parameters);
IsVariadic = function.IsVariadic;
IsInline = function.IsInline;
IsPure = function.IsPure;
OperatorKind = function.OperatorKind;
CallingConvention = function.CallingConvention;
SynthKind = function.SynthKind;
OriginalFunction = function.OriginalFunction;
Mangled = function.Mangled;
}
public QualifiedType ReturnType { get; set; } public QualifiedType ReturnType { get; set; }
public bool IsReturnIndirect { get; set; } public bool IsReturnIndirect { get; set; }

20
src/AST/Method.cs

@ -67,13 +67,31 @@ namespace CppSharp.AST
/// <summary> /// <summary>
/// Represents a C++ record method declaration. /// Represents a C++ record method declaration.
/// </summary> /// </summary>
public class Method : Function, ITypedDecl public class Method : Function
{ {
public Method() public Method()
{ {
Access = AccessSpecifier.Public; Access = AccessSpecifier.Public;
} }
public Method(Method method)
: base(method)
{
Access = method.Access;
AccessDecl = method.AccessDecl;
IsVirtual = method.IsVirtual;
IsConst = method.IsConst;
IsImplicit = method.IsImplicit;
IsSynthetized = method.IsSynthetized;
IsOverride = method.IsOverride;
IsProxy = method.IsProxy;
Kind = method.Kind;
IsDefaultConstructor = method.IsDefaultConstructor;
IsCopyConstructor = method.IsCopyConstructor;
IsMoveConstructor = method.IsMoveConstructor;
Conversion = method.Conversion;
}
public AccessSpecifierDecl AccessDecl { get; set; } public AccessSpecifierDecl AccessDecl { get; set; }
public bool IsVirtual { get; set; } public bool IsVirtual { get; set; }

4
src/Generator/AST/Utils.cs

@ -37,7 +37,7 @@ namespace CppSharp.AST
if (method.Kind == CXXMethodKind.Conversion) if (method.Kind == CXXMethodKind.Conversion)
return true; return true;
if (method.Access != AccessSpecifier.Public) if (method.Access == AccessSpecifier.Private)
return true; return true;
return false; return false;
@ -45,7 +45,7 @@ namespace CppSharp.AST
public static bool CheckIgnoreField(Field field) public static bool CheckIgnoreField(Field field)
{ {
if (field.Access != AccessSpecifier.Public) if (field.Access == AccessSpecifier.Private)
return true; return true;
return field.Ignore; return field.Ignore;

1
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -243,6 +243,7 @@ namespace CppSharp.Generators.CSharp
} }
else else
{ {
instance = instance.Trim('*');
Context.SupportBefore.WriteLine( Context.SupportBefore.WriteLine(
"CppSharp.Runtime.Helpers.memcpy({0}, new IntPtr(&{1}), new UIntPtr({2}));", "CppSharp.Runtime.Helpers.memcpy({0}, new IntPtr(&{1}), new UIntPtr({2}));",
instanceName, instance, @class.Layout.Size); instanceName, instance, @class.Layout.Size);

Loading…
Cancel
Save