diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-12-14 20:44:21 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-12-14 20:44:21 +0100 |
commit | f1e5db3e5c5bc4909dd1f1e6e3288e7a8187efdc (patch) | |
tree | 7f8962e54edc13e7d17064976cf13a400f487485 /unoidl | |
parent | e0b93ef5712264f78b8876993e718ccaad2c1216 (diff) |
Use emplace_back
Change-Id: I006e3c8f411b480917d9cfb9c4f3d082b79c833d
Diffstat (limited to 'unoidl')
-rw-r--r-- | unoidl/source/legacyprovider.cxx | 130 | ||||
-rw-r--r-- | unoidl/source/sourceprovider-parser.y | 70 | ||||
-rw-r--r-- | unoidl/source/unoidlprovider.cxx | 110 |
3 files changed, 126 insertions, 184 deletions
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index 46058c7be032..7b2d45babdf1 100644 --- a/unoidl/source/legacyprovider.cxx +++ b/unoidl/source/legacyprovider.cxx @@ -234,19 +234,16 @@ rtl::Reference< Entity > readEntity( std::vector< AnnotatedReference > mandBases; sal_uInt16 n = reader.getSuperTypeCount(); for (sal_uInt16 j = 0; j != n; ++j) { - mandBases.push_back( - AnnotatedReference( - reader.getSuperTypeName(j).replace('/', '.'), - std::vector< OUString >())); + mandBases.emplace_back( + reader.getSuperTypeName(j).replace('/', '.'), + std::vector< OUString >()); } std::vector< AnnotatedReference > optBases; n = reader.getReferenceCount(); for (sal_uInt16 j = 0; j != n; ++j) { - optBases.push_back( - AnnotatedReference( - reader.getReferenceTypeName(j).replace('/', '.'), - translateAnnotations( - reader.getReferenceDocumentation(j)))); + optBases.emplace_back( + reader.getReferenceTypeName(j).replace('/', '.'), + translateAnnotations(reader.getReferenceDocumentation(j))); } sal_uInt16 methodCount = reader.getMethodCount(); std::vector< InterfaceTypeEntity::Attribute > attrs; @@ -297,12 +294,11 @@ rtl::Reference< Entity > readEntity( } } RTFieldAccess flags = reader.getFieldFlags(j); - attrs.push_back( - InterfaceTypeEntity::Attribute( - attrName, reader.getFieldTypeName(j).replace('/', '.'), - bool(flags & RTFieldAccess::BOUND), - bool(flags & RTFieldAccess::READONLY), getExcs, setExcs, - translateAnnotations(reader.getFieldDocumentation(j)))); + attrs.emplace_back( + attrName, reader.getFieldTypeName(j).replace('/', '.'), + bool(flags & RTFieldAccess::BOUND), + bool(flags & RTFieldAccess::READONLY), getExcs, setExcs, + translateAnnotations(reader.getFieldDocumentation(j))); } std::vector< InterfaceTypeEntity::Method > meths; for (sal_uInt16 j = 0; j != methodCount; ++j) { @@ -338,12 +334,11 @@ rtl::Reference< Entity > readEntity( + " in interface type with key " + sub.getName())); } - params.push_back( - InterfaceTypeEntity::Method::Parameter( - reader.getMethodParameterName(j, k), - (reader.getMethodParameterTypeName(j, k). - replace('/', '.')), - dir)); + params.emplace_back( + reader.getMethodParameterName(j, k), + (reader.getMethodParameterTypeName(j, k). + replace('/', '.')), + dir); } std::vector< OUString > excs; m = reader.getMethodExceptionCount(j); @@ -354,13 +349,12 @@ rtl::Reference< Entity > readEntity( reader.getMethodExceptionTypeName(j, k).replace( '/', '.')); } - meths.push_back( - InterfaceTypeEntity::Method( - reader.getMethodName(j), - reader.getMethodReturnTypeName(j).replace('/', '.'), - params, excs, - translateAnnotations( - reader.getMethodDocumentation(j)))); + meths.emplace_back( + reader.getMethodName(j), + reader.getMethodReturnTypeName(j).replace('/', '.'), + params, excs, + translateAnnotations( + reader.getMethodDocumentation(j))); } } return new InterfaceTypeEntity( @@ -391,12 +385,10 @@ rtl::Reference< Entity > readEntity( std::vector< PlainStructTypeEntity::Member > mems; n = reader.getFieldCount(); for (sal_uInt16 j = 0; j < n; ++j) { - mems.push_back( - PlainStructTypeEntity::Member( - reader.getFieldName(j), - reader.getFieldTypeName(j).replace('/', '.'), - translateAnnotations( - reader.getFieldDocumentation(j)))); + mems.emplace_back( + reader.getFieldName(j), + reader.getFieldTypeName(j).replace('/', '.'), + translateAnnotations(reader.getFieldDocumentation(j))); } return new PlainStructTypeEntity( reader.isPublished(), base, mems, @@ -418,14 +410,13 @@ rtl::Reference< Entity > readEntity( std::vector< PolymorphicStructTypeTemplateEntity::Member > mems; n = reader.getFieldCount(); for (sal_uInt16 j = 0; j < n; ++j) { - mems.push_back( - PolymorphicStructTypeTemplateEntity::Member( - reader.getFieldName(j), - reader.getFieldTypeName(j).replace('/', '.'), - bool(reader.getFieldFlags(j) - & RTFieldAccess::PARAMETERIZED_TYPE), - translateAnnotations( - reader.getFieldDocumentation(j)))); + mems.emplace_back( + reader.getFieldName(j), + reader.getFieldTypeName(j).replace('/', '.'), + bool( + reader.getFieldFlags(j) + & RTFieldAccess::PARAMETERIZED_TYPE), + translateAnnotations(reader.getFieldDocumentation(j))); } return new PolymorphicStructTypeTemplateEntity( reader.isPublished(), params, mems, @@ -446,10 +437,9 @@ rtl::Reference< Entity > readEntity( + reader.getFieldName(j) + " of enum type with key " + sub.getName())); } - mems.push_back( - EnumTypeEntity::Member( - reader.getFieldName(j), v.m_value.aLong, - translateAnnotations(reader.getFieldDocumentation(j)))); + mems.emplace_back( + reader.getFieldName(j), v.m_value.aLong, + translateAnnotations(reader.getFieldDocumentation(j))); } return new EnumTypeEntity( @@ -476,11 +466,10 @@ rtl::Reference< Entity > readEntity( std::vector< ExceptionTypeEntity::Member > mems; sal_uInt16 n = reader.getFieldCount(); for (sal_uInt16 j = 0; j != n; ++j) { - mems.push_back( - ExceptionTypeEntity::Member( - reader.getFieldName(j), - reader.getFieldTypeName(j).replace('/', '.'), - translateAnnotations(reader.getFieldDocumentation(j)))); + mems.emplace_back( + reader.getFieldName(j), + reader.getFieldTypeName(j).replace('/', '.'), + translateAnnotations(reader.getFieldDocumentation(j))); } return new ExceptionTypeEntity( reader.isPublished(), base, mems, @@ -507,10 +496,10 @@ rtl::Reference< Entity > readEntity( std::vector< AnnotatedReference > optIfcs; sal_uInt16 n = reader.getReferenceCount(); for (sal_uInt16 j = 0; j != n; ++j) { - AnnotatedReference base( + AnnotatedReference base{ reader.getReferenceTypeName(j).replace('/', '.'), translateAnnotations( - reader.getReferenceDocumentation(j))); + reader.getReferenceDocumentation(j))}; switch (reader.getReferenceSort(j)) { case RTReferenceType::EXPORTS: if (!(reader.getReferenceFlags(j) & RTFieldAccess::OPTIONAL)) @@ -578,15 +567,13 @@ rtl::Reference< Entity > readEntity( attrs |= AccumulationBasedServiceEntity::Property:: ATTRIBUTE_REMOVABLE; } - props.push_back( - AccumulationBasedServiceEntity::Property( - reader.getFieldName(j), - reader.getFieldTypeName(j).replace('/', '.'), - static_cast< - AccumulationBasedServiceEntity::Property:: + props.emplace_back( + reader.getFieldName(j), + reader.getFieldTypeName(j).replace('/', '.'), + static_cast< + AccumulationBasedServiceEntity::Property:: Attributes >(attrs), - translateAnnotations( - reader.getFieldDocumentation(j)))); + translateAnnotations(reader.getFieldDocumentation(j))); } return new AccumulationBasedServiceEntity( reader.isPublished(), mandServs, optServs, mandIfcs, @@ -652,13 +639,11 @@ rtl::Reference< Entity > readEntity( + " in service with key " + sub.getName())); } - params.push_back( - SingleInterfaceBasedServiceEntity::Constructor:: - Parameter( - reader.getMethodParameterName(j, k), - (reader.getMethodParameterTypeName(j, k). - replace('/', '.')), - (mode & RT_PARAM_REST) != 0)); + params.emplace_back( + reader.getMethodParameterName(j, k), + (reader.getMethodParameterTypeName(j, k). + replace('/', '.')), + (mode & RT_PARAM_REST) != 0); } std::vector< OUString > excs; m = reader.getMethodExceptionCount(j); @@ -768,11 +753,10 @@ rtl::Reference< Entity > readEntity( std::vector< ConstantGroupEntity::Member > mems; sal_uInt16 n = reader.getFieldCount(); for (sal_uInt16 j = 0; j != n; ++j) { - mems.push_back( - ConstantGroupEntity::Member( - reader.getFieldName(j), - translateConstantValue(sub, reader.getFieldValue(j)), - translateAnnotations(reader.getFieldDocumentation(j)))); + mems.emplace_back( + reader.getFieldName(j), + translateConstantValue(sub, reader.getFieldValue(j)), + translateAnnotations(reader.getFieldDocumentation(j))); } return new ConstantGroupEntity( reader.isPublished(), mems, diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y index ad6c6574f19d..945ebea0f488 100644 --- a/unoidl/source/sourceprovider-parser.y +++ b/unoidl/source/sourceprovider-parser.y @@ -1039,8 +1039,7 @@ enumMember: } ++v; } - pad->members.push_back( - unoidl::EnumTypeEntity::Member(id, v, annotations($1))); + pad->members.emplace_back(id, v, annotations($1)); } | deprecated_opt identifier '=' expr { @@ -1078,8 +1077,7 @@ enumMember: YYERROR; break; } - pad->members.push_back( - unoidl::EnumTypeEntity::Member(id, v, annotations($1))); + pad->members.emplace_back(id, v, annotations($1)); } ; @@ -1399,9 +1397,7 @@ structMember: p->entity.get()); } } - p1->members.push_back( - unoidl::PlainStructTypeEntity::Member( - id, t.getName(), annotations($1))); + p1->members.emplace_back(id, t.getName(), annotations($1)); } else { unoidl::detail::SourceProviderPolymorphicStructTypeTemplateEntityPad * p2 = dynamic_cast<unoidl::detail::SourceProviderPolymorphicStructTypeTemplateEntityPad *>( @@ -1420,12 +1416,10 @@ structMember: YYERROR; } } - p2->members.push_back( - unoidl::PolymorphicStructTypeTemplateEntity::Member( - id, t.getName(), - (t.type - == unoidl::detail::SourceProviderType::TYPE_PARAMETER), - annotations($1))); + p2->members.emplace_back( + id, t.getName(), + t.type == unoidl::detail::SourceProviderType::TYPE_PARAMETER, + annotations($1)); } else { unoidl::detail::SourceProviderExceptionTypeEntityPad * p3 = dynamic_cast<unoidl::detail::SourceProviderExceptionTypeEntityPad *>( @@ -1499,9 +1493,7 @@ structMember: p->entity.get()); } } - p3->members.push_back( - unoidl::ExceptionTypeEntity::Member( - id, t.getName(), annotations($1))); + p3->members.emplace_back(id, t.getName(), annotations($1)); } } } @@ -1625,14 +1617,14 @@ interfaceDefn: i(pad->directMandatoryBases.begin()); i != pad->directMandatoryBases.end(); ++i) { - mbases.push_back(unoidl::AnnotatedReference(i->name, i->annotations)); + mbases.emplace_back(i->name, i->annotations); } std::vector<unoidl::AnnotatedReference> obases; for (std::vector<unoidl::detail::SourceProviderInterfaceTypeEntityPad::DirectBase>::const_iterator i(pad->directOptionalBases.begin()); i != pad->directOptionalBases.end(); ++i) { - obases.push_back(unoidl::AnnotatedReference(i->name, i->annotations)); + obases.emplace_back(i->name, i->annotations); } ent->entity = new unoidl::InterfaceTypeEntity( pad->isPublished(), mbases, obases, pad->directAttributes, @@ -1760,12 +1752,10 @@ interfaceAttribute: if (!pad->addDirectMember(@4, yyscanner, data, id)) { YYERROR; } - pad->directAttributes.push_back( - unoidl::InterfaceTypeEntity::Attribute( - id, t.getName(), ($2 & unoidl::detail::FLAG_BOUND) != 0, - ($2 & unoidl::detail::FLAG_READONLY) != 0, - std::vector<OUString>(), std::vector<OUString>(), - annotations($1))); + pad->directAttributes.emplace_back( + id, t.getName(), ($2 & unoidl::detail::FLAG_BOUND) != 0, + ($2 & unoidl::detail::FLAG_READONLY) != 0, + std::vector<OUString>(), std::vector<OUString>(), annotations($1)); } attributeAccessDecls_opt ';' ; @@ -1842,11 +1832,10 @@ interfaceMethod: if (!pad->addDirectMember(@3, yyscanner, data, id)) { YYERROR; } - pad->directMethods.push_back( - unoidl::InterfaceTypeEntity::Method( - id, t.getName(), - std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>(), - std::vector<OUString>(), annotations($1))); + pad->directMethods.emplace_back( + id, t.getName(), + std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>(), + std::vector<OUString>(), annotations($1)); } '(' methodParams_opt ')' exceptionSpec_opt ';' { @@ -1910,8 +1899,7 @@ methodParam: YYERROR; } } - pad->directMethods.back().parameters.push_back( - unoidl::InterfaceTypeEntity::Method::Parameter(id, t.getName(), $2)); + pad->directMethods.back().parameters.emplace_back(id, t.getName(), $2); } ; @@ -2309,8 +2297,7 @@ constant: YYERROR; break; } - pad->members.push_back( - unoidl::ConstantGroupEntity::Member(id, v, annotations($1))); + pad->members.emplace_back(id, v, annotations($1)); } ; @@ -2396,9 +2383,7 @@ singleInterfaceBasedServiceDefn: j(i->parameters.begin()); j != i->parameters.end(); ++j) { - parms.push_back( - unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter( - j->name, j->type.getName(), j->rest)); + parms.emplace_back(j->name, j->type.getName(), j->rest); } ctors.push_back( unoidl::SingleInterfaceBasedServiceEntity::Constructor( @@ -2691,7 +2676,7 @@ serviceBase: YYERROR; } } - v.push_back(unoidl::AnnotatedReference(name, annotations($1))); + v.emplace_back(name, annotations($1)); } ; @@ -2770,7 +2755,7 @@ serviceInterfaceBase: YYERROR; } } - v.push_back(unoidl::AnnotatedReference(name, annotations($1))); + v.emplace_back(name, annotations($1)); } ; @@ -2860,11 +2845,10 @@ serviceProperty: YYERROR; } } - pad->directProperties.push_back( - unoidl::AccumulationBasedServiceEntity::Property( - id, t.getName(), - unoidl::AccumulationBasedServiceEntity::Property::Attributes(att), - annotations($1))); + pad->directProperties.emplace_back( + id, t.getName(), + unoidl::AccumulationBasedServiceEntity::Property::Attributes(att), + annotations($1)); } ; diff --git a/unoidl/source/unoidlprovider.cxx b/unoidl/source/unoidlprovider.cxx index d2e664527a24..6ed977ba4216 100644 --- a/unoidl/source/unoidlprovider.cxx +++ b/unoidl/source/unoidlprovider.cxx @@ -777,10 +777,9 @@ rtl::Reference< Entity > readEntity( // sal_uInt32 to sal_Int32 relies on two's complement // representation offset += 4; - mems.push_back( - EnumTypeEntity::Member( - memName, memValue, - readAnnotations(annotated, file, offset, &offset))); + mems.emplace_back( + memName, memValue, + readAnnotations(annotated, file, offset, &offset)); } return new EnumTypeEntity( published, mems, readAnnotations(annotated, file, offset)); @@ -814,10 +813,9 @@ rtl::Reference< Entity > readEntity( checkEntityName(file, memName); OUString memType(file->readIdxName(&offset)); checkTypeName(file, memType); - mems.push_back( - PlainStructTypeEntity::Member( - memName, memType, - readAnnotations(annotated, file, offset, &offset))); + mems.emplace_back( + memName, memType, + readAnnotations(annotated, file, offset, &offset)); } return new PlainStructTypeEntity( published, base, mems, @@ -862,10 +860,9 @@ rtl::Reference< Entity > readEntity( + " for member " + memName + " of polymorphic struct type template")); } - mems.push_back( - PolymorphicStructTypeTemplateEntity::Member( - memName, memType, v == 1, - readAnnotations(annotated, file, offset, &offset))); + mems.emplace_back( + memName, memType, v == 1, + readAnnotations(annotated, file, offset, &offset)); } return new PolymorphicStructTypeTemplateEntity( published, params, mems, @@ -899,10 +896,9 @@ rtl::Reference< Entity > readEntity( checkEntityName(file, memName); OUString memType(file->readIdxName(&offset)); checkTypeName(file, memType); - mems.push_back( - ExceptionTypeEntity::Member( - memName, memType, - readAnnotations(annotated, file, offset, &offset))); + mems.emplace_back( + memName, memType, + readAnnotations(annotated, file, offset, &offset)); } return new ExceptionTypeEntity( published, base, mems, @@ -922,10 +918,8 @@ rtl::Reference< Entity > readEntity( for (sal_uInt32 i = 0; i != n; ++i) { OUString base(file->readIdxName(&offset)); checkTypeName(file, base); - mandBases.push_back( - AnnotatedReference( - base, - readAnnotations(annotated, file, offset, &offset))); + mandBases.emplace_back( + base, readAnnotations(annotated, file, offset, &offset)); } n = file->read32(offset); if (n > SAL_MAX_INT32) { @@ -939,10 +933,8 @@ rtl::Reference< Entity > readEntity( for (sal_uInt32 i = 0; i != n; ++i) { OUString base(file->readIdxName(&offset)); checkTypeName(file, base); - optBases.push_back( - AnnotatedReference( - base, - readAnnotations(annotated, file, offset, &offset))); + optBases.emplace_back( + base, readAnnotations(annotated, file, offset, &offset)); } sal_uInt32 nAttrs = file->read32(offset); if (nAttrs > SAL_MAX_INT32) { @@ -997,11 +989,10 @@ rtl::Reference< Entity > readEntity( setExcs.push_back(exc); } } - attrs.push_back( - InterfaceTypeEntity::Attribute( - attrName, attrType, (v & 0x01) != 0, (v & 0x02) != 0, - getExcs, setExcs, - readAnnotations(annotated, file, offset, &offset))); + attrs.emplace_back( + attrName, attrType, (v & 0x01) != 0, (v & 0x02) != 0, + getExcs, setExcs, + readAnnotations(annotated, file, offset, &offset)); } sal_uInt32 nMeths = file->read32(offset); if (nMeths > SAL_MAX_INT32 - nAttrs) { @@ -1055,9 +1046,7 @@ rtl::Reference< Entity > readEntity( + paramName + " for method " + methName + " of interface type")); } - params.push_back( - InterfaceTypeEntity::Method::Parameter( - paramName, paramType, dir)); + params.emplace_back(paramName, paramType, dir); } std::vector< OUString > excs; m = file->read32(offset); @@ -1073,10 +1062,9 @@ rtl::Reference< Entity > readEntity( checkTypeName(file, exc); excs.push_back(exc); } - meths.push_back( - InterfaceTypeEntity::Method( - methName, methType, params, excs, - readAnnotations(annotated, file, offset, &offset))); + meths.emplace_back( + methName, methType, params, excs, + readAnnotations(annotated, file, offset, &offset)); } return new InterfaceTypeEntity( published, mandBases, optBases, attrs, meths, @@ -1113,10 +1101,9 @@ rtl::Reference< Entity > readEntity( sal_uInt32 off = p[i].data.getUnsigned32(); bool ann; ConstantValue val(readConstant(file, off, &off, &ann)); - mems.push_back( - ConstantGroupEntity::Member( - file->readNulName(p[i].name.getUnsigned32()), val, - readAnnotations(ann, file, off))); + mems.emplace_back( + file->readNulName(p[i].name.getUnsigned32()), val, + readAnnotations(ann, file, off)); } return new ConstantGroupEntity( published, mems, @@ -1179,10 +1166,7 @@ rtl::Reference< Entity > readEntity( + paramName + " for constructor " + ctorName + " of single-interface--based service")); } - params.push_back( - SingleInterfaceBasedServiceEntity::Constructor:: - Parameter( - paramName, paramType, rest)); + params.emplace_back(paramName, paramType, rest); } std::vector< OUString > excs; m = file->read32(offset); @@ -1223,10 +1207,8 @@ rtl::Reference< Entity > readEntity( for (sal_uInt32 i = 0; i != n; ++i) { OUString base(file->readIdxName(&offset)); checkTypeName(file, base); - mandServs.push_back( - AnnotatedReference( - base, - readAnnotations(annotated, file, offset, &offset))); + mandServs.emplace_back( + base, readAnnotations(annotated, file, offset, &offset)); } n = file->read32(offset); if (n > SAL_MAX_INT32) { @@ -1240,10 +1222,8 @@ rtl::Reference< Entity > readEntity( for (sal_uInt32 i = 0; i != n; ++i) { OUString base(file->readIdxName(&offset)); checkTypeName(file, base); - optServs.push_back( - AnnotatedReference( - base, - readAnnotations(annotated, file, offset, &offset))); + optServs.emplace_back( + base, readAnnotations(annotated, file, offset, &offset)); } n = file->read32(offset); if (n > SAL_MAX_INT32) { @@ -1257,10 +1237,8 @@ rtl::Reference< Entity > readEntity( for (sal_uInt32 i = 0; i != n; ++i) { OUString base(file->readIdxName(&offset)); checkTypeName(file, base); - mandIfcs.push_back( - AnnotatedReference( - base, - readAnnotations(annotated, file, offset, &offset))); + mandIfcs.emplace_back( + base, readAnnotations(annotated, file, offset, &offset)); } n = file->read32(offset); if (n > SAL_MAX_INT32) { @@ -1274,10 +1252,8 @@ rtl::Reference< Entity > readEntity( for (sal_uInt32 i = 0; i != n; ++i) { OUString base(file->readIdxName(&offset)); checkTypeName(file, base); - optIfcs.push_back( - AnnotatedReference( - base, - readAnnotations(annotated, file, offset, &offset))); + optIfcs.emplace_back( + base, readAnnotations(annotated, file, offset, &offset)); } n = file->read32(offset); if (n > SAL_MAX_INT32) { @@ -1302,14 +1278,12 @@ rtl::Reference< Entity > readEntity( + " of property " + propName + " for accumulation-based servcie")); } - props.push_back( - AccumulationBasedServiceEntity::Property( - propName, propType, - static_cast< - AccumulationBasedServiceEntity::Property:: - Attributes >( - attrs), - readAnnotations(annotated, file, offset, &offset))); + props.emplace_back( + propName, propType, + static_cast< + AccumulationBasedServiceEntity::Property::Attributes >( + attrs), + readAnnotations(annotated, file, offset, &offset)); } return new AccumulationBasedServiceEntity( published, mandServs, optServs, mandIfcs, optIfcs, props, |