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 @@ -87,6 +87,22 @@ namespace CppSharp.AST
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>
/// Does this class provide its own virtual-function table
/// pointer, rather than inheriting one from a primary base

30
src/AST/Declaration.cs

@ -55,7 +55,11 @@ namespace CppSharp.AST @@ -55,7 +55,11 @@ namespace CppSharp.AST
}
private string name;
public virtual string OriginalName { get; set;}
public virtual string OriginalName
{
get { return originalName; }
set { originalName = value; }
}
// Name of the declaration.
public virtual string Name
@ -194,6 +198,7 @@ namespace CppSharp.AST @@ -194,6 +198,7 @@ namespace CppSharp.AST
// Pointer to the original declaration from Clang.
public IntPtr OriginalPtr;
private string originalName;
protected Declaration()
{
@ -205,7 +210,28 @@ namespace CppSharp.AST @@ -205,7 +210,28 @@ namespace CppSharp.AST
protected Declaration(string name)
: 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()

17
src/AST/Function.cs

@ -76,6 +76,23 @@ namespace CppSharp.AST @@ -76,6 +76,23 @@ namespace CppSharp.AST
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 bool IsReturnIndirect { get; set; }

20
src/AST/Method.cs

@ -67,13 +67,31 @@ namespace CppSharp.AST @@ -67,13 +67,31 @@ namespace CppSharp.AST
/// <summary>
/// Represents a C++ record method declaration.
/// </summary>
public class Method : Function, ITypedDecl
public class Method : Function
{
public Method()
{
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 bool IsVirtual { get; set; }

4
src/Generator/AST/Utils.cs

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

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

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

Loading…
Cancel
Save