update dev300-m58
[ooovba.git] / cppu / test / test_cuno.c
blobeecc87da3eecf9b183d7596c7a33dd8a4d455cf7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: test_cuno.c,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <stdio.h>
32 #include <osl/diagnose.h>
33 #include <osl/time.h>
34 #include <osl/interlck.h>
35 #include <rtl/alloc.h>
38 #include <uno/dispatcher.h>
39 #include <uno/environment.h>
40 #include <uno/mapping.hxx>
42 #include <uno/data.h>
43 #include <uno/any2.h>
44 #include <uno/sequence2.h>
46 #include <test/XLanguageBindingTest.h>
49 typedef struct _InstanceData
51 void const * m_XInterface[2];
52 void const * m_XLBTestBase[2];
53 void const * m_XLanguageBindingTest[2];
55 sal_Int32 m_refCount;
56 typelib_TypeDescription* m_pTDXInterface;
57 typelib_TypeDescription* m_pTDSeqTestElement;
58 typelib_TypeDescription* m_pTDTestDataElements;
59 test_TestDataElements m_data, m_structData;
60 } InstanceData;
62 #define GET_THIS( p ) (InstanceData *)((void **)p)[1]
64 //==================================================================================================
65 static void SAL_CALL c_acquire( void * p )
66 SAL_THROW_EXTERN_C( )
68 CUNO_CALL( ((com_sun_star_uno_XInterface *)p) )->acquire( (com_sun_star_uno_XInterface *)p );
70 //==================================================================================================
71 static void SAL_CALL c_release( void * p )
72 SAL_THROW_EXTERN_C( )
74 CUNO_CALL( ((com_sun_star_uno_XInterface *)p) )->release( (com_sun_star_uno_XInterface *)p );
76 //==================================================================================================
77 static void * SAL_CALL c_queryInterface( void * p, typelib_TypeDescriptionReference * pType )
78 SAL_THROW_EXTERN_C( )
80 uno_Any aExc;
81 com_sun_star_uno_XInterface * pRet = NULL;
83 if (CUNO_EXCEPTION_OCCURED( CUNO_CALL( ((com_sun_star_uno_XInterface *)p) )->queryInterface( (com_sun_star_uno_XInterface *)p, &aExc, &pRet, pType ) ))
85 uno_any_destruct( &aExc, c_release );
86 return NULL;
88 else
90 return pRet;
94 void defaultConstructData(test_TestDataElements* pData, typelib_TypeDescriptionReference * pElemType)
96 pData->_Base._Base.Bool = sal_False;
97 pData->_Base._Base.Char = 0;
98 pData->_Base._Base.Byte = 0;
99 pData->_Base._Base.Short = 0;
100 pData->_Base._Base.UShort = 0;
101 pData->_Base._Base.Long = 0;
102 pData->_Base._Base.ULong = 0;
103 pData->_Base._Base.Hyper = 0;
104 pData->_Base._Base.UHyper = 0;
105 pData->_Base._Base.Float = 0;
106 pData->_Base._Base.Double = 0;
107 pData->_Base._Base.Enum = test_TestEnum_TEST;
108 pData->_Base.String = 0;
109 rtl_uString_new(&pData->_Base.String);
110 pData->_Base.Interface = 0;
111 uno_any_construct(&pData->_Base.Any, 0, 0, 0);
112 /* pData->Sequence = 0; */
113 uno_type_sequence_construct(
114 &pData->Sequence, pElemType, 0, 0, c_acquire );
117 void assign1( test_TestSimple* rData,
118 sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
119 sal_Int16 nShort, sal_uInt16 nUShort,
120 sal_Int32 nLong, sal_uInt32 nULong,
121 sal_Int64 nHyper, sal_uInt64 nUHyper,
122 float fFloat, double fDouble,
123 test_TestEnum eEnum)
125 rData->Bool = bBool;
126 rData->Char = cChar;
127 rData->Byte = nByte;
128 rData->Short = nShort;
129 rData->UShort = nUShort;
130 rData->Long = nLong;
131 rData->ULong = nULong;
132 rData->Hyper = nHyper;
133 rData->UHyper = nUHyper;
134 rData->Float = fFloat;
135 rData->Double = fDouble;
136 rData->Enum = eEnum;
139 void assign2( test_TestElement* rData,
140 sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
141 sal_Int16 nShort, sal_uInt16 nUShort,
142 sal_Int32 nLong, sal_uInt32 nULong,
143 sal_Int64 nHyper, sal_uInt64 nUHyper,
144 float fFloat, double fDouble,
145 test_TestEnum eEnum, rtl_uString* rStr,
146 com_sun_star_uno_XInterface* xTest,
147 uno_Any* rAny,
148 typelib_TypeDescription* pTDIface)
150 assign1( (test_TestSimple *)rData,
151 bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
152 eEnum );
153 rtl_uString_assign(&rData->String, rStr);
154 /* uno_assignData(&rData->Interface, pTDIface, &xTest, pTDIface, c_queryInterface, c_acquire, c_release); */
155 if ( rData->Interface )
156 CUNO_CALL(rData->Interface)->release(rData->Interface);
158 if ( xTest )
160 CUNO_CALL(xTest)->acquire(xTest);
161 rData->Interface = xTest;
162 } else
164 rData->Interface = 0;
167 uno_type_any_assign(&rData->Any, rAny->pData, rAny->pType, c_acquire, c_release);
170 void assign3( test_TestDataElements* rData,
171 sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
172 sal_Int16 nShort, sal_uInt16 nUShort,
173 sal_Int32 nLong, sal_uInt32 nULong,
174 sal_Int64 nHyper, sal_uInt64 nUHyper,
175 float fFloat, double fDouble,
176 test_TestEnum eEnum, rtl_uString* rStr,
177 com_sun_star_uno_XInterface* xTest,
178 uno_Any* rAny,
179 /* sequence< test_TestElement >*/uno_Sequence* rSequence,
180 typelib_TypeDescription* pTDIface,
181 typelib_TypeDescription* pTDSeqElem)
183 assign2( (test_TestElement *)rData,
184 bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
185 eEnum,rStr, xTest, rAny, pTDIface );
186 uno_sequence_assign(&rData->Sequence, rSequence, pTDSeqElem, c_release);
189 /* XInterface =============================================================================== */
191 /* XInterface::acquire */
192 cuno_ErrorCode SAL_CALL XInterface_acquire( com_sun_star_uno_XInterface* pIFace)
194 InstanceData * pImpl = GET_THIS( pIFace );
195 osl_incrementInterlockedCount( &pImpl->m_refCount );
196 return CUNO_ERROR_NONE;
199 /* XInterface::release */
200 cuno_ErrorCode SAL_CALL XInterface_release( com_sun_star_uno_XInterface * pIFace )
202 InstanceData * pImpl = GET_THIS( pIFace );
203 if( osl_decrementInterlockedCount( &pImpl->m_refCount ) == 0)
205 uno_destructData(&pImpl->m_data, pImpl->m_pTDTestDataElements, c_release);
206 uno_destructData(&pImpl->m_structData, pImpl->m_pTDTestDataElements, c_release);
207 typelib_typedescription_release(pImpl->m_pTDXInterface);
208 typelib_typedescription_release(pImpl->m_pTDSeqTestElement);
209 typelib_typedescription_release(pImpl->m_pTDTestDataElements);
210 rtl_freeMemory( pImpl );
212 return CUNO_ERROR_NONE;
215 /* XInterface::queryInterface */
216 cuno_ErrorCode SAL_CALL XInterface_queryInterface( com_sun_star_uno_XInterface * pIFace, uno_Any * pExc, com_sun_star_uno_XInterface ** pRet, typelib_TypeDescriptionReference * pTypeRef)
218 InstanceData * pImpl = GET_THIS( pIFace );
219 com_sun_star_uno_XInterface * pIFaceRet = 0;
220 if ( pTypeRef )
222 if( ! rtl_ustr_ascii_compare_WithLength( pTypeRef->pTypeName->buffer, pTypeRef->pTypeName->length,
223 "com.sun.star.uno.XInterface" ) )
224 pIFaceRet = (com_sun_star_uno_XInterface *)&pImpl->m_XInterface;
225 else if( !rtl_ustr_ascii_compare_WithLength( pTypeRef->pTypeName->buffer, pTypeRef->pTypeName->length,
226 "test.XLBTestBase" ) )
227 pIFaceRet = (com_sun_star_uno_XInterface *)&pImpl->m_XLBTestBase;
228 else if( !rtl_ustr_ascii_compare_WithLength( pTypeRef->pTypeName->buffer, pTypeRef->pTypeName->length,
229 "test.XLanguageBindingTest" ) )
230 pIFaceRet = (com_sun_star_uno_XInterface *)&pImpl->m_XLanguageBindingTest;
232 if( pIFaceRet )
234 CUNO_CALL(pIFaceRet)->acquire( pIFaceRet );
235 *pRet = pIFaceRet;
236 } else
238 *pRet = 0;
241 return CUNO_ERROR_NONE;
244 /* XLBTestBase =============================================================================== */
246 /* XLBTestBase::getBool */
247 cuno_ErrorCode SAL_CALL XLBTestBase_getBool( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Bool *pRet)
249 InstanceData * pImpl = GET_THIS( pIFace );
250 *pRet = pImpl->m_data._Base._Base.Bool;
251 return CUNO_ERROR_NONE;
253 /* XLBTestBase::setBool */
254 cuno_ErrorCode SAL_CALL XLBTestBase_setBool( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Bool value)
256 InstanceData * pImpl = GET_THIS( pIFace );
257 pImpl->m_data._Base._Base.Bool = value;
258 return CUNO_ERROR_NONE;
260 /* XLBTestBase::getByte */
261 cuno_ErrorCode SAL_CALL XLBTestBase_getByte( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int8 *pRet)
263 InstanceData * pImpl = GET_THIS( pIFace );
264 *pRet = pImpl->m_data._Base._Base.Byte;
265 return CUNO_ERROR_NONE;
267 /* XLBTestBase::setByte */
268 cuno_ErrorCode SAL_CALL XLBTestBase_setByte( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int8 value)
270 InstanceData * pImpl = GET_THIS( pIFace );
271 pImpl->m_data._Base._Base.Byte = value;
272 return CUNO_ERROR_NONE;
274 /* XLBTestBase::getChar */
275 cuno_ErrorCode SAL_CALL XLBTestBase_getChar( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Unicode *pRet)
277 InstanceData * pImpl = GET_THIS( pIFace );
278 *pRet = pImpl->m_data._Base._Base.Char;
279 return CUNO_ERROR_NONE;
281 /* XLBTestBase::setChar */
282 cuno_ErrorCode SAL_CALL XLBTestBase_setChar( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Unicode value)
284 InstanceData * pImpl = GET_THIS( pIFace );
285 pImpl->m_data._Base._Base.Char = value;
286 return CUNO_ERROR_NONE;
288 /* XLBTestBase::getShort */
289 cuno_ErrorCode SAL_CALL XLBTestBase_getShort( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int16 *pRet)
291 InstanceData * pImpl = GET_THIS( pIFace );
292 *pRet = pImpl->m_data._Base._Base.Short;
293 return CUNO_ERROR_NONE;
295 /* XLBTestBase::setShort */
296 cuno_ErrorCode SAL_CALL XLBTestBase_setShort( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int16 value)
298 InstanceData * pImpl = GET_THIS( pIFace );
299 pImpl->m_data._Base._Base.Short = value;
300 return CUNO_ERROR_NONE;
302 /* XLBTestBase::getUShort */
303 cuno_ErrorCode SAL_CALL XLBTestBase_getUShort( test_XLBTestBase * pIFace, uno_Any * pExc, sal_uInt16 *pRet)
305 InstanceData * pImpl = GET_THIS( pIFace );
306 *pRet = pImpl->m_data._Base._Base.UShort;
307 return CUNO_ERROR_NONE;
309 /* XLBTestBase::setUShort */
310 cuno_ErrorCode SAL_CALL XLBTestBase_setUShort( test_XLBTestBase * pIFace, uno_Any * pExc, sal_uInt16 value)
312 InstanceData * pImpl = GET_THIS( pIFace );
313 pImpl->m_data._Base._Base.UShort = value;
314 return CUNO_ERROR_NONE;
316 /* XLBTestBase::getLong */
317 cuno_ErrorCode SAL_CALL XLBTestBase_getLong( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int32 *pRet)
319 InstanceData * pImpl = GET_THIS( pIFace );
320 *pRet = pImpl->m_data._Base._Base.Long;
321 return CUNO_ERROR_NONE;
323 /* XLBTestBase::setLong */
324 cuno_ErrorCode SAL_CALL XLBTestBase_setLong( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int32 value)
326 InstanceData * pImpl = GET_THIS( pIFace );
327 pImpl->m_data._Base._Base.Long = value;
328 return CUNO_ERROR_NONE;
330 /* XLBTestBase::getULong */
331 cuno_ErrorCode SAL_CALL XLBTestBase_getULong( test_XLBTestBase * pIFace, uno_Any * pExc, sal_uInt32 *pRet)
333 InstanceData * pImpl = GET_THIS( pIFace );
334 *pRet = pImpl->m_data._Base._Base.ULong;
335 return CUNO_ERROR_NONE;
337 /* XLBTestBase::setULong */
338 cuno_ErrorCode SAL_CALL XLBTestBase_setULong( test_XLBTestBase * pIFace, uno_Any * pExc, sal_uInt32 value)
340 InstanceData * pImpl = GET_THIS( pIFace );
341 pImpl->m_data._Base._Base.ULong = value;
342 return CUNO_ERROR_NONE;
344 /* XLBTestBase::getHyper */
345 cuno_ErrorCode SAL_CALL XLBTestBase_getHyper( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int64 *pRet)
347 InstanceData * pImpl = GET_THIS( pIFace );
348 *pRet = pImpl->m_data._Base._Base.Hyper;
349 return CUNO_ERROR_NONE;
351 /* XLBTestBase::setHyper */
352 cuno_ErrorCode SAL_CALL XLBTestBase_setHyper( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Int64 value)
354 InstanceData * pImpl = GET_THIS( pIFace );
355 pImpl->m_data._Base._Base.Hyper = value;
356 return CUNO_ERROR_NONE;
358 /* XLBTestBase::getUHyper */
359 cuno_ErrorCode SAL_CALL XLBTestBase_getUHyper( test_XLBTestBase * pIFace, uno_Any * pExc, sal_uInt64 *pRet)
361 InstanceData * pImpl = GET_THIS( pIFace );
362 *pRet = pImpl->m_data._Base._Base.UHyper;
363 return CUNO_ERROR_NONE;
365 /* XLBTestBase::setUHyper */
366 cuno_ErrorCode SAL_CALL XLBTestBase_setUHyper( test_XLBTestBase * pIFace, uno_Any * pExc, sal_uInt64 value)
368 InstanceData * pImpl = GET_THIS( pIFace );
369 pImpl->m_data._Base._Base.UHyper = value;
370 return CUNO_ERROR_NONE;
372 /* XLBTestBase::getFloat */
373 cuno_ErrorCode SAL_CALL XLBTestBase_getFloat( test_XLBTestBase * pIFace, uno_Any * pExc, float *pRet)
375 InstanceData * pImpl = GET_THIS( pIFace );
376 *pRet = pImpl->m_data._Base._Base.Float;
377 return CUNO_ERROR_NONE;
379 /* XLBTestBase::setFloat */
380 cuno_ErrorCode SAL_CALL XLBTestBase_setFloat( test_XLBTestBase * pIFace, uno_Any * pExc, float value)
382 InstanceData * pImpl = GET_THIS( pIFace );
383 pImpl->m_data._Base._Base.Float = value;
384 return CUNO_ERROR_NONE;
386 /* XLBTestBase::getDouble */
387 cuno_ErrorCode SAL_CALL XLBTestBase_getDouble( test_XLBTestBase * pIFace, uno_Any * pExc, double *pRet)
389 InstanceData * pImpl = GET_THIS( pIFace );
390 *pRet = pImpl->m_data._Base._Base.Double;
391 return CUNO_ERROR_NONE;
393 /* XLBTestBase::setDouble */
394 cuno_ErrorCode SAL_CALL XLBTestBase_setDouble( test_XLBTestBase * pIFace, uno_Any * pExc, double value)
396 InstanceData * pImpl = GET_THIS( pIFace );
397 pImpl->m_data._Base._Base.Double = value;
398 return CUNO_ERROR_NONE;
400 /* XLBTestBase::getEnum */
401 cuno_ErrorCode SAL_CALL XLBTestBase_getEnum( test_XLBTestBase * pIFace, uno_Any * pExc, test_TestEnum *pRet)
403 InstanceData * pImpl = GET_THIS( pIFace );
404 *pRet = pImpl->m_data._Base._Base.Enum;
405 return CUNO_ERROR_NONE;
407 /* XLBTestBase::setEnum */
408 cuno_ErrorCode SAL_CALL XLBTestBase_setEnum( test_XLBTestBase * pIFace, uno_Any * pExc, test_TestEnum value)
410 InstanceData * pImpl = GET_THIS( pIFace );
411 pImpl->m_data._Base._Base.Enum = value;
412 return CUNO_ERROR_NONE;
414 /* XLBTestBase::getString */
415 cuno_ErrorCode SAL_CALL XLBTestBase_getString( test_XLBTestBase * pIFace, uno_Any * pExc, rtl_uString **pRet)
417 InstanceData * pImpl = GET_THIS( pIFace );
418 *pRet = 0;
419 rtl_uString_newFromString(pRet, pImpl->m_data._Base.String);
420 return CUNO_ERROR_NONE;
422 /* XLBTestBase::setString */
423 cuno_ErrorCode SAL_CALL XLBTestBase_setString( test_XLBTestBase * pIFace, uno_Any * pExc, rtl_uString *value)
425 InstanceData * pImpl = GET_THIS( pIFace );
426 rtl_uString_assign(&pImpl->m_data._Base.String, value);
427 return CUNO_ERROR_NONE;
429 /* XLBTestBase::getInterface */
430 cuno_ErrorCode SAL_CALL XLBTestBase_getInterface( test_XLBTestBase * pIFace, uno_Any * pExc, com_sun_star_uno_XInterface **pRet)
432 InstanceData * pImpl = GET_THIS( pIFace );
433 /* uno_copyData(pRet, &pImpl->m_data._Base.Interface, pImpl->m_pTDXInterface, c_acquire); */
434 if ( pImpl->m_data._Base.Interface )
436 CUNO_CALL(pImpl->m_data._Base.Interface)->acquire(pImpl->m_data._Base.Interface);
437 *pRet = pImpl->m_data._Base.Interface;
438 } else
440 *pRet = 0;
442 return CUNO_ERROR_NONE;
444 /* XLBTestBase::setInterface */
445 cuno_ErrorCode SAL_CALL XLBTestBase_setInterface( test_XLBTestBase * pIFace, uno_Any * pExc, com_sun_star_uno_XInterface *value)
447 InstanceData * pImpl = GET_THIS( pIFace );
448 /* uno_assignData(&pImpl->m_data._Base.Interface, pImpl->m_pTDXInterface, &value, pImpl->m_pTDXInterface, c_queryInterface, c_acquire, c_release); */
449 if ( pImpl->m_data._Base.Interface )
450 CUNO_CALL(pImpl->m_data._Base.Interface)->release(pImpl->m_data._Base.Interface);
452 if ( value )
454 CUNO_CALL(value)->acquire(value);
455 pImpl->m_data._Base.Interface = value;
456 } else
458 pImpl->m_data._Base.Interface = 0;
460 return CUNO_ERROR_NONE;
462 /* XLBTestBase::getAny */
463 cuno_ErrorCode SAL_CALL XLBTestBase_getAny( test_XLBTestBase * pIFace, uno_Any * pExc, uno_Any *pRet)
465 InstanceData * pImpl = GET_THIS( pIFace );
466 typelib_TypeDescription* pTD = 0;
467 typelib_typedescriptionreference_getDescription(&pTD, pImpl->m_data._Base.Any.pType);
468 uno_any_construct(pRet, pImpl->m_data._Base.Any.pData, pTD, c_acquire);
469 typelib_typedescription_release(pTD);
470 return CUNO_ERROR_NONE;
472 /* XLBTestBase::setAny */
473 cuno_ErrorCode SAL_CALL XLBTestBase_setAny( test_XLBTestBase * pIFace, uno_Any * pExc, uno_Any *value)
475 InstanceData * pImpl = GET_THIS( pIFace );
476 typelib_TypeDescription* pTD = 0;
477 typelib_typedescriptionreference_getDescription(&pTD, value->pType);
478 uno_any_assign(&pImpl->m_data._Base.Any, value->pData, pTD, c_acquire, c_release);
479 typelib_typedescription_release(pTD);
480 return CUNO_ERROR_NONE;
482 /* XLBTestBase::getSequence */
483 cuno_ErrorCode SAL_CALL XLBTestBase_getSequence( test_XLBTestBase * pIFace, uno_Any * pExc, /*sequence< test.TestElement >*/uno_Sequence **pRet)
485 InstanceData * pImpl = GET_THIS( pIFace );
486 uno_sequence_construct(pRet, pImpl->m_pTDSeqTestElement, pImpl->m_data.Sequence->elements, pImpl->m_data.Sequence->nElements, c_acquire);
487 return CUNO_ERROR_NONE;
489 /* XLBTestBase::setSequence */
490 cuno_ErrorCode SAL_CALL XLBTestBase_setSequence( test_XLBTestBase * pIFace, uno_Any * pExc, /*sequence< test.TestElement >*/uno_Sequence *value)
492 InstanceData * pImpl = GET_THIS( pIFace );
493 uno_sequence_assign(&pImpl->m_data.Sequence, value, pImpl->m_pTDSeqTestElement, c_release);
494 return CUNO_ERROR_NONE;
496 /* XLBTestBase::getStruct */
497 cuno_ErrorCode SAL_CALL XLBTestBase_getStruct( test_XLBTestBase * pIFace, uno_Any * pExc, test_TestDataElements *pRet)
499 InstanceData * pImpl = GET_THIS( pIFace );
500 uno_copyData(pRet, &pImpl->m_structData, pImpl->m_pTDTestDataElements, c_acquire);
501 return CUNO_ERROR_NONE;
503 /* XLBTestBase::setStruct */
504 cuno_ErrorCode SAL_CALL XLBTestBase_setStruct( test_XLBTestBase * pIFace, uno_Any * pExc, test_TestDataElements *value)
506 InstanceData * pImpl = GET_THIS( pIFace );
507 uno_assignData(&pImpl->m_structData, pImpl->m_pTDTestDataElements, value, pImpl->m_pTDTestDataElements, c_queryInterface, c_acquire, c_release);
508 return CUNO_ERROR_NONE;
510 /* XLBTestBase::setValues */
511 cuno_ErrorCode SAL_CALL XLBTestBase_setValues( test_XLBTestBase * pIFace, uno_Any * pExc, sal_Bool aBool, sal_Unicode aChar, sal_Int8 aByte, sal_Int16 aShort, sal_uInt16 aUShort, sal_Int32 aLong, sal_uInt32 aULong, sal_Int64 aHyper, sal_uInt64 aUHyper, float aFloat, double aDouble, test_TestEnum aEnum, rtl_uString* aString, com_sun_star_uno_XInterface *aInterface, uno_Any * aAny, /*sequence< test.TestElement >*/ uno_Sequence * aSequence, test_TestDataElements *aStruct)
513 InstanceData * pImpl = GET_THIS( pIFace );
514 assign3(&pImpl->m_data, aBool, aChar, aByte, aShort, aUShort, aLong, aULong, aHyper, aUHyper, aFloat, aDouble,
515 aEnum, aString, aInterface, aAny,aSequence, pImpl->m_pTDXInterface, pImpl->m_pTDSeqTestElement);
516 uno_assignData(&pImpl->m_structData, pImpl->m_pTDTestDataElements, aStruct, pImpl->m_pTDTestDataElements, c_queryInterface, c_acquire, c_release);
517 return CUNO_ERROR_NONE;
519 /* XLBTestBase::setValues2 */
520 cuno_ErrorCode SAL_CALL XLBTestBase_setValues2( test_XLBTestBase * pIFace, uno_Any * pExc, test_TestDataElements* pRet, sal_Bool* aBool, sal_Unicode* aChar, sal_Int8* aByte, sal_Int16* aShort, sal_uInt16* aUShort, sal_Int32* aLong, sal_uInt32* aULong, sal_Int64* aHyper, sal_uInt64* aUHyper, float* aFloat, double* aDouble, test_TestEnum* aEnum, rtl_uString** aString, com_sun_star_uno_XInterface **aInterface, uno_Any * aAny, /*sequence< test.TestElement >*/ uno_Sequence ** aSequence, test_TestDataElements * aStruct)
522 InstanceData * pImpl = GET_THIS( pIFace );
523 assign3(&pImpl->m_data, *aBool, *aChar, *aByte, *aShort, *aUShort, *aLong, *aULong, *aHyper, *aUHyper, *aFloat, *aDouble,
524 *aEnum, *aString, *aInterface, aAny, *aSequence, pImpl->m_pTDXInterface, pImpl->m_pTDSeqTestElement);
525 uno_assignData(&pImpl->m_structData, pImpl->m_pTDTestDataElements, aStruct, pImpl->m_pTDTestDataElements, c_queryInterface, c_acquire, c_release);
526 uno_copyData(pRet, &pImpl->m_structData, pImpl->m_pTDTestDataElements, c_acquire);
527 return CUNO_ERROR_NONE;
529 /* XLBTestBase::getValues */
530 cuno_ErrorCode SAL_CALL XLBTestBase_getValues( test_XLBTestBase * pIFace, uno_Any * pExc, test_TestDataElements* pRet, sal_Bool* aBool, sal_Unicode* aChar, sal_Int8* aByte, sal_Int16* aShort, sal_uInt16* aUShort, sal_Int32* aLong, sal_uInt32* aULong, sal_Int64* aHyper, sal_uInt64* aUHyper, float* aFloat, double* aDouble, test_TestEnum* aEnum, rtl_uString** aString, com_sun_star_uno_XInterface **aInterface, uno_Any * aAny, /*sequence< test.TestElement >*/ uno_Sequence ** aSequence, test_TestDataElements * aStruct)
532 typelib_TypeDescription* pTD = 0;
533 InstanceData * pImpl = GET_THIS( pIFace );
534 *aBool = pImpl->m_data._Base._Base.Bool;
535 *aChar = pImpl->m_data._Base._Base.Char;
536 *aByte = pImpl->m_data._Base._Base.Byte;
537 *aShort = pImpl->m_data._Base._Base.Short;
538 *aUShort = pImpl->m_data._Base._Base.UShort;
539 *aLong = pImpl->m_data._Base._Base.Long;
540 *aULong = pImpl->m_data._Base._Base.ULong;
541 *aHyper = pImpl->m_data._Base._Base.Hyper;
542 *aUHyper = pImpl->m_data._Base._Base.UHyper;
543 *aFloat = pImpl->m_data._Base._Base.Float;
544 *aDouble = pImpl->m_data._Base._Base.Double;
545 *aEnum = pImpl->m_data._Base._Base.Enum;
546 *aString = 0;
547 rtl_uString_newFromString(aString, pImpl->m_data._Base.String);
548 /* uno_copyData(aInterface, &pImpl->m_data._Base.Interface, pImpl->m_pTDXInterface, c_acquire); */
549 if ( pImpl->m_data._Base.Interface )
551 CUNO_CALL(pImpl->m_data._Base.Interface)->acquire(pImpl->m_data._Base.Interface);
552 *aInterface = pImpl->m_data._Base.Interface;
553 } else
555 *aInterface = 0;
557 typelib_typedescriptionreference_getDescription(&pTD, pImpl->m_data._Base.Any.pType);
558 uno_any_construct(aAny, pImpl->m_data._Base.Any.pData, pTD, c_acquire);
559 typelib_typedescription_release(pTD);
560 uno_sequence_construct(aSequence, pImpl->m_pTDSeqTestElement, pImpl->m_data.Sequence->elements, pImpl->m_data.Sequence->nElements, c_acquire);
561 uno_copyData(aStruct, &pImpl->m_structData, pImpl->m_pTDTestDataElements, c_acquire);
562 uno_copyData(pRet, &pImpl->m_structData, pImpl->m_pTDTestDataElements, c_acquire);
563 return CUNO_ERROR_NONE;
566 /* XLanguageBindingTest =============================================================================== */
568 /* XLanguageBindingTest::getRuntimeException */
569 cuno_ErrorCode SAL_CALL XLanguageBindingTest_getRuntimeException( test_XLanguageBindingTest * pIFace, uno_Any * pExc, sal_Int32 *pRet)
571 InstanceData * pImpl = GET_THIS( pIFace );
572 com_sun_star_uno_RuntimeException aExc;
573 typelib_TypeDescription * pTD = 0;
574 rtl_uString * pTypeName = 0;
575 uno_Any excp;
577 rtl_uString_newFromAscii( &pTypeName, "com.sun.star.uno.RuntimeException");
578 typelib_typedescription_getByName(&pTD, pTypeName);
580 aExc._Base.Message = 0;
581 rtl_uString_newFromAscii(&aExc._Base.Message, "dum dum dum ich tanz im kreis herum...");
582 aExc._Base.Context = 0;
583 if (CUNO_EXCEPTION_OCCURED( CUNO_CALL(pIFace)->getInterface( (test_XLBTestBase *)pIFace, &excp, &aExc._Base.Context) ))
585 /* ... */
586 uno_any_destruct( &excp, 0 );
589 uno_any_construct(pExc, &aExc, pTD, c_acquire);
590 uno_destructData(&aExc, pTD, c_release);
591 typelib_typedescription_release(pTD);
592 rtl_uString_release(pTypeName);
594 return CUNO_ERROR_EXCEPTION;
596 /* XLanguageBindingTest::setRuntimeException */
597 cuno_ErrorCode SAL_CALL XLanguageBindingTest_setRuntimeException( test_XLanguageBindingTest * pIFace, uno_Any * pExc, sal_Int32 value)
599 InstanceData * pImpl = GET_THIS( pIFace );
600 com_sun_star_uno_RuntimeException aExc;
601 typelib_TypeDescription * pTD = 0;
602 rtl_uString * pTypeName = 0;
603 uno_Any excp;
605 rtl_uString_newFromAscii( &pTypeName, "com.sun.star.uno.RuntimeException");
606 typelib_typedescription_getByName(&pTD, pTypeName);
608 aExc._Base.Message = 0;
609 rtl_uString_newFromAscii(&aExc._Base.Message, "dum dum dum ich tanz im kreis herum...");
610 aExc._Base.Context = 0;
611 if (CUNO_EXCEPTION_OCCURED( CUNO_CALL(pIFace)->getInterface( (test_XLBTestBase *)pIFace, &excp, &aExc._Base.Context) ))
613 /* ... */
614 uno_any_destruct( &excp, 0 );
617 uno_any_construct(pExc, &aExc, pTD, c_acquire);
618 uno_destructData(&aExc, pTD, c_release);
619 typelib_typedescription_release(pTD);
620 rtl_uString_release(pTypeName);
622 return CUNO_ERROR_EXCEPTION;
624 /* XLanguageBindingTest::raiseException */
625 cuno_ErrorCode SAL_CALL XLanguageBindingTest_raiseException( test_XLanguageBindingTest * pIFace, uno_Any * pExc, test_TestDataElements* pRet, sal_Bool* aBool, sal_Unicode* aChar, sal_Int8* aByte, sal_Int16* aShort, sal_uInt16* aUShort, sal_Int32* aLong, sal_uInt32* aULong, sal_Int64* aHyper, sal_uInt64* aUHyper, float* aFloat, double* aDouble, test_TestEnum* aEnum, rtl_uString ** aString, com_sun_star_uno_XInterface ** aInterface, uno_Any* aAny, /*sequence< test.TestElement >*/ uno_Sequence ** aSequence, test_TestDataElements* AStruct)
627 InstanceData * pImpl = GET_THIS( pIFace );
628 com_sun_star_lang_IllegalArgumentException aExc;
629 typelib_TypeDescription * pTD = 0;
630 rtl_uString * pTypeName = 0;
631 uno_Any excp;
633 rtl_uString_newFromAscii( &pTypeName, "com.sun.star.lang.IllegalArgumentException");
634 typelib_typedescription_getByName(&pTD, pTypeName);
636 aExc.ArgumentPosition = 5;
637 aExc._Base.Message = 0;
638 rtl_uString_newFromAscii(&aExc._Base.Message, "dum dum dum ich tanz im kreis herum...");
639 aExc._Base.Context = 0;
640 if (CUNO_EXCEPTION_OCCURED( CUNO_CALL(pIFace)->getInterface( (test_XLBTestBase *)pIFace, &excp, &aExc._Base.Context) ))
642 /* ... */
643 uno_any_destruct( &excp, 0 );
646 uno_any_construct(pExc, &aExc, pTD, c_acquire);
647 uno_destructData(&aExc, pTD, c_release);
648 typelib_typedescription_release(pTD);
649 rtl_uString_release(pTypeName);
651 return CUNO_ERROR_EXCEPTION;
655 static const com_sun_star_uno_XInterface_ftab s_XInterface_ftab={
656 XInterface_queryInterface,
657 XInterface_acquire,
658 XInterface_release,
660 static const test_XLBTestBase_ftab s_XLBTestBase_ftab={
661 XInterface_queryInterface,
662 XInterface_acquire,
663 XInterface_release,
664 XLBTestBase_getBool,
665 XLBTestBase_setBool,
666 XLBTestBase_getByte,
667 XLBTestBase_setByte,
668 XLBTestBase_getChar,
669 XLBTestBase_setChar,
670 XLBTestBase_getShort,
671 XLBTestBase_setShort,
672 XLBTestBase_getUShort,
673 XLBTestBase_setUShort,
674 XLBTestBase_getLong,
675 XLBTestBase_setLong,
676 XLBTestBase_getULong,
677 XLBTestBase_setULong,
678 XLBTestBase_getHyper,
679 XLBTestBase_setHyper,
680 XLBTestBase_getUHyper,
681 XLBTestBase_setUHyper,
682 XLBTestBase_getFloat,
683 XLBTestBase_setFloat,
684 XLBTestBase_getDouble,
685 XLBTestBase_setDouble,
686 XLBTestBase_getEnum,
687 XLBTestBase_setEnum,
688 XLBTestBase_getString,
689 XLBTestBase_setString,
690 XLBTestBase_getInterface,
691 XLBTestBase_setInterface,
692 XLBTestBase_getAny,
693 XLBTestBase_setAny,
694 XLBTestBase_getSequence,
695 XLBTestBase_setSequence,
696 XLBTestBase_getStruct,
697 XLBTestBase_setStruct,
698 XLBTestBase_setValues,
699 XLBTestBase_setValues2,
700 XLBTestBase_getValues
702 static const test_XLanguageBindingTest_ftab s_XLanguageBindingTest_ftab={
703 XInterface_queryInterface,
704 XInterface_acquire,
705 XInterface_release,
706 XLBTestBase_getBool,
707 XLBTestBase_setBool,
708 XLBTestBase_getByte,
709 XLBTestBase_setByte,
710 XLBTestBase_getChar,
711 XLBTestBase_setChar,
712 XLBTestBase_getShort,
713 XLBTestBase_setShort,
714 XLBTestBase_getUShort,
715 XLBTestBase_setUShort,
716 XLBTestBase_getLong,
717 XLBTestBase_setLong,
718 XLBTestBase_getULong,
719 XLBTestBase_setULong,
720 XLBTestBase_getHyper,
721 XLBTestBase_setHyper,
722 XLBTestBase_getUHyper,
723 XLBTestBase_setUHyper,
724 XLBTestBase_getFloat,
725 XLBTestBase_setFloat,
726 XLBTestBase_getDouble,
727 XLBTestBase_setDouble,
728 XLBTestBase_getEnum,
729 XLBTestBase_setEnum,
730 XLBTestBase_getString,
731 XLBTestBase_setString,
732 XLBTestBase_getInterface,
733 XLBTestBase_setInterface,
734 XLBTestBase_getAny,
735 XLBTestBase_setAny,
736 XLBTestBase_getSequence,
737 XLBTestBase_setSequence,
738 XLBTestBase_getStruct,
739 XLBTestBase_setStruct,
740 XLBTestBase_setValues,
741 XLBTestBase_setValues2,
742 XLBTestBase_getValues,
743 XLanguageBindingTest_getRuntimeException,
744 XLanguageBindingTest_setRuntimeException,
745 XLanguageBindingTest_raiseException
748 com_sun_star_uno_XInterface* SAL_CALL createTestObject()
750 InstanceData *pObj;
751 rtl_uString* usXInterface = 0;
752 rtl_uString* usSeqTestElement = 0;
753 rtl_uString* usTestDataElements = 0;
755 /* Create a data instance of the component */
756 pObj= (InstanceData*)rtl_allocateMemory( sizeof( InstanceData) );
757 pObj->m_XInterface[0] = &s_XInterface_ftab;
758 pObj->m_XInterface[1] = pObj;
759 pObj->m_XLBTestBase[0] = &s_XLBTestBase_ftab;
760 pObj->m_XLBTestBase[1] = pObj;
761 pObj->m_XLanguageBindingTest[0] = &s_XLanguageBindingTest_ftab;
762 pObj->m_XLanguageBindingTest[1] = pObj;
764 /* Initalize the reference counter member and other component data */
765 pObj->m_refCount= 1;
767 pObj->m_pTDXInterface = 0;
768 rtl_uString_newFromAscii( &usXInterface, "com.sun.star.uno.XInterface");
769 typelib_typedescription_getByName(&pObj->m_pTDXInterface, usXInterface);
771 pObj->m_pTDSeqTestElement = 0;
772 rtl_uString_newFromAscii( &usSeqTestElement, "[]test.TestElement");
773 typelib_typedescription_getByName(&pObj->m_pTDSeqTestElement, usSeqTestElement);
775 pObj->m_pTDTestDataElements = 0;
776 rtl_uString_newFromAscii( &usTestDataElements, "test.TestDataElements");
777 typelib_typedescription_getByName(&pObj->m_pTDTestDataElements, usTestDataElements);
779 defaultConstructData(&pObj->m_data, pObj->m_pTDSeqTestElement->pWeakRef);
780 defaultConstructData(&pObj->m_structData, pObj->m_pTDSeqTestElement->pWeakRef);
782 rtl_uString_release(usXInterface);
783 rtl_uString_release(usSeqTestElement);
784 rtl_uString_release(usTestDataElements);
785 return (com_sun_star_uno_XInterface *)&pObj->m_XInterface;