diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 0d5024d..f8a1099 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -1316,11 +1316,11 @@ Slice::findMetaData(const SequencePtr& seq, const StringList& metaData, bool& is } } // - // Otherwise if the data is "class" it is returned. + // Otherwise if the data is "class" or "one-shot" it is returned. // else { - if(ss == "class") + if(ss == "class" || ss == "one-shot") { return ss; } @@ -1377,12 +1377,12 @@ Slice::findMetaData(const StringList& metaData, int typeCtx) } } // - // Otherwise if the data is "class" it is returned. + // Otherwise if the data is "class" or "one-shot" it is returned. // else { string ss = str.substr(prefix.size()); - if(ss == "class") + if(ss == "class" || ss == "one-shot") { return ss; } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 3509ea1..2d920a2 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1077,7 +1077,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { H << sp << nl << "struct " << name; H << sb; - if(p->hasDefaultValues()) + if(p->hasDefaultValues() || (!dataMembers.empty() && findMetaData(p->getMetaData()) == "one-shot")) { H << nl << _dllExport << name << "();"; @@ -1094,7 +1094,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) // Generate a one-shot constructor if the struct uses the class mapping, or if at least // one of its members has a default value. // - if(!dataMembers.empty() && (findMetaData(p->getMetaData()) == "class" || p->hasDefaultValues())) + if(!dataMembers.empty() && (findMetaData(p->getMetaData()) == "class" || findMetaData(p->getMetaData()) == "one-shot" || p->hasDefaultValues())) { DataMemberList::const_iterator q; vector paramDecls; @@ -7037,7 +7037,7 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin continue; } } - if(StructPtr::dynamicCast(cont) && ss.find("class") == 0) + if(StructPtr::dynamicCast(cont) && (ss.find("class") == 0 || ss.find("one-shot") == 0)) { continue; }