diff options
author | Noel Grandin <noel@peralex.com> | 2014-05-23 12:03:21 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-05-23 15:06:00 +0200 |
commit | e7bc3cab019fbf040f9fb8b53ae2cf3f977d200b (patch) | |
tree | bc507bccee9fb71134e362b72d22991561e32aa0 /binaryurp | |
parent | c5d47c327a57df55fa3dac0fff6b65888d0345e4 (diff) |
remove boilerplate in UNO Exception constructor calls
Now that we have default values for Exception constructor params,
remove lots of boilerplate code.
Change-Id: I620bd641eecfed38e6123873b3b94aaf47922e74
Diffstat (limited to 'binaryurp')
-rw-r--r-- | binaryurp/source/bridge.cxx | 24 | ||||
-rw-r--r-- | binaryurp/source/currentcontext.cxx | 8 | ||||
-rw-r--r-- | binaryurp/source/incomingrequest.cxx | 7 | ||||
-rw-r--r-- | binaryurp/source/marshal.cxx | 3 | ||||
-rw-r--r-- | binaryurp/source/outgoingrequests.cxx | 3 | ||||
-rw-r--r-- | binaryurp/source/proxy.cxx | 5 | ||||
-rw-r--r-- | binaryurp/source/reader.cxx | 57 | ||||
-rw-r--r-- | binaryurp/source/unmarshal.cxx | 61 | ||||
-rw-r--r-- | binaryurp/source/writer.cxx | 7 |
9 files changed, 60 insertions, 115 deletions
diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx index ac13fa29fec1..c93df640b555 100644 --- a/binaryurp/source/bridge.cxx +++ b/binaryurp/source/bridge.cxx @@ -194,14 +194,10 @@ Bridge::Bridge( { assert(factory.is() && connection.is()); if (!binaryUno_.is()) { - throw css::uno::RuntimeException( - "URP: no binary UNO environment", - css::uno::Reference< css::uno::XInterface >()); + throw css::uno::RuntimeException("URP: no binary UNO environment"); } if (!(cppToBinaryMapping_.is() && binaryToCppMapping_.is())) { - throw css::uno::RuntimeException( - "URP: no C++ UNO mapping", - css::uno::Reference< css::uno::XInterface >()); + throw css::uno::RuntimeException("URP: no C++ UNO mapping"); } passive_.set(); } @@ -464,8 +460,7 @@ OUString Bridge::registerOutgoingInterface( assert(stub != &newStub); if (j->second.references == SAL_MAX_UINT32) { throw css::uno::RuntimeException( - "URP: stub reference count overflow", - css::uno::Reference< css::uno::XInterface >()); + "URP: stub reference count overflow"); } ++j->second.references; } @@ -505,15 +500,11 @@ void Bridge::releaseStub( osl::MutexGuard g(mutex_); Stubs::iterator i(stubs_.find(oid)); if (i == stubs_.end()) { - throw css::uno::RuntimeException( - "URP: release unknown stub", - css::uno::Reference< css::uno::XInterface >()); + throw css::uno::RuntimeException("URP: release unknown stub"); } Stub::iterator j(i->second.find(type)); if (j == i->second.end()) { - throw css::uno::RuntimeException( - "URP: release unknown stub", - css::uno::Reference< css::uno::XInterface >()); + throw css::uno::RuntimeException("URP: release unknown stub"); } assert(j->second.references > 0); --j->second.references; @@ -880,9 +871,8 @@ css::uno::Reference< css::uno::XInterface > Bridge::getInstance( for (sal_Int32 i = 0; i != sInstanceName.getLength(); ++i) { if (sInstanceName[i] > 0x7F) { throw css::uno::RuntimeException( - ("XBridge::getInstance sInstanceName contains non-ASCII" - " character"), - css::uno::Reference< css::uno::XInterface >()); + "XBridge::getInstance sInstanceName contains non-ASCII" + " character"); } } css::uno::TypeDescription ifc( diff --git a/binaryurp/source/currentcontext.cxx b/binaryurp/source/currentcontext.cxx index 143dd34879ac..81d46672dbd2 100644 --- a/binaryurp/source/currentcontext.cxx +++ b/binaryurp/source/currentcontext.cxx @@ -40,9 +40,7 @@ css::uno::UnoInterfaceReference get() { reinterpret_cast< void ** >(&cc.m_pUnoI), OUString(UNO_LB_UNO).pData, 0)) { - throw css::uno::RuntimeException( - "uno_getCurrentContext failed", - css::uno::Reference< css::uno::XInterface >()); + throw css::uno::RuntimeException("uno_getCurrentContext failed"); } return cc; } @@ -53,9 +51,7 @@ void set(css::uno::UnoInterfaceReference const & value) { cc.m_pUnoI, OUString(UNO_LB_UNO).pData, 0)) { - throw css::uno::RuntimeException( - "uno_setCurrentContext failed", - css::uno::Reference< css::uno::XInterface >()); + throw css::uno::RuntimeException("uno_setCurrentContext failed"); } } diff --git a/binaryurp/source/incomingrequest.cxx b/binaryurp/source/incomingrequest.cxx index ff30a8e142e9..30b876ef81c8 100644 --- a/binaryurp/source/incomingrequest.cxx +++ b/binaryurp/source/incomingrequest.cxx @@ -74,10 +74,9 @@ void IncomingRequest::execute() const { isExc = !execute_throw(&ret, &outArgs); } catch (const std::exception & e) { throw css::uno::RuntimeException( - ("caught C++ exception: " + - OStringToOUString( - OString(e.what()), RTL_TEXTENCODING_ASCII_US)), - css::uno::Reference< css::uno::XInterface >()); + "caught C++ exception: " + + OStringToOUString( + OString(e.what()), RTL_TEXTENCODING_ASCII_US)); // best-effort string conversion } } catch (const css::uno::RuntimeException &) { diff --git a/binaryurp/source/marshal.cxx b/binaryurp/source/marshal.cxx index 241c2be3fda8..ad5f2b882a63 100644 --- a/binaryurp/source/marshal.cxx +++ b/binaryurp/source/marshal.cxx @@ -81,8 +81,7 @@ void writeString( RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) { throw css::uno::RuntimeException( - "UNO string contains invalid UTF-16 sequence", - css::uno::Reference< css::uno::XInterface >()); + "UNO string contains invalid UTF-16 sequence"); } writeCompressed(buffer, static_cast< sal_uInt32 >(v.getLength())); buffer->insert(buffer->end(), v.getStr(), v.getStr() + v.getLength()); diff --git a/binaryurp/source/outgoingrequests.cxx b/binaryurp/source/outgoingrequests.cxx index a0fb6d272f82..06b2553629e9 100644 --- a/binaryurp/source/outgoingrequests.cxx +++ b/binaryurp/source/outgoingrequests.cxx @@ -45,8 +45,7 @@ OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) { Map::iterator i(map_.find(tid)); if (i == map_.end()) { throw css::uno::RuntimeException( - "URP: reply for unknown TID", - css::uno::Reference< css::uno::XInterface >()); + "URP: reply for unknown TID"); } OSL_ASSERT(!i->second.empty()); return i->second.back(); diff --git a/binaryurp/source/proxy.cxx b/binaryurp/source/proxy.cxx index 355ac8787d1f..a28dbc5ef560 100644 --- a/binaryurp/source/proxy.cxx +++ b/binaryurp/source/proxy.cxx @@ -107,10 +107,9 @@ void Proxy::do_dispatch( do_dispatch_throw(member, returnValue, arguments, exception); } catch (const std::exception & e) { throw css::uno::RuntimeException( - ("caught C++ exception: " + + "caught C++ exception: " + OStringToOUString( - OString(e.what()), RTL_TEXTENCODING_ASCII_US)), - css::uno::Reference< css::uno::XInterface >()); + OString(e.what()), RTL_TEXTENCODING_ASCII_US)); // best-effort string conversion } } catch (const css::uno::RuntimeException &) { diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx index 99b27443a5dc..92da48519f33 100644 --- a/binaryurp/source/reader.cxx +++ b/binaryurp/source/reader.cxx @@ -63,8 +63,7 @@ css::uno::Sequence< sal_Int8 > read( assert(connection.is()); if (size > SAL_MAX_INT32) { throw css::uno::RuntimeException( - "binaryurp::Reader: block size too large", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Reader: block size too large"); } css::uno::Sequence< sal_Int8 > buf; sal_Int32 n = connection->read(buf, static_cast< sal_Int32 >(size)); @@ -73,8 +72,7 @@ css::uno::Sequence< sal_Int8 > read( } if (n != static_cast< sal_Int32 >(size)) { throw css::io::IOException( - "binaryurp::Reader: premature end of input", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Reader: premature end of input"); } assert(buf.getLength() == static_cast< sal_Int32 >(size)); return buf; @@ -113,8 +111,7 @@ void Reader::execute() { header.done(); if (count == 0) { throw css::io::IOException( - "binaryurp::Reader: block with zero message count received", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Reader: block with zero message count received"); } Unmarshal block(bridge_, state_, read(con, size, false)); for (sal_uInt32 i = 0; i != count; ++i) { @@ -152,9 +149,8 @@ void Reader::readMessage(Unmarshal & unmarshal) { if (((flags2 & 0x40) != 0) != forceSynchronous) { // bit 6: SYNCHRONOUS throw css::uno::RuntimeException( - ("URP: request message with MUSTREPLY != SYNCHRONOUS" - " received"), - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with MUSTREPLY != SYNCHRONOUS" + " received"); } } else { forceSynchronous = false; @@ -176,9 +172,8 @@ void Reader::readMessage(Unmarshal & unmarshal) { } else { if (!lastType_.is()) { throw css::uno::RuntimeException( - ("URP: request message with NEWTYPE received when last" - " interface type has not yet been set"), - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with NEWTYPE received when last" + " interface type has not yet been set"); } type = lastType_; } @@ -187,16 +182,14 @@ void Reader::readMessage(Unmarshal & unmarshal) { oid = unmarshal.readOid(); if (oid.isEmpty()) { throw css::io::IOException( - "binaryurp::Unmarshal: emtpy OID", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: emtpy OID"); } lastOid_ = oid; } else { if (lastOid_.isEmpty()) { throw css::uno::RuntimeException( - ("URP: request message with NEWOID received when last OID has" - " not yet been set"), - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with NEWOID received when last OID has" + " not yet been set"); } oid = lastOid_; } @@ -205,15 +198,13 @@ void Reader::readMessage(Unmarshal & unmarshal) { type.makeComplete(); if (type.get()->eTypeClass != typelib_TypeClass_INTERFACE) { throw css::uno::RuntimeException( - "URP: request message with non-interface interface type received", - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with non-interface interface type received"); } typelib_InterfaceTypeDescription * itd = reinterpret_cast< typelib_InterfaceTypeDescription * >(type.get()); if (functionId >= itd->nMapFunctionIndexToMemberIndex) { throw css::uno::RuntimeException( - "URP: request message with unknown function ID received", - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with unknown function ID received"); } sal_Int32 memberId = itd->pMapFunctionIndexToMemberIndex[functionId]; css::uno::TypeDescription memberTd(itd->ppAllMembers[memberId]); @@ -289,9 +280,8 @@ void Reader::readMessage(Unmarshal & unmarshal) { break; default: throw css::uno::RuntimeException( - ("URP: request message with UrpProtocolProperties OID and" - " unknown function ID received"), - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with UrpProtocolProperties OID and" + " unknown function ID received"); } } else { css::uno::UnoInterfaceReference obj; @@ -320,24 +310,21 @@ void Reader::readMessage(Unmarshal & unmarshal) { css::uno::XInterface > >::get()))))) { throw css::uno::RuntimeException( - ("URP: queryInterface request message with unknown OID" - " received"), - css::uno::Reference< css::uno::XInterface >()); + "URP: queryInterface request message with unknown OID" + " received"); } } break; case SPECIAL_FUNCTION_ID_RESERVED: throw css::uno::RuntimeException( - "URP: request message with unknown function ID 1 received", - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with unknown function ID 1 received"); case SPECIAL_FUNCTION_ID_RELEASE: break; default: obj = bridge_->findStub(oid, type); if (!obj.is()) { throw css::uno::RuntimeException( - "URP: request message with unknown OID received", - css::uno::Reference< css::uno::XInterface >()); + "URP: request message with unknown OID received"); } break; } @@ -413,8 +400,7 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) { } if (!ok) { throw css::uno::RuntimeException( - "URP: reply message with bad exception type received", - css::uno::Reference< css::uno::XInterface >()); + "URP: reply message with bad exception type received"); } } } else { @@ -483,9 +469,8 @@ rtl::ByteSequence Reader::getTid(Unmarshal & unmarshal, bool newTid) const { } if (lastTid_.getLength() == 0) { throw css::uno::RuntimeException( - ("URP: message with NEWTID received when last TID has not yet been" - " set"), - css::uno::Reference< css::uno::XInterface >()); + "URP: message with NEWTID received when last TID has not yet been" + " set"); } return lastTid_; } diff --git a/binaryurp/source/unmarshal.cxx b/binaryurp/source/unmarshal.cxx index d413e5f84e78..d04c8893265d 100644 --- a/binaryurp/source/unmarshal.cxx +++ b/binaryurp/source/unmarshal.cxx @@ -144,8 +144,7 @@ css::uno::TypeDescription Unmarshal::readType() { case typelib_TypeClass_ANY: if ((flags & 0x80) != 0) { throw css::io::IOException( - "binaryurp::Unmarshal: cache flag of simple type is set", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: cache flag of simple type is set"); } return css::uno::TypeDescription( *typelib_static_type_getByTypeClass( @@ -160,8 +159,7 @@ css::uno::TypeDescription Unmarshal::readType() { if ((flags & 0x80) == 0) { if (idx == cache::ignore || !state_.typeCache[idx].is()) { throw css::io::IOException( - "binaryurp::Unmarshal: unknown type cache index", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: unknown type cache index"); } return state_.typeCache[idx]; } else { @@ -172,8 +170,7 @@ css::uno::TypeDescription Unmarshal::readType() { { throw css::io::IOException( - "binaryurp::Unmarshal: type with unknown name: " + str, - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: type with unknown name: " + str); } for (css::uno::TypeDescription t2(t); t2.get()->eTypeClass == typelib_TypeClass_SEQUENCE;) @@ -184,17 +181,15 @@ css::uno::TypeDescription Unmarshal::readType() { t2.get())->pType); if (!t2.is()) { throw css::io::IOException( - ("binaryurp::Unmarshal: sequence type with unknown" - " component type"), - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: sequence type with unknown" + " component type"); } switch (t2.get()->eTypeClass) { case typelib_TypeClass_VOID: case typelib_TypeClass_EXCEPTION: throw css::io::IOException( - ("binaryurp::Unmarshal: sequence type with bad" - " component type"), - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: sequence type with bad" + " component type"); default: break; } @@ -207,8 +202,7 @@ css::uno::TypeDescription Unmarshal::readType() { } default: throw css::io::IOException( - "binaryurp::Unmarshal: type of unknown type class", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: type of unknown type class"); } } @@ -217,16 +211,14 @@ OUString Unmarshal::readOid() { for (sal_Int32 i = 0; i != oid.getLength(); ++i) { if (oid[i] > 0x7F) { throw css::io::IOException( - "binaryurp::Unmarshal: OID contains non-ASCII character", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: OID contains non-ASCII character"); } } sal_uInt16 idx = readCacheIndex(); if (oid.isEmpty() && idx != cache::ignore) { if (state_.oidCache[idx].isEmpty()) { throw css::io::IOException( - "binaryurp::Unmarshal: unknown OID cache index", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: unknown OID cache index"); } return state_.oidCache[idx]; } @@ -249,8 +241,7 @@ rtl::ByteSequence Unmarshal::readTid() { if (tid.getLength() == 0) { if (idx == cache::ignore || state_.tidCache[idx].getLength() == 0) { throw css::io::IOException( - "binaryurp::Unmarshal: unknown TID cache index", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: unknown TID cache index"); } return state_.tidCache[idx]; } @@ -273,8 +264,7 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) { sal_uInt8 v = read8(); if (v > 1) { throw css::io::IOException( - "binaryurp::Unmarshal: boolean of unknown value", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: boolean of unknown value"); } return BinaryAny(type, &v); } @@ -320,8 +310,7 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) { css::uno::TypeDescription t(readType()); if (t.get()->eTypeClass == typelib_TypeClass_ANY) { throw css::io::IOException( - "binaryurp::Unmarshal: any of type ANY", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: any of type ANY"); } return readValue(t); } @@ -343,8 +332,7 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) { } if (!found) { throw css::io::IOException( - "binaryurp::Unmarshal: unknown enum value", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: unknown enum value"); } return BinaryAny(type, &v); } @@ -374,16 +362,14 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) { void Unmarshal::done() const { if (data_ != end_) { throw css::io::IOException( - "binaryurp::Unmarshal: block contains excess data", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: block contains excess data"); } } void Unmarshal::check(sal_Int32 size) const { if (end_ - data_ < size) { throw css::io::IOException( - "binaryurp::Unmarshal: trying to read past end of block", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: trying to read past end of block"); } } @@ -396,8 +382,7 @@ sal_uInt16 Unmarshal::readCacheIndex() { sal_uInt16 idx = read16(); if (idx >= cache::size && idx != cache::ignore) { throw css::io::IOException( - "binaryurp::Unmarshal: cache index out of range", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: cache index out of range"); } return idx; } @@ -418,8 +403,7 @@ OUString Unmarshal::readString() { sal_uInt32 n = readCompressed(); if (n > SAL_MAX_INT32) { throw css::uno::RuntimeException( - "binaryurp::Unmarshal: string size too large", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: string size too large"); } check(static_cast< sal_Int32 >(n)); OUString s; @@ -431,8 +415,7 @@ OUString Unmarshal::readString() { RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) { throw css::io::IOException( - "binaryurp::Unmarshal: string does not contain UTF-8", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: string does not contain UTF-8"); } data_ += n; return s; @@ -443,8 +426,7 @@ BinaryAny Unmarshal::readSequence(css::uno::TypeDescription const & type) { sal_uInt32 n = readCompressed(); if (n > SAL_MAX_INT32) { throw css::uno::RuntimeException( - "binaryurp::Unmarshal: sequence size too large", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: sequence size too large"); } if (n == 0) { return BinaryAny(type, 0); @@ -471,8 +453,7 @@ BinaryAny Unmarshal::readSequence(css::uno::TypeDescription const & type) { // sal_uInt32 * sal_Int32 -> sal_uInt64 cannot overflow if (size > SAL_MAX_SIZE - SAL_SEQUENCE_HEADER_SIZE) { throw css::uno::RuntimeException( - "binaryurp::Unmarshal: sequence size too large", - css::uno::Reference< css::uno::XInterface >()); + "binaryurp::Unmarshal: sequence size too large"); } void * buf = allocate( SAL_SEQUENCE_HEADER_SIZE + static_cast< sal_Size >(size)); diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx index 6b666b089057..a47abf81a822 100644 --- a/binaryurp/source/writer.cxx +++ b/binaryurp/source/writer.cxx @@ -238,9 +238,7 @@ void Writer::sendRequest( } OSL_ASSERT(functionId >= 0); if (functionId > SAL_MAX_UINT16) { - throw css::uno::RuntimeException( - "function ID too large for URP", - css::uno::Reference< css::uno::XInterface >()); + throw css::uno::RuntimeException("function ID too large for URP"); } std::vector< unsigned char > buf; bool newType = !(lastType_.is() && t.equals(lastType_)); @@ -406,8 +404,7 @@ void Writer::sendMessage(std::vector< unsigned char > const & buffer) { std::vector< unsigned char > header; if (buffer.size() > SAL_MAX_UINT32) { throw css::uno::RuntimeException( - "message too large for URP", - css::uno::Reference< css::uno::XInterface >()); + "message too large for URP"); } Marshal::write32(&header, static_cast< sal_uInt32 >(buffer.size())); Marshal::write32(&header, 1); |