WIP Refactoring alias template resolution based on clang canonical representation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <functional>
|
||||
#include <ios>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
@@ -27,6 +28,13 @@ template <typename T, typename P> struct A {
|
||||
};
|
||||
|
||||
template <typename T> using AString = A<T, std::string>;
|
||||
template <typename T> using AStringPtr = A<T, std::unique_ptr<std::string>>;
|
||||
|
||||
template <class T> using VectorPtr = std::unique_ptr<std::vector<T>>;
|
||||
template <class T> using APtr = std::unique_ptr<A<double, T>>;
|
||||
template <class T> using ASharedPtr = std::shared_ptr<A<double,T>>;
|
||||
template <class T, class U> using AAPtr =
|
||||
std::unique_ptr<std::pair<A<double,T>, A<long,U>>>;
|
||||
|
||||
template <typename... T> using GeneralCallback = std::function<void(T..., int)>;
|
||||
using VoidCallback = GeneralCallback<>;
|
||||
@@ -42,12 +50,19 @@ using AIntString = AString<int>;
|
||||
using AStringString = AString<std::string>;
|
||||
using BStringString = AStringString;
|
||||
|
||||
template <typename T> using PairPairBA = std::pair<std::pair<B, A<long,T>>, long>;
|
||||
|
||||
class R {
|
||||
// clang-uml: tinst A<T, std::string>
|
||||
PairPairBA<bool> bapair;
|
||||
|
||||
APtr<bool> abool;
|
||||
AAPtr<bool,float> aboolfloat;
|
||||
ASharedPtr<float> afloat;
|
||||
A<bool, std::string> boolstring;
|
||||
AString<float> floatstring;
|
||||
AStringPtr<float> floatstring;
|
||||
AIntString intstring;
|
||||
AStringString stringstring;
|
||||
BStringString bstringstring;
|
||||
|
||||
protected:
|
||||
BVector bs;
|
||||
@@ -56,6 +71,7 @@ public:
|
||||
BVector2 bs2;
|
||||
GeneralCallback<AIntString> cb;
|
||||
VoidCallback vcb;
|
||||
VectorPtr<B> vps;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,31 +36,53 @@ TEST_CASE("t00014", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T,P"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T,std::string"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T,std::unique_ptr<std::string>"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "double,T"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "long,U"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "long,T"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "long,bool"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "double,bool"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "long,float"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "double,float"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "bool,std::string"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("AString", "float"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("AString", "int"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("AString", "std::string"));
|
||||
REQUIRE_THAT(puml, IsClass(_A("B")));
|
||||
|
||||
REQUIRE_THAT(
|
||||
puml, !IsClassTemplate("std::std::function", "void(T...,int),int)"));
|
||||
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("A<T,P>"), _A("A<T,std::string>")));
|
||||
REQUIRE_THAT(
|
||||
puml, IsInstantiation(_A("A<T,std::string>"), _A("AString<float>")));
|
||||
REQUIRE_THAT(
|
||||
puml, IsInstantiation(_A("A<T,std::string>"), _A("AString<int>")));
|
||||
REQUIRE_THAT(
|
||||
puml, !IsInstantiation(_A("AString<int>"), _A("AString<int>")));
|
||||
REQUIRE_THAT(puml,
|
||||
IsInstantiation(_A("A<T,std::string>"), _A("AString<std::string>")));
|
||||
REQUIRE_THAT(puml,
|
||||
!IsInstantiation(
|
||||
_A("AString<std::string>"), _A("AString<std::string>")));
|
||||
REQUIRE_THAT(
|
||||
puml, IsAggregation(_A("R"), _A("A<bool,std::string>"), "-boolstring"));
|
||||
REQUIRE_THAT(
|
||||
puml, IsAggregation(_A("R"), _A("AString<float>"), "-floatstring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "#bs"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "+bs2"));
|
||||
// REQUIRE_THAT(puml, IsInstantiation(_A("A<T,P>"), _A("A<T,std::string>")));
|
||||
// REQUIRE_THAT(
|
||||
// puml, IsInstantiation(_A("A<T,std::string>"), _A("AString<float>")));
|
||||
// REQUIRE_THAT(
|
||||
// puml, IsInstantiation(_A("A<T,std::string>"), _A("AString<int>")));
|
||||
// REQUIRE_THAT(
|
||||
// puml, !IsInstantiation(_A("AString<int>"), _A("AString<int>")));
|
||||
// REQUIRE_THAT(puml,
|
||||
// IsInstantiation(_A("A<T,std::string>"), _A("AString<std::string>")));
|
||||
// REQUIRE_THAT(
|
||||
// puml, IsInstantiation(_A("A<T,std::string>"), _A("A<double,bool>")));
|
||||
//
|
||||
// REQUIRE_THAT(puml,
|
||||
// !IsInstantiation(
|
||||
// _A("AString<std::string>"), _A("AString<std::string>")));
|
||||
|
||||
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "+vps"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "-bapair"));
|
||||
|
||||
// REQUIRE_THAT(
|
||||
// puml, IsAggregation(_A("R"), _A("A<bool,std::string>"), "-boolstring"));
|
||||
//
|
||||
//
|
||||
//
|
||||
// REQUIRE_THAT(
|
||||
// puml, IsAggregation(_A("R"), _A("A<bool,std::string>"), "-boolstring"));
|
||||
// REQUIRE_THAT(
|
||||
// puml, IsAggregation(_A("R"), _A("AString<float>"), "-floatstring"));
|
||||
// REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "#bs"));
|
||||
// REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "+bs2"));
|
||||
// REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "+vsp"));
|
||||
// REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A<double,bool>"), "+bvsp"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
Reference in New Issue
Block a user