Skip to content

Commit e057653

Browse files
committed
integrating clang-mirror generated ids.
1 parent c6ffa14 commit e057653

5 files changed

Lines changed: 49 additions & 58 deletions

File tree

CxxTestUtils/inc/TestUtilsPerson.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ namespace test_utils
2222
static constexpr std::string_view ADDRESS = "221B Baker Street.";
2323
static constexpr std::string_view OCCUPATION = "Private Detective.";
2424

25-
static constexpr std::string_view class_ = "Person";
26-
static constexpr std::string_view str_createPtr = "createPtr";
27-
static constexpr std::string_view str_getProfile = "getProfile";
28-
static constexpr std::string_view str_createConst = "createConst";
29-
static constexpr std::string_view str_getDefaults = "getDefaults";
30-
static constexpr std::string_view str_getFirstName = "getFirstName";
31-
static constexpr std::string_view str_updateAddress = "updateAddress";
32-
static constexpr std::string_view str_updateLastName = "updateLastName";
33-
3425
static const bool assert_zero_instance_count();
3526

3627
static const std::string get_str_returned_on_call_getDefaults();

RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -220,33 +220,33 @@ namespace rtl_tests
220220
{
221221
auto _ = rtl::CxxMirror({
222222

223-
rtl::type().record<Person>(person::class_).build(),
223+
rtl::type().record<Person>(cxx::type::Person::id).build(),
224224

225225
rtl::type().member<Person>().constructor<std::string>().build(),
226226

227-
rtl::type().member<Person>().methodStatic(person::str_createPtr).build(&Person::createPtr),
227+
rtl::type().member<Person>().methodStatic(cxx::type::Person::fn::createPtr::id).build(&Person::createPtr),
228228

229-
rtl::type().member<Person>().method<void>(person::str_updateAddress).build(&Person::updateAddress),
229+
rtl::type().member<Person>().method<void>(cxx::type::Person::fn::updateAddress::id).build(&Person::updateAddress),
230230

231-
rtl::type().member<Person>().method<std::string>(person::str_updateAddress).build(&Person::updateAddress),
231+
rtl::type().member<Person>().method<std::string>(cxx::type::Person::fn::updateAddress::id).build(&Person::updateAddress),
232232

233-
rtl::type().member<Person>().method(person::str_getFirstName).build(&Person::getFirstName),
233+
rtl::type().member<Person>().method(cxx::type::Person::fn::getFirstName::id).build(&Person::getFirstName),
234234

235-
rtl::type().member<Person>().methodConst(person::str_updateLastName).build(&Person::updateLastName),
235+
rtl::type().member<Person>().methodConst(cxx::type::Person::fn::updateLastName::id).build(&Person::updateLastName),
236236

237-
rtl::type().member<Person>().methodConst<void>(person::str_updateAddress).build(&Person::updateAddress),
237+
rtl::type().member<Person>().methodConst<void>(cxx::type::Person::fn::updateAddress::id).build(&Person::updateAddress),
238238

239-
rtl::type().member<Person>().methodConst<std::string>(person::str_updateAddress).build(&Person::updateAddress),
239+
rtl::type().member<Person>().methodConst<std::string>(cxx::type::Person::fn::updateAddress::id).build(&Person::updateAddress),
240240

241-
rtl::type().member<Person>().methodStatic(person::str_getDefaults).build(&Person::getDefaults),
241+
rtl::type().member<Person>().methodStatic(cxx::type::Person::fn::getDefaults::id).build(&Person::getDefaults),
242242

243-
rtl::type().member<Person>().methodStatic(person::str_createConst).build(&Person::createConst),
243+
rtl::type().member<Person>().methodStatic(cxx::type::Person::fn::createConst::id).build(&Person::createConst),
244244

245-
rtl::type().member<Person>().methodStatic<void>(person::str_getProfile).build(&Person::getProfile),
245+
rtl::type().member<Person>().methodStatic<void>(cxx::type::Person::fn::getProfile::id).build(&Person::getProfile),
246246

247-
rtl::type().member<Person>().methodStatic<bool>(person::str_getProfile).build(&Person::getProfile),
247+
rtl::type().member<Person>().methodStatic<bool>(cxx::type::Person::fn::getProfile::id).build(&Person::getProfile),
248248

249-
rtl::type().member<Person>().methodStatic<std::string, size_t>(person::str_getProfile).build(&Person::getProfile)
249+
rtl::type().member<Person>().methodStatic<std::string, size_t>(cxx::type::Person::fn::getProfile::id).build(&Person::getProfile)
250250
});
251251

252252
std::cout << "\n [t4]\trtl_tests::InitMirror::reflectingPerson() ==> Done.\n";
@@ -272,20 +272,20 @@ namespace rtl_tests
272272
/* GCC fails to automatically identify the correct overloaded functor to pick. (non-const-lvalue-ref & rvalue as argument)
273273
we need to explicitly cast the functor like, static_cast<void(Animal::*)(std::string&)>(&Animal::setAnimalName).
274274
*/ rtl::type().member<Animal>()
275-
.method<std::string&>(cxx::type::Animal::fn::setAnimalName::id)
276-
.build(static_cast<void(Animal::*)(std::string&)>(&Animal::setAnimalName)), //overloaded method, taking non-const lvalue reference as argument.
275+
.method<std::string&>(cxx::type::Animal::fn::setAnimalName::id)
276+
.build(static_cast<void(Animal::*)(std::string&)>(&Animal::setAnimalName)), //overloaded method, taking non-const lvalue reference as argument.
277277

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

282282
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.
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.
285285

286286
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.
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.
289289

290290
});
291291

RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ namespace rtl_tests
2525
EXPECT_TRUE(err0 == error::None);
2626
ASSERT_FALSE(book.isEmpty());
2727

28-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
28+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
2929
ASSERT_TRUE(classPerson);
3030

31-
optional<Method> oUpdateLastName = classPerson->getMethod(person::str_updateLastName);
31+
optional<Method> oUpdateLastName = classPerson->getMethod(cxx::type::Person::fn::updateLastName::id);
3232
ASSERT_TRUE(oUpdateLastName);
3333
EXPECT_TRUE(oUpdateLastName->hasSignature<string>());
3434

@@ -85,10 +85,10 @@ namespace rtl_tests
8585
{
8686
auto testWithAllocOn = [](alloc alloc)->void
8787
{
88-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
88+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
8989
ASSERT_TRUE(classPerson);
9090

91-
optional<Method> oUpdateLastName = classPerson->getMethod(person::str_updateLastName);
91+
optional<Method> oUpdateLastName = classPerson->getMethod(cxx::type::Person::fn::updateLastName::id);
9292
ASSERT_TRUE(oUpdateLastName);
9393

9494
auto [err0, person] = classPerson->ctorT<std::string>()(alloc, person::FIRST_NAME.data());
@@ -128,14 +128,14 @@ namespace rtl_tests
128128
{
129129
auto testWithAllocOn = [](alloc alloc)->void
130130
{
131-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
131+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
132132
ASSERT_TRUE(classPerson);
133133

134134
auto [err0, person] = classPerson->ctorT<std::string>()(alloc, person::FIRST_NAME.data());
135135
EXPECT_TRUE(err0 == error::None);
136136
ASSERT_FALSE(person.isEmpty());
137137

138-
optional<Method> oUpdateAddress = classPerson->getMethod(person::str_updateAddress);
138+
optional<Method> oUpdateAddress = classPerson->getMethod(cxx::type::Person::fn::updateAddress::id);
139139
ASSERT_TRUE(oUpdateAddress);
140140
EXPECT_TRUE(oUpdateAddress->hasSignature<string>());
141141

@@ -167,10 +167,10 @@ namespace rtl_tests
167167
TEST(ConstMethodOverload, explicit_method_resolution__only_non_const_method_exists__call_on_returned_const_target)
168168
{
169169
{
170-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
170+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
171171
ASSERT_TRUE(classPerson);
172172

173-
optional<Method> createConstPerson = classPerson->getMethod(person::str_createConst);
173+
optional<Method> createConstPerson = classPerson->getMethod(cxx::type::Person::fn::createConst::id);
174174
ASSERT_TRUE(createConstPerson);
175175

176176
static_method<Return()> createPerson = createConstPerson->argsT().returnT();
@@ -181,7 +181,7 @@ namespace rtl_tests
181181
EXPECT_TRUE(err0 == error::None);
182182
ASSERT_FALSE(constPerson.isEmpty());
183183

184-
optional<Method> oGetFirstName = classPerson->getMethod(person::str_getFirstName);
184+
optional<Method> oGetFirstName = classPerson->getMethod(cxx::type::Person::fn::getFirstName::id);
185185
ASSERT_TRUE(oGetFirstName);
186186
EXPECT_TRUE(oGetFirstName->hasSignature<>());
187187

@@ -209,10 +209,10 @@ namespace rtl_tests
209209
TEST(ConstMethodOverload, explicit_method_resolution__only_non_const_method_exists__call_on_returned_const_pointer_target)
210210
{
211211
{
212-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
212+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
213213
ASSERT_TRUE(classPerson);
214214

215-
optional<Method> createConstPtrPerson = classPerson->getMethod(person::str_createPtr);
215+
optional<Method> createConstPtrPerson = classPerson->getMethod(cxx::type::Person::fn::createPtr::id);
216216
ASSERT_TRUE(createConstPtrPerson);
217217

218218
static_method<Return()> createPerson = createConstPtrPerson->argsT().returnT();
@@ -224,7 +224,7 @@ namespace rtl_tests
224224
EXPECT_TRUE(err0 == error::None);
225225
ASSERT_FALSE(constPersonPtr.isEmpty());
226226

227-
optional<Method> oGetFirstName = classPerson->getMethod(person::str_getFirstName);
227+
optional<Method> oGetFirstName = classPerson->getMethod(cxx::type::Person::fn::getFirstName::id);
228228
ASSERT_TRUE(oGetFirstName);
229229
EXPECT_TRUE(oGetFirstName->hasSignature<>());
230230

RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ namespace rtl_tests
264264

265265
TEST(ReflectionOpErrorCodeTests, static_method_call__error_SignatureMismatch)
266266
{
267-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
267+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
268268
ASSERT_TRUE(classPerson);
269269

270-
optional<Method> optGetProfile = classPerson->getMethod(person::str_getProfile);
270+
optional<Method> optGetProfile = classPerson->getMethod(cxx::type::Person::fn::getProfile::id);
271271
ASSERT_TRUE(optGetProfile);
272272
EXPECT_TRUE(optGetProfile->hasSignature<>()); //empty template params checks for zero arguments.
273273

@@ -303,7 +303,7 @@ namespace rtl_tests
303303
TEST(ReflectionOpErrorCodeTests, method_call_using_heap_object__error_TargetMismatch)
304304
{
305305
{
306-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
306+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
307307
ASSERT_TRUE(classPerson);
308308

309309
optional<Record> classBook = cxx::mirror().getRecord(cxx::type::Book::id);
@@ -331,7 +331,7 @@ namespace rtl_tests
331331
TEST(ReflectionOpErrorCodeTests, method_call_using_stack_object__error_TargetMismatch)
332332
{
333333
{
334-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
334+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
335335
ASSERT_TRUE(classPerson);
336336

337337
optional<Record> classBook = cxx::mirror().getRecord(cxx::type::Book::id);

RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ namespace rtl_tests
1515
{
1616
TEST(StaticMethods, unique_method_call)
1717
{
18-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
18+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
1919
ASSERT_TRUE(classPerson);
2020

21-
optional<Method> optGetDefaults = classPerson->getMethod(person::str_getDefaults);
21+
optional<Method> optGetDefaults = classPerson->getMethod(cxx::type::Person::fn::getDefaults::id);
2222
ASSERT_TRUE(optGetDefaults);
2323
EXPECT_TRUE(optGetDefaults->hasSignature<>()); //empty template params checks for zero arguments.
2424

@@ -38,10 +38,10 @@ namespace rtl_tests
3838

3939
TEST(StaticMethods, overload_method_void_call)
4040
{
41-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
41+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
4242
ASSERT_TRUE(classPerson);
4343

44-
optional<Method> optGetProfile = classPerson->getMethod(person::str_getProfile);
44+
optional<Method> optGetProfile = classPerson->getMethod(cxx::type::Person::fn::getProfile::id);
4545
ASSERT_TRUE(optGetProfile);
4646
EXPECT_TRUE(optGetProfile->hasSignature<>()); //empty template params checks for zero arguments.
4747

@@ -61,10 +61,10 @@ namespace rtl_tests
6161

6262
TEST(StaticMethods, overload_method_args_bool_call)
6363
{
64-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
64+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
6565
ASSERT_TRUE(classPerson);
6666

67-
optional<Method> optGetProfile = classPerson->getMethod(person::str_getProfile);
67+
optional<Method> optGetProfile = classPerson->getMethod(cxx::type::Person::fn::getProfile::id);
6868
ASSERT_TRUE(optGetProfile);
6969
EXPECT_TRUE(optGetProfile->hasSignature<bool>());
7070

@@ -95,11 +95,11 @@ namespace rtl_tests
9595

9696
TEST(StaticMethods, overload_method_args_string_size_t_call)
9797
{
98-
optional<Record> recOpt = cxx::mirror().getRecord(person::class_);
98+
optional<Record> recOpt = cxx::mirror().getRecord(cxx::type::Person::id);
9999
ASSERT_TRUE(recOpt.has_value());
100100

101101
const Record& classPerson = recOpt.value();
102-
optional<Method> methOpt = classPerson.getMethod(person::str_getProfile);
102+
optional<Method> methOpt = classPerson.getMethod(cxx::type::Person::fn::getProfile::id);
103103
ASSERT_TRUE(methOpt.has_value());
104104

105105
const Method& optGetProfile = methOpt.value();
@@ -124,10 +124,10 @@ namespace rtl_tests
124124

125125
TEST(StaticMethods, static_method_call_on_target_instance)
126126
{
127-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
127+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
128128
ASSERT_TRUE(classPerson);
129129

130-
optional<Method> getDefaultsOpt = classPerson->getMethod(person::str_getDefaults);
130+
optional<Method> getDefaultsOpt = classPerson->getMethod(cxx::type::Person::fn::getDefaults::id);
131131
ASSERT_TRUE(getDefaultsOpt);
132132
EXPECT_TRUE(getDefaultsOpt->hasSignature<>()); //empty template params checks for zero arguments.
133133
{
@@ -162,10 +162,10 @@ namespace rtl_tests
162162

163163
TEST(StaticMethods, static_method_call_on_target_instance_with_args)
164164
{
165-
optional<Record> classPerson = cxx::mirror().getRecord(person::class_);
165+
optional<Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
166166
ASSERT_TRUE(classPerson);
167167

168-
optional<Method> getProfileOpt = classPerson->getMethod(person::str_getProfile);
168+
optional<Method> getProfileOpt = classPerson->getMethod(cxx::type::Person::fn::getProfile::id);
169169
ASSERT_TRUE(getProfileOpt);
170170
EXPECT_TRUE((getProfileOpt->hasSignature<string, size_t>()));
171171

0 commit comments

Comments
 (0)