24 #include <unordered_map>
29 #include <rtl/ref.hxx>
30 #include <rtl/ustring.hxx>
31 #include <rtl/strbuf.hxx>
33 #include <uno/environment.h>
34 #include <typelib/typedescription.hxx>
36 #include <com/sun/star/uno/Type.hxx>
38 namespace jvmaccess {
class UnoVirtualMachine; }
44 typelib_TypeDescriptionReference * type1,
45 typelib_TypeDescriptionReference * type2 )
49 OUString
const & name1 =
50 OUString::unacquired( &type1->pTypeName );
51 OUString
const & name2 =
52 OUString::unacquired( &type2->pTypeName );
53 return ((type1->eTypeClass == type2->eTypeClass) && name1 == name2);
58 return ((typelib_TypeClass_INTERFACE == type->eTypeClass) &&
59 OUString::unacquired( &type->pTypeName ) ==
"com.sun.star.uno.XInterface");
67 ::com::sun::star::uno::TypeDescription
m_td;
70 virtual void destroy( JNIEnv * jni_env ) = 0;
73 { jni_env->DeleteGlobalRef( m_class ); }
86 virtual void destroy( JNIEnv * jni_env )
override;
102 virtual void destroy( JNIEnv * jni_env )
override;
120 typedef std::unordered_map<
216 typelib_TypeDescriptionReference * type )
const;
219 OUString
const & uno_name )
const;
221 OStringBuffer * buf, typelib_TypeDescriptionReference * type,
222 bool use_Object_for_type_XInterface =
true,
bool use_slashes =
true );
227 inline void destroy( JNIEnv * jni_env );
235 JNI_info( JNIEnv * jni_env, jobject class_loader,
236 jclass classClass, jmethodID methodForName );
247 OStringBuffer * buf, typelib_TypeDescriptionReference * type,
248 bool use_Object_for_type_XInterface,
bool use_slashes )
250 switch (type->eTypeClass)
252 case typelib_TypeClass_VOID:
255 case typelib_TypeClass_CHAR:
258 case typelib_TypeClass_BOOLEAN:
261 case typelib_TypeClass_BYTE:
264 case typelib_TypeClass_SHORT:
265 case typelib_TypeClass_UNSIGNED_SHORT:
268 case typelib_TypeClass_LONG:
269 case typelib_TypeClass_UNSIGNED_LONG:
272 case typelib_TypeClass_HYPER:
273 case typelib_TypeClass_UNSIGNED_HYPER:
276 case typelib_TypeClass_FLOAT:
279 case typelib_TypeClass_DOUBLE:
282 case typelib_TypeClass_STRING:
284 buf->append(
"Ljava/lang/String;" );
286 buf->append(
"Ljava.lang.String;" );
289 case typelib_TypeClass_TYPE:
291 buf->append(
"Lcom/sun/star/uno/Type;" );
293 buf->append(
"Lcom.sun.star.uno.Type;" );
296 case typelib_TypeClass_ANY:
298 buf->append(
"Ljava/lang/Object;" );
300 buf->append(
"Ljava.lang.Object;" );
303 case typelib_TypeClass_ENUM:
304 case typelib_TypeClass_STRUCT:
305 case typelib_TypeClass_EXCEPTION:
307 OUString
const & uno_name =
308 OUString::unacquired( &type->pTypeName );
311 sal_Int32
i = uno_name.indexOf(
'<' );
315 use_slashes ? uno_name.replace(
'.',
'/' ) : uno_name,
316 RTL_TEXTENCODING_JAVA_UTF8 ) );
318 OUString s( uno_name.copy( 0, i ) );
321 use_slashes ? s.replace(
'.',
'/' ) : s,
322 RTL_TEXTENCODING_JAVA_UTF8 ) );
327 case typelib_TypeClass_SEQUENCE:
332 buf, reinterpret_cast<typelib_IndirectTypeDescription *>(td.
get())->pType,
333 use_Object_for_type_XInterface, use_slashes );
336 case typelib_TypeClass_INTERFACE:
340 buf->append(
"Ljava/lang/Object;" );
342 buf->append(
"Ljava.lang.Object;" );
347 OUString
const & uno_name =
348 OUString::unacquired( &type->pTypeName );
352 use_slashes ? uno_name.replace(
'.',
'/' ) : uno_name,
353 RTL_TEXTENCODING_JAVA_UTF8 ) );
359 "unsupported type: " +
360 OUString::unacquired( &type->pTypeName ) );
jmethodID m_method_Object_toString
jobject m_object_Type_UNSIGNED_LONG
jmethodID m_method_Double_doubleValue
jmethodID m_ctor_Any_with_Type_Object
::com::sun::star::uno::Type const & m_Exception_type
JNI_compound_type_info(JNI_context const &jni, typelib_TypeDescription *td)
jfieldID m_field_JNI_proxy_m_receiver_handle
jobject m_object_Type_UNSIGNED_HYPER
jclass m_class_AsynchronousFinalizer
jclass m_class_UnoRuntime
virtual void destroy(JNIEnv *jni_env) override
::com::sun::star::uno::TypeDescription m_XInterface_queryInterface_td
jobject m_object_Any_VOID
jmethodID m_ctor_AsynchronousFinalizer
JNI_type_info const * create_type_info(JNI_context const &jni, typelib_TypeDescription *td) const
const JNI_type_info & operator=(const JNI_type_info &)=delete
jmethodID m_ctor_Long_with_long
jmethodID m_method_UnoRuntime_generateOid
static void append_sig(OStringBuffer *buf, typelib_TypeDescriptionReference *type, bool use_Object_for_type_XInterface=true, bool use_slashes=true)
jmethodID m_method_Boolean_booleanValue
jmethodID m_ctor_Float_with_float
virtual ~JNI_compound_type_info() override
jmethodID m_method_TypeClass_fromInt
std::unique_ptr< jmethodID[]> m_methods
jmethodID m_ctor_Character_with_char
jmethodID m_method_Byte_byteValue
jmethodID m_method_Class_forName
jmethodID m_ctor_Double_with_double
jmethodID m_ctor_Type_with_Class
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::unique_ptr< jfieldID[]> m_fields
jmethodID m_method_JNI_proxy_create
jfieldID m_field_JNI_proxy_m_type
JNI_interface_type_info(JNI_context const &jni, typelib_TypeDescription *td)
jfieldID m_field_Any_object
jfieldID m_field_Type_typeName
void destroy(JNIEnv *jni_env)
JNI_type_info(const JNI_type_info &)=delete
jfieldID m_field_JNI_proxy_m_td_handle
jmethodID m_method_IEnvironment_getRegisteredInterface
jobject m_object_java_env
jmethodID m_ctor_Short_with_short
JNI_interface_type_info const * m_XInterface_type_info
jfieldID m_field_Any_type
jmethodID m_ctor_Byte_with_byte
jmethodID m_ctor_Type_with_Name_TypeClass
jmethodID m_method_Long_longValue
struct _typelib_TypeDescription typelib_TypeDescription
JNI_type_info const * get_type_info(JNI_context const &jni, typelib_TypeDescription *type) const
::com::sun::star::uno::TypeDescription m_td
void destruct(JNIEnv *jni_env)
jmethodID m_method_Float_floatValue
const JNI_info & operator=(const JNI_info &)=delete
jclass m_class_RuntimeException
jmethodID m_method_Character_charValue
jmethodID m_method_UnoRuntime_queryInterface
::com::sun::star::uno::Type const & m_RuntimeException_type
jmethodID m_method_IEnvironment_registerInterface
jmethodID m_method_Integer_intValue
jfieldID m_field_Enum_m_value
typelib_TypeDescription * get() const
std::unordered_map< OUString, JNI_type_info_holder > t_str2type
virtual void destroy(JNIEnv *jni_env) override
static JNI_info const * get_jni_info(rtl::Reference< jvmaccess::UnoVirtualMachine > const &uno_vm)
jmethodID m_method_AsynchronousFinalizer_drain
::com::sun::star::uno::Type const & m_void_type
virtual ~JNI_interface_type_info() override
const JNI_type_info_holder & operator=(const JNI_type_info_holder &)=delete
jmethodID m_ctor_Integer_with_int
jmethodID m_method_Class_getName
jobject m_object_Type_UNSIGNED_SHORT
jmethodID m_ctor_Boolean_with_boolean
bool type_equals(typelib_TypeDescriptionReference *type1, typelib_TypeDescriptionReference *type2)
bool is_XInterface(typelib_TypeDescriptionReference *type)
JNI_info(const JNI_info &)=delete
jmethodID m_method_Short_shortValue
jmethodID m_method_JNI_proxy_get_proxy_ctor
JNI_type_info const * m_base
void destruct(JNIEnv *jni_env)
jfieldID m_field_JNI_proxy_m_oid
virtual void destroy(JNIEnv *jni_env)=0
jmethodID m_method_Throwable_getMessage