diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 08:12:18 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 13:15:15 +0200 |
commit | 4c71240a8e09f253d6156036485ed78449863f64 (patch) | |
tree | cf83678746b413911de7e1457686592840becf46 /cppuhelper | |
parent | a9d314b57b8eb897f977e4c2062f72d85d0a7964 (diff) |
Prepare for removal of non-const operator[] from Sequence in cppuhelper
Change-Id: I692f1faf0b6ebe26771f3b8c5be1aa548ebd8515
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124355
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/component_context.cxx | 3 | ||||
-rw-r--r-- | cppuhelper/source/propertysetmixin.cxx | 14 | ||||
-rw-r--r-- | cppuhelper/source/servicemanager.cxx | 4 | ||||
-rw-r--r-- | cppuhelper/source/typemanager.cxx | 89 |
4 files changed, 69 insertions, 41 deletions
diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx index 16264dae53c4..1aa3d33e5c35 100644 --- a/cppuhelper/source/component_context.cxx +++ b/cppuhelper/source/component_context.cxx @@ -288,8 +288,7 @@ Any ComponentContext::lookupMap( OUString const & rName ) Sequence<Any> args; if (args_.hasValue() && !(args_ >>= args)) { - args.realloc( 1 ); - args[ 0 ] = args_; + args = { args_ }; } Reference< lang::XSingleComponentFactory > xFac; diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx index 41f9442ff311..030160c65f0f 100644 --- a/cppuhelper/source/propertysetmixin.cxx +++ b/cppuhelper/source/propertysetmixin.cxx @@ -220,7 +220,7 @@ void Data::initProperties( break; } attrAttribs |= n; - css::uno::Sequence< + const css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > args( css::uno::Reference< @@ -291,11 +291,12 @@ css::uno::Sequence< css::beans::Property > Info::getProperties() assert(m_data->properties.size() <= SAL_MAX_INT32); css::uno::Sequence< css::beans::Property > s( static_cast< sal_Int32 >(m_data->properties.size())); + auto r = asNonConstRange(s); sal_Int32 n = 0; for (const auto& rEntry : m_data->properties) { if (rEntry.second.present) { - s[n++] = rEntry.second.property; + r[n++] = rEntry.second.property; } } s.realloc(n); @@ -1093,12 +1094,13 @@ PropertySetMixinImpl::getPropertyValues() { css::uno::Sequence< css::beans::PropertyValue > s( m_impl->handleMap.getLength()); + auto r = asNonConstRange(s); sal_Int32 n = 0; for (sal_Int32 i = 0; i < m_impl->handleMap.getLength(); ++i) { try { - s[n].Value = m_impl->getProperty( + r[n].Value = m_impl->getProperty( static_cast< css::beans::XPropertySet * >(this), - m_impl->handleMap[i], &s[n].State); + m_impl->handleMap[i], &r[n].State); } catch (css::beans::UnknownPropertyException &) { continue; } catch (css::lang::WrappedTargetException & e) { @@ -1106,8 +1108,8 @@ PropertySetMixinImpl::getPropertyValues() e.Message, static_cast< css::beans::XPropertySet * >(this), e.TargetException); } - s[n].Name = m_impl->handleMap[i]; - s[n].Handle = i; + r[n].Name = m_impl->handleMap[i]; + r[n].Handle = i; ++n; } s.realloc(n); diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index 121ad088dc50..57a3b646858e 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -1279,9 +1279,7 @@ void cppuhelper::ServiceManager::removeVetoableChangeListener( css::uno::Sequence< css::beans::Property > cppuhelper::ServiceManager::getProperties() { - css::uno::Sequence< css::beans::Property > props(1); - props[0] = getDefaultContextProperty(); - return props; + return { getDefaultContextProperty() }; } css::beans::Property cppuhelper::ServiceManager::getPropertyByName( diff --git a/cppuhelper/source/typemanager.cxx b/cppuhelper/source/typemanager.cxx index 82aad46483fc..d6bf844a74ee 100644 --- a/cppuhelper/source/typemanager.cxx +++ b/cppuhelper/source/typemanager.cxx @@ -179,8 +179,9 @@ ModuleDescription::getMembers() { sal_Int32 n = static_cast< sal_Int32 >(names.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(makePrefix(name_) + names[i]); + r[i] = manager_->resolve(makePrefix(name_) + names[i]); } return s; } catch (unoidl::FileFormatException & e) { @@ -228,8 +229,9 @@ css::uno::Sequence< OUString > EnumTypeDescription::getEnumNames() assert(entity_->getMembers().size() <= SAL_MAX_INT32); sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size()); css::uno::Sequence< OUString > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getMembers()[i].name; + r[i] = entity_->getMembers()[i].name; } return s; } @@ -239,8 +241,9 @@ css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues() assert(entity_->getMembers().size() <= SAL_MAX_INT32); sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size()); css::uno::Sequence< sal_Int32 > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getMembers()[i].value; + r[i] = entity_->getMembers()[i].value; } return s; } @@ -305,8 +308,9 @@ PlainStructTypeDescription::getMemberTypes() sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(entity_->getDirectMembers()[i].type); + r[i] = manager_->resolve(entity_->getDirectMembers()[i].type); } return s; } @@ -316,8 +320,9 @@ css::uno::Sequence< OUString > PlainStructTypeDescription::getMemberNames() assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32); sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size()); css::uno::Sequence< OUString > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getDirectMembers()[i].name; + r[i] = entity_->getDirectMembers()[i].name; } return s; } @@ -402,8 +407,9 @@ PolymorphicStructTypeTemplateDescription::getMemberTypes() sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getMembers()[i].parameterized + r[i] = entity_->getMembers()[i].parameterized ? new ParameterizedMemberTypeDescription( entity_->getMembers()[i].type) : manager_->resolve(entity_->getMembers()[i].type); @@ -417,8 +423,9 @@ PolymorphicStructTypeTemplateDescription::getMemberNames() assert(entity_->getMembers().size() <= SAL_MAX_INT32); sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size()); css::uno::Sequence< OUString > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getMembers()[i].name; + r[i] = entity_->getMembers()[i].name; } return s; } @@ -429,8 +436,9 @@ PolymorphicStructTypeTemplateDescription::getTypeParameters() assert(entity_->getTypeParameters().size() <= SAL_MAX_INT32); sal_Int32 n = static_cast< sal_Int32 >(entity_->getTypeParameters().size()); css::uno::Sequence< OUString > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getTypeParameters()[i]; + r[i] = entity_->getTypeParameters()[i]; } return s; } @@ -493,6 +501,7 @@ InstantiatedPolymorphicStructTypeDescription::getMemberTypes() sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { OUString type(entity_->getMembers()[i].type); if (entity_->getMembers()[i].parameterized) { @@ -504,7 +513,7 @@ InstantiatedPolymorphicStructTypeDescription::getMemberTypes() assert(false); // this cannot happen //TODO! found:; } - s[i] = manager_->resolve(type); + r[i] = manager_->resolve(type); } return s; } @@ -515,8 +524,9 @@ InstantiatedPolymorphicStructTypeDescription::getMemberNames() assert(entity_->getMembers().size() <= SAL_MAX_INT32); sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size()); css::uno::Sequence< OUString > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getMembers()[i].name; + r[i] = entity_->getMembers()[i].name; } return s; } @@ -527,8 +537,9 @@ InstantiatedPolymorphicStructTypeDescription::getTypeArguments() sal_Int32 n = static_cast< sal_Int32 >(arguments_.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(arguments_[i]); + r[i] = manager_->resolve(arguments_[i]); } return s; } @@ -581,8 +592,9 @@ ExceptionTypeDescription::getMemberTypes() { sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(entity_->getDirectMembers()[i].type); + r[i] = manager_->resolve(entity_->getDirectMembers()[i].type); } return s; } @@ -592,8 +604,9 @@ css::uno::Sequence< OUString > ExceptionTypeDescription::getMemberNames() assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32); sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size()); css::uno::Sequence< OUString > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = entity_->getDirectMembers()[i].name; + r[i] = entity_->getDirectMembers()[i].name; } return s; } @@ -660,8 +673,9 @@ AttributeDescription::getGetExceptions() { sal_Int32 n = static_cast< sal_Int32 >(attribute_.getExceptions.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i].set( + r[i].set( manager_->resolve(attribute_.getExceptions[i]), css::uno::UNO_QUERY_THROW); } @@ -675,8 +689,9 @@ AttributeDescription::getSetExceptions() { sal_Int32 n = static_cast< sal_Int32 >(attribute_.setExceptions.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i].set( + r[i].set( manager_->resolve(attribute_.setExceptions[i]), css::uno::UNO_QUERY_THROW); } @@ -786,8 +801,9 @@ MethodDescription::getParameters() { sal_Int32 n = static_cast< sal_Int32 >(method_.parameters.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XMethodParameter > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = new MethodParameter(manager_, method_.parameters[i], i); + r[i] = new MethodParameter(manager_, method_.parameters[i], i); } return s; } @@ -798,8 +814,9 @@ MethodDescription::getExceptions() { sal_Int32 n = static_cast< sal_Int32 >(method_.exceptions.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(method_.exceptions[i]); + r[i] = manager_->resolve(method_.exceptions[i]); } return s; } @@ -928,14 +945,15 @@ InterfaceTypeDescription::getMembers() { css::uno::Sequence< css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > > s(n1 + n2); + auto r = asNonConstRange(s); sal_Int32 off = BaseOffset(this).get(); for (sal_Int32 i = 0; i != n1; ++i) { - s[i] = new AttributeDescription( + r[i] = new AttributeDescription( manager_, name_ + "::" + entity_->getDirectAttributes()[i].name, entity_->getDirectAttributes()[i], off + i); } for (sal_Int32 i = 0; i != n2; ++i) { - s[n1 + i] = new MethodDescription( + r[n1 + i] = new MethodDescription( manager_, name_ + "::" + entity_->getDirectMethods()[i].name, entity_->getDirectMethods()[i], off + n1 + i); } @@ -949,8 +967,9 @@ InterfaceTypeDescription::getBaseTypes() { entity_->getDirectMandatoryBases().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(entity_->getDirectMandatoryBases()[i].name); + r[i] = manager_->resolve(entity_->getDirectMandatoryBases()[i].name); } return s; } @@ -963,8 +982,9 @@ InterfaceTypeDescription::getOptionalBaseTypes() entity_->getDirectOptionalBases().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(entity_->getDirectOptionalBases()[i].name); + r[i] = manager_->resolve(entity_->getDirectOptionalBases()[i].name); } return s; } @@ -1072,8 +1092,9 @@ ConstantGroupDescription::getConstants() { sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = new ConstantDescription(name_, entity_->getMembers()[i]); + r[i] = new ConstantDescription(name_, entity_->getMembers()[i]); } return s; } @@ -1191,8 +1212,9 @@ ConstructorDescription::getParameters() { sal_Int32 n = static_cast< sal_Int32 >(constructor_.parameters.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > > s( n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = new ConstructorParameter( + r[i] = new ConstructorParameter( manager_, constructor_.parameters[i], i); } return s; @@ -1205,8 +1227,9 @@ ConstructorDescription::getExceptions() { sal_Int32 n = static_cast< sal_Int32 >(constructor_.exceptions.size()); css::uno::Sequence< css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i].set( + r[i].set( manager_->resolve(constructor_.exceptions[i]), css::uno::UNO_QUERY_THROW); } @@ -1313,8 +1336,9 @@ SingleInterfaceBasedServiceDescription::getConstructors() css::uno::Sequence< css::uno::Reference< css::reflection::XServiceConstructorDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = new ConstructorDescription( + r[i] = new ConstructorDescription( manager_, entity_->getConstructors()[i]); } return s; @@ -1432,8 +1456,9 @@ AccumulationBasedServiceDescription::getMandatoryServices() entity_->getDirectMandatoryBaseServices().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i].set( + r[i].set( manager_->resolve( entity_->getDirectMandatoryBaseServices()[i].name), css::uno::UNO_QUERY_THROW); @@ -1450,8 +1475,9 @@ AccumulationBasedServiceDescription::getOptionalServices() entity_->getDirectOptionalBaseServices().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i].set( + r[i].set( manager_->resolve(entity_->getDirectOptionalBaseServices()[i].name), css::uno::UNO_QUERY_THROW); } @@ -1468,8 +1494,9 @@ AccumulationBasedServiceDescription::getMandatoryInterfaces() css::uno::Sequence< css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s( n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i].set( + r[i].set( resolveTypedefs( manager_->find( entity_->getDirectMandatoryBaseInterfaces()[i].name)), @@ -1488,8 +1515,9 @@ AccumulationBasedServiceDescription::getOptionalInterfaces() css::uno::Sequence< css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s( n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i].set( + r[i].set( resolveTypedefs( manager_->find( entity_->getDirectOptionalBaseInterfaces()[i].name)), @@ -1507,8 +1535,9 @@ AccumulationBasedServiceDescription::getProperties() entity_->getDirectProperties().size()); css::uno::Sequence< css::uno::Reference< css::reflection::XPropertyTypeDescription > > s(n); + auto r = asNonConstRange(s); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = new PropertyDescription( + r[i] = new PropertyDescription( manager_, entity_->getDirectProperties()[i]); } return s; |