Browse Source

Ignored defaulted functions when generating C++ for symbols.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/913/head
Dimitar Dobrev 8 years ago
parent
commit
9294ea0978
  1. 5
      src/AST/Function.cs
  2. 1
      src/CppParser/AST.cpp
  3. 1
      src/CppParser/AST.h
  4. 10
      src/CppParser/Bindings/CLI/AST.cpp
  5. 6
      src/CppParser/Bindings/CLI/AST.h
  6. 19
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs
  7. 15
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std.cs
  8. 19
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs
  9. 19
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs
  10. 15
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs
  11. 19
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs
  12. 19
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs
  13. 19
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs
  14. 1
      src/CppParser/Parser.cpp
  15. 8
      src/Generator/Passes/GenerateSymbolsPass.cs
  16. 1
      src/Parser/ASTConverter.cs

5
src/AST/Function.cs

@ -158,6 +158,10 @@ namespace CppSharp.AST
IsVariadic = function.IsVariadic; IsVariadic = function.IsVariadic;
IsInline = function.IsInline; IsInline = function.IsInline;
IsPure = function.IsPure; IsPure = function.IsPure;
IsDeleted = function.IsDeleted;
IsDefaulted = function.IsDefaulted;
IsAmbiguous = function.IsAmbiguous;
FriendKind = function.FriendKind;
OperatorKind = function.OperatorKind; OperatorKind = function.OperatorKind;
CallingConvention = function.CallingConvention; CallingConvention = function.CallingConvention;
SynthKind = function.SynthKind; SynthKind = function.SynthKind;
@ -182,6 +186,7 @@ namespace CppSharp.AST
public bool IsInline { get; set; } public bool IsInline { get; set; }
public bool IsPure { get; set; } public bool IsPure { get; set; }
public bool IsDeleted { get; set; } public bool IsDeleted { get; set; }
public bool IsDefaulted { get; set; }
public bool IsAmbiguous { get; set; } public bool IsAmbiguous { get; set; }
public FriendKind FriendKind { get; set; } public FriendKind FriendKind { get; set; }
public CXXOperatorKind OperatorKind { get; set; } public CXXOperatorKind OperatorKind { get; set; }

1
src/CppParser/AST.cpp

@ -633,6 +633,7 @@ Function::Function()
, isInline(false) , isInline(false)
, isPure(false) , isPure(false)
, isDeleted(false) , isDeleted(false)
, isDefaulted(false)
, friendKind(FriendKind::None) , friendKind(FriendKind::None)
, operatorKind(CXXOperatorKind::None) , operatorKind(CXXOperatorKind::None)
, callingConvention(CallingConvention::Default) , callingConvention(CallingConvention::Default)

1
src/CppParser/AST.h

@ -731,6 +731,7 @@ public:
bool isInline; bool isInline;
bool isPure; bool isPure;
bool isDeleted; bool isDeleted;
bool isDefaulted;
FriendKind friendKind; FriendKind friendKind;
CXXOperatorKind operatorKind; CXXOperatorKind operatorKind;
std::string mangled; std::string mangled;

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

@ -3594,6 +3594,16 @@ void CppSharp::Parser::AST::Function::IsDeleted::set(bool value)
((::CppSharp::CppParser::AST::Function*)NativePtr)->isDeleted = value; ((::CppSharp::CppParser::AST::Function*)NativePtr)->isDeleted = value;
} }
bool CppSharp::Parser::AST::Function::IsDefaulted::get()
{
return ((::CppSharp::CppParser::AST::Function*)NativePtr)->isDefaulted;
}
void CppSharp::Parser::AST::Function::IsDefaulted::set(bool value)
{
((::CppSharp::CppParser::AST::Function*)NativePtr)->isDefaulted = value;
}
CppSharp::Parser::AST::FriendKind CppSharp::Parser::AST::Function::FriendKind::get() CppSharp::Parser::AST::FriendKind CppSharp::Parser::AST::Function::FriendKind::get()
{ {
return (CppSharp::Parser::AST::FriendKind)((::CppSharp::CppParser::AST::Function*)NativePtr)->friendKind; return (CppSharp::Parser::AST::FriendKind)((::CppSharp::CppParser::AST::Function*)NativePtr)->friendKind;

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

@ -2072,6 +2072,12 @@ namespace CppSharp
void set(bool); void set(bool);
} }
property bool IsDefaulted
{
bool get();
void set(bool);
}
property CppSharp::Parser::AST::FriendKind FriendKind property CppSharp::Parser::AST::FriendKind FriendKind
{ {
CppSharp::Parser::AST::FriendKind get(); CppSharp::Parser::AST::FriendKind get();

19
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs

@ -7168,6 +7168,9 @@ namespace CppSharp
[FieldOffset(246)] [FieldOffset(246)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(247)]
internal byte isDefaulted;
[FieldOffset(248)] [FieldOffset(248)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;
@ -7429,6 +7432,19 @@ namespace CppSharp
} }
} }
public bool IsDefaulted
{
get
{
return ((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted != 0;
}
set
{
((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.FriendKind FriendKind public global::CppSharp.Parser.AST.FriendKind FriendKind
{ {
get get
@ -7700,6 +7716,9 @@ namespace CppSharp
[FieldOffset(246)] [FieldOffset(246)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(247)]
internal byte isDefaulted;
[FieldOffset(248)] [FieldOffset(248)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;

15
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std.cs

@ -122,6 +122,21 @@ namespace Std
{ {
namespace __1 namespace __1
{ {
namespace Vector
{
[StructLayout(LayoutKind.Explicit, Size = 12)]
public unsafe partial struct __Internal
{
[FieldOffset(0)]
internal global::System.IntPtr __begin_;
[FieldOffset(4)]
internal global::System.IntPtr __end_;
[FieldOffset(8)]
internal global::Std.__1.CompressedPair.__Internal __end_cap_;
}
}
} }
} }

19
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs

@ -7168,6 +7168,9 @@ namespace CppSharp
[FieldOffset(278)] [FieldOffset(278)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(279)]
internal byte isDefaulted;
[FieldOffset(280)] [FieldOffset(280)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;
@ -7429,6 +7432,19 @@ namespace CppSharp
} }
} }
public bool IsDefaulted
{
get
{
return ((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted != 0;
}
set
{
((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.FriendKind FriendKind public global::CppSharp.Parser.AST.FriendKind FriendKind
{ {
get get
@ -7700,6 +7716,9 @@ namespace CppSharp
[FieldOffset(278)] [FieldOffset(278)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(279)]
internal byte isDefaulted;
[FieldOffset(280)] [FieldOffset(280)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;

19
src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs

@ -7167,6 +7167,9 @@ namespace CppSharp
[FieldOffset(470)] [FieldOffset(470)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(471)]
internal byte isDefaulted;
[FieldOffset(472)] [FieldOffset(472)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;
@ -7428,6 +7431,19 @@ namespace CppSharp
} }
} }
public bool IsDefaulted
{
get
{
return ((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted != 0;
}
set
{
((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.FriendKind FriendKind public global::CppSharp.Parser.AST.FriendKind FriendKind
{ {
get get
@ -7699,6 +7715,9 @@ namespace CppSharp
[FieldOffset(470)] [FieldOffset(470)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(471)]
internal byte isDefaulted;
[FieldOffset(472)] [FieldOffset(472)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;

15
src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs

@ -122,6 +122,21 @@ namespace Std
{ {
namespace __1 namespace __1
{ {
namespace Vector
{
[StructLayout(LayoutKind.Explicit, Size = 24)]
public unsafe partial struct __Internal
{
[FieldOffset(0)]
internal global::System.IntPtr __begin_;
[FieldOffset(8)]
internal global::System.IntPtr __end_;
[FieldOffset(16)]
internal global::Std.__1.CompressedPair.__Internal __end_cap_;
}
}
} }
} }

19
src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs

@ -7167,6 +7167,9 @@ namespace CppSharp
[FieldOffset(518)] [FieldOffset(518)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(519)]
internal byte isDefaulted;
[FieldOffset(520)] [FieldOffset(520)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;
@ -7428,6 +7431,19 @@ namespace CppSharp
} }
} }
public bool IsDefaulted
{
get
{
return ((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted != 0;
}
set
{
((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.FriendKind FriendKind public global::CppSharp.Parser.AST.FriendKind FriendKind
{ {
get get
@ -7699,6 +7715,9 @@ namespace CppSharp
[FieldOffset(518)] [FieldOffset(518)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(519)]
internal byte isDefaulted;
[FieldOffset(520)] [FieldOffset(520)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;

19
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs

@ -7167,6 +7167,9 @@ namespace CppSharp
[FieldOffset(446)] [FieldOffset(446)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(447)]
internal byte isDefaulted;
[FieldOffset(448)] [FieldOffset(448)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;
@ -7428,6 +7431,19 @@ namespace CppSharp
} }
} }
public bool IsDefaulted
{
get
{
return ((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted != 0;
}
set
{
((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.FriendKind FriendKind public global::CppSharp.Parser.AST.FriendKind FriendKind
{ {
get get
@ -7699,6 +7715,9 @@ namespace CppSharp
[FieldOffset(446)] [FieldOffset(446)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(447)]
internal byte isDefaulted;
[FieldOffset(448)] [FieldOffset(448)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;

19
src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs

@ -7168,6 +7168,9 @@ namespace CppSharp
[FieldOffset(486)] [FieldOffset(486)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(487)]
internal byte isDefaulted;
[FieldOffset(488)] [FieldOffset(488)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;
@ -7429,6 +7432,19 @@ namespace CppSharp
} }
} }
public bool IsDefaulted
{
get
{
return ((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted != 0;
}
set
{
((global::CppSharp.Parser.AST.Function.__Internal*) __Instance)->isDefaulted = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.FriendKind FriendKind public global::CppSharp.Parser.AST.FriendKind FriendKind
{ {
get get
@ -7700,6 +7716,9 @@ namespace CppSharp
[FieldOffset(486)] [FieldOffset(486)]
internal byte isDeleted; internal byte isDeleted;
[FieldOffset(487)]
internal byte isDefaulted;
[FieldOffset(488)] [FieldOffset(488)]
internal global::CppSharp.Parser.AST.FriendKind friendKind; internal global::CppSharp.Parser.AST.FriendKind friendKind;

1
src/CppParser/Parser.cpp

@ -2859,6 +2859,7 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F,
F->isDependent = FD->isDependentContext(); F->isDependent = FD->isDependentContext();
F->isPure = FD->isPure(); F->isPure = FD->isPure();
F->isDeleted = FD->isDeleted(); F->isDeleted = FD->isDeleted();
F->isDefaulted = FD->isDefaulted();
SetBody(FD, F); SetBody(FD, F);
if (auto InstantiatedFrom = FD->getTemplateInstantiationPattern()) if (auto InstantiatedFrom = FD->getTemplateInstantiationPattern())
F->instantiatedFrom = static_cast<Function*>(WalkDeclaration(InstantiatedFrom)); F->instantiatedFrom = static_cast<Function*>(WalkDeclaration(InstantiatedFrom));

8
src/Generator/Passes/GenerateSymbolsPass.cs

@ -31,6 +31,7 @@ namespace CppSharp.Passes
{ {
var result = base.VisitASTContext(context); var result = base.VisitASTContext(context);
var findSymbolsPass = Context.TranslationUnitPasses.FindPass<FindSymbolsPass>(); var findSymbolsPass = Context.TranslationUnitPasses.FindPass<FindSymbolsPass>();
if (remainingCompilationTasks > 0)
findSymbolsPass.Wait = true; findSymbolsPass.Wait = true;
GenerateSymbols(); GenerateSymbols();
return result; return result;
@ -50,7 +51,8 @@ namespace CppSharp.Passes
symbolsCodeGenerator.NewLine(); symbolsCodeGenerator.NewLine();
foreach (var specialization in specializations[module]) foreach (var specialization in specializations[module])
foreach (var method in specialization.Methods.Where( foreach (var method in specialization.Methods.Where(
m => m.IsGenerated && !m.IsDependent && !m.IsImplicit && !m.IsDeleted)) m => m.IsGenerated && !m.IsDependent && !m.IsImplicit &&
!m.IsDeleted && !m.IsDefaulted))
symbolsCodeGenerator.VisitMethodDecl(method); symbolsCodeGenerator.VisitMethodDecl(method);
} }
@ -124,8 +126,8 @@ namespace CppSharp.Passes
{ {
var mangled = function.Mangled; var mangled = function.Mangled;
var method = function as Method; var method = function as Method;
return function.IsGenerated && !function.IsDeleted && !function.IsDependent && return function.IsGenerated && !function.IsDeleted && !function.IsDefaulted &&
!function.IsPure && !function.IsDependent && !function.IsPure &&
(!string.IsNullOrEmpty(function.Body) || function.IsImplicit) && (!string.IsNullOrEmpty(function.Body) || function.IsImplicit) &&
!(function.Namespace is ClassTemplateSpecialization) && !(function.Namespace is ClassTemplateSpecialization) &&
// we don't need symbols for virtual functions anyway // we don't need symbols for virtual functions anyway

1
src/Parser/ASTConverter.cs

@ -1170,6 +1170,7 @@ namespace CppSharp
_function.IsInline = function.IsInline; _function.IsInline = function.IsInline;
_function.IsPure = function.IsPure; _function.IsPure = function.IsPure;
_function.IsDeleted = function.IsDeleted; _function.IsDeleted = function.IsDeleted;
_function.IsDefaulted = function.IsDefaulted;
_function.FriendKind = VisitFriendKind(function.FriendKind); _function.FriendKind = VisitFriendKind(function.FriendKind);
_function.OperatorKind = VisitCXXOperatorKind(function.OperatorKind); _function.OperatorKind = VisitCXXOperatorKind(function.OperatorKind);
_function.Mangled = function.Mangled; _function.Mangled = function.Mangled;

Loading…
Cancel
Save