Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <sal/config.h>
22 : : #ifdef SAL_UNX
23 : : #include <sal/alloca.h>
24 : : #endif
25 : : #if !(defined(MACOSX) || defined(IOS) || defined(FREEBSD))
26 : : #include <malloc.h>
27 : : #endif
28 : : #include <rtl/alloc.h>
29 : : #include <typelib/typedescription.hxx>
30 : : #include <uno/data.h>
31 : :
32 : : #include "base.hxx"
33 : :
34 : : #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
35 : : #include "com/sun/star/uno/RuntimeException.hpp"
36 : : #include "cppuhelper/exc_hlp.hxx"
37 : :
38 : : namespace stoc_corefl
39 : : {
40 : :
41 : : //==================================================================================================
42 [ - + ]: 4870 : class IdlAttributeFieldImpl
43 : : : public IdlMemberImpl
44 : : , public XIdlField
45 : : , public XIdlField2
46 : : {
47 : : public:
48 : 5044 : typelib_InterfaceAttributeTypeDescription * getAttributeTypeDescr()
49 : 5044 : { return (typelib_InterfaceAttributeTypeDescription *)getTypeDescr(); }
50 : :
51 : 2511 : IdlAttributeFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
52 : : typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
53 : 2511 : : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
54 : 2511 : {}
55 : :
56 : : // XInterface
57 : : virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
58 : : virtual void SAL_CALL acquire() throw();
59 : : virtual void SAL_CALL release() throw();
60 : :
61 : : // XTypeProvider
62 : : virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
63 : : virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
64 : :
65 : : // XIdlMember
66 : : virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
67 : : virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
68 : : // XIdlField
69 : : virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
70 : : virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException);
71 : : virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
72 : : virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
73 : : // XIdlField2: getType, getAccessMode and get are equal to XIdlField
74 : : virtual void SAL_CALL set( Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
75 : :
76 : : private:
77 : : void checkException(
78 : : uno_Any * exception, Reference< XInterface > const & context);
79 : : };
80 : :
81 : : // XInterface
82 : : //__________________________________________________________________________________________________
83 : 504 : Any IdlAttributeFieldImpl::queryInterface( const Type & rType )
84 : : throw(::com::sun::star::uno::RuntimeException)
85 : : {
86 : : Any aRet( ::cppu::queryInterface( rType,
87 : : static_cast< XIdlField * >( this ),
88 [ + - ]: 504 : static_cast< XIdlField2 * >( this ) ) );
89 [ + + ][ + - ]: 504 : return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
90 : : }
91 : : //__________________________________________________________________________________________________
92 : 7150 : void IdlAttributeFieldImpl::acquire() throw()
93 : : {
94 : 7150 : IdlMemberImpl::acquire();
95 : 7150 : }
96 : : //__________________________________________________________________________________________________
97 : 7074 : void IdlAttributeFieldImpl::release() throw()
98 : : {
99 : 7074 : IdlMemberImpl::release();
100 : 7074 : }
101 : :
102 : : // XTypeProvider
103 : : //__________________________________________________________________________________________________
104 : 0 : Sequence< Type > IdlAttributeFieldImpl::getTypes()
105 : : throw (::com::sun::star::uno::RuntimeException)
106 : : {
107 : : static OTypeCollection * s_pTypes = 0;
108 [ # # ]: 0 : if (! s_pTypes)
109 : : {
110 [ # # ][ # # ]: 0 : MutexGuard aGuard( getMutexAccess() );
111 [ # # ]: 0 : if (! s_pTypes)
112 : : {
113 : : static OTypeCollection s_aTypes(
114 [ # # ]: 0 : ::getCppuType( (const Reference< XIdlField2 > *)0 ),
115 [ # # ]: 0 : ::getCppuType( (const Reference< XIdlField > *)0 ),
116 [ # # ][ # # ]: 0 : IdlMemberImpl::getTypes() );
[ # # ][ # # ]
[ # # ][ # # ]
117 : 0 : s_pTypes = &s_aTypes;
118 [ # # ]: 0 : }
119 : : }
120 : 0 : return s_pTypes->getTypes();
121 : : }
122 : : //__________________________________________________________________________________________________
123 : 0 : Sequence< sal_Int8 > IdlAttributeFieldImpl::getImplementationId()
124 : : throw (::com::sun::star::uno::RuntimeException)
125 : : {
126 : : static OImplementationId * s_pId = 0;
127 [ # # ]: 0 : if (! s_pId)
128 : : {
129 [ # # ][ # # ]: 0 : MutexGuard aGuard( getMutexAccess() );
130 [ # # ]: 0 : if (! s_pId)
131 : : {
132 [ # # ][ # # ]: 0 : static OImplementationId s_aId;
133 : 0 : s_pId = &s_aId;
134 [ # # ]: 0 : }
135 : : }
136 : 0 : return s_pId->getImplementationId();
137 : : }
138 : :
139 : : // XIdlMember
140 : : //__________________________________________________________________________________________________
141 : 0 : Reference< XIdlClass > IdlAttributeFieldImpl::getDeclaringClass()
142 : : throw(::com::sun::star::uno::RuntimeException)
143 : : {
144 [ # # ]: 0 : if (! _xDeclClass.is())
145 : : {
146 [ # # ][ # # ]: 0 : MutexGuard aGuard( getMutexAccess() );
147 [ # # ]: 0 : if (! _xDeclClass.is())
148 : : {
149 : 0 : rtl::OUString aName(getAttributeTypeDescr()->aBase.aBase.pTypeName);
150 : 0 : sal_Int32 i = aName.indexOf(':');
151 : : OSL_ASSERT(i >= 0);
152 [ # # ][ # # ]: 0 : _xDeclClass = getReflection()->forName(aName.copy(0, i));
153 [ # # ]: 0 : }
154 : : }
155 : 0 : return _xDeclClass;
156 : : }
157 : : //__________________________________________________________________________________________________
158 : 2345 : OUString IdlAttributeFieldImpl::getName()
159 : : throw(::com::sun::star::uno::RuntimeException)
160 : : {
161 : 2345 : return IdlMemberImpl::getName();
162 : : }
163 : :
164 : : // XIdlField
165 : : //__________________________________________________________________________________________________
166 : 2428 : Reference< XIdlClass > IdlAttributeFieldImpl::getType()
167 : : throw(::com::sun::star::uno::RuntimeException)
168 : : {
169 : : return getReflection()->forType(
170 : 2428 : getAttributeTypeDescr()->pAttributeTypeRef );
171 : : }
172 : : //__________________________________________________________________________________________________
173 : 2345 : FieldAccessMode IdlAttributeFieldImpl::getAccessMode()
174 : : throw(::com::sun::star::uno::RuntimeException)
175 : : {
176 : 2345 : return (((typelib_InterfaceAttributeTypeDescription *)getAttributeTypeDescr())->bReadOnly
177 [ + + ]: 2345 : ? FieldAccessMode_READONLY : FieldAccessMode_READWRITE);
178 : : }
179 : : //__________________________________________________________________________________________________
180 : 93 : Any IdlAttributeFieldImpl::get( const Any & rObj )
181 : : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
182 : : {
183 : : uno_Interface * pUnoI = getReflection()->mapToUno(
184 : 93 : rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() );
185 : : OSL_ENSURE( pUnoI, "### illegal destination object given!" );
186 [ + - ]: 93 : if (pUnoI)
187 : : {
188 : 93 : TypeDescription aTD( getAttributeTypeDescr()->pAttributeTypeRef );
189 : 93 : typelib_TypeDescription * pTD = aTD.get();
190 : :
191 : : uno_Any aExc;
192 : 93 : uno_Any * pExc = &aExc;
193 : 93 : void * pReturn = alloca( pTD->nSize );
194 : :
195 [ + - ]: 93 : (*pUnoI->pDispatcher)( pUnoI, getTypeDescr(), pReturn, 0, &pExc );
196 [ + - ]: 93 : (*pUnoI->release)( pUnoI );
197 : :
198 : : checkException(
199 : : pExc,
200 [ + - ]: 93 : *static_cast< Reference< XInterface > const * >(rObj.getValue()));
201 : 93 : Any aRet;
202 : : uno_any_destruct(
203 : 93 : &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
204 [ + - ]: 93 : uno_any_constructAndConvert( &aRet, pReturn, pTD, getReflection()->getUno2Cpp().get() );
205 : 93 : uno_destructData( pReturn, pTD, 0 );
206 : 93 : return aRet;
207 : : }
208 : : throw IllegalArgumentException(
209 : : OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
210 [ # # ][ # # ]: 0 : (XWeak *)(OWeakObject *)this, 0 );
[ # # ]
211 : : }
212 : : //__________________________________________________________________________________________________
213 : 89 : void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue )
214 : : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
215 : : {
216 [ - + ]: 89 : if (getAttributeTypeDescr()->bReadOnly)
217 : : {
218 : : throw IllegalAccessException(
219 : : OUString( RTL_CONSTASCII_USTRINGPARAM("cannot set readonly attribute!") ),
220 [ # # ][ # # ]: 0 : (XWeak *)(OWeakObject *)this );
[ # # ]
221 : : }
222 : :
223 : : uno_Interface * pUnoI = getReflection()->mapToUno(
224 : 89 : rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() );
225 : : OSL_ENSURE( pUnoI, "### illegal destination object given!" );
226 [ + - ]: 89 : if (pUnoI)
227 : : {
228 : 89 : TypeDescription aTD( getAttributeTypeDescr()->pAttributeTypeRef );
229 : 89 : typelib_TypeDescription * pTD = aTD.get();
230 : :
231 : : // construct uno value to be set
232 : : void * pArgs[1];
233 : 89 : void * pArg = pArgs[0] = alloca( pTD->nSize );
234 : :
235 : : sal_Bool bAssign;
236 [ + + ]: 89 : if (pTD->eTypeClass == typelib_TypeClass_ANY)
237 : : {
238 : : uno_copyAndConvertData( pArg, (const_cast< Any * >(&rValue)),
239 [ + - ]: 6 : pTD, getReflection()->getCpp2Uno().get() );
240 : 6 : bAssign = sal_True;
241 : : }
242 [ + - ]: 83 : else if (typelib_typedescriptionreference_equals( rValue.getValueTypeRef(), pTD->pWeakRef ))
243 : : {
244 : 83 : uno_copyAndConvertData( pArg, (const_cast< void * >(rValue.getValue()) ),
245 [ + - ]: 166 : pTD, getReflection()->getCpp2Uno().get() );
246 : 83 : bAssign = sal_True;
247 : : }
248 [ # # ]: 0 : else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
249 : : {
250 : 0 : Reference< XInterface > xObj;
251 : : bAssign = extract(
252 : : rValue, (typelib_InterfaceTypeDescription *)pTD, xObj,
253 [ # # ]: 0 : getReflection() );
254 [ # # ]: 0 : if (bAssign)
255 : : {
256 [ # # ]: 0 : *(void **)pArg = getReflection()->getCpp2Uno().mapInterface(
257 [ # # ][ # # ]: 0 : xObj.get(), (typelib_InterfaceTypeDescription *)pTD );
258 : 0 : }
259 : : }
260 : : else
261 : : {
262 : 0 : typelib_TypeDescription * pValueTD = 0;
263 [ # # ][ # # ]: 0 : TYPELIB_DANGER_GET( &pValueTD, rValue.getValueTypeRef() );
[ # # ][ # # ]
[ # # ]
264 : : // construct temp uno val to do proper assignment: todo opt
265 : 0 : void * pTemp = alloca( pValueTD->nSize );
266 : : uno_copyAndConvertData(
267 [ # # ]: 0 : pTemp, (void *)rValue.getValue(), pValueTD, getReflection()->getCpp2Uno().get() );
268 : : uno_constructData(
269 : 0 : pArg, pTD );
270 : : // assignment does simple conversion
271 : : bAssign = uno_assignData(
272 : 0 : pArg, pTD, pTemp, pValueTD, 0, 0, 0 );
273 : : uno_destructData(
274 : 0 : pTemp, pValueTD, 0 );
275 [ # # ][ # # ]: 0 : TYPELIB_DANGER_RELEASE( pValueTD );
276 : : }
277 : :
278 [ + - ]: 89 : if (bAssign)
279 : : {
280 : : uno_Any aExc;
281 : 89 : uno_Any * pExc = &aExc;
282 [ + - ]: 89 : (*pUnoI->pDispatcher)( pUnoI, getTypeDescr(), 0, pArgs, &pExc );
283 [ + - ]: 89 : (*pUnoI->release)( pUnoI );
284 : :
285 : 89 : uno_destructData( pArg, pTD, 0 );
286 : : checkException(
287 : : pExc,
288 : : *static_cast< Reference< XInterface > const * >(
289 [ + - ]: 89 : rObj.getValue()));
290 : 89 : return;
291 : : }
292 [ # # ]: 0 : (*pUnoI->release)( pUnoI );
293 : :
294 : : throw IllegalArgumentException(
295 : : OUString( RTL_CONSTASCII_USTRINGPARAM("illegal value given!") ),
296 [ # # ][ # # ]: 89 : *(const Reference< XInterface > *)rObj.getValue(), 1 );
297 : : }
298 : : throw IllegalArgumentException(
299 : : OUString( RTL_CONSTASCII_USTRINGPARAM("illegal destination object given!") ),
300 [ # # ][ # # ]: 0 : (XWeak *)(OWeakObject *)this, 0 );
[ # # ]
301 : : }
302 : : //__________________________________________________________________________________________________
303 : 0 : void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue )
304 : : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
305 : : {
306 : 0 : IdlAttributeFieldImpl::set( const_cast< Any & >( rObj ), rValue );
307 : 0 : }
308 : :
309 : 182 : void IdlAttributeFieldImpl::checkException(
310 : : uno_Any * exception, Reference< XInterface > const & context)
311 : : {
312 [ - + ]: 182 : if (exception != 0) {
313 : 0 : Any e;
314 : 0 : uno_any_destruct(&e, reinterpret_cast< uno_ReleaseFunc >(cpp_release));
315 : : uno_type_any_constructAndConvert(
316 : : &e, exception->pData, exception->pType,
317 [ # # ]: 0 : getReflection()->getUno2Cpp().get());
318 : 0 : uno_any_destruct(exception, 0);
319 [ # # ]: 0 : if (e.isExtractableTo(
320 [ # # ]: 0 : getCppuType(static_cast< RuntimeException const * >(0))))
321 : : {
322 [ # # ]: 0 : cppu::throwException(e);
323 : : } else {
324 : : throw WrappedTargetRuntimeException(
325 : : OUString(
326 : : RTL_CONSTASCII_USTRINGPARAM(
327 : : "non-RuntimeException occurred when accessing an"
328 : : " interface type attribute")),
329 [ # # ][ # # ]: 0 : context, e);
330 : 0 : }
331 : : }
332 : 182 : }
333 : :
334 : : //##################################################################################################
335 : : //##################################################################################################
336 : : //##################################################################################################
337 : :
338 : :
339 : : //==================================================================================================
340 : : class IdlInterfaceMethodImpl
341 : : : public IdlMemberImpl
342 : : , public XIdlMethod
343 : : {
344 : : Sequence< Reference< XIdlClass > > * _pExceptionTypes;
345 : : Sequence< Reference< XIdlClass > > * _pParamTypes;
346 : : Sequence< ParamInfo > * _pParamInfos;
347 : :
348 : : public:
349 : 255547 : typelib_InterfaceMethodTypeDescription * getMethodTypeDescr()
350 : 255547 : { return (typelib_InterfaceMethodTypeDescription *)getTypeDescr(); }
351 : :
352 : 140776 : IdlInterfaceMethodImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
353 : : typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
354 : : : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
355 : : , _pExceptionTypes( 0 )
356 : : , _pParamTypes( 0 )
357 : 140776 : , _pParamInfos( 0 )
358 : 140776 : {}
359 : : virtual ~IdlInterfaceMethodImpl();
360 : :
361 : : // XInterface
362 : : virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
363 : : virtual void SAL_CALL acquire() throw();
364 : : virtual void SAL_CALL release() throw();
365 : :
366 : : // XTypeProvider
367 : : virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
368 : : virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
369 : :
370 : : // XIdlMember
371 : : virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
372 : : virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
373 : : // XIdlMethod
374 : : virtual Reference< XIdlClass > SAL_CALL getReturnType() throw(::com::sun::star::uno::RuntimeException);
375 : : virtual Sequence< Reference< XIdlClass > > SAL_CALL getParameterTypes() throw(::com::sun::star::uno::RuntimeException);
376 : : virtual Sequence< ParamInfo > SAL_CALL getParameterInfos() throw(::com::sun::star::uno::RuntimeException);
377 : : virtual Sequence< Reference< XIdlClass > > SAL_CALL getExceptionTypes() throw(::com::sun::star::uno::RuntimeException);
378 : : virtual MethodMode SAL_CALL getMode() throw(::com::sun::star::uno::RuntimeException);
379 : : virtual Any SAL_CALL invoke( const Any & rObj, Sequence< Any > & rArgs ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
380 : : };
381 : : //__________________________________________________________________________________________________
382 : 134314 : IdlInterfaceMethodImpl::~IdlInterfaceMethodImpl()
383 : : {
384 [ + + ][ + - ]: 134314 : delete _pParamInfos;
385 [ + + ][ + - ]: 134314 : delete _pParamTypes;
386 [ + + ][ + - ]: 134314 : delete _pExceptionTypes;
387 [ - + ]: 268628 : }
388 : :
389 : : // XInterface
390 : : //__________________________________________________________________________________________________
391 : 38 : Any IdlInterfaceMethodImpl::queryInterface( const Type & rType )
392 : : throw(::com::sun::star::uno::RuntimeException)
393 : : {
394 [ + - ]: 38 : Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlMethod * >( this ) ) );
395 [ - + ][ + - ]: 38 : return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
396 : : }
397 : : //__________________________________________________________________________________________________
398 : 243193 : void IdlInterfaceMethodImpl::acquire() throw()
399 : : {
400 : 243193 : IdlMemberImpl::acquire();
401 : 243193 : }
402 : : //__________________________________________________________________________________________________
403 : 235354 : void IdlInterfaceMethodImpl::release() throw()
404 : : {
405 : 235354 : IdlMemberImpl::release();
406 : 235354 : }
407 : :
408 : : // XTypeProvider
409 : : //__________________________________________________________________________________________________
410 : 0 : Sequence< Type > IdlInterfaceMethodImpl::getTypes()
411 : : throw (::com::sun::star::uno::RuntimeException)
412 : : {
413 : : static OTypeCollection * s_pTypes = 0;
414 [ # # ]: 0 : if (! s_pTypes)
415 : : {
416 [ # # ][ # # ]: 0 : MutexGuard aGuard( getMutexAccess() );
417 [ # # ]: 0 : if (! s_pTypes)
418 : : {
419 : : static OTypeCollection s_aTypes(
420 [ # # ]: 0 : ::getCppuType( (const Reference< XIdlMethod > *)0 ),
421 [ # # ][ # # ]: 0 : IdlMemberImpl::getTypes() );
[ # # ][ # # ]
[ # # ][ # # ]
422 : 0 : s_pTypes = &s_aTypes;
423 [ # # ]: 0 : }
424 : : }
425 : 0 : return s_pTypes->getTypes();
426 : : }
427 : : //__________________________________________________________________________________________________
428 : 0 : Sequence< sal_Int8 > IdlInterfaceMethodImpl::getImplementationId()
429 : : throw (::com::sun::star::uno::RuntimeException)
430 : : {
431 : : static OImplementationId * s_pId = 0;
432 [ # # ]: 0 : if (! s_pId)
433 : : {
434 [ # # ][ # # ]: 0 : MutexGuard aGuard( getMutexAccess() );
435 [ # # ]: 0 : if (! s_pId)
436 : : {
437 [ # # ][ # # ]: 0 : static OImplementationId s_aId;
438 : 0 : s_pId = &s_aId;
439 [ # # ]: 0 : }
440 : : }
441 : 0 : return s_pId->getImplementationId();
442 : : }
443 : :
444 : : // XIdlMember
445 : : //__________________________________________________________________________________________________
446 : 633645 : Reference< XIdlClass > IdlInterfaceMethodImpl::getDeclaringClass()
447 : : throw(::com::sun::star::uno::RuntimeException)
448 : : {
449 [ + + ]: 633645 : if (! _xDeclClass.is())
450 : : {
451 [ + - ][ + - ]: 140738 : MutexGuard aGuard( getMutexAccess() );
452 [ + - ]: 140738 : if (! _xDeclClass.is())
453 : : {
454 : 140738 : rtl::OUString aName(getMethodTypeDescr()->aBase.aBase.pTypeName);
455 : 140738 : sal_Int32 i = aName.indexOf(':');
456 : : OSL_ASSERT(i >= 0);
457 [ + - ][ + - ]: 140738 : _xDeclClass = getReflection()->forName(aName.copy(0, i));
458 [ + - ]: 140738 : }
459 : : }
460 : 633645 : return _xDeclClass;
461 : : }
462 : : //__________________________________________________________________________________________________
463 : 340588 : OUString IdlInterfaceMethodImpl::getName()
464 : : throw(::com::sun::star::uno::RuntimeException)
465 : : {
466 : 340588 : return IdlMemberImpl::getName();
467 : : }
468 : :
469 : : // XIdlMethod
470 : : //__________________________________________________________________________________________________
471 : 21988 : Reference< XIdlClass > SAL_CALL IdlInterfaceMethodImpl::getReturnType()
472 : : throw(::com::sun::star::uno::RuntimeException)
473 : : {
474 : 21988 : return getReflection()->forType( getMethodTypeDescr()->pReturnTypeRef );
475 : : }
476 : : //__________________________________________________________________________________________________
477 : 38 : Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
478 : : throw(::com::sun::star::uno::RuntimeException)
479 : : {
480 [ + - ]: 38 : if (! _pExceptionTypes)
481 : : {
482 [ + - ][ + - ]: 38 : MutexGuard aGuard( getMutexAccess() );
483 [ + - ]: 38 : if (! _pExceptionTypes)
484 : : {
485 : 38 : sal_Int32 nExc = getMethodTypeDescr()->nExceptions;
486 : : Sequence< Reference< XIdlClass > > * pTempExceptionTypes =
487 [ + - ]: 38 : new Sequence< Reference< XIdlClass > >( nExc );
488 [ + - ]: 38 : Reference< XIdlClass > * pExceptionTypes = pTempExceptionTypes->getArray();
489 : :
490 : : typelib_TypeDescriptionReference ** ppExc =
491 : 38 : getMethodTypeDescr()->ppExceptions;
492 : 38 : IdlReflectionServiceImpl * pRefl = getReflection();
493 : :
494 [ + + ]: 62 : while (nExc--)
495 [ + - ][ + - ]: 24 : pExceptionTypes[nExc] = pRefl->forType( ppExc[nExc] );
496 : :
497 : 38 : _pExceptionTypes = pTempExceptionTypes;
498 [ + - ]: 38 : }
499 : : }
500 : 38 : return *_pExceptionTypes;
501 : : }
502 : : //__________________________________________________________________________________________________
503 : 37620 : Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
504 : : throw(::com::sun::star::uno::RuntimeException)
505 : : {
506 [ + + ]: 37620 : if (! _pParamTypes)
507 : : {
508 [ + - ][ + - ]: 37588 : MutexGuard aGuard( getMutexAccess() );
509 [ + - ]: 37588 : if (! _pParamTypes)
510 : : {
511 : 37588 : sal_Int32 nParams = getMethodTypeDescr()->nParams;
512 : : Sequence< Reference< XIdlClass > > * pTempParamTypes =
513 [ + - ]: 37588 : new Sequence< Reference< XIdlClass > >( nParams );
514 [ + - ]: 37588 : Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
515 : :
516 : : typelib_MethodParameter * pTypelibParams =
517 : 37588 : getMethodTypeDescr()->pParams;
518 : 37588 : IdlReflectionServiceImpl * pRefl = getReflection();
519 : :
520 [ + + ]: 63842 : while (nParams--)
521 [ + - ][ + - ]: 26254 : pParamTypes[nParams] = pRefl->forType( pTypelibParams[nParams].pTypeRef );
522 : :
523 : 37588 : _pParamTypes = pTempParamTypes;
524 [ + - ]: 37588 : }
525 : : }
526 : 37620 : return *_pParamTypes;
527 : : }
528 : : //__________________________________________________________________________________________________
529 : 5289 : Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
530 : : throw(::com::sun::star::uno::RuntimeException)
531 : : {
532 [ + + ]: 5289 : if (! _pParamInfos)
533 : : {
534 [ + - ][ + - ]: 2177 : MutexGuard aGuard( getMutexAccess() );
535 [ + - ]: 2177 : if (! _pParamInfos)
536 : : {
537 : 2177 : sal_Int32 nParams = getMethodTypeDescr()->nParams;
538 [ + - ]: 2177 : Sequence< ParamInfo > * pTempParamInfos = new Sequence< ParamInfo >( nParams );
539 [ + - ]: 2177 : ParamInfo * pParamInfos = pTempParamInfos->getArray();
540 : :
541 : : typelib_MethodParameter * pTypelibParams =
542 : 2177 : getMethodTypeDescr()->pParams;
543 : :
544 [ + + ]: 2177 : if (_pParamTypes) // use param types
545 : : {
546 : 1815 : const Reference< XIdlClass > * pParamTypes = _pParamTypes->getConstArray();
547 : :
548 [ + + ]: 6893 : while (nParams--)
549 : : {
550 : 5078 : const typelib_MethodParameter & rParam = pTypelibParams[nParams];
551 : 5078 : ParamInfo & rInfo = pParamInfos[nParams];
552 : 5078 : rInfo.aName = rParam.pName;
553 [ + - ]: 5078 : if (rParam.bIn)
554 [ - + ]: 5078 : rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN);
555 : : else
556 : 0 : rInfo.aMode = ParamMode_OUT;
557 [ + - ]: 5078 : rInfo.aType = pParamTypes[nParams];
558 : : }
559 : : }
560 : : else // make also param types sequence if not already initialized
561 : : {
562 : : Sequence< Reference< XIdlClass > > * pTempParamTypes =
563 [ + - ]: 362 : new Sequence< Reference< XIdlClass > >( nParams );
564 [ + - ]: 362 : Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
565 : :
566 : 362 : IdlReflectionServiceImpl * pRefl = getReflection();
567 : :
568 [ + + ]: 864 : while (nParams--)
569 : : {
570 : 502 : const typelib_MethodParameter & rParam = pTypelibParams[nParams];
571 : 502 : ParamInfo & rInfo = pParamInfos[nParams];
572 : 502 : rInfo.aName = rParam.pName;
573 [ + - ]: 502 : if (rParam.bIn)
574 [ + + ]: 502 : rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN);
575 : : else
576 : 0 : rInfo.aMode = ParamMode_OUT;
577 [ + - ][ + - ]: 502 : rInfo.aType = pParamTypes[nParams] = pRefl->forType( rParam.pTypeRef );
[ + - ]
578 : : }
579 : :
580 : 362 : _pParamTypes = pTempParamTypes;
581 : : }
582 : :
583 : 2177 : _pParamInfos = pTempParamInfos;
584 [ + - ]: 2177 : }
585 : : }
586 : 5289 : return *_pParamInfos;
587 : : }
588 : : //__________________________________________________________________________________________________
589 : 0 : MethodMode SAL_CALL IdlInterfaceMethodImpl::getMode()
590 : : throw(::com::sun::star::uno::RuntimeException)
591 : : {
592 : : return
593 : 0 : getMethodTypeDescr()->bOneWay ? MethodMode_ONEWAY : MethodMode_TWOWAY;
594 : : }
595 : : //__________________________________________________________________________________________________
596 : 4405 : Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & rArgs )
597 : : throw(::com::sun::star::lang::IllegalArgumentException,
598 : : ::com::sun::star::reflection::InvocationTargetException,
599 : : ::com::sun::star::uno::RuntimeException)
600 : : {
601 [ + - ]: 4405 : if (rObj.getValueTypeClass() == TypeClass_INTERFACE)
602 : : {
603 : : // acquire()/ release()
604 [ - + ]: 8810 : if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer,
605 : 4405 : "com.sun.star.uno.XInterface::acquire" ) == 0)
606 : : {
607 : 0 : (*(const Reference< XInterface > *)rObj.getValue())->acquire();
608 : 0 : return Any();
609 : : }
610 [ - + ]: 8810 : else if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer,
611 : 4405 : "com.sun.star.uno.XInterface::release" ) == 0)
612 : : {
613 : 0 : (*(const Reference< XInterface > *)rObj.getValue())->release();
614 : 0 : return Any();
615 : : }
616 : : }
617 : :
618 : : uno_Interface * pUnoI = getReflection()->mapToUno(
619 : 4405 : rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() );
620 : : OSL_ENSURE( pUnoI, "### illegal destination object given!" );
621 [ + - ]: 4405 : if (pUnoI)
622 : : {
623 : 4405 : sal_Int32 nParams = getMethodTypeDescr()->nParams;
624 [ - + ]: 4405 : if (rArgs.getLength() != nParams)
625 : : {
626 [ # # ]: 0 : (*pUnoI->release)( pUnoI );
627 : : throw IllegalArgumentException(
628 : : OUString( RTL_CONSTASCII_USTRINGPARAM("arguments len differ!") ),
629 [ # # ][ # # ]: 0 : *(const Reference< XInterface > *)rObj.getValue(), 1 );
630 : : }
631 : :
632 [ + - ]: 4405 : Any * pCppArgs = rArgs.getArray();
633 : 4405 : typelib_MethodParameter * pParams = getMethodTypeDescr()->pParams;
634 : 4405 : typelib_TypeDescription * pReturnType = 0;
635 [ - + ][ + - ]: 4405 : TYPELIB_DANGER_GET(
[ - + ][ # # ]
[ + - ]
636 : : &pReturnType, getMethodTypeDescr()->pReturnTypeRef );
637 : :
638 : 4405 : void * pUnoReturn = alloca( pReturnType->nSize );
639 : 4405 : void ** ppUnoArgs = (void **)alloca( sizeof(void *) * nParams *2 );
640 : 4405 : typelib_TypeDescription ** ppParamTypes = (typelib_TypeDescription **)(ppUnoArgs + nParams);
641 : :
642 : : // convert arguments
643 [ + + ]: 9221 : for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
644 : : {
645 : 4816 : ppParamTypes[nPos] = 0;
646 [ + - ][ - + ]: 4816 : TYPELIB_DANGER_GET( ppParamTypes + nPos, pParams[nPos].pTypeRef );
[ + - ][ - + ]
[ # # ]
647 : 4816 : typelib_TypeDescription * pTD = ppParamTypes[nPos];
648 : :
649 : 4816 : ppUnoArgs[nPos] = alloca( pTD->nSize );
650 [ + - ]: 4816 : if (pParams[nPos].bIn)
651 : : {
652 : : sal_Bool bAssign;
653 [ + + ]: 4816 : if (typelib_typedescriptionreference_equals(
654 : 4816 : pCppArgs[nPos].getValueTypeRef(), pTD->pWeakRef ))
655 : : {
656 : : uno_type_copyAndConvertData(
657 : 4064 : ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(),
658 [ + - ]: 8128 : pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() );
659 : 4064 : bAssign = sal_True;
660 : : }
661 [ + + ]: 752 : else if (pTD->eTypeClass == typelib_TypeClass_ANY)
662 : : {
663 : : uno_type_any_constructAndConvert(
664 : 706 : (uno_Any *)ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(),
665 [ + - ]: 1412 : pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() );
666 : 706 : bAssign = sal_True;
667 : : }
668 [ + - ]: 46 : else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
669 : : {
670 : 46 : Reference< XInterface > xDest;
671 : : bAssign = extract(
672 : : pCppArgs[nPos], (typelib_InterfaceTypeDescription *)pTD,
673 [ + - ]: 46 : xDest, getReflection() );
674 [ + - ]: 46 : if (bAssign)
675 : : {
676 [ + - ]: 46 : *(void **)ppUnoArgs[nPos] = getReflection()->getCpp2Uno().mapInterface(
677 [ + - ][ + - ]: 92 : xDest.get(), (typelib_InterfaceTypeDescription *)pTD );
678 : 46 : }
679 : : }
680 : : else
681 : : {
682 : 0 : typelib_TypeDescription * pValueTD = 0;
683 [ # # ][ # # ]: 0 : TYPELIB_DANGER_GET( &pValueTD, pCppArgs[nPos].getValueTypeRef() );
[ # # ][ # # ]
[ # # ]
684 : : // construct temp uno val to do proper assignment: todo opt
685 : 0 : void * pTemp = alloca( pValueTD->nSize );
686 : : uno_copyAndConvertData(
687 : 0 : pTemp, (void *)pCppArgs[nPos].getValue(), pValueTD,
688 [ # # ]: 0 : getReflection()->getCpp2Uno().get() );
689 : : uno_constructData(
690 : 0 : ppUnoArgs[nPos], pTD );
691 : : // assignment does simple conversion
692 : : bAssign = uno_assignData(
693 : 0 : ppUnoArgs[nPos], pTD, pTemp, pValueTD, 0, 0, 0 );
694 : : uno_destructData(
695 : 0 : pTemp, pValueTD, 0 );
696 [ # # ][ # # ]: 0 : TYPELIB_DANGER_RELEASE( pValueTD );
697 : : }
698 : :
699 [ - + ]: 4816 : if (! bAssign)
700 : : {
701 : : IllegalArgumentException aExc(
702 : : OUString( RTL_CONSTASCII_USTRINGPARAM("cannot coerce argument type during corereflection call!") ),
703 [ # # ][ # # ]: 0 : *(const Reference< XInterface > *)rObj.getValue(), (sal_Int16)nPos );
704 : :
705 : : // cleanup
706 [ # # ]: 0 : while (nPos--)
707 : : {
708 [ # # ]: 0 : if (pParams[nPos].bIn)
709 : 0 : uno_destructData( ppUnoArgs[nPos], ppParamTypes[nPos], 0 );
710 [ # # ][ # # ]: 0 : TYPELIB_DANGER_RELEASE( ppParamTypes[nPos] );
711 : : }
712 [ # # ][ # # ]: 0 : TYPELIB_DANGER_RELEASE( pReturnType );
713 [ # # ]: 0 : (*pUnoI->release)( pUnoI );
714 : :
715 [ # # ]: 0 : throw aExc;
716 : : }
717 : : }
718 : : }
719 : :
720 : : uno_Any aUnoExc;
721 : 4405 : uno_Any * pUnoExc = &aUnoExc;
722 : :
723 : : (*pUnoI->pDispatcher)(
724 [ + - ]: 4405 : pUnoI, getTypeDescr(), pUnoReturn, ppUnoArgs, &pUnoExc );
725 [ + - ]: 4405 : (*pUnoI->release)( pUnoI );
726 : :
727 : 4405 : Any aRet;
728 [ + + ]: 4405 : if (pUnoExc)
729 : : {
730 : : // cleanup
731 [ + + ]: 12 : while (nParams--)
732 : : {
733 [ + - ]: 8 : if (pParams[nParams].bIn)
734 : 8 : uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], 0 );
735 [ + - ][ - + ]: 8 : TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] );
736 : : }
737 [ + - ][ - + ]: 4 : TYPELIB_DANGER_RELEASE( pReturnType );
738 : :
739 [ + - ]: 4 : InvocationTargetException aExc;
740 [ + - ]: 4 : aExc.Context = *(const Reference< XInterface > *)rObj.getValue();
741 [ + - ]: 4 : aExc.Message = OUString( RTL_CONSTASCII_USTRINGPARAM("exception occurred during invocation!") );
742 : : uno_any_destruct(
743 : : &aExc.TargetException,
744 : 4 : reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
745 : : uno_type_copyAndConvertData(
746 [ + - ]: 4 : &aExc.TargetException, pUnoExc, ::getCppuType( (const Any *)0 ).getTypeLibType(),
747 [ + - ]: 8 : getReflection()->getUno2Cpp().get() );
748 : 4 : uno_any_destruct( pUnoExc, 0 );
749 [ + - ]: 4 : throw aExc;
750 : : }
751 : : else
752 : : {
753 : : // reconvert arguments and cleanup
754 [ + + ]: 9209 : while (nParams--)
755 : : {
756 [ + + ]: 4808 : if (pParams[nParams].bOut) // write back
757 : : {
758 : : uno_any_destruct(
759 : 16 : &pCppArgs[nParams],
760 : 16 : reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
761 : : uno_any_constructAndConvert(
762 : 48 : &pCppArgs[nParams], ppUnoArgs[nParams], ppParamTypes[nParams],
763 [ + - ]: 16 : getReflection()->getUno2Cpp().get() );
764 : : }
765 : 4808 : uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], 0 );
766 [ - + ][ + - ]: 4808 : TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] );
767 : : }
768 : : uno_any_destruct(
769 : 4401 : &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
770 : : uno_any_constructAndConvert(
771 : : &aRet, pUnoReturn, pReturnType,
772 [ + - ]: 4401 : getReflection()->getUno2Cpp().get() );
773 : 4401 : uno_destructData( pUnoReturn, pReturnType, 0 );
774 [ - + ][ + - ]: 4401 : TYPELIB_DANGER_RELEASE( pReturnType );
775 : : }
776 : 4405 : return aRet;
777 : : }
778 : : throw IllegalArgumentException(
779 : : OUString( RTL_CONSTASCII_USTRINGPARAM("illegal destination object given!") ),
780 [ # # ][ # # ]: 4401 : (XWeak *)(OWeakObject *)this, 0 );
[ # # ]
781 : : }
782 : :
783 : :
784 : : //##################################################################################################
785 : : //##################################################################################################
786 : : //##################################################################################################
787 : :
788 : :
789 : : //__________________________________________________________________________________________________
790 [ + - ][ + - ]: 6107 : InterfaceIdlClassImpl::~InterfaceIdlClassImpl()
[ + - ]
791 : : {
792 [ + + ]: 8950 : for ( sal_Int32 nPos = _nMethods + _nAttributes; nPos--; )
793 : 2843 : typelib_typedescription_release( _pSortedMemberInit[nPos].second );
794 : :
795 [ + + ][ + + ]: 8950 : delete [] _pSortedMemberInit;
796 [ - + ]: 12214 : }
797 : :
798 : : //__________________________________________________________________________________________________
799 : 52548 : Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses()
800 : : throw(::com::sun::star::uno::RuntimeException)
801 : : {
802 [ + - ][ + - ]: 52548 : MutexGuard aGuard(getMutexAccess());
803 [ + + ]: 52548 : if (_xSuperClasses.getLength() == 0) {
804 : 38546 : typelib_InterfaceTypeDescription * pType = getTypeDescr();
805 [ + - ]: 38546 : _xSuperClasses.realloc(pType->nBaseTypes);
806 [ + + ]: 52192 : for (sal_Int32 i = 0; i < pType->nBaseTypes; ++i) {
807 [ + - ]: 13646 : _xSuperClasses[i] = getReflection()->forType(
808 [ + - ][ + - ]: 27292 : &pType->ppBaseTypes[i]->aBase);
809 : : OSL_ASSERT(_xSuperClasses[i].is());
810 : : }
811 : : }
812 [ + - ][ + - ]: 52548 : return Sequence< Reference< XIdlClass > >(_xSuperClasses);
813 : : }
814 : : //__________________________________________________________________________________________________
815 : 12119 : void InterfaceIdlClassImpl::initMembers()
816 : : {
817 : 12119 : sal_Int32 nAll = getTypeDescr()->nAllMembers;
818 [ + + ]: 91183 : MemberInit * pSortedMemberInit = new MemberInit[nAll];
819 : 12119 : typelib_TypeDescriptionReference ** ppAllMembers = getTypeDescr()->ppAllMembers;
820 : :
821 [ + + ]: 91183 : for ( sal_Int32 nPos = 0; nPos < nAll; ++nPos )
822 : : {
823 : : sal_Int32 nIndex;
824 [ + + ]: 79064 : if (ppAllMembers[nPos]->eTypeClass == typelib_TypeClass_INTERFACE_METHOD)
825 : : {
826 : : // methods to front
827 : 77034 : nIndex = _nMethods;
828 : 77034 : ++_nMethods;
829 : : }
830 : : else
831 : : {
832 : 2030 : ++_nAttributes;
833 : 2030 : nIndex = (nAll - _nAttributes);
834 : : // attributes at the back
835 : : }
836 : :
837 : 79064 : typelib_TypeDescription * pTD = 0;
838 : 79064 : typelib_typedescriptionreference_getDescription( &pTD, ppAllMembers[nPos] );
839 : : OSL_ENSURE( pTD, "### cannot get type description!" );
840 : 79064 : pSortedMemberInit[nIndex].first = ((typelib_InterfaceMemberTypeDescription *)pTD)->pMemberName;
841 : 79064 : pSortedMemberInit[nIndex].second = pTD;
842 : : }
843 : :
844 : 12119 : _pSortedMemberInit = pSortedMemberInit;
845 : 12119 : }
846 : : //__________________________________________________________________________________________________
847 : 4759 : sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
848 : : throw(::com::sun::star::uno::RuntimeException)
849 : : {
850 [ + - ][ + - ]: 4759 : if (xType.is() && xType->getTypeClass() == TypeClass_INTERFACE)
[ + - ]
851 : : {
852 [ + + ]: 4759 : if (equals( xType ))
853 : 130 : return sal_True;
854 : : else
855 : : {
856 : 4629 : const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses();
857 [ - + ]: 4629 : for (sal_Int32 i = 0; i < rSeq.getLength(); ++i) {
858 [ # # ][ # # ]: 0 : if (isAssignableFrom(rSeq[i])) {
859 : 0 : return true;
860 : : }
861 [ + - ]: 4629 : }
862 : : }
863 : : }
864 : 4759 : return sal_False;
865 : : }
866 : : //__________________________________________________________________________________________________
867 : 0 : Uik InterfaceIdlClassImpl::getUik()
868 : : throw(::com::sun::star::uno::RuntimeException)
869 : : {
870 : 0 : return Uik(0, 0, 0, 0, 0);
871 : : // Uiks are deprecated and this function must not be called
872 : : }
873 : : //__________________________________________________________________________________________________
874 : 23488 : Sequence< Reference< XIdlMethod > > InterfaceIdlClassImpl::getMethods()
875 : : throw(::com::sun::star::uno::RuntimeException)
876 : : {
877 [ + - ][ + - ]: 23488 : MutexGuard aGuard( getMutexAccess() );
878 [ - + ]: 23488 : if (! _pSortedMemberInit)
879 [ # # ]: 0 : initMembers();
880 : :
881 : : // create methods sequence
882 [ + - ]: 23488 : Sequence< Reference< XIdlMethod > > aRet( _nMethods );
883 [ + - ]: 23488 : Reference< XIdlMethod > * pRet = aRet.getArray();
884 [ + + ]: 164226 : for ( sal_Int32 nPos = _nMethods; nPos--; )
885 : : {
886 : :
887 : : /*_aName2Method[_pSortedMemberInit[nPos].first] = */pRet[nPos] = new IdlInterfaceMethodImpl(
888 : 281476 : getReflection(), _pSortedMemberInit[nPos].first,
889 [ + - ][ + - ]: 140738 : _pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() );
[ + - ]
890 : : }
891 [ + - ]: 23488 : return aRet;
892 : : }
893 : : //__________________________________________________________________________________________________
894 : 23488 : Sequence< Reference< XIdlField > > InterfaceIdlClassImpl::getFields()
895 : : throw(::com::sun::star::uno::RuntimeException)
896 : : {
897 [ + - ][ + - ]: 23488 : MutexGuard aGuard( getMutexAccess() );
898 [ + + ]: 23488 : if (! _pSortedMemberInit)
899 [ + - ]: 12034 : initMembers();
900 : :
901 : : // create fields sequence
902 [ + - ]: 23488 : Sequence< Reference< XIdlField > > aRet( _nAttributes );
903 [ + - ]: 23488 : Reference< XIdlField > * pRet = aRet.getArray();
904 [ + + ]: 25833 : for ( sal_Int32 nPos = _nAttributes; nPos--; )
905 : : {
906 : : /*_aName2Field[_pSortedMemberInit[_nMethods+nPos].first] = */pRet[_nAttributes-nPos-1] =
907 : : new IdlAttributeFieldImpl(
908 : 4690 : getReflection(), _pSortedMemberInit[_nMethods+nPos].first,
909 [ + - ][ + - ]: 2345 : _pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() );
[ + - ]
910 : : }
911 [ + - ]: 23488 : return aRet;
912 : : }
913 : : //__________________________________________________________________________________________________
914 : 38 : Reference< XIdlMethod > InterfaceIdlClassImpl::getMethod( const OUString & rName )
915 : : throw(::com::sun::star::uno::RuntimeException)
916 : : {
917 [ + - ][ + - ]: 38 : MutexGuard aGuard( getMutexAccess() );
918 [ + + ]: 38 : if (! _pSortedMemberInit)
919 [ + - ]: 2 : initMembers();
920 : :
921 : 38 : Reference< XIdlMethod > xRet;
922 : :
923 : : // try weak map
924 [ + - ]: 38 : const OUString2Method::const_iterator iFind( _aName2Method.find( rName ) );
925 [ + + ][ + - ]: 38 : if (iFind != _aName2Method.end())
926 [ + - ][ + - ]: 30 : xRet = (*iFind).second; // harden ref
[ + - ]
927 : :
928 [ + - ]: 38 : if (! xRet.is())
929 : : {
930 [ + - ]: 112 : for ( sal_Int32 nPos = _nMethods; nPos--; )
931 : : {
932 [ + + ]: 74 : if (_pSortedMemberInit[nPos].first == rName)
933 : : {
934 [ + - ]: 38 : _aName2Method[rName] = xRet = new IdlInterfaceMethodImpl(
935 : 38 : getReflection(), rName,
936 [ + - ][ + - ]: 76 : _pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() );
[ + - ][ + - ]
937 : 38 : break;
938 : : }
939 : : }
940 : : }
941 [ + - ]: 38 : return xRet;
942 : : }
943 : : //__________________________________________________________________________________________________
944 : 249 : Reference< XIdlField > InterfaceIdlClassImpl::getField( const OUString & rName )
945 : : throw(::com::sun::star::uno::RuntimeException)
946 : : {
947 [ + - ][ + - ]: 249 : MutexGuard aGuard( getMutexAccess() );
948 [ + + ]: 249 : if (! _pSortedMemberInit)
949 [ + - ]: 83 : initMembers();
950 : :
951 : 249 : Reference< XIdlField > xRet;
952 : :
953 : : // try weak map
954 [ + - ]: 249 : const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
955 [ + + ][ + - ]: 249 : if (iFind != _aName2Field.end())
956 [ + - ][ + - ]: 83 : xRet = (*iFind).second; // harden ref
[ + - ]
957 : :
958 [ + + ]: 249 : if (! xRet.is())
959 : : {
960 [ + - ]: 415 : for ( sal_Int32 nPos = _nAttributes; nPos--; )
961 : : {
962 [ + + ]: 249 : if (_pSortedMemberInit[_nMethods+nPos].first == rName)
963 : : {
964 [ + - ]: 166 : _aName2Field[rName] = xRet = new IdlAttributeFieldImpl(
965 : 166 : getReflection(), rName,
966 [ + - ][ + - ]: 332 : _pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() );
[ + - ][ + - ]
967 : 166 : break;
968 : : }
969 : : }
970 : : }
971 [ + - ]: 249 : return xRet;
972 : : }
973 : : //__________________________________________________________________________________________________
974 : 0 : void InterfaceIdlClassImpl::createObject( Any & rObj )
975 : : throw(::com::sun::star::uno::RuntimeException)
976 : : {
977 : : // interfaces cannot be constructed
978 : 0 : rObj.clear();
979 : 0 : }
980 : :
981 : : }
982 : :
983 : :
984 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|