Skip to content

Commit aaec14d

Browse files
Fix up polymorphic handling within RESTProcess.
1 parent 519df79 commit aaec14d

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

RESTProcessExample/RESTProcessExample.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ struct Bar: Foo
8686
int f;
8787
EnumFoo barfoo;
8888
std::vector<Foo> vFoo;
89+
std::map<std::string,Foo> mFoo;
8990
Bar& overloadExample() {return *this;}
9091
int overloadExample(int x, int y=0) const {return x+y;}
9192
// test overloading
9293
BarE barE(BarE e) const {return e;}
9394
BarE barE() const {return a;}
9495
GlobE globE() const {return ga;}
9596
Bar() {}
96-
Bar(int i): Foo(i), f(20), barfoo(eb), vFoo(3,1) {}
97+
Bar(int i): Foo(i), f(20), barfoo(eb), vFoo(3,1) {mFoo["foo"]=Foo(2);}
9798

9899
// overload triggers bug
99100
void rvalueRef(Foo&& f) {}

RESTProcessExample/RESTProcessExpected.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/root=>{"bar":{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vFoo":[{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]}],"vs":[" hello"," hello"]},"bar1":{"barfoo":"ec","f":{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"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":[],"sef":{},"sm":{},"um":[],"vs":[]},"g":2,"vFoo":[{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"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":[],"sef":{},"sm":{},"um":[],"vFoo":[],"vs":[]},"spoly":{}}
1+
/root=>{"bar":{"a":0.10000000000000001,"af":0.20000000298023224,"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.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]}}],"sef":"ea","sm":{},"um":[],"vFoo":[{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]}],"vs":[" hello"," hello"]},"bar1":{"barfoo":"ec","f":{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"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":[],"sef":{},"sm":{},"um":[],"vs":[]},"g":2,"vFoo":[{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"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":[],"sef":{},"sm":{},"um":[],"vFoo":[],"vs":[]},"spoly":{}}
22
/root/bar/csi=>20
33
/root/bar/csi=>Exception: attempt to alter a const variable
44
/root/bar/si=>0
@@ -102,7 +102,7 @@
102102
/root/bar/shello=>"hello"
103103
/root/bar/seqLength=>3
104104
/root/bar/name=>"Bar"
105-
/root/bar/overloadExample=>{"a":0.20000000000000001,"af":0.30000001192092896,"b":1,"barfoo":"eb","bf":true,"bt":false,"c":"hello world","c1":["x","\r"],"ch":"M","d":[0,5,2],"d1":[[0,1],[2,6],[7,10]],"ef":"ea","f":20,"h":[2,2,2,2],"l":[2,2,2,2],"llex":[["hello","hello"],["baa","baa","blacksheep"]],"m":[{"first":0,"second":5},{"first":3,"second":5}],"sef":"eb","sm":{},"um":[{"first":1,"second":5}],"vFoo":[{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]}],"vs":[" hello"," hello"]}
105+
/root/bar/overloadExample=>{"a":0.20000000000000001,"af":0.30000001192092896,"b":1,"barfoo":"eb","bf":true,"bt":false,"c":"hello world","c1":["x","\r"],"ch":"M","d":[0,5,2],"d1":[[0,1],[2,6],[7,10]],"ef":"ea","f":20,"h":[2,2,2,2],"l":[2,2,2,2],"llex":[["hello","hello"],["baa","baa","blacksheep"]],"m":[{"first":0,"second":5},{"first":3,"second":5}],"mFoo":[{"first":"foo","second":{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]}}],"sef":"eb","sm":{},"um":[{"first":1,"second":5}],"vFoo":[{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]},{"a":0.10000000000000001,"af":0.20000000298023224,"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}],"sef":"ea","sm":{},"um":[],"vs":[" hello"," hello"]}],"vs":[" hello"," hello"]}
106106
/root/bar/barE=>"a"
107107
/root/bar/barE=>"b"
108108
/root/bar/globE=>"ga"

RESTProcess_base.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,10 @@ namespace classdesc
583583
json_pack_t process(const string& remainder, const json_pack_t& arguments) override;
584584
json_pack_t signature() const override;
585585
json_pack_t list() const override {
586-
if (ptr) return RESTProcessObject<typename T::element_type>(*ptr).list();
587-
else return json_pack_t(json_spirit::mArray());
586+
if (ptr)
587+
return const_cast<RESTProcessPtr<T>*>(this)->process("/@list",{});
588+
else
589+
return json_pack_t(json_spirit::mArray());
588590
}
589591
json_pack_t type() const override {return json_pack_t(typeName<T>());}
590592
};

RESTProcess_epilogue.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ namespace classdesc
135135
json_pack_t RESTProcessPtr<T>::process(const string& remainder, const json_pack_t& arguments)
136136
{
137137
if (ptr)
138-
if (remainder.empty())
139-
return rProcess(*ptr, remainder, arguments);
140-
else
141-
return mapAndProcess(remainder,arguments,*ptr);
138+
return rProcess(*ptr, remainder, arguments);
142139
else
143140
return {};
144141
}

0 commit comments

Comments
 (0)