Skip to content

Commit 1496b01

Browse files
Fixes to make Minsky buildable
1 parent 030cc4d commit 1496b01

File tree

6 files changed

+58
-17
lines changed

6 files changed

+58
-17
lines changed

RESTProcess_base.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,13 @@ namespace classdesc
381381
RPPtr makeRESTProcessValueObject(T&& obj)
382382
{return std::make_shared<RESTProcessValueObject<typename std::remove_reference<T>::type>>(std::forward<T>(obj));}
383383
// specialization for string and string vector to allow
384-
RPPtr makeRESTProcessValueObject(const char* s)
384+
inline RPPtr makeRESTProcessValueObject(const char* s)
385385
{return std::make_shared<RESTProcessValueObject<std::string>>(s);}
386-
RPPtr makeRESTProcessValueObject(const std::initializer_list<std::string>& init)
386+
inline RPPtr makeRESTProcessValueObject(const std::initializer_list<std::string>& init)
387387
{return std::make_shared<RESTProcessValueObject<std::vector<std::string>>>(init);}
388388

389389
/// class that represents the void, or null object
390-
class RESTProcessVoid: public RESTProcessBase
390+
struct RESTProcessVoid: public RESTProcessBase
391391
{
392392
std::shared_ptr<RESTProcessBase> process(const string&, const REST_PROCESS_BUFFER&) override
393393
{return std::make_shared<RESTProcessVoid>();}
@@ -712,7 +712,7 @@ namespace classdesc
712712
return RESTProcessObject<typename T::element_type>(*p).list();
713713
return makeRESTProcessValueObject({});
714714
}
715-
REST_PROCESS_BUFFER type() const override {return REST_PROCESS_BUFFER(typeName<std::weak_ptr<T> >());}
715+
RPPtr type() const override {return makeRESTProcessValueObject(typeName<std::weak_ptr<T> >());}
716716
object* getClassdescObject() override {
717717
auto p=ptr.lock();
718718
if (!p || is_const<typename T::element_type>::value) return nullptr;
@@ -722,6 +722,11 @@ namespace classdesc
722722
auto p=ptr.lock();
723723
return p? getClassdescObjectImpl(*p): nullptr;
724724
}
725+
REST_PROCESS_BUFFER asBuffer() const override {
726+
REST_PROCESS_BUFFER r;
727+
auto p=ptr.lock();
728+
return p? (r<<*p): r;
729+
}
725730
};
726731

727732

@@ -1082,19 +1087,21 @@ namespace classdesc
10821087
template <class U>
10831088
typename enable_if<
10841089
And<
1085-
is_default_constructible<remove_reference<U>>,
1090+
is_default_constructible<typename remove_reference<U>::type>,
1091+
//Not<is_abstract<typename remove_reference<U>::type>>,
10861092
Not<is_void<U>>
10871093
>,RPPtr>::T
10881094
slist() const {
1089-
typename remove_reference<U>::type x;
1095+
typename remove_const<typename remove_reference<U>::type>::type x;
10901096
return RESTProcessObject<U>(x).list();
10911097
}
10921098
// for now, we cannot extract the lists of a non-default constructible return type
10931099
template <class U>
10941100
typename enable_if<
10951101
Not<
10961102
And<
1097-
is_default_constructible<remove_reference<U>>,
1103+
is_default_constructible<typename remove_reference<U>::type>,
1104+
//Not<is_abstract<typename remove_reference<U>::type>>,
10981105
Not<is_void<U>>
10991106
>>,RPPtr>::T
11001107
slist() const {return makeRESTProcessValueObject({});}
@@ -1171,7 +1178,7 @@ namespace classdesc
11711178
RPPtr signature() const override;
11721179
RPPtr list() const override {return makeRESTProcessValueObject({});}
11731180
RPPtr type() const override {return makeRESTProcessValueObject(typeName<E>());}
1174-
REST_PROCESS_BUFFER asBuffer() const {return REST_PROCESS_BUFFER(enum_keys<E>()(e));}
1181+
REST_PROCESS_BUFFER asBuffer() const override {return REST_PROCESS_BUFFER(enum_keys<E>()(e));}
11751182
};
11761183

11771184
template <class E>

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
@@ -1058,6 +1058,10 @@ namespace classdesc
10581058
bool operator!() const {return !val;}
10591059
};
10601060

1061+
template <class T> struct is_excluded: public false_type {};
1062+
template <class T> struct is_excluded<Exclude<T> >: public true_type {};
1063+
1064+
10611065
/// @}
10621066

10631067
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ 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<is_fundamental<T>,is_container<T>,is_excluded<T> > {};
481481

482482
#ifndef THROW_PTR_EXCEPTION
483483
template <class T>
@@ -755,6 +755,9 @@ namespace classdesc
755755
a=x;
756756
}
757757

758+
template <class T> void pack(pack_t&, const string&, const Exclude<T>&) {}
759+
template <class T> void unpack(pack_t&, const string&, const Exclude<T>&) {}
760+
758761
}
759762

760763
#include "use_mbr_pointers.h"

signature.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,14 @@ namespace classdesc
2222
}
2323

2424
#include "signature.cd"
25+
26+
#pragma omit RESTProcess classdesc::Signature
27+
namespace classdesc_access
28+
{
29+
#ifdef RESTPROCESS_H // spurious, needed for old Classdesc
30+
template <>
31+
struct access_RESTProcess<classdesc::Signature>: public classdesc::NullDescriptor<classdesc::RESTProcess_t> {};
32+
#endif
33+
}
34+
2535
#endif

0 commit comments

Comments
 (0)