Skip to content

Commit 392d56c

Browse files
Merge branch 'return-restprocess-object-refactor' of github.com:highperformancecoder/classdesc into return-restprocess-object-refactor
2 parents 656459c + ed578a9 commit 392d56c

22 files changed

+237
-104
lines changed

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ CPLUSPLUS=g++
55
# -I/usr/include/tirpc is needed for Fedora
66
FLAGS=-g -I. -I/usr/include/tirpc
77

8-
CDHEADERS=multiArray object poly polyBase polyRESTProcess polyRESTProcessBase polyXMLBase RESTProcess_base signature stringKeyMap xml_pack_base xml_unpack_base
9-
DESCRIPTORS=dump pack json_pack random_init RESTProcess xml_pack typeName
8+
CDHEADERS=multiArray object poly polyBase polyRESTProcess polyRESTProcessBase polyXMLBase RESTProcess_base signature stringKeyMap xml_pack_base xml_unpack_base xml_common
9+
DESCRIPTORS=dump pack json_pack random_init RESTProcess xml_pack xsd_generate typeName
1010
CDFILES=$(foreach d,$(DESCRIPTORS),$(foreach h,$(CDHEADERS),$(h)-$(d).cd))
1111

1212
ifdef GCOV
@@ -206,6 +206,9 @@ $(DESCRIPTORS:%=%-allCDs.h): Makefile createCDs.sh
206206
%-xml_pack.cd: %.h classdesc
207207
./classdesc -nodef -onbase -respect_private -i $< xml_pack xml_unpack >$@
208208

209+
%-xsd_generate.cd: %.h classdesc
210+
./classdesc -nodef -onbase -respect_private -i $< xsd_generate >$@
211+
209212
%-random_init.cd: %.h classdesc
210213
./classdesc -nodef -onbase -i $< random_init >$@
211214

RESTProcess-allCDs.h

+3
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@
3636
#ifdef CLASSDESC_XML_UNPACK_BASE_H
3737
#include "xml_unpack_base-RESTProcess.cd"
3838
#endif
39+
#ifdef CLASSDESC_XML_COMMON_H
40+
#include "xml_common-RESTProcess.cd"
41+
#endif
3942
#endif

RESTProcessExample/RESTProcessExample.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct Bar: Foo
9090
{
9191
enum BarE {a, b};
9292
Bar(const Bar&)=delete;
93-
int f;
93+
int f=20;
9494
EnumFoo barfoo;
9595
std::vector<Foo> vFoo;
9696
std::map<std::string,Foo> mFoo;
@@ -101,7 +101,7 @@ struct Bar: Foo
101101
BarE barE() const {return a;}
102102
GlobE globE() const {return ga;}
103103
Bar() {}
104-
Bar(int i): Foo(i), f(20), barfoo(eb), vFoo(3,1) {mFoo["foo"]=Foo(2);}
104+
Bar(int i): Foo(i), barfoo(eb), vFoo(3,1) {mFoo["foo"]=Foo(2);}
105105

106106
// overload triggers bug
107107
void rvalueRef(Foo&& f) {}
@@ -164,7 +164,7 @@ struct IPoly: public PolyRESTProcess<IPoly> {};
164164

165165
struct Poly: public PolyRESTProcess<Poly, IPoly>
166166
{
167-
int a;
167+
int a=5;
168168
};
169169

170170
// root type

RESTProcessExample/RESTProcessExpected.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/root=>{"bar":{"a":0.1,"af":0.2000000029802322,"b":3,"barfoo":"eb","bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","f":20,"h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"mFoo":[{"first":"foo","second":{"a":0.1,"af":0.2000000029802322,"b":2,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]}}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vFoo":[{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]}],"vs":[" hello"," hello"]},"bar1":{"barfoo":"ec","f":{"a":0.1,"af":0.2000000029802322,"b":2,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},"fp":{"a":0,"af":0,"b":0,"bf":false,"bt":false,"c":"","c1":[],"ch":"\u0000","d":[0,0,0],"d1":[[0,0],[0,0],[0,0]],"ef":"ea","h":[],"l":[],"llex":[],"m":[],"m_rotation":0,"sef":{},"sm":{},"ss":[],"um":[],"vs":[]},"g":2,"vFoo":[{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]}]},"defaultless":{},"sbar":{"a":0,"af":0,"b":0,"barfoo":"ea","bf":false,"bt":false,"c":"","c1":[],"ch":"\u0000","d":[0,0,0],"d1":[[0,0],[0,0],[0,0]],"ef":"ea","f":0,"h":[],"l":[],"llex":[],"m":[],"mFoo":[],"m_rotation":0,"sef":{},"sm":{},"ss":[],"um":[],"vFoo":[],"vs":[]},"spoly":{"base___classdesc__PolyRESTProcessBase":{}}}
1+
/root=>{"bar":{"a":0.1,"af":0.2000000029802322,"b":3,"barfoo":"eb","bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","f":20,"h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"mFoo":[{"first":"foo","second":{"a":0.1,"af":0.2000000029802322,"b":2,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]}}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vFoo":[{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]}],"vs":[" hello"," hello"]},"bar1":{"barfoo":"ec","f":{"a":0.1,"af":0.2000000029802322,"b":2,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},"fp":{"a":0,"af":0,"b":0,"bf":false,"bt":false,"c":"","c1":[],"ch":"\u0000","d":[0,0,0],"d1":[[0,0],[0,0],[0,0]],"ef":"ea","h":[],"l":[],"llex":[],"m":[],"m_rotation":0,"sef":{},"sm":{},"ss":[],"um":[],"vs":[]},"g":2,"vFoo":[{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]},{"a":0.1,"af":0.2000000029802322,"b":1,"bf":false,"bt":true,"c":"\r hello & 123 ","c1":["\r","\r"],"ch":"M","d":[0,1,2],"d1":[[0,1],[2,3],[4,5]],"ef":"ea","h":[2,2,2],"l":[2,2,2],"llex":[["hello","hello"],["hello","hello"]],"m":[{"first":0,"second":5},{"first":3,"second":2}],"m_rotation":0,"sef":"ea","sm":{},"ss":[],"um":[],"vs":[" hello"," hello"]}]},"defaultless":{},"sbar":{"a":0,"af":0,"b":0,"barfoo":"ea","bf":false,"bt":false,"c":"","c1":[],"ch":"\u0000","d":[0,0,0],"d1":[[0,0],[0,0],[0,0]],"ef":"ea","f":20,"h":[],"l":[],"llex":[],"m":[],"mFoo":[],"m_rotation":0,"sef":{},"sm":{},"ss":[],"um":[],"vFoo":[],"vs":[]},"spoly":{"base___classdesc__PolyRESTProcessBase":{}}}
22
/root/bar/csi=>20
33
/root/bar/csi=>Exception: attempt to alter a const variable
44
/root/bar/si=>0

RESTProcessExample/example.py

+24-17
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def expectThrow(f):
5757
assert root.bar.c()=='hello world'
5858

5959
assert root.bar.c1()==['\r','\r']
60-
assert root.bar.c1[0]()=='\r'
60+
assert root.bar.c1[0]=='\r'
6161
root.bar.c1[0]='x'
62-
assert root.bar.c1[0]()=='x'
62+
assert root.bar.c1[0]=='x'
6363

6464
assert root.bar.ef()=='ea'
6565
assert root.bar.ef('eb')=='eb'
@@ -72,21 +72,21 @@ def expectThrow(f):
7272

7373
assert root.bar.d()==[0,1,2]
7474
assert len(root.bar.d)==3
75-
assert root.bar.d[1]()==1
75+
assert root.bar.d[1]==1
7676
root.bar.d[1]=5
77-
assert root.bar.d[1]()==5
77+
assert root.bar.d[1]==5
7878

7979
assert len(root.bar.d1)==2
8080
assert root.bar.d1[1]()==[3,4,5]
8181
root.bar.d1[1]=[6,7,8]
8282
assert root.bar.d1[1]()==[6,7,8]
8383
assert root.bar.d1()==[[0,1,2],[6,7,8]]
8484
root.bar.d1[1][2]=10
85-
assert root.bar.d1[1][2]()==10
85+
assert root.bar.d1[1][2]==10
8686
assert root.bar.h()==[2,2,2]
87-
assert root.bar.h[1]()==2
87+
assert root.bar.h[1]==2
8888
root.bar.h[1]=3
89-
assert root.bar.h[1]()==3
89+
assert root.bar.h[1]==3
9090
root.bar.h.insert(5)
9191
assert root.bar.h()==[2,3,2,5]
9292
root.bar.h.erase(1)
@@ -96,25 +96,25 @@ def expectThrow(f):
9696
assert root.bar.h._list()==[".@elem",".@elemNoThrow",".@erase",".@insert",".@size"]
9797

9898
assert root.bar.l()==[2,2,2]
99-
assert root.bar.l[1]()==2
99+
assert root.bar.l[1]==2
100100
root.bar.l[1]=3
101-
assert root.bar.l[1]()==3
101+
assert root.bar.l[1]==3
102102
root.bar.l.insert(5)
103103
assert root.bar.l()==[2,3,2,5]
104104
assert root.bar.l([2,2,2,2])()==[2,2,2,2]
105105

106106
assert root.bar.m()==[{"first":0,"second":5},{"first":3,"second":2}]
107107
assert len(root.bar.m)==2
108108
assert root.bar.m._signature()==[{"args":[],"ret":"std::map<int,int>"},{"args":["std::map<int,int>"],"ret":"std::map<int,int>"}]
109-
assert root.bar.m[3]()==2
109+
assert root.bar.m[3]==2
110110
root.bar.m[3]=5
111-
assert root.bar.m[3]()==5
111+
assert root.bar.m[3]==5
112112

113113
root.bar.m.insert({"first":1,"second":2})
114-
assert root.bar.m[1]()==2
114+
assert root.bar.m[1]==2
115115
assert root.bar.m.contains(1)
116116
root.bar.m[10]=2
117-
assert root.bar.m[10]()==2
117+
assert root.bar.m[10]==2
118118
assert root.bar.m.contains(10)
119119
assert root.bar.m._type()=="std::map<int,int>"
120120
assert root.bar.m._list()==[".@elem",".@elemNoThrow",".@erase",".@insert",".@keys",".@size"]
@@ -129,14 +129,14 @@ def expectThrow(f):
129129
root.bar.um.insert({"first":1,"second":3})
130130
assert root.bar.um()==[{"first":1,"second":3}]
131131
root.bar.um[1]=5
132-
assert root.bar.um[1]()==5
132+
assert root.bar.um[1]==5
133133

134134
assert root.bar.llex()==[["hello","hello"],["hello","hello"]]
135135
root.bar.llex[1]=["baa","baa","blacksheep"]
136136
assert root.bar.llex[1]()==["baa","baa","blacksheep"]
137137
assert root.bar.llex()==[["hello","hello"],["baa","baa","blacksheep"]]
138138
assert root.bar.llex._signature()==[{"args":[],"ret":"std::list<std::list<std::string>>"},{"args":["std::list<std::list<std::string>>"],"ret":"std::list<std::list<std::string>>"}]
139-
assert root.bar.llex[1][1]()=="baa"
139+
assert root.bar.llex[1][1]=="baa"
140140

141141
# Should fail
142142
expectThrow(lambda: root.bar.iex())
@@ -161,9 +161,12 @@ def expectThrow(f):
161161
assert root.bar1.fooRef().b()==2
162162
assert root.bar1.f.name()=='Foo'
163163

164-
assert root.bar1.vFoo[1]._properties()['b']==1
164+
assert root.bar1.vFoo[1]()['b']==1
165+
assert root.bar1.vFoo[1].b()==1
165166
expectThrow(lambda: root.bar1.vFoo[10])
166167

168+
assert root.bar.mFoo['foo'].b()==2
169+
167170
assert root.bar1.foo().b(3)==3
168171
assert root.bar1.foo().b()==2
169172
assert root.bar1.fooRef().b(3)==3
@@ -191,7 +194,7 @@ def expectThrow(f):
191194
assert root.bar.sm({"foo":1,"bar":2})._properties()=={"foo":1,"bar":2}
192195
assert root.bar.sm()=={"foo":1,"bar":2}
193196
assert root.bar.sm({"foo":1,"foobar":3})._properties()=={"foo":1,"foobar":3}
194-
assert root.bar.sm['foo']()==1
197+
assert root.bar.sm['foo']==1
195198
assert root.bar.sm.contains("foobar")
196199
root.bar.sm.erase("foobar")
197200
assert not root.bar.sm.contains("foobar")
@@ -217,3 +220,7 @@ def expectThrow(f):
217220
fb=FooBar1()
218221
assert foo.b()==2
219222
assert fb.f.b()==0
223+
224+
# shared pointer support
225+
assert root.sbar.f()==20
226+
assert root.spoly.a()==5

RESTProcess_base.h

+35-10
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ namespace classdesc
333333
}
334334

335335
template <class E>
336-
typename enable_if<is_enum<E>,void>::T
336+
typename enable_if<And<is_enum<E>,Not<is_const<E>>>, void>::T
337337
convert(E& x, const REST_PROCESS_BUFFER& j)
338338
{
339339
string tmp; j>>tmp;
@@ -343,7 +343,7 @@ namespace classdesc
343343
template <class X>
344344
void convert(const X* x, const REST_PROCESS_BUFFER& j)
345345
{}
346-
346+
347347
template <class F, int N> struct DefineFunctionArgTypes;
348348

349349
/// REST processor registry
@@ -393,7 +393,8 @@ namespace classdesc
393393
functs->overloadedFunctions.emplace_back(rp);
394394
i->second=functs;
395395
}
396-
else {assert(false);/* should not be here */}
396+
else // overloading something that is not a function
397+
i->second.reset(rp);
397398
}
398399

399400
inline RPPtr process(const std::string& query, const REST_PROCESS_BUFFER& jin);
@@ -884,7 +885,14 @@ namespace classdesc
884885
template <class T, class Enable=void> struct MappedType;
885886
template <class T> struct MappedType // for maps
886887
<T, typename enable_if<is_pair<typename T::value_type>, void>::T>
887-
{using type=typename T::value_type::second_type;};
888+
{
889+
using type=typename transfer_const<
890+
T,
891+
typename T::value_type::second_type,
892+
Or<is_const<T>, is_const<typename T::value_type>,
893+
is_const<typename T::value_type::second_type>>::value
894+
>::type;
895+
};
888896

889897
template <class T> struct MappedType // for sets
890898
<T, typename enable_if<Not<is_pair<typename T::value_type>>, void>::T>
@@ -904,7 +912,17 @@ namespace classdesc
904912

905913
/// get element if a map
906914
template <class I>
907-
typename enable_if<is_pair<typename std::iterator_traits<I>::value_type>, typename std::iterator_traits<I>::value_type::second_type&>::T
915+
typename enable_if<
916+
is_pair<typename std::iterator_traits<I>::value_type>,
917+
// in C++20, std::iterator_traits<I>::value_type has any const
918+
// attribute stripped off, hence this convoluted mouthful
919+
typename transfer_const<
920+
typename std::remove_reference<
921+
typename std::iterator_traits<I>::reference
922+
>::type,
923+
typename std::iterator_traits<I>::value_type::second_type
924+
>::type&
925+
>::T
908926
elem_of(const I& i) const {return i->second;}
909927

910928
/// get element if a set
@@ -1017,6 +1035,7 @@ namespace classdesc
10171035
REST_PROCESS_BUFFER r;
10181036
return ptr? (r<<*ptr): r;
10191037
}
1038+
bool isObject() const override {return true;}
10201039
};
10211040

10221041
template <class T>
@@ -1041,6 +1060,12 @@ namespace classdesc
10411060
auto p=ptr.lock();
10421061
return p? getClassdescObjectImpl(*p): nullptr;
10431062
}
1063+
REST_PROCESS_BUFFER asBuffer() const override {
1064+
REST_PROCESS_BUFFER r;
1065+
auto p=ptr.lock();
1066+
return p? (r<<*p): r;
1067+
}
1068+
bool isObject() const override {return true;}
10441069
};
10451070

10461071

@@ -1282,8 +1307,8 @@ namespace classdesc
12821307
template <class T>
12831308
typename enable_if<
12841309
And<
1285-
Not<is_floating_point<typename remove_reference<T>::type> >,
1286-
Not<is_container<T> >,
1310+
Not<is_floating_point<T>>,
1311+
Not<is_container<T>>,
12871312
Not<And<is_reference<T>,is_const<typename remove_reference<T>::type>>>
12881313
>, bool>::T
12891314
partiallyMatchable(const REST_PROCESS_BUFFER& x);
@@ -1304,8 +1329,8 @@ namespace classdesc
13041329
template <class T>
13051330
typename enable_if<
13061331
And<
1307-
Not<is_floating_point<typename remove_reference<T>::type> >,
1308-
Not<is_container<T> >,
1332+
Not<is_floating_point<T>>,
1333+
Not<is_container<T>>,
13091334
Not<And<is_reference<T>,is_const<typename remove_reference<T>::type>>>
13101335
>, bool>::T
13111336
partiallyMatchable(const REST_PROCESS_BUFFER& x)
@@ -1429,7 +1454,7 @@ namespace classdesc
14291454
Not<is_void<U>>
14301455
>,RESTProcess_t>::T
14311456
slist() const {
1432-
typename remove_reference<U>::type x{};
1457+
typename remove_const<typename remove_reference<U>::type>::type x;
14331458
return RESTProcessObject<U>(x).list();
14341459
}
14351460
// for now, we cannot extract the lists of a non-default constructible return type

RESTProcess_epilogue.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ namespace classdesc
370370
if (ptr)
371371
return rProcess(*ptr, remainder, arguments);
372372
else
373-
return {};
373+
return std::make_shared<RESTProcessVoid>();
374374
}
375375

376376
template <class E>
@@ -389,7 +389,7 @@ namespace classdesc
389389
if (auto p=ptr.lock())
390390
return rProcess(*p, remainder, arguments);
391391
else
392-
return {};
392+
return std::make_shared<RESTProcessVoid>();
393393
}
394394

395395
inline RPPtr RESTProcess_t::process(const std::string& query, const REST_PROCESS_BUFFER& jin)

classdesc.cc

+22-5
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,25 @@ struct type_defined_t: hash_map<string,int>
184184

185185
std::map<std::string, std::vector<std::string> > enum_keys;
186186

187+
// insert a typename keyword on types with :: qualification
188+
string insertTypename(string type)
189+
{
190+
// replace whitespace characters with space
191+
for (size_t i=0; i<type.size(); ++i)
192+
if (isspace(type[i]))
193+
type[i]=' ';
194+
if (type.find("::")==string::npos || type.find("typename ")!=string::npos)
195+
return type; // nothing needs to be done
196+
197+
type=trimWS(type);
198+
static const int constSize=strlen("const ");
199+
if (type.find("const ")==0)
200+
// insert typename between const and type
201+
return "const typename "+type.substr(constSize);
202+
else
203+
return "typename "+type;
204+
}
205+
187206
// overloaded member database
188207
struct MemberSig
189208
{
@@ -193,16 +212,14 @@ struct MemberSig
193212
MemberSig(string d, string r, string a, string p, string n, Type t):
194213
declName(d), returnType(r), argList(a), prefix(p), name(n), type(t) {}
195214
string declare() {
196-
// If qualified type, the typename qualifier required
197-
string rType=returnType.find("::")!=string::npos && returnType.find("typename ")==string::npos? "typename "+returnType: returnType;
198215
switch (type)
199216
{
200217
case none:
201-
return rType+"("+prefix+"*"+declName+")("+argList+")=&"+prefix+name+";";
218+
return insertTypename(returnType)+"("+prefix+"*"+declName+")("+argList+")=&"+prefix+name+";";
202219
case is_const:
203-
return rType+"("+prefix+"*"+declName+")("+argList+") const=&"+prefix+name+";";
220+
return insertTypename(returnType)+"("+prefix+"*"+declName+")("+argList+") const=&"+prefix+name+";";
204221
case is_static:
205-
return rType+"(*"+declName+")("+argList+")=&"+prefix+name+";";
222+
return insertTypename(returnType)+"(*"+declName+")("+argList+")=&"+prefix+name+";";
206223
case is_constructor:
207224
return "void (*"+declName+")("+argList+")=0;";
208225
default: assert(false); return ""; // should never be executed, - statement to silence warning

classdesc.h

+4
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,10 @@ namespace classdesc
10631063
bool operator!() const {return !val;}
10641064
};
10651065

1066+
template <class T> struct is_excluded: public false_type {};
1067+
template <class T> struct is_excluded<Exclude<T> >: public true_type {};
1068+
1069+
10661070
/// @}
10671071

10681072
template <class T>

classdesc_epilogue.h

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ namespace
3434
#include "xml_pack_epilogue.h"
3535
#endif
3636

37+
#ifdef CLASSDESC_XSD_GENERATE_BASE_H
38+
#include "xsd_generate-allCDs.h"
39+
#endif
40+
3741
#ifdef CLASSDESC_DUMP_BASE_H
3842
#include "dump_epilogue.h"
3943
#endif

dump-allCDs.h

+3
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@
3636
#ifdef CLASSDESC_XML_UNPACK_BASE_H
3737
#include "xml_unpack_base-dump.cd"
3838
#endif
39+
#ifdef CLASSDESC_XML_COMMON_H
40+
#include "xml_common-dump.cd"
41+
#endif
3942
#endif

json_pack-allCDs.h

+3
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@
3636
#ifdef CLASSDESC_XML_UNPACK_BASE_H
3737
#include "xml_unpack_base-json_pack.cd"
3838
#endif
39+
#ifdef CLASSDESC_XML_COMMON_H
40+
#include "xml_common-json_pack.cd"
41+
#endif
3942
#endif

0 commit comments

Comments
 (0)