26#include <com/sun/star/bridge/XInstanceProvider.hpp>
27#include <com/sun/star/container/NoSuchElementException.hpp>
30#include <rtl/byteseq.hxx>
32#include <rtl/ustring.hxx>
35#include <typelib/typedescription.hxx>
36#include <uno/dispatcher.hxx>
48 OUString oid, css::uno::UnoInterfaceReference
object,
49 css::uno::TypeDescription type, sal_uInt16 functionId,
50 bool synchronous, css::uno::TypeDescription
const & member,
bool setter,
51 std::vector< BinaryAny >&& inArguments,
bool currentContextMode,
52 css::uno::UnoInterfaceReference currentContext):
54 member_(member), currentContext_(
std::move(currentContext)),
55 inArguments_(
std::move(inArguments)), functionId_(functionId),
56 synchronous_(synchronous), setter_(setter), currentContextMode_(currentContextMode)
60 assert(member.get()->bComplete);
63IncomingRequest::~IncomingRequest() {}
65void IncomingRequest::execute()
const {
67 std::vector< BinaryAny > outArgs;
71 css::uno::UnoInterfaceReference oldCc;
72 if (currentContextMode_) {
79 isExc = !execute_throw(&ret, &outArgs);
80 }
catch (
const std::exception & e) {
81 throw css::uno::RuntimeException(
82 "caught C++ exception: "
85 }
catch (
const css::uno::RuntimeException &) {
87 ret = bridge_->mapCppToBinaryAny(exc);
93 }
catch (
const css::uno::RuntimeException &) {
95 ret = bridge_->mapCppToBinaryAny(exc);
99 bridge_->decrementActiveCalls();
101 bridge_->getWriter()->queueReply(
102 tid_, member_, setter_, isExc, ret, std::move(outArgs),
false);
104 }
catch (
const css::uno::RuntimeException & e) {
105 SAL_INFO(
"binaryurp",
"caught " << e);
106 }
catch (
const std::exception & e) {
107 SAL_INFO(
"binaryurp",
"caught C++ exception " << e.what());
109 bridge_->terminate(
false);
112 SAL_INFO(
"binaryurp",
"oneway method raised exception");
114 bridge_->decrementCalls();
120 return (val + (
sizeof(
size_t)-1)) & ~(
sizeof(size_t)-1);
123bool IncomingRequest::execute_throw(
124 BinaryAny * returnValue, std::vector< BinaryAny > * outArguments)
const
126 assert(returnValue !=
nullptr);
130 assert(outArguments !=
nullptr);
131 assert(outArguments->empty());
133 switch (functionId_) {
138 bridge_->releaseStub(oid_,
type_);
142 css::uno::Reference< css::uno::XInterface > ifc;
143 css::uno::Reference< css::bridge::XInstanceProvider > prov(
144 bridge_->getProvider());
147 ifc = prov->getInstance(oid_);
148 }
catch (
const css::container::NoSuchElementException & e) {
149 SAL_INFO(
"binaryurp",
"initial element " << oid_ <<
": " << e);
153 css::uno::UnoInterfaceReference unoIfc(
154 static_cast< uno_Interface *
>(
155 bridge_->getCppToBinaryMapping().mapInterface(
157 (css::uno::TypeDescription(
160 css::uno::XInterface > >
::get()).
164 css::uno::TypeDescription(
167 css::uno::XInterface > >
::get()),
176 css::uno::TypeDescription retType;
177 std::vector< std::vector< char > > outBufs;
178 std::vector< void * >
args;
179 switch (member_.get()->eTypeClass) {
180 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
182 css::uno::TypeDescription
t(
184 typelib_InterfaceAttributeTypeDescription *
>(
188 assert(inArguments_.size() == 1);
191 assert(inArguments_.empty());
196 case typelib_TypeClass_INTERFACE_METHOD:
198 typelib_InterfaceMethodTypeDescription * mtd =
200 typelib_InterfaceMethodTypeDescription *
>(
202 retType = css::uno::TypeDescription(mtd->pReturnTypeRef);
203 std::vector< BinaryAny >::const_iterator
i(
204 inArguments_.begin());
205 for (sal_Int32 j = 0; j != mtd->nParams; ++j) {
207 if (mtd->pParams[j].bIn) {
209 css::uno::TypeDescription(
210 mtd->pParams[j].pTypeRef));
213 css::uno::TypeDescription(
214 mtd->pParams[j].pTypeRef).
216 p = outBufs.back().data();
219 if (mtd->pParams[j].bOut) {
223 assert(
i == inArguments_.end());
233 std::vector< char > retBuf(nSize);
237 object_.get(), member_.get(), retBuf.empty() ? nullptr : retBuf.data(),
238 args.empty() ? nullptr :
args.data(), &pexc);
239 isExc = pexc !=
nullptr;
242 css::uno::TypeDescription(
247 if (!retBuf.empty()) {
248 *returnValue =
BinaryAny(retType, retBuf.data());
251 if (!outArguments->empty()) {
253 member_.get()->eTypeClass ==
254 typelib_TypeClass_INTERFACE_METHOD);
255 typelib_InterfaceMethodTypeDescription * mtd =
257 typelib_InterfaceMethodTypeDescription *
>(
259 std::vector< BinaryAny >::iterator
i(outArguments->begin());
260 std::vector< std::vector< char > >::iterator j(
262 for (sal_Int32 k = 0; k != mtd->nParams; ++k) {
263 if (mtd->pParams[k].bOut) {
265 css::uno::TypeDescription(
266 mtd->pParams[k].pTypeRef),
269 if (!mtd->pParams[k].bIn) {
271 (j++)->data(), mtd->pParams[k].pTypeRef,
nullptr);
274 assert(
i == outArguments->end());
275 assert(j == outBufs.end());
void SAL_CALL uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
com::sun::star::uno::TypeDescription getType() const noexcept
IncomingRequest(const IncomingRequest &)=delete
void SAL_CALL uno_type_destructData(void *pValue, typelib_TypeDescriptionReference *pType, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
void SAL_CALL uno_destructData(void *pValue, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
#define SAL_INFO(area, stream)
void set(css::uno::UnoInterfaceReference const &value)
css::uno::UnoInterfaceReference get()
@ SPECIAL_FUNCTION_ID_RELEASE
@ SPECIAL_FUNCTION_ID_RESERVED
@ SPECIAL_FUNCTION_ID_QUERY_INTERFACE
static size_t size_t_round(size_t val)
Any SAL_CALL getCaughtException()
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
OUString runtimeToOUString(char const *runtimeString)