Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/bridges/inc/bridge.hxx
Line
Count
Source
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
#pragma once
21
22
#include <sal/config.h>
23
24
#include <atomic>
25
#include <cstddef>
26
27
#include <sal/types.h>
28
#include <typelib/typedescription.h>
29
#include <uno/environment.h>
30
#include <uno/mapping.h>
31
32
namespace bridges::cpp_uno::shared {
33
34
// private:
35
extern "C" void freeMapping(uno_Mapping *);
36
37
// private:
38
extern "C" void acquireMapping(uno_Mapping *);
39
40
// private:
41
extern "C" void releaseMapping(uno_Mapping *);
42
43
// private:
44
extern "C" void cpp2unoMapping(
45
    uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
46
47
// private:
48
extern "C" void uno2cppMapping(
49
    uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
50
51
/**
52
 * Holding environments and mappings.
53
 */
54
class Bridge {
55
public:
56
    // Interface for generic/component.cxx:
57
58
    static uno_Mapping * createMapping(
59
        uno_ExtEnvironment * pCppEnv, uno_ExtEnvironment * pUnoEnv,
60
        bool bExportCpp2Uno);
61
62
    // Interface for Cpp/UnoInterfaceProxy:
63
64
    void acquire();
65
    void release();
66
67
    // Interface for individual CPP--UNO bridges:
68
69
368k
    uno_ExtEnvironment * getCppEnv() { return pCppEnv; }
70
276k
    uno_ExtEnvironment * getUnoEnv() { return pUnoEnv; }
71
72
39.6k
    uno_Mapping * getCpp2Uno() { return &aCpp2Uno; }
73
75.1k
    uno_Mapping * getUno2Cpp() { return &aUno2Cpp; }
74
75
private:
76
    Bridge(Bridge const &) = delete;
77
    Bridge& operator =(const Bridge&) = delete;
78
79
    Bridge(
80
        uno_ExtEnvironment * pCppEnv_, uno_ExtEnvironment * pUnoEnv_,
81
        bool bExportCpp2Uno_);
82
83
    ~Bridge();
84
85
    struct Mapping: public uno_Mapping {
86
        Bridge * pBridge;
87
    };
88
89
    std::atomic<std::size_t> nRef;
90
91
    uno_ExtEnvironment * pCppEnv;
92
    uno_ExtEnvironment * pUnoEnv;
93
94
    Mapping aCpp2Uno;
95
    Mapping aUno2Cpp;
96
97
    bool bExportCpp2Uno;
98
99
    friend void freeMapping(uno_Mapping * pMapping);
100
101
    friend void acquireMapping(uno_Mapping * pMapping);
102
103
    friend void releaseMapping(uno_Mapping * pMapping);
104
105
    friend void cpp2unoMapping(
106
        uno_Mapping * pMapping, void ** ppUnoI, void * pCppI,
107
        typelib_InterfaceTypeDescription * pTypeDescr);
108
109
    friend void uno2cppMapping(
110
        uno_Mapping * pMapping, void ** ppCppI, void * pUnoI,
111
        typelib_InterfaceTypeDescription * pTypeDescr);
112
};
113
114
}
115
116
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */