LCOV - code coverage report
Current view: top level - bridges/source/cpp_uno/shared - unointerfaceproxy.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 37 37 100.0 %
Date: 2015-06-13 12:38:46 Functions: 6 6 100.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/interlck.h"
      26             : #include "typelib/typedescription.h"
      27             : #include "uno/dispatcher.h"
      28             : 
      29             : namespace bridges { namespace cpp_uno { namespace shared {
      30             : 
      31      191839 : void freeUnoInterfaceProxy(uno_ExtEnvironment * pEnv, void * pProxy)
      32             : {
      33             :     UnoInterfaceProxy * pThis =
      34             :         static_cast< UnoInterfaceProxy * >(
      35      191839 :             static_cast< uno_Interface * >( pProxy ) );
      36      191839 :     if (pEnv != pThis->pBridge->getUnoEnv()) {
      37             :         assert(false);
      38             :     }
      39             : 
      40      191839 :     (*pThis->pBridge->getCppEnv()->revokeInterface)(
      41      191839 :         pThis->pBridge->getCppEnv(), pThis->pCppI );
      42      191839 :     pThis->pCppI->release();
      43      191839 :     ::typelib_typedescription_release(&pThis->pTypeDescr->aBase);
      44      191839 :     pThis->pBridge->release();
      45             : 
      46             : #if OSL_DEBUG_LEVEL > 1
      47             :     *(int *)pProxy = 0xdeadbabe;
      48             : #endif
      49      191839 :     delete pThis;
      50      191839 : }
      51             : 
      52     1353626 : void acquireProxy(uno_Interface * pUnoI)
      53             : {
      54     1353626 :     if (1 == osl_atomic_increment(
      55             :             & static_cast< UnoInterfaceProxy * >( pUnoI )->nRef ))
      56             :     {
      57             :         // rebirth of proxy zombie
      58             :         // register at uno env
      59             : #if OSL_DEBUG_LEVEL > 1
      60             :         void * pThis = pUnoI;
      61             : #endif
      62        5072 :         (*static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv()->
      63             :          registerProxyInterface)(
      64             :              static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv(),
      65             :              reinterpret_cast< void ** >( &pUnoI ), freeUnoInterfaceProxy,
      66             :              static_cast< UnoInterfaceProxy * >( pUnoI )->oid.pData,
      67        5072 :              static_cast< UnoInterfaceProxy * >( pUnoI )->pTypeDescr );
      68             : #if OSL_DEBUG_LEVEL > 1
      69             :         assert(pThis == pUnoI);
      70             : #endif
      71             :     }
      72     1353626 : }
      73             : 
      74     1545476 : void releaseProxy(uno_Interface * pUnoI)
      75             : {
      76     1545476 :     if (! osl_atomic_decrement(
      77             :             & static_cast< UnoInterfaceProxy * >( pUnoI )->nRef ))
      78             :     {
      79             :         // revoke from uno env on last release
      80      197201 :         (*static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv()->
      81             :          revokeInterface)(
      82             :              static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv(),
      83      197201 :              pUnoI );
      84             :     }
      85     1545476 : }
      86             : 
      87      192495 : UnoInterfaceProxy * UnoInterfaceProxy::create(
      88             :     bridges::cpp_uno::shared::Bridge * pBridge,
      89             :     com::sun::star::uno::XInterface * pCppI,
      90             :     typelib_InterfaceTypeDescription * pTypeDescr,
      91             :     OUString const & rOId)
      92             : {
      93      192495 :     return new UnoInterfaceProxy(pBridge, pCppI, pTypeDescr, rOId);
      94             : }
      95             : 
      96      192495 : UnoInterfaceProxy::UnoInterfaceProxy(
      97             :     bridges::cpp_uno::shared::Bridge * pBridge_,
      98             :     com::sun::star::uno::XInterface * pCppI_,
      99             :     typelib_InterfaceTypeDescription * pTypeDescr_, OUString const & rOId_)
     100             :     : nRef( 1 )
     101             :     , pBridge( pBridge_ )
     102             :     , pCppI( pCppI_ )
     103             :     , pTypeDescr( pTypeDescr_ )
     104      192495 :     , oid( rOId_ )
     105             : {
     106      192495 :     pBridge->acquire();
     107      192495 :     ::typelib_typedescription_acquire(&pTypeDescr->aBase);
     108      192495 :     if (!pTypeDescr->aBase.bComplete)
     109             :         ::typelib_typedescription_complete(
     110        2026 :             reinterpret_cast<typelib_TypeDescription **>(&pTypeDescr));
     111             :     assert(pTypeDescr->aBase.bComplete);
     112      192495 :     pCppI->acquire();
     113      192495 :     (*pBridge->getCppEnv()->registerInterface)(
     114             :         pBridge->getCppEnv(), reinterpret_cast< void ** >( &pCppI ), oid.pData,
     115      192495 :         pTypeDescr );
     116             : 
     117             :     // uno_Interface
     118      192495 :     acquire = acquireProxy;
     119      192495 :     release = releaseProxy;
     120      192495 :     pDispatcher = unoInterfaceProxyDispatch;
     121      192495 : }
     122             : 
     123      191839 : UnoInterfaceProxy::~UnoInterfaceProxy()
     124      191839 : {}
     125             : 
     126             : } } }
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11