6 #include "osl/process.h"
7 #include "osl/file.hxx"
8 #include "osl/thread.h"
9 #include "rtl/ustring.hxx"
10 #include "rtl/ustrbuf.hxx"
11 #include "cppuhelper/shlib.hxx"
12 #include "cppuhelper/bootstrap.hxx"
13 #include "com/sun/star/lang/XInitialization.hpp"
14 #include "com/sun/star/lang/XSingleComponentFactory.hpp"
15 #include "com/sun/star/lang/XComponent.hpp"
16 #include "com/sun/star/container/XSet.hpp"
17 #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
18 #include "com/sun/star/reflection/XConstantTypeDescription.hpp"
19 #include "com/sun/star/reflection/XConstantsTypeDescription.hpp"
20 #include "com/sun/star/reflection/XEnumTypeDescription.hpp"
21 #include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
22 #include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp"
23 #include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp"
24 #include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
25 #include "com/sun/star/reflection/XMethodParameter.hpp"
26 #include "com/sun/star/reflection/XParameter.hpp"
27 #include "com/sun/star/reflection/XServiceConstructorDescription.hpp"
28 #include "com/sun/star/reflection/XServiceTypeDescription2.hpp"
29 #include "com/sun/star/reflection/XSingletonTypeDescription2.hpp"
30 #include "com/sun/star/reflection/XStructTypeDescription.hpp"
31 #include "com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp"
32 #include "com/sun/star/registry/XSimpleRegistry.hpp"
34 using namespace ::std
;
36 using namespace ::rtl
;
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::uno
;
40 #define OUSTR(x) ::rtl::OUString(x, strlen (x), osl_getThreadTextEncoding ())
65 UTC_InterfaceAttribute
,
74 UnoTypeClass
unoTypeClassToCLI (TypeClass tc
)
77 case TypeClass_UNKNOWN
:
83 case TypeClass_BOOLEAN
:
89 case TypeClass_UNSIGNED_SHORT
:
90 return UTC_UnsignedShort
;
93 case TypeClass_UNSIGNED_LONG
:
94 return UTC_UnsignedLong
;
97 case TypeClass_UNSIGNED_HYPER
:
98 return UTC_UnsignedHyper
;
101 case TypeClass_DOUBLE
:
103 case TypeClass_STRING
:
111 case TypeClass_TYPEDEF
:
113 case TypeClass_STRUCT
:
115 case TypeClass_EXCEPTION
:
116 return UTC_Exception
;
117 case TypeClass_SEQUENCE
:
119 case TypeClass_INTERFACE
:
120 return UTC_Interface
;
121 case TypeClass_INTERFACE_ATTRIBUTE
:
122 return UTC_InterfaceAttribute
;
123 case TypeClass_INTERFACE_METHOD
:
124 return UTC_InterfaceMethod
;
125 case TypeClass_CONSTANT
:
127 case TypeClass_CONSTANTS
:
128 return UTC_Constants
;
129 case TypeClass_SERVICE
:
131 case TypeClass_SINGLETON
:
132 return UTC_Singleton
;
133 case TypeClass_MODULE
:
139 throw RuntimeException(
140 OUSTR("unexpected type in unoTypeClassToCLI"),
141 Reference
< XInterface
>() );
144 UnoTypeClass
unoTypeClass (reflection::XTypeDescription
* xType
)
146 return unoTypeClassToCLI (xType
->getTypeClass ());
151 Reference
< XComponentContext
> mxContext
;
152 Reference
< lang::XSingleComponentFactory
> mxTDprov_factory
;
153 Reference
< container::XHierarchicalNameAccess
> mxTDmgr
;
154 Reference
< XInterface
> mxTD_provider
;
155 Reference
< reflection::XTypeDescriptionEnumeration
> mxTD_enum
;
156 Reference
< reflection::XTypeDescription
> mxTD
;
159 vector
< OUString
> mMandatoryRegistries
;
160 vector
< OUString
> mExtraRegistries
;
161 vector
< OUString
> mExplicitTypes
;
163 static OUString
const & path_get_working_dir()
165 static OUString s_workingDir
;
166 if (! s_workingDir
.getLength())
167 osl_getProcessWorkingDir( &s_workingDir
.pData
);
171 static OUString
path_make_absolute_file_url( OUString
const & path
)
174 oslFileError rc
= osl_getFileURLFromSystemPath(
175 path
.pData
, &file_url
.pData
);
176 if (osl_File_E_None
== rc
)
179 rc
= osl_getAbsoluteFileURL(
180 path_get_working_dir().pData
, file_url
.pData
, &abs
.pData
);
181 if (osl_File_E_None
== rc
)
187 throw RuntimeException(
188 OUSTR("cannot make absolute: ") + file_url
,
189 Reference
< XInterface
>() );
194 throw RuntimeException(
195 OUSTR("cannot get file url from system path: ") + path
,
196 Reference
< XInterface
>() );
200 Reference
< registry::XSimpleRegistry
> open_registries(
201 vector
< OUString
> const & registries
)
203 if (registries
.empty())
205 throw RuntimeException(OUSTR("no registries given!"),
206 Reference
< XInterface
>() );
209 Reference
< registry::XSimpleRegistry
> xSimReg
;
210 for ( size_t nPos
= registries
.size(); nPos
--; )
212 Reference
< registry::XSimpleRegistry
> xReg(
213 mxContext
->getServiceManager()->createInstanceWithContext(
214 OUSTR("com.sun.star.registry.SimpleRegistry"), mxContext
),
216 xReg
->open( registries
[ nPos
], sal_True
, sal_False
);
217 if (! xReg
->isValid())
219 throw RuntimeException(
220 OUSTR("invalid registry: ") + registries
[ nPos
],
221 Reference
< XInterface
>() );
224 if (xSimReg
.is()) // nest?
226 Reference
< registry::XSimpleRegistry
> xNested(
227 mxContext
->getServiceManager()->createInstanceWithContext(
228 OUSTR("com.sun.star.registry.NestedRegistry"), mxContext
),
230 Reference
< lang::XInitialization
> xInit(
231 xNested
, UNO_QUERY_THROW
);
232 Sequence
< Any
> args( 2 );
234 args
[ 1 ] <<= xSimReg
;
235 xInit
->initialize( args
);
252 mxContext
= ::cppu::bootstrap_InitialComponentContext(
253 Reference
< registry::XSimpleRegistry
>() );
254 mxTDmgr
= Reference
< container::XHierarchicalNameAccess
> (
255 mxContext
->getValueByName(
256 OUSTR("/singletons/com.sun.star.reflection."
257 "theTypeDescriptionManager") ),
260 // get rdb tdprovider factory
261 mxTDprov_factory
= Reference
< lang::XSingleComponentFactory
> (
262 ::cppu::loadSharedLibComponentFactory(
263 OUSTR("bootstrap.uno" SAL_DLLEXTENSION
), OUString(),
264 OUSTR("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"),
265 Reference
< lang::XMultiServiceFactory
>(
266 mxContext
->getServiceManager(), UNO_QUERY
),
267 Reference
< registry::XRegistryKey
>() ), UNO_QUERY
);
268 if (! mxTDprov_factory
.is())
270 throw RuntimeException(
271 OUSTR("cannot get registry typedescription provider: "
272 "bootstrap.uno" SAL_DLLEXTENSION
"!"),
273 Reference
< XInterface
>() );
277 void AddMandatoryRegistry (char *registry
)
279 mMandatoryRegistries
.push_back(
280 path_make_absolute_file_url( OUSTR( registry
) ) );
283 void AddExtraRegistry (char *registry
)
285 mExtraRegistries
.push_back(
286 path_make_absolute_file_url( OUSTR( registry
) ) );
289 void AddExplicitType (char *typeName
)
291 mExplicitTypes
.push_back( OUSTR( typeName
) );
294 void OpenRegistries ()
296 // create registry td provider for mandatory registry files
297 Any
arg( makeAny( open_registries( mMandatoryRegistries
) ) );
298 mxTD_provider
= Reference
< XInterface
>(
299 mxTDprov_factory
->createInstanceWithArgumentsAndContext(
300 Sequence
< Any
>( &arg
, 1 ), mxContext
) );
302 // insert provider to tdmgr
303 Reference
< container::XSet
> xSet( mxTDmgr
, UNO_QUERY_THROW
);
304 Any
provider( makeAny( mxTD_provider
) );
305 xSet
->insert( provider
);
306 OSL_ASSERT( xSet
->has( provider
) );
308 if (! mExtraRegistries
.empty())
310 arg
= makeAny( open_registries( mExtraRegistries
) );
312 mxTDprov_factory
->createInstanceWithArgumentsAndContext(
313 Sequence
< Any
>( &arg
, 1 ), mxContext
) );
314 xSet
->insert( provider
);
315 OSL_ASSERT( xSet
->has( provider
) );
318 // and emit types to it
319 if (mExplicitTypes
.empty())
321 mxTD_enum
= Reference
< reflection::XTypeDescriptionEnumeration
> (
322 Reference
< reflection::XTypeDescriptionEnumerationAccess
>(
323 mxTD_provider
, UNO_QUERY_THROW
)
324 ->createTypeDescriptionEnumeration(
325 OUString() /* all IDL modules */,
326 Sequence
< TypeClass
>() /* all classes of types */,
327 reflection::TypeDescriptionSearchDepth_INFINITE
) );
334 Reference
< reflection::XTypeDescription
> xTD
;
336 if (mnPos
< mExplicitTypes
.size()) {
337 Reference
< container::XHierarchicalNameAccess
> xHNA(
338 mxTD_provider
, UNO_QUERY_THROW
);
339 xTD
= Reference
< reflection::XTypeDescription
>(
340 xHNA
->getByHierarchicalName( mExplicitTypes
[ mnPos
] ),
343 } else if (mxTD_enum
.is() && mxTD_enum
->hasMoreElements())
344 xTD
= Reference
< reflection::XTypeDescription
>(mxTD_enum
->nextTypeDescription());
347 xTD
.get ()->acquire ();
362 static char* oustr_to_char (OUString oustr
)
364 OString os
= OUStringToOString (oustr
, osl_getThreadTextEncoding());
366 size_t len
= os
.getLength () + 1;
367 char *str
= (char *) malloc (len
);
368 memcpy (str
, os
.getStr (), len
);
373 /* UnoHelper class glue */
376 cmm_uno_helper_new ()
378 return new UnoHelper ();
382 cmm_uno_helper_add_mandatory_registry (void *ptr
, char *registry
)
384 UnoHelper
*helper
= (UnoHelper
*) ptr
;
386 helper
->AddMandatoryRegistry (registry
);
390 cmm_uno_helper_add_extra_registry (void *ptr
, char *registry
)
392 UnoHelper
*helper
= (UnoHelper
*) ptr
;
394 helper
->AddExtraRegistry (registry
);
398 cmm_uno_helper_add_explicit_type (void *ptr
, char *typeName
)
400 UnoHelper
*helper
= (UnoHelper
*) ptr
;
402 helper
->AddExplicitType (typeName
);
406 cmm_uno_helper_open_registries (void *ptr
)
408 UnoHelper
*helper
= (UnoHelper
*) ptr
;
410 helper
->OpenRegistries ();
414 cmm_uno_helper_next_type (void *ptr
)
416 UnoHelper
*helper
= (UnoHelper
*) ptr
;
418 return helper
->NextType ();
422 cmm_uno_helper_delete (void *ptr
)
424 UnoHelper
*helper
= (UnoHelper
*) ptr
;
429 /* XTypeDescription glue */
432 cmm_x_type_description_get_name (void *ptr
)
434 reflection::XTypeDescription
* xTD
= (reflection::XTypeDescription
*) ptr
;
436 return oustr_to_char (xTD
->getName ());
440 cmm_x_type_description_get_type_class (void *ptr
)
442 reflection::XTypeDescription
* xTD
= (reflection::XTypeDescription
*) ptr
;
444 return unoTypeClass (xTD
);
448 cmm_x_type_description_release (void *ptr
)
450 reflection::XTypeDescription
* xTD
= (reflection::XTypeDescription
*) ptr
;
455 /* XEnumTypeDescription glue */
458 cmm_x_enum_type_description_get_name (void *ptr
, int idx
)
460 reflection::XEnumTypeDescription
* xTD
= (reflection::XEnumTypeDescription
*) ptr
;
462 Sequence
< OUString
> seq_enum_names (xTD
->getEnumNames ());
464 return oustr_to_char (seq_enum_names
[idx
]);
468 cmm_x_enum_type_description_get_value (void *ptr
, int idx
)
470 reflection::XEnumTypeDescription
* xTD
= (reflection::XEnumTypeDescription
*) ptr
;
472 Sequence
< sal_Int32
> seq_enum_values (xTD
->getEnumValues ());
474 return seq_enum_values
[idx
];
478 cmm_x_enum_type_description_get_length (void *ptr
)
480 reflection::XEnumTypeDescription
* xTD
= (reflection::XEnumTypeDescription
*) ptr
;
482 Sequence
< sal_Int32
> seq_enum_values (xTD
->getEnumValues ());
484 return seq_enum_values
.getLength ();
487 /* XInterfaceTypeDescription glue */
490 cmm_x_interface_type_description_get_members (void *ptr
, const void **handle
)
492 reflection::XInterfaceTypeDescription
* xTD
= (reflection::XInterfaceTypeDescription
*) ptr
;
495 Reference
< reflection::XInterfaceMemberTypeDescription
> > seq_members (xTD
->getMembers ());
496 Reference
< reflection::XInterfaceMemberTypeDescription
> const * types
= seq_members
.getConstArray();
498 int length
= seq_members
.getLength ();
499 reflection::XInterfaceMemberTypeDescription
**array
= (reflection::XInterfaceMemberTypeDescription
**) malloc (length
*sizeof (reflection::XInterfaceMemberTypeDescription
*));
503 for (int i
= 0; i
< length
; i
++) {
504 array
[i
] = types
[i
].get ();
505 array
[i
]->acquire ();
512 cmm_x_interface_type_description_get_member (void *ptr
, int idx
)
514 reflection::XInterfaceMemberTypeDescription
** members
= (reflection::XInterfaceMemberTypeDescription
**) ptr
;
516 members
[idx
]->acquire ();
518 return members
[idx
];
522 cmm_x_interface_type_description_members_release (void *ptr
)
524 // uno_Sequence* seq = (uno_Sequence*) ptr;
529 /* XInterfaceTypeDescription2 glue */
532 cmm_resolveInterface (Reference
< reflection::XTypeDescription
> type
)
534 Reference
<reflection::XInterfaceTypeDescription2
>
535 xIfaceTd (type
, UNO_QUERY
);
538 reflection::XTypeDescription
* xtd
= type
.get ();
544 Reference
<reflection::XIndirectTypeDescription
> xIndTd(
546 if (xIndTd
.is() == sal_False
)
547 throw uno::Exception(
548 OUSTR("resolveInterfaceTypedef was called with an invalid argument"), 0);
549 return cmm_resolveInterface (xIndTd
->getReferencedType());
555 cmm_x_interface_type_description_get_base_type (void *ptr
, int idx
)
557 reflection::XInterfaceTypeDescription2
* xTD
= (reflection::XInterfaceTypeDescription2
*) ptr
;
559 Sequence
< Reference
< reflection::XTypeDescription
> > seq_base_types (xTD
->getBaseTypes ());
561 Reference
< reflection::XTypeDescription
> type (seq_base_types
[idx
]);
563 return cmm_resolveInterface (type
);
567 cmm_x_interface_type_description_get_length (void *ptr
)
569 reflection::XInterfaceTypeDescription2
* xTD
= (reflection::XInterfaceTypeDescription2
*) ptr
;
571 Sequence
< Reference
< reflection::XTypeDescription
> > seq_base_types (xTD
->getBaseTypes ());
573 return seq_base_types
.getLength ();
576 /* XInterfaceAttributeTypeDescription glue */
579 cmm_x_interface_attribute_type_description_get_type (void *ptr
)
581 reflection::XInterfaceAttributeTypeDescription2
* xTD
= (reflection::XInterfaceAttributeTypeDescription2
*) ptr
;
582 Reference
< reflection::XTypeDescription
> xrt
= xTD
->getType ();
584 xrt
.get ()->acquire ();
590 cmm_x_interface_attribute_type_description_is_bound (void *ptr
)
592 reflection::XInterfaceAttributeTypeDescription2
* xTD
= (reflection::XInterfaceAttributeTypeDescription2
*) ptr
;
594 return xTD
->isBound ();
598 cmm_x_interface_attribute_type_description_is_read_only (void *ptr
)
600 reflection::XInterfaceAttributeTypeDescription2
* xTD
= (reflection::XInterfaceAttributeTypeDescription2
*) ptr
;
602 return xTD
->isReadOnly ();
606 get_exception_types (const Sequence
<Reference
< reflection::XCompoundTypeDescription
> >& seq_exceptionsCTD
, void **handle
)
608 int length
= seq_exceptionsCTD
.getLength ();
613 Reference
< reflection::XCompoundTypeDescription
> const * types
= seq_exceptionsCTD
.getConstArray();
614 size_t size
= length
*sizeof (reflection::XCompoundTypeDescription
*);
615 reflection::XCompoundTypeDescription
**array
= (reflection::XCompoundTypeDescription
**) malloc (size
);
619 for (int i
= 0; i
< length
; i
++) {
620 array
[i
] = types
[i
].get ();
621 array
[i
]->acquire ();
628 cmm_x_interface_attribute_type_description_get_get_exception_types (void *ptr
, void **handle
)
630 reflection::XInterfaceAttributeTypeDescription2
* xTD
= (reflection::XInterfaceAttributeTypeDescription2
*) ptr
;
632 return get_exception_types (xTD
->getGetExceptions (), handle
);
636 cmm_x_interface_attribute_type_description_get_set_exception_types (void *ptr
, void **handle
)
638 reflection::XInterfaceAttributeTypeDescription2
* xTD
= (reflection::XInterfaceAttributeTypeDescription2
*) ptr
;
640 return get_exception_types (xTD
->getSetExceptions (), handle
);
644 cmm_x_interface_attribute_type_description_get_exception_type (void *ptr
, int index
)
646 reflection::XCompoundTypeDescription
**array
= (reflection::XCompoundTypeDescription
**) ptr
;;
648 return array
[index
];
652 free_exception_types (void *ptr
, int count
)
654 reflection::XCompoundTypeDescription
**array
= (reflection::XCompoundTypeDescription
**) ptr
;;
657 for (i
= 0; i
< count
; i
++)
658 array
[i
]->release ();
664 cmm_x_interface_attribute_type_description_free_exception_types (void *ptr
, int count
)
666 free_exception_types (ptr
, count
);
669 /* XInterfaceMemberTypeDescription glue */
672 cmm_x_interface_member_type_description_get_member_name (void *ptr
)
674 reflection::XInterfaceMemberTypeDescription
* xTD
= (reflection::XInterfaceMemberTypeDescription
*) ptr
;
676 return oustr_to_char (xTD
->getMemberName ());;
679 /* XInterfaceMethodTypeDescription glue */
682 cmm_x_interface_method_type_description_get_parameters (void *ptr
, const void **parametersHandle
, const void** parametersArrayHandle
)
684 reflection::XInterfaceMethodTypeDescription
* xTD
= (reflection::XInterfaceMethodTypeDescription
*) ptr
;
687 Reference
< reflection::XMethodParameter
> > seq_parameters (xTD
->getParameters ());
688 Reference
< reflection::XMethodParameter
> const * parameters
= seq_parameters
.getConstArray();
690 *parametersHandle
= seq_parameters
.get ();
692 int length
= seq_parameters
.getLength();
693 size_t size
= length
*sizeof (Reference
< reflection::XMethodParameter
> const);
694 Reference
< reflection::XMethodParameter
> *copy
= (Reference
< reflection::XMethodParameter
> *) malloc (size
);
695 memcpy (copy
, parameters
, size
);
697 *parametersArrayHandle
= copy
;
699 for (int i
=0; i
<length
; i
++) {
700 copy
[i
].get()->acquire ();
707 cmm_x_interface_method_type_description_get_parameter (void *ptr
, int idx
)
709 Reference
< reflection::XMethodParameter
> const * parameters
= (Reference
< reflection::XMethodParameter
> const *) ptr
;
711 reflection::XMethodParameter
* parameterHandle
= parameters
[idx
].get ();
713 parameterHandle
->acquire ();
715 return parameterHandle
;
719 cmm_x_interface_method_type_description_get_exception_types (void *ptr
, const void **exceptionTypesHandle
, const void** exceptionTypesArrayHandle
)
721 reflection::XInterfaceMethodTypeDescription
* xMethod
= (reflection::XInterfaceMethodTypeDescription
*) ptr
;
723 const Sequence
<Reference
<reflection::XTypeDescription
> > seqTD
= xMethod
->getExceptions();
724 int length
= seqTD
.getLength();
725 Sequence
<Reference
<reflection::XCompoundTypeDescription
> > seqCTD( length
);
726 Reference
< reflection::XCompoundTypeDescription
> * arCTD
= seqCTD
.getArray();
729 size_t size
= length
*sizeof (Reference
< reflection::XCompoundTypeDescription
> const);
730 Reference
< reflection::XCompoundTypeDescription
> *copy
= (Reference
< reflection::XCompoundTypeDescription
> *) malloc (size
);
732 for (int i
=0; i
<length
; i
++) {
733 arCTD
[i
] = Reference
<reflection::XCompoundTypeDescription
>(seqTD
[i
], UNO_QUERY_THROW
);
736 memcpy (copy
, arCTD
, size
);
738 *exceptionTypesArrayHandle
= copy
;
740 for (int i
=0; i
<length
; i
++) {
741 copy
[i
].get()->acquire ();
744 *exceptionTypesArrayHandle
= NULL
;
745 *exceptionTypesHandle
= NULL
;
752 cmm_x_interface_method_type_description_get_exception_type (void *ptr
, int idx
)
754 Reference
< reflection::XCompoundTypeDescription
> const * exceptionTypes
= (Reference
< reflection::XCompoundTypeDescription
> const *) ptr
;
756 reflection::XCompoundTypeDescription
* exceptionTypeHandle
= exceptionTypes
[idx
].get ();
758 exceptionTypeHandle
->acquire ();
760 return exceptionTypeHandle
;
764 cmm_x_interface_method_type_description_get_return_type (void *ptr
)
766 reflection::XInterfaceMethodTypeDescription
* xTD
= (reflection::XInterfaceMethodTypeDescription
*) ptr
;
767 Reference
< reflection::XTypeDescription
> xrt
= xTD
->getReturnType ();
769 xrt
.get ()->acquire ();
775 cmm_x_interface_method_type_description_returns_struct (void *ptr
)
777 reflection::XInterfaceMethodTypeDescription
* xTD
= (reflection::XInterfaceMethodTypeDescription
*) ptr
;
778 Reference
< reflection::XStructTypeDescription
> xrt (xTD
->getReturnType (), UNO_QUERY
);
784 cmm_x_interface_method_type_description_is_oneway (void *ptr
)
786 reflection::XInterfaceMethodTypeDescription
* xTD
= (reflection::XInterfaceMethodTypeDescription
*) ptr
;
788 return xTD
->isOneway ();
791 /* XMethodParameter glue */
794 cmm_x_method_parameter_is_out (void *ptr
)
796 reflection::XMethodParameter
* p
= (reflection::XMethodParameter
*) ptr
;
802 cmm_x_method_parameter_is_in (void *ptr
)
804 reflection::XMethodParameter
* p
= (reflection::XMethodParameter
*) ptr
;
810 cmm_x_method_parameter_position (void *ptr
)
812 reflection::XMethodParameter
* p
= (reflection::XMethodParameter
*) ptr
;
814 return p
->getPosition ();
818 cmm_x_method_parameter_name (void *ptr
)
820 reflection::XMethodParameter
* p
= (reflection::XMethodParameter
*) ptr
;
822 return oustr_to_char (p
->getName ());
826 cmm_x_method_parameter_type (void *ptr
)
828 reflection::XMethodParameter
* p
= (reflection::XMethodParameter
*) ptr
;
829 Reference
< reflection::XTypeDescription
> xtd
= p
->getType ();
831 xtd
.get ()->acquire ();
836 /* XCompoundTypeDescription glue */
839 cmm_x_compound_type_description_get_base_type (void *ptr
)
841 reflection::XCompoundTypeDescription
* xTD
= (reflection::XCompoundTypeDescription
*) ptr
;
842 Reference
< reflection::XTypeDescription
> xrt
= xTD
->getBaseType ();
847 xrt
.get ()->acquire ();
853 cmm_x_compound_type_description_get_member_names (void *ptr
, const void **handle
)
855 reflection::XCompoundTypeDescription
* xTD
= (reflection::XCompoundTypeDescription
*) ptr
;
857 Sequence
< OUString
> seq_member_names
= xTD
->getMemberNames ();
858 int length
= seq_member_names
.getLength ();
863 OUString
const * parameters
= seq_member_names
.getConstArray();
864 char **array
= (char**) malloc (length
*sizeof (char *));
868 for (int i
= 0; i
< length
; i
++) {
869 array
[i
] = oustr_to_char (parameters
[i
]);
876 cmm_x_compound_type_description_get_member_name (void *ptr
, int idx
)
878 char** member_names
= (char **) ptr
;
880 return strdup (member_names
[idx
]);
884 cmm_x_compound_type_description_get_member_types (void *ptr
, const void **handle
)
886 reflection::XCompoundTypeDescription
* xTD
= (reflection::XCompoundTypeDescription
*) ptr
;
888 Sequence
< Reference
< reflection::XTypeDescription
> > seq_member_types
= xTD
->getMemberTypes ();
889 int length
= seq_member_types
.getLength ();
894 Reference
< reflection::XTypeDescription
> const * types
= seq_member_types
.getConstArray();
895 reflection::XTypeDescription
**array
= (reflection::XTypeDescription
**) malloc (length
*sizeof (reflection::XTypeDescription
*));
899 for (int i
= 0; i
< length
; i
++) {
900 array
[i
] = types
[i
].get ();
901 array
[i
]->acquire ();
908 cmm_x_compound_type_description_get_member_type (void *ptr
, int idx
)
910 reflection::XTypeDescription
** member_types
= (reflection::XTypeDescription
**) ptr
;
911 member_types
[idx
]->acquire ();
913 return member_types
[idx
];
916 /* XStructTypeDescription glue */
919 cmm_x_struct_type_description_get_type_parameters (void *ptr
, const void **handle
)
921 reflection::XStructTypeDescription
* xTD
= (reflection::XStructTypeDescription
*) ptr
;
923 Sequence
< OUString
> seq_type_parameters
= xTD
->getTypeParameters ();
924 int length
= seq_type_parameters
.getLength ();
929 OUString
const * parameters
= seq_type_parameters
.getConstArray();
930 char **array
= (char**) malloc (length
*sizeof (char *));
934 for (int i
= 0; i
< length
; i
++) {
935 array
[i
] = oustr_to_char (parameters
[i
]);
942 cmm_x_struct_type_description_get_type_parameter (void *ptr
, int idx
)
944 char** type_parameters
= (char **) ptr
;
946 return strdup (type_parameters
[idx
]);
950 cmm_x_struct_type_description_get_type_arguments (void *ptr
, const void **typeArgumentsHandle
, const void** typeArgumentsArrayHandle
)
952 reflection::XStructTypeDescription
* xTD
= (reflection::XStructTypeDescription
*) ptr
;
955 Reference
< reflection::XTypeDescription
> > seq_type_arguments (xTD
->getTypeArguments ());
956 Reference
< reflection::XTypeDescription
> const * type_arguments
= seq_type_arguments
.getConstArray();
958 *typeArgumentsHandle
= seq_type_arguments
.get ();
960 int length
= seq_type_arguments
.getLength();
961 size_t size
= length
*sizeof (Reference
< reflection::XTypeDescription
> const);
962 Reference
< reflection::XTypeDescription
> *copy
= (Reference
< reflection::XTypeDescription
> *) malloc (size
);
963 memcpy (copy
, type_arguments
, size
);
965 *typeArgumentsArrayHandle
= copy
;
967 for (int i
=0; i
<length
; i
++) {
968 copy
[i
].get()->acquire ();
975 cmm_x_struct_type_description_get_type_argument (void *ptr
, int idx
)
977 Reference
< reflection::XTypeDescription
> const * type_arguments
= (Reference
< reflection::XTypeDescription
> const *) ptr
;
979 reflection::XTypeDescription
* typeArgumentHandle
= type_arguments
[idx
].get ();
981 typeArgumentHandle
->acquire ();
983 return typeArgumentHandle
;
986 /* XIndirectTypeDescription glue */
989 cmm_x_indirect_type_description_get_referenced_type (void *ptr
)
991 reflection::XIndirectTypeDescription
* xTD
= (reflection::XIndirectTypeDescription
*) ptr
;
992 Reference
< reflection::XTypeDescription
> xrt
= xTD
->getReferencedType ();
994 xrt
.get ()->acquire ();
999 /* XConstantTypeDescription glue */
1001 UnoTypeClass SAL_CALL
1002 cmm_any_to_cli_constant (void *ptr
,
1003 sal_Unicode
*tChar
, sal_Bool
*tBool
,
1005 sal_Int16
*tInt16
, sal_uInt16
*tUInt16
,
1006 sal_Int32
*tInt32
, sal_uInt32
*tUInt32
,
1007 sal_Int64
*tInt64
, sal_uInt64
*tUInt64
,
1008 float *tFloat
, double *tDouble
)
1010 reflection::XConstantTypeDescription
* xtd
= (reflection::XConstantTypeDescription
*) ptr
;
1011 Any
const & value (xtd
->getConstantValue ());
1013 switch (value
.getValueTypeClass ()) {
1014 case TypeClass_CHAR
:
1015 *tChar
= *reinterpret_cast< sal_Unicode
const * > (value
.getValue ());
1017 case TypeClass_BOOLEAN
:
1018 *tBool
= *reinterpret_cast< sal_Bool
const * > (value
.getValue ());
1019 case TypeClass_BYTE
:
1020 *tByte
= *reinterpret_cast< sal_uInt8
const * > (value
.getValue ());
1022 case TypeClass_SHORT
:
1023 *tInt16
= *reinterpret_cast< sal_Int16
const * > (value
.getValue ());
1025 case TypeClass_UNSIGNED_SHORT
:
1026 *tUInt16
= *reinterpret_cast< sal_uInt16
const * > (value
.getValue ());
1028 case TypeClass_LONG
:
1029 *tInt32
= *reinterpret_cast< sal_Int32
const * > (value
.getValue ());
1031 case TypeClass_UNSIGNED_LONG
:
1032 *tUInt32
= *reinterpret_cast< sal_uInt32
const * > (value
.getValue ());
1034 case TypeClass_HYPER
:
1035 *tInt64
= *reinterpret_cast< sal_Int64
const * > (value
.getValue ());
1037 case TypeClass_UNSIGNED_HYPER
:
1038 *tUInt64
= *reinterpret_cast< sal_uInt64
const * > (value
.getValue ());
1040 case TypeClass_FLOAT
:
1041 *tFloat
= *reinterpret_cast< float const * > (value
.getValue ());
1043 case TypeClass_DOUBLE
:
1044 *tDouble
= *reinterpret_cast< double const * > (value
.getValue ());
1047 throw RuntimeException(OUSTR("unexpected constant type ") +
1048 value
.getValueType().getTypeName(),
1049 Reference
< XInterface
>() );
1052 return unoTypeClassToCLI (value
.getValueTypeClass ());
1055 /* XConstantsTypeDescription glue */
1058 cmm_x_constants_type_description_get_constants (void *ptr
, const void **handle
)
1060 reflection::XConstantsTypeDescription
* xTD
= (reflection::XConstantsTypeDescription
*) ptr
;
1062 Sequence
< Reference
< reflection::XConstantTypeDescription
> > seq_member_types
= xTD
->getConstants ();
1063 int length
= seq_member_types
.getLength ();
1068 Reference
< reflection::XConstantTypeDescription
> const * types
= seq_member_types
.getConstArray();
1069 reflection::XConstantTypeDescription
**array
= (reflection::XConstantTypeDescription
**) malloc (length
*sizeof (reflection::XConstantTypeDescription
*));
1073 for (int i
= 0; i
< length
; i
++) {
1074 array
[i
] = types
[i
].get ();
1075 array
[i
]->acquire ();
1082 cmm_x_constants_type_description_get_constant (void *ptr
, int idx
)
1084 reflection::XConstantTypeDescription
** array
= (reflection::XConstantTypeDescription
**) ptr
;
1085 array
[idx
]->acquire ();
1090 /* XServiceTypeDescription glue */
1093 cmm_x_service_type_description_is_single_interface_based (void *ptr
)
1095 reflection::XServiceTypeDescription2
* xTD
= (reflection::XServiceTypeDescription2
*) ptr
;
1097 return xTD
->isSingleInterfaceBased ();
1101 cmm_x_service_type_description_get_interface (void *ptr
)
1103 reflection::XServiceTypeDescription2
* xTD
= (reflection::XServiceTypeDescription2
*) ptr
;
1104 reflection::XTypeDescription
* xTDiface
= xTD
->getInterface ().get ();
1106 xTDiface
->acquire ();
1112 cmm_x_service_type_description_get_constructors (void *ptr
, const void **handle
)
1114 reflection::XServiceTypeDescription2
* xTD
= (reflection::XServiceTypeDescription2
*) ptr
;
1116 Sequence
< Reference
< reflection::XServiceConstructorDescription
> > seq_member_types
= xTD
->getConstructors ();
1117 int length
= seq_member_types
.getLength ();
1122 Reference
< reflection::XServiceConstructorDescription
> const * types
= seq_member_types
.getConstArray();
1123 reflection::XServiceConstructorDescription
**array
= (reflection::XServiceConstructorDescription
**) malloc (length
*sizeof (reflection::XServiceConstructorDescription
*));
1127 for (int i
= 0; i
< length
; i
++) {
1128 array
[i
] = types
[i
].get ();
1129 array
[i
]->acquire ();
1136 cmm_x_service_type_description_get_constructor (void *ptr
, int idx
)
1138 reflection::XServiceConstructorDescription
** array
= (reflection::XServiceConstructorDescription
**) ptr
;
1139 array
[idx
]->acquire ();
1144 /* XServiceConstructorDescription glue */
1147 cmm_x_service_constructor_description_get_parameters (void *ptr
, const void **handle
)
1149 reflection::XServiceConstructorDescription
* xTD
= (reflection::XServiceConstructorDescription
*) ptr
;
1151 Sequence
< Reference
< reflection::XParameter
> > seq_member_types
= xTD
->getParameters ();
1152 int length
= seq_member_types
.getLength ();
1157 Reference
< reflection::XParameter
> const * types
= seq_member_types
.getConstArray();
1158 reflection::XParameter
**array
= (reflection::XParameter
**) malloc (length
*sizeof (reflection::XParameter
*));
1162 for (int i
= 0; i
< length
; i
++) {
1163 array
[i
] = types
[i
].get ();
1164 array
[i
]->acquire ();
1171 cmm_x_service_constructor_description_get_parameter (void *ptr
, int idx
)
1173 reflection::XParameter
** array
= (reflection::XParameter
**) ptr
;
1174 array
[idx
]->acquire ();
1180 cmm_x_service_constructor_description_get_name (void *ptr
)
1182 reflection::XServiceConstructorDescription
* xTD
= (reflection::XServiceConstructorDescription
*) ptr
;
1184 return oustr_to_char (xTD
->getName ());
1188 cmm_x_service_constructor_description_is_default_constructor (void *ptr
)
1190 reflection::XServiceConstructorDescription
* xTD
= (reflection::XServiceConstructorDescription
*) ptr
;
1192 return xTD
->isDefaultConstructor ();
1196 cmm_x_service_constructor_description_get_exception_types (void *ptr
, void **handle
)
1198 reflection::XServiceConstructorDescription
* xTD
= (reflection::XServiceConstructorDescription
*) ptr
;
1200 return get_exception_types (xTD
->getExceptions (), handle
);
1204 cmm_x_service_constructor_description_get_exception_type (void *ptr
, int index
)
1206 reflection::XCompoundTypeDescription
**array
= (reflection::XCompoundTypeDescription
**) ptr
;;
1208 return array
[index
];
1212 cmm_x_service_constructor_description_free_exception_types (void *ptr
, int count
)
1214 free_exception_types (ptr
, count
);
1217 /* XParameter glue */
1220 cmm_x_parameter_is_rest (void *ptr
)
1222 reflection::XParameter
* xTD
= (reflection::XParameter
*) ptr
;
1224 return xTD
->isRestParameter ();
1227 /* XServiceTypeDescription glue */
1230 cmm_x_singleton_type_description_is_interface_based (void *ptr
)
1232 reflection::XSingletonTypeDescription2
* xTD
= (reflection::XSingletonTypeDescription2
*) ptr
;
1234 return xTD
->isInterfaceBased ();
1238 cmm_x_singleton_type_description_get_interface (void *ptr
)
1240 reflection::XSingletonTypeDescription2
* xTD
= (reflection::XSingletonTypeDescription2
*) ptr
;
1241 Reference
< reflection::XTypeDescription
> xrt
= xTD
->getInterface ();
1243 xrt
.get ()->acquire ();