Skip to content

Commit 1be4f00

Browse files
Merge branch 'master' into return-restprocess-object-refactor
2 parents 319383b + f810fa2 commit 1be4f00

File tree

6 files changed

+49
-12
lines changed

6 files changed

+49
-12
lines changed

RESTProcess_base.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ namespace classdesc
10171017
REST_PROCESS_BUFFER r;
10181018
return ptr? (r<<*ptr): r;
10191019
}
1020+
bool isObject() const override {return true;}
10201021
};
10211022

10221023
template <class T>
@@ -1041,6 +1042,12 @@ namespace classdesc
10411042
auto p=ptr.lock();
10421043
return p? getClassdescObjectImpl(*p): nullptr;
10431044
}
1045+
REST_PROCESS_BUFFER asBuffer() const override {
1046+
REST_PROCESS_BUFFER r;
1047+
auto p=ptr.lock();
1048+
return p? (r<<*p): r;
1049+
}
1050+
bool isObject() const override {return true;}
10441051
};
10451052

10461053

@@ -1429,7 +1436,7 @@ namespace classdesc
14291436
Not<is_void<U>>
14301437
>,RESTProcess_t>::T
14311438
slist() const {
1432-
typename remove_reference<U>::type x{};
1439+
typename remove_const<typename remove_reference<U>::type>::type x;
14331440
return RESTProcessObject<U>(x).list();
14341441
}
14351442
// for now, we cannot extract the lists of a non-default constructible return type

RESTProcess_epilogue.h

Lines changed: 2 additions & 2 deletions
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

Lines changed: 22 additions & 5 deletions
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

Lines changed: 4 additions & 0 deletions
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>

object.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
namespace classdesc
1717
{
1818
struct object;
19-
typedef std::vector<shared_ptr<object> > Factory;
20-
inline Factory& factory()
19+
typedef std::vector<shared_ptr<object> > ObjectFactory;
20+
inline ObjectFactory& factory()
2121
{
2222
// ensure factory is initialised on first use
23-
static Factory f;
23+
static ObjectFactory f;
2424
return f;
2525
}
2626

pack_base.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,13 @@ namespace classdesc
477477
/// for use in metaprogramming support. Indicate that a given type
478478
/// is supported explicitly
479479
template <class T> struct pack_supported:
480-
public Or<is_fundamental<T>,is_container<T> > {};
480+
public Or<
481+
Or<
482+
is_fundamental<T>,
483+
is_container<T>
484+
>,
485+
is_excluded<T>
486+
> {};
481487

482488
#ifndef THROW_PTR_EXCEPTION
483489
template <class T>
@@ -755,6 +761,9 @@ namespace classdesc
755761
a=x;
756762
}
757763

764+
template <class T> void pack(pack_t&, const string&, const Exclude<T>&) {}
765+
template <class T> void unpack(pack_t&, const string&, const Exclude<T>&) {}
766+
758767
}
759768

760769
#include "use_mbr_pointers.h"

0 commit comments

Comments
 (0)