Skip to content

Commit 68c8826

Browse files
committed
integrating clang-mirror generated ids.
1 parent 1d52872 commit 68c8826

4 files changed

Lines changed: 39 additions & 62 deletions

File tree

CxxTestUtils/inc/TestUtilsAnimal.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ namespace test_utils
2424
static constexpr std::string_view FAMILY_NAME = "Great Ape";
2525
static constexpr std::string_view ZOO_KEEPER = "Donald McAdams";
2626

27-
static constexpr std::string_view class_ = "Animal";
28-
static constexpr std::string_view str_updateZooKeeper = "updateZooKeeper";
29-
static constexpr std::string_view str_setAnimalName = "setAnimalName";
30-
static constexpr std::string_view str_setFamilyName = "setFamilyName";
31-
static constexpr std::string_view str_getFamilyName = "getFamilyName";
32-
3327
static const bool assert_zero_instance_count();
3428

3529
static const bool test_method_setAnimalName_rvalue_args(const rtl::RObject& pInstance);

RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -257,53 +257,36 @@ namespace rtl_tests
257257
{
258258
auto _ = rtl::CxxMirror({
259259

260-
rtl::type().record<Animal>(animal::class_).build(),
260+
rtl::type().record<Animal>(cxx::type::Animal::id).build(),
261261

262262
rtl::type().member<Animal>().constructor<std::string>().build(),
263263

264-
rtl::type().member<Animal>().method(animal::str_setFamilyName).build(&Animal::setFamilyName),
264+
rtl::type().member<Animal>().method(cxx::type::Animal::fn::setFamilyName::id).build(&Animal::setFamilyName),
265265

266-
rtl::type().member<Animal>().methodConst(animal::str_getFamilyName).build(&Animal::getFamilyName),
266+
rtl::type().member<Animal>().methodConst(cxx::type::Animal::fn::getFamilyName::id).build(&Animal::getFamilyName),
267267

268-
rtl::type().member<Animal>().method<const std::string&>(animal::str_setAnimalName).build(&Animal::setAnimalName),
268+
rtl::type().member<Animal>().method<const std::string&>(cxx::type::Animal::fn::setFamilyName::id).build(&Animal::setAnimalName),
269269

270-
rtl::type().member<Animal>().methodStatic<const std::string&>(animal::str_updateZooKeeper).build(&Animal::updateZooKeeper),
270+
rtl::type().member<Animal>().methodStatic<const std::string&>(cxx::type::Animal::fn::updateZooKeeper::id).build(&Animal::updateZooKeeper),
271271

272-
#if defined(__GNUC__) && !defined(__clang__)
273-
/* GCC fails to automatically identify the correct overloaded functor to pick. (non-const-lvalue-ref & rvalue as argument)
274-
we need to explicitly cast the functor like, static_cast<void(Animal::*)(std::string&)>(&Animal::setAnimalName).
275-
*/ rtl::type().member<Animal>()
276-
.method<std::string&>(animal::str_setAnimalName)
277-
.build(static_cast<void(Animal::*)(std::string&)>(&Animal::setAnimalName)), //overloaded method, taking non-const lvalue reference as argument.
272+
/* GCC fails to automatically identify the correct overloaded functor to pick. (non-const-lvalue-ref & rvalue as argument)
273+
we need to explicitly cast the functor like, static_cast<void(Animal::*)(std::string&)>(&Animal::setAnimalName).
274+
*/ rtl::type().member<Animal>()
275+
.method<std::string&>(cxx::type::Animal::fn::setFamilyName::id)
276+
.build(static_cast<void(Animal::*)(std::string&)>(&Animal::setAnimalName)), //overloaded method, taking non-const lvalue reference as argument.
278277

279-
rtl::type().member<Animal>()
280-
.method<std::string&&>(animal::str_setAnimalName)
281-
.build(static_cast<void(Animal::*)(std::string&&)>(&Animal::setAnimalName)), //overloaded method, taking rvalue reference as argument.
278+
rtl::type().member<Animal>()
279+
.method<std::string&&>(cxx::type::Animal::fn::setFamilyName::id)
280+
.build(static_cast<void(Animal::*)(std::string&&)>(&Animal::setAnimalName)), //overloaded method, taking rvalue reference as argument.
282281

283-
rtl::type().member<Animal>()
284-
.methodStatic<std::string&>(animal::str_updateZooKeeper)
285-
.build(static_cast<std::string(*)(std::string&)>(&Animal::updateZooKeeper)), //static method, taking non-const lvalue reference as argument.
282+
rtl::type().member<Animal>()
283+
.methodStatic<std::string&>(cxx::type::Animal::fn::updateZooKeeper::id)
284+
.build(static_cast<std::string(*)(std::string&)>(&Animal::updateZooKeeper)), //static method, taking non-const lvalue reference as argument.
286285

287-
rtl::type().member<Animal>()
288-
.methodStatic<std::string&&>(animal::str_updateZooKeeper)
289-
.build(static_cast<std::string(*)(std::string&&)>(&Animal::updateZooKeeper)), //static method, taking rvalue reference as argument.
290-
#else
291-
rtl::type().member<Animal>()
292-
.method<std::string&>(animal::str_setAnimalName)
293-
.build(&Animal::setAnimalName),
286+
rtl::type().member<Animal>()
287+
.methodStatic<std::string&&>(cxx::type::Animal::fn::updateZooKeeper::id)
288+
.build(static_cast<std::string(*)(std::string&&)>(&Animal::updateZooKeeper)), //static method, taking rvalue reference as argument.
294289

295-
rtl::type().member<Animal>()
296-
.method<std::string&&>(animal::str_setAnimalName)
297-
.build(&Animal::setAnimalName),
298-
299-
rtl::type().member<Animal>()
300-
.methodStatic<std::string&>(animal::str_updateZooKeeper)
301-
.build(&Animal::updateZooKeeper),
302-
303-
rtl::type().member<Animal>()
304-
.methodStatic<std::string&&>(animal::str_updateZooKeeper)
305-
.build(&Animal::updateZooKeeper)
306-
#endif
307290
});
308291

309292
std::cout << "\n [t3]\trtl_tests::InitMirror::reflectingAnimal() ==> Done.\n";

RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ namespace rtl_tests
253253
{
254254
{
255255
// Retrieve the metadata for the "Animal" class.
256-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
256+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
257257
ASSERT_TRUE(classAnimal);
258258

259259
// Create an instance of the "Animal" class.
@@ -262,7 +262,7 @@ namespace rtl_tests
262262
ASSERT_FALSE(animal.isEmpty());
263263

264264
// Retrieve the "setAnimalName" method.
265-
optional<Method> oSetAnimalName = classAnimal->getMethod(animal::str_setAnimalName);
265+
optional<Method> oSetAnimalName = classAnimal->getMethod(cxx::type::Animal::fn::setFamilyName::id);
266266
ASSERT_TRUE(oSetAnimalName);
267267
// Verify that the method has the correct signature for a const L-value reference.
268268
EXPECT_TRUE((oSetAnimalName->hasSignature<const std::string&>()));

RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace rtl_tests
4141
{
4242
{
4343
// Retrieve the metadata for the "Animal" class.
44-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
44+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
4545
ASSERT_TRUE(classAnimal);
4646

4747
// Create an instance of the "Animal" class.
@@ -50,7 +50,7 @@ namespace rtl_tests
5050
ASSERT_FALSE(animal.isEmpty());
5151

5252
// Retrieve the "setAnimalName" method.
53-
optional<Method> oSetAnimalName = classAnimal->getMethod(animal::str_setAnimalName);
53+
optional<Method> oSetAnimalName = classAnimal->getMethod(cxx::type::Animal::fn::setFamilyName::id);
5454
ASSERT_TRUE(oSetAnimalName);
5555
// Verify that the method has the correct signature for an R-value reference.
5656
EXPECT_TRUE((oSetAnimalName->hasSignature<std::string&&>()));
@@ -83,7 +83,7 @@ namespace rtl_tests
8383
{
8484
{
8585
// Retrieve the metadata for the "Animal" class.
86-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
86+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
8787
ASSERT_TRUE(classAnimal);
8888

8989
// Create an instance of the "Animal" class.
@@ -92,7 +92,7 @@ namespace rtl_tests
9292
ASSERT_FALSE(animal.isEmpty());
9393

9494
// Retrieve the "setAnimalName" method.
95-
optional<Method> oSetAnimalName = classAnimal->getMethod(animal::str_setAnimalName);
95+
optional<Method> oSetAnimalName = classAnimal->getMethod(cxx::type::Animal::fn::setFamilyName::id);
9696
ASSERT_TRUE(oSetAnimalName);
9797
// Verify that the method has the correct signature for a non-const L-value reference.
9898
EXPECT_TRUE((oSetAnimalName->hasSignature<std::string&>()));
@@ -126,7 +126,7 @@ namespace rtl_tests
126126
{
127127
{
128128
// Retrieve the metadata for the "Animal" class.
129-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
129+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
130130
ASSERT_TRUE(classAnimal);
131131

132132
// Create an instance of the "Animal" class.
@@ -135,7 +135,7 @@ namespace rtl_tests
135135
ASSERT_FALSE(animal.isEmpty());
136136

137137
// Retrieve the "setAnimalName" method.
138-
optional<Method> oSetAnimalName = classAnimal->getMethod(animal::str_setAnimalName);
138+
optional<Method> oSetAnimalName = classAnimal->getMethod(cxx::type::Animal::fn::setFamilyName::id);
139139
ASSERT_TRUE(oSetAnimalName);
140140
// Verify that the method has the correct signature for a const L-value reference.
141141
EXPECT_TRUE((oSetAnimalName->hasSignature<const std::string&>()));
@@ -170,7 +170,7 @@ namespace rtl_tests
170170
{
171171
{
172172
// Retrieve the metadata for the "Animal" class.
173-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
173+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
174174
ASSERT_TRUE(classAnimal);
175175

176176
// Create an instance of the "Animal" class.
@@ -179,7 +179,7 @@ namespace rtl_tests
179179
ASSERT_FALSE(animal.isEmpty());
180180

181181
// Retrieve the "setAnimalName" method.
182-
optional<Method> oSetAnimalName = classAnimal->getMethod(animal::str_setAnimalName);
182+
optional<Method> oSetAnimalName = classAnimal->getMethod(cxx::type::Animal::fn::setFamilyName::id);
183183
ASSERT_TRUE(oSetAnimalName);
184184
// Verify that the method has the correct signature for an R-value reference.
185185
EXPECT_TRUE((oSetAnimalName->hasSignature<std::string&&>()));
@@ -212,7 +212,7 @@ namespace rtl_tests
212212
{
213213
{
214214
// Retrieve the metadata for the "Animal" class.
215-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
215+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
216216
ASSERT_TRUE(classAnimal);
217217

218218
// Create an instance of the "Animal" class.
@@ -221,7 +221,7 @@ namespace rtl_tests
221221
ASSERT_FALSE(animal.isEmpty());
222222

223223
// Retrieve the "setAnimalName" method.
224-
optional<Method> oSetAnimalName = classAnimal->getMethod(animal::str_setAnimalName);
224+
optional<Method> oSetAnimalName = classAnimal->getMethod(cxx::type::Animal::fn::setFamilyName::id);
225225
ASSERT_TRUE(oSetAnimalName);
226226
// Verify that the method has the correct signature for a non-const L-value reference.
227227
EXPECT_TRUE((oSetAnimalName->hasSignature<std::string&>()));
@@ -254,7 +254,7 @@ namespace rtl_tests
254254
{
255255
{
256256
// Retrieve the metadata for the "Animal" class.
257-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
257+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
258258
ASSERT_TRUE(classAnimal);
259259

260260
// Create an instance of the "Animal" class.
@@ -263,7 +263,7 @@ namespace rtl_tests
263263
ASSERT_FALSE(animal.isEmpty());
264264

265265
// Retrieve the "setAnimalName" method.
266-
optional<Method> oSetAnimalName = classAnimal->getMethod(animal::str_setAnimalName);
266+
optional<Method> oSetAnimalName = classAnimal->getMethod(cxx::type::Animal::fn::setFamilyName::id);
267267
ASSERT_TRUE(oSetAnimalName);
268268
// Verify that the method has the correct signature for a const L-value reference.
269269
EXPECT_TRUE((oSetAnimalName->hasSignature<const std::string&>()));
@@ -290,10 +290,10 @@ namespace rtl_tests
290290
TEST(PerfectForwardingTest, static_fn_overload_resolution_with_rvalue_ref)
291291
{
292292
{
293-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
293+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
294294
ASSERT_TRUE(classAnimal);
295295

296-
optional<Method> oUpdateZooKeeper = classAnimal->getMethod(animal::str_updateZooKeeper);
296+
optional<Method> oUpdateZooKeeper = classAnimal->getMethod(cxx::type::Animal::fn::updateZooKeeper::id);
297297
ASSERT_TRUE(oUpdateZooKeeper);
298298

299299
const auto& isValid = oUpdateZooKeeper->hasSignature<std::string&&>();
@@ -324,10 +324,10 @@ namespace rtl_tests
324324
TEST(PerfectForwardingTest, static_fn_overload_resolution_with_const_lvalue_ref)
325325
{
326326
{
327-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
327+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
328328
ASSERT_TRUE(classAnimal);
329329

330-
optional<Method> oUpdateZooKeeper = classAnimal->getMethod(animal::str_updateZooKeeper);
330+
optional<Method> oUpdateZooKeeper = classAnimal->getMethod(cxx::type::Animal::fn::updateZooKeeper::id);
331331
ASSERT_TRUE(oUpdateZooKeeper);
332332

333333
const auto& isValid = oUpdateZooKeeper->hasSignature<const std::string&>();
@@ -354,10 +354,10 @@ namespace rtl_tests
354354
TEST(PerfectForwardingTest, static_fn_overload_resolution_with_non_const_lvalue_ref)
355355
{
356356
{
357-
optional<Record> classAnimal = cxx::mirror().getRecord(animal::class_);
357+
optional<Record> classAnimal = cxx::mirror().getRecord(cxx::type::Animal::id);
358358
ASSERT_TRUE(classAnimal);
359359

360-
optional<Method> oUpdateZooKeeper = classAnimal->getMethod(animal::str_updateZooKeeper);
360+
optional<Method> oUpdateZooKeeper = classAnimal->getMethod(cxx::type::Animal::fn::updateZooKeeper::id);
361361
ASSERT_TRUE(oUpdateZooKeeper);
362362

363363
const auto& isValid = oUpdateZooKeeper->hasSignature<const std::string&>();

0 commit comments

Comments
 (0)