22#include <com/sun/star/uno/Reference.hxx>
23#include <com/sun/star/uno/RuntimeException.hpp>
24#include <com/sun/star/uno/XInterface.hpp>
25#include <osl/mutex.hxx>
27#include <rtl/process.h>
28#include <rtl/ustrbuf.hxx>
29#include <rtl/ustring.h>
30#include <rtl/ustring.hxx>
33#include <uno/environment.h>
34#include <uno/lbnames.h>
35#include <uno/mapping.h>
41const OUString & cppu_cppenv_getStaticOIdPart()
43 static OUString s_aStaticOidPart = []() {
44 OUStringBuffer aRet(64);
48 ::rtl_getGlobalProcessId(ar);
49 for (
unsigned char i : ar)
51 aRet.append(
static_cast<sal_Int32
>(i), 16);
53 return aRet.makeStringAndClear();
55 return s_aStaticOidPart;
64 uno_ExtEnvironment * pEnv = va_arg(*pParam, uno_ExtEnvironment *);
65 rtl_uString ** ppOId = va_arg(*pParam, rtl_uString **);
66 void * pInterface = va_arg(*pParam,
void *);
69 assert(pEnv && ppOId && pInterface);
70 if (!(pEnv && ppOId && pInterface))
75 rtl_uString_release( *ppOId );
82 ::com::sun::star::uno::XInterface > xHome(
83 static_cast< ::com::sun::star::uno::XInterface *
>(
85 ::com::sun::star::uno::UNO_QUERY );
86 assert(xHome.is() &&
"### query to XInterface failed!");
91 OUString::number(
reinterpret_cast< sal_IntPtr
>(xHome.get()), 16 ) +
94 OUString::unacquired(&pEnv->aBase.pTypeName) +
96 OUString::number(
reinterpret_cast< sal_IntPtr
>(pEnv->aBase.pContext), 16 ) +
98 cppu_cppenv_getStaticOIdPart();
100 ::rtl_uString_acquire( *ppOId );
103 catch (const ::com::sun::star::uno::RuntimeException & e)
106 "### RuntimeException occurred during queryInterface(): "
112 uno_ExtEnvironment * pExtEnv, rtl_uString ** ppOId,
void * pInterface )
119 va_arg(*pParam, uno_ExtEnvironment *);
120 void * pCppI = va_arg(*pParam,
void *);
122 static_cast< ::com::sun::star::uno::XInterface *
>( pCppI )->acquire();
132 va_arg(*pParam, uno_ExtEnvironment *);
133 void * pCppI = va_arg(*pParam,
void *);
135 static_cast< ::com::sun::star::uno::XInterface *
>( pCppI )->release();
148#ifdef DISABLE_DYNLOADING
149#define uno_initEnvironment CPPU_ENV_uno_initEnvironment
155 assert(pCppEnv->pExtEnv);
157 ::rtl_ustr_ascii_compare_WithLength(
158 pCppEnv->pTypeName->buffer, rtl_str_getLength(CPPU_CURRENT_LANGUAGE_BINDING_NAME), CPPU_CURRENT_LANGUAGE_BINDING_NAME )
160 &&
"### wrong environment type!");
168#ifdef DISABLE_DYNLOADING
169#define uno_ext_getMapping CPPU_ENV_uno_ext_getMapping
176 assert(ppMapping && pFrom && pTo);
177 if (!(ppMapping && pFrom && pTo && pFrom->pExtEnv && pTo->pExtEnv))
185 if (rtl_ustr_ascii_compare(
186 from_envTypeName.pData->buffer,
187 CPPU_CURRENT_LANGUAGE_BINDING_NAME ) == 0 &&
188 rtl_ustr_ascii_compare(
189 to_envTypeName.pData->buffer, UNO_LB_UNO ) == 0)
193 pFrom->pExtEnv, pTo->pExtEnv,
true );
194 ::uno_registerMapping(
196 &pFrom->pExtEnv->aBase,
197 &pTo->pExtEnv->aBase,
nullptr );
199 else if (rtl_ustr_ascii_compare(
200 to_envTypeName.pData->buffer,
201 CPPU_CURRENT_LANGUAGE_BINDING_NAME ) == 0 &&
202 rtl_ustr_ascii_compare(
203 from_envTypeName.pData->buffer, UNO_LB_UNO ) == 0)
207 pTo->pExtEnv, pFrom->pExtEnv,
false );
208 ::uno_registerMapping(
210 &pFrom->pExtEnv->aBase,
211 &pTo->pExtEnv->aBase,
nullptr );
216 (*(*ppMapping)->release)( *ppMapping );
void SAL_CALL uno_Environment_invoke(uno_Environment *pEnv, uno_EnvCallee *pCallee,...) SAL_THROW_EXTERN_C()
static uno_Mapping * createMapping(uno_ExtEnvironment *pCppEnv, uno_ExtEnvironment *pUnoEnv, bool bExportCpp2Uno)
static void s_stub_computeObjectIdentifier(va_list *pParam)
static void environmentDisposing(SAL_UNUSED_PARAMETER uno_Environment *)
static void releaseInterface(uno_ExtEnvironment *pExtEnv, void *pCppI)
static void acquireInterface(uno_ExtEnvironment *pExtEnv, void *pCppI)
static void s_stub_releaseInterface(va_list *pParam)
static void s_stub_acquireInterface(va_list *pParam)
SAL_DLLPUBLIC_EXPORT void uno_initEnvironment(uno_Environment *pCppEnv) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC_EXPORT void uno_ext_getMapping(uno_Mapping **ppMapping, uno_Environment *pFrom, uno_Environment *pTo) SAL_THROW_EXTERN_C()
static void computeObjectIdentifier(uno_ExtEnvironment *pExtEnv, rtl_uString **ppOId, void *pInterface)
struct _uno_Environment uno_Environment
#define SAL_WARN(area, stream)
struct _uno_Mapping uno_Mapping
void freeMapping(uno_Mapping *pMapping)
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
#define SAL_THROW_EXTERN_C()