LCOV - code coverage report
Current view: top level - bridges/source/cpp_uno/shared - unointerfaceproxy.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
      21             : 
      22             : #include "bridges/cpp_uno/shared/bridge.hxx"
      23             : 
      24             : #include "com/sun/star/uno/XInterface.hpp"
      25             : #include "osl/diagnose.h"
      26             : #include "osl/interlck.h"
      27             : #include "typelib/typedescription.h"
      28             : #include "uno/dispatcher.h"
      29             : 
      30             : namespace bridges { namespace cpp_uno { namespace shared {
      31             : 
      32           0 : void freeUnoInterfaceProxy(uno_ExtEnvironment * pEnv, void * pProxy)
      33             : {
      34             :     UnoInterfaceProxy * pThis =
      35             :         static_cast< UnoInterfaceProxy * >(
      36           0 :             reinterpret_cast< uno_Interface * >( pProxy ) );
      37           0 :     if (pEnv != pThis->pBridge->getUnoEnv()) {
      38             :         OSL_ASSERT(false);
      39             :     }
      40             : 
      41           0 :     (*pThis->pBridge->getCppEnv()->revokeInterface)(
      42           0 :         pThis->pBridge->getCppEnv(), pThis->pCppI );
      43           0 :     pThis->pCppI->release();
      44             :     ::typelib_typedescription_release(
      45           0 :         (typelib_TypeDescription *)pThis->pTypeDescr );
      46           0 :     pThis->pBridge->release();
      47             : 
      48             : #if OSL_DEBUG_LEVEL > 1
      49             :     *(int *)pProxy = 0xdeadbabe;
      50             : #endif
      51           0 :     delete pThis;
      52           0 : }
      53             : 
      54           0 : void acquireProxy(uno_Interface * pUnoI)
      55             : {
      56           0 :     if (1 == osl_atomic_increment(
      57             :             & static_cast< UnoInterfaceProxy * >( pUnoI )->nRef ))
      58             :     {
      59             :         // rebirth of proxy zombie
      60             :         // register at uno env
      61             : #if OSL_DEBUG_LEVEL > 1
      62             :         void * pThis = pUnoI;
      63             : #endif
      64           0 :         (*static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv()->
      65             :          registerProxyInterface)(
      66             :              static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv(),
      67             :              reinterpret_cast< void ** >( &pUnoI ), freeUnoInterfaceProxy,
      68             :              static_cast< UnoInterfaceProxy * >( pUnoI )->oid.pData,
      69           0 :              static_cast< UnoInterfaceProxy * >( pUnoI )->pTypeDescr );
      70             : #if OSL_DEBUG_LEVEL > 1
      71             :         OSL_ASSERT( pThis == pUnoI );
      72             : #endif
      73             :     }
      74           0 : }
      75             : 
      76           0 : void releaseProxy(uno_Interface * pUnoI)
      77             : {
      78           0 :     if (! osl_atomic_decrement(
      79             :             & static_cast< UnoInterfaceProxy * >( pUnoI )->nRef ))
      80             :     {
      81             :         // revoke from uno env on last release
      82           0 :         (*static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv()->
      83             :          revokeInterface)(
      84             :              static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv(),
      85           0 :              pUnoI );
      86             :     }
      87           0 : }
      88             : 
      89           0 : UnoInterfaceProxy * UnoInterfaceProxy::create(
      90             :     bridges::cpp_uno::shared::Bridge * pBridge,
      91             :     com::sun::star::uno::XInterface * pCppI,
      92             :     typelib_InterfaceTypeDescription * pTypeDescr,
      93             :     OUString const & rOId) SAL_THROW(())
      94             : {
      95           0 :     return new UnoInterfaceProxy(pBridge, pCppI, pTypeDescr, rOId);
      96             : }
      97             : 
      98           0 : UnoInterfaceProxy::UnoInterfaceProxy(
      99             :     bridges::cpp_uno::shared::Bridge * pBridge_,
     100             :     com::sun::star::uno::XInterface * pCppI_,
     101             :     typelib_InterfaceTypeDescription * pTypeDescr_, OUString const & rOId_)
     102             :     SAL_THROW(())
     103             :     : nRef( 1 )
     104             :     , pBridge( pBridge_ )
     105             :     , pCppI( pCppI_ )
     106             :     , pTypeDescr( pTypeDescr_ )
     107           0 :     , oid( rOId_ )
     108             : {
     109           0 :     pBridge->acquire();
     110           0 :     ::typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr );
     111           0 :     if (! ((typelib_TypeDescription *)pTypeDescr)->bComplete)
     112             :         ::typelib_typedescription_complete(
     113           0 :             (typelib_TypeDescription **)&pTypeDescr );
     114             :     OSL_ENSURE(
     115             :         ((typelib_TypeDescription *)pTypeDescr)->bComplete,
     116             :         "### type is incomplete!" );
     117           0 :     pCppI->acquire();
     118           0 :     (*pBridge->getCppEnv()->registerInterface)(
     119             :         pBridge->getCppEnv(), reinterpret_cast< void ** >( &pCppI ), oid.pData,
     120           0 :         pTypeDescr );
     121             : 
     122             :     // uno_Interface
     123           0 :     acquire = acquireProxy;
     124           0 :     release = releaseProxy;
     125           0 :     pDispatcher = unoInterfaceProxyDispatch;
     126           0 : }
     127             : 
     128           0 : UnoInterfaceProxy::~UnoInterfaceProxy()
     129           0 : {}
     130             : 
     131             : } } }
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10