25#include <com/sun/star/reflection/XConstantTypeDescription.hpp>
26#include <com/sun/star/reflection/XTypeDescription.hpp>
27#include <com/sun/star/uno/RuntimeException.hpp>
28#include <com/sun/star/uno/XComponentContext.hpp>
30#include <uno/lbnames.h>
33using namespace css::uno;
34using namespace css::lang;
35using namespace css::reflection;
47 const Reference< XComponentContext > & xContext )
48 : WeakComponentImplHelper( _aComponentMutex )
50 xContext->getValueByName(
51 "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) >>=
_xTDMgr;
52 OSL_ENSURE(
_xTDMgr.is(),
"### cannot get singleton \"TypeDescriptionManager\" from context!" );
63#ifdef TEST_LIST_CLASSES
64 OSL_ENSURE( g_aClassNames.empty(),
"### idl classes still alive!" );
65 for (
auto const& className : g_aClassNames)
67 OUString
aName(className);
76 return "com.sun.star.comp.stoc.CoreReflection";
86 Sequence< OUString > seqNames {
"com.sun.star.reflection.CoreReflection" };
94 return (rObj.hasValue() ?
forType( rObj.getValueTypeRef() ) : Reference< XIdlClass >());
101 OSL_ENSURE( pTypeDescr->eTypeClass != typelib_TypeClass_TYPEDEF,
"### unexpected typedef!" );
103 switch (pTypeDescr->eTypeClass)
105 case typelib_TypeClass_VOID:
106 case typelib_TypeClass_CHAR:
107 case typelib_TypeClass_BOOLEAN:
108 case typelib_TypeClass_BYTE:
109 case typelib_TypeClass_SHORT:
110 case typelib_TypeClass_UNSIGNED_SHORT:
111 case typelib_TypeClass_LONG:
112 case typelib_TypeClass_UNSIGNED_LONG:
113 case typelib_TypeClass_HYPER:
114 case typelib_TypeClass_UNSIGNED_HYPER:
115 case typelib_TypeClass_FLOAT:
116 case typelib_TypeClass_DOUBLE:
117 case typelib_TypeClass_STRING:
118 case typelib_TypeClass_ANY:
119 return new IdlClassImpl(
this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
121 case typelib_TypeClass_ENUM:
122 return new EnumIdlClassImpl(
this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
124 case typelib_TypeClass_STRUCT:
125 case typelib_TypeClass_EXCEPTION:
126 return new CompoundIdlClassImpl(
this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
128 case typelib_TypeClass_SEQUENCE:
129 return new ArrayIdlClassImpl(
this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
131 case typelib_TypeClass_INTERFACE:
134 case typelib_TypeClass_TYPE:
135 return new IdlClassImpl(
this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
138 SAL_INFO(
"stoc",
"corereflection type unsupported: " << pTypeDescr->pTypeName);
139 return Reference< XIdlClass >();
145 Reference< XIdlClass > xRet;
174 if (! aRet.hasValue())
176 aRet =
_xTDMgr->getByHierarchicalName( rName );
177 if (aRet.getValueTypeClass() == TypeClass_INTERFACE)
183 css::uno::Reference< css::reflection::XConstantTypeDescription >
187 aRet = ctd->getConstantValue();
214 if (!aRet.hasValue())
215 throw container::NoSuchElementException( rName );
228 catch (container::NoSuchElementException &)
237 Reference< XIdlClass > xRet;
238 OUString
aName( pTypeDescr->pTypeName );
258 TYPELIB_DANGER_GET( &pTD, pRef );
261 Reference< XIdlClass > xRet =
forType( pTD );
262 TYPELIB_DANGER_RELEASE( pTD );
266 "IdlReflectionServiceImpl::forType() failed!",
279 OSL_ENSURE(
_aCpp2Uno.is(),
"### cannot get c++ to uno mapping!" );
283 "cannot get c++ to uno mapping!",
299 OSL_ENSURE(
_aUno2Cpp.is(),
"### cannot get uno to c++ mapping!" );
303 "cannot get uno to c++ mapping!",
312 const Any & rObj, typelib_InterfaceTypeDescription * pTo )
314 Reference< XInterface > xObj;
315 if (
extract( rObj, pTo, xObj,
this ))
316 return static_cast<uno_Interface *
>(
getCpp2Uno().mapInterface( xObj.get(), pTo ));
319 "illegal object given!",
326extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
328 css::uno::XComponentContext * context,
329 css::uno::Sequence<css::uno::Any>
const & arguments)
332 arguments.hasElements(),
"stoc",
"unexpected singleton arguments");
void clear()
Clears the cache, thus releasing all cached elements and keys.
void setValue(const t_Key &rKey, const t_Val &rValue)
Sets a value to be cached for given key.
t_Val getValue(const t_Key &rKey) const
Retrieves a value from the cache.
LRU_CacheAnyByOUString _aElements
virtual sal_Bool SAL_CALL hasByHierarchicalName(const OUString &rName) override
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual ~IdlReflectionServiceImpl() override
uno_Interface * mapToUno(const css::uno::Any &rObj, typelib_InterfaceTypeDescription *pTo)
virtual css::uno::Any SAL_CALL getByHierarchicalName(const OUString &rName) override
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL getType(const css::uno::Any &rObj) override
css::uno::Mapping _aUno2Cpp
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
IdlReflectionServiceImpl(const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL forName(const OUString &rTypeName) override
css::uno::Reference< css::reflection::XIdlClass > constructClass(typelib_TypeDescription *pTypeDescr)
const css::uno::Mapping & getCpp2Uno()
css::uno::Reference< css::reflection::XIdlClass > forType(typelib_TypeDescription *pTypeDescr)
css::uno::Reference< css::container::XHierarchicalNameAccess > _xTDMgr
virtual OUString SAL_CALL getImplementationName() override
const css::uno::Mapping & getUno2Cpp()
::osl::Mutex _aComponentMutex
css::uno::Mapping _aCpp2Uno
virtual void SAL_CALL disposing() override
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_stoc_CoreReflection_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &arguments)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
struct _typelib_TypeDescription typelib_TypeDescription
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
detail::Optional< T >::type forceAccess(css::uno::Any const &any)
::osl::Mutex & getMutexAccess()
bool extract(const css::uno::Any &rObj, typelib_InterfaceTypeDescription *pTo, css::uno::Reference< css::uno::XInterface > &rDest, IdlReflectionServiceImpl *pRefl)
void SAL_CALL typelib_typedescription_release(typelib_TypeDescription *pTD) SAL_THROW_EXTERN_C()
void SAL_CALL typelib_typedescription_getByName(typelib_TypeDescription **ppRet, rtl_uString *pName) SAL_THROW_EXTERN_C()