1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #include "IdentityMapping.hxx"
30 #include "uno/mapping.h"
31 #include "uno/environment.hxx"
33 #include "osl/interlck.h"
36 using namespace ::com::sun::star
;
38 struct IdentityMapping
: public uno_Mapping
41 uno::Environment m_env
;
43 IdentityMapping(uno::Environment
const & rEnv
);
49 static void SAL_CALL
s_free(uno_Mapping
* pMapping
) SAL_THROW(())
51 delete static_cast<IdentityMapping
*>(pMapping
);
54 static void SAL_CALL
s_acquire(uno_Mapping
* pMapping
) SAL_THROW(())
56 static rtl::OUString s_purpose
;
58 if (1 == ::osl_incrementInterlockedCount(&static_cast<IdentityMapping
*>(pMapping
)->m_nRef
))
63 static_cast<IdentityMapping
*>(pMapping
)->m_env
.get(),
64 static_cast<IdentityMapping
*>(pMapping
)->m_env
.get(),
69 static void SAL_CALL
s_release(uno_Mapping
* pMapping
) SAL_THROW(())
71 if (!::osl_decrementInterlockedCount(&static_cast<IdentityMapping
*>(pMapping
)->m_nRef
))
72 uno_revokeMapping(pMapping
);
75 static void SAL_CALL
s_mapInterface(uno_Mapping
* pMapping
,
78 struct _typelib_InterfaceTypeDescription
* /*pInterfaceTypeDescr*/)
85 IdentityMapping
* that
= static_cast<IdentityMapping
*>(pMapping
);
87 (that
->m_env
.get()->pExtEnv
->acquireInterface
)(that
->m_env
.get()->pExtEnv
, pInterface
);
93 IdentityMapping::IdentityMapping(uno::Environment
const & rEnv
)
97 uno_Mapping::acquire
= s_acquire
;
98 uno_Mapping::release
= s_release
;
99 uno_Mapping::mapInterface
= s_mapInterface
;
103 uno_Mapping
* createIdentityMapping(uno::Environment
const & rEnv
) SAL_THROW(())
105 return new IdentityMapping(rEnv
);