Browse Source

Connected the functions in the AST to the template functions they instantiate, if any.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/519/merge
Dimitar Dobrev 9 years ago
parent
commit
192fede3f7
  1. 2
      src/AST/Function.cs
  2. 2
      src/Core/Parser/ASTConverter.cs
  3. 1
      src/CppParser/AST.cpp
  4. 1
      src/CppParser/AST.h
  5. 10
      src/CppParser/Bindings/CLI/AST.cpp
  6. 6
      src/CppParser/Bindings/CLI/AST.h
  7. 58
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs
  8. 58
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs
  9. 58
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs
  10. 58
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs
  11. 58
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs
  12. 2
      src/CppParser/Parser.cpp
  13. 9
      src/Generator.Tests/AST/TestAST.cs

2
src/AST/Function.cs

@ -160,6 +160,8 @@ namespace CppSharp.AST @@ -160,6 +160,8 @@ namespace CppSharp.AST
public FunctionTemplateSpecialization SpecializationInfo { get; set; }
public Function InstantiatedFrom { get; set; }
public bool IsThisCall
{
get { return CallingConvention == CallingConvention.ThisCall; }

2
src/Core/Parser/ASTConverter.cs

@ -987,6 +987,8 @@ namespace CppSharp @@ -987,6 +987,8 @@ namespace CppSharp
_function.Mangled = function.Mangled;
_function.Signature = function.Signature;
_function.CallingConvention = VisitCallingConvention(function.CallingConvention);
if (function.InstantiatedFrom != null)
_function.InstantiatedFrom = (AST.Function) Visit(function.InstantiatedFrom);
for (uint i = 0; i < function.ParametersCount; ++i)
{

1
src/CppParser/AST.cpp

@ -543,6 +543,7 @@ Function::Function() @@ -543,6 +543,7 @@ Function::Function()
: Declaration(DeclarationKind::Function)
, IsReturnIndirect(false)
, SpecializationInfo(0)
, InstantiatedFrom(0)
{
}

1
src/CppParser/AST.h

@ -630,6 +630,7 @@ public: @@ -630,6 +630,7 @@ public:
CppSharp::CppParser::AST::CallingConvention CallingConvention;
VECTOR(Parameter*, Parameters)
FunctionTemplateSpecialization* SpecializationInfo;
Function* InstantiatedFrom;
};
class AccessSpecifierDecl;

10
src/CppParser/Bindings/CLI/AST.cpp

@ -2642,6 +2642,16 @@ void CppSharp::Parser::AST::Function::SpecializationInfo::set(CppSharp::Parser:: @@ -2642,6 +2642,16 @@ void CppSharp::Parser::AST::Function::SpecializationInfo::set(CppSharp::Parser::
((::CppSharp::CppParser::AST::Function*)NativePtr)->SpecializationInfo = (::CppSharp::CppParser::AST::FunctionTemplateSpecialization*)value->NativePtr;
}
CppSharp::Parser::AST::Function^ CppSharp::Parser::AST::Function::InstantiatedFrom::get()
{
return (((::CppSharp::CppParser::AST::Function*)NativePtr)->InstantiatedFrom == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*)((::CppSharp::CppParser::AST::Function*)NativePtr)->InstantiatedFrom);
}
void CppSharp::Parser::AST::Function::InstantiatedFrom::set(CppSharp::Parser::AST::Function^ value)
{
((::CppSharp::CppParser::AST::Function*)NativePtr)->InstantiatedFrom = (::CppSharp::CppParser::AST::Function*)value->NativePtr;
}
CppSharp::Parser::AST::Method::Method(::CppSharp::CppParser::AST::Method* native)
: CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*)native)
{

6
src/CppParser/Bindings/CLI/AST.h

@ -1659,6 +1659,12 @@ namespace CppSharp @@ -1659,6 +1659,12 @@ namespace CppSharp
void set(CppSharp::Parser::AST::FunctionTemplateSpecialization^);
}
property CppSharp::Parser::AST::Function^ InstantiatedFrom
{
CppSharp::Parser::AST::Function^ get();
void set(CppSharp::Parser::AST::Function^);
}
CppSharp::Parser::AST::Parameter^ getParameters(unsigned int i);
void addParameters(CppSharp::Parser::AST::Parameter^ s);

58
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs

@ -5516,7 +5516,7 @@ namespace CppSharp @@ -5516,7 +5516,7 @@ namespace CppSharp
public unsafe partial class Function : CppSharp.Parser.AST.Declaration, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 156)]
[StructLayout(LayoutKind.Explicit, Size = 160)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5588,6 +5588,9 @@ namespace CppSharp @@ -5588,6 +5588,9 @@ namespace CppSharp
[FieldOffset(152)]
public global::System.IntPtr SpecializationInfo;
[FieldOffset(156)]
public global::System.IntPtr InstantiatedFrom;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST8FunctionC2Ev")]
@ -5656,7 +5659,7 @@ namespace CppSharp @@ -5656,7 +5659,7 @@ namespace CppSharp
private static void* __CopyValue(Function.Internal native)
{
var ret = Marshal.AllocHGlobal(156);
var ret = Marshal.AllocHGlobal(160);
CppSharp.Parser.AST.Function.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -5680,7 +5683,7 @@ namespace CppSharp @@ -5680,7 +5683,7 @@ namespace CppSharp
public Function()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(156);
__Instance = Marshal.AllocHGlobal(160);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -5689,7 +5692,7 @@ namespace CppSharp @@ -5689,7 +5692,7 @@ namespace CppSharp
public Function(CppSharp.Parser.AST.Function _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(156);
__Instance = Marshal.AllocHGlobal(160);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))
@ -5906,11 +5909,29 @@ namespace CppSharp @@ -5906,11 +5909,29 @@ namespace CppSharp
((Internal*) __Instance)->SpecializationInfo = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
public CppSharp.Parser.AST.Function InstantiatedFrom
{
get
{
CppSharp.Parser.AST.Function __result0;
if (((Internal*) __Instance)->InstantiatedFrom == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Function.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->InstantiatedFrom))
__result0 = (CppSharp.Parser.AST.Function) CppSharp.Parser.AST.Function.NativeToManagedMap[((Internal*) __Instance)->InstantiatedFrom];
else __result0 = CppSharp.Parser.AST.Function.__CreateInstance(((Internal*) __Instance)->InstantiatedFrom);
return __result0;
}
set
{
((Internal*) __Instance)->InstantiatedFrom = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class Method : CppSharp.Parser.AST.Function, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 180)]
[StructLayout(LayoutKind.Explicit, Size = 184)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5983,33 +6004,36 @@ namespace CppSharp @@ -5983,33 +6004,36 @@ namespace CppSharp
public global::System.IntPtr SpecializationInfo;
[FieldOffset(156)]
public global::System.IntPtr InstantiatedFrom;
[FieldOffset(160)]
public byte IsVirtual;
[FieldOffset(157)]
[FieldOffset(161)]
public byte IsStatic;
[FieldOffset(158)]
[FieldOffset(162)]
public byte IsConst;
[FieldOffset(159)]
[FieldOffset(163)]
public byte IsExplicit;
[FieldOffset(160)]
[FieldOffset(164)]
public byte IsOverride;
[FieldOffset(164)]
[FieldOffset(168)]
public CppSharp.Parser.AST.CXXMethodKind MethodKind;
[FieldOffset(168)]
[FieldOffset(172)]
public byte IsDefaultConstructor;
[FieldOffset(169)]
[FieldOffset(173)]
public byte IsCopyConstructor;
[FieldOffset(170)]
[FieldOffset(174)]
public byte IsMoveConstructor;
[FieldOffset(172)]
[FieldOffset(176)]
public CppSharp.Parser.AST.QualifiedType.Internal ConversionType;
[SuppressUnmanagedCodeSecurity]
@ -6040,7 +6064,7 @@ namespace CppSharp @@ -6040,7 +6064,7 @@ namespace CppSharp
private static void* __CopyValue(Method.Internal native)
{
var ret = Marshal.AllocHGlobal(180);
var ret = Marshal.AllocHGlobal(184);
CppSharp.Parser.AST.Method.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -6064,7 +6088,7 @@ namespace CppSharp @@ -6064,7 +6088,7 @@ namespace CppSharp
public Method()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(180);
__Instance = Marshal.AllocHGlobal(184);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6073,7 +6097,7 @@ namespace CppSharp @@ -6073,7 +6097,7 @@ namespace CppSharp
public Method(CppSharp.Parser.AST.Method _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(180);
__Instance = Marshal.AllocHGlobal(184);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))

58
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs

@ -5516,7 +5516,7 @@ namespace CppSharp @@ -5516,7 +5516,7 @@ namespace CppSharp
public unsafe partial class Function : CppSharp.Parser.AST.Declaration, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 216)]
[StructLayout(LayoutKind.Explicit, Size = 220)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5588,6 +5588,9 @@ namespace CppSharp @@ -5588,6 +5588,9 @@ namespace CppSharp
[FieldOffset(212)]
public global::System.IntPtr SpecializationInfo;
[FieldOffset(216)]
public global::System.IntPtr InstantiatedFrom;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0Function@AST@CppParser@CppSharp@@QAE@XZ")]
@ -5656,7 +5659,7 @@ namespace CppSharp @@ -5656,7 +5659,7 @@ namespace CppSharp
private static void* __CopyValue(Function.Internal native)
{
var ret = Marshal.AllocHGlobal(216);
var ret = Marshal.AllocHGlobal(220);
CppSharp.Parser.AST.Function.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -5680,7 +5683,7 @@ namespace CppSharp @@ -5680,7 +5683,7 @@ namespace CppSharp
public Function()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(216);
__Instance = Marshal.AllocHGlobal(220);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -5689,7 +5692,7 @@ namespace CppSharp @@ -5689,7 +5692,7 @@ namespace CppSharp
public Function(CppSharp.Parser.AST.Function _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(216);
__Instance = Marshal.AllocHGlobal(220);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))
@ -5906,11 +5909,29 @@ namespace CppSharp @@ -5906,11 +5909,29 @@ namespace CppSharp
((Internal*) __Instance)->SpecializationInfo = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
public CppSharp.Parser.AST.Function InstantiatedFrom
{
get
{
CppSharp.Parser.AST.Function __result0;
if (((Internal*) __Instance)->InstantiatedFrom == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Function.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->InstantiatedFrom))
__result0 = (CppSharp.Parser.AST.Function) CppSharp.Parser.AST.Function.NativeToManagedMap[((Internal*) __Instance)->InstantiatedFrom];
else __result0 = CppSharp.Parser.AST.Function.__CreateInstance(((Internal*) __Instance)->InstantiatedFrom);
return __result0;
}
set
{
((Internal*) __Instance)->InstantiatedFrom = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class Method : CppSharp.Parser.AST.Function, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 240)]
[StructLayout(LayoutKind.Explicit, Size = 244)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5983,33 +6004,36 @@ namespace CppSharp @@ -5983,33 +6004,36 @@ namespace CppSharp
public global::System.IntPtr SpecializationInfo;
[FieldOffset(216)]
public global::System.IntPtr InstantiatedFrom;
[FieldOffset(220)]
public byte IsVirtual;
[FieldOffset(217)]
[FieldOffset(221)]
public byte IsStatic;
[FieldOffset(218)]
[FieldOffset(222)]
public byte IsConst;
[FieldOffset(219)]
[FieldOffset(223)]
public byte IsExplicit;
[FieldOffset(220)]
[FieldOffset(224)]
public byte IsOverride;
[FieldOffset(224)]
[FieldOffset(228)]
public CppSharp.Parser.AST.CXXMethodKind MethodKind;
[FieldOffset(228)]
[FieldOffset(232)]
public byte IsDefaultConstructor;
[FieldOffset(229)]
[FieldOffset(233)]
public byte IsCopyConstructor;
[FieldOffset(230)]
[FieldOffset(234)]
public byte IsMoveConstructor;
[FieldOffset(232)]
[FieldOffset(236)]
public CppSharp.Parser.AST.QualifiedType.Internal ConversionType;
[SuppressUnmanagedCodeSecurity]
@ -6040,7 +6064,7 @@ namespace CppSharp @@ -6040,7 +6064,7 @@ namespace CppSharp
private static void* __CopyValue(Method.Internal native)
{
var ret = Marshal.AllocHGlobal(240);
var ret = Marshal.AllocHGlobal(244);
CppSharp.Parser.AST.Method.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -6064,7 +6088,7 @@ namespace CppSharp @@ -6064,7 +6088,7 @@ namespace CppSharp
public Method()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(240);
__Instance = Marshal.AllocHGlobal(244);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6073,7 +6097,7 @@ namespace CppSharp @@ -6073,7 +6097,7 @@ namespace CppSharp
public Method(CppSharp.Parser.AST.Method _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(240);
__Instance = Marshal.AllocHGlobal(244);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))

58
src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs

@ -5515,7 +5515,7 @@ namespace CppSharp @@ -5515,7 +5515,7 @@ namespace CppSharp
public unsafe partial class Function : CppSharp.Parser.AST.Declaration, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 288)]
[StructLayout(LayoutKind.Explicit, Size = 296)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5587,6 +5587,9 @@ namespace CppSharp @@ -5587,6 +5587,9 @@ namespace CppSharp
[FieldOffset(280)]
public global::System.IntPtr SpecializationInfo;
[FieldOffset(288)]
public global::System.IntPtr InstantiatedFrom;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST8FunctionC2Ev")]
@ -5655,7 +5658,7 @@ namespace CppSharp @@ -5655,7 +5658,7 @@ namespace CppSharp
private static void* __CopyValue(Function.Internal native)
{
var ret = Marshal.AllocHGlobal(288);
var ret = Marshal.AllocHGlobal(296);
CppSharp.Parser.AST.Function.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -5679,7 +5682,7 @@ namespace CppSharp @@ -5679,7 +5682,7 @@ namespace CppSharp
public Function()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(288);
__Instance = Marshal.AllocHGlobal(296);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -5688,7 +5691,7 @@ namespace CppSharp @@ -5688,7 +5691,7 @@ namespace CppSharp
public Function(CppSharp.Parser.AST.Function _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(288);
__Instance = Marshal.AllocHGlobal(296);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))
@ -5905,11 +5908,29 @@ namespace CppSharp @@ -5905,11 +5908,29 @@ namespace CppSharp
((Internal*) __Instance)->SpecializationInfo = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
public CppSharp.Parser.AST.Function InstantiatedFrom
{
get
{
CppSharp.Parser.AST.Function __result0;
if (((Internal*) __Instance)->InstantiatedFrom == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Function.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->InstantiatedFrom))
__result0 = (CppSharp.Parser.AST.Function) CppSharp.Parser.AST.Function.NativeToManagedMap[((Internal*) __Instance)->InstantiatedFrom];
else __result0 = CppSharp.Parser.AST.Function.__CreateInstance(((Internal*) __Instance)->InstantiatedFrom);
return __result0;
}
set
{
((Internal*) __Instance)->InstantiatedFrom = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class Method : CppSharp.Parser.AST.Function, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 320)]
[StructLayout(LayoutKind.Explicit, Size = 328)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5982,33 +6003,36 @@ namespace CppSharp @@ -5982,33 +6003,36 @@ namespace CppSharp
public global::System.IntPtr SpecializationInfo;
[FieldOffset(288)]
public global::System.IntPtr InstantiatedFrom;
[FieldOffset(296)]
public byte IsVirtual;
[FieldOffset(289)]
[FieldOffset(297)]
public byte IsStatic;
[FieldOffset(290)]
[FieldOffset(298)]
public byte IsConst;
[FieldOffset(291)]
[FieldOffset(299)]
public byte IsExplicit;
[FieldOffset(292)]
[FieldOffset(300)]
public byte IsOverride;
[FieldOffset(296)]
[FieldOffset(304)]
public CppSharp.Parser.AST.CXXMethodKind MethodKind;
[FieldOffset(300)]
[FieldOffset(308)]
public byte IsDefaultConstructor;
[FieldOffset(301)]
[FieldOffset(309)]
public byte IsCopyConstructor;
[FieldOffset(302)]
[FieldOffset(310)]
public byte IsMoveConstructor;
[FieldOffset(304)]
[FieldOffset(312)]
public CppSharp.Parser.AST.QualifiedType.Internal ConversionType;
[SuppressUnmanagedCodeSecurity]
@ -6039,7 +6063,7 @@ namespace CppSharp @@ -6039,7 +6063,7 @@ namespace CppSharp
private static void* __CopyValue(Method.Internal native)
{
var ret = Marshal.AllocHGlobal(320);
var ret = Marshal.AllocHGlobal(328);
CppSharp.Parser.AST.Method.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -6063,7 +6087,7 @@ namespace CppSharp @@ -6063,7 +6087,7 @@ namespace CppSharp
public Method()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(320);
__Instance = Marshal.AllocHGlobal(328);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6072,7 +6096,7 @@ namespace CppSharp @@ -6072,7 +6096,7 @@ namespace CppSharp
public Method(CppSharp.Parser.AST.Method _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(320);
__Instance = Marshal.AllocHGlobal(328);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))

58
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs

@ -5515,7 +5515,7 @@ namespace CppSharp @@ -5515,7 +5515,7 @@ namespace CppSharp
public unsafe partial class Function : CppSharp.Parser.AST.Declaration, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 208)]
[StructLayout(LayoutKind.Explicit, Size = 216)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5587,6 +5587,9 @@ namespace CppSharp @@ -5587,6 +5587,9 @@ namespace CppSharp
[FieldOffset(200)]
public global::System.IntPtr SpecializationInfo;
[FieldOffset(208)]
public global::System.IntPtr InstantiatedFrom;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST8FunctionC2Ev")]
@ -5655,7 +5658,7 @@ namespace CppSharp @@ -5655,7 +5658,7 @@ namespace CppSharp
private static void* __CopyValue(Function.Internal native)
{
var ret = Marshal.AllocHGlobal(208);
var ret = Marshal.AllocHGlobal(216);
CppSharp.Parser.AST.Function.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -5679,7 +5682,7 @@ namespace CppSharp @@ -5679,7 +5682,7 @@ namespace CppSharp
public Function()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(208);
__Instance = Marshal.AllocHGlobal(216);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -5688,7 +5691,7 @@ namespace CppSharp @@ -5688,7 +5691,7 @@ namespace CppSharp
public Function(CppSharp.Parser.AST.Function _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(208);
__Instance = Marshal.AllocHGlobal(216);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))
@ -5905,11 +5908,29 @@ namespace CppSharp @@ -5905,11 +5908,29 @@ namespace CppSharp
((Internal*) __Instance)->SpecializationInfo = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
public CppSharp.Parser.AST.Function InstantiatedFrom
{
get
{
CppSharp.Parser.AST.Function __result0;
if (((Internal*) __Instance)->InstantiatedFrom == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Function.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->InstantiatedFrom))
__result0 = (CppSharp.Parser.AST.Function) CppSharp.Parser.AST.Function.NativeToManagedMap[((Internal*) __Instance)->InstantiatedFrom];
else __result0 = CppSharp.Parser.AST.Function.__CreateInstance(((Internal*) __Instance)->InstantiatedFrom);
return __result0;
}
set
{
((Internal*) __Instance)->InstantiatedFrom = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class Method : CppSharp.Parser.AST.Function, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 240)]
[StructLayout(LayoutKind.Explicit, Size = 248)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5982,33 +6003,36 @@ namespace CppSharp @@ -5982,33 +6003,36 @@ namespace CppSharp
public global::System.IntPtr SpecializationInfo;
[FieldOffset(208)]
public global::System.IntPtr InstantiatedFrom;
[FieldOffset(216)]
public byte IsVirtual;
[FieldOffset(209)]
[FieldOffset(217)]
public byte IsStatic;
[FieldOffset(210)]
[FieldOffset(218)]
public byte IsConst;
[FieldOffset(211)]
[FieldOffset(219)]
public byte IsExplicit;
[FieldOffset(212)]
[FieldOffset(220)]
public byte IsOverride;
[FieldOffset(216)]
[FieldOffset(224)]
public CppSharp.Parser.AST.CXXMethodKind MethodKind;
[FieldOffset(220)]
[FieldOffset(228)]
public byte IsDefaultConstructor;
[FieldOffset(221)]
[FieldOffset(229)]
public byte IsCopyConstructor;
[FieldOffset(222)]
[FieldOffset(230)]
public byte IsMoveConstructor;
[FieldOffset(224)]
[FieldOffset(232)]
public CppSharp.Parser.AST.QualifiedType.Internal ConversionType;
[SuppressUnmanagedCodeSecurity]
@ -6039,7 +6063,7 @@ namespace CppSharp @@ -6039,7 +6063,7 @@ namespace CppSharp
private static void* __CopyValue(Method.Internal native)
{
var ret = Marshal.AllocHGlobal(240);
var ret = Marshal.AllocHGlobal(248);
CppSharp.Parser.AST.Method.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -6063,7 +6087,7 @@ namespace CppSharp @@ -6063,7 +6087,7 @@ namespace CppSharp
public Method()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(240);
__Instance = Marshal.AllocHGlobal(248);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6072,7 +6096,7 @@ namespace CppSharp @@ -6072,7 +6096,7 @@ namespace CppSharp
public Method(CppSharp.Parser.AST.Method _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(240);
__Instance = Marshal.AllocHGlobal(248);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))

58
src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs

@ -5516,7 +5516,7 @@ namespace CppSharp @@ -5516,7 +5516,7 @@ namespace CppSharp
public unsafe partial class Function : CppSharp.Parser.AST.Declaration, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 328)]
[StructLayout(LayoutKind.Explicit, Size = 336)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5588,6 +5588,9 @@ namespace CppSharp @@ -5588,6 +5588,9 @@ namespace CppSharp
[FieldOffset(320)]
public global::System.IntPtr SpecializationInfo;
[FieldOffset(328)]
public global::System.IntPtr InstantiatedFrom;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="??0Function@AST@CppParser@CppSharp@@QEAA@XZ")]
@ -5656,7 +5659,7 @@ namespace CppSharp @@ -5656,7 +5659,7 @@ namespace CppSharp
private static void* __CopyValue(Function.Internal native)
{
var ret = Marshal.AllocHGlobal(328);
var ret = Marshal.AllocHGlobal(336);
CppSharp.Parser.AST.Function.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -5680,7 +5683,7 @@ namespace CppSharp @@ -5680,7 +5683,7 @@ namespace CppSharp
public Function()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(328);
__Instance = Marshal.AllocHGlobal(336);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -5689,7 +5692,7 @@ namespace CppSharp @@ -5689,7 +5692,7 @@ namespace CppSharp
public Function(CppSharp.Parser.AST.Function _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(328);
__Instance = Marshal.AllocHGlobal(336);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))
@ -5906,11 +5909,29 @@ namespace CppSharp @@ -5906,11 +5909,29 @@ namespace CppSharp
((Internal*) __Instance)->SpecializationInfo = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
public CppSharp.Parser.AST.Function InstantiatedFrom
{
get
{
CppSharp.Parser.AST.Function __result0;
if (((Internal*) __Instance)->InstantiatedFrom == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Function.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->InstantiatedFrom))
__result0 = (CppSharp.Parser.AST.Function) CppSharp.Parser.AST.Function.NativeToManagedMap[((Internal*) __Instance)->InstantiatedFrom];
else __result0 = CppSharp.Parser.AST.Function.__CreateInstance(((Internal*) __Instance)->InstantiatedFrom);
return __result0;
}
set
{
((Internal*) __Instance)->InstantiatedFrom = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class Method : CppSharp.Parser.AST.Function, IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 360)]
[StructLayout(LayoutKind.Explicit, Size = 368)]
public new partial struct Internal
{
[FieldOffset(0)]
@ -5983,33 +6004,36 @@ namespace CppSharp @@ -5983,33 +6004,36 @@ namespace CppSharp
public global::System.IntPtr SpecializationInfo;
[FieldOffset(328)]
public global::System.IntPtr InstantiatedFrom;
[FieldOffset(336)]
public byte IsVirtual;
[FieldOffset(329)]
[FieldOffset(337)]
public byte IsStatic;
[FieldOffset(330)]
[FieldOffset(338)]
public byte IsConst;
[FieldOffset(331)]
[FieldOffset(339)]
public byte IsExplicit;
[FieldOffset(332)]
[FieldOffset(340)]
public byte IsOverride;
[FieldOffset(336)]
[FieldOffset(344)]
public CppSharp.Parser.AST.CXXMethodKind MethodKind;
[FieldOffset(340)]
[FieldOffset(348)]
public byte IsDefaultConstructor;
[FieldOffset(341)]
[FieldOffset(349)]
public byte IsCopyConstructor;
[FieldOffset(342)]
[FieldOffset(350)]
public byte IsMoveConstructor;
[FieldOffset(344)]
[FieldOffset(352)]
public CppSharp.Parser.AST.QualifiedType.Internal ConversionType;
[SuppressUnmanagedCodeSecurity]
@ -6040,7 +6064,7 @@ namespace CppSharp @@ -6040,7 +6064,7 @@ namespace CppSharp
private static void* __CopyValue(Method.Internal native)
{
var ret = Marshal.AllocHGlobal(360);
var ret = Marshal.AllocHGlobal(368);
CppSharp.Parser.AST.Method.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer();
}
@ -6064,7 +6088,7 @@ namespace CppSharp @@ -6064,7 +6088,7 @@ namespace CppSharp
public Method()
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(360);
__Instance = Marshal.AllocHGlobal(368);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6073,7 +6097,7 @@ namespace CppSharp @@ -6073,7 +6097,7 @@ namespace CppSharp
public Method(CppSharp.Parser.AST.Method _0)
: this((void*) null)
{
__Instance = Marshal.AllocHGlobal(360);
__Instance = Marshal.AllocHGlobal(368);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null))

2
src/CppParser/Parser.cpp

@ -2220,6 +2220,8 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F, @@ -2220,6 +2220,8 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F,
F->IsDependent = FD->isDependentContext();
F->IsPure = FD->isPure();
F->IsDeleted = FD->isDeleted();
if (auto InstantiatedFrom = FD->getInstantiatedFromMemberFunction())
F->InstantiatedFrom = static_cast<Function*>(WalkDeclaration(InstantiatedFrom));
auto CC = FT->getCallConv();
F->CallingConvention = ConvertCallConv(CC);

9
src/Generator.Tests/AST/TestAST.cs

@ -295,5 +295,14 @@ namespace CppSharp.Generator.Tests.AST @@ -295,5 +295,14 @@ namespace CppSharp.Generator.Tests.AST
var classTemplate = AstContext.FindDecl<ClassTemplate>("TestSpecializationArguments").FirstOrDefault();
Assert.IsTrue(classTemplate.Specializations[0].Arguments[0].Type.Type.IsPrimitiveType(PrimitiveType.Int));
}
[Test]
public void TestFunctionInstantiatedFrom()
{
var classTemplate = AstContext.FindDecl<ClassTemplate>("TestSpecializationArguments").FirstOrDefault();
Assert.AreEqual(classTemplate.Specializations[0].Constructors.First(
c => !c.IsCopyConstructor && !c.IsMoveConstructor).InstantiatedFrom,
classTemplate.TemplatedClass.Constructors.First(c => !c.IsCopyConstructor && !c.IsMoveConstructor));
}
}
}

Loading…
Cancel
Save