Skip to content

Commit 829d644

Browse files
committed
1 parent 52035ab commit 829d644

12 files changed

+236
-0
lines changed

root/io/uniquePointer/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@ ROOTTEST_ADD_TEST(simpleRead
6565
OUTREF simpleRead.ref
6666
DEPENDS simpleWriteRead)
6767

68+
ROOTTEST_ADD_TEST(privacy-dict
69+
COMMAND ${ROOT_rootcling_CMD} -f privacy.dict.cc
70+
${CMAKE_CURRENT_SOURCE_DIR}/privacy.hh
71+
${CMAKE_CURRENT_SOURCE_DIR}/privacyLinkDef.h
72+
OUTREF privacyDict.oref
73+
ERRREF privacyDict.eref)
74+
75+
ROOTTEST_GENERATE_DICTIONARY(privacy privacy.hh LINKDEF privacyLinkDef.h)
76+
77+
ROOTTEST_ADD_TEST(privacy-load
78+
MACRO privacyLoad.C
79+
OUTREF privacyLoad.oref
80+
ERRREF privacyLoad.eref
81+
DEPENDS ${GENERATE_DICTIONARY_TEST})
82+
83+
ROOTTEST_ADD_TEST(privacy-interp
84+
MACRO privacyInterp.C
85+
OUTREF privacyInterp.oref
86+
ERRREF privacyInterp.eref)
87+
6888
ROOTTEST_GENERATE_REFLEX_DICTIONARY(classes classes.h SELECTION sel.xml)
6989

7090
ROOTTEST_ADD_TEST(simpleWriteRead

root/io/uniquePointer/ns_privacy.hh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#ifndef ns_privacy_hh
2+
#define ns_privacy_hh
3+
#include <iostream>
4+
#include <filesystem>
5+
#include <tuple>
6+
7+
namespace fs = std::filesystem;
8+
9+
namespace privacy
10+
{
11+
12+
class test
13+
{
14+
public:
15+
test() = default;
16+
~test() = default;;
17+
18+
private:
19+
fs::path path; ///<!
20+
fs::path persistent_path;
21+
};
22+
23+
class test1 {
24+
private:
25+
struct Inner { struct Most {}; };
26+
std::unique_ptr<Inner> unique_data;
27+
Inner *ptr_data;
28+
};
29+
30+
class test2 {
31+
private:
32+
test1 transient_data; ///<!
33+
test1 persistent_data;
34+
};
35+
36+
class test3 {
37+
private:
38+
struct Inner {};
39+
std::tuple<int, Inner> persistent_data;
40+
std::tuple<int, int, Inner> transient_data; ///<!
41+
};
42+
43+
class test4 {
44+
private:
45+
test3 transient_data; ///<!
46+
};
47+
48+
} // namespace privacy
49+
50+
#endif // ns_privacy_hh

root/io/uniquePointer/privacy.hh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifndef privacy_hh
2+
#define privacy_hh
3+
#include <iostream>
4+
#include <filesystem>
5+
#include <tuple>
6+
7+
namespace fs = std::filesystem;
8+
9+
class test
10+
{
11+
public:
12+
test() = default;
13+
~test() = default;;
14+
15+
private:
16+
fs::path path; ///<!
17+
fs::path persistent_path;
18+
};
19+
20+
class test1 {
21+
private:
22+
struct Inner { struct Most {}; };
23+
std::unique_ptr<Inner> unique_data;
24+
Inner *ptr_data;
25+
};
26+
27+
class test2 {
28+
private:
29+
test1 transient_data; ///<!
30+
test1 persistent_data;
31+
};
32+
33+
class test3 {
34+
private:
35+
struct Inner {};
36+
std::tuple<int, Inner> persistent_data;
37+
std::tuple<int, int, Inner> transient_data; ///<!
38+
};
39+
40+
class test4 {
41+
private:
42+
test3 transient_data; ///<!
43+
};
44+
45+
#endif

root/io/uniquePointer/privacyDict.eref

Whitespace-only changes.

root/io/uniquePointer/privacyDict.oref

Whitespace-only changes.

root/io/uniquePointer/privacyInterp.C

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "ns_privacy.hh"
2+
3+
int privacyInterp() {
4+
5+
const char *names[] = {
6+
"privacy::test",
7+
"privacy::test1",
8+
"privacy::test2",
9+
"privacy::test3",
10+
"privacy::test4"
11+
};
12+
13+
for(auto name : names) {
14+
auto cl = TClass::GetClass(name);
15+
if (!cl) {
16+
std::cout << "Could not find class " << name << "\n";
17+
return 1;
18+
}
19+
cl->GetStreamerInfo()->ls();
20+
}
21+
22+
return 0;
23+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Warning in <TStreamerInfo::Build>: privacy::test: filesystem::path has no streamer or dictionary, data member "persistent_path" will not be saved
2+
Error in <Load>: Could not declare alternate type for tuple<privacy::test1::Inner*,default_delete<privacy::test1::Inner> > since privacy::test1::Inner* (or one of its context) is private or protected
3+
Warning in <TClass::Init>: no dictionary for class tuple<privacy::test1::Inner*,default_delete<privacy::test1::Inner> > is available
4+
Error in <TStreamerInfo::Build>: privacy::test1: privacy::test1::Inner has no streamer or dictionary, data member unique_data will not be saved
5+
Error in <TStreamerInfo::Build>: privacy::test1: privacy::test1::Inner* has no streamer or dictionary, data member ptr_data will not be saved
6+
Warning in <TStreamerInfo::Build>: privacy::test2: privacy::test1 has no streamer or dictionary, data member "persistent_data" will not be saved
7+
Error in <Load>: Could not declare alternate type for tuple<int,privacy::test3::Inner> since privacy::test3::Inner (or one of its context) is private or protected
8+
Warning in <TClass::Init>: no dictionary for class tuple<int,privacy::test3::Inner> is available
9+
Warning in <TStreamerInfo::Build>: privacy::test3: tuple<int,privacy::test3::Inner> has no streamer or dictionary, data member "persistent_data" will not be saved
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
Processing /home/pcanal/root_working/code/root/roottest/root/io/uniquePointer/privacyInterp.C...
3+
4+
StreamerInfo for class: privacy::test, checksum=0xe856e707
5+
filesystem::path persistent_path offset= 40 type=62
6+
i= 0, persistent_path type= 62, offset= 40, len=1, method=0
7+
8+
StreamerInfo for class: privacy::test1, checksum=0x1ff89af2
9+
privacy::test1::Inner* unique_data offset= 0 type=69
10+
privacy::test1::Inner* ptr_data offset= 8 type=69
11+
i= 0, unique_data type= 69, offset= 0, len=1, method=0
12+
i= 1, ptr_data type= 69, offset= 8, len=1, method=0
13+
14+
StreamerInfo for class: privacy::test2, checksum=0x99ae9c61
15+
privacy::test1 persistent_data offset= 16 type=62
16+
i= 0, persistent_data type= 62, offset= 16, len=1, method=0
17+
18+
StreamerInfo for class: privacy::test3, checksum=0x929c0633
19+
tuple<int,privacy::test3::Inner> persistent_data offset= 0 type=62
20+
i= 0, persistent_data type= 62, offset= 0, len=1, method=0
21+
22+
StreamerInfo for class: privacy::test4, checksum=0xff367a2
23+
(int) 0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma link C++ class test+;
2+
3+
// We can generate the dictionary for this class even-though it has
4+
// data members whose types is private. There will be a clear error
5+
// message if the user request the StreamerInfo for this class.
6+
#pragma link C++ class test1+;
7+
8+
// Dictionary of private classes is not supported, uncommented this leads
9+
// to the expected warning message explaining this.
10+
// #pragma link C++ class test1::Inner+;
11+
12+
#pragma link C++ class test2+;
13+
#pragma link C++ class test3+;
14+
#pragma link C++ class test4+;
15+

root/io/uniquePointer/privacyLoad.C

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
int privacyLoad() {
2+
gSystem->Load("privacy");
3+
4+
const char *names[] = {
5+
"test",
6+
"test1",
7+
"test2",
8+
"test3",
9+
"test4"
10+
};
11+
12+
for(auto name : names) {
13+
auto cl = TClass::GetClass(name);
14+
if (!cl) {
15+
std::cout << "Could not find class " << name << "\n";
16+
return 1;
17+
}
18+
cl->GetStreamerInfo()->ls();
19+
}
20+
21+
return 0;
22+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Warning in <TStreamerInfo::Build>: test: filesystem::path has no streamer or dictionary, data member "persistent_path" will not be saved
2+
Error in <TStreamerInfo::Build>: test1: test1::Inner has no streamer or dictionary, data member unique_data will not be saved
3+
Error in <TStreamerInfo::Build>: test1: test1::Inner* has no streamer or dictionary, data member ptr_data will not be saved
4+
Error in <Load>: Could not declare alternate type for tuple<int,test3::Inner> since test3::Inner (or one of its context) is private or protected
5+
Warning in <TClass::Init>: no dictionary for class tuple<int,test3::Inner> is available
6+
Warning in <TStreamerInfo::Build>: test3: tuple<int,test3::Inner> has no streamer or dictionary, data member "persistent_data" will not be saved
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
Processing /home/pcanal/root_working/code/root/roottest/root/io/uniquePointer/privacyLoad.C...
3+
4+
StreamerInfo for class: test, checksum=0x621ea8bb
5+
filesystem::path persistent_path offset= 40 type=62
6+
i= 0, persistent_path type= 62, offset= 40, len=1, method=0
7+
8+
StreamerInfo for class: test1, checksum=0xde5f26fc
9+
test1::Inner* unique_data offset= 0 type=69
10+
test1::Inner* ptr_data offset= 8 type=69
11+
i= 0, unique_data type= 69, offset= 0, len=1, method=0
12+
i= 1, ptr_data type= 69, offset= 8, len=1, method=0
13+
14+
StreamerInfo for class: test2, checksum=0xb61be35d
15+
test1 persistent_data offset= 16 type=62
16+
i= 0, persistent_data type= 62, offset= 16, len=1, method=0
17+
18+
StreamerInfo for class: test3, checksum=0xdcf7ad57
19+
tuple<int,test3::Inner> persistent_data offset= 0 type=62
20+
i= 0, persistent_data type= 62, offset= 0, len=1, method=0
21+
22+
StreamerInfo for class: test4, checksum=0x34f6
23+
(int) 0

0 commit comments

Comments
 (0)