LibreOffice Module bridges (master) 1
jni_bridge.h
Go to the documentation of this file.
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 "jni_base.h"
28#include "jni_helper.h"
29
30#include <osl/diagnose.h>
31
32#include <uno/mapping.h>
33#include <uno/dispatcher.h>
34
35#include <com/sun/star/uno/XInterface.hpp>
36
37
38namespace jni_uno
39{
40
41class JNI_info;
42struct Bridge;
43
44struct Mapping : public uno_Mapping
45{
47};
48
49// Holds environments and mappings:
50struct Bridge
51{
52 mutable std::atomic<std::size_t> m_ref;
53
54 uno_ExtEnvironment * m_uno_env;
56
60
61 ~Bridge();
62 explicit Bridge(
63 uno_Environment * java_env, uno_ExtEnvironment * uno_env,
64 bool registered_java2uno );
65
66 void acquire() const;
67 void release() const;
68
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;
84
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;
98
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;
112
113 JNI_info const * getJniInfo() const;
114};
115
116}
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _uno_Environment uno_Environment
struct _uno_Mapping uno_Mapping
Definition: msvc/except.hxx:33
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:53
struct _uno_Any uno_Any
Definition: msvc/except.hxx:32
void map_to_java(JNI_context const &jni, jvalue *java_data, void const *uno_data, typelib_TypeDescriptionReference *type, JNI_type_info const *info, bool in_param, bool out_param, bool special_wrapped_integral_types=false) const
Definition: jni_data.cxx:1155
Mapping m_uno2java
Definition: jni_bridge.h:58
void release() const
Definition: jni_bridge.cxx:217
void map_to_uno(JNI_context const &jni, void *uno_data, jvalue java_data, typelib_TypeDescriptionReference *type, JNI_type_info const *info, bool assign, bool out_param, bool special_wrapped_integral_types=false) const
Definition: jni_data.cxx:211
void call_java(jobject javaI, typelib_InterfaceTypeDescription *iface_td, sal_Int32 local_member_index, sal_Int32 function_pos_offset, typelib_TypeDescriptionReference *return_type, typelib_MethodParameter *params, sal_Int32 nParams, void *uno_ret, void *uno_args[], uno_Any **uno_exc) const
uno_ExtEnvironment * m_uno_env
Definition: jni_bridge.h:54
bool m_registered_java2uno
Definition: jni_bridge.h:59
Bridge(uno_Environment *java_env, uno_ExtEnvironment *uno_env, bool registered_java2uno)
Definition: jni_bridge.cxx:229
JNI_info const * getJniInfo() const
Definition: jni_bridge.cxx:270
void handle_java_exc(JNI_context const &jni, JLocalAutoRef const &jo_exc, uno_Any *uno_exc) const
void handle_uno_exc(JNI_context const &jni, uno_Any *uno_exc) const
std::atomic< std::size_t > m_ref
Definition: jni_bridge.h:52
void acquire() const
Definition: jni_bridge.cxx:195
jobject call_uno(JNI_context const &jni, uno_Interface *pUnoI, typelib_TypeDescription *member_td, typelib_TypeDescriptionReference *return_tdref, sal_Int32 nParams, typelib_MethodParameter const *pParams, jobjectArray jo_args) const
Mapping m_java2uno
Definition: jni_bridge.h:57
uno_Environment * m_java_env
Definition: jni_bridge.h:55
Bridge * m_bridge
Definition: jni_bridge.h:46