Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / bridges / source / jni_uno / jni_bridge.h
blobea55a139158b0a95905cf786adb94cef667d6145
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <atomic>
25 #include <cstddef>
27 #include "jni_base.h"
28 #include "jni_helper.h"
30 #include <osl/diagnose.h>
32 #include <uno/mapping.h>
33 #include <uno/dispatcher.h>
35 #include <com/sun/star/uno/XInterface.hpp>
38 namespace jni_uno
41 class JNI_info;
42 struct Bridge;
44 struct Mapping : public uno_Mapping
46 Bridge * m_bridge;
49 // Holds environments and mappings:
50 struct Bridge
52 mutable std::atomic<std::size_t> m_ref;
54 uno_ExtEnvironment * m_uno_env;
55 uno_Environment * m_java_env;
57 Mapping m_java2uno;
58 Mapping m_uno2java;
59 bool m_registered_java2uno;
61 ~Bridge();
62 explicit Bridge(
63 uno_Environment * java_env, uno_ExtEnvironment * uno_env,
64 bool registered_java2uno );
66 void acquire() const;
67 void release() const;
69 // jni_data.cxx
70 void map_to_uno(
71 JNI_context const & jni,
72 void * uno_data, jvalue java_data,
73 typelib_TypeDescriptionReference * type,
74 JNI_type_info const * info /* maybe 0 */,
75 bool assign, bool out_param,
76 bool special_wrapped_integral_types = false ) const;
77 void map_to_java(
78 JNI_context const & jni,
79 jvalue * java_data, void const * uno_data,
80 typelib_TypeDescriptionReference * type,
81 JNI_type_info const * info /* maybe 0 */,
82 bool in_param, bool out_param,
83 bool special_wrapped_integral_types = false ) const;
85 // jni_uno2java.cxx
86 void handle_uno_exc(
87 JNI_context const & jni, uno_Any * uno_exc ) const;
88 void call_java(
89 jobject javaI,
90 typelib_InterfaceTypeDescription * iface_td,
91 sal_Int32 local_member_index, sal_Int32 function_pos_offset,
92 typelib_TypeDescriptionReference * return_type,
93 typelib_MethodParameter * params, sal_Int32 nParams,
94 void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const;
95 jobject map_to_java(
96 JNI_context const & jni,
97 uno_Interface * pUnoI, JNI_interface_type_info const * info ) const;
99 // jni_java2uno.cxx
100 void handle_java_exc(
101 JNI_context const & jni,
102 JLocalAutoRef const & jo_exc, uno_Any * uno_exc ) const;
103 jobject call_uno(
104 JNI_context const & jni,
105 uno_Interface * pUnoI, typelib_TypeDescription * member_td,
106 typelib_TypeDescriptionReference * return_tdref,
107 sal_Int32 nParams, typelib_MethodParameter const * pParams,
108 jobjectArray jo_args ) const;
109 uno_Interface * map_to_uno(
110 JNI_context const & jni,
111 jobject javaI, JNI_interface_type_info const * info ) const;
113 JNI_info const * getJniInfo() const;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */