1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #if ! defined INCLUDED_CLI_BASE_H
30 #define INCLUDED_CLI_BASE_H
33 // Workaround: osl/mutex.h contains only a forward declaration of _oslMutexImpls.
34 // When using the inline class in Mutex in osl/mutex.hxx, the loader needs to find
35 // a declaration for the struct. If not found a TypeLoadException is being thrown.
41 #include "rtl/ustring.hxx"
42 #include "typelib/typedescription.hxx"
47 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
51 System::Type
* loadCliType(System::String
* typeName
);
52 System::Type
* mapUnoType(typelib_TypeDescription
const * pTD
);
53 System::Type
* mapUnoType(typelib_TypeDescriptionReference
const * pTD
);
54 typelib_TypeDescriptionReference
* mapCliType(System::Type
* cliType
);
55 rtl::OUString
mapCliString(System::String
const * data
);
56 System::String
* mapUnoString(rtl_uString
const * data
);
57 System::String
* mapUnoTypeName(rtl_uString
const * typeName
);
61 static const System::String
* sXInterfaceName
= new System::String(
62 S
"unoidl.com.sun.star.uno.XInterface");
63 static const System::String
* sObject
= new System::String(S
"System.Object");
64 static const System::String
* sType
= new System::String(S
"System.Type");
65 static const System::String
* sUnoidl
= new System::String(S
"unoidl.");
66 static const System::String
* sVoid
= new System::String(S
"System.Void");
67 static const System::String
* sAny
= new System::String(S
"uno.Any");
68 static const System::String
* sArArray
= new System::String(S
"System.Array[]");
69 static const System::String
* sBoolean
= new System::String(S
"System.Boolean");
70 static const System::String
* sChar
= new System::String(S
"System.Char");
71 static const System::String
* sByte
= new System::String(S
"System.Byte");
72 static const System::String
* sInt16
= new System::String(S
"System.Int16");
73 static const System::String
* sUInt16
= new System::String(S
"System.UInt16");
74 static const System::String
* sInt32
= new System::String(S
"System.Int32");
75 static const System::String
* sUInt32
= new System::String(S
"System.UInt32");
76 static const System::String
* sInt64
= new System::String(S
"System.Int64");
77 static const System::String
* sUInt64
= new System::String(S
"System.UInt64");
78 static const System::String
* sString
= new System::String(S
"System.String");
79 static const System::String
* sSingle
= new System::String(S
"System.Single");
80 static const System::String
* sDouble
= new System::String(S
"System.Double");
81 static const System::String
* sArBoolean
= new System::String(S
"System.Boolean[]");
82 static const System::String
* sArChar
= new System::String(S
"System.Char[]");
83 static const System::String
* sArByte
= new System::String(S
"System.Byte[]");
84 static const System::String
* sArInt16
= new System::String(S
"System.Int16[]");
85 static const System::String
* sArUInt16
= new System::String(S
"System.UInt16[]");
86 static const System::String
* sArInt32
= new System::String(S
"System.Int32[]");
87 static const System::String
* sArUInt32
= new System::String(S
"System.UInt32[]");
88 static const System::String
* sArInt64
= new System::String(S
"System.Int64[]");
89 static const System::String
* sArUInt64
= new System::String(S
"System.UInt64[]");
90 static const System::String
* sArString
= new System::String(S
"System.String[]");
91 static const System::String
* sArSingle
= new System::String(S
"System.Single[]");
92 static const System::String
* sArDouble
= new System::String(S
"System.Double[]");
93 static const System::String
* sArType
= new System::String(S
"System.Type[]");
94 static const System::String
* sArObject
= new System::String(S
"System.Object[]");
95 static const System::String
* sBrackets
= new System::String(S
"[]");
96 static const System::String
* sAttributeSet
= new System::String(S
"set_");
97 static const System::String
* sAttributeGet
= new System::String(S
"get_");
99 static const System::String
* usXInterface
= S
"com.sun.star.uno.XInterface";
100 static const System::String
* usVoid
= S
"void";
101 static const System::String
* usType
= S
"type";
102 static const System::String
* usAny
= S
"any";
103 static const System::String
* usBrackets
= S
"[]";
104 static const System::String
* usBool
= S
"boolean";
105 static const System::String
* usByte
= S
"byte";
106 static const System::String
* usChar
= S
"char";
107 static const System::String
* usShort
= S
"short";
108 static const System::String
* usUShort
= S
"unsigned short";
109 static const System::String
* usLong
= S
"long";
110 static const System::String
* usULong
= S
"unsigned long";
111 static const System::String
* usHyper
= S
"hyper";
112 static const System::String
* usUHyper
= S
"unsigned hyper";
113 static const System::String
* usString
= S
"string";
114 static const System::String
* usFloat
= S
"float";
115 static const System::String
* usDouble
= S
"double";
118 struct BridgeRuntimeError
120 ::rtl::OUString m_message
;
122 inline BridgeRuntimeError( ::rtl::OUString
const & message
)
123 : m_message( message
)
127 //==================================================================================================
130 inline static void * operator new ( size_t nSize
)
131 { return rtl_allocateMemory( nSize
); }
132 inline static void operator delete ( void * mem
)
133 { if (mem
) rtl_freeMemory( mem
); }
134 inline static void * operator new ( size_t, void * mem
)
136 inline static void operator delete ( void *, void * )
139 static inline ::std::auto_ptr
< rtl_mem
> allocate( ::std::size_t bytes
);
141 //--------------------------------------------------------------------------------------------------
142 inline ::std::auto_ptr
< rtl_mem
> rtl_mem::allocate( ::std::size_t bytes
)
144 void * p
= rtl_allocateMemory( bytes
);
146 throw BridgeRuntimeError(OUSTR("out of memory!") );
147 return ::std::auto_ptr
< rtl_mem
>( (rtl_mem
*)p
);
150 //==================================================================================================
153 typelib_TypeDescription
* m_td
;
155 TypeDescr( TypeDescr
& ); // not impl
156 void operator = ( TypeDescr
); // not impl
159 inline explicit TypeDescr( typelib_TypeDescriptionReference
* td_ref
);
160 inline ~TypeDescr() SAL_THROW(())
161 { TYPELIB_DANGER_RELEASE( m_td
); }
163 inline typelib_TypeDescription
* get() const
167 inline TypeDescr::TypeDescr( typelib_TypeDescriptionReference
* td_ref
)
170 TYPELIB_DANGER_GET( &m_td
, td_ref
);
173 throw BridgeRuntimeError(
174 OUSTR("cannot get comprehensive type description for ") +
175 *reinterpret_cast< ::rtl::OUString
const * >( &td_ref
->pTypeName
) );
180 } //end namespace cli_uno
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */