2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-28 21:09:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
#include <sal/config.h>
|
Make sure space handed to C/C++ ABI is padded large enough
PythonTest_pyuno_pytests_testcollections had failed with -fsanitize=address:
> ==6341==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffe5cf77048 at pc 0x7f6be12e51ba bp 0x7ffe5cf76810 sp 0x7ffe5cf76808
> WRITE of size 8 at 0x7ffe5cf77048 thread T0
> #0 0x7f6be12e51b9 in x86_64::fill_struct(_typelib_TypeDescriptionReference*, unsigned long const*, double const*, void*) bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx
> #1 0x7f6be1307f03 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:171:17
> #2 0x7f6be130346d in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233:13
> #3 0x7f6be1301c56 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(_uno_Interface*, _typelib_TypeDescription const*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:420:13
> #4 0x7f6be0be09ff in stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx:679:9
> #5 0x7f6be0be304c in non-virtual thunk to stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx
> #6 0x7f6be0375ef9 in (anonymous namespace)::IntrospectionAccessStatic_Impl::getPropertyValueByIndex(com::sun::star::uno::Any const&, int) const stoc/source/inspect/introspection.cxx:609:33
> #7 0x7f6be03753eb in (anonymous namespace)::IntrospectionAccessStatic_Impl::getPropertyValue(com::sun::star::uno::Any const&, rtl::OUString const&) const stoc/source/inspect/introspection.cxx:519:16
> #8 0x7f6be036bd75 in (anonymous namespace)::ImplIntrospectionAccess::getPropertyValue(rtl::OUString const&) stoc/source/inspect/introspection.cxx:1040:26
> #9 0x7f6be037102c in non-virtual thunk to (anonymous namespace)::ImplIntrospectionAccess::getPropertyValue(rtl::OUString const&) stoc/source/inspect/introspection.cxx
> #10 0x7f6be0f95805 in stoc_inv::Invocation_Impl::getValue(rtl::OUString const&) stoc/source/invocation/invocation.cxx:495:35
> #11 0x7f6be0f95fcc in non-virtual thunk to stoc_inv::Invocation_Impl::getValue(rtl::OUString const&) stoc/source/invocation/invocation.cxx
> #12 0x7f6be665d69a in pyuno::PyUNO_getattr(_object*, char*) pyuno/source/module/pyuno.cxx:1424:52
> #13 0x7f6bf34b1a5f in PyObject_GetAttr workdir/UnpackedTarball/python3/Objects/object.c:894:16
> #14 0x7f6bf39f10f9 in PyEval_EvalFrameEx workdir/UnpackedTarball/python3/Python/ceval.c:2793:29
...
Change-Id: I7c8aa0f0e153a022c19c981165730725a566a0b2
Reviewed-on: https://gerrit.libreoffice.org/42946
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-29 18:37:15 +02:00
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <limits>
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
#ifdef SAL_UNX
|
2006-01-16 12:27:51 +00:00
|
|
|
#include <sal/alloca.h>
|
2000-10-10 04:35:45 +00:00
|
|
|
#endif
|
2011-06-14 01:59:20 +03:00
|
|
|
#if !(defined(MACOSX) || defined(IOS) || defined(FREEBSD))
|
2000-09-18 14:29:57 +00:00
|
|
|
#include <malloc.h>
|
2001-03-14 04:35:02 +00:00
|
|
|
#endif
|
2016-06-21 14:05:17 +02:00
|
|
|
#include <o3tl/any.hxx>
|
2000-09-18 14:29:57 +00:00
|
|
|
#include <rtl/alloc.h>
|
|
|
|
#include <typelib/typedescription.hxx>
|
|
|
|
#include <uno/data.h>
|
|
|
|
|
|
|
|
#include "base.hxx"
|
|
|
|
|
2014-05-22 08:56:06 +02:00
|
|
|
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
|
|
|
|
#include <com/sun/star/uno/RuntimeException.hpp>
|
2014-11-18 00:06:30 +01:00
|
|
|
#include <cppuhelper/queryinterface.hxx>
|
2014-05-22 08:56:06 +02:00
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2014-05-22 08:43:59 +02:00
|
|
|
using namespace css::lang;
|
|
|
|
using namespace css::reflection;
|
|
|
|
using namespace css::uno;
|
|
|
|
|
Make sure space handed to C/C++ ABI is padded large enough
PythonTest_pyuno_pytests_testcollections had failed with -fsanitize=address:
> ==6341==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffe5cf77048 at pc 0x7f6be12e51ba bp 0x7ffe5cf76810 sp 0x7ffe5cf76808
> WRITE of size 8 at 0x7ffe5cf77048 thread T0
> #0 0x7f6be12e51b9 in x86_64::fill_struct(_typelib_TypeDescriptionReference*, unsigned long const*, double const*, void*) bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx
> #1 0x7f6be1307f03 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:171:17
> #2 0x7f6be130346d in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233:13
> #3 0x7f6be1301c56 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(_uno_Interface*, _typelib_TypeDescription const*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:420:13
> #4 0x7f6be0be09ff in stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx:679:9
> #5 0x7f6be0be304c in non-virtual thunk to stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx
> #6 0x7f6be0375ef9 in (anonymous namespace)::IntrospectionAccessStatic_Impl::getPropertyValueByIndex(com::sun::star::uno::Any const&, int) const stoc/source/inspect/introspection.cxx:609:33
> #7 0x7f6be03753eb in (anonymous namespace)::IntrospectionAccessStatic_Impl::getPropertyValue(com::sun::star::uno::Any const&, rtl::OUString const&) const stoc/source/inspect/introspection.cxx:519:16
> #8 0x7f6be036bd75 in (anonymous namespace)::ImplIntrospectionAccess::getPropertyValue(rtl::OUString const&) stoc/source/inspect/introspection.cxx:1040:26
> #9 0x7f6be037102c in non-virtual thunk to (anonymous namespace)::ImplIntrospectionAccess::getPropertyValue(rtl::OUString const&) stoc/source/inspect/introspection.cxx
> #10 0x7f6be0f95805 in stoc_inv::Invocation_Impl::getValue(rtl::OUString const&) stoc/source/invocation/invocation.cxx:495:35
> #11 0x7f6be0f95fcc in non-virtual thunk to stoc_inv::Invocation_Impl::getValue(rtl::OUString const&) stoc/source/invocation/invocation.cxx
> #12 0x7f6be665d69a in pyuno::PyUNO_getattr(_object*, char*) pyuno/source/module/pyuno.cxx:1424:52
> #13 0x7f6bf34b1a5f in PyObject_GetAttr workdir/UnpackedTarball/python3/Objects/object.c:894:16
> #14 0x7f6bf39f10f9 in PyEval_EvalFrameEx workdir/UnpackedTarball/python3/Python/ceval.c:2793:29
...
Change-Id: I7c8aa0f0e153a022c19c981165730725a566a0b2
Reviewed-on: https://gerrit.libreoffice.org/42946
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-29 18:37:15 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
std::size_t multipleOf16(std::size_t n) {
|
|
|
|
assert(n <= std::numeric_limits<std::size_t>::max() - 15);
|
|
|
|
return (n + 15) & ~std::size_t(15);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
namespace stoc_corefl
|
|
|
|
{
|
|
|
|
|
2014-02-25 20:42:12 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
class IdlAttributeFieldImpl
|
|
|
|
: public IdlMemberImpl
|
|
|
|
, public XIdlField
|
2001-05-03 12:57:45 +00:00
|
|
|
, public XIdlField2
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-10-27 09:03:20 +02:00
|
|
|
typelib_InterfaceAttributeTypeDescription * getAttributeTypeDescr() const
|
2015-01-18 21:32:06 +01:00
|
|
|
{ return reinterpret_cast<typelib_InterfaceAttributeTypeDescription *>(getTypeDescr()); }
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
IdlAttributeFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
|
|
|
|
typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
|
|
|
|
: IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
|
|
|
|
{}
|
|
|
|
|
|
|
|
// XInterface
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Any SAL_CALL queryInterface( const Type & rType ) override;
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void SAL_CALL acquire() throw() override;
|
|
|
|
virtual void SAL_CALL release() throw() override;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
// XTypeProvider
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Sequence< Type > SAL_CALL getTypes() override;
|
|
|
|
virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
// XIdlMember
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() override;
|
|
|
|
virtual OUString SAL_CALL getName() override;
|
2000-09-18 14:29:57 +00:00
|
|
|
// XIdlField
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Reference< XIdlClass > SAL_CALL getType() override;
|
|
|
|
virtual FieldAccessMode SAL_CALL getAccessMode() override;
|
|
|
|
virtual Any SAL_CALL get( const Any & rObj ) override;
|
|
|
|
virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) override;
|
2001-05-03 12:57:45 +00:00
|
|
|
// XIdlField2: getType, getAccessMode and get are equal to XIdlField
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void SAL_CALL set( Any & rObj, const Any & rValue ) override;
|
2004-06-04 01:30:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void checkException(
|
2017-10-27 09:03:20 +02:00
|
|
|
uno_Any * exception, Reference< XInterface > const & context) const;
|
2000-09-18 14:29:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// XInterface
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Any IdlAttributeFieldImpl::queryInterface( const Type & rType )
|
|
|
|
{
|
2001-05-03 12:57:45 +00:00
|
|
|
Any aRet( ::cppu::queryInterface( rType,
|
|
|
|
static_cast< XIdlField * >( this ),
|
|
|
|
static_cast< XIdlField2 * >( this ) ) );
|
2000-09-18 14:29:57 +00:00
|
|
|
return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
void IdlAttributeFieldImpl::acquire() throw()
|
|
|
|
{
|
|
|
|
IdlMemberImpl::acquire();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
void IdlAttributeFieldImpl::release() throw()
|
|
|
|
{
|
|
|
|
IdlMemberImpl::release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XTypeProvider
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< Type > IdlAttributeFieldImpl::getTypes()
|
|
|
|
{
|
2015-11-10 10:24:34 +01:00
|
|
|
static ::cppu::OTypeCollection * s_pTypes = nullptr;
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! s_pTypes)
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! s_pTypes)
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
static ::cppu::OTypeCollection s_aTypes(
|
2014-05-23 22:11:27 +02:00
|
|
|
cppu::UnoType<XIdlField2>::get(),
|
|
|
|
cppu::UnoType<XIdlField>::get(),
|
2000-09-18 14:29:57 +00:00
|
|
|
IdlMemberImpl::getTypes() );
|
|
|
|
s_pTypes = &s_aTypes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s_pTypes->getTypes();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< sal_Int8 > IdlAttributeFieldImpl::getImplementationId()
|
|
|
|
{
|
2014-03-10 15:59:35 +01:00
|
|
|
return css::uno::Sequence<sal_Int8>();
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XIdlMember
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlClass > IdlAttributeFieldImpl::getDeclaringClass()
|
|
|
|
{
|
|
|
|
if (! _xDeclClass.is())
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _xDeclClass.is())
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aName(getAttributeTypeDescr()->aBase.aBase.pTypeName);
|
2004-02-03 11:02:07 +00:00
|
|
|
sal_Int32 i = aName.indexOf(':');
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT(i >= 0);
|
2004-02-03 11:02:07 +00:00
|
|
|
_xDeclClass = getReflection()->forName(aName.copy(0, i));
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return _xDeclClass;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
OUString IdlAttributeFieldImpl::getName()
|
|
|
|
{
|
|
|
|
return IdlMemberImpl::getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XIdlField
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlClass > IdlAttributeFieldImpl::getType()
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
return getReflection()->forType(
|
|
|
|
getAttributeTypeDescr()->pAttributeTypeRef );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
FieldAccessMode IdlAttributeFieldImpl::getAccessMode()
|
|
|
|
{
|
2017-11-24 13:08:01 +02:00
|
|
|
return (getAttributeTypeDescr()->bReadOnly
|
2000-09-18 14:29:57 +00:00
|
|
|
? FieldAccessMode_READONLY : FieldAccessMode_READWRITE);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Any IdlAttributeFieldImpl::get( const Any & rObj )
|
|
|
|
{
|
2002-10-17 06:49:57 +00:00
|
|
|
uno_Interface * pUnoI = getReflection()->mapToUno(
|
2015-01-18 21:32:06 +01:00
|
|
|
rObj, reinterpret_cast<typelib_InterfaceTypeDescription *>(getDeclTypeDescr()) );
|
2001-03-12 14:38:06 +00:00
|
|
|
OSL_ENSURE( pUnoI, "### illegal destination object given!" );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (pUnoI)
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
TypeDescription aTD( getAttributeTypeDescr()->pAttributeTypeRef );
|
2000-09-18 14:29:57 +00:00
|
|
|
typelib_TypeDescription * pTD = aTD.get();
|
|
|
|
|
|
|
|
uno_Any aExc;
|
|
|
|
uno_Any * pExc = &aExc;
|
|
|
|
void * pReturn = alloca( pTD->nSize );
|
|
|
|
|
2015-11-10 10:24:34 +01:00
|
|
|
(*pUnoI->pDispatcher)( pUnoI, getTypeDescr(), pReturn, nullptr, &pExc );
|
2000-09-18 14:29:57 +00:00
|
|
|
(*pUnoI->release)( pUnoI );
|
|
|
|
|
2016-06-21 14:05:17 +02:00
|
|
|
checkException(pExc, *o3tl::doAccess<Reference<XInterface>>(rObj));
|
2000-09-18 14:29:57 +00:00
|
|
|
Any aRet;
|
2006-06-19 23:01:08 +00:00
|
|
|
uno_any_destruct(
|
|
|
|
&aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
|
2004-06-04 01:30:23 +00:00
|
|
|
uno_any_constructAndConvert( &aRet, pReturn, pTD, getReflection()->getUno2Cpp().get() );
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_destructData( pReturn, pTD, nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
throw IllegalArgumentException(
|
2014-05-28 12:50:02 +02:00
|
|
|
"illegal object given!",
|
2015-06-08 16:28:10 +02:00
|
|
|
static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-03-27 11:01:26 +00:00
|
|
|
void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue )
|
2001-05-03 12:57:45 +00:00
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
if (getAttributeTypeDescr()->bReadOnly)
|
2001-05-03 12:57:45 +00:00
|
|
|
{
|
|
|
|
throw IllegalAccessException(
|
2014-05-28 12:50:02 +02:00
|
|
|
"cannot set readonly attribute!",
|
2015-06-08 16:28:10 +02:00
|
|
|
static_cast<XWeak *>(static_cast<OWeakObject *>(this)) );
|
2001-05-03 12:57:45 +00:00
|
|
|
}
|
|
|
|
|
2002-10-17 06:49:57 +00:00
|
|
|
uno_Interface * pUnoI = getReflection()->mapToUno(
|
2015-01-18 21:32:06 +01:00
|
|
|
rObj, reinterpret_cast<typelib_InterfaceTypeDescription *>(getDeclTypeDescr()) );
|
2001-05-03 12:57:45 +00:00
|
|
|
OSL_ENSURE( pUnoI, "### illegal destination object given!" );
|
|
|
|
if (pUnoI)
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
TypeDescription aTD( getAttributeTypeDescr()->pAttributeTypeRef );
|
2001-05-03 12:57:45 +00:00
|
|
|
typelib_TypeDescription * pTD = aTD.get();
|
|
|
|
|
|
|
|
// construct uno value to be set
|
|
|
|
void * pArgs[1];
|
|
|
|
void * pArg = pArgs[0] = alloca( pTD->nSize );
|
|
|
|
|
2014-04-24 12:26:33 +02:00
|
|
|
bool bAssign;
|
2001-05-03 12:57:45 +00:00
|
|
|
if (pTD->eTypeClass == typelib_TypeClass_ANY)
|
|
|
|
{
|
2017-09-04 08:53:38 +02:00
|
|
|
uno_copyAndConvertData( pArg, const_cast< Any * >(&rValue),
|
2002-10-17 06:49:57 +00:00
|
|
|
pTD, getReflection()->getCpp2Uno().get() );
|
2014-04-24 12:26:33 +02:00
|
|
|
bAssign = true;
|
2001-05-03 12:57:45 +00:00
|
|
|
}
|
|
|
|
else if (typelib_typedescriptionreference_equals( rValue.getValueTypeRef(), pTD->pWeakRef ))
|
|
|
|
{
|
2017-09-04 08:53:38 +02:00
|
|
|
uno_copyAndConvertData( pArg, const_cast< void * >(rValue.getValue()),
|
2002-10-17 06:49:57 +00:00
|
|
|
pTD, getReflection()->getCpp2Uno().get() );
|
2014-04-24 12:26:33 +02:00
|
|
|
bAssign = true;
|
2001-05-03 12:57:45 +00:00
|
|
|
}
|
|
|
|
else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
|
|
|
|
{
|
|
|
|
Reference< XInterface > xObj;
|
2006-06-19 23:01:08 +00:00
|
|
|
bAssign = extract(
|
2015-01-18 21:32:06 +01:00
|
|
|
rValue, reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD), xObj,
|
2006-06-19 23:01:08 +00:00
|
|
|
getReflection() );
|
|
|
|
if (bAssign)
|
2001-05-03 12:57:45 +00:00
|
|
|
{
|
2015-03-28 19:07:13 +01:00
|
|
|
*static_cast<void **>(pArg) = getReflection()->getCpp2Uno().mapInterface(
|
2015-01-18 21:32:06 +01:00
|
|
|
xObj.get(), reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD) );
|
2001-05-03 12:57:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-10 10:24:34 +01:00
|
|
|
typelib_TypeDescription * pValueTD = nullptr;
|
2001-05-03 12:57:45 +00:00
|
|
|
TYPELIB_DANGER_GET( &pValueTD, rValue.getValueTypeRef() );
|
|
|
|
// construct temp uno val to do proper assignment: todo opt
|
|
|
|
void * pTemp = alloca( pValueTD->nSize );
|
|
|
|
uno_copyAndConvertData(
|
2015-03-29 09:17:00 +02:00
|
|
|
pTemp, const_cast<void *>(rValue.getValue()), pValueTD, getReflection()->getCpp2Uno().get() );
|
2001-05-03 12:57:45 +00:00
|
|
|
uno_constructData(
|
|
|
|
pArg, pTD );
|
|
|
|
// assignment does simple conversion
|
|
|
|
bAssign = uno_assignData(
|
2015-11-10 10:24:34 +01:00
|
|
|
pArg, pTD, pTemp, pValueTD, nullptr, nullptr, nullptr );
|
2001-05-03 12:57:45 +00:00
|
|
|
uno_destructData(
|
2015-11-10 10:24:34 +01:00
|
|
|
pTemp, pValueTD, nullptr );
|
2001-05-03 12:57:45 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pValueTD );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bAssign)
|
|
|
|
{
|
|
|
|
uno_Any aExc;
|
|
|
|
uno_Any * pExc = &aExc;
|
2015-11-10 10:24:34 +01:00
|
|
|
(*pUnoI->pDispatcher)( pUnoI, getTypeDescr(), nullptr, pArgs, &pExc );
|
2001-05-03 12:57:45 +00:00
|
|
|
(*pUnoI->release)( pUnoI );
|
|
|
|
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_destructData( pArg, pTD, nullptr );
|
2016-06-21 14:05:17 +02:00
|
|
|
checkException(pExc, *o3tl::doAccess<Reference<XInterface>>(rObj));
|
2001-05-03 12:57:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
(*pUnoI->release)( pUnoI );
|
|
|
|
|
|
|
|
throw IllegalArgumentException(
|
2014-05-28 12:50:02 +02:00
|
|
|
"illegal value given!",
|
2016-06-21 14:05:17 +02:00
|
|
|
*o3tl::doAccess<Reference<XInterface>>(rObj), 1 );
|
2001-05-03 12:57:45 +00:00
|
|
|
}
|
|
|
|
throw IllegalArgumentException(
|
2014-05-28 12:50:02 +02:00
|
|
|
"illegal destination object given!",
|
2015-06-08 16:28:10 +02:00
|
|
|
static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 );
|
2001-05-03 12:57:45 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-03-27 11:01:26 +00:00
|
|
|
void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2003-03-27 11:01:26 +00:00
|
|
|
IdlAttributeFieldImpl::set( const_cast< Any & >( rObj ), rValue );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 01:30:23 +00:00
|
|
|
void IdlAttributeFieldImpl::checkException(
|
2017-10-27 09:03:20 +02:00
|
|
|
uno_Any * exception, Reference< XInterface > const & context) const
|
2004-06-04 01:30:23 +00:00
|
|
|
{
|
2015-11-10 10:24:34 +01:00
|
|
|
if (exception != nullptr) {
|
2004-06-04 01:30:23 +00:00
|
|
|
Any e;
|
2006-06-19 23:01:08 +00:00
|
|
|
uno_any_destruct(&e, reinterpret_cast< uno_ReleaseFunc >(cpp_release));
|
2004-06-04 01:30:23 +00:00
|
|
|
uno_type_any_constructAndConvert(
|
|
|
|
&e, exception->pData, exception->pType,
|
|
|
|
getReflection()->getUno2Cpp().get());
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_any_destruct(exception, nullptr);
|
2017-09-22 12:53:28 +02:00
|
|
|
if (!e.isExtractableTo(
|
2014-05-14 23:17:17 +02:00
|
|
|
cppu::UnoType<RuntimeException>::get()))
|
2004-06-04 01:30:23 +00:00
|
|
|
{
|
|
|
|
throw WrappedTargetRuntimeException(
|
2014-05-28 12:50:02 +02:00
|
|
|
"non-RuntimeException occurred when accessing an"
|
|
|
|
" interface type attribute",
|
2004-06-04 01:30:23 +00:00
|
|
|
context, e);
|
|
|
|
}
|
2017-09-22 12:53:28 +02:00
|
|
|
cppu::throwException(e);
|
2004-06-04 01:30:23 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
class IdlInterfaceMethodImpl
|
|
|
|
: public IdlMemberImpl
|
|
|
|
, public XIdlMethod
|
|
|
|
{
|
2018-01-10 12:30:15 +02:00
|
|
|
std::unique_ptr<Sequence< Reference< XIdlClass > >> _pExceptionTypes;
|
|
|
|
std::unique_ptr<Sequence< Reference< XIdlClass > >> _pParamTypes;
|
|
|
|
std::unique_ptr<Sequence< ParamInfo >> _pParamInfos;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
public:
|
2017-10-27 09:03:20 +02:00
|
|
|
typelib_InterfaceMethodTypeDescription * getMethodTypeDescr() const
|
2015-01-18 21:32:06 +01:00
|
|
|
{ return reinterpret_cast<typelib_InterfaceMethodTypeDescription *>(getTypeDescr()); }
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
IdlInterfaceMethodImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
|
|
|
|
typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
|
|
|
|
: IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
|
|
|
|
{}
|
|
|
|
|
|
|
|
// XInterface
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Any SAL_CALL queryInterface( const Type & rType ) override;
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void SAL_CALL acquire() throw() override;
|
|
|
|
virtual void SAL_CALL release() throw() override;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
// XTypeProvider
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Sequence< Type > SAL_CALL getTypes() override;
|
|
|
|
virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
// XIdlMember
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() override;
|
|
|
|
virtual OUString SAL_CALL getName() override;
|
2000-09-18 14:29:57 +00:00
|
|
|
// XIdlMethod
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Reference< XIdlClass > SAL_CALL getReturnType() override;
|
|
|
|
virtual Sequence< Reference< XIdlClass > > SAL_CALL getParameterTypes() override;
|
|
|
|
virtual Sequence< ParamInfo > SAL_CALL getParameterInfos() override;
|
|
|
|
virtual Sequence< Reference< XIdlClass > > SAL_CALL getExceptionTypes() override;
|
|
|
|
virtual MethodMode SAL_CALL getMode() override;
|
|
|
|
virtual Any SAL_CALL invoke( const Any & rObj, Sequence< Any > & rArgs ) override;
|
2000-09-18 14:29:57 +00:00
|
|
|
};
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
// XInterface
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Any IdlInterfaceMethodImpl::queryInterface( const Type & rType )
|
|
|
|
{
|
|
|
|
Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlMethod * >( this ) ) );
|
|
|
|
return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
void IdlInterfaceMethodImpl::acquire() throw()
|
|
|
|
{
|
|
|
|
IdlMemberImpl::acquire();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
void IdlInterfaceMethodImpl::release() throw()
|
|
|
|
{
|
|
|
|
IdlMemberImpl::release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XTypeProvider
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< Type > IdlInterfaceMethodImpl::getTypes()
|
|
|
|
{
|
2015-11-10 10:24:34 +01:00
|
|
|
static ::cppu::OTypeCollection * s_pTypes = nullptr;
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! s_pTypes)
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! s_pTypes)
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
static ::cppu::OTypeCollection s_aTypes(
|
2014-05-23 22:11:27 +02:00
|
|
|
cppu::UnoType<XIdlMethod>::get(),
|
2000-09-18 14:29:57 +00:00
|
|
|
IdlMemberImpl::getTypes() );
|
|
|
|
s_pTypes = &s_aTypes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s_pTypes->getTypes();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< sal_Int8 > IdlInterfaceMethodImpl::getImplementationId()
|
|
|
|
{
|
2014-03-10 15:59:35 +01:00
|
|
|
return css::uno::Sequence<sal_Int8>();
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XIdlMember
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlClass > IdlInterfaceMethodImpl::getDeclaringClass()
|
|
|
|
{
|
|
|
|
if (! _xDeclClass.is())
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _xDeclClass.is())
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aName(getMethodTypeDescr()->aBase.aBase.pTypeName);
|
2004-02-03 11:02:07 +00:00
|
|
|
sal_Int32 i = aName.indexOf(':');
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT(i >= 0);
|
2004-02-03 11:02:07 +00:00
|
|
|
_xDeclClass = getReflection()->forName(aName.copy(0, i));
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return _xDeclClass;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
OUString IdlInterfaceMethodImpl::getName()
|
|
|
|
{
|
|
|
|
return IdlMemberImpl::getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XIdlMethod
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlClass > SAL_CALL IdlInterfaceMethodImpl::getReturnType()
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
return getReflection()->forType( getMethodTypeDescr()->pReturnTypeRef );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
|
|
|
|
{
|
|
|
|
if (! _pExceptionTypes)
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _pExceptionTypes)
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
sal_Int32 nExc = getMethodTypeDescr()->nExceptions;
|
2018-01-10 12:30:15 +02:00
|
|
|
std::unique_ptr<Sequence< Reference< XIdlClass > >> pTempExceptionTypes(
|
|
|
|
new Sequence< Reference< XIdlClass > >( nExc ));
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlClass > * pExceptionTypes = pTempExceptionTypes->getArray();
|
|
|
|
|
2006-06-19 23:01:08 +00:00
|
|
|
typelib_TypeDescriptionReference ** ppExc =
|
|
|
|
getMethodTypeDescr()->ppExceptions;
|
2000-09-18 14:29:57 +00:00
|
|
|
IdlReflectionServiceImpl * pRefl = getReflection();
|
|
|
|
|
|
|
|
while (nExc--)
|
|
|
|
pExceptionTypes[nExc] = pRefl->forType( ppExc[nExc] );
|
|
|
|
|
2018-01-10 12:30:15 +02:00
|
|
|
_pExceptionTypes = std::move(pTempExceptionTypes);
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *_pExceptionTypes;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
|
|
|
|
{
|
|
|
|
if (! _pParamTypes)
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _pParamTypes)
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
sal_Int32 nParams = getMethodTypeDescr()->nParams;
|
2018-01-10 12:30:15 +02:00
|
|
|
std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
|
|
|
|
new Sequence< Reference< XIdlClass > >( nParams ));
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
|
|
|
|
|
2006-06-19 23:01:08 +00:00
|
|
|
typelib_MethodParameter * pTypelibParams =
|
|
|
|
getMethodTypeDescr()->pParams;
|
2000-09-18 14:29:57 +00:00
|
|
|
IdlReflectionServiceImpl * pRefl = getReflection();
|
|
|
|
|
|
|
|
while (nParams--)
|
|
|
|
pParamTypes[nParams] = pRefl->forType( pTypelibParams[nParams].pTypeRef );
|
|
|
|
|
2018-01-10 12:30:15 +02:00
|
|
|
_pParamTypes = std::move(pTempParamTypes);
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *_pParamTypes;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
|
|
|
|
{
|
|
|
|
if (! _pParamInfos)
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _pParamInfos)
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
sal_Int32 nParams = getMethodTypeDescr()->nParams;
|
2018-01-10 12:30:15 +02:00
|
|
|
std::unique_ptr<Sequence< ParamInfo > > pTempParamInfos( new Sequence< ParamInfo >( nParams ) );
|
2000-09-18 14:29:57 +00:00
|
|
|
ParamInfo * pParamInfos = pTempParamInfos->getArray();
|
|
|
|
|
2006-06-19 23:01:08 +00:00
|
|
|
typelib_MethodParameter * pTypelibParams =
|
|
|
|
getMethodTypeDescr()->pParams;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
if (_pParamTypes) // use param types
|
|
|
|
{
|
|
|
|
const Reference< XIdlClass > * pParamTypes = _pParamTypes->getConstArray();
|
|
|
|
|
|
|
|
while (nParams--)
|
|
|
|
{
|
|
|
|
const typelib_MethodParameter & rParam = pTypelibParams[nParams];
|
|
|
|
ParamInfo & rInfo = pParamInfos[nParams];
|
|
|
|
rInfo.aName = rParam.pName;
|
|
|
|
if (rParam.bIn)
|
|
|
|
rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN);
|
|
|
|
else
|
|
|
|
rInfo.aMode = ParamMode_OUT;
|
|
|
|
rInfo.aType = pParamTypes[nParams];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // make also param types sequence if not already initialized
|
|
|
|
{
|
2018-01-10 12:30:15 +02:00
|
|
|
std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
|
|
|
|
new Sequence< Reference< XIdlClass > >( nParams ));
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
|
|
|
|
|
|
|
|
IdlReflectionServiceImpl * pRefl = getReflection();
|
|
|
|
|
|
|
|
while (nParams--)
|
|
|
|
{
|
|
|
|
const typelib_MethodParameter & rParam = pTypelibParams[nParams];
|
|
|
|
ParamInfo & rInfo = pParamInfos[nParams];
|
|
|
|
rInfo.aName = rParam.pName;
|
|
|
|
if (rParam.bIn)
|
|
|
|
rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN);
|
|
|
|
else
|
|
|
|
rInfo.aMode = ParamMode_OUT;
|
|
|
|
rInfo.aType = pParamTypes[nParams] = pRefl->forType( rParam.pTypeRef );
|
|
|
|
}
|
|
|
|
|
2018-01-10 12:30:15 +02:00
|
|
|
_pParamTypes = std::move(pTempParamTypes);
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
2018-01-10 12:30:15 +02:00
|
|
|
_pParamInfos = std::move(pTempParamInfos);
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *_pParamInfos;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
MethodMode SAL_CALL IdlInterfaceMethodImpl::getMode()
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
return
|
|
|
|
getMethodTypeDescr()->bOneWay ? MethodMode_ONEWAY : MethodMode_TWOWAY;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & rArgs )
|
|
|
|
{
|
2016-06-21 14:05:17 +02:00
|
|
|
if (auto ifc = o3tl::tryAccess<css::uno::Reference<css::uno::XInterface>>(
|
|
|
|
rObj))
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
// acquire()/ release()
|
2006-06-19 23:01:08 +00:00
|
|
|
if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer,
|
2000-09-18 14:29:57 +00:00
|
|
|
"com.sun.star.uno.XInterface::acquire" ) == 0)
|
|
|
|
{
|
2016-06-21 14:05:17 +02:00
|
|
|
(*ifc)->acquire();
|
2000-09-18 14:29:57 +00:00
|
|
|
return Any();
|
|
|
|
}
|
2006-06-19 23:01:08 +00:00
|
|
|
else if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer,
|
2000-09-18 14:29:57 +00:00
|
|
|
"com.sun.star.uno.XInterface::release" ) == 0)
|
|
|
|
{
|
2016-06-21 14:05:17 +02:00
|
|
|
(*ifc)->release();
|
2000-09-18 14:29:57 +00:00
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-17 06:49:57 +00:00
|
|
|
uno_Interface * pUnoI = getReflection()->mapToUno(
|
2015-01-18 21:32:06 +01:00
|
|
|
rObj, reinterpret_cast<typelib_InterfaceTypeDescription *>(getDeclTypeDescr()) );
|
2001-03-12 14:38:06 +00:00
|
|
|
OSL_ENSURE( pUnoI, "### illegal destination object given!" );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (pUnoI)
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
sal_Int32 nParams = getMethodTypeDescr()->nParams;
|
2000-09-18 14:29:57 +00:00
|
|
|
if (rArgs.getLength() != nParams)
|
|
|
|
{
|
|
|
|
(*pUnoI->release)( pUnoI );
|
|
|
|
throw IllegalArgumentException(
|
2017-01-30 11:22:54 +02:00
|
|
|
"expected " + OUString::number(nParams) +
|
|
|
|
" arguments, got " + OUString::number(rArgs.getLength()),
|
2016-06-21 14:05:17 +02:00
|
|
|
*o3tl::doAccess<Reference<XInterface>>(rObj), 1 );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Any * pCppArgs = rArgs.getArray();
|
2006-06-19 23:01:08 +00:00
|
|
|
typelib_MethodParameter * pParams = getMethodTypeDescr()->pParams;
|
2015-11-10 10:24:34 +01:00
|
|
|
typelib_TypeDescription * pReturnType = nullptr;
|
2006-06-19 23:01:08 +00:00
|
|
|
TYPELIB_DANGER_GET(
|
|
|
|
&pReturnType, getMethodTypeDescr()->pReturnTypeRef );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
Make sure space handed to C/C++ ABI is padded large enough
PythonTest_pyuno_pytests_testcollections had failed with -fsanitize=address:
> ==6341==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffe5cf77048 at pc 0x7f6be12e51ba bp 0x7ffe5cf76810 sp 0x7ffe5cf76808
> WRITE of size 8 at 0x7ffe5cf77048 thread T0
> #0 0x7f6be12e51b9 in x86_64::fill_struct(_typelib_TypeDescriptionReference*, unsigned long const*, double const*, void*) bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx
> #1 0x7f6be1307f03 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:171:17
> #2 0x7f6be130346d in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233:13
> #3 0x7f6be1301c56 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(_uno_Interface*, _typelib_TypeDescription const*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:420:13
> #4 0x7f6be0be09ff in stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx:679:9
> #5 0x7f6be0be304c in non-virtual thunk to stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx
> #6 0x7f6be0375ef9 in (anonymous namespace)::IntrospectionAccessStatic_Impl::getPropertyValueByIndex(com::sun::star::uno::Any const&, int) const stoc/source/inspect/introspection.cxx:609:33
> #7 0x7f6be03753eb in (anonymous namespace)::IntrospectionAccessStatic_Impl::getPropertyValue(com::sun::star::uno::Any const&, rtl::OUString const&) const stoc/source/inspect/introspection.cxx:519:16
> #8 0x7f6be036bd75 in (anonymous namespace)::ImplIntrospectionAccess::getPropertyValue(rtl::OUString const&) stoc/source/inspect/introspection.cxx:1040:26
> #9 0x7f6be037102c in non-virtual thunk to (anonymous namespace)::ImplIntrospectionAccess::getPropertyValue(rtl::OUString const&) stoc/source/inspect/introspection.cxx
> #10 0x7f6be0f95805 in stoc_inv::Invocation_Impl::getValue(rtl::OUString const&) stoc/source/invocation/invocation.cxx:495:35
> #11 0x7f6be0f95fcc in non-virtual thunk to stoc_inv::Invocation_Impl::getValue(rtl::OUString const&) stoc/source/invocation/invocation.cxx
> #12 0x7f6be665d69a in pyuno::PyUNO_getattr(_object*, char*) pyuno/source/module/pyuno.cxx:1424:52
> #13 0x7f6bf34b1a5f in PyObject_GetAttr workdir/UnpackedTarball/python3/Objects/object.c:894:16
> #14 0x7f6bf39f10f9 in PyEval_EvalFrameEx workdir/UnpackedTarball/python3/Python/ceval.c:2793:29
...
Change-Id: I7c8aa0f0e153a022c19c981165730725a566a0b2
Reviewed-on: https://gerrit.libreoffice.org/42946
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-29 18:37:15 +02:00
|
|
|
// C/C++ ABIs typically assume that structs are padded at the end, and
|
|
|
|
// that those padding bytes may be written to (e.g., to write into the
|
|
|
|
// end of a "short" struct by writing the full contents of a "long"
|
|
|
|
// register); so create enough space here (assuming that no ABI requires
|
|
|
|
// padding larger than 16 byte boundaries):
|
|
|
|
void * pUnoReturn = alloca( multipleOf16(pReturnType->nSize) );
|
2015-03-28 19:07:13 +01:00
|
|
|
void ** ppUnoArgs = static_cast<void **>(alloca( sizeof(void *) * nParams *2 ));
|
|
|
|
typelib_TypeDescription ** ppParamTypes = reinterpret_cast<typelib_TypeDescription **>(ppUnoArgs + nParams);
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
// convert arguments
|
|
|
|
for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
|
|
|
|
{
|
2015-11-10 10:24:34 +01:00
|
|
|
ppParamTypes[nPos] = nullptr;
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_GET( ppParamTypes + nPos, pParams[nPos].pTypeRef );
|
|
|
|
typelib_TypeDescription * pTD = ppParamTypes[nPos];
|
|
|
|
|
|
|
|
ppUnoArgs[nPos] = alloca( pTD->nSize );
|
|
|
|
if (pParams[nPos].bIn)
|
|
|
|
{
|
2014-04-24 12:26:33 +02:00
|
|
|
bool bAssign;
|
2003-03-27 11:01:26 +00:00
|
|
|
if (typelib_typedescriptionreference_equals(
|
|
|
|
pCppArgs[nPos].getValueTypeRef(), pTD->pWeakRef ))
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
uno_type_copyAndConvertData(
|
2015-03-29 09:17:00 +02:00
|
|
|
ppUnoArgs[nPos], const_cast<void *>(pCppArgs[nPos].getValue()),
|
2002-10-17 06:49:57 +00:00
|
|
|
pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() );
|
2014-04-24 12:26:33 +02:00
|
|
|
bAssign = true;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
else if (pTD->eTypeClass == typelib_TypeClass_ANY)
|
|
|
|
{
|
|
|
|
uno_type_any_constructAndConvert(
|
2015-03-29 09:17:00 +02:00
|
|
|
static_cast<uno_Any *>(ppUnoArgs[nPos]), const_cast<void *>(pCppArgs[nPos].getValue()),
|
2002-10-17 06:49:57 +00:00
|
|
|
pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() );
|
2014-04-24 12:26:33 +02:00
|
|
|
bAssign = true;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2003-03-27 11:01:26 +00:00
|
|
|
else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
Reference< XInterface > xDest;
|
2006-06-19 23:01:08 +00:00
|
|
|
bAssign = extract(
|
2015-01-18 21:32:06 +01:00
|
|
|
pCppArgs[nPos], reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD),
|
2006-06-19 23:01:08 +00:00
|
|
|
xDest, getReflection() );
|
|
|
|
if (bAssign)
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2015-03-28 19:07:13 +01:00
|
|
|
*static_cast<void **>(ppUnoArgs[nPos]) = getReflection()->getCpp2Uno().mapInterface(
|
2015-01-18 21:32:06 +01:00
|
|
|
xDest.get(), reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD) );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-10 10:24:34 +01:00
|
|
|
typelib_TypeDescription * pValueTD = nullptr;
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_GET( &pValueTD, pCppArgs[nPos].getValueTypeRef() );
|
|
|
|
// construct temp uno val to do proper assignment: todo opt
|
|
|
|
void * pTemp = alloca( pValueTD->nSize );
|
|
|
|
uno_copyAndConvertData(
|
2015-03-29 09:17:00 +02:00
|
|
|
pTemp, const_cast<void *>(pCppArgs[nPos].getValue()), pValueTD,
|
2002-10-17 06:49:57 +00:00
|
|
|
getReflection()->getCpp2Uno().get() );
|
2000-09-18 14:29:57 +00:00
|
|
|
uno_constructData(
|
|
|
|
ppUnoArgs[nPos], pTD );
|
|
|
|
// assignment does simple conversion
|
|
|
|
bAssign = uno_assignData(
|
2015-11-10 10:24:34 +01:00
|
|
|
ppUnoArgs[nPos], pTD, pTemp, pValueTD, nullptr, nullptr, nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
uno_destructData(
|
2015-11-10 10:24:34 +01:00
|
|
|
pTemp, pValueTD, nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pValueTD );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! bAssign)
|
|
|
|
{
|
|
|
|
IllegalArgumentException aExc(
|
2017-01-26 16:31:42 +01:00
|
|
|
"cannot coerce argument type during corereflection call:"
|
|
|
|
"\narg no.: " + OUString::number(nPos)
|
|
|
|
+ " expected: \"" + OUString(pTD->pTypeName)
|
2017-01-27 12:14:37 +01:00
|
|
|
+ "\" actual: \"" + OUString(pCppArgs[nPos].getValueTypeRef()->pTypeName)
|
|
|
|
+ "\"",
|
2018-01-12 20:15:18 +01:00
|
|
|
*o3tl::doAccess<Reference<XInterface>>(rObj), static_cast<sal_Int16>(nPos) );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
// cleanup
|
|
|
|
while (nPos--)
|
|
|
|
{
|
|
|
|
if (pParams[nPos].bIn)
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_destructData( ppUnoArgs[nPos], ppParamTypes[nPos], nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( ppParamTypes[nPos] );
|
|
|
|
}
|
|
|
|
TYPELIB_DANGER_RELEASE( pReturnType );
|
|
|
|
(*pUnoI->release)( pUnoI );
|
|
|
|
|
|
|
|
throw aExc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uno_Any aUnoExc;
|
|
|
|
uno_Any * pUnoExc = &aUnoExc;
|
|
|
|
|
|
|
|
(*pUnoI->pDispatcher)(
|
2006-06-19 23:01:08 +00:00
|
|
|
pUnoI, getTypeDescr(), pUnoReturn, ppUnoArgs, &pUnoExc );
|
2000-09-18 14:29:57 +00:00
|
|
|
(*pUnoI->release)( pUnoI );
|
|
|
|
|
|
|
|
Any aRet;
|
|
|
|
if (pUnoExc)
|
|
|
|
{
|
|
|
|
// cleanup
|
|
|
|
while (nParams--)
|
|
|
|
{
|
|
|
|
if (pParams[nParams].bIn)
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] );
|
|
|
|
}
|
|
|
|
TYPELIB_DANGER_RELEASE( pReturnType );
|
|
|
|
|
|
|
|
InvocationTargetException aExc;
|
2016-06-21 14:05:17 +02:00
|
|
|
aExc.Context = *o3tl::doAccess<Reference<XInterface>>(rObj);
|
2013-10-31 17:49:01 +02:00
|
|
|
aExc.Message = "exception occurred during invocation!";
|
2006-06-19 23:01:08 +00:00
|
|
|
uno_any_destruct(
|
|
|
|
&aExc.TargetException,
|
|
|
|
reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
|
2000-09-18 14:29:57 +00:00
|
|
|
uno_type_copyAndConvertData(
|
2014-05-23 22:11:27 +02:00
|
|
|
&aExc.TargetException, pUnoExc, cppu::UnoType<Any>::get().getTypeLibType(),
|
2002-10-17 06:49:57 +00:00
|
|
|
getReflection()->getUno2Cpp().get() );
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_any_destruct( pUnoExc, nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
throw aExc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// reconvert arguments and cleanup
|
|
|
|
while (nParams--)
|
|
|
|
{
|
|
|
|
if (pParams[nParams].bOut) // write back
|
|
|
|
{
|
2006-06-19 23:01:08 +00:00
|
|
|
uno_any_destruct(
|
|
|
|
&pCppArgs[nParams],
|
|
|
|
reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
|
2000-09-18 14:29:57 +00:00
|
|
|
uno_any_constructAndConvert(
|
2002-10-17 06:49:57 +00:00
|
|
|
&pCppArgs[nParams], ppUnoArgs[nParams], ppParamTypes[nParams],
|
|
|
|
getReflection()->getUno2Cpp().get() );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] );
|
|
|
|
}
|
2006-06-19 23:01:08 +00:00
|
|
|
uno_any_destruct(
|
|
|
|
&aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
|
2002-10-17 06:49:57 +00:00
|
|
|
uno_any_constructAndConvert(
|
|
|
|
&aRet, pUnoReturn, pReturnType,
|
|
|
|
getReflection()->getUno2Cpp().get() );
|
2015-11-10 10:24:34 +01:00
|
|
|
uno_destructData( pUnoReturn, pReturnType, nullptr );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pReturnType );
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
throw IllegalArgumentException(
|
2014-05-28 12:50:02 +02:00
|
|
|
"illegal destination object given!",
|
2015-06-08 16:28:10 +02:00
|
|
|
static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InterfaceIdlClassImpl::~InterfaceIdlClassImpl()
|
|
|
|
{
|
|
|
|
for ( sal_Int32 nPos = _nMethods + _nAttributes; nPos--; )
|
|
|
|
typelib_typedescription_release( _pSortedMemberInit[nPos].second );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses()
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard(getMutexAccess());
|
2004-02-03 11:02:07 +00:00
|
|
|
if (_xSuperClasses.getLength() == 0) {
|
|
|
|
typelib_InterfaceTypeDescription * pType = getTypeDescr();
|
|
|
|
_xSuperClasses.realloc(pType->nBaseTypes);
|
|
|
|
for (sal_Int32 i = 0; i < pType->nBaseTypes; ++i) {
|
|
|
|
_xSuperClasses[i] = getReflection()->forType(
|
|
|
|
&pType->ppBaseTypes[i]->aBase);
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT(_xSuperClasses[i].is());
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-12 09:48:19 +01:00
|
|
|
return _xSuperClasses;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
void InterfaceIdlClassImpl::initMembers()
|
|
|
|
{
|
|
|
|
sal_Int32 nAll = getTypeDescr()->nAllMembers;
|
2018-01-10 12:30:15 +02:00
|
|
|
std::unique_ptr<MemberInit[]> pSortedMemberInit(new MemberInit[nAll]);
|
2000-09-18 14:29:57 +00:00
|
|
|
typelib_TypeDescriptionReference ** ppAllMembers = getTypeDescr()->ppAllMembers;
|
|
|
|
|
|
|
|
for ( sal_Int32 nPos = 0; nPos < nAll; ++nPos )
|
|
|
|
{
|
|
|
|
sal_Int32 nIndex;
|
|
|
|
if (ppAllMembers[nPos]->eTypeClass == typelib_TypeClass_INTERFACE_METHOD)
|
|
|
|
{
|
|
|
|
// methods to front
|
|
|
|
nIndex = _nMethods;
|
|
|
|
++_nMethods;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++_nAttributes;
|
|
|
|
nIndex = (nAll - _nAttributes);
|
|
|
|
// attributes at the back
|
|
|
|
}
|
|
|
|
|
2015-11-10 10:24:34 +01:00
|
|
|
typelib_TypeDescription * pTD = nullptr;
|
2000-09-18 14:29:57 +00:00
|
|
|
typelib_typedescriptionreference_getDescription( &pTD, ppAllMembers[nPos] );
|
2014-07-07 10:15:32 +01:00
|
|
|
assert(pTD && "### cannot get type description!");
|
2015-01-18 21:32:06 +01:00
|
|
|
pSortedMemberInit[nIndex].first = reinterpret_cast<typelib_InterfaceMemberTypeDescription *>(pTD)->pMemberName;
|
2000-09-18 14:29:57 +00:00
|
|
|
pSortedMemberInit[nIndex].second = pTD;
|
|
|
|
}
|
|
|
|
|
2018-01-10 12:30:15 +02:00
|
|
|
_pSortedMemberInit = std::move(pSortedMemberInit);
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
|
|
|
|
{
|
|
|
|
if (xType.is() && xType->getTypeClass() == TypeClass_INTERFACE)
|
|
|
|
{
|
|
|
|
if (equals( xType ))
|
2016-04-20 17:19:52 +02:00
|
|
|
return true;
|
2000-09-18 14:29:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses();
|
2004-02-03 11:02:07 +00:00
|
|
|
for (sal_Int32 i = 0; i < rSeq.getLength(); ++i) {
|
|
|
|
if (isAssignableFrom(rSeq[i])) {
|
|
|
|
return true;
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-20 17:19:52 +02:00
|
|
|
return false;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Uik InterfaceIdlClassImpl::getUik()
|
|
|
|
{
|
2010-03-12 10:43:00 +01:00
|
|
|
return Uik(0, 0, 0, 0, 0);
|
|
|
|
// Uiks are deprecated and this function must not be called
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< Reference< XIdlMethod > > InterfaceIdlClassImpl::getMethods()
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _pSortedMemberInit)
|
|
|
|
initMembers();
|
|
|
|
|
|
|
|
// create methods sequence
|
|
|
|
Sequence< Reference< XIdlMethod > > aRet( _nMethods );
|
|
|
|
Reference< XIdlMethod > * pRet = aRet.getArray();
|
|
|
|
for ( sal_Int32 nPos = _nMethods; nPos--; )
|
|
|
|
{
|
|
|
|
|
|
|
|
/*_aName2Method[_pSortedMemberInit[nPos].first] = */pRet[nPos] = new IdlInterfaceMethodImpl(
|
|
|
|
getReflection(), _pSortedMemberInit[nPos].first,
|
|
|
|
_pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() );
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Sequence< Reference< XIdlField > > InterfaceIdlClassImpl::getFields()
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _pSortedMemberInit)
|
|
|
|
initMembers();
|
|
|
|
|
|
|
|
// create fields sequence
|
|
|
|
Sequence< Reference< XIdlField > > aRet( _nAttributes );
|
|
|
|
Reference< XIdlField > * pRet = aRet.getArray();
|
|
|
|
for ( sal_Int32 nPos = _nAttributes; nPos--; )
|
|
|
|
{
|
|
|
|
/*_aName2Field[_pSortedMemberInit[_nMethods+nPos].first] = */pRet[_nAttributes-nPos-1] =
|
|
|
|
new IdlAttributeFieldImpl(
|
|
|
|
getReflection(), _pSortedMemberInit[_nMethods+nPos].first,
|
|
|
|
_pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() );
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlMethod > InterfaceIdlClassImpl::getMethod( const OUString & rName )
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _pSortedMemberInit)
|
|
|
|
initMembers();
|
|
|
|
|
|
|
|
Reference< XIdlMethod > xRet;
|
|
|
|
|
|
|
|
// try weak map
|
|
|
|
const OUString2Method::const_iterator iFind( _aName2Method.find( rName ) );
|
|
|
|
if (iFind != _aName2Method.end())
|
|
|
|
xRet = (*iFind).second; // harden ref
|
|
|
|
|
|
|
|
if (! xRet.is())
|
|
|
|
{
|
|
|
|
for ( sal_Int32 nPos = _nMethods; nPos--; )
|
|
|
|
{
|
|
|
|
if (_pSortedMemberInit[nPos].first == rName)
|
|
|
|
{
|
|
|
|
_aName2Method[rName] = xRet = new IdlInterfaceMethodImpl(
|
|
|
|
getReflection(), rName,
|
|
|
|
_pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return xRet;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
Reference< XIdlField > InterfaceIdlClassImpl::getField( const OUString & rName )
|
|
|
|
{
|
2014-05-22 08:43:59 +02:00
|
|
|
::osl::MutexGuard aGuard( getMutexAccess() );
|
2000-09-18 14:29:57 +00:00
|
|
|
if (! _pSortedMemberInit)
|
|
|
|
initMembers();
|
|
|
|
|
|
|
|
Reference< XIdlField > xRet;
|
|
|
|
|
|
|
|
// try weak map
|
|
|
|
const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
|
|
|
|
if (iFind != _aName2Field.end())
|
|
|
|
xRet = (*iFind).second; // harden ref
|
|
|
|
|
|
|
|
if (! xRet.is())
|
|
|
|
{
|
|
|
|
for ( sal_Int32 nPos = _nAttributes; nPos--; )
|
|
|
|
{
|
|
|
|
if (_pSortedMemberInit[_nMethods+nPos].first == rName)
|
|
|
|
{
|
|
|
|
_aName2Field[rName] = xRet = new IdlAttributeFieldImpl(
|
|
|
|
getReflection(), rName,
|
|
|
|
_pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return xRet;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
void InterfaceIdlClassImpl::createObject( Any & rObj )
|
|
|
|
{
|
|
|
|
// interfaces cannot be constructed
|
|
|
|
rObj.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-14 08:30:07 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|