1*129fa3d1SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*129fa3d1SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*129fa3d1SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*129fa3d1SAndrew Rist * distributed with this work for additional information 6*129fa3d1SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*129fa3d1SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*129fa3d1SAndrew Rist * "License"); you may not use this file except in compliance 9*129fa3d1SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*129fa3d1SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*129fa3d1SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*129fa3d1SAndrew Rist * software distributed under the License is distributed on an 15*129fa3d1SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*129fa3d1SAndrew Rist * KIND, either express or implied. See the License for the 17*129fa3d1SAndrew Rist * specific language governing permissions and limitations 18*129fa3d1SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*129fa3d1SAndrew Rist *************************************************************/ 21*129fa3d1SAndrew Rist 22*129fa3d1SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_cppu.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "cppu/helper/purpenv/Environment.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "osl/diagnose.h" 30cdf0e10cSrcweir #include "uno/lbnames.h" 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include "typelib/typedescription.h" 33cdf0e10cSrcweir #include "osl/interlck.h" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #ifdef debug 36cdf0e10cSrcweir # define LOG_LIFECYCLE_cppu_helper_purpenv_Base 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir 39cdf0e10cSrcweir #ifdef LOG_LIFECYCLE_cppu_helper_purpenv_Base 40cdf0e10cSrcweir # include <iostream> 41cdf0e10cSrcweir # define LOG_LIFECYCLE_cppu_helper_purpenv_Base_emit(x) x 42cdf0e10cSrcweir 43cdf0e10cSrcweir #else 44cdf0e10cSrcweir # define LOG_LIFECYCLE_cppu_helper_purpenv_Base_emit(x) 45cdf0e10cSrcweir 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir 48cdf0e10cSrcweir 49cdf0e10cSrcweir extern "C" { 50cdf0e10cSrcweir typedef void SAL_CALL EnvFun_P (uno_Environment *); 51cdf0e10cSrcweir typedef void SAL_CALL EnvFun_PP_P(uno_Environment ** ppHardEnv, uno_Environment *); 52cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_registerProxyInterface (uno_ExtEnvironment *, 53cdf0e10cSrcweir void ** ppProxy, 54cdf0e10cSrcweir uno_freeProxyFunc freeProxy, 55cdf0e10cSrcweir rtl_uString * pOId, 56cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr); 57cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_revokeInterface (uno_ExtEnvironment *, 58cdf0e10cSrcweir void * pInterface); 59cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_getObjectIdentifier (uno_ExtEnvironment *, 60cdf0e10cSrcweir rtl_uString **, 61cdf0e10cSrcweir void *); 62cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_getRegisteredInterface (uno_ExtEnvironment *, 63cdf0e10cSrcweir void **, 64cdf0e10cSrcweir rtl_uString *, 65cdf0e10cSrcweir typelib_InterfaceTypeDescription *); 66cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_getRegisteredInterfaces(uno_ExtEnvironment *, 67cdf0e10cSrcweir void *** pppInterfaces, 68cdf0e10cSrcweir sal_Int32 * pnLen, 69cdf0e10cSrcweir uno_memAlloc memAlloc); 70cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_computeObjectIdentifier(uno_ExtEnvironment *, 71cdf0e10cSrcweir rtl_uString ** ppOId, 72cdf0e10cSrcweir void * pInterface); 73cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_acquireInterface (uno_ExtEnvironment *, 74cdf0e10cSrcweir void * pInterface); 75cdf0e10cSrcweir typedef void SAL_CALL ExtEnv_releaseInterface (uno_ExtEnvironment *, 76cdf0e10cSrcweir void * pInterface); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir class Base : public cppu::Enterable 80cdf0e10cSrcweir { 81cdf0e10cSrcweir public: 82cdf0e10cSrcweir explicit Base(uno_Environment * pEnv, cppu::Enterable * pEnterable); 83cdf0e10cSrcweir 84cdf0e10cSrcweir void acquireWeak(void); 85cdf0e10cSrcweir void releaseWeak(void); 86cdf0e10cSrcweir void harden (uno_Environment ** ppHardEnv); 87cdf0e10cSrcweir void acquire (void); 88cdf0e10cSrcweir void release (void); 89cdf0e10cSrcweir 90cdf0e10cSrcweir void registerProxyInterface (void ** ppProxy, 91cdf0e10cSrcweir uno_freeProxyFunc freeProxy, 92cdf0e10cSrcweir rtl::OUString const & oid, 93cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr); 94cdf0e10cSrcweir void revokeInterface (void * pInterface); 95cdf0e10cSrcweir void getObjectIdentifier (void * pInterface, 96cdf0e10cSrcweir rtl::OUString * pOid); 97cdf0e10cSrcweir void getRegisteredInterface (void **, 98cdf0e10cSrcweir rtl::OUString const & oid, 99cdf0e10cSrcweir typelib_InterfaceTypeDescription *); 100cdf0e10cSrcweir void getRegisteredInterfaces(void ***, 101cdf0e10cSrcweir sal_Int32 * pnLen, 102cdf0e10cSrcweir uno_memAlloc memAlloc); 103cdf0e10cSrcweir void computeObjectIdentifier(void * pInterface, 104cdf0e10cSrcweir rtl::OUString * pOid); 105cdf0e10cSrcweir void acquireInterface (void * pInterface); 106cdf0e10cSrcweir void releaseInterface (void * pInterface); 107cdf0e10cSrcweir 108cdf0e10cSrcweir virtual void v_enter (void); 109cdf0e10cSrcweir virtual void v_leave (void); 110cdf0e10cSrcweir virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam); 111cdf0e10cSrcweir virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam); 112cdf0e10cSrcweir virtual int v_isValid (rtl::OUString * pReason); 113cdf0e10cSrcweir 114cdf0e10cSrcweir protected: 115cdf0e10cSrcweir oslInterlockedCount m_nRef; 116cdf0e10cSrcweir uno_Environment * m_pEnv; 117cdf0e10cSrcweir cppu::Enterable * m_pEnterable; 118cdf0e10cSrcweir 119cdf0e10cSrcweir EnvFun_P * m_env_acquire; 120cdf0e10cSrcweir EnvFun_P * m_env_release; 121cdf0e10cSrcweir EnvFun_PP_P * m_env_harden; 122cdf0e10cSrcweir EnvFun_P * m_env_acquireWeak; 123cdf0e10cSrcweir EnvFun_P * m_env_releaseWeak; 124cdf0e10cSrcweir 125cdf0e10cSrcweir ExtEnv_registerProxyInterface * m_env_registerProxyInterface; 126cdf0e10cSrcweir ExtEnv_revokeInterface * m_env_revokeInterface; 127cdf0e10cSrcweir ExtEnv_getObjectIdentifier * m_env_getObjectIdentifier; 128cdf0e10cSrcweir ExtEnv_getRegisteredInterface * m_env_getRegisteredInterface; 129cdf0e10cSrcweir ExtEnv_getRegisteredInterfaces * m_env_getRegisteredInterfaces; 130cdf0e10cSrcweir ExtEnv_computeObjectIdentifier * m_env_computeObjectIdentifier; 131cdf0e10cSrcweir ExtEnv_acquireInterface * m_env_acquireInterface; 132cdf0e10cSrcweir ExtEnv_releaseInterface * m_env_releaseInterface; 133cdf0e10cSrcweir 134cdf0e10cSrcweir virtual ~Base(); 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir 137cdf0e10cSrcweir extern "C" { 138cdf0e10cSrcweir static void SAL_CALL s_acquire(uno_Environment * pEnv) //SAL_THROW_EXTERN_C() 139cdf0e10cSrcweir { 140cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pEnv->pReserved); 141cdf0e10cSrcweir pBase->acquire(); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir static void SAL_CALL s_release(uno_Environment * pEnv) SAL_THROW_EXTERN_C() 145cdf0e10cSrcweir { 146cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pEnv->pReserved); 147cdf0e10cSrcweir pBase->release(); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir static void SAL_CALL s_harden(uno_Environment ** ppHardEnv, uno_Environment * pEnv) SAL_THROW_EXTERN_C() 151cdf0e10cSrcweir { 152cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pEnv->pReserved); 153cdf0e10cSrcweir pBase->harden(ppHardEnv); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir static void SAL_CALL s_acquireWeak(uno_Environment * pEnv) SAL_THROW_EXTERN_C() 157cdf0e10cSrcweir { 158cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pEnv->pReserved); 159cdf0e10cSrcweir pBase->acquireWeak(); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir static void SAL_CALL s_releaseWeak(uno_Environment * pEnv) SAL_THROW_EXTERN_C() 163cdf0e10cSrcweir { 164cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pEnv->pReserved); 165cdf0e10cSrcweir pBase->releaseWeak(); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir 169cdf0e10cSrcweir static void SAL_CALL s_registerProxyInterface(uno_ExtEnvironment * pExtEnv, 170cdf0e10cSrcweir void ** ppProxy, 171cdf0e10cSrcweir uno_freeProxyFunc freeProxy, 172cdf0e10cSrcweir rtl_uString * pOId, 173cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 176cdf0e10cSrcweir pBase->registerProxyInterface(ppProxy, freeProxy, pOId, pTypeDescr); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir static void SAL_CALL s_revokeInterface(uno_ExtEnvironment * pExtEnv, void * pInterface) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 182cdf0e10cSrcweir pBase->revokeInterface(pInterface); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir static void SAL_CALL s_getObjectIdentifier(uno_ExtEnvironment * pExtEnv, 186cdf0e10cSrcweir rtl_uString ** ppOId, 187cdf0e10cSrcweir void * pInterface) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 190cdf0e10cSrcweir pBase->getObjectIdentifier(pInterface, reinterpret_cast<rtl::OUString *>(ppOId)); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir static void SAL_CALL s_getRegisteredInterface(uno_ExtEnvironment * pExtEnv, 194cdf0e10cSrcweir void ** ppInterface, 195cdf0e10cSrcweir rtl_uString * pOId, 196cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 199cdf0e10cSrcweir pBase->getRegisteredInterface(ppInterface, pOId, pTypeDescr); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir static void SAL_CALL s_getRegisteredInterfaces(uno_ExtEnvironment * pExtEnv, 203cdf0e10cSrcweir void *** pppInterface, 204cdf0e10cSrcweir sal_Int32 * pnLen, 205cdf0e10cSrcweir uno_memAlloc memAlloc) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 208cdf0e10cSrcweir pBase->getRegisteredInterfaces(pppInterface, pnLen, memAlloc); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir static void SAL_CALL s_computeObjectIdentifier(uno_ExtEnvironment * pExtEnv, 212cdf0e10cSrcweir rtl_uString ** ppOId, 213cdf0e10cSrcweir void * pInterface) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 216cdf0e10cSrcweir pBase->computeObjectIdentifier(pInterface, reinterpret_cast<rtl::OUString *>(ppOId)); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir static void SAL_CALL s_acquireInterface(uno_ExtEnvironment * pExtEnv, void * pInterface) { 220cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 221cdf0e10cSrcweir pBase->acquireInterface(pInterface); 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir static void SAL_CALL s_releaseInterface(uno_ExtEnvironment * pExtEnv, void * pInterface) { 225cdf0e10cSrcweir Base * pBase = static_cast<Base *>(pExtEnv->aBase.pReserved); 226cdf0e10cSrcweir pBase->releaseInterface(pInterface); 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir Base::Base(uno_Environment * pEnv, cppu::Enterable * pEnterable) 232cdf0e10cSrcweir :m_nRef(1), 233cdf0e10cSrcweir m_pEnv(pEnv), 234cdf0e10cSrcweir m_pEnterable (pEnterable), 235cdf0e10cSrcweir m_env_acquire (pEnv->acquire), 236cdf0e10cSrcweir m_env_release (pEnv->release), 237cdf0e10cSrcweir m_env_harden (pEnv->harden), 238cdf0e10cSrcweir m_env_acquireWeak(pEnv->acquireWeak), 239cdf0e10cSrcweir m_env_releaseWeak(pEnv->releaseWeak), 240cdf0e10cSrcweir m_env_registerProxyInterface (pEnv->pExtEnv->registerProxyInterface), 241cdf0e10cSrcweir m_env_revokeInterface (pEnv->pExtEnv->revokeInterface), 242cdf0e10cSrcweir m_env_getObjectIdentifier (pEnv->pExtEnv->getObjectIdentifier), 243cdf0e10cSrcweir m_env_getRegisteredInterface (pEnv->pExtEnv->getRegisteredInterface), 244cdf0e10cSrcweir m_env_getRegisteredInterfaces(pEnv->pExtEnv->getRegisteredInterfaces), 245cdf0e10cSrcweir m_env_computeObjectIdentifier(pEnv->pExtEnv->computeObjectIdentifier), 246cdf0e10cSrcweir m_env_acquireInterface (pEnv->pExtEnv->acquireInterface), 247cdf0e10cSrcweir m_env_releaseInterface (pEnv->pExtEnv->releaseInterface) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir LOG_LIFECYCLE_cppu_helper_purpenv_Base_emit(fprintf(stderr, "LIFE: %s -> %p\n", "cppu::helper::purpenv::Base::Base(uno_Environment * pEnv)", this)); 250cdf0e10cSrcweir OSL_ENSURE( 251cdf0e10cSrcweir rtl_ustr_ascii_compare_WithLength(pEnv->pTypeName->buffer, rtl_str_getLength(UNO_LB_UNO), UNO_LB_UNO) 252cdf0e10cSrcweir == 0, 253cdf0e10cSrcweir "### wrong environment type!"); 254cdf0e10cSrcweir 255cdf0e10cSrcweir pEnv->acquire = s_acquire; 256cdf0e10cSrcweir pEnv->release = s_release; 257cdf0e10cSrcweir pEnv->harden = s_harden; 258cdf0e10cSrcweir pEnv->acquireWeak = s_acquireWeak; 259cdf0e10cSrcweir pEnv->releaseWeak = s_releaseWeak; 260cdf0e10cSrcweir 261cdf0e10cSrcweir pEnv->pExtEnv->registerProxyInterface = s_registerProxyInterface; 262cdf0e10cSrcweir pEnv->pExtEnv->revokeInterface = s_revokeInterface; 263cdf0e10cSrcweir pEnv->pExtEnv->getObjectIdentifier = s_getObjectIdentifier; 264cdf0e10cSrcweir pEnv->pExtEnv->getRegisteredInterface = s_getRegisteredInterface; 265cdf0e10cSrcweir pEnv->pExtEnv->getRegisteredInterfaces = s_getRegisteredInterfaces; 266cdf0e10cSrcweir pEnv->pExtEnv->computeObjectIdentifier = s_computeObjectIdentifier; 267cdf0e10cSrcweir pEnv->pExtEnv->acquireInterface = s_acquireInterface; 268cdf0e10cSrcweir pEnv->pExtEnv->releaseInterface = s_releaseInterface; 269cdf0e10cSrcweir 270cdf0e10cSrcweir pEnv->pReserved = this; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir Base::~Base() 274cdf0e10cSrcweir { 275cdf0e10cSrcweir LOG_LIFECYCLE_cppu_helper_purpenv_Base_emit(fprintf(stderr, "LIFE: %s -> %p\n", "cppu::helper::purpenv::Base::~Base()", this)); 276cdf0e10cSrcweir 277cdf0e10cSrcweir m_pEnv->acquire = m_env_acquire; 278cdf0e10cSrcweir m_pEnv->release = m_env_release; 279cdf0e10cSrcweir m_pEnv->harden = m_env_harden; 280cdf0e10cSrcweir m_pEnv->acquireWeak = m_env_acquireWeak; 281cdf0e10cSrcweir m_pEnv->releaseWeak = m_env_releaseWeak; 282cdf0e10cSrcweir 283cdf0e10cSrcweir m_pEnv->pReserved = NULL; 284cdf0e10cSrcweir 285cdf0e10cSrcweir delete m_pEnterable; 286cdf0e10cSrcweir m_pEnv->release(m_pEnv); 287cdf0e10cSrcweir } 288cdf0e10cSrcweir 289cdf0e10cSrcweir void Base::acquire(void) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir m_env_acquire(m_pEnv); 292cdf0e10cSrcweir 293cdf0e10cSrcweir osl_incrementInterlockedCount(&m_nRef); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir void Base::release(void) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir if (osl_decrementInterlockedCount(&m_nRef) == 0) 299cdf0e10cSrcweir delete this; 300cdf0e10cSrcweir 301cdf0e10cSrcweir else 302cdf0e10cSrcweir m_env_release(m_pEnv); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir void Base::harden(uno_Environment ** ppHardEnv) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir m_env_harden(ppHardEnv, m_pEnv); 308cdf0e10cSrcweir osl_incrementInterlockedCount(&m_nRef); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir void Base::acquireWeak(void) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir m_env_acquireWeak(m_pEnv); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir void Base::releaseWeak(void) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir m_env_releaseWeak(m_pEnv); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir 322cdf0e10cSrcweir extern "C" { static void s_registerProxyInterface_v(va_list * pParam) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 325cdf0e10cSrcweir void ** ppProxy = va_arg(*pParam, void **); 326cdf0e10cSrcweir uno_freeProxyFunc freeProxy = va_arg(*pParam, uno_freeProxyFunc); 327cdf0e10cSrcweir rtl_uString * pOId = va_arg(*pParam, rtl_uString *); 328cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr = va_arg(*pParam, typelib_InterfaceTypeDescription *); 329cdf0e10cSrcweir ExtEnv_registerProxyInterface * pRegisterProxyInterface 330cdf0e10cSrcweir = va_arg(*pParam, ExtEnv_registerProxyInterface *); 331cdf0e10cSrcweir 332cdf0e10cSrcweir pRegisterProxyInterface(pExtEnv, ppProxy, freeProxy, pOId, pTypeDescr); 333cdf0e10cSrcweir }} 334cdf0e10cSrcweir 335cdf0e10cSrcweir void Base::registerProxyInterface(void ** ppProxy, 336cdf0e10cSrcweir uno_freeProxyFunc freeProxy, 337cdf0e10cSrcweir rtl::OUString const & oid, 338cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, 341cdf0e10cSrcweir s_registerProxyInterface_v, 342cdf0e10cSrcweir m_pEnv->pExtEnv, 343cdf0e10cSrcweir ppProxy, 344cdf0e10cSrcweir freeProxy, 345cdf0e10cSrcweir oid.pData, 346cdf0e10cSrcweir pTypeDescr, 347cdf0e10cSrcweir m_env_registerProxyInterface); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir 351cdf0e10cSrcweir extern "C" { static void s_revokeInterface_v(va_list * pParam) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 354cdf0e10cSrcweir void * pInterface = va_arg(*pParam, void *); 355cdf0e10cSrcweir ExtEnv_revokeInterface * pRevokeInterface = va_arg(*pParam, ExtEnv_revokeInterface *); 356cdf0e10cSrcweir 357cdf0e10cSrcweir pRevokeInterface(pExtEnv, pInterface); 358cdf0e10cSrcweir }} 359cdf0e10cSrcweir 360cdf0e10cSrcweir void Base::revokeInterface(void * pInterface) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, 363cdf0e10cSrcweir s_revokeInterface_v, 364cdf0e10cSrcweir m_pEnv->pExtEnv, 365cdf0e10cSrcweir pInterface, 366cdf0e10cSrcweir m_env_revokeInterface); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir 370cdf0e10cSrcweir extern "C" { static void s_getObjectIdentifier_v(va_list * pParam) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 373cdf0e10cSrcweir void * pInterface = va_arg(*pParam, void *); 374cdf0e10cSrcweir rtl::OUString * pOId = va_arg(*pParam, rtl::OUString *); 375cdf0e10cSrcweir ExtEnv_getObjectIdentifier * pGetObjectIdentifier 376cdf0e10cSrcweir = va_arg(*pParam, ExtEnv_getObjectIdentifier *); 377cdf0e10cSrcweir 378cdf0e10cSrcweir pGetObjectIdentifier(pExtEnv, reinterpret_cast<rtl_uString **>(pOId), pInterface); 379cdf0e10cSrcweir }} 380cdf0e10cSrcweir 381cdf0e10cSrcweir void Base::getObjectIdentifier(void * pInterface, rtl::OUString * pOid) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, 384cdf0e10cSrcweir s_getObjectIdentifier_v, 385cdf0e10cSrcweir m_pEnv->pExtEnv, 386cdf0e10cSrcweir pInterface, 387cdf0e10cSrcweir pOid, 388cdf0e10cSrcweir m_env_getObjectIdentifier); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir 392cdf0e10cSrcweir extern "C" { static void s_getRegisteredInterface_v(va_list * pParam) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 395cdf0e10cSrcweir void ** ppInterface = va_arg(*pParam, void **); 396cdf0e10cSrcweir rtl_uString * pOId = va_arg(*pParam, rtl_uString *); 397cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr = va_arg(*pParam, typelib_InterfaceTypeDescription *); 398cdf0e10cSrcweir ExtEnv_getRegisteredInterface * pGetRegisteredInterface 399cdf0e10cSrcweir = va_arg(*pParam, ExtEnv_getRegisteredInterface *); 400cdf0e10cSrcweir 401cdf0e10cSrcweir pGetRegisteredInterface(pExtEnv, ppInterface, pOId, pTypeDescr); 402cdf0e10cSrcweir }} 403cdf0e10cSrcweir 404cdf0e10cSrcweir void Base::getRegisteredInterface(void ** ppInterface, 405cdf0e10cSrcweir rtl::OUString const & oid, 406cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, 409cdf0e10cSrcweir s_getRegisteredInterface_v, 410cdf0e10cSrcweir m_pEnv->pExtEnv, 411cdf0e10cSrcweir ppInterface, 412cdf0e10cSrcweir oid.pData, 413cdf0e10cSrcweir pTypeDescr, 414cdf0e10cSrcweir m_env_getRegisteredInterface); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir 417cdf0e10cSrcweir 418cdf0e10cSrcweir extern "C" { static void s_getRegisteredInterfaces_v(va_list * pParam) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 421cdf0e10cSrcweir void *** pppInterface = va_arg(*pParam, void ***); 422cdf0e10cSrcweir sal_Int32 * pnLen = va_arg(*pParam, sal_Int32 *); 423cdf0e10cSrcweir uno_memAlloc memAlloc = va_arg(*pParam, uno_memAlloc); 424cdf0e10cSrcweir ExtEnv_getRegisteredInterfaces * pGetRegisteredInterfaces 425cdf0e10cSrcweir = va_arg(*pParam, ExtEnv_getRegisteredInterfaces *); 426cdf0e10cSrcweir 427cdf0e10cSrcweir pGetRegisteredInterfaces(pExtEnv, pppInterface, pnLen, memAlloc); 428cdf0e10cSrcweir }} 429cdf0e10cSrcweir 430cdf0e10cSrcweir void Base::getRegisteredInterfaces(void *** pppInterface, 431cdf0e10cSrcweir sal_Int32 * pnLen, 432cdf0e10cSrcweir uno_memAlloc memAlloc) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, 435cdf0e10cSrcweir s_getRegisteredInterfaces_v, 436cdf0e10cSrcweir m_pEnv->pExtEnv, 437cdf0e10cSrcweir pppInterface, 438cdf0e10cSrcweir pnLen, 439cdf0e10cSrcweir memAlloc, 440cdf0e10cSrcweir m_env_getRegisteredInterfaces); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir 444cdf0e10cSrcweir extern "C" { static void s_computeObjectIdentifier_v(va_list * pParam) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 447cdf0e10cSrcweir void * pInterface = va_arg(*pParam, void *); 448cdf0e10cSrcweir rtl::OUString * pOId = va_arg(*pParam, rtl::OUString *); 449cdf0e10cSrcweir ExtEnv_computeObjectIdentifier * pComputeObjectIdentifier 450cdf0e10cSrcweir = va_arg(*pParam, ExtEnv_computeObjectIdentifier *); 451cdf0e10cSrcweir 452cdf0e10cSrcweir pComputeObjectIdentifier(pExtEnv, reinterpret_cast<rtl_uString **>(pOId), pInterface); 453cdf0e10cSrcweir }} 454cdf0e10cSrcweir 455cdf0e10cSrcweir void Base::computeObjectIdentifier(void * pInterface, rtl::OUString * pOid) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, 458cdf0e10cSrcweir s_computeObjectIdentifier_v, 459cdf0e10cSrcweir m_pEnv->pExtEnv, 460cdf0e10cSrcweir pInterface, 461cdf0e10cSrcweir pOid, 462cdf0e10cSrcweir m_env_computeObjectIdentifier); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir 466cdf0e10cSrcweir extern "C" { static void s_acquireInterface_v(va_list * pParam) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 469cdf0e10cSrcweir void * pInterface = va_arg(*pParam, void *); 470cdf0e10cSrcweir ExtEnv_acquireInterface * pAcquireInterface 471cdf0e10cSrcweir = va_arg(*pParam, ExtEnv_acquireInterface *); 472cdf0e10cSrcweir 473cdf0e10cSrcweir pAcquireInterface(pExtEnv, pInterface); 474cdf0e10cSrcweir }} 475cdf0e10cSrcweir 476cdf0e10cSrcweir void Base::acquireInterface(void * pInterface) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, s_acquireInterface_v, m_pEnv->pExtEnv, pInterface, m_env_acquireInterface); 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir 482cdf0e10cSrcweir extern "C" { static void s_releaseInterface_v(va_list * pParam) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir uno_ExtEnvironment * pExtEnv = va_arg(*pParam, uno_ExtEnvironment *); 485cdf0e10cSrcweir void * pInterface = va_arg(*pParam, void *); 486cdf0e10cSrcweir ExtEnv_releaseInterface * pReleaseInterface 487cdf0e10cSrcweir = va_arg(*pParam, ExtEnv_releaseInterface *); 488cdf0e10cSrcweir 489cdf0e10cSrcweir pReleaseInterface(pExtEnv, pInterface); 490cdf0e10cSrcweir }} 491cdf0e10cSrcweir 492cdf0e10cSrcweir void Base::releaseInterface(void * pInterface) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir uno_Environment_invoke(m_pEnv, 495cdf0e10cSrcweir s_releaseInterface_v, 496cdf0e10cSrcweir m_pEnv->pExtEnv, 497cdf0e10cSrcweir pInterface, 498cdf0e10cSrcweir m_env_releaseInterface); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir 501cdf0e10cSrcweir void Base::v_enter(void) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir m_pEnterable->enter(); 504cdf0e10cSrcweir } 505cdf0e10cSrcweir 506cdf0e10cSrcweir void Base::v_leave(void) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir m_pEnterable->leave(); 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir void Base::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir m_pEnterable->callInto_v(pCallee, pParam); 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir void Base::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir m_pEnterable->callOut_v(pCallee, pParam); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir 521cdf0e10cSrcweir int Base::v_isValid(rtl::OUString * pReason) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir return m_pEnterable->isValid(pReason); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir namespace cppu { namespace helper { namespace purpenv { 527cdf0e10cSrcweir 528cdf0e10cSrcweir void Environment_initWithEnterable(uno_Environment * pEnvironment, cppu::Enterable * pEnterable) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir new Base(pEnvironment, pEnterable); 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir }}} 534