Skip to content

Commit 5f96568

Browse files
CppVarType is no longer a CppEntity as it doesn't appear as a node in an AST
1 parent 515f446 commit 5f96568

23 files changed

Lines changed: 105 additions & 328 deletions

cppast/include/cppast/cpp_entity_type.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ enum class CppEntityType
1313
PREPROCESSOR,
1414
ENTITY_ACCESS_SPECIFIER,
1515
COMPOUND,
16-
VAR_TYPE,
1716
VAR,
1817
VAR_LIST,
1918
TYPEDEF_DECL,

cppast/include/cppast/cpp_templatable_entity.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
#ifndef D94591D6_2473_4804_A403_3EF86D03DD28
55
#define D94591D6_2473_4804_A403_3EF86D03DD28
66

7-
#include "cppast/cpp_template_param.h"
8-
97
#include <optional>
8+
#include <vector>
109

1110
namespace cppast {
1211

@@ -33,4 +32,6 @@ class CppTemplatableEntity
3332

3433
} // namespace cppast
3534

35+
#include "cppast/cpp_template_param.h"
36+
3637
#endif /* D94591D6_2473_4804_A403_3EF86D03DD28 */

cppast/include/cppast/cpp_template_param.h

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,61 @@
77
#include "cppast/defs.h"
88

99
#include <memory>
10+
#include <optional>
1011
#include <string>
12+
#include <variant>
1113

1214
namespace cppast {
1315

1416
class CppEntity;
1517
class CppVarType;
1618
class CppFunctionPointer;
19+
class CppExpression;
1720

1821
/**
1922
* Parameter types that are used to define a templated C++ entity.
2023
*/
2124
class CppTemplateParam
2225
{
2326
public:
24-
CppTemplateParam(std::string paramName, std::unique_ptr<const CppEntity> defArg = nullptr);
25-
CppTemplateParam(std::unique_ptr<const CppVarType> paramType,
26-
std::string paramName,
27-
std::unique_ptr<const CppEntity> defArg = nullptr);
28-
CppTemplateParam(std::unique_ptr<const CppFunctionPointer> paramType,
29-
std::string paramName,
30-
std::unique_ptr<const CppEntity> defArg = nullptr);
27+
using ParamType = std::variant<std::unique_ptr<const CppVarType>, std::unique_ptr<const CppFunctionPointer>>;
28+
using ArgType = std::variant<std::unique_ptr<const CppVarType>, std::unique_ptr<const CppExpression>>;
29+
30+
public:
31+
CppTemplateParam(std::string paramName, ArgType defArg = ArgType());
32+
CppTemplateParam(ParamType paramType, std::string paramName, ArgType defArg = ArgType());
3133

3234
CppTemplateParam(CppTemplateParam&& rval) = default;
3335

3436
~CppTemplateParam();
3537

3638
public:
37-
const CppEntity* paramType() const
39+
const std::optional<ParamType>& paramType() const
3840
{
39-
return paramType_.get();
41+
return paramType_;
4042
}
4143

4244
const std::string& paramName() const
4345
{
4446
return paramName_;
4547
}
4648

47-
const CppEntity* defaultArg() const
49+
const ArgType& defaultArg() const
4850
{
49-
return defaultArg_.get();
51+
return defaultArg_;
5052
}
5153

5254
private:
53-
// If not nullptr then template param is not of type typename/class
54-
std::unique_ptr<const CppEntity> paramType_;
55-
std::string paramName_;
56-
std::unique_ptr<const CppEntity> defaultArg_; //< Can be CppVarType or CppExpression
55+
// If initialized then template param is not of type typename/class
56+
std::optional<ParamType> paramType_;
57+
std::string paramName_;
58+
ArgType defaultArg_;
5759
};
5860

5961
} // namespace cppast
6062

63+
#include "cppast/cpp_expression.h"
64+
#include "cppast/cpp_function.h"
65+
#include "cppast/cpp_var_type.h"
66+
6167
#endif /* A6947342_A917_4B84_B327_5878ACC690B3 */

cppast/include/cppast/cpp_type_alias.h

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,15 @@ class CppUsingDecl : public CppEntity, public CppTemplatableEntity
6868
return CppEntityType::USING_DECL;
6969
}
7070

71-
public:
72-
CppUsingDecl(std::string name, std::unique_ptr<CppVarType> varType)
73-
: CppEntity(EntityType())
74-
, name_(std::move(name))
75-
, cppEntity_(std::move(varType))
76-
{
77-
}
71+
using DeclData = std::variant<std::unique_ptr<const CppVarType>,
72+
std::unique_ptr<const CppFunctionPointer>,
73+
std::unique_ptr<const CppCompound>>;
7874

79-
CppUsingDecl(std::string name, std::unique_ptr<CppFunctionPointer> fptr)
80-
: CppEntity(EntityType())
81-
, name_(std::move(name))
82-
, cppEntity_(std::move(fptr))
83-
{
84-
}
85-
86-
CppUsingDecl(std::string name, std::unique_ptr<CppCompound> compound)
75+
public:
76+
CppUsingDecl(std::string name, DeclData declData)
8777
: CppEntity(EntityType())
8878
, name_(std::move(name))
89-
, cppEntity_(std::move(compound))
79+
, declData_(std::move(declData))
9080
{
9181
}
9282

@@ -102,14 +92,14 @@ class CppUsingDecl : public CppEntity, public CppTemplatableEntity
10292
return name_;
10393
}
10494

105-
const CppEntity* definition() const
95+
const DeclData& definition() const
10696
{
107-
return cppEntity_.get();
97+
return declData_;
10898
}
10999

110100
private:
111-
const std::string name_;
112-
const std::unique_ptr<CppEntity> cppEntity_;
101+
const std::string name_;
102+
const DeclData declData_;
113103
};
114104

115105
} // namespace cppast

cppast/include/cppast/cpp_var_type.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#ifndef DEE52E89_9A5C_4A01_B51A_D0D4786BC7EF
55
#define DEE52E89_9A5C_4A01_B51A_D0D4786BC7EF
66

7-
#include "cppast/cpp_entity.h"
87
#include "cppast/cpp_enum.h"
98
#include "cppast/cpp_function.h"
109
#include "cppast/cpp_type_modifier.h"
@@ -24,14 +23,8 @@ class CppEnum;
2423
* It can be used to define a variable or function parameter.
2524
* @see CppVar.
2625
*/
27-
class CppVarType : public CppEntity
26+
class CppVarType : public CppAttributeSpecifierSequenceContainer
2827
{
29-
public:
30-
static constexpr auto EntityType()
31-
{
32-
return CppEntityType::VAR_TYPE;
33-
}
34-
3528
public:
3629
CppVarType(std::string baseType, CppTypeModifier modifier);
3730
CppVarType(CppCompound* compound, CppTypeModifier modifier);

cppast/src/cpp_template_param.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,13 @@
77

88
namespace cppast {
99

10-
CppTemplateParam::CppTemplateParam(std::string paramName, std::unique_ptr<const CppEntity> defArg)
10+
CppTemplateParam::CppTemplateParam(std::string paramName, ArgType defArg)
1111
: paramName_(std::move(paramName))
1212
, defaultArg_(std::move(defArg))
1313
{
1414
}
1515

16-
CppTemplateParam::CppTemplateParam(std::unique_ptr<const CppVarType> paramType,
17-
std::string paramName,
18-
std::unique_ptr<const CppEntity> defArg)
19-
: paramType_(std::move(paramType))
20-
, paramName_(std::move(paramName))
21-
, defaultArg_(std::move(defArg))
22-
{
23-
}
24-
25-
CppTemplateParam::CppTemplateParam(std::unique_ptr<const CppFunctionPointer> paramType,
26-
std::string paramName,
27-
std::unique_ptr<const CppEntity> defArg)
16+
CppTemplateParam::CppTemplateParam(ParamType paramType, std::string paramName, ArgType defArg)
2817
: paramType_(std::move(paramType))
2918
, paramName_(std::move(paramName))
3019
, defaultArg_(std::move(defArg))

cppast/src/cpp_var_type.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@ CppVarType::CppVarType(std::string baseType, CppTypeModifier modifier)
1212
}
1313

1414
CppVarType::CppVarType(CppCompound* compound, CppTypeModifier modifier)
15-
: CppEntity(EntityType())
16-
, compound_(compound)
15+
: compound_(compound)
1716
, typeModifier_(modifier)
1817
{
1918
}
2019

2120
CppVarType::CppVarType(CppFunctionPointer* compound, CppTypeModifier modifier)
22-
: CppEntity(EntityType())
23-
, compound_(compound)
21+
: compound_(compound)
2422
, typeModifier_(modifier)
2523
{
2624
}
2725

2826
CppVarType::CppVarType(CppEnum* enumObj, CppTypeModifier modifier)
29-
: CppEntity(EntityType())
30-
, compound_(enumObj)
27+
: compound_(enumObj)
3128
, typeModifier_(modifier)
3229
{
3330
}
@@ -39,8 +36,7 @@ CppVarType::CppVarType(const CppVarType& varType)
3936
}
4037

4138
CppVarType::CppVarType(std::string baseType, std::uint32_t typeAttr, CppTypeModifier modifier)
42-
: CppEntity(EntityType())
43-
, baseType_(std::move(baseType))
39+
: baseType_(std::move(baseType))
4440
, typeModifier_(modifier)
4541
, typeAttr_(typeAttr)
4642
{

cppparser/test/e2e/test_master/ObjectArxHeaders/acedads.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ int acedSSName(const ads_name ss, int i, ads_name entres);
8686
int acedSSNameX(struct resbuf** rbpp, const ads_name ss, int i);
8787
int acedSSNameXEx(struct resbuf** rbpp, const ads_name ss, int i, unsigned int flags);
8888
using SSCallbackType = struct resbuf* (*) (const ACHAR*);
89-
;
9089
int acedSSGetKwordCallbackPtr(SSCallbackType* pFunc);
9190
int acedSSSetKwordCallbackPtr(SSCallbackType pFunc);
9291
int acedSSGetOtherCallbackPtr(SSCallbackType* pFunc);

cppparser/test/e2e/test_master/ObjectArxHeaders/rxclass.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class AcRxClass : public AcRxObject
7272
AcRxClass operator =(const AcRxClass&);
7373
};
7474
using PseudoConstructor = AcRxObject* (*) ();
75-
;
7675
ACBASE_PORT AcRxClass* newAcRxClass(const ACHAR* className, const ACHAR* parentClassName, int proxyFlags = 0, PseudoConstructor pseudoConstructor = NULL, const ACHAR* dxfName = NULL, const ACHAR* appName = NULL);
7776
ACBASE_PORT AcRxClass* newAcRxClass(const ACHAR* className, const ACHAR* parentClassName, int dwgVer, int maintVer, int proxyFlags = 0, PseudoConstructor pseudoConstructor = NULL, const ACHAR* dxfName = NULL, const ACHAR* appName = NULL, AppNameChangeFuncPtr func = NULL);
7877
ACBASE_PORT AcRxClass* newAcRxClass(const ACHAR* className, const ACHAR* parentClassName, int dwgVer, int maintVer, int proxyFlags, AcRxObject* (*pseudoConstructor) (), const ACHAR* dxfName, const ACHAR* appName, AppNameChangeFuncPtr func, AcRxMemberCollectionConstructorPtr makeMembers, void* userData = NULL);

cppparser/test/e2e/test_master/skia/include/core/SkDeferredDisplayListRecorder.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ class SK_API SkDeferredDisplayListRecorder
4848
std::unique_ptr<SkDeferredDisplayList> detach();
4949
using PromiseImageTextureContext = void*;
5050
using PromiseImageTextureFulfillProc = sk_sp<SkPromiseImageTexture> (*) (PromiseImageTextureContext);
51-
;
5251
using PromiseImageTextureReleaseProc = void (*) (PromiseImageTextureContext);
53-
;
5452
using PromiseImageTextureDoneProc = void (*) (PromiseImageTextureContext);
55-
;
5653
enum class PromiseImageApiVersion {
5754
kLegacy, kNew
5855
};

0 commit comments

Comments
 (0)