1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
24 #define _BRIDGES_CPP_UNO_BRIDGE_HXX_
25 
26 #ifndef _BRIDGES_CPP_UNO_BRIDGE_H_
27 #include <bridges/cpp_uno/bridge.h>
28 #endif
29 #include <osl/mutex.hxx>
30 #include <rtl/process.h>
31 #include <rtl/ustrbuf.hxx>
32 #include <com/sun/star/uno/genfunc.hxx>
33 #include <com/sun/star/uno/XInterface.hpp>
34 
35 
36 namespace CPPU_CURRENT_NAMESPACE
37 {
38 
39 //--------------------------------------------------------------------------------------------------
cppu_cppInterfaceProxy_free(uno_ExtEnvironment * pEnv,void * pProxy)40 inline void SAL_CALL cppu_cppInterfaceProxy_free( uno_ExtEnvironment * pEnv, void * pProxy ) SAL_THROW( () )
41 {
42 	cppu_cppInterfaceProxy * pThis =
43 		static_cast< cppu_cppInterfaceProxy * >(
44 			reinterpret_cast< ::com::sun::star::uno::XInterface * >( pProxy ) );
45 	OSL_ASSERT( pEnv == pThis->pBridge->pCppEnv );
46 
47 	(*pThis->pBridge->pUnoEnv->revokeInterface)( pThis->pBridge->pUnoEnv, pThis->pUnoI );
48 	(*pThis->pUnoI->release)( pThis->pUnoI );
49 	::typelib_typedescription_release( (typelib_TypeDescription *)pThis->pTypeDescr );
50 	pThis->pBridge->release();
51 
52 #if OSL_DEBUG_LEVEL > 1
53 	*(int *)pProxy = 0xdeadbabe;
54 #endif
55 	delete pThis;
56 }
57 //--------------------------------------------------------------------------------------------------
cppu_Mapping_uno2cpp(uno_Mapping * pMapping,void ** ppCppI,void * pUnoI,typelib_InterfaceTypeDescription * pTypeDescr)58 inline void SAL_CALL cppu_Mapping_uno2cpp(
59 	uno_Mapping * pMapping, void ** ppCppI,
60 	void * pUnoI, typelib_InterfaceTypeDescription * pTypeDescr ) SAL_THROW( () )
61 {
62 	OSL_ASSERT( ppCppI && pTypeDescr );
63 	if (*ppCppI)
64 	{
65 		reinterpret_cast< ::com::sun::star::uno::XInterface * >( *ppCppI )->release();
66 		*ppCppI = 0;
67 	}
68 	if (pUnoI)
69 	{
70 		cppu_Bridge * pBridge = static_cast< cppu_Mapping * >( pMapping )->pBridge;
71 
72 		// get object id of uno interface to be wrapped
73 		rtl_uString * pOId = 0;
74 		(*pBridge->pUnoEnv->getObjectIdentifier)( pBridge->pUnoEnv, &pOId, pUnoI );
75 		OSL_ASSERT( pOId );
76 
77 		// try to get any known interface from target environment
78 		(*pBridge->pCppEnv->getRegisteredInterface)(
79 			pBridge->pCppEnv, ppCppI, pOId, pTypeDescr );
80 
81 		if (! *ppCppI) // no existing interface, register new proxy interface
82 		{
83 			// try to publish a new proxy (ref count initially 1)
84 			cppu_cppInterfaceProxy * pProxy = new cppu_cppInterfaceProxy(
85 				pBridge, reinterpret_cast< uno_Interface * >( pUnoI ), pTypeDescr, pOId );
86 			::com::sun::star::uno::XInterface * pSurrogate = pProxy;
87 			cppu_cppInterfaceProxy_patchVtable( pSurrogate, pProxy->pTypeDescr );
88 
89 			// proxy may be exchanged during registration
90 			(*pBridge->pCppEnv->registerProxyInterface)(
91 				pBridge->pCppEnv, reinterpret_cast< void ** >( &pSurrogate ),
92 				(uno_freeProxyFunc)cppu_cppInterfaceProxy_free, pOId, pTypeDescr );
93 
94 			*ppCppI = pSurrogate;
95 		}
96 		::rtl_uString_release( pOId );
97 	}
98 }
99 //__________________________________________________________________________________________________
acquireProxy()100 inline void cppu_cppInterfaceProxy::acquireProxy() SAL_THROW( () )
101 {
102 	if (1 == osl_incrementInterlockedCount( &nRef ))
103 	{
104 		// rebirth of proxy zombie
105 		// register at cpp env
106 		void * pThis = static_cast< ::com::sun::star::uno::XInterface * >( this );
107 		(*pBridge->pCppEnv->registerProxyInterface)(
108 			pBridge->pCppEnv, &pThis, (uno_freeProxyFunc)cppu_cppInterfaceProxy_free,
109             oid.pData, pTypeDescr );
110 		OSL_ASSERT( pThis == static_cast< ::com::sun::star::uno::XInterface * >( this ) );
111 	}
112 }
113 //__________________________________________________________________________________________________
releaseProxy()114 inline void cppu_cppInterfaceProxy::releaseProxy() SAL_THROW( () )
115 {
116 	if (! osl_decrementInterlockedCount( &nRef )) // last release
117 	{
118 		// revoke from cpp env
119 		(*pBridge->pCppEnv->revokeInterface)(
120 			pBridge->pCppEnv, static_cast< ::com::sun::star::uno::XInterface * >( this ) );
121 	}
122 }
123 //__________________________________________________________________________________________________
cppu_cppInterfaceProxy(cppu_Bridge * pBridge_,uno_Interface * pUnoI_,typelib_InterfaceTypeDescription * pTypeDescr_,const::rtl::OUString & rOId_)124 inline cppu_cppInterfaceProxy::cppu_cppInterfaceProxy(
125 	cppu_Bridge * pBridge_, uno_Interface * pUnoI_,
126 	typelib_InterfaceTypeDescription * pTypeDescr_, const ::rtl::OUString & rOId_ ) SAL_THROW( () )
127 	: nRef( 1 )
128 	, pBridge( pBridge_ )
129 	, pUnoI( pUnoI_ )
130 	, pTypeDescr( pTypeDescr_ )
131 	, oid( rOId_ )
132 {
133 	pBridge->acquire();
134 	::typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr );
135 	if (! ((typelib_TypeDescription *)pTypeDescr)->bComplete)
136 		::typelib_typedescription_complete( (typelib_TypeDescription **)&pTypeDescr );
137 	OSL_ENSURE( ((typelib_TypeDescription *)pTypeDescr)->bComplete, "### type is incomplete!" );
138 	(*pUnoI->acquire)( pUnoI );
139 	(*pBridge->pUnoEnv->registerInterface)(
140 		pBridge->pUnoEnv, reinterpret_cast< void ** >( &pUnoI ), oid.pData, pTypeDescr );
141 }
142 
143 
144 //##################################################################################################
145 //##################################################################################################
146 //##################################################################################################
147 
148 
149 //--------------------------------------------------------------------------------------------------
cppu_unoInterfaceProxy_free(uno_ExtEnvironment * pEnv,void * pProxy)150 inline void SAL_CALL cppu_unoInterfaceProxy_free( uno_ExtEnvironment * pEnv, void * pProxy ) SAL_THROW( () )
151 {
152 	cppu_unoInterfaceProxy * pThis =
153 		static_cast< cppu_unoInterfaceProxy * >(
154 			reinterpret_cast< uno_Interface * >( pProxy ) );
155 	OSL_ASSERT( pEnv == pThis->pBridge->pUnoEnv );
156 
157 	(*pThis->pBridge->pCppEnv->revokeInterface)( pThis->pBridge->pCppEnv, pThis->pCppI );
158 	pThis->pCppI->release();
159 	::typelib_typedescription_release( (typelib_TypeDescription *)pThis->pTypeDescr );
160 	pThis->pBridge->release();
161 
162 #if OSL_DEBUG_LEVEL > 1
163 	*(int *)pProxy = 0xdeadbabe;
164 #endif
165 	delete pThis;
166 }
167 //--------------------------------------------------------------------------------------------------
cppu_unoInterfaceProxy_acquire(uno_Interface * pUnoI)168 inline void SAL_CALL cppu_unoInterfaceProxy_acquire( uno_Interface * pUnoI ) SAL_THROW( () )
169 {
170 	if (1 == osl_incrementInterlockedCount( & static_cast< cppu_unoInterfaceProxy * >( pUnoI )->nRef ))
171 	{
172 		// rebirth of proxy zombie
173 		// register at uno env
174 #if OSL_DEBUG_LEVEL > 1
175 		void * pThis = pUnoI;
176 #endif
177 		(*static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv->registerProxyInterface)(
178 			static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv,
179 			reinterpret_cast< void ** >( &pUnoI ),
180             (uno_freeProxyFunc)cppu_unoInterfaceProxy_free,
181 			static_cast< cppu_unoInterfaceProxy * >( pUnoI )->oid.pData,
182 			static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pTypeDescr );
183 #if OSL_DEBUG_LEVEL > 1
184 		OSL_ASSERT( pThis == pUnoI );
185 #endif
186 	}
187 }
188 //--------------------------------------------------------------------------------------------------
cppu_unoInterfaceProxy_release(uno_Interface * pUnoI)189 inline void SAL_CALL cppu_unoInterfaceProxy_release( uno_Interface * pUnoI ) SAL_THROW( () )
190 {
191 	if (! osl_decrementInterlockedCount( & static_cast< cppu_unoInterfaceProxy * >( pUnoI )->nRef ))
192 	{
193 		// revoke from uno env on last release
194 		(*static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv->revokeInterface)(
195 			static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv, pUnoI );
196 	}
197 }
198 //--------------------------------------------------------------------------------------------------
cppu_Mapping_cpp2uno(uno_Mapping * pMapping,void ** ppUnoI,void * pCppI,typelib_InterfaceTypeDescription * pTypeDescr)199 inline void SAL_CALL cppu_Mapping_cpp2uno(
200 	uno_Mapping * pMapping, void ** ppUnoI,
201 	void * pCppI, typelib_InterfaceTypeDescription * pTypeDescr ) SAL_THROW( () )
202 {
203 	OSL_ENSURE( ppUnoI && pTypeDescr, "### null ptr!" );
204 	if (*ppUnoI)
205 	{
206 		(*reinterpret_cast< uno_Interface * >( *ppUnoI )->release)(
207 			reinterpret_cast< uno_Interface * >( *ppUnoI ) );
208 		*ppUnoI = 0;
209 	}
210 	if (pCppI)
211 	{
212 		cppu_Bridge * pBridge = static_cast< cppu_Mapping * >( pMapping )->pBridge;
213 
214 		// get object id of interface to be wrapped
215 		rtl_uString * pOId = 0;
216 		(*pBridge->pCppEnv->getObjectIdentifier)( pBridge->pCppEnv, &pOId, pCppI );
217 		OSL_ASSERT( pOId );
218 
219 		// try to get any known interface from target environment
220 		(*pBridge->pUnoEnv->getRegisteredInterface)(
221 			pBridge->pUnoEnv, ppUnoI, pOId, pTypeDescr );
222 
223 		if (! *ppUnoI) // no existing interface, register new proxy interface
224 		{
225 			// try to publish a new proxy (refcount initially 1)
226 			uno_Interface * pSurrogate = new cppu_unoInterfaceProxy(
227 				pBridge, reinterpret_cast< ::com::sun::star::uno::XInterface * >( pCppI ),
228 				pTypeDescr, pOId );
229 
230 			// proxy may be exchanged during registration
231 			(*pBridge->pUnoEnv->registerProxyInterface)(
232 				pBridge->pUnoEnv, reinterpret_cast< void ** >( &pSurrogate ),
233 				(uno_freeProxyFunc)cppu_unoInterfaceProxy_free, pOId, pTypeDescr );
234 
235 			*ppUnoI = pSurrogate;
236 		}
237 		::rtl_uString_release( pOId );
238 	}
239 }
240 //__________________________________________________________________________________________________
cppu_unoInterfaceProxy(cppu_Bridge * pBridge_,::com::sun::star::uno::XInterface * pCppI_,typelib_InterfaceTypeDescription * pTypeDescr_,const::rtl::OUString & rOId_)241 inline cppu_unoInterfaceProxy::cppu_unoInterfaceProxy(
242 	cppu_Bridge * pBridge_, ::com::sun::star::uno::XInterface * pCppI_,
243 	typelib_InterfaceTypeDescription * pTypeDescr_, const ::rtl::OUString & rOId_ ) SAL_THROW( () )
244 	: nRef( 1 )
245 	, pBridge( pBridge_ )
246 	, pCppI( pCppI_ )
247 	, pTypeDescr( pTypeDescr_ )
248 	, oid( rOId_ )
249 {
250 	pBridge->acquire();
251 	::typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr );
252 	if (! ((typelib_TypeDescription *)pTypeDescr)->bComplete)
253 		::typelib_typedescription_complete( (typelib_TypeDescription **)&pTypeDescr );
254 	OSL_ENSURE( ((typelib_TypeDescription *)pTypeDescr)->bComplete, "### type is incomplete!" );
255 	pCppI->acquire();
256 	(*pBridge->pCppEnv->registerInterface)(
257 		pBridge->pCppEnv, reinterpret_cast< void ** >( &pCppI ), oid.pData, pTypeDescr );
258 
259 	// uno_Interface
260 	uno_Interface::acquire = cppu_unoInterfaceProxy_acquire;
261 	uno_Interface::release = cppu_unoInterfaceProxy_release;
262 	uno_Interface::pDispatcher = (uno_DispatchMethod)cppu_unoInterfaceProxy_dispatch;
263 }
264 
265 
266 //##################################################################################################
267 //##################################################################################################
268 //##################################################################################################
269 
270 
271 //--------------------------------------------------------------------------------------------------
cppu_Mapping_acquire(uno_Mapping * pMapping)272 inline void SAL_CALL cppu_Mapping_acquire( uno_Mapping * pMapping ) SAL_THROW( () )
273 {
274 	static_cast< cppu_Mapping * >( pMapping )->pBridge->acquire();
275 }
276 //--------------------------------------------------------------------------------------------------
cppu_Mapping_release(uno_Mapping * pMapping)277 inline void SAL_CALL cppu_Mapping_release( uno_Mapping * pMapping ) SAL_THROW( () )
278 {
279 	static_cast< cppu_Mapping * >( pMapping )->pBridge->release();
280 }
281 //__________________________________________________________________________________________________
cppu_Bridge(uno_ExtEnvironment * pCppEnv_,uno_ExtEnvironment * pUnoEnv_,sal_Bool bExportCpp2Uno_)282 inline cppu_Bridge::cppu_Bridge(
283 	uno_ExtEnvironment * pCppEnv_, uno_ExtEnvironment * pUnoEnv_,
284 	sal_Bool bExportCpp2Uno_ ) SAL_THROW( () )
285 	: nRef( 1 )
286 	, pCppEnv( pCppEnv_ )
287 	, pUnoEnv( pUnoEnv_ )
288 	, bExportCpp2Uno( bExportCpp2Uno_ )
289 {
290     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
291 
292 	aCpp2Uno.pBridge = this;
293 	aCpp2Uno.acquire = cppu_Mapping_acquire;
294 	aCpp2Uno.release = cppu_Mapping_release;
295     aCpp2Uno.mapInterface = cppu_Mapping_cpp2uno;
296 
297 	aUno2Cpp.pBridge = this;
298 	aUno2Cpp.acquire = cppu_Mapping_acquire;
299 	aUno2Cpp.release = cppu_Mapping_release;
300     aUno2Cpp.mapInterface = cppu_Mapping_uno2cpp;
301 
302 	(*((uno_Environment *)pCppEnv)->acquire)( (uno_Environment *)pCppEnv );
303 	(*((uno_Environment *)pUnoEnv)->acquire)( (uno_Environment *)pUnoEnv );
304 }
305 //__________________________________________________________________________________________________
~cppu_Bridge()306 inline cppu_Bridge::~cppu_Bridge() SAL_THROW( () )
307 {
308 	(*((uno_Environment *)pUnoEnv)->release)( (uno_Environment *)pUnoEnv );
309 	(*((uno_Environment *)pCppEnv)->release)( (uno_Environment *)pCppEnv );
310 	g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
311 }
312 //__________________________________________________________________________________________________
cppu_Bridge_free(uno_Mapping * pMapping)313 inline void SAL_CALL cppu_Bridge_free( uno_Mapping * pMapping ) SAL_THROW( () )
314 {
315 	delete static_cast< cppu_Mapping * >( pMapping )->pBridge;
316 }
317 //__________________________________________________________________________________________________
acquire()318 inline void cppu_Bridge::acquire() SAL_THROW( () )
319 {
320 	if (1 == osl_incrementInterlockedCount( &nRef ))
321 	{
322 		if (bExportCpp2Uno)
323 		{
324 			uno_Mapping * pMapping = &aCpp2Uno;
325 			::uno_registerMapping(
326                 &pMapping, cppu_Bridge_free,
327                 (uno_Environment *)pCppEnv, (uno_Environment *)pUnoEnv, 0 );
328 		}
329 		else
330 		{
331 			uno_Mapping * pMapping = &aUno2Cpp;
332 			::uno_registerMapping(
333                 &pMapping, cppu_Bridge_free,
334                 (uno_Environment *)pUnoEnv, (uno_Environment *)pCppEnv, 0 );
335 		}
336 	}
337 }
338 //__________________________________________________________________________________________________
release()339 inline void cppu_Bridge::release() SAL_THROW( () )
340 {
341 	if (! osl_decrementInterlockedCount( &nRef ))
342 	{
343 		::uno_revokeMapping( bExportCpp2Uno ? &aCpp2Uno : &aUno2Cpp );
344 	}
345 }
346 
347 //##################################################################################################
cppu_ext_getMapping(uno_Mapping ** ppMapping,uno_Environment * pFrom,uno_Environment * pTo)348 inline void SAL_CALL cppu_ext_getMapping(
349 	uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo ) SAL_THROW( () )
350 {
351 	OSL_ASSERT( ppMapping && pFrom && pTo );
352 	if (ppMapping && pFrom && pTo && pFrom->pExtEnv && pTo->pExtEnv)
353 	{
354 		uno_Mapping * pMapping = 0;
355 
356 		if (0 == rtl_ustr_ascii_compare( pFrom->pTypeName->buffer, CPPU_CURRENT_LANGUAGE_BINDING_NAME ) &&
357 			0 == rtl_ustr_ascii_compare( pTo->pTypeName->buffer, UNO_LB_UNO ))
358 		{
359 			// ref count initially 1
360 			pMapping = &(new cppu_Bridge( pFrom->pExtEnv, pTo->pExtEnv, sal_True ))->aCpp2Uno;
361 			::uno_registerMapping(
362                 &pMapping, cppu_Bridge_free,
363                 (uno_Environment *)pFrom->pExtEnv,
364                 (uno_Environment *)pTo->pExtEnv, 0 );
365 		}
366 		else if (0 == rtl_ustr_ascii_compare( pTo->pTypeName->buffer, CPPU_CURRENT_LANGUAGE_BINDING_NAME ) &&
367                  0 == rtl_ustr_ascii_compare( pFrom->pTypeName->buffer, UNO_LB_UNO ))
368 		{
369 			// ref count initially 1
370 			pMapping = &(new cppu_Bridge( pTo->pExtEnv, pFrom->pExtEnv, sal_False ))->aUno2Cpp;
371 			::uno_registerMapping(
372                 &pMapping, cppu_Bridge_free,
373                 (uno_Environment *)pFrom->pExtEnv,
374                 (uno_Environment *)pTo->pExtEnv, 0 );
375 		}
376 
377 		if (*ppMapping)
378         {
379 			(*(*ppMapping)->release)( *ppMapping );
380         }
381         if (pMapping)
382 		*ppMapping = pMapping;
383 	}
384 }
385 
386 
387 //##################################################################################################
388 //##################################################################################################
389 //##################################################################################################
390 
391 #if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
392 static ::rtl::OUString * s_pStaticOidPart = 0;
393 #endif
394 
395 // environment init stuff
396 //--------------------------------------------------------------------------------------------------
cppu_cppenv_getStaticOIdPart()397 inline const ::rtl::OUString & SAL_CALL cppu_cppenv_getStaticOIdPart() SAL_THROW( () )
398 {
399 #if ! (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
400 	static ::rtl::OUString * s_pStaticOidPart = 0;
401 #endif
402 	if (! s_pStaticOidPart)
403 	{
404 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
405 		if (! s_pStaticOidPart)
406 		{
407 			::rtl::OUStringBuffer aRet( 64 );
408 			aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM("];") );
409 			// good guid
410 			sal_uInt8 ar[16];
411 			::rtl_getGlobalProcessId( ar );
412 			for ( sal_Int32 i = 0; i < 16; ++i )
413 			{
414 				aRet.append( (sal_Int32)ar[i], 16 );
415 			}
416 #if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
417 			s_pStaticOidPart = new ::rtl::OUString( aRet.makeStringAndClear() );
418 #else
419 			static ::rtl::OUString s_aStaticOidPart( aRet.makeStringAndClear() );
420 			s_pStaticOidPart = &s_aStaticOidPart;
421 #endif
422 		}
423 	}
424 	return *s_pStaticOidPart;
425 }
426 // functions set at environment init
427 //--------------------------------------------------------------------------------------------------
cppu_cppenv_computeObjectIdentifier(uno_ExtEnvironment * pEnv,rtl_uString ** ppOId,void * pInterface)428 inline void SAL_CALL cppu_cppenv_computeObjectIdentifier(
429 	uno_ExtEnvironment * pEnv, rtl_uString ** ppOId, void * pInterface ) SAL_THROW( () )
430 {
431 	OSL_ENSURE( pEnv && ppOId && pInterface, "### null ptr!" );
432 	if (pEnv && ppOId && pInterface)
433 	{
434 		if (*ppOId)
435 		{
436 			rtl_uString_release( *ppOId );
437 			*ppOId = 0;
438 		}
439 
440 		try
441 		{
442 			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xHome(
443 				reinterpret_cast< ::com::sun::star::uno::XInterface * >( pInterface ),
444 				::com::sun::star::uno::UNO_QUERY );
445 			OSL_ENSURE( xHome.is(), "### query to XInterface failed!" );
446 			if (xHome.is())
447 			{
448 				// interface
449 				::rtl::OUStringBuffer oid( 64 );
450 				oid.append( (sal_Int64)xHome.get(), 16 );
451 				oid.append( (sal_Unicode)';' );
452 				// ;environment[context]
453 				oid.append(
454                     *reinterpret_cast< ::rtl::OUString const * >(
455                         &((uno_Environment *) pEnv)->pTypeName ) );
456 				oid.append( (sal_Unicode)'[' );
457 				oid.append( (sal_Int64)((uno_Environment *)pEnv)->pContext, 16 );
458 				// ];good guid
459 				oid.append( cppu_cppenv_getStaticOIdPart() );
460 				::rtl::OUString aRet( oid.makeStringAndClear() );
461 				::rtl_uString_acquire( *ppOId = aRet.pData );
462 			}
463 		}
464 		catch (::com::sun::star::uno::RuntimeException &)
465 		{
466             OSL_ENSURE( 0, "### RuntimeException occurred udring queryInterface()!" );
467 		}
468 	}
469 }
470 //--------------------------------------------------------------------------------------------------
cppu_cppenv_acquireInterface(uno_ExtEnvironment *,void * pCppI)471 inline void SAL_CALL cppu_cppenv_acquireInterface( uno_ExtEnvironment *, void * pCppI ) SAL_THROW( () )
472 {
473 	reinterpret_cast< ::com::sun::star::uno::XInterface * >( pCppI )->acquire();
474 }
475 //--------------------------------------------------------------------------------------------------
cppu_cppenv_releaseInterface(uno_ExtEnvironment *,void * pCppI)476 inline void SAL_CALL cppu_cppenv_releaseInterface( uno_ExtEnvironment *, void * pCppI ) SAL_THROW( () )
477 {
478 	reinterpret_cast< ::com::sun::star::uno::XInterface * >( pCppI )->release();
479 }
480 //--------------------------------------------------------------------------------------------------
cppu_cppenv_environmentDisposing(uno_Environment *)481 inline void SAL_CALL cppu_cppenv_environmentDisposing( uno_Environment * ) SAL_THROW( () )
482 {
483 	g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
484 }
485 //--------------------------------------------------------------------------------------------------
cppu_cppenv_initEnvironment(uno_Environment * pCppEnv)486 inline void SAL_CALL cppu_cppenv_initEnvironment( uno_Environment * pCppEnv ) SAL_THROW( () )
487 {
488 	OSL_ENSURE( pCppEnv->pExtEnv, "### expected extended environment!" );
489 	OSL_ENSURE( ::rtl_ustr_ascii_compare( pCppEnv->pTypeName->buffer, CPPU_CURRENT_LANGUAGE_BINDING_NAME ) == 0, "### wrong environment type!" );
490     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
491 	((uno_ExtEnvironment *)pCppEnv)->computeObjectIdentifier = cppu_cppenv_computeObjectIdentifier;
492 	((uno_ExtEnvironment *)pCppEnv)->acquireInterface = cppu_cppenv_acquireInterface;
493 	((uno_ExtEnvironment *)pCppEnv)->releaseInterface = cppu_cppenv_releaseInterface;
494 	pCppEnv->environmentDisposing = cppu_cppenv_environmentDisposing;
495 }
496 
497 }
498 
499 #endif
500