21#if !defined WIN32_LEAN_AND_MEAN
22# define WIN32_LEAN_AND_MEAN
25#include "uno/environment.hxx"
26#include "uno/lbnames.h"
27#include "uno/mapping.hxx"
28#include "typelib/typedescription.hxx"
29#include "rtl/ustring.hxx"
35namespace sri= System::Runtime::InteropServices;
59 void * pIn, typelib_InterfaceTypeDescription * td )
62 uno_Interface ** ppUnoI = (uno_Interface **)ppOut;
63 intptr_t cliI = (intptr_t)pIn;
65 OSL_ENSURE( ppUnoI && td,
"### null ptr!" );
69 uno_Interface * pUnoI = *(uno_Interface **)ppUnoI;
70 (*pUnoI->release)( pUnoI );
80 System::Object^ cliObj= sri::GCHandle::FromIntPtr(IntPtr(cliI)).Target;
87 SAL_WARN(
"cli",
"[cli_uno bridge error] " <<
err.m_message );
93 void * pIn, typelib_InterfaceTypeDescription * td )
98 OSL_ENSURE( td && ppOut,
"### null ptr!" );
99 OSL_ENSURE( (
sizeof(System::Char) ==
sizeof(
sal_Unicode))
100 && (
sizeof(System::Boolean) ==
sizeof(
sal_Bool))
101 && (
sizeof(System::SByte) ==
sizeof(
sal_Int8))
102 && (
sizeof(System::Int16) ==
sizeof(sal_Int16))
103 && (
sizeof(System::UInt16) ==
sizeof(sal_uInt16))
104 && (
sizeof(System::Int32) ==
sizeof(sal_Int32))
105 && (
sizeof(System::UInt32) ==
sizeof(sal_uInt32))
106 && (
sizeof(System::Int64) ==
sizeof(sal_Int64))
107 && (
sizeof(System::UInt64) ==
sizeof(sal_uInt64))
108 && (
sizeof(System::Single) ==
sizeof(
float))
109 && (
sizeof(System::Double) ==
sizeof(
double)),
110 "[cli_uno bridge] incompatible .NET data types");
111 intptr_t * ppDNetI = (intptr_t *)ppOut;
112 uno_Interface * pUnoI = (uno_Interface *)pIn;
119 sri::GCHandle::FromIntPtr(IntPtr(ppDNetI)).Free();
124 System::Object^ cliI= bridge->
map_uno2cli(pUnoI, td);
128 ptr= sri::GCHandle::ToIntPtr(sri::GCHandle::Alloc(cliI))
135 (*ppOut)=
reinterpret_cast<void*
>(ptr);
141 SAL_WARN(
"cli",
"[cli_uno bridge error] " <<
err.m_message );
171 if (1 == osl_atomic_increment( &
m_ref ))
190 if (! osl_atomic_decrement( &
m_ref ))
201 bool registered_cli2uno )
203 m_uno_env( uno_env ),
204 m_uno_cli_env( uno_cli_env ),
205 m_registered_cli2uno( registered_cli2uno )
244 uno_cli_env->pContext = 0;
258 uno_cli_env->pExtEnv = 0;
260#if OSL_DEBUG_LEVEL >= 1
261 System::Diagnostics::Trace::Listeners->
262 Add( gcnew System::Diagnostics::TextWriterTraceListener(System::Console::Out));
264 OSL_ASSERT( 0 == uno_cli_env->pContext );
279 OSL_ASSERT( 0 != ppMapping && 0 != pFrom && 0 != pTo );
282 (*(*ppMapping)->release)( *ppMapping );
287 OUString
const & from_env_typename = OUString::unacquired(
289 OUString
const & to_env_typename = OUString::unacquired( &pTo->pTypeName );
295 if ( from_env_typename == UNO_LB_CLI && to_env_typename == UNO_LB_UNO )
297 Bridge * bridge =
new Bridge( pFrom, pTo->pExtEnv,
true );
302 else if ( from_env_typename == UNO_LB_UNO && to_env_typename == UNO_LB_CLI )
304 Bridge * bridge =
new Bridge( pTo, pFrom->pExtEnv,
false );
313 SAL_WARN(
"cli",
"[cli_uno bridge error] " <<
err.m_message );
315 *ppMapping = mapping;
struct _uno_Environment uno_Environment
std::atomic< std::size_t > m_ref
void SAL_CALL uno_registerMapping(uno_Mapping **ppMapping, uno_freeMappingFunc freeMapping, uno_Environment *pFrom, uno_Environment *pTo, rtl_uString *pAddPurpose) SAL_THROW_EXTERN_C()
void SAL_CALL uno_revokeMapping(uno_Mapping *pMapping) SAL_THROW_EXTERN_C()
#define SAL_WARN(area, stream)
struct _uno_Mapping uno_Mapping
struct _typelib_TypeDescription typelib_TypeDescription
void SAL_CALL Mapping_acquire(uno_Mapping *mapping) SAL_THROW_EXTERN_C()
void SAL_CALL Mapping_release(uno_Mapping *mapping) SAL_THROW_EXTERN_C()
void SAL_CALL Mapping_uno2cli(uno_Mapping *mapping, void **ppOut, void *pIn, typelib_InterfaceTypeDescription *td) SAL_THROW_EXTERN_C()
void SAL_CALL Bridge_free(uno_Mapping *mapping) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_initEnvironment(uno_Environment *uno_cli_env) SAL_THROW_EXTERN_C()
void SAL_CALL Mapping_cli2uno(uno_Mapping *mapping, void **ppOut, void *pIn, typelib_InterfaceTypeDescription *td) SAL_THROW_EXTERN_C()
void SAL_CALL cli_env_disposing(uno_Environment *uno_cli_env) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping(uno_Mapping **ppMapping, uno_Environment *pFrom, uno_Environment *pTo) SAL_THROW_EXTERN_C()
An instance of Bridge represents exactly one mapping therefore either m_cli2uno or m_uno2cli is valid...
System::Object map_uno2cli(uno_Interface *pUnoI, typelib_InterfaceTypeDescription *pTD) const
oslInterlockedCount m_ref
uno_Environment * m_uno_cli_env
Bridge(uno_Environment *java_env, uno_ExtEnvironment *uno_env, bool registered_java2uno)
uno_ExtEnvironment * m_uno_env
uno_Interface * map_cli2uno(System::Object^ cliI, typelib_TypeDescription *pTD) const
void acquire() const
ToDo I doubt that the case that the ref count raises from 0 to 1 can occur.
bool m_registered_cli2uno
static Cli_environment g_cli_env
#define SAL_THROW_EXTERN_C()