Skip to content

Commit 1710202

Browse files
committed
Add Method.IsVolatile property.
Fixes #1761
1 parent 99a5ed3 commit 1710202

File tree

15 files changed

+124
-3
lines changed

15 files changed

+124
-3
lines changed

src/AST/Method.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ public Method(Method method)
9494
{
9595
Access = method.Access;
9696
IsVirtual = method.IsVirtual;
97+
IsStatic = method.IsStatic;
9798
IsConst = method.IsConst;
99+
IsExplicit = method.IsExplicit;
100+
IsVolatile = method.IsVolatile;
98101
IsFinal = method.IsFinal;
99102
IsProxy = method.IsProxy;
100-
IsStatic = method.IsStatic;
101103
Kind = method.Kind;
102104
IsDefaultConstructor = method.IsDefaultConstructor;
103105
IsCopyConstructor = method.IsCopyConstructor;
@@ -119,6 +121,7 @@ public Method(Function function)
119121
public bool IsStatic { get; set; }
120122
public bool IsConst { get; set; }
121123
public bool IsExplicit { get; set; }
124+
public bool IsVolatile { get; set; }
122125

123126
public bool IsOverride
124127
{

src/CppParser/AST.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ Method::Method()
674674
, isStatic(false)
675675
, isConst(false)
676676
, isExplicit(false)
677+
, isVolatile(false)
677678
, isDefaultConstructor(false)
678679
, isCopyConstructor(false)
679680
, isMoveConstructor(false)

src/CppParser/Bindings/CLI/Decl.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,16 @@ void CppSharp::Parser::AST::Method::IsExplicit::set(bool value)
20282028
((class ::CppSharp::CppParser::AST::Method*)NativePtr)->isExplicit = value;
20292029
}
20302030

2031+
bool CppSharp::Parser::AST::Method::IsVolatile::get()
2032+
{
2033+
return ((class ::CppSharp::CppParser::AST::Method*)NativePtr)->isVolatile;
2034+
}
2035+
2036+
void CppSharp::Parser::AST::Method::IsVolatile::set(bool value)
2037+
{
2038+
((class ::CppSharp::CppParser::AST::Method*)NativePtr)->isVolatile = value;
2039+
}
2040+
20312041
CppSharp::Parser::AST::CXXMethodKind CppSharp::Parser::AST::Method::MethodKind::get()
20322042
{
20332043
return (CppSharp::Parser::AST::CXXMethodKind)((class ::CppSharp::CppParser::AST::Method*)NativePtr)->methodKind;

src/CppParser/Bindings/CLI/Decl.h

+6
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,12 @@ namespace CppSharp
11201120
void set(bool);
11211121
}
11221122

1123+
property bool IsVolatile
1124+
{
1125+
bool get();
1126+
void set(bool);
1127+
}
1128+
11231129
property CppSharp::Parser::AST::CXXMethodKind MethodKind
11241130
{
11251131
CppSharp::Parser::AST::CXXMethodKind get();

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -9350,7 +9350,7 @@ public uint ParametersCount
93509350

93519351
public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable
93529352
{
9353-
[StructLayout(LayoutKind.Sequential, Size = 372)]
9353+
[StructLayout(LayoutKind.Sequential, Size = 376)]
93549354
public new partial struct __Internal
93559355
{
93569356
internal global::CppSharp.Parser.AST.DeclarationKind kind;
@@ -9410,6 +9410,7 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
94109410
internal byte isStatic;
94119411
internal byte isConst;
94129412
internal byte isExplicit;
9413+
internal byte isVolatile;
94139414
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
94149415
internal byte isDefaultConstructor;
94159416
internal byte isCopyConstructor;
@@ -9592,6 +9593,19 @@ public bool IsExplicit
95929593
}
95939594
}
95949595

9596+
public bool IsVolatile
9597+
{
9598+
get
9599+
{
9600+
return ((__Internal*)__Instance)->isVolatile != 0;
9601+
}
9602+
9603+
set
9604+
{
9605+
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
9606+
}
9607+
}
9608+
95959609
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
95969610
{
95979611
get

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -9350,7 +9350,7 @@ public uint ParametersCount
93509350

93519351
public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisposable
93529352
{
9353-
[StructLayout(LayoutKind.Sequential, Size = 440)]
9353+
[StructLayout(LayoutKind.Sequential, Size = 444)]
93549354
public new partial struct __Internal
93559355
{
93569356
internal global::CppSharp.Parser.AST.DeclarationKind kind;
@@ -9410,6 +9410,7 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
94109410
internal byte isStatic;
94119411
internal byte isConst;
94129412
internal byte isExplicit;
9413+
internal byte isVolatile;
94139414
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
94149415
internal byte isDefaultConstructor;
94159416
internal byte isCopyConstructor;
@@ -9592,6 +9593,19 @@ public bool IsExplicit
95929593
}
95939594
}
95949595

9596+
public bool IsVolatile
9597+
{
9598+
get
9599+
{
9600+
return ((__Internal*)__Instance)->isVolatile != 0;
9601+
}
9602+
9603+
set
9604+
{
9605+
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
9606+
}
9607+
}
9608+
95959609
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
95969610
{
95979611
get

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

+14
Original file line numberDiff line numberDiff line change
@@ -9410,6 +9410,7 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
94109410
internal byte isStatic;
94119411
internal byte isConst;
94129412
internal byte isExplicit;
9413+
internal byte isVolatile;
94139414
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
94149415
internal byte isDefaultConstructor;
94159416
internal byte isCopyConstructor;
@@ -9592,6 +9593,19 @@ public bool IsExplicit
95929593
}
95939594
}
95949595

9596+
public bool IsVolatile
9597+
{
9598+
get
9599+
{
9600+
return ((__Internal*)__Instance)->isVolatile != 0;
9601+
}
9602+
9603+
set
9604+
{
9605+
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
9606+
}
9607+
}
9608+
95959609
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
95969610
{
95979611
get

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

+14
Original file line numberDiff line numberDiff line change
@@ -9410,6 +9410,7 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
94109410
internal byte isStatic;
94119411
internal byte isConst;
94129412
internal byte isExplicit;
9413+
internal byte isVolatile;
94139414
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
94149415
internal byte isDefaultConstructor;
94159416
internal byte isCopyConstructor;
@@ -9592,6 +9593,19 @@ public bool IsExplicit
95929593
}
95939594
}
95949595

9596+
public bool IsVolatile
9597+
{
9598+
get
9599+
{
9600+
return ((__Internal*)__Instance)->isVolatile != 0;
9601+
}
9602+
9603+
set
9604+
{
9605+
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
9606+
}
9607+
}
9608+
95959609
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
95969610
{
95979611
get

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

+14
Original file line numberDiff line numberDiff line change
@@ -9410,6 +9410,7 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
94109410
internal byte isStatic;
94119411
internal byte isConst;
94129412
internal byte isExplicit;
9413+
internal byte isVolatile;
94139414
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
94149415
internal byte isDefaultConstructor;
94159416
internal byte isCopyConstructor;
@@ -9592,6 +9593,19 @@ public bool IsExplicit
95929593
}
95939594
}
95949595

9596+
public bool IsVolatile
9597+
{
9598+
get
9599+
{
9600+
return ((__Internal*)__Instance)->isVolatile != 0;
9601+
}
9602+
9603+
set
9604+
{
9605+
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
9606+
}
9607+
}
9608+
95959609
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
95969610
{
95979611
get

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

+14
Original file line numberDiff line numberDiff line change
@@ -9410,6 +9410,7 @@ public unsafe partial class Method : global::CppSharp.Parser.AST.Function, IDisp
94109410
internal byte isStatic;
94119411
internal byte isConst;
94129412
internal byte isExplicit;
9413+
internal byte isVolatile;
94139414
internal global::CppSharp.Parser.AST.CXXMethodKind methodKind;
94149415
internal byte isDefaultConstructor;
94159416
internal byte isCopyConstructor;
@@ -9592,6 +9593,19 @@ public bool IsExplicit
95929593
}
95939594
}
95949595

9596+
public bool IsVolatile
9597+
{
9598+
get
9599+
{
9600+
return ((__Internal*)__Instance)->isVolatile != 0;
9601+
}
9602+
9603+
set
9604+
{
9605+
((__Internal*)__Instance)->isVolatile = (byte) (value ? 1 : 0);
9606+
}
9607+
}
9608+
95959609
public global::CppSharp.Parser.AST.CXXMethodKind MethodKind
95969610
{
95979611
get

src/CppParser/Decl.h

+1
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ namespace CppSharp
380380
bool isStatic;
381381
bool isConst;
382382
bool isExplicit;
383+
bool isVolatile;
383384

384385
CXXMethodKind methodKind;
385386

src/CppParser/Parser.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ Method* Parser::WalkMethodCXX(const clang::CXXMethodDecl* MD)
18981898
Method->isStatic = MD->isStatic();
18991899
Method->isVirtual = MD->isVirtual();
19001900
Method->isConst = MD->isConst();
1901+
Method->isVolatile = MD->isVolatile();
19011902
for (auto OverriddenMethod : MD->overridden_methods())
19021903
{
19031904
auto OM = WalkMethodCXX(OverriddenMethod);

src/Generator.Tests/AST/TestAST.cs

+8
Original file line numberDiff line numberDiff line change
@@ -564,5 +564,13 @@ public void TestPreprocessedEntities()
564564
Assert.NotNull(macro);
565565
Assert.AreEqual("(x, y, z) x##y##z", macro.Expression);
566566
}
567+
568+
[Test]
569+
public void TestMethods()
570+
{
571+
var hasMethodsClass = AstContext.FindClass("HasMethods").First();
572+
var isVolatileMethod = hasMethodsClass.FindMethod("isVolatileMethod");
573+
Assert.That(isVolatileMethod.IsVolatile, Is.EqualTo(true));
574+
}
567575
}
568576
}

src/Parser/ASTConverter.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,7 @@ public override AST.Declaration VisitMethod(Method decl)
13091309
_method.IsConst = decl.IsConst;
13101310
_method.IsImplicit = decl.IsImplicit;
13111311
_method.IsExplicit = decl.IsExplicit;
1312+
_method.IsVolatile = decl.IsVolatile;
13121313

13131314
switch (decl.RefQualifier)
13141315
{

tests/dotnet/Native/AST.h

+6
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,9 @@ int non_deprecated_func(int num);
185185
TestTemplateClass<double> returnIncompleteTemplateSpecialization();
186186

187187
#define MACRO(x, y, z) x##y##z
188+
189+
class HasMethods
190+
{
191+
public:
192+
void isVolatileMethod() volatile {}
193+
};

0 commit comments

Comments
 (0)