Browse Source

Add Method.IsVolatile property.

Fixes https://github.com/mono/CppSharp/issues/1761
pull/1769/head
Joao Matos 2 years ago
parent
commit
17102021cc
  1. 5
      src/AST/Method.cs
  2. 1
      src/CppParser/AST.cpp
  3. 10
      src/CppParser/Bindings/CLI/Decl.cpp
  4. 6
      src/CppParser/Bindings/CLI/Decl.h
  5. 16
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs
  6. 16
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs
  7. 14
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs
  8. 14
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs
  9. 14
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs
  10. 14
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs
  11. 1
      src/CppParser/Decl.h
  12. 1
      src/CppParser/Parser.cpp
  13. 8
      src/Generator.Tests/AST/TestAST.cs
  14. 1
      src/Parser/ASTConverter.cs
  15. 6
      tests/dotnet/Native/AST.h

5
src/AST/Method.cs

@ -94,10 +94,12 @@ namespace CppSharp.AST
{ {
Access = method.Access; Access = method.Access;
IsVirtual = method.IsVirtual; IsVirtual = method.IsVirtual;
IsStatic = method.IsStatic;
IsConst = method.IsConst; IsConst = method.IsConst;
IsExplicit = method.IsExplicit;
IsVolatile = method.IsVolatile;
IsFinal = method.IsFinal; IsFinal = method.IsFinal;
IsProxy = method.IsProxy; IsProxy = method.IsProxy;
IsStatic = method.IsStatic;
Kind = method.Kind; Kind = method.Kind;
IsDefaultConstructor = method.IsDefaultConstructor; IsDefaultConstructor = method.IsDefaultConstructor;
IsCopyConstructor = method.IsCopyConstructor; IsCopyConstructor = method.IsCopyConstructor;
@ -119,6 +121,7 @@ namespace CppSharp.AST
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 IsVolatile { get; set; }
public bool IsOverride public bool IsOverride
{ {

1
src/CppParser/AST.cpp

@ -674,6 +674,7 @@ Method::Method()
, isStatic(false) , isStatic(false)
, isConst(false) , isConst(false)
, isExplicit(false) , isExplicit(false)
, isVolatile(false)
, isDefaultConstructor(false) , isDefaultConstructor(false)
, isCopyConstructor(false) , isCopyConstructor(false)
, isMoveConstructor(false) , isMoveConstructor(false)

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

@ -2028,6 +2028,16 @@ void CppSharp::Parser::AST::Method::IsExplicit::set(bool value)
((class ::CppSharp::CppParser::AST::Method*)NativePtr)->isExplicit = value; ((class ::CppSharp::CppParser::AST::Method*)NativePtr)->isExplicit = value;
} }
bool CppSharp::Parser::AST::Method::IsVolatile::get()
{
return ((class ::CppSharp::CppParser::AST::Method*)NativePtr)->isVolatile;
}
void CppSharp::Parser::AST::Method::IsVolatile::set(bool value)
{
((class ::CppSharp::CppParser::AST::Method*)NativePtr)->isVolatile = 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)((class ::CppSharp::CppParser::AST::Method*)NativePtr)->methodKind; return (CppSharp::Parser::AST::CXXMethodKind)((class ::CppSharp::CppParser::AST::Method*)NativePtr)->methodKind;

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

@ -1120,6 +1120,12 @@ namespace CppSharp
void set(bool); void set(bool);
} }
property bool IsVolatile
{
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();

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

@ -9350,7 +9350,7 @@ namespace CppSharp
public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable
{ {
[StructLayout(LayoutKind.Sequential, Size = 372)] [StructLayout(LayoutKind.Sequential, Size = 376)]
public new partial struct __Internal public new partial struct __Internal
{ {
internal global::CppSharp.Parser.AST.DeclarationKind kind; internal global::CppSharp.Parser.AST.DeclarationKind kind;
@ -9410,6 +9410,7 @@ namespace CppSharp
internal byte isStatic; internal byte isStatic;
internal byte isConst; internal byte isConst;
internal byte isExplicit; internal byte isExplicit;
internal byte isVolatile;
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind; internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
internal byte isDefaultConstructor; internal byte isDefaultConstructor;
internal byte isCopyConstructor; internal byte isCopyConstructor;
@ -9592,6 +9593,19 @@ namespace CppSharp
} }
} }
public bool IsVolatile
{
get
{
return ((__Internal*)__Instance)->isVolatile != 0;
}
set
{
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
{ {
get get

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

@ -9350,7 +9350,7 @@ namespace CppSharp
public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable
{ {
[StructLayout(LayoutKind.Sequential, Size = 440)] [StructLayout(LayoutKind.Sequential, Size = 444)]
public new partial struct __Internal public new partial struct __Internal
{ {
internal global::CppSharp.Parser.AST.DeclarationKind kind; internal global::CppSharp.Parser.AST.DeclarationKind kind;
@ -9410,6 +9410,7 @@ namespace CppSharp
internal byte isStatic; internal byte isStatic;
internal byte isConst; internal byte isConst;
internal byte isExplicit; internal byte isExplicit;
internal byte isVolatile;
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind; internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
internal byte isDefaultConstructor; internal byte isDefaultConstructor;
internal byte isCopyConstructor; internal byte isCopyConstructor;
@ -9592,6 +9593,19 @@ namespace CppSharp
} }
} }
public bool IsVolatile
{
get
{
return ((__Internal*)__Instance)->isVolatile != 0;
}
set
{
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
{ {
get get

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

@ -9410,6 +9410,7 @@ namespace CppSharp
internal byte isStatic; internal byte isStatic;
internal byte isConst; internal byte isConst;
internal byte isExplicit; internal byte isExplicit;
internal byte isVolatile;
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind; internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
internal byte isDefaultConstructor; internal byte isDefaultConstructor;
internal byte isCopyConstructor; internal byte isCopyConstructor;
@ -9592,6 +9593,19 @@ namespace CppSharp
} }
} }
public bool IsVolatile
{
get
{
return ((__Internal*)__Instance)->isVolatile != 0;
}
set
{
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
{ {
get get

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

@ -9410,6 +9410,7 @@ namespace CppSharp
internal byte isStatic; internal byte isStatic;
internal byte isConst; internal byte isConst;
internal byte isExplicit; internal byte isExplicit;
internal byte isVolatile;
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind; internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
internal byte isDefaultConstructor; internal byte isDefaultConstructor;
internal byte isCopyConstructor; internal byte isCopyConstructor;
@ -9592,6 +9593,19 @@ namespace CppSharp
} }
} }
public bool IsVolatile
{
get
{
return ((__Internal*)__Instance)->isVolatile != 0;
}
set
{
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
{ {
get get

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

@ -9410,6 +9410,7 @@ namespace CppSharp
internal byte isStatic; internal byte isStatic;
internal byte isConst; internal byte isConst;
internal byte isExplicit; internal byte isExplicit;
internal byte isVolatile;
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind; internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
internal byte isDefaultConstructor; internal byte isDefaultConstructor;
internal byte isCopyConstructor; internal byte isCopyConstructor;
@ -9592,6 +9593,19 @@ namespace CppSharp
} }
} }
public bool IsVolatile
{
get
{
return ((__Internal*)__Instance)->isVolatile != 0;
}
set
{
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
{ {
get get

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

@ -9410,6 +9410,7 @@ namespace CppSharp
internal byte isStatic; internal byte isStatic;
internal byte isConst; internal byte isConst;
internal byte isExplicit; internal byte isExplicit;
internal byte isVolatile;
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind; internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
internal byte isDefaultConstructor; internal byte isDefaultConstructor;
internal byte isCopyConstructor; internal byte isCopyConstructor;
@ -9592,6 +9593,19 @@ namespace CppSharp
} }
} }
public bool IsVolatile
{
get
{
return ((__Internal*)__Instance)->isVolatile != 0;
}
set
{
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
}
}
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
{ {
get get

1
src/CppParser/Decl.h

@ -380,6 +380,7 @@ namespace CppSharp
bool isStatic; bool isStatic;
bool isConst; bool isConst;
bool isExplicit; bool isExplicit;
bool isVolatile;
CXXMethodKind methodKind; CXXMethodKind methodKind;

1
src/CppParser/Parser.cpp

@ -1898,6 +1898,7 @@ Method* Parser::WalkMethodCXX(const clang::CXXMethodDecl* MD)
Method->isStatic = MD->isStatic(); Method->isStatic = MD->isStatic();
Method->isVirtual = MD->isVirtual(); Method->isVirtual = MD->isVirtual();
Method->isConst = MD->isConst(); Method->isConst = MD->isConst();
Method->isVolatile = MD->isVolatile();
for (auto OverriddenMethod : MD->overridden_methods()) for (auto OverriddenMethod : MD->overridden_methods())
{ {
auto OM = WalkMethodCXX(OverriddenMethod); auto OM = WalkMethodCXX(OverriddenMethod);

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

@ -564,5 +564,13 @@ namespace CppSharp.Generator.Tests.AST
Assert.NotNull(macro); Assert.NotNull(macro);
Assert.AreEqual("(x, y, z) x##y##z", macro.Expression); Assert.AreEqual("(x, y, z) x##y##z", macro.Expression);
} }
[Test]
public void TestMethods()
{
var hasMethodsClass = AstContext.FindClass("HasMethods").First();
var isVolatileMethod = hasMethodsClass.FindMethod("isVolatileMethod");
Assert.That(isVolatileMethod.IsVolatile, Is.EqualTo(true));
}
} }
} }

1
src/Parser/ASTConverter.cs

@ -1309,6 +1309,7 @@ namespace CppSharp
_method.IsConst = decl.IsConst; _method.IsConst = decl.IsConst;
_method.IsImplicit = decl.IsImplicit; _method.IsImplicit = decl.IsImplicit;
_method.IsExplicit = decl.IsExplicit; _method.IsExplicit = decl.IsExplicit;
_method.IsVolatile = decl.IsVolatile;
switch (decl.RefQualifier) switch (decl.RefQualifier)
{ {

6
tests/dotnet/Native/AST.h

@ -185,3 +185,9 @@ int non_deprecated_func(int num);
TestTemplateClass<double> returnIncompleteTemplateSpecialization(); TestTemplateClass<double> returnIncompleteTemplateSpecialization();
#define MACRO(x, y, z) x##y##z #define MACRO(x, y, z) x##y##z
class HasMethods
{
public:
void isVolatileMethod() volatile {}
};
Loading…
Cancel
Save