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 : #ifndef INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_BRIDGE_HXX
21 : #define INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_BRIDGE_HXX
22 :
23 : #include "osl/interlck.h"
24 : #include "sal/types.h"
25 : #include "typelib/typedescription.h"
26 : #include "uno/environment.h"
27 : #include "uno/mapping.h"
28 :
29 : namespace bridges { namespace cpp_uno { namespace shared {
30 :
31 : // private:
32 : extern "C" typedef void SAL_CALL FreeMapping(uno_Mapping *);
33 : FreeMapping freeMapping;
34 :
35 : // private:
36 : extern "C"
37 : typedef void SAL_CALL AcquireMapping(uno_Mapping *);
38 : AcquireMapping acquireMapping;
39 :
40 : // private:
41 : extern "C"
42 : typedef void SAL_CALL ReleaseMapping(uno_Mapping *);
43 : ReleaseMapping releaseMapping;
44 :
45 : // private:
46 : extern "C" typedef void SAL_CALL Cpp2unoMapping(
47 : uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
48 : Cpp2unoMapping cpp2unoMapping;
49 :
50 : // private:
51 : extern "C" typedef void SAL_CALL Uno2cppMapping(
52 : uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
53 : Uno2cppMapping uno2cppMapping;
54 :
55 : /**
56 : * Holding environments and mappings.
57 : */
58 : class Bridge {
59 : public:
60 : // Interface for generic/component.cxx:
61 :
62 : static uno_Mapping * createMapping(
63 : uno_ExtEnvironment * pCppEnv, uno_ExtEnvironment * pUnoEnv,
64 : bool bExportCpp2Uno);
65 :
66 : // Interface for Cpp/UnoInterfaceProxy:
67 :
68 : void acquire();
69 : void release();
70 :
71 : // Interface for individual CPP--UNO bridges:
72 :
73 1595139 : uno_ExtEnvironment * getCppEnv() { return pCppEnv; }
74 1332209 : uno_ExtEnvironment * getUnoEnv() { return pUnoEnv; }
75 :
76 266202 : uno_Mapping * getCpp2Uno() { return &aCpp2Uno; }
77 363706 : uno_Mapping * getUno2Cpp() { return &aUno2Cpp; }
78 :
79 : private:
80 : Bridge(Bridge &) SAL_DELETED_FUNCTION;
81 : void operator =(const Bridge&) SAL_DELETED_FUNCTION;
82 :
83 : Bridge(
84 : uno_ExtEnvironment * pCppEnv_, uno_ExtEnvironment * pUnoEnv_,
85 : bool bExportCpp2Uno_);
86 :
87 : ~Bridge();
88 :
89 : struct Mapping: public uno_Mapping {
90 : Bridge * pBridge;
91 : };
92 :
93 : oslInterlockedCount nRef;
94 :
95 : uno_ExtEnvironment * pCppEnv;
96 : uno_ExtEnvironment * pUnoEnv;
97 :
98 : Mapping aCpp2Uno;
99 : Mapping aUno2Cpp;
100 :
101 : bool bExportCpp2Uno;
102 :
103 : friend void SAL_CALL freeMapping(uno_Mapping * pMapping);
104 :
105 : friend void SAL_CALL acquireMapping(uno_Mapping * pMapping);
106 :
107 : friend void SAL_CALL releaseMapping(uno_Mapping * pMapping);
108 :
109 : friend void SAL_CALL cpp2unoMapping(
110 : uno_Mapping * pMapping, void ** ppUnoI, void * pCppI,
111 : typelib_InterfaceTypeDescription * pTypeDescr);
112 :
113 : friend void SAL_CALL uno2cppMapping(
114 : uno_Mapping * pMapping, void ** ppCppI, void * pUnoI,
115 : typelib_InterfaceTypeDescription * pTypeDescr);
116 : };
117 :
118 : } } }
119 :
120 : #endif
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|