Skip to content

Commit

Permalink
Added to a method a list of its overridden methods.
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information
ddobrev committed Jul 27, 2017
1 parent cf98ecd commit e2e4109
Show file tree
Hide file tree
Showing 13 changed files with 456 additions and 146 deletions.
15 changes: 13 additions & 2 deletions src/AST/Method.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using CppSharp.AST.Extensions; using CppSharp.AST.Extensions;


namespace CppSharp.AST namespace CppSharp.AST
Expand Down Expand Up @@ -103,6 +105,7 @@ public Method(Method method)
Conversion = method.Conversion; Conversion = method.Conversion;
SynthKind = method.SynthKind; SynthKind = method.SynthKind;
AdjustedOffset = method.AdjustedOffset; AdjustedOffset = method.AdjustedOffset;
OverriddenMethods.AddRange(method.OverriddenMethods);
} }


public Method(Function function) public Method(Function function)
Expand All @@ -115,9 +118,13 @@ public Method(Function function)
public bool IsStatic { get; set; } public bool IsStatic { get; set; }
public bool IsConst { get; set; } public bool IsConst { get; set; }
public bool IsExplicit { get; set; } public bool IsExplicit { get; set; }
public bool IsOverride { get; set; } public bool IsOverride
{
get { return isOverride ?? OverriddenMethods.Any(); }
set { isOverride = value; }
}


// True if the method is final / sealed. // True if the method is final / sealed.
public bool IsFinal { get; set; } public bool IsFinal { get; set; }


public bool IsProxy { get; set; } public bool IsProxy { get; set; }
Expand Down Expand Up @@ -161,9 +168,13 @@ public bool IsDestructor


public int AdjustedOffset { get; set; } public int AdjustedOffset { get; set; }


public List<Method> OverriddenMethods { get; } = new List<Method>();

public override T Visit<T>(IDeclVisitor<T> visitor) public override T Visit<T>(IDeclVisitor<T> visitor)
{ {
return visitor.VisitMethodDecl(this); return visitor.VisitMethodDecl(this);
} }

private bool? isOverride;
} }
} }
3 changes: 2 additions & 1 deletion src/CppParser/AST.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -650,7 +650,6 @@ Method::Method()
, isStatic(false) , isStatic(false)
, isConst(false) , isConst(false)
, isExplicit(false) , isExplicit(false)
, isOverride(false)
, isDefaultConstructor(false) , isDefaultConstructor(false)
, isCopyConstructor(false) , isCopyConstructor(false)
, isMoveConstructor(false) , isMoveConstructor(false)
Expand All @@ -661,6 +660,8 @@ Method::Method()


Method::~Method() {} Method::~Method() {}


DEF_VECTOR(Method, Method*, OverriddenMethods)

// Enumeration // Enumeration


Enumeration::Enumeration() : DeclarationContext(DeclarationKind::Enumeration), Enumeration::Enumeration() : DeclarationContext(DeclarationKind::Enumeration),
Expand Down
2 changes: 1 addition & 1 deletion src/CppParser/AST.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -762,7 +762,6 @@ class CS_API Method : public Function
bool isStatic; bool isStatic;
bool isConst; bool isConst;
bool isExplicit; bool isExplicit;
bool isOverride;


CXXMethodKind methodKind; CXXMethodKind methodKind;


Expand All @@ -772,6 +771,7 @@ class CS_API Method : public Function


QualifiedType conversionType; QualifiedType conversionType;
RefQualifierKind refQualifier; RefQualifierKind refQualifier;
VECTOR(Method*, OverriddenMethods)
}; };


class CS_API Enumeration : public DeclarationContext class CS_API Enumeration : public DeclarationContext
Expand Down
58 changes: 48 additions & 10 deletions src/CppParser/Bindings/CLI/AST.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3739,6 +3739,26 @@ CppSharp::Parser::AST::Method::Method()
NativePtr = new ::CppSharp::CppParser::AST::Method(); NativePtr = new ::CppSharp::CppParser::AST::Method();
} }


CppSharp::Parser::AST::Method^ CppSharp::Parser::AST::Method::GetOverriddenMethods(unsigned int i)
{
auto __ret = ((::CppSharp::CppParser::AST::Method*)NativePtr)->getOverriddenMethods(i);
if (__ret == nullptr) return nullptr;
return (__ret == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Method((::CppSharp::CppParser::AST::Method*)__ret);
}

void CppSharp::Parser::AST::Method::AddOverriddenMethods(CppSharp::Parser::AST::Method^ s)
{
if (ReferenceEquals(s, nullptr))
throw gcnew ::System::ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
auto __arg0 = (::CppSharp::CppParser::AST::Method*)s->NativePtr;
((::CppSharp::CppParser::AST::Method*)NativePtr)->addOverriddenMethods(__arg0);
}

void CppSharp::Parser::AST::Method::ClearOverriddenMethods()
{
((::CppSharp::CppParser::AST::Method*)NativePtr)->clearOverriddenMethods();
}

CppSharp::Parser::AST::Method::Method(CppSharp::Parser::AST::Method^ _0) CppSharp::Parser::AST::Method::Method(CppSharp::Parser::AST::Method^ _0)
: CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*)nullptr) : CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*)nullptr)
{ {
Expand Down Expand Up @@ -3789,16 +3809,6 @@ void CppSharp::Parser::AST::Method::IsExplicit::set(bool value)
((::CppSharp::CppParser::AST::Method*)NativePtr)->isExplicit = value; ((::CppSharp::CppParser::AST::Method*)NativePtr)->isExplicit = value;
} }


bool CppSharp::Parser::AST::Method::IsOverride::get()
{
return ((::CppSharp::CppParser::AST::Method*)NativePtr)->isOverride;
}

void CppSharp::Parser::AST::Method::IsOverride::set(bool value)
{
((::CppSharp::CppParser::AST::Method*)NativePtr)->isOverride = value;
}

CppSharp::Parser::AST::CXXMethodKind CppSharp::Parser::AST::Method::MethodKind::get() CppSharp::Parser::AST::CXXMethodKind CppSharp::Parser::AST::Method::MethodKind::get()
{ {
return (CppSharp::Parser::AST::CXXMethodKind)((::CppSharp::CppParser::AST::Method*)NativePtr)->methodKind; return (CppSharp::Parser::AST::CXXMethodKind)((::CppSharp::CppParser::AST::Method*)NativePtr)->methodKind;
Expand Down Expand Up @@ -3859,6 +3869,34 @@ void CppSharp::Parser::AST::Method::RefQualifier::set(CppSharp::Parser::AST::Ref
((::CppSharp::CppParser::AST::Method*)NativePtr)->refQualifier = (::CppSharp::CppParser::AST::RefQualifierKind)value; ((::CppSharp::CppParser::AST::Method*)NativePtr)->refQualifier = (::CppSharp::CppParser::AST::RefQualifierKind)value;
} }


System::Collections::Generic::List<CppSharp::Parser::AST::Method^>^ CppSharp::Parser::AST::Method::OverriddenMethods::get()
{
auto _tmp__OverriddenMethods = gcnew System::Collections::Generic::List<CppSharp::Parser::AST::Method^>();
for(auto _element : ((::CppSharp::CppParser::AST::Method*)NativePtr)->OverriddenMethods)
{
auto _marshalElement = (_element == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Method((::CppSharp::CppParser::AST::Method*)_element);
_tmp__OverriddenMethods->Add(_marshalElement);
}
return _tmp__OverriddenMethods;
}

void CppSharp::Parser::AST::Method::OverriddenMethods::set(System::Collections::Generic::List<CppSharp::Parser::AST::Method^>^ value)
{
auto _tmpvalue = std::vector<::CppSharp::CppParser::AST::Method*>();
for each(CppSharp::Parser::AST::Method^ _element in value)
{
auto _marshalElement = (::CppSharp::CppParser::AST::Method*)_element->NativePtr;
_tmpvalue.push_back(_marshalElement);
}
((::CppSharp::CppParser::AST::Method*)NativePtr)->OverriddenMethods = _tmpvalue;
}

unsigned int CppSharp::Parser::AST::Method::OverriddenMethodsCount::get()
{
auto __ret = ((::CppSharp::CppParser::AST::Method*)NativePtr)->getOverriddenMethodsCount();
return __ret;
}

CppSharp::Parser::AST::Enumeration::Item::Item(::CppSharp::CppParser::AST::Enumeration::Item* native) CppSharp::Parser::AST::Enumeration::Item::Item(::CppSharp::CppParser::AST::Enumeration::Item* native)
: CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)native) : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)native)
{ {
Expand Down
23 changes: 17 additions & 6 deletions src/CppParser/Bindings/CLI/AST.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2180,12 +2180,6 @@ namespace CppSharp
void set(bool); void set(bool);
} }


property bool IsOverride
{
bool get();
void set(bool);
}

property CppSharp::Parser::AST::CXXMethodKind MethodKind property CppSharp::Parser::AST::CXXMethodKind MethodKind
{ {
CppSharp::Parser::AST::CXXMethodKind get(); CppSharp::Parser::AST::CXXMethodKind get();
Expand Down Expand Up @@ -2221,6 +2215,23 @@ namespace CppSharp
CppSharp::Parser::AST::RefQualifierKind get(); CppSharp::Parser::AST::RefQualifierKind get();
void set(CppSharp::Parser::AST::RefQualifierKind); void set(CppSharp::Parser::AST::RefQualifierKind);
} }

property System::Collections::Generic::List<CppSharp::Parser::AST::Method^>^ OverriddenMethods
{
System::Collections::Generic::List<CppSharp::Parser::AST::Method^>^ get();
void set(System::Collections::Generic::List<CppSharp::Parser::AST::Method^>^);
}

property unsigned int OverriddenMethodsCount
{
unsigned int get();
}

CppSharp::Parser::AST::Method^ GetOverriddenMethods(unsigned int i);

void AddOverriddenMethods(CppSharp::Parser::AST::Method^ s);

void ClearOverriddenMethods();
}; };


public ref class Enumeration : CppSharp::Parser::AST::DeclarationContext public ref class Enumeration : CppSharp::Parser::AST::DeclarationContext
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7583,7 +7583,7 @@ public uint ParametersCount


public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 352)] [StructLayout(LayoutKind.Explicit, Size = 360)]
public new partial struct __Internal public new partial struct __Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
Expand Down Expand Up @@ -7743,26 +7743,26 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
internal byte isExplicit; internal byte isExplicit;


[FieldOffset(328)] [FieldOffset(328)]
internal byte isOverride;

[FieldOffset(332)]
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind; internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;


[FieldOffset(336)] [FieldOffset(332)]
internal byte isDefaultConstructor; internal byte isDefaultConstructor;


[FieldOffset(337)] [FieldOffset(333)]
internal byte isCopyConstructor; internal byte isCopyConstructor;


[FieldOffset(338)] [FieldOffset(334)]
internal byte isMoveConstructor; internal byte isMoveConstructor;


[FieldOffset(340)] [FieldOffset(336)]
internal global::CppSharp.Parser.AST.QualifiedType.__Internal conversionType; internal global::CppSharp.Parser.AST.QualifiedType.__Internal conversionType;


[FieldOffset(348)] [FieldOffset(344)]
internal global::CppSharp.Parser.AST.RefQualifierKind refQualifier; internal global::CppSharp.Parser.AST.RefQualifierKind refQualifier;


[FieldOffset(348)]
internal global::Std.__1.Vector.__Internal OverriddenMethods;

[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST6MethodC2Ev")] EntryPoint="_ZN8CppSharp9CppParser3AST6MethodC2Ev")]
Expand All @@ -7777,6 +7777,26 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
[DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST6MethodD2Ev")] EntryPoint="_ZN8CppSharp9CppParser3AST6MethodD2Ev")]
internal static extern void dtor(global::System.IntPtr instance); internal static extern void dtor(global::System.IntPtr instance);

[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST6Method20getOverriddenMethodsEj")]
internal static extern global::System.IntPtr GetOverriddenMethods(global::System.IntPtr instance, uint i);

[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST6Method20addOverriddenMethodsERPS2_")]
internal static extern void AddOverriddenMethods(global::System.IntPtr instance, global::System.IntPtr s);

[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST6Method22clearOverriddenMethodsEv")]
internal static extern void ClearOverriddenMethods(global::System.IntPtr instance);

[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST6Method25getOverriddenMethodsCountEv")]
internal static extern uint GetOverriddenMethodsCount(global::System.IntPtr instance);
} }


internal static new global::CppSharp.Parser.AST.Method __CreateInstance(global::System.IntPtr native, bool skipVTables = false) internal static new global::CppSharp.Parser.AST.Method __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
Expand Down Expand Up @@ -7846,6 +7866,30 @@ public override void Dispose(bool disposing)
__Instance = IntPtr.Zero; __Instance = IntPtr.Zero;
} }


public global::CppSharp.Parser.AST.Method GetOverriddenMethods(uint i)
{
var __ret = __Internal.GetOverriddenMethods((__Instance + __PointerAdjustment), i);
global::CppSharp.Parser.AST.Method __result0;
if (__ret == IntPtr.Zero) __result0 = null;
else if (global::CppSharp.Parser.AST.Method.NativeToManagedMap.ContainsKey(__ret))
__result0 = (global::CppSharp.Parser.AST.Method) global::CppSharp.Parser.AST.Method.NativeToManagedMap[__ret];
else __result0 = global::CppSharp.Parser.AST.Method.__CreateInstance(__ret);
return __result0;
}

public void AddOverriddenMethods(global::CppSharp.Parser.AST.Method s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var __arg0 = s.__Instance;
__Internal.AddOverriddenMethods((__Instance + __PointerAdjustment), __arg0);
}

public void ClearOverriddenMethods()
{
__Internal.ClearOverriddenMethods((__Instance + __PointerAdjustment));
}

public bool IsVirtual public bool IsVirtual
{ {
get get
Expand Down Expand Up @@ -7898,19 +7942,6 @@ public bool IsExplicit
} }
} }


public bool IsOverride
{
get
{
return ((global::CppSharp.Parser.AST.Method.__Internal*) __Instance)->isOverride != 0;
}

set
{
((global::CppSharp.Parser.AST.Method.__Internal*) __Instance)->isOverride = (byte) (value ? 1 : 0);
}
}

public global::CppSharp.Parser.AST.CXXMethodKind MethodKind public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
{ {
get get
Expand Down Expand Up @@ -7988,6 +8019,15 @@ public bool IsMoveConstructor
((global::CppSharp.Parser.AST.Method.__Internal*) __Instance)->refQualifier = value; ((global::CppSharp.Parser.AST.Method.__Internal*) __Instance)->refQualifier = value;
} }
} }

public uint OverriddenMethodsCount
{
get
{
var __ret = __Internal.GetOverriddenMethodsCount((__Instance + __PointerAdjustment));
return __ret;
}
}
} }


public unsafe partial class Enumeration : global::CppSharp.Parser.AST.DeclarationContext, IDisposable public unsafe partial class Enumeration : global::CppSharp.Parser.AST.DeclarationContext, IDisposable
Expand Down
Loading

0 comments on commit e2e4109

Please sign in to comment.