Bump version to 24.04.3.4
[LibreOffice.git] / cli_ure / source / uno_bridge / cli_base.h
blobbca780f7c66122a522a118d0625876451c5d2501
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 #ifndef INCLUDED_CLI_URE_SOURCE_UNO_BRIDGE_CLI_BASE_H
21 #define INCLUDED_CLI_URE_SOURCE_UNO_BRIDGE_CLI_BASE_H
23 #pragma unmanaged
24 // Workaround: osl/mutex.h contains only a forward declaration of _oslMutexImpls.
25 // When using the inline class in Mutex in osl/mutex.hxx, the loader needs to find
26 // a declaration for the struct. If not found a TypeLoadException is being thrown.
27 struct _oslMutexImpl
30 #pragma managed
31 #include <memory>
32 #include "rtl/ustring.hxx"
33 #include "typelib/typedescription.hxx"
35 #using <system.dll>
37 namespace cli_uno
39 System::Type^ loadCliType(System::String ^ typeName);
40 System::Type^ mapUnoType(typelib_TypeDescription const * pTD);
41 System::Type^ mapUnoType(typelib_TypeDescriptionReference const * pTD);
42 typelib_TypeDescriptionReference* mapCliType(System::Type^ cliType);
43 OUString mapCliString(System::String ^ data);
44 System::String^ mapUnoString(rtl_uString const * data);
45 System::String^ mapUnoTypeName(rtl_uString const * typeName);
47 ref struct Constants
49 static System::String^ sXInterfaceName= gcnew System::String(
50 "unoidl.com.sun.star.uno.XInterface");
51 static System::String^ sObject= gcnew System::String("System.Object");
52 static System::String^ sType= gcnew System::String("System.Type");
53 static System::String^ sUnoidl= gcnew System::String("unoidl.");
54 static System::String^ sVoid= gcnew System::String("System.Void");
55 static System::String^ sAny= gcnew System::String("uno.Any");
56 static System::String^ sArArray= gcnew System::String("System.Array[]");
57 static System::String^ sBoolean= gcnew System::String("System.Boolean");
58 static System::String^ sChar= gcnew System::String("System.Char");
59 static System::String^ sByte= gcnew System::String("System.Byte");
60 static System::String^ sInt16= gcnew System::String("System.Int16");
61 static System::String^ sUInt16= gcnew System::String("System.UInt16");
62 static System::String^ sInt32= gcnew System::String("System.Int32");
63 static System::String^ sUInt32= gcnew System::String("System.UInt32");
64 static System::String^ sInt64= gcnew System::String("System.Int64");
65 static System::String^ sUInt64= gcnew System::String("System.UInt64");
66 static System::String^ sString= gcnew System::String("System.String");
67 static System::String^ sSingle= gcnew System::String("System.Single");
68 static System::String^ sDouble= gcnew System::String("System.Double");
69 static System::String^ sArBoolean= gcnew System::String("System.Boolean[]");
70 static System::String^ sArChar= gcnew System::String("System.Char[]");
71 static System::String^ sArByte= gcnew System::String("System.Byte[]");
72 static System::String^ sArInt16= gcnew System::String("System.Int16[]");
73 static System::String^ sArUInt16= gcnew System::String("System.UInt16[]");
74 static System::String^ sArInt32= gcnew System::String("System.Int32[]");
75 static System::String^ sArUInt32= gcnew System::String("System.UInt32[]");
76 static System::String^ sArInt64= gcnew System::String("System.Int64[]");
77 static System::String^ sArUInt64= gcnew System::String("System.UInt64[]");
78 static System::String^ sArString= gcnew System::String("System.String[]");
79 static System::String^ sArSingle= gcnew System::String("System.Single[]");
80 static System::String^ sArDouble= gcnew System::String("System.Double[]");
81 static System::String^ sArType= gcnew System::String("System.Type[]");
82 static System::String^ sArObject= gcnew System::String("System.Object[]");
83 static System::String^ sBrackets= gcnew System::String("[]");
84 static System::String^ sAttributeSet= gcnew System::String("set_");
85 static System::String^ sAttributeGet= gcnew System::String("get_");
87 static System::String^ usXInterface = "com.sun.star.uno.XInterface";
88 static System::String^ usVoid = "void";
89 static System::String^ usType = "type";
90 static System::String^ usAny = "any";
91 static System::String^ usBrackets = "[]";
92 static System::String^ usBool = "boolean";
93 static System::String^ usByte = "byte";
94 static System::String^ usChar = "char";
95 static System::String^ usShort = "short";
96 static System::String^ usUShort = "unsigned short";
97 static System::String^ usLong = "long";
98 static System::String^ usULong = "unsigned long";
99 static System::String^ usHyper = "hyper";
100 static System::String^ usUHyper = "unsigned hyper";
101 static System::String^ usString = "string";
102 static System::String^ usFloat = "float";
103 static System::String^ usDouble = "double";
106 struct BridgeRuntimeError
108 OUString m_message;
110 inline BridgeRuntimeError( OUString const & message )
111 : m_message( message )
116 struct rtl_mem
118 inline static void * operator new ( size_t nSize )
119 { return std::malloc( nSize ); }
120 inline static void operator delete ( void * mem )
121 { std::free( mem ); }
122 inline static void * operator new ( size_t, void * mem )
123 { return mem; }
124 inline static void operator delete ( void *, void * )
127 static inline std::unique_ptr< rtl_mem > allocate( std::size_t bytes );
130 inline std::unique_ptr< rtl_mem > rtl_mem::allocate( std::size_t bytes )
132 void * p = std::malloc( bytes );
133 if (0 == p)
134 throw BridgeRuntimeError("out of memory!" );
135 return std::unique_ptr< rtl_mem >( (rtl_mem *)p );
139 class TypeDescr
141 typelib_TypeDescription * m_td;
143 TypeDescr( TypeDescr const & ) = delete;
144 TypeDescr& operator = ( TypeDescr const & ) = delete;
146 public:
147 inline explicit TypeDescr( typelib_TypeDescriptionReference * td_ref );
148 inline ~TypeDescr()
149 { TYPELIB_DANGER_RELEASE( m_td ); }
151 inline typelib_TypeDescription * get() const
152 { return m_td; }
155 inline TypeDescr::TypeDescr( typelib_TypeDescriptionReference * td_ref )
156 : m_td( 0 )
158 TYPELIB_DANGER_GET( &m_td, td_ref );
159 if (0 == m_td)
161 throw BridgeRuntimeError(
162 "cannot get comprehensive type description for " +
163 OUString::unacquired(&td_ref->pTypeName) );
168 } //end namespace cli_uno
169 #endif
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */