30#include <rtl/ustring.hxx>
32#include <typelib/typedescription.h>
33#include <typelib/typedescription.hxx>
35#include <uno/dispatcher.h>
36#include <uno/dispatcher.hxx>
46extern "C" void proxy_acquireInterface(uno_Interface * pInterface) {
47 assert(pInterface !=
nullptr);
48 static_cast< Proxy *
>(pInterface)->do_acquire();
51extern "C" void proxy_releaseInterface(uno_Interface * pInterface) {
52 assert(pInterface !=
nullptr);
53 static_cast< Proxy *
>(pInterface)->do_release();
56extern "C" void proxy_dispatchInterface(
58 void * pReturn,
void ** pArgs,
uno_Any ** ppException)
60 assert(pUnoI !=
nullptr);
61 static_cast< Proxy *
>(pUnoI)->do_dispatch(
62 pMemberType, pReturn, pArgs, ppException);
69 css::uno::TypeDescription type):
70 bridge_(bridge), oid_(
std::move(oid)),
type_(
std::move(
type)), references_(1)
73 acquire = &proxy_acquireInterface;
74 release = &proxy_releaseInterface;
75 pDispatcher = &proxy_dispatchInterface;
79void Proxy::do_acquire() {
80 if (++references_ == 1) {
81 bridge_->resurrectProxy(*
this);
85void Proxy::do_release() {
86 if (--references_ == 0) {
87 bridge_->revokeProxy(*
this);
91void Proxy::do_free() {
92 bridge_->freeProxy(*
this);
96void Proxy::do_dispatch(
98 void ** arguments,
uno_Any ** exception)
const
102 do_dispatch_throw(member, returnValue, arguments, exception);
103 }
catch (
const std::exception & e) {
104 throw css::uno::RuntimeException(
107 }
catch (
const css::uno::RuntimeException &) {
113 bridge_->getCppToBinaryMapping().get());
119 css::uno::UnoInterfaceReference
const &
object, OUString * oid)
122 return object.m_pUnoI->acquire == &proxy_acquireInterface &&
123 static_cast< Proxy *
>(
object.m_pUnoI)->isProxy(bridge, oid);
128void Proxy::do_dispatch_throw(
130 void ** arguments,
uno_Any ** exception)
const
133 assert(member !=
nullptr);
134 bool bSetter =
false;
135 std::vector< BinaryAny > inArgs;
136 switch (member->eTypeClass) {
137 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
138 bSetter = returnValue ==
nullptr;
141 css::uno::TypeDescription(
143 typelib_InterfaceAttributeTypeDescription
const *
>(
149 case typelib_TypeClass_INTERFACE_METHOD:
151 typelib_InterfaceMethodTypeDescription
const * mtd =
153 typelib_InterfaceMethodTypeDescription
const *
>(member);
154 for (sal_Int32
i = 0;
i != mtd->nParams; ++
i) {
155 if (mtd->pParams[
i].bIn) {
157 css::uno::TypeDescription(mtd->pParams[
i].pTypeRef),
168 std::vector< BinaryAny > outArgs;
169 if (bridge_->makeCall(
171 css::uno::TypeDescription(
173 bSetter, std::move(inArgs), &ret, &outArgs))
175 assert(ret.
getType().get()->eTypeClass == typelib_TypeClass_EXCEPTION);
179 switch (member->eTypeClass) {
180 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
182 css::uno::TypeDescription
t(
184 typelib_InterfaceAttributeTypeDescription
const *
>(
190 case typelib_TypeClass_INTERFACE_METHOD:
192 typelib_InterfaceMethodTypeDescription
const * mtd =
194 typelib_InterfaceMethodTypeDescription
const *
>(
196 css::uno::TypeDescription
t(mtd->pReturnTypeRef);
197 if (
t.get()->eTypeClass != typelib_TypeClass_VOID) {
200 std::vector< BinaryAny >::iterator
i(outArgs.begin());
201 for (sal_Int32 j = 0; j != mtd->nParams; ++j) {
202 if (mtd->pParams[j].bOut) {
203 css::uno::TypeDescription
pt(mtd->pParams[j].pTypeRef);
204 if (mtd->pParams[j].bIn) {
206 arguments[j],
pt.get(),
i++->getValue(
pt),
207 pt.get(),
nullptr,
nullptr,
nullptr);
214 assert(
i == outArgs.end());
221 *exception =
nullptr;
228 assert(oid !=
nullptr);
229 if (bridge == bridge_) {
void SAL_CALL uno_any_construct(uno_Any *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
com::sun::star::uno::TypeDescription getType() const noexcept
void * getValue(com::sun::star::uno::TypeDescription const &type) const noexcept
Proxy(rtl::Reference< Bridge > const &bridge, OUString oid, com::sun::star::uno::TypeDescription type)
sal_Bool SAL_CALL uno_assignData(void *pDest, typelib_TypeDescription *pDestTD, void *pSource, typelib_TypeDescription *pSourceTD, uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
void SAL_CALL uno_copyData(void *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
void SAL_CALL uno_copyAndConvertData(void *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_Mapping *mapping) SAL_THROW_EXTERN_C()
struct _typelib_TypeDescription typelib_TypeDescription
css::uno::UnoInterfaceReference get()
Any SAL_CALL getCaughtException()
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
OUString runtimeToOUString(char const *runtimeString)