void FreezeScript::AssignVisitor::visitSequence(const SequenceDataPtr& dest) { Slice::TypePtr type = dest->getType(); SequenceDataPtr src = SequenceDataPtr::dynamicCast(_src); if(src && isCompatible(type, src->getType())) { DataList& srcElements = src->getElements(); DataList destElements; Slice::SequencePtr seqType = Slice::SequencePtr::dynamicCast(type); assert(seqType); Slice::TypePtr elemType = seqType->type(); string typeName = typeToString(type); for(DataList::const_iterator p = srcElements.begin(); p != srcElements.end(); ++p) { DataPtr element = _factory->create(elemType, false); Destroyer<DataPtr> elementDestroyer(element); AssignVisitor v(*p, _factory, _errorReporter, _convert, typeName + " element"); element->visit(v); destElements.push_back(element); elementDestroyer.release(); } DataList& l = dest->getElements(); l.swap(destElements); } else { typeMismatchError(type, _src->getType()); } }
void FreezeScript::TransformVisitor::visitSequence(const SequenceDataPtr& dest) { Slice::TypePtr type = dest->getType(); if(_info->doDefaultTransform(type)) { SequenceDataPtr s = SequenceDataPtr::dynamicCast(_src); if(s && isCompatible(type, _src->getType())) { DataList& srcElements = s->getElements(); DataList destElements; Slice::SequencePtr seqType = Slice::SequencePtr::dynamicCast(type); assert(seqType); Slice::TypePtr elemType = seqType->type(); string typeName = typeToString(type); for(DataList::const_iterator p = srcElements.begin(); p != srcElements.end(); ++p) { DataPtr element = _info->getDataFactory()->create(elemType, false); Destroyer<DataPtr> elementDestroyer(element); try { TransformVisitor v(*p, _info, typeName + " element"); element->visit(v); destElements.push_back(element); elementDestroyer.release(); } catch(const ClassNotFoundException& ex) { // // If transformation of the sequence element fails because a class // could not be found, then we invoke purgeObjects() to determine // whether we should ignore the situation (and remove the element // from the sequence) or raise the exception again. // if(!_info->purgeObjects()) { throw; } warning("purging element of sequence " + typeToString(type) + " due to missing class type " + ex.id); } } DataList& l = dest->getElements(); l.swap(destElements); } else { typeMismatchError(type, _src->getType()); } } _info->executeCustomTransform(dest, _src); }
void FreezeScript::SliceVisitor::visitSequence(const Slice::SequencePtr& v) { if(v->isLocal()) { return; } string scoped = v->scoped(); if(ignoreType(scoped)) { return; } _out.newline(); _out.newline(); _out << "<!-- sequence " << scoped << " -->"; _out << se("dump") << attr("type", scoped) << ee; }