1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 warning(push, 1)
27 #include "rtl/ustring.hxx"
28 #include "rtl/ustrbuf.hxx"
29 #include "uno/sequence2.h"
30 #include "typelib/typedescription.hxx"
31 #include "cli_proxy.h"
33 #include "cli_bridge.h"
35 #using <cli_uretypes.dll>
40 namespace sri
= System::Runtime::InteropServices
;
41 namespace sr
= System::Reflection
;
42 namespace st
= System::Text
;
43 namespace ucss
= unoidl::com::sun::star
;
51 System::String
^ mapUnoPolymorphicName(System::String
^ unoName
);
52 OUString
mapCliTypeName(System::String
^ typeName
);
53 System::String
^ mapCliPolymorphicName(System::String
^ unoName
);
54 System::String
^ mapPolymorphicName(System::String
^ unoName
, bool bCliToUno
);
56 inline auto_ptr
< rtl_mem
> seq_allocate( sal_Int32 nElements
, sal_Int32 nSize
)
58 auto_ptr
< rtl_mem
> seq(
59 rtl_mem::allocate( SAL_SEQUENCE_HEADER_SIZE
+ (nElements
* nSize
) ) );
60 uno_Sequence
* p
= (uno_Sequence
*)seq
.get();
62 p
->nElements
= nElements
;
67 System::Object
^ Bridge::map_uno2cli(uno_Interface
* pUnoI
, typelib_InterfaceTypeDescription
*pTD
) const
69 System::Object
^ retVal
= nullptr;
71 rtl_uString
* pOid
= 0;
72 (*m_uno_env
->getObjectIdentifier
)( m_uno_env
, &pOid
, pUnoI
);
73 OSL_ASSERT( 0 != pOid
);
74 OUString
oid(pOid
, SAL_NO_ACQUIRE
);
76 //see if the interface was already mapped
77 System::Type
^ ifaceType
= mapUnoType(reinterpret_cast<typelib_TypeDescription
*>(pTD
));
78 System::String
^ sOid
= mapUnoString(oid
.pData
);
80 System::Threading::Monitor::Enter( CliEnvHolder::g_cli_env
);
83 retVal
= CliEnvHolder::g_cli_env
->getRegisteredInterface(sOid
, ifaceType
);
86 // There is already an registered object. It can either be a proxy
87 // for the UNO object or a real cli object. In the first case we
88 // tell the proxy that it shall also represent the current UNO
89 // interface. If it already does that, then it does nothing
90 if (srr::RemotingServices::IsTransparentProxy(retVal
))
92 UnoInterfaceProxy
^ p
= static_cast<UnoInterfaceProxy
^>(
93 srr::RemotingServices::GetRealProxy(retVal
));
94 p
->addUnoInterface(pUnoI
, pTD
);
99 retVal
= UnoInterfaceProxy::create(
100 (Bridge
*) this, pUnoI
, pTD
, oid
);
105 System::Threading::Monitor::Exit( CliEnvHolder::g_cli_env
);
111 uno_Interface
* Bridge::map_cli2uno(System::Object
^ cliObj
, typelib_TypeDescription
*pTD
) const
113 uno_Interface
* retIface
= NULL
;
114 // get oid from dot net environment
115 System::String
^ ds_oid
= CliEnvHolder::g_cli_env
->getObjectIdentifier( cliObj
);
116 OUString ousOid
= mapCliString(ds_oid
);
117 // look if interface is already mapped
118 m_uno_env
->getRegisteredInterface(m_uno_env
, (void**) &retIface
, ousOid
.pData
,
119 (typelib_InterfaceTypeDescription
*) pTD
);
122 System::Threading::Monitor::Enter(Cli_environment::typeid);
125 m_uno_env
->getRegisteredInterface(m_uno_env
, (void**) &retIface
, ousOid
.pData
,
126 (typelib_InterfaceTypeDescription
*) pTD
);
129 retIface
= CliProxy::create((Bridge
*)this, cliObj
, pTD
, ousOid
);
134 System::Threading::Monitor::Exit(Cli_environment::typeid);
140 inline System::Type
^ loadCliType(rtl_uString
* unoName
)
142 return loadCliType(mapUnoTypeName(unoName
));
145 System::Type
^ loadCliType(System::String
^ unoName
)
147 System::Type
^ retVal
= nullptr;
150 //If unoName denotes a polymorphic type, e.g com.sun.star.beans.Defaulted<System.Char>
151 //then we remove the type list, otherwise the type could not be loaded.
152 bool bIsPolymorphic
= false;
154 System::String
^ loadName
= unoName
;
155 int index
= unoName
->IndexOf('<');
158 loadName
= unoName
->Substring(0, index
);
159 bIsPolymorphic
= true;
161 System::AppDomain
^ currentDomain
= System::AppDomain::CurrentDomain
;
162 array
<sr::Assembly
^>^ assems
= currentDomain
->GetAssemblies();
163 for (int i
= 0; i
< assems
->Length
; i
++)
165 retVal
= assems
[i
]->GetType(loadName
, false);
170 if (retVal
== nullptr)
172 System::String
^ msg
= gcnew
System::String("A type could not be loaded: ");
173 msg
= System::String::Concat(msg
, loadName
);
174 throw BridgeRuntimeError(mapCliString(msg
));
179 retVal
= uno::PolymorphicType::GetType(retVal
, unoName
);
182 catch( System::Exception
^ e
)
184 OUString
ouMessage(mapCliString(e
->Message
));
185 throw BridgeRuntimeError(ouMessage
);
191 System::Type
^ mapUnoType(typelib_TypeDescription
const * pTD
)
193 return mapUnoType(pTD
->pWeakRef
);
196 System::Type
^ mapUnoType(typelib_TypeDescriptionReference
const * pTD
)
198 System::Type
^ retVal
= nullptr;
199 switch (pTD
->eTypeClass
)
201 case typelib_TypeClass_VOID
:
202 retVal
= void::typeid; break;
203 case typelib_TypeClass_CHAR
:
204 retVal
= System::Char::typeid; break;
205 case typelib_TypeClass_BOOLEAN
:
206 retVal
= System::Boolean::typeid; break;
207 case typelib_TypeClass_BYTE
:
208 retVal
= System::Byte::typeid; break;
209 case typelib_TypeClass_SHORT
:
210 retVal
= System::Int16::typeid; break;
211 case typelib_TypeClass_UNSIGNED_SHORT
:
212 retVal
= System::UInt16::typeid; break;
213 case typelib_TypeClass_LONG
:
214 retVal
= System::Int32::typeid; break;
215 case typelib_TypeClass_UNSIGNED_LONG
:
216 retVal
= System::UInt32::typeid; break;
217 case typelib_TypeClass_HYPER
:
218 retVal
= System::Int64::typeid; break;
219 case typelib_TypeClass_UNSIGNED_HYPER
:
220 retVal
= System::UInt64::typeid; break;
221 case typelib_TypeClass_FLOAT
:
222 retVal
= System::Single::typeid; break;
223 case typelib_TypeClass_DOUBLE
:
224 retVal
= System::Double::typeid; break;
225 case typelib_TypeClass_STRING
:
226 retVal
= System::String::typeid; break;
227 case typelib_TypeClass_TYPE
:
228 retVal
= System::Type::typeid; break;
229 case typelib_TypeClass_ANY
:
230 retVal
= uno::Any::typeid; break;
231 case typelib_TypeClass_ENUM
:
232 case typelib_TypeClass_STRUCT
:
233 case typelib_TypeClass_EXCEPTION
:
234 retVal
= loadCliType(pTD
->pTypeName
); break;
235 case typelib_TypeClass_INTERFACE
:
237 //special handling for XInterface, since it does not exist in cli.
238 OUString
usXInterface("com.sun.star.uno.XInterface");
239 if (usXInterface
.equals(pTD
->pTypeName
))
240 retVal
= System::Object::typeid;
242 retVal
= loadCliType(pTD
->pTypeName
);
245 case typelib_TypeClass_SEQUENCE
:
247 css::uno::TypeDescription
seqType(
248 const_cast<typelib_TypeDescriptionReference
*>(pTD
));
249 typelib_TypeDescriptionReference
* pElementTDRef
=
250 reinterpret_cast<typelib_IndirectTypeDescription
*>(seqType
.get())->pType
;
251 switch (pElementTDRef
->eTypeClass
)
253 case typelib_TypeClass_CHAR
:
254 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArChar
)); break;
255 case typelib_TypeClass_BOOLEAN
:
256 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArBoolean
));
258 case typelib_TypeClass_BYTE
:
259 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArByte
));
261 case typelib_TypeClass_SHORT
:
262 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArInt16
));
264 case typelib_TypeClass_UNSIGNED_SHORT
:
265 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArUInt16
));
267 case typelib_TypeClass_LONG
:
268 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArInt32
));
270 case typelib_TypeClass_UNSIGNED_LONG
:
271 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArUInt32
));
273 case typelib_TypeClass_HYPER
:
274 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArInt64
));
276 case typelib_TypeClass_UNSIGNED_HYPER
:
277 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArUInt64
));
279 case typelib_TypeClass_FLOAT
:
280 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArSingle
));
282 case typelib_TypeClass_DOUBLE
:
283 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArDouble
));
285 case typelib_TypeClass_STRING
:
286 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArString
));
288 case typelib_TypeClass_TYPE
:
289 retVal
= System::Type::GetType(const_cast<System::String
^>(Constants::sArType
));
291 case typelib_TypeClass_ANY
:
292 case typelib_TypeClass_ENUM
:
293 case typelib_TypeClass_EXCEPTION
:
294 case typelib_TypeClass_STRUCT
:
295 case typelib_TypeClass_INTERFACE
:
296 case typelib_TypeClass_SEQUENCE
:
298 retVal
= loadCliType(pTD
->pTypeName
);
302 //All cases should be handled by the case statements above
315 /** Returns an acquired td.
317 typelib_TypeDescriptionReference
* mapCliType(System::Type
^ cliType
)
319 typelib_TypeDescriptionReference
* retVal
= NULL
;
320 if (cliType
== nullptr)
322 retVal
= * typelib_static_type_getByTypeClass(
323 typelib_TypeClass_VOID
);
324 typelib_typedescriptionreference_acquire( retVal
);
327 //check for Enum first,
328 //because otherwise case System::TypeCode::Int32 applies
331 OUString usTypeName
= mapCliTypeName(cliType
->FullName
);
332 css::uno::Type
unoType(css::uno::TypeClass_ENUM
, usTypeName
);
333 retVal
= unoType
.getTypeLibType();
334 typelib_typedescriptionreference_acquire(retVal
);
338 switch (System::Type::GetTypeCode(cliType
))
340 case System::TypeCode::Boolean
:
341 retVal
= * typelib_static_type_getByTypeClass(
342 typelib_TypeClass_BOOLEAN
);
343 typelib_typedescriptionreference_acquire( retVal
);
345 case System::TypeCode::Char
:
346 retVal
= * typelib_static_type_getByTypeClass(
347 typelib_TypeClass_CHAR
);
348 typelib_typedescriptionreference_acquire( retVal
);
350 case System::TypeCode::Byte
:
351 retVal
= * typelib_static_type_getByTypeClass(
352 typelib_TypeClass_BYTE
);
353 typelib_typedescriptionreference_acquire( retVal
);
355 case System::TypeCode::Int16
:
356 retVal
= * typelib_static_type_getByTypeClass(
357 typelib_TypeClass_SHORT
);
358 typelib_typedescriptionreference_acquire( retVal
);
360 case System::TypeCode::Int32
:
361 retVal
= * typelib_static_type_getByTypeClass(
362 typelib_TypeClass_LONG
);
363 typelib_typedescriptionreference_acquire( retVal
);
365 case System::TypeCode::Int64
:
366 retVal
= * typelib_static_type_getByTypeClass(
367 typelib_TypeClass_HYPER
);
368 typelib_typedescriptionreference_acquire( retVal
);
370 case System::TypeCode::UInt16
:
371 retVal
= * typelib_static_type_getByTypeClass(
372 typelib_TypeClass_UNSIGNED_SHORT
);
373 typelib_typedescriptionreference_acquire( retVal
);
375 case System::TypeCode::UInt32
:
376 retVal
= * typelib_static_type_getByTypeClass(
377 typelib_TypeClass_UNSIGNED_LONG
);
378 typelib_typedescriptionreference_acquire( retVal
);
380 case System::TypeCode::UInt64
:
381 retVal
= * typelib_static_type_getByTypeClass(
382 typelib_TypeClass_UNSIGNED_HYPER
);
383 typelib_typedescriptionreference_acquire( retVal
);
385 case System::TypeCode::Single
:
386 retVal
= * typelib_static_type_getByTypeClass(
387 typelib_TypeClass_FLOAT
);
388 typelib_typedescriptionreference_acquire( retVal
);
390 case System::TypeCode::Double
:
391 retVal
= * typelib_static_type_getByTypeClass(
392 typelib_TypeClass_DOUBLE
);
393 typelib_typedescriptionreference_acquire( retVal
);
395 case System::TypeCode::String
:
396 retVal
= * typelib_static_type_getByTypeClass(
397 typelib_TypeClass_STRING
);
398 typelib_typedescriptionreference_acquire( retVal
);
406 System::String
^ cliTypeName
= cliType
->FullName
;
408 if (const_cast<System::String
^>(Constants::sVoid
)->Equals(
411 retVal
= * typelib_static_type_getByTypeClass(
412 typelib_TypeClass_VOID
);
413 typelib_typedescriptionreference_acquire( retVal
);
416 else if (const_cast<System::String
^>(Constants::sType
)->Equals(
419 retVal
= * typelib_static_type_getByTypeClass(
420 typelib_TypeClass_TYPE
);
421 typelib_typedescriptionreference_acquire( retVal
);
424 else if (const_cast<System::String
^>(Constants::sAny
)->Equals(
427 retVal
= * typelib_static_type_getByTypeClass(
428 typelib_TypeClass_ANY
);
429 typelib_typedescriptionreference_acquire( retVal
);
431 //struct, interfaces, sequences
435 uno::PolymorphicType
^ poly
= dynamic_cast<uno::PolymorphicType
^>(cliType
);
437 usTypeName
= mapCliTypeName( poly
->PolymorphicName
);
439 usTypeName
= mapCliTypeName(cliTypeName
);
440 typelib_TypeDescription
* td
= NULL
;
441 typelib_typedescription_getByName(&td
, usTypeName
.pData
);
444 retVal
= td
->pWeakRef
;
445 typelib_typedescriptionreference_acquire(retVal
);
446 typelib_typedescription_release(td
);
452 OUStringBuffer
buf( 128 );
454 RTL_CONSTASCII_STRINGPARAM("[cli_uno bridge] mapCliType():"
455 "could not map type: ") );
456 buf
.append(mapCliString(cliType
->FullName
));
457 throw BridgeRuntimeError( buf
.makeStringAndClear() );
463 Otherwise a leading "unoidl." is removed.
465 System::String
^ mapUnoTypeName(rtl_uString
const * typeName
)
467 OUString
usUnoName( const_cast< rtl_uString
* >( typeName
) );
468 st::StringBuilder
^ buf
= gcnew
st::StringBuilder();
469 //determine if the type is a sequence and its dimensions
471 if (usUnoName
[0] == '[')
476 if (usUnoName
[index
++] == ']')
478 if (usUnoName
[index
++] != '[')
481 usUnoName
= usUnoName
.copy(index
- 1);
483 System::String
^ sUnoName
= mapUnoString(usUnoName
.pData
);
484 if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usBool
)))
485 buf
->Append(const_cast<System::String
^>(Constants::sBoolean
));
486 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usChar
)))
487 buf
->Append(const_cast<System::String
^>(Constants::sChar
));
488 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usByte
)))
489 buf
->Append(const_cast<System::String
^>(Constants::sByte
));
490 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usShort
)))
491 buf
->Append(const_cast<System::String
^>(Constants::sInt16
));
492 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usUShort
)))
493 buf
->Append(const_cast<System::String
^>(Constants::sUInt16
));
494 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usLong
)))
495 buf
->Append(const_cast<System::String
^>(Constants::sInt32
));
496 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usULong
)))
497 buf
->Append(const_cast<System::String
^>(Constants::sUInt32
));
498 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usHyper
)))
499 buf
->Append(const_cast<System::String
^>(Constants::sInt64
));
500 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usUHyper
)))
501 buf
->Append(const_cast<System::String
^>(Constants::sUInt64
));
502 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usFloat
)))
503 buf
->Append(const_cast<System::String
^>(Constants::sSingle
));
504 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usDouble
)))
505 buf
->Append(const_cast<System::String
^>(Constants::sDouble
));
506 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usString
)))
507 buf
->Append(const_cast<System::String
^>(Constants::sString
));
508 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usVoid
)))
509 buf
->Append(const_cast<System::String
^>(Constants::sVoid
));
510 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usType
)))
511 buf
->Append(const_cast<System::String
^>(Constants::sType
));
512 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usXInterface
)))
513 buf
->Append(const_cast<System::String
^>(Constants::sObject
));
514 else if (sUnoName
->Equals(const_cast<System::String
^>(Constants::usAny
)))
516 buf
->Append(const_cast<System::String
^>(Constants::sAny
));
520 //put "unoidl." at the beginning
521 buf
->Append(const_cast<System::String
^>(Constants::sUnoidl
));
522 //for polymorphic struct types remove the brackets, e.g mystruct<bool> -> mystruct
523 System::String
^ sName
= mapUnoPolymorphicName(sUnoName
);
528 buf
->Append(const_cast<System::String
^>(Constants::sBrackets
));
530 return buf
->ToString();
536 /** For example, there is a uno type
537 com.sun.star.Foo<char, long>.
538 The values in the type list
539 are uno types and are replaced by cli types, such as System.Char,
541 The präfix unoidl is not added.
543 inline System::String
^ mapUnoPolymorphicName(System::String
^ unoName
)
545 return mapPolymorphicName(unoName
, false);
547 /** For example, there is a type name such as
548 com.sun.star.Foo<System.Char, System.Int32>.
549 The values in the type list
550 are CLI types and are replaced by uno types, such as char,
552 The präfix unoidl remains.
554 inline System::String
^ mapCliPolymorphicName(System::String
^ unoName
)
556 return mapPolymorphicName(unoName
, true);
559 System::String
^ mapPolymorphicName(System::String
^ unoName
, bool bCliToUno
)
561 int index
= unoName
->IndexOf('<');
565 System::Text::StringBuilder
^ builder
= gcnew
System::Text::StringBuilder(256);
566 builder
->Append(unoName
->Substring(0, index
+1 ));
568 //Find the first occurrence of ','
569 //If the parameter is a polymorphic struct then we neede to ignore everything
570 //between the brackets because it can also contain commas
571 //get the type list within < and >
572 int endIndex
= unoName
->Length
- 1;
576 while (cur
<= endIndex
)
578 System::Char c
= unoName
[cur
];
579 if (c
== ',' || c
== '>')
581 //insert a comma if needed
582 if (countParams
!= 0)
583 builder
->Append(",");
585 System::String
^ sParam
= unoName
->Substring(index
, cur
- index
);
588 //the the index to the beginning of the next param
592 builder
->Append(mapCliTypeName(sParam
).getStr());
596 OUString s
= mapCliString(sParam
);
597 builder
->Append(mapUnoTypeName(s
.pData
));
603 //continue until the matching '>'
607 System::Char curChar
= unoName
[cur
];
612 else if (curChar
== '>')
624 builder
->Append((System::Char
) '>');
625 return builder
->ToString();
628 OUString
mapCliTypeName(System::String
^ typeName
)
631 // Array? determine the "rank" (number of "[]")
632 // move from the rightmost end to the left, for example
633 // unoidl.PolymorphicStruct<System.Char[]>[]
634 // has only a "dimension" of 1
635 int cur
= typeName
->Length
- 1;
636 bool bRightBracket
= false;
639 System::Char c
= typeName
[cur
];
642 bRightBracket
= true;
647 throw BridgeRuntimeError(
648 "Typename is wrong. No matching brackets for sequence. Name is: " +
649 mapCliString(typeName
));
650 bRightBracket
= false;
656 throw BridgeRuntimeError(
657 "Typename is wrong. No matching brackets for sequence. Name is: " +
658 mapCliString(typeName
));
664 if (bRightBracket
|| cur
< 0)
665 throw BridgeRuntimeError(
666 "Typename is wrong. " +
667 mapCliString(typeName
));
669 typeName
= typeName
->Substring(0, cur
+ 1);
671 System::Text::StringBuilder
^ buf
= gcnew
System::Text::StringBuilder(512);
673 //Put the "[]" at the beginning of the uno type name
675 buf
->Append(const_cast<System::String
^>(Constants::usBrackets
));
677 if (typeName
->Equals(const_cast<System::String
^>(Constants::sBoolean
)))
678 buf
->Append(const_cast<System::String
^>(Constants::usBool
));
679 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sChar
)))
680 buf
->Append(const_cast<System::String
^>(Constants::usChar
));
681 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sByte
)))
682 buf
->Append(const_cast<System::String
^>(Constants::usByte
));
683 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sInt16
)))
684 buf
->Append(const_cast<System::String
^>(Constants::usShort
));
685 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sUInt16
)))
686 buf
->Append(const_cast<System::String
^>(Constants::usUShort
));
687 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sInt32
)))
688 buf
->Append(const_cast<System::String
^>(Constants::usLong
));
689 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sUInt32
)))
690 buf
->Append(const_cast<System::String
^>(Constants::usULong
));
691 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sInt64
)))
692 buf
->Append(const_cast<System::String
^>(Constants::usHyper
));
693 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sUInt64
)))
694 buf
->Append(const_cast<System::String
^>(Constants::usUHyper
));
695 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sSingle
)))
696 buf
->Append(const_cast<System::String
^>(Constants::usFloat
));
697 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sDouble
)))
698 buf
->Append(const_cast<System::String
^>(Constants::usDouble
));
699 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sString
)))
700 buf
->Append(const_cast<System::String
^>(Constants::usString
));
701 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sVoid
)))
702 buf
->Append(const_cast<System::String
^>(Constants::usVoid
));
703 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sType
)))
704 buf
->Append(const_cast<System::String
^>(Constants::usType
));
705 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sObject
)))
706 buf
->Append(const_cast<System::String
^>(Constants::usXInterface
));
707 else if (typeName
->Equals(const_cast<System::String
^>(Constants::sAny
)))
708 buf
->Append(const_cast<System::String
^>(Constants::usAny
));
711 System::String
^ sName
= mapCliPolymorphicName(typeName
);
712 int i
= sName
->IndexOf(L
'.');
713 buf
->Append(sName
->Substring(i
+ 1));
715 return mapCliString(buf
->ToString());
717 /** Maps uno types to dot net types.
718 * If uno_data is null then the type description is converted to System::Type
720 inline System::String
^ mapUnoString( rtl_uString
const * data
)
723 return gcnew
System::String((__wchar_t
*) data
->buffer
, 0, data
->length
);
726 OUString
mapCliString(System::String
^ data
)
731 OSL_ASSERT(sizeof(wchar_t) == sizeof(sal_Unicode
));
732 pin_ptr
<wchar_t const> pdata
= PtrToStringChars(data
);
733 return OUString(pdata
, const_cast<System::String
^>(data
)->Length
);
741 // ToDo convert cli types to expected types, e.g a long to a short where the uno type
742 // is a sal_Int16. This could be necessary if a scripting language (typeless) is used
743 // @param assign the uno_data has to be destructed (in/out args)
744 void Bridge::map_to_uno(void * uno_data
, System::Object
^ cli_data
,
745 typelib_TypeDescriptionReference
* type
,
749 switch (type
->eTypeClass
)
751 case typelib_TypeClass_VOID
:
753 case typelib_TypeClass_CHAR
:
755 System::Char aChar
= *safe_cast
<System::Char
^>(cli_data
);
756 *(sal_Unicode
*) uno_data
= aChar
;
759 case typelib_TypeClass_BOOLEAN
:
761 System::Boolean aBool
= *safe_cast
<System::Boolean
^>(cli_data
);
762 *(sal_Bool
*)uno_data
= aBool
== true ? sal_True
: sal_False
;
765 case typelib_TypeClass_BYTE
:
767 System::Byte aByte
= *safe_cast
<System::Byte
^>(cli_data
);
768 *(sal_Int8
*) uno_data
= aByte
;
771 case typelib_TypeClass_SHORT
:
773 System::Int16 aShort
= *safe_cast
<System::Int16
^>(cli_data
);
774 *(sal_Int16
*) uno_data
= aShort
;
777 case typelib_TypeClass_UNSIGNED_SHORT
:
779 System::UInt16 aUShort
= *safe_cast
<System::UInt16
^>(cli_data
);
780 *(sal_uInt16
*) uno_data
= aUShort
;
783 case typelib_TypeClass_LONG
:
785 System::Int32 aLong
= *safe_cast
<System::Int32
^>(cli_data
);
786 *(sal_Int32
*) uno_data
= aLong
;
789 case typelib_TypeClass_UNSIGNED_LONG
:
791 System::UInt32 aULong
= *safe_cast
<System::UInt32
^>(cli_data
);
792 *(sal_uInt32
*) uno_data
= aULong
;
795 case typelib_TypeClass_HYPER
:
797 System::Int64 aHyper
= *safe_cast
<System::Int64
^>(cli_data
);
798 *(sal_Int64
*) uno_data
= aHyper
;
801 case typelib_TypeClass_UNSIGNED_HYPER
:
803 System::UInt64 aLong
= *safe_cast
<System::UInt64
^>(cli_data
);
804 *(sal_uInt64
*) uno_data
= aLong
;
807 case typelib_TypeClass_FLOAT
:
809 System::Single aFloat
= *safe_cast
<System::Single
^>(cli_data
);
810 *(float*) uno_data
= aFloat
;
813 case typelib_TypeClass_DOUBLE
:
815 System::Double aDouble
= *safe_cast
<System::Double
^>(cli_data
);
816 *(double*) uno_data
= aDouble
;
819 case typelib_TypeClass_STRING
:
821 if (assign
&& *(rtl_uString
**) uno_data
)
822 rtl_uString_release(*(rtl_uString
**) uno_data
);
824 *(rtl_uString
**)uno_data
= 0;
825 if (cli_data
== nullptr)
827 rtl_uString_new((rtl_uString
**) uno_data
);
831 System::String
^s
= safe_cast
<System::String
^>(cli_data
);
832 pin_ptr
<const wchar_t> pdata
= PtrToStringChars(s
);
833 rtl_uString_newFromStr_WithLength( (rtl_uString
**) uno_data
,
838 case typelib_TypeClass_TYPE
:
840 typelib_TypeDescriptionReference
* td
= mapCliType(safe_cast
<System::Type
^>(
844 typelib_typedescriptionreference_release(
845 *(typelib_TypeDescriptionReference
**)uno_data
);
847 *(typelib_TypeDescriptionReference
**)uno_data
= td
;
850 case typelib_TypeClass_ANY
:
852 uno_Any
* pAny
= (uno_Any
*)uno_data
;
853 if (cli_data
== nullptr) // null-ref or uninitialized any maps to empty any
856 uno_any_destruct( pAny
, 0 );
857 uno_any_construct( pAny
, 0, 0, 0 );
860 uno::Any aAny
= *safe_cast
<uno::Any
^>(cli_data
);
861 css::uno::Type
value_td( mapCliType(aAny
.Type
), SAL_NO_ACQUIRE
);
864 uno_any_destruct( pAny
, 0 );
868 switch (value_td
.getTypeClass())
870 case typelib_TypeClass_VOID
:
871 pAny
->pData
= &pAny
->pReserved
;
873 case typelib_TypeClass_CHAR
:
874 pAny
->pData
= &pAny
->pReserved
;
875 *(sal_Unicode
*) &pAny
->pReserved
= *safe_cast
<System::Char
^>(aAny
.Value
);
877 case typelib_TypeClass_BOOLEAN
:
878 pAny
->pData
= &pAny
->pReserved
;
879 *(sal_Bool
*) &pAny
->pReserved
= *safe_cast
<System::Boolean
^>(aAny
.Value
);
881 case typelib_TypeClass_BYTE
:
882 pAny
->pData
= &pAny
->pReserved
;
883 *(sal_Int8
*) &pAny
->pReserved
= *safe_cast
<System::Byte
^>(aAny
.Value
);
885 case typelib_TypeClass_SHORT
:
886 pAny
->pData
= &pAny
->pReserved
;
887 *(sal_Int16
*) &pAny
->pReserved
= *safe_cast
<System::Int16
^>(aAny
.Value
);
889 case typelib_TypeClass_UNSIGNED_SHORT
:
890 pAny
->pData
= &pAny
->pReserved
;
891 *(sal_uInt16
*) &pAny
->pReserved
= *safe_cast
<System::UInt16
^>(aAny
.Value
);
893 case typelib_TypeClass_LONG
:
894 pAny
->pData
= &pAny
->pReserved
;
895 *(sal_Int32
*) &pAny
->pReserved
= *safe_cast
<System::Int32
^>(aAny
.Value
);
897 case typelib_TypeClass_UNSIGNED_LONG
:
898 pAny
->pData
= &pAny
->pReserved
;
899 *(sal_uInt32
*) &pAny
->pReserved
= *safe_cast
<System::UInt32
^>(aAny
.Value
);
901 case typelib_TypeClass_HYPER
:
902 if (sizeof (sal_Int64
) <= sizeof (void *))
904 pAny
->pData
= &pAny
->pReserved
;
905 *(sal_Int64
*) &pAny
->pReserved
= *safe_cast
<System::Int64
^>(aAny
.Value
);
909 auto_ptr
< rtl_mem
> mem( rtl_mem::allocate( sizeof (sal_Int64
) ) );
910 *(sal_Int64
*) mem
.get()= *safe_cast
<System::Int64
^>(aAny
.Value
);
911 pAny
->pData
= mem
.release();
914 case typelib_TypeClass_UNSIGNED_HYPER
:
915 if (sizeof (sal_uInt64
) <= sizeof (void *))
917 pAny
->pData
= &pAny
->pReserved
;
918 *(sal_uInt64
*) &pAny
->pReserved
= *safe_cast
<System::UInt64
^>(aAny
.Value
);
922 auto_ptr
< rtl_mem
> mem( rtl_mem::allocate( sizeof (sal_uInt64
) ) );
923 *(sal_uInt64
*) mem
.get()= *safe_cast
<System::UInt64
^>(aAny
.Value
);
924 pAny
->pData
= mem
.release();
927 case typelib_TypeClass_FLOAT
:
928 if (sizeof (float) <= sizeof (void *))
930 pAny
->pData
= &pAny
->pReserved
;
931 *(float*) &pAny
->pReserved
= *safe_cast
<System::Single
^>(aAny
.Value
);
935 auto_ptr
< rtl_mem
> mem( rtl_mem::allocate( sizeof (float) ) );
936 *(float*) mem
.get() = *safe_cast
<System::Single
^>(aAny
.Value
);
937 pAny
->pData
= mem
.release();
940 case typelib_TypeClass_DOUBLE
:
941 if (sizeof (double) <= sizeof (void *))
943 pAny
->pData
= &pAny
->pReserved
;
944 *(double*) &pAny
->pReserved
= *safe_cast
<System::Double
^>(aAny
.Value
);
948 auto_ptr
< rtl_mem
> mem( rtl_mem::allocate( sizeof (double) ) );
949 *(double*) mem
.get()= *safe_cast
<System::Double
^>(aAny
.Value
);
950 pAny
->pData
= mem
.release();
953 case typelib_TypeClass_STRING
: // anies often contain strings; copy string directly
955 pAny
->pData
= &pAny
->pReserved
;
956 OUString _s
= mapCliString(static_cast<System::String
^>(aAny
.Value
));
957 pAny
->pReserved
= _s
.pData
;
958 rtl_uString_acquire(_s
.pData
);
961 case typelib_TypeClass_TYPE
:
962 case typelib_TypeClass_ENUM
: //ToDo copy enum direct
963 case typelib_TypeClass_SEQUENCE
:
964 case typelib_TypeClass_INTERFACE
:
965 pAny
->pData
= &pAny
->pReserved
;
968 &pAny
->pReserved
, aAny
.Value
, value_td
.getTypeLibType(),
969 false /* no assign */);
971 case typelib_TypeClass_STRUCT
:
972 case typelib_TypeClass_EXCEPTION
:
974 css::uno::Type
anyType(value_td
);
975 typelib_TypeDescription
* td
= NULL
;
976 anyType
.getDescription(&td
);
977 auto_ptr
< rtl_mem
> mem(rtl_mem::allocate(td
->nSize
));
978 typelib_typedescription_release(td
);
980 mem
.get(), aAny
.Value
, value_td
.getTypeLibType(),
981 false /* no assign */);
982 pAny
->pData
= mem
.release();
987 OUStringBuffer
buf( 128 );
988 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") );
989 buf
.append(value_td
.getTypeName());
990 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] unsupported value type of any!") );
991 throw BridgeRuntimeError( buf
.makeStringAndClear() );
995 catch(System::InvalidCastException
^ )
999 uno_any_construct( pAny
, 0, 0, 0 ); // restore some valid any
1000 OUStringBuffer
buf( 256 );
1001 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():Any") );
1002 buf
.append(value_td
.getTypeName());
1003 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("]The Any type "));
1004 buf
.append(value_td
.getTypeName());
1005 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM(" does not correspont "
1006 "to its value type: ") );
1007 if(aAny
.Value
!= nullptr)
1009 css::uno::Type
td(mapCliType(aAny
.Value
->GetType()), SAL_NO_ACQUIRE
);
1010 buf
.append(td
.getTypeName());
1013 uno_any_construct( pAny
, 0, 0, 0 ); // restore some valid any
1014 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1016 catch (BridgeRuntimeError
& )
1019 uno_any_construct( pAny
, 0, 0, 0 ); // restore some valid any
1025 uno_any_construct( pAny
, 0, 0, 0 ); // restore some valid any
1029 pAny
->pType
= value_td
.getTypeLibType();
1030 typelib_typedescriptionreference_acquire(pAny
->pType
);
1033 case typelib_TypeClass_ENUM
:
1035 // InvalidCastException is caught at the end of this method
1036 System::Int32 aEnum
= System::Convert::ToInt32((cli_data
));
1037 *(sal_Int32
*) uno_data
= aEnum
;
1040 case typelib_TypeClass_STRUCT
:
1041 case typelib_TypeClass_EXCEPTION
:
1043 css::uno::TypeDescription
td(type
);
1044 typelib_CompoundTypeDescription
* comp_td
=
1045 (typelib_CompoundTypeDescription
*) td
.get();
1047 typelib_StructTypeDescription
* struct_td
= NULL
;
1048 if (type
->eTypeClass
== typelib_TypeClass_STRUCT
)
1049 struct_td
= (typelib_StructTypeDescription
*) td
.get();
1051 if ( ! ((typelib_TypeDescription
*) comp_td
)->bComplete
)
1052 ::typelib_typedescription_complete(
1053 (typelib_TypeDescription
**) & comp_td
);
1055 sal_Int32 nMembers
= comp_td
->nMembers
;
1056 boolean bException
= false;
1057 System::Type
^ cliType
= nullptr;
1059 cliType
= cli_data
->GetType();
1061 if (0 != comp_td
->pBaseTypeDescription
)
1065 ((typelib_TypeDescription
*)comp_td
->pBaseTypeDescription
)->pWeakRef
,
1071 typelib_TypeDescriptionReference
* member_type
= NULL
;
1073 OUString
usUnoException("com.sun.star.uno.Exception");
1074 for (; nPos
< nMembers
; ++nPos
)
1076 member_type
= comp_td
->ppTypeRefs
[nPos
];
1077 #if OSL_DEBUG_LEVEL >= 2
1078 System::String
* __s
;
1079 sr::FieldInfo
* arFields
[];
1080 __s
= mapUnoString(comp_td
->ppMemberNames
[nPos
]);
1081 arFields
= cliType
!= NULL
? cliType
->GetFields() : NULL
;
1083 System::Object
^ val
= nullptr;
1084 if (cli_data
!= nullptr)
1086 sr::FieldInfo
^ aField
= cliType
->GetField(
1087 mapUnoString(comp_td
->ppMemberNames
[nPos
]));
1088 // special case for Exception.Message property
1089 // The com.sun.star.uno.Exception.Message field is mapped to the
1090 // System.Exception property. Type.GetField("Message") returns null
1091 if ( ! aField
&& usUnoException
.equals(td
.get()->pTypeName
))
1092 {// get Exception.Message property
1093 OUString
usMessageMember("Message");
1094 if (usMessageMember
.equals(comp_td
->ppMemberNames
[nPos
]))
1096 sr::PropertyInfo
^ pi
= cliType
->GetProperty(
1097 mapUnoString(comp_td
->ppMemberNames
[nPos
]));
1098 val
= pi
->GetValue(cli_data
, nullptr);
1102 OUStringBuffer
buf(512);
1103 buf
.appendAscii(RTL_CONSTASCII_STRINGPARAM("[map_to_uno(): Member: "));
1104 buf
.append(comp_td
->ppMemberNames
[nPos
]);
1105 throw BridgeRuntimeError(buf
.makeStringAndClear());
1110 val
= aField
->GetValue(cli_data
);
1113 void * p
= (char *) uno_data
+ comp_td
->pMemberOffsets
[ nPos
];
1114 //When using polymorphic structs then the parameterized members can be null.
1115 //Then we set a default value.
1116 bool bDefault
= ((struct_td
!= NULL
1117 && struct_td
->pParameterizedTypes
!= NULL
1118 && struct_td
->pParameterizedTypes
[nPos
] == sal_True
1120 || cli_data
== nullptr) ? true : false;
1121 switch (member_type
->eTypeClass
)
1123 case typelib_TypeClass_CHAR
:
1125 *(sal_Unicode
*) p
= 0;
1127 *(sal_Unicode
*) p
= *safe_cast
<System::Char
^>(val
);
1129 case typelib_TypeClass_BOOLEAN
:
1131 *(sal_Bool
*) p
= sal_False
;
1133 *(sal_Bool
*) p
= *safe_cast
<System::Boolean
^>(val
);
1135 case typelib_TypeClass_BYTE
:
1139 *(sal_Int8
*) p
= *safe_cast
<System::Byte
^>(val
);
1141 case typelib_TypeClass_SHORT
:
1143 *(sal_Int16
*) p
= 0;
1145 *(sal_Int16
*) p
= *safe_cast
<System::Int16
^>(val
);
1147 case typelib_TypeClass_UNSIGNED_SHORT
:
1149 *(sal_uInt16
*) p
= 0;
1151 *(sal_uInt16
*) p
= *safe_cast
<System::UInt16
^>(val
);
1153 case typelib_TypeClass_LONG
:
1155 *(sal_Int32
*) p
= 0;
1157 *(sal_Int32
*) p
= *safe_cast
<System::Int32
^>(val
);
1159 case typelib_TypeClass_UNSIGNED_LONG
:
1161 *(sal_uInt32
*) p
= 0;
1163 *(sal_uInt32
*) p
= *safe_cast
<System::UInt32
^>(val
);
1165 case typelib_TypeClass_HYPER
:
1167 *(sal_Int64
*) p
= 0;
1169 *(sal_Int64
*) p
= *safe_cast
<System::Int64
^>(val
);
1171 case typelib_TypeClass_UNSIGNED_HYPER
:
1173 *(sal_uInt64
*) p
= 0;
1175 *(sal_uInt64
*) p
= *safe_cast
<System::UInt64
^>(val
);
1177 case typelib_TypeClass_FLOAT
:
1181 *(float*) p
= *safe_cast
<System::Single
^>(val
);
1183 case typelib_TypeClass_DOUBLE
:
1187 *(double*) p
= *safe_cast
<System::Double
^>(val
);
1190 { // ToDo enum, should be converted here
1191 map_to_uno(p
, val
, member_type
, assign
);
1197 catch (BridgeRuntimeError
& e
)
1200 OUStringBuffer
buf(512);
1201 buf
.appendAscii(RTL_CONSTASCII_STRINGPARAM("[map_to_uno():"));
1204 buf
.append(mapCliString(cliType
->FullName
));
1205 buf
.appendAscii(RTL_CONSTASCII_STRINGPARAM("."));
1206 buf
.append(comp_td
->ppMemberNames
[nPos
]);
1207 buf
.appendAscii(RTL_CONSTASCII_STRINGPARAM(" "));
1209 buf
.append(e
.m_message
);
1210 throw BridgeRuntimeError(buf
.makeStringAndClear());
1212 catch (System::InvalidCastException
^ )
1215 OUStringBuffer
buf( 256 );
1216 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") );
1219 buf
.append(mapCliString(cliType
->FullName
));
1220 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("."));
1221 buf
.append(comp_td
->ppMemberNames
[nPos
]);
1223 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] Value has not the required type."));
1224 throw BridgeRuntimeError(buf
.makeStringAndClear());
1234 if (bException
&& !assign
) // if assign then caller cleans up
1236 // cleanup the members which we have converted so far
1237 for ( sal_Int32 nCleanup
= 0; nCleanup
< nPos
; ++nCleanup
)
1239 uno_type_destructData(
1240 uno_data
, comp_td
->ppTypeRefs
[ nCleanup
], 0 );
1242 if (0 != comp_td
->pBaseTypeDescription
)
1245 uno_data
, (typelib_TypeDescription
*)comp_td
->pBaseTypeDescription
, 0 );
1251 case typelib_TypeClass_SEQUENCE
:
1253 TypeDescr
td( type
);
1254 typelib_TypeDescriptionReference
* element_type
=
1255 ((typelib_IndirectTypeDescription
*)td
.get())->pType
;
1257 auto_ptr
< rtl_mem
> seq
;
1259 System::Array
^ ar
= nullptr;
1260 if (cli_data
!= nullptr)
1262 ar
= safe_cast
<System::Array
^>(cli_data
);
1263 sal_Int32 nElements
= ar
->GetLength(0);
1267 switch (element_type
->eTypeClass
)
1269 case typelib_TypeClass_CHAR
:
1270 seq
= seq_allocate(nElements
, sizeof (sal_Unicode
));
1271 sri::Marshal::Copy(safe_cast
<array
<System::Char
>^>(cli_data
), 0,
1272 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1274 case typelib_TypeClass_BOOLEAN
:
1275 seq
= seq_allocate(nElements
, sizeof (sal_Bool
));
1276 sri::Marshal::Copy(safe_cast
<array
<System::Char
>^>(cli_data
), 0,
1277 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1279 case typelib_TypeClass_BYTE
:
1280 seq
= seq_allocate( nElements
, sizeof (sal_Int8
) );
1281 sri::Marshal::Copy(safe_cast
<array
<System::Byte
>^>(cli_data
), 0,
1282 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1284 case typelib_TypeClass_SHORT
:
1285 seq
= seq_allocate(nElements
, sizeof (sal_Int16
));
1286 sri::Marshal::Copy(safe_cast
<array
<System::Int16
>^>(cli_data
), 0,
1287 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1289 case typelib_TypeClass_UNSIGNED_SHORT
:
1290 seq
= seq_allocate( nElements
, sizeof (sal_uInt16
) );
1291 sri::Marshal::Copy(dynamic_cast<array
<System::Int16
>^>(
1292 safe_cast
<array
<System::UInt16
>^>(cli_data
)), 0,
1293 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1295 case typelib_TypeClass_LONG
:
1296 seq
= seq_allocate(nElements
, sizeof (sal_Int32
));
1297 sri::Marshal::Copy(safe_cast
<array
<System::Int32
>^>(cli_data
), 0,
1298 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1300 case typelib_TypeClass_UNSIGNED_LONG
:
1301 seq
= seq_allocate( nElements
, sizeof (sal_uInt32
) );
1302 sri::Marshal::Copy(dynamic_cast<array
<System::Int32
>^>(
1303 safe_cast
<array
<System::UInt32
>^>(cli_data
)), 0,
1304 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1306 case typelib_TypeClass_HYPER
:
1307 seq
= seq_allocate(nElements
, sizeof (sal_Int64
));
1308 sri::Marshal::Copy(safe_cast
<array
<System::Int64
>^>(cli_data
), 0,
1309 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1311 case typelib_TypeClass_UNSIGNED_HYPER
:
1312 seq
= seq_allocate(nElements
, sizeof (sal_uInt64
));
1313 sri::Marshal::Copy(dynamic_cast<array
<System::Int64
>^>(
1314 safe_cast
<array
<System::UInt64
>^>(cli_data
)), 0,
1315 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1317 case typelib_TypeClass_FLOAT
:
1318 seq
= seq_allocate(nElements
, sizeof (float));
1319 sri::Marshal::Copy(safe_cast
<array
<System::Single
>^>(cli_data
), 0,
1320 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1322 case typelib_TypeClass_DOUBLE
:
1323 seq
= seq_allocate(nElements
, sizeof (double));
1324 sri::Marshal::Copy(safe_cast
<array
<System::Double
>^>(cli_data
), 0,
1325 IntPtr(& ((uno_Sequence
*) seq
.get())->elements
), nElements
);
1327 case typelib_TypeClass_STRING
:
1329 seq
= seq_allocate(nElements
, sizeof (rtl_uString
*));
1330 array
<System::String
^>^ arStr
= safe_cast
<array
<System::String
^>^>(cli_data
);
1331 for (int i
= 0; i
< nElements
; i
++)
1333 pin_ptr
<const wchar_t> pdata
= PtrToStringChars(arStr
[i
]);
1334 rtl_uString
** pStr
= & ((rtl_uString
**) &
1335 ((uno_Sequence
*) seq
.get())->elements
)[i
];
1337 rtl_uString_newFromStr_WithLength( pStr
, pdata
,
1342 case typelib_TypeClass_ENUM
:
1343 seq
= seq_allocate(nElements
, sizeof (sal_Int32
));
1344 for (int i
= 0; i
< nElements
; i
++)
1346 ((sal_Int32
*) &((uno_Sequence
*) seq
.get())->elements
)[i
]=
1347 System::Convert::ToInt32(ar
->GetValue(i
));
1350 case typelib_TypeClass_TYPE
:
1351 case typelib_TypeClass_ANY
:
1352 case typelib_TypeClass_STRUCT
:
1353 case typelib_TypeClass_EXCEPTION
:
1354 case typelib_TypeClass_SEQUENCE
:
1355 case typelib_TypeClass_INTERFACE
:
1357 TypeDescr
element_td( element_type
);
1358 seq
= seq_allocate( nElements
, element_td
.get()->nSize
);
1360 for (sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
1364 void * p
= ((uno_Sequence
*) seq
.get())->elements
+
1365 (nPos
* element_td
.get()->nSize
);
1366 System::Object
^ elemData
= dynamic_cast<System::Array
^>(cli_data
)->GetValue(nPos
);
1368 p
, elemData
, element_td
.get()->pWeakRef
,
1369 false /* no assign */);
1374 for ( sal_Int32 nCleanPos
= 0; nCleanPos
< nPos
; ++nCleanPos
)
1377 ((uno_Sequence
*)seq
.get())->elements
+
1378 (nCleanPos
* element_td
.get()->nSize
);
1379 uno_destructData( p
, element_td
.get(), 0 );
1388 OUStringBuffer
buf( 128 );
1389 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") );
1390 buf
.append( *reinterpret_cast< OUString
const * >( &type
->pTypeName
) );
1391 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] unsupported sequence element type: ") );
1392 buf
.append( *reinterpret_cast< OUString
const * >( &element_type
->pTypeName
) );
1393 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1397 catch (BridgeRuntimeError
& e
)
1399 OUStringBuffer
buf( 128 );
1400 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") );
1401 buf
.append( *reinterpret_cast< OUString
const * >( &type
->pTypeName
));
1402 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] conversion failed\n "));
1403 buf
.append(e
.m_message
);
1404 throw BridgeRuntimeError(buf
.makeStringAndClear());
1406 catch (System::InvalidCastException
^ )
1409 OUStringBuffer
buf( 128 );
1410 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") );
1411 buf
.append( *reinterpret_cast< OUString
const * >( &type
->pTypeName
) );
1412 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] could not convert sequence element type: ") );
1413 buf
.append( *reinterpret_cast< OUString
const * >( &element_type
->pTypeName
) );
1414 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1424 uno_destructData( uno_data
, td
.get(), 0 );
1429 seq
= seq_allocate(0, sizeof (sal_Int32
));
1431 *(uno_Sequence
**)uno_data
= (uno_Sequence
*)seq
.release();
1434 case typelib_TypeClass_INTERFACE
:
1438 uno_Interface
* p
= *(uno_Interface
**)uno_data
;
1442 if (nullptr == cli_data
) // null-ref
1444 *(uno_Interface
**)uno_data
= 0;
1448 TypeDescr
td( type
);
1449 uno_Interface
* pUnoI
= map_cli2uno(cli_data
, td
.get());
1450 *(uno_Interface
**)uno_data
= pUnoI
;
1457 OUStringBuffer
buf( 128 );
1458 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") );
1459 buf
.append( *reinterpret_cast< OUString
const * >( &type
->pTypeName
) );
1460 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] unsupported type!") );
1461 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1465 // BridgeRuntimeError are allowed to be thrown
1466 catch (System::InvalidCastException
^ )
1469 OUStringBuffer
buf( 128 );
1470 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") );
1471 buf
.append( *reinterpret_cast< OUString
const * >( &type
->pTypeName
) );
1472 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] could not convert type!") );
1473 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1475 catch (System::NullReferenceException
^ e
)
1477 OUStringBuffer
buf(512);
1478 buf
.appendAscii(RTL_CONSTASCII_STRINGPARAM(
1479 "[map_to_uno()] Illegal null reference passed!\n"));
1480 buf
.append(mapCliString(e
->StackTrace
));
1481 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1483 catch (BridgeRuntimeError
& )
1497 The expected target type. Currently info is provdided when this method is called
1498 to convert the in/out and out parameters of a call from cli to uno. Then info
1499 is always a byref type, e.g. "System.String&". info is used for Any and Enum conversion.
1500 @param bDontCreateObj
1501 false - a new object is created which holds the mapped uno value and is assigned to
1503 true - cli_data already contains the newly constructed object. This is the case if
1504 a struct is converted then on the first call to map_to_cli the new object is created.
1505 If the struct inherits another struct then this function is called recursivly while the
1506 newly created object is passed in cli_data.
1508 void Bridge::map_to_cli(
1509 System::Object
^ *cli_data
, void const * uno_data
,
1510 typelib_TypeDescriptionReference
* type
, System::Type
^ info
,
1511 bool bDontCreateObj
) const
1513 switch (type
->eTypeClass
)
1515 case typelib_TypeClass_CHAR
:
1516 *cli_data
= *(__wchar_t
const*)uno_data
;
1518 case typelib_TypeClass_BOOLEAN
:
1519 *cli_data
= (*(bool const*)uno_data
) == sal_True
? true : false;
1521 case typelib_TypeClass_BYTE
:
1522 *cli_data
= *(unsigned char const*) uno_data
;
1524 case typelib_TypeClass_SHORT
:
1525 *cli_data
= *(short const*) uno_data
;
1527 case typelib_TypeClass_UNSIGNED_SHORT
:
1528 *cli_data
= *(unsigned short const*) uno_data
;
1530 case typelib_TypeClass_LONG
:
1531 *cli_data
= *(int const*) uno_data
;
1533 case typelib_TypeClass_UNSIGNED_LONG
:
1534 *cli_data
= *(unsigned int const*) uno_data
;
1536 case typelib_TypeClass_HYPER
:
1537 *cli_data
= *(__int64
const*) uno_data
;
1539 case typelib_TypeClass_UNSIGNED_HYPER
:
1540 *cli_data
= *(unsigned __int64
const*) uno_data
;
1542 case typelib_TypeClass_FLOAT
:
1543 *cli_data
= *(float const*) uno_data
;
1545 case typelib_TypeClass_DOUBLE
:
1546 *cli_data
= *(double const*) uno_data
;
1548 case typelib_TypeClass_STRING
:
1550 rtl_uString
const* sVal
= NULL
;
1551 sVal
= *(rtl_uString
* const*) uno_data
;
1552 *cli_data
= gcnew
System::String((__wchar_t
*) sVal
->buffer
,0, sVal
->length
);
1555 case typelib_TypeClass_TYPE
:
1557 *cli_data
= mapUnoType( *(typelib_TypeDescriptionReference
* const *)uno_data
);
1560 case typelib_TypeClass_ANY
:
1562 uno_Any
const * pAny
= (uno_Any
const *)uno_data
;
1563 if (typelib_TypeClass_VOID
!= pAny
->pType
->eTypeClass
)
1565 System::Object
^ objCli
= nullptr;
1567 &objCli
, pAny
->pData
, pAny
->pType
, nullptr,
1570 uno::Any
anyVal(mapUnoType(pAny
->pType
), objCli
);
1575 *cli_data
= uno::Any::VOID
;
1579 case typelib_TypeClass_ENUM
:
1581 if (info
!= nullptr)
1583 OSL_ASSERT(info
->IsByRef
);
1584 info
= info
->GetElementType();
1585 *cli_data
= System::Enum::ToObject(info
, *(System::Int32
*) uno_data
);
1588 *cli_data
= System::Enum::ToObject(
1589 mapUnoType(type
), *(System::Int32
*) uno_data
);
1592 case typelib_TypeClass_STRUCT
:
1593 case typelib_TypeClass_EXCEPTION
:
1595 TypeDescr
td( type
);
1596 typelib_CompoundTypeDescription
* comp_td
=
1597 (typelib_CompoundTypeDescription
*) td
.get();
1598 if ( ! ((typelib_TypeDescription
*) comp_td
)->bComplete
)
1599 ::typelib_typedescription_complete(
1600 (typelib_TypeDescription
**) & comp_td
);
1604 System::Type
^ cliType
= loadCliType(td
.get()->pTypeName
);
1605 //detect if we recursivly convert inherited structures
1606 //If this point is reached because of a recursive call during convering a
1607 //struct then we must not create a new object rather we use the one in
1608 // cli_data argument.
1609 System::Object
^ cliObj
;
1611 cliObj
= *cli_data
; // recursive call
1614 //Special handling for Exception conversion. We must call constructor System::Exception
1615 //to pass the message string
1616 if (ucss::uno::Exception::typeid->IsAssignableFrom(cliType
))
1618 //We need to get the Message field. Therefore we must obtain the offset from
1619 //the typedescription. The base interface of all exceptions is
1620 //com::sun::star::uno::Exception which contains the message
1621 typelib_CompoundTypeDescription
* pCTD
= comp_td
;
1622 while (pCTD
->pBaseTypeDescription
)
1623 pCTD
= pCTD
->pBaseTypeDescription
;
1626 OUString
usMessageMember("Message");
1627 for (int i
= 0; i
< pCTD
->nMembers
; i
++)
1629 #if OSL_DEBUG_LEVEL >= 2
1630 System::String
* sMember
;
1631 sMember
= mapUnoString(pCTD
->ppMemberNames
[i
]);
1633 if (usMessageMember
.equals(pCTD
->ppMemberNames
[i
]))
1639 OSL_ASSERT (nPos
!= -1);
1640 int offset
= pCTD
->pMemberOffsets
[nPos
];
1641 //With the offset within the exception we can get the message string
1642 System::String
^ sMessage
= mapUnoString(*(rtl_uString
**)
1643 ((char*) uno_data
+ offset
));
1644 //We need to find a constructor for the exception that takes the message string
1645 //We assume that the first argument is the message string
1646 array
<sr::ConstructorInfo
^>^ arCtorInfo
= cliType
->GetConstructors();
1647 sr::ConstructorInfo
^ ctorInfo
= nullptr;
1648 int numCtors
= arCtorInfo
->Length
;
1649 //Constructor must at least have 2 params for the base
1650 //unoidl.com.sun.star.uno.Exception (String, Object);
1651 array
<sr::ParameterInfo
^>^ arParamInfo
;
1652 for (int i
= 0; i
< numCtors
; i
++)
1654 arParamInfo
= arCtorInfo
[i
]->GetParameters();
1655 if (arParamInfo
->Length
< 2)
1657 ctorInfo
= arCtorInfo
[i
];
1660 OSL_ASSERT(arParamInfo
[0]->ParameterType
->Equals(System::String::typeid)
1661 && arParamInfo
[1]->ParameterType
->Equals(System::Object::typeid)
1662 && arParamInfo
[0]->Position
== 0
1663 && arParamInfo
[1]->Position
== 1);
1664 //Prepare parameters for constructor
1665 int numArgs
= arParamInfo
->Length
;
1666 array
<System::Object
^>^ args
= gcnew array
<System::Object
^>(numArgs
);
1667 //only initialize the first argument with the message
1669 cliObj
= ctorInfo
->Invoke(args
);
1672 cliObj
= System::Activator::CreateInstance(cliType
);
1674 sal_Int32
* pMemberOffsets
= comp_td
->pMemberOffsets
;
1676 if (comp_td
->pBaseTypeDescription
)
1678 //convert inherited struct
1679 //cliObj is passed inout (args in_param, out_param are true), hence the passed
1680 // cliObj is used by the callee instead of a newly created struct
1683 ((typelib_TypeDescription
*)comp_td
->pBaseTypeDescription
)->pWeakRef
, nullptr,
1686 OUString
usUnoException("com.sun.star.uno.Exception");
1687 for (sal_Int32 nPos
= comp_td
->nMembers
; nPos
--; )
1689 typelib_TypeDescriptionReference
* member_type
= comp_td
->ppTypeRefs
[ nPos
];
1690 System::String
^ sMemberName
= mapUnoString(comp_td
->ppMemberNames
[nPos
]);
1691 sr::FieldInfo
^ aField
= cliType
->GetField(sMemberName
);
1692 // special case for Exception.Message. The field has already been
1693 // set while constructing cli object
1694 if ( ! aField
&& usUnoException
.equals(td
.get()->pTypeName
))
1698 void const * p
= (char const *)uno_data
+ pMemberOffsets
[ nPos
];
1699 switch (member_type
->eTypeClass
)
1701 case typelib_TypeClass_CHAR
:
1702 aField
->SetValue(cliObj
, *(System::Char
*) p
);
1704 case typelib_TypeClass_BOOLEAN
:
1705 aField
->SetValue(cliObj
, *(System::Boolean
*) p
);
1707 case typelib_TypeClass_BYTE
:
1708 aField
->SetValue(cliObj
, *(System::Byte
*) p
);
1710 case typelib_TypeClass_SHORT
:
1711 aField
->SetValue(cliObj
, *(System::Int16
*) p
);
1713 case typelib_TypeClass_UNSIGNED_SHORT
:
1714 aField
->SetValue(cliObj
, *(System::UInt16
*) p
);
1716 case typelib_TypeClass_LONG
:
1717 aField
->SetValue(cliObj
, *(System::Int32
*) p
);
1719 case typelib_TypeClass_UNSIGNED_LONG
:
1720 aField
->SetValue(cliObj
, *(System::UInt32
*) p
);
1722 case typelib_TypeClass_HYPER
:
1723 aField
->SetValue(cliObj
, *(System::Int64
*) p
);
1725 case typelib_TypeClass_UNSIGNED_HYPER
:
1726 aField
->SetValue(cliObj
, *(System::UInt64
*) p
);
1728 case typelib_TypeClass_FLOAT
:
1729 aField
->SetValue(cliObj
, *(System::Single
*) p
);
1731 case typelib_TypeClass_DOUBLE
:
1732 aField
->SetValue(cliObj
, *(System::Double
*) p
);
1736 System::Object
^ cli_val
;
1738 &cli_val
, p
, member_type
, nullptr,
1740 aField
->SetValue(cliObj
, cli_val
);
1748 case typelib_TypeClass_SEQUENCE
:
1750 sal_Int32 nElements
;
1751 uno_Sequence
const * seq
= 0;
1752 seq
= *(uno_Sequence
* const *)uno_data
;
1753 nElements
= seq
->nElements
;
1755 TypeDescr
td( type
);
1756 typelib_TypeDescriptionReference
* element_type
=
1757 ((typelib_IndirectTypeDescription
*)td
.get())->pType
;
1759 switch (element_type
->eTypeClass
)
1761 case typelib_TypeClass_CHAR
:
1763 array
<System::Char
>^ arChar
= gcnew array
<System::Char
>(nElements
);
1764 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arChar
, 0, nElements
);
1768 case typelib_TypeClass_BOOLEAN
:
1770 array
<System::Byte
>^ arBool
= gcnew array
<System::Byte
>(nElements
);
1771 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arBool
, 0, nElements
);
1772 *cli_data
= dynamic_cast<array
<System::Boolean
>^>(arBool
);
1775 case typelib_TypeClass_BYTE
:
1777 array
<System::Byte
>^ arByte
= gcnew array
<System::Byte
>(nElements
);
1778 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arByte
, 0, nElements
);
1782 case typelib_TypeClass_SHORT
:
1784 array
<System::Int16
>^ arShort
= gcnew array
<System::Int16
>(nElements
);
1785 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arShort
, 0, nElements
);
1789 case typelib_TypeClass_UNSIGNED_SHORT
:
1791 array
<System::UInt16
>^ arUInt16
= gcnew array
<System::UInt16
>(nElements
);
1792 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), dynamic_cast<array
<System::Int16
>^>(arUInt16
),
1794 *cli_data
= arUInt16
;
1797 case typelib_TypeClass_LONG
:
1799 array
<System::Int32
>^ arInt32
= gcnew array
<System::Int32
>(nElements
);
1800 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arInt32
, 0, nElements
);
1804 case typelib_TypeClass_UNSIGNED_LONG
:
1806 array
<System::UInt32
>^ arUInt32
= gcnew array
<System::UInt32
>(nElements
);
1807 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), dynamic_cast<array
<System::Int32
>^>(arUInt32
),
1809 *cli_data
= arUInt32
;
1812 case typelib_TypeClass_HYPER
:
1814 array
<System::Int64
>^ arInt64
= gcnew array
<System::Int64
>(nElements
);
1815 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arInt64
, 0, nElements
);
1819 //FIXME: Marshal::Copy of UInt64?
1820 case typelib_TypeClass_UNSIGNED_HYPER
:
1822 array
<System::IntPtr
>^ arUInt64
= gcnew array
<System::IntPtr
>(nElements
);
1823 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arUInt64
, 0, nElements
);
1824 *cli_data
= dynamic_cast<array
<System::UInt64
>^>(arUInt64
);
1827 case typelib_TypeClass_FLOAT
:
1829 array
<System::Single
>^ arSingle
= gcnew array
<System::Single
>(nElements
);
1830 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arSingle
, 0, nElements
);
1831 *cli_data
= arSingle
;
1834 case typelib_TypeClass_DOUBLE
:
1836 array
<System::Double
>^ arDouble
= gcnew array
<System::Double
>(nElements
);
1837 sri::Marshal::Copy( IntPtr((void*) &seq
->elements
), arDouble
, 0, nElements
);
1838 *cli_data
= arDouble
;
1841 case typelib_TypeClass_STRING
:
1843 array
<System::String
^>^ arString
= gcnew array
<System::String
^>(nElements
);
1844 for (int i
= 0; i
< nElements
; i
++)
1846 rtl_uString
*aStr
= ((rtl_uString
**)(&seq
->elements
))[i
];
1847 arString
[i
]= gcnew
System::String( (__wchar_t
*) &aStr
->buffer
, 0, aStr
->length
);
1849 *cli_data
= arString
;
1852 case typelib_TypeClass_TYPE
:
1854 array
<System::Type
^>^ arType
= gcnew array
<System::Type
^>(nElements
);
1855 for (int i
= 0; i
< nElements
; i
++)
1858 mapUnoType( ((typelib_TypeDescriptionReference
**) seq
->elements
)[i
]);
1863 case typelib_TypeClass_ANY
:
1865 array
<uno::Any
>^ arCli
= gcnew array
<uno::Any
>(nElements
);
1866 uno_Any
const * p
= (uno_Any
const *)seq
->elements
;
1867 for (sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
1869 System::Object
^ cli_obj
= nullptr;
1871 &cli_obj
, &p
[ nPos
], element_type
, nullptr, false);
1872 arCli
[nPos
]= *safe_cast
<uno::Any
^>(cli_obj
);
1877 case typelib_TypeClass_ENUM
:
1880 System::Type
^ enumType
= nullptr;
1881 if (info
!= nullptr)
1883 //info is EnumType[]&, remove &
1884 OSL_ASSERT(info
->IsByRef
);
1885 enumType
= info
->GetElementType();
1886 //enumType is EnumType[], remove []
1887 enumType
= enumType
->GetElementType();
1890 enumType
= mapUnoType(element_type
);
1892 System::Array
^ arEnum
= System::Array::CreateInstance(
1893 enumType
, nElements
);
1894 for (int i
= 0; i
< nElements
; i
++)
1896 arEnum
->SetValue(System::Enum::ToObject(enumType
,
1897 ((sal_Int32
*) seq
->elements
)[i
]), i
);
1902 case typelib_TypeClass_STRUCT
:
1903 case typelib_TypeClass_EXCEPTION
:
1905 TypeDescr
element_td( element_type
);
1906 System::Array
^ ar
= System::Array::CreateInstance(
1907 mapUnoType(element_type
),nElements
);
1911 char * p
= (char *) &seq
->elements
;
1912 sal_Int32 nSize
= element_td
.get()->nSize
;
1913 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
1915 System::Object
^ val
;
1917 &val
, p
+ (nSize
* nPos
), element_type
, nullptr, false);
1918 ar
->SetValue(val
, nPos
);
1925 case typelib_TypeClass_SEQUENCE
:
1927 System::Array
^ar
= System::Array::CreateInstance(
1928 mapUnoType(element_type
), nElements
);
1931 TypeDescr
element_td( element_type
);
1932 uno_Sequence
** elements
= (uno_Sequence
**) seq
->elements
;
1933 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
1935 System::Object
^ val
;
1937 &val
, &elements
[nPos
], element_type
, nullptr, false);
1938 ar
->SetValue(val
, nPos
);
1944 case typelib_TypeClass_INTERFACE
:
1946 TypeDescr
element_td( element_type
);
1947 System::Type
^ ifaceType
= mapUnoType(element_type
);
1948 System::Array
^ ar
= System::Array::CreateInstance(ifaceType
, nElements
);
1950 char * p
= (char *)seq
->elements
;
1951 sal_Int32 nSize
= element_td
.get()->nSize
;
1952 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
1954 System::Object
^ val
;
1956 &val
, p
+ (nSize
* nPos
), element_type
, nullptr, false);
1958 ar
->SetValue(val
, nPos
);
1965 OUStringBuffer
buf( 128 );
1966 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_cli():") );
1967 buf
.append( *reinterpret_cast< OUString
const * >( &type
->pTypeName
) );
1968 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] unsupported element type: ") );
1969 buf
.append( *reinterpret_cast< OUString
const * >( &element_type
->pTypeName
) );
1970 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1975 case typelib_TypeClass_INTERFACE
:
1977 uno_Interface
* pUnoI
= *(uno_Interface
* const *)uno_data
;
1980 TypeDescr
td( type
);
1981 *cli_data
= map_uno2cli( pUnoI
, reinterpret_cast<
1982 typelib_InterfaceTypeDescription
*>(td
.get())) ;
1990 //ToDo check this exception. The String is probably crippled
1991 OUStringBuffer
buf( 128 );
1992 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_cli():") );
1993 buf
.append( *reinterpret_cast< OUString
const * >( &type
->pTypeName
) );
1994 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("] unsupported type!") );
1995 throw BridgeRuntimeError( buf
.makeStringAndClear() );
2001 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */