Merge branch 'master' into PSI
This commit is contained in:
commit
8a5a6fcd27
19 files changed
+333
-130
No files matched your search
@@ -28,6 +28,8 @@
|
||||
#include <pv/thread.h>
|
||||
#include <pv/pvData.h>
|
||||
|
||||
#include "factoryPvt.h"
|
||||
|
||||
using std::tr1::static_pointer_cast;
|
||||
using std::size_t;
|
||||
using std::string;
|
||||
@@ -36,7 +38,6 @@ namespace epics { namespace pvData {
|
||||
|
||||
size_t Field::num_instances;
|
||||
|
||||
|
||||
struct Field::Helper {
|
||||
static unsigned hash(Field *fld) {
|
||||
std::ostringstream key;
|
||||
@@ -1488,6 +1489,7 @@ static int decodeScalar(int8 code)
|
||||
|
||||
FieldConstPtr FieldCreate::deserialize(ByteBuffer* buffer, DeserializableControl* control) const
|
||||
{
|
||||
RecurseGuard RG;
|
||||
control->ensureData(1);
|
||||
int8 code = buffer->getByte();
|
||||
if (code == -1)
|
||||
@@ -1576,7 +1578,9 @@ FieldConstPtr FieldCreate::deserialize(ByteBuffer* buffer, DeserializableControl
|
||||
throw std::invalid_argument("fixed and bounded structure array not supported");
|
||||
|
||||
// Type type = Type.structureArray;
|
||||
StructureConstPtr elementStructure = std::tr1::static_pointer_cast<const Structure>(control->cachedDeserialize(buffer));
|
||||
StructureConstPtr elementStructure = std::tr1::dynamic_pointer_cast<const Structure>(control->cachedDeserialize(buffer));
|
||||
if(!elementStructure)
|
||||
throw std::invalid_argument("Expected Structure");
|
||||
// TODO use std::make_shared
|
||||
std::tr1::shared_ptr<Field> sp(new StructureArray(elementStructure));
|
||||
Helper::cache(this, sp);
|
||||
@@ -1589,7 +1593,9 @@ FieldConstPtr FieldCreate::deserialize(ByteBuffer* buffer, DeserializableControl
|
||||
throw std::invalid_argument("fixed and bounded structure array not supported");
|
||||
|
||||
// Type type = Type.unionArray;
|
||||
UnionConstPtr elementUnion = std::tr1::static_pointer_cast<const Union>(control->cachedDeserialize(buffer));
|
||||
UnionConstPtr elementUnion = std::tr1::dynamic_pointer_cast<const Union>(control->cachedDeserialize(buffer));
|
||||
if(!elementUnion)
|
||||
throw std::invalid_argument("Expected Union");
|
||||
// TODO use std::make_shared
|
||||
std::tr1::shared_ptr<Field> sp(new UnionArray(elementUnion));
|
||||
Helper::cache(this, sp);
|
||||
@@ -1612,6 +1618,7 @@ FieldConstPtr FieldCreate::deserialize(ByteBuffer* buffer, DeserializableControl
|
||||
namespace detail {
|
||||
struct field_factory {
|
||||
FieldCreatePtr fieldCreate;
|
||||
epicsThreadPrivate<unsigned> deserDepth;
|
||||
field_factory() :fieldCreate(new FieldCreate()) {
|
||||
registerRefCounter("Field", &Field::num_instances);
|
||||
registerRefCounter("Thread", &Thread::num_instances);
|
||||
@@ -1622,6 +1629,23 @@ struct field_factory {
|
||||
static detail::field_factory* field_factory_s;
|
||||
static epicsThreadOnceId field_factory_once = EPICS_THREAD_ONCE_INIT;
|
||||
|
||||
#if defined(__rtems__) || defined(vxWorks)
|
||||
// lower limit on embedded targets
|
||||
const unsigned maxDepth = 10;
|
||||
#else
|
||||
const unsigned maxDepth = 20;
|
||||
#endif
|
||||
RecurseGuard::RecurseGuard() {
|
||||
size_t current = (size_t)field_factory_s->deserDepth.get();
|
||||
if(current>=maxDepth)
|
||||
throw std::logic_error("FieldCreateFactory recursion depth exceeded");
|
||||
field_factory_s->deserDepth.set((unsigned*)(current+1));
|
||||
}
|
||||
RecurseGuard::~RecurseGuard() {
|
||||
size_t current = (size_t)field_factory_s->deserDepth.get();
|
||||
field_factory_s->deserDepth.set((unsigned*)(current-1));
|
||||
}
|
||||
|
||||
static void field_factory_init(void*)
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user