xref: /trunk/main/stoc/source/corereflection/base.hxx (revision 1c4c525f)
1*1c4c525fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1c4c525fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1c4c525fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1c4c525fSAndrew Rist  * distributed with this work for additional information
6*1c4c525fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1c4c525fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1c4c525fSAndrew Rist  * "License"); you may not use this file except in compliance
9*1c4c525fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1c4c525fSAndrew Rist  *
11*1c4c525fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1c4c525fSAndrew Rist  *
13*1c4c525fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1c4c525fSAndrew Rist  * software distributed under the License is distributed on an
15*1c4c525fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1c4c525fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*1c4c525fSAndrew Rist  * specific language governing permissions and limitations
18*1c4c525fSAndrew Rist  * under the License.
19*1c4c525fSAndrew Rist  *
20*1c4c525fSAndrew Rist  *************************************************************/
21*1c4c525fSAndrew Rist 
22*1c4c525fSAndrew Rist 
23cdf0e10cSrcweir //  #define TEST_LIST_CLASSES
24cdf0e10cSrcweir //  #define TRACE(x) OSL_TRACE(x)
25cdf0e10cSrcweir #define TRACE(x)
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <osl/diagnose.h>
28cdf0e10cSrcweir #include <osl/mutex.hxx>
29cdf0e10cSrcweir #include <uno/mapping.hxx>
30cdf0e10cSrcweir #include <uno/dispatcher.h>
31cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
32cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
33cdf0e10cSrcweir #include <cppuhelper/component.hxx>
34cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include "lrucache.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifdef TEST_LIST_CLASSES
39cdf0e10cSrcweir #include <list>
40cdf0e10cSrcweir #include <algorithm>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <hash_map>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
45cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
46cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlClass.hpp>
49cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlReflection.hpp>
50cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlField.hpp>
51cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlField2.hpp>
52cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlMethod.hpp>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir using namespace std;
55cdf0e10cSrcweir using namespace osl;
56cdf0e10cSrcweir using namespace rtl;
57cdf0e10cSrcweir using namespace cppu;
58cdf0e10cSrcweir using namespace com::sun::star::uno;
59cdf0e10cSrcweir using namespace com::sun::star::lang;
60cdf0e10cSrcweir using namespace com::sun::star::reflection;
61cdf0e10cSrcweir using namespace com::sun::star::container;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace stoc_corefl
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #ifdef TEST_LIST_CLASSES
68cdf0e10cSrcweir typedef list< OUString > ClassNameList;
69cdf0e10cSrcweir extern ClassNameList g_aClassNames;
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir 
72cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
73cdf0e10cSrcweir Mutex & getMutexAccess();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
td_equals(typelib_TypeDescription * pTD,typelib_TypeDescriptionReference * pType)76cdf0e10cSrcweir inline bool td_equals( typelib_TypeDescription * pTD, typelib_TypeDescriptionReference * pType )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 	return (pTD->pWeakRef == pType ||
79cdf0e10cSrcweir 			(pTD->pTypeName->length == pType->pTypeName->length &&
80cdf0e10cSrcweir 			 rtl_ustr_compare( pTD->pTypeName->buffer, pType->pTypeName->buffer ) == 0));
81cdf0e10cSrcweir }
82cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
getTypeByName(const OUString & rName)83cdf0e10cSrcweir inline typelib_TypeDescription * getTypeByName( const OUString & rName )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	typelib_TypeDescription * pTypeDescr = 0;
86cdf0e10cSrcweir 	typelib_typedescription_getByName( &pTypeDescr, rName.pData );
87cdf0e10cSrcweir 	if (! pTypeDescr->bComplete)
88cdf0e10cSrcweir 		typelib_typedescription_complete( &pTypeDescr );
89cdf0e10cSrcweir 	return pTypeDescr;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir typedef std::hash_map< OUString, WeakReference< XIdlField >,
93cdf0e10cSrcweir 	FctHashOUString, equal_to< OUString > > OUString2Field;
94cdf0e10cSrcweir typedef std::hash_map< OUString, WeakReference< XIdlMethod >,
95cdf0e10cSrcweir 	FctHashOUString, equal_to< OUString > > OUString2Method;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir //==================================================================================================
98cdf0e10cSrcweir class IdlReflectionServiceImpl
99cdf0e10cSrcweir 	: public OComponentHelper
100cdf0e10cSrcweir 	, public XIdlReflection
101cdf0e10cSrcweir 	, public XHierarchicalNameAccess
102cdf0e10cSrcweir 	, public XServiceInfo
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	Mutex									_aComponentMutex;
105cdf0e10cSrcweir 	Reference< XMultiServiceFactory >		_xMgr;
106cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess >	_xTDMgr;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	// caching
109cdf0e10cSrcweir 	LRU_CacheAnyByOUString					_aElements;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     Mapping						_aCpp2Uno;
112cdf0e10cSrcweir 	Mapping						_aUno2Cpp;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	inline Reference< XIdlClass > constructClass( typelib_TypeDescription * pTypeDescr );
115cdf0e10cSrcweir public:
getTDMgr() const116cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > getTDMgr() const
117cdf0e10cSrcweir 		{ return _xTDMgr; }
getSMgr() const118cdf0e10cSrcweir 	Reference< XMultiServiceFactory > getSMgr() const
119cdf0e10cSrcweir 		{ return _xMgr; }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     const Mapping & getCpp2Uno() throw(::com::sun::star::uno::RuntimeException);
122cdf0e10cSrcweir 	const Mapping & getUno2Cpp() throw(::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir 	uno_Interface * mapToUno( const Any & rObj, typelib_InterfaceTypeDescription * pTo ) throw(::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	// ctor/ dtor
126cdf0e10cSrcweir 	IdlReflectionServiceImpl( const Reference< XComponentContext > & xContext );
127cdf0e10cSrcweir 	virtual ~IdlReflectionServiceImpl();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	// XInterface
130cdf0e10cSrcweir 	virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
131cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw();
132cdf0e10cSrcweir 	virtual void SAL_CALL release() throw();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	// some XComponent part from OComponentHelper
135cdf0e10cSrcweir 	virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	// XServiceInfo
138cdf0e10cSrcweir 	virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
139cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
140cdf0e10cSrcweir 	virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	// XTypeProvider
143cdf0e10cSrcweir 	virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
144cdf0e10cSrcweir 	virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	// XIdlReflection
147cdf0e10cSrcweir 	virtual Reference< XIdlClass > SAL_CALL forName( const OUString & rTypeName ) throw(::com::sun::star::uno::RuntimeException);
148cdf0e10cSrcweir 	virtual Reference< XIdlClass > SAL_CALL getType( const Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	// XHierarchicalNameAccess
151cdf0e10cSrcweir 	virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
152cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	Reference< XIdlClass > forType( typelib_TypeDescription * pTypeDescr ) throw(::com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir 	Reference< XIdlClass > forType( typelib_TypeDescriptionReference * pRef ) throw(::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir };
157cdf0e10cSrcweir 
158cdf0e10cSrcweir //==================================================================================================
159cdf0e10cSrcweir class IdlClassImpl
160cdf0e10cSrcweir 	: public WeakImplHelper1< XIdlClass >
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	IdlReflectionServiceImpl *	_pReflection;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	OUString					_aName;
165cdf0e10cSrcweir 	TypeClass					_eTypeClass;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	typelib_TypeDescription *	_pTypeDescr;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir public:
getTypeDescr() const170cdf0e10cSrcweir 	typelib_TypeDescription *	getTypeDescr() const
171cdf0e10cSrcweir 		{ return _pTypeDescr; }
getReflection() const172cdf0e10cSrcweir 	IdlReflectionServiceImpl *	getReflection() const
173cdf0e10cSrcweir 		{ return _pReflection; }
getSMgr() const174cdf0e10cSrcweir 	Reference< XMultiServiceFactory > getSMgr() const
175cdf0e10cSrcweir 		{ return _pReflection->getSMgr(); }
getTDMgr() const176cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > getTDMgr() const
177cdf0e10cSrcweir 		{ return getReflection()->getTDMgr(); }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	// Ctor
180cdf0e10cSrcweir 	IdlClassImpl( IdlReflectionServiceImpl * pReflection,
181cdf0e10cSrcweir 				  const OUString & rName, typelib_TypeClass eTypeClass,
182cdf0e10cSrcweir 				  typelib_TypeDescription * pTypeDescr );
183cdf0e10cSrcweir 	virtual ~IdlClassImpl();
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	// XIdlClassImpl default implementation
186cdf0e10cSrcweir     virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
187cdf0e10cSrcweir     virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
188cdf0e10cSrcweir     virtual sal_Bool SAL_CALL equals( const Reference< XIdlClass >& xType ) throw(::com::sun::star::uno::RuntimeException);
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
191cdf0e10cSrcweir     virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	// def impl ????
194cdf0e10cSrcweir     virtual Sequence< Reference< XIdlClass > > SAL_CALL getClasses() throw(::com::sun::star::uno::RuntimeException);
195cdf0e10cSrcweir     virtual Reference< XIdlClass > SAL_CALL getClass( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
196cdf0e10cSrcweir     virtual Sequence< Reference< XIdlClass > > SAL_CALL getInterfaces() throw(::com::sun::star::uno::RuntimeException);
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	// structs, interfaces
199cdf0e10cSrcweir     virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException);
200cdf0e10cSrcweir 	// structs
201cdf0e10cSrcweir     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
202cdf0e10cSrcweir     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
203cdf0e10cSrcweir 	// interfaces
204cdf0e10cSrcweir     virtual Uik SAL_CALL getUik() throw(::com::sun::star::uno::RuntimeException);
205cdf0e10cSrcweir     virtual Reference< XIdlMethod > SAL_CALL getMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
206cdf0e10cSrcweir     virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods() throw(::com::sun::star::uno::RuntimeException);
207cdf0e10cSrcweir 	// array
208cdf0e10cSrcweir     virtual Reference< XIdlClass > SAL_CALL getComponentType() throw(::com::sun::star::uno::RuntimeException);
209cdf0e10cSrcweir     virtual Reference< XIdlArray > SAL_CALL getArray() throw(::com::sun::star::uno::RuntimeException);
210cdf0e10cSrcweir };
211cdf0e10cSrcweir 
212cdf0e10cSrcweir //==================================================================================================
213cdf0e10cSrcweir class InterfaceIdlClassImpl
214cdf0e10cSrcweir 	: public IdlClassImpl
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	typedef pair< OUString, typelib_TypeDescription * > MemberInit;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	Sequence< Reference< XIdlClass > >		_xSuperClasses;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	MemberInit *							_pSortedMemberInit; // first methods, then attributes
221cdf0e10cSrcweir 	OUString2Field							_aName2Field;
222cdf0e10cSrcweir 	OUString2Method							_aName2Method;
223cdf0e10cSrcweir 	sal_Int32								_nMethods;
224cdf0e10cSrcweir 	sal_Int32								_nAttributes;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	void initMembers();
227cdf0e10cSrcweir 
228cdf0e10cSrcweir public:
getTypeDescr() const229cdf0e10cSrcweir 	typelib_InterfaceTypeDescription * getTypeDescr() const
230cdf0e10cSrcweir 		{ return (typelib_InterfaceTypeDescription *)IdlClassImpl::getTypeDescr(); }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	// ctor/ dtor
InterfaceIdlClassImpl(IdlReflectionServiceImpl * pReflection,const OUString & rName,typelib_TypeClass eTypeClass,typelib_TypeDescription * pTypeDescr)233cdf0e10cSrcweir 	InterfaceIdlClassImpl( IdlReflectionServiceImpl * pReflection,
234cdf0e10cSrcweir 						   const OUString & rName, typelib_TypeClass eTypeClass,
235cdf0e10cSrcweir 						   typelib_TypeDescription * pTypeDescr )
236cdf0e10cSrcweir 		: IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
237cdf0e10cSrcweir 		, _pSortedMemberInit( 0 )
238cdf0e10cSrcweir 		, _nMethods( 0 )
239cdf0e10cSrcweir 		, _nAttributes( 0 )
240cdf0e10cSrcweir 		{}
241cdf0e10cSrcweir 	virtual ~InterfaceIdlClassImpl();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	// IdlClassImpl modifications
244cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
245cdf0e10cSrcweir     virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException);
246cdf0e10cSrcweir     virtual Uik SAL_CALL getUik() throw(::com::sun::star::uno::RuntimeException);
247cdf0e10cSrcweir     virtual Reference< XIdlMethod > SAL_CALL getMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
248cdf0e10cSrcweir     virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods() throw(::com::sun::star::uno::RuntimeException);
249cdf0e10cSrcweir     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
250cdf0e10cSrcweir     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
251cdf0e10cSrcweir     virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
252cdf0e10cSrcweir };
253cdf0e10cSrcweir 
254cdf0e10cSrcweir //==================================================================================================
255cdf0e10cSrcweir class CompoundIdlClassImpl
256cdf0e10cSrcweir 	: public IdlClassImpl
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	Reference< XIdlClass >					_xSuperClass;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	Sequence< Reference< XIdlField > > *	_pFields;
261cdf0e10cSrcweir 	OUString2Field							_aName2Field;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir public:
getTypeDescr() const264cdf0e10cSrcweir 	typelib_CompoundTypeDescription * getTypeDescr() const
265cdf0e10cSrcweir 		{ return (typelib_CompoundTypeDescription *)IdlClassImpl::getTypeDescr(); }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	// ctor/ dtor
CompoundIdlClassImpl(IdlReflectionServiceImpl * pReflection,const OUString & rName,typelib_TypeClass eTypeClass,typelib_TypeDescription * pTypeDescr)268cdf0e10cSrcweir 	CompoundIdlClassImpl( IdlReflectionServiceImpl * pReflection,
269cdf0e10cSrcweir 						  const OUString & rName, typelib_TypeClass eTypeClass,
270cdf0e10cSrcweir 						  typelib_TypeDescription * pTypeDescr )
271cdf0e10cSrcweir 		: IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
272cdf0e10cSrcweir 		, _pFields( 0 )
273cdf0e10cSrcweir 		{}
274cdf0e10cSrcweir 	virtual ~CompoundIdlClassImpl();
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	// IdlClassImpl modifications
277cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
278cdf0e10cSrcweir     virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException);
279cdf0e10cSrcweir     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
280cdf0e10cSrcweir     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
281cdf0e10cSrcweir };
282cdf0e10cSrcweir 
283cdf0e10cSrcweir //==================================================================================================
284cdf0e10cSrcweir class ArrayIdlClassImpl
285cdf0e10cSrcweir 	: public IdlClassImpl
286cdf0e10cSrcweir 	, public XIdlArray
287cdf0e10cSrcweir {
288cdf0e10cSrcweir public:
getTypeDescr() const289cdf0e10cSrcweir 	typelib_IndirectTypeDescription * getTypeDescr() const
290cdf0e10cSrcweir 		{ return (typelib_IndirectTypeDescription *)IdlClassImpl::getTypeDescr(); }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 	// ctor
ArrayIdlClassImpl(IdlReflectionServiceImpl * pReflection,const OUString & rName,typelib_TypeClass eTypeClass,typelib_TypeDescription * pTypeDescr)293cdf0e10cSrcweir 	ArrayIdlClassImpl( IdlReflectionServiceImpl * pReflection,
294cdf0e10cSrcweir 					   const OUString & rName, typelib_TypeClass eTypeClass,
295cdf0e10cSrcweir 					   typelib_TypeDescription * pTypeDescr )
296cdf0e10cSrcweir 		: IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
297cdf0e10cSrcweir 		{}
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
300cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw();
301cdf0e10cSrcweir 	virtual void SAL_CALL release() throw();
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 	// XTypeProvider
304cdf0e10cSrcweir 	virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
305cdf0e10cSrcweir 	virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 	// IdlClassImpl modifications
308cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
309cdf0e10cSrcweir     virtual Reference< XIdlClass > SAL_CALL getComponentType() throw(::com::sun::star::uno::RuntimeException);
310cdf0e10cSrcweir     virtual Reference< XIdlArray > SAL_CALL getArray() throw(::com::sun::star::uno::RuntimeException);
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 	// XIdlArray
313cdf0e10cSrcweir     virtual void SAL_CALL realloc( Any & rArray, sal_Int32 nLen ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
314cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getLen( const Any & rArray ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
315cdf0e10cSrcweir     virtual Any SAL_CALL get( const Any & rArray, sal_Int32 nIndex ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
316cdf0e10cSrcweir     virtual void SAL_CALL set( Any & rArray, sal_Int32 nIndex, const Any & rNewValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
317cdf0e10cSrcweir };
318cdf0e10cSrcweir 
319cdf0e10cSrcweir //==================================================================================================
320cdf0e10cSrcweir class EnumIdlClassImpl
321cdf0e10cSrcweir 	: public IdlClassImpl
322cdf0e10cSrcweir {
323cdf0e10cSrcweir 	Sequence< Reference< XIdlField > > * _pFields;
324cdf0e10cSrcweir 	OUString2Field						 _aName2Field;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir public:
getTypeDescr() const327cdf0e10cSrcweir 	typelib_EnumTypeDescription * getTypeDescr() const
328cdf0e10cSrcweir 		{ return (typelib_EnumTypeDescription *)IdlClassImpl::getTypeDescr(); }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	// ctor/ dtor
EnumIdlClassImpl(IdlReflectionServiceImpl * pReflection,const OUString & rName,typelib_TypeClass eTypeClass,typelib_TypeDescription * pTypeDescr)331cdf0e10cSrcweir 	EnumIdlClassImpl( IdlReflectionServiceImpl * pReflection,
332cdf0e10cSrcweir 					  const OUString & rName, typelib_TypeClass eTypeClass,
333cdf0e10cSrcweir 					  typelib_TypeDescription * pTypeDescr )
334cdf0e10cSrcweir 		: IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
335cdf0e10cSrcweir 		, _pFields( 0 )
336cdf0e10cSrcweir 		{}
337cdf0e10cSrcweir 	virtual ~EnumIdlClassImpl();
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	// IdlClassImpl modifications
340cdf0e10cSrcweir     virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
341cdf0e10cSrcweir     virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
342cdf0e10cSrcweir     virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
343cdf0e10cSrcweir };
344cdf0e10cSrcweir 
345cdf0e10cSrcweir //==================================================================================================
346cdf0e10cSrcweir class IdlMemberImpl
347cdf0e10cSrcweir 	: public WeakImplHelper1< XIdlMember >
348cdf0e10cSrcweir {
349cdf0e10cSrcweir 	IdlReflectionServiceImpl *	_pReflection;
350cdf0e10cSrcweir 	OUString					_aName;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 	typelib_TypeDescription *	_pTypeDescr;
353cdf0e10cSrcweir 	typelib_TypeDescription *	_pDeclTypeDescr;
354cdf0e10cSrcweir 
355cdf0e10cSrcweir protected:
356cdf0e10cSrcweir 	Reference< XIdlClass >		_xDeclClass;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir public:
getReflection() const359cdf0e10cSrcweir 	IdlReflectionServiceImpl *	getReflection() const
360cdf0e10cSrcweir 		{ return _pReflection; }
getSMgr() const361cdf0e10cSrcweir 	Reference< XMultiServiceFactory > getSMgr() const
362cdf0e10cSrcweir 		{ return _pReflection->getSMgr(); }
getTypeDescr() const363cdf0e10cSrcweir 	typelib_TypeDescription *	getTypeDescr() const
364cdf0e10cSrcweir 		{ return _pTypeDescr; }
getDeclTypeDescr() const365cdf0e10cSrcweir 	typelib_TypeDescription *	getDeclTypeDescr() const
366cdf0e10cSrcweir 		{ return _pDeclTypeDescr; }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	// ctor/ dtor
369cdf0e10cSrcweir 	IdlMemberImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
370cdf0e10cSrcweir 				   typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr );
371cdf0e10cSrcweir 	virtual ~IdlMemberImpl();
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	// XIdlMember
374cdf0e10cSrcweir     virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
375cdf0e10cSrcweir     virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
376cdf0e10cSrcweir };
377cdf0e10cSrcweir 
378cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
379cdf0e10cSrcweir // coerces to type descr pTo else queries for it: the interface pointer is returned via rDest
380cdf0e10cSrcweir // ## type to XidlClass coercion possible
extract(const Any & rObj,typelib_InterfaceTypeDescription * pTo,Reference<XInterface> & rDest,IdlReflectionServiceImpl * pRefl)381cdf0e10cSrcweir inline sal_Bool extract(
382cdf0e10cSrcweir 	const Any & rObj, typelib_InterfaceTypeDescription * pTo,
383cdf0e10cSrcweir 	Reference< XInterface > & rDest,
384cdf0e10cSrcweir 	IdlReflectionServiceImpl * pRefl )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	rDest.clear();
387cdf0e10cSrcweir 	if (0 != pTo)
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir         if (! rObj.hasValue())
390cdf0e10cSrcweir             return sal_True;
391cdf0e10cSrcweir 		if (rObj.getValueTypeClass() == TypeClass_INTERFACE)
392cdf0e10cSrcweir 		{
393cdf0e10cSrcweir 			return ::uno_type_assignData(
394cdf0e10cSrcweir 				&rDest, ((typelib_TypeDescription *)pTo)->pWeakRef,
395cdf0e10cSrcweir 				const_cast< void * >( rObj.getValue() ), rObj.getValueTypeRef(),
396cdf0e10cSrcweir 				reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
397cdf0e10cSrcweir                 reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
398cdf0e10cSrcweir                 reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
399cdf0e10cSrcweir 		}
400cdf0e10cSrcweir 		else if (rObj.getValueTypeClass() == TypeClass_TYPE)
401cdf0e10cSrcweir 		{
402cdf0e10cSrcweir 			rDest = pRefl->forType( reinterpret_cast< const Type * >( rObj.getValue() )->getTypeLibType() );
403cdf0e10cSrcweir 			return rDest.is();
404cdf0e10cSrcweir 		}
405cdf0e10cSrcweir 	}
406cdf0e10cSrcweir 	return sal_False;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
coerce_assign(void * pDest,typelib_TypeDescription * pTD,const Any & rSource,IdlReflectionServiceImpl * pRefl)409cdf0e10cSrcweir inline sal_Bool coerce_assign(
410cdf0e10cSrcweir 	void * pDest, typelib_TypeDescription * pTD, const Any & rSource,
411cdf0e10cSrcweir 	IdlReflectionServiceImpl * pRefl )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir     if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
414cdf0e10cSrcweir     {
415cdf0e10cSrcweir         Reference< XInterface > xVal;
416cdf0e10cSrcweir         if (extract( rSource, (typelib_InterfaceTypeDescription *)pTD, xVal, pRefl ))
417cdf0e10cSrcweir         {
418cdf0e10cSrcweir             if (*(XInterface **)pDest)
419cdf0e10cSrcweir                 (*(XInterface **)pDest)->release();
420cdf0e10cSrcweir             *(XInterface **)pDest = xVal.get();
421cdf0e10cSrcweir             if (*(XInterface **)pDest)
422cdf0e10cSrcweir                 (*(XInterface **)pDest)->acquire();
423cdf0e10cSrcweir             return sal_True;
424cdf0e10cSrcweir         }
425cdf0e10cSrcweir         return sal_False;
426cdf0e10cSrcweir     }
427cdf0e10cSrcweir     else if (pTD->eTypeClass == typelib_TypeClass_ANY)
428cdf0e10cSrcweir     {
429cdf0e10cSrcweir         return uno_assignData(
430cdf0e10cSrcweir             pDest, pTD,
431cdf0e10cSrcweir             (void *)&rSource, pTD,
432cdf0e10cSrcweir             reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
433cdf0e10cSrcweir             reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
434cdf0e10cSrcweir             reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
435cdf0e10cSrcweir     }
436cdf0e10cSrcweir     else
437cdf0e10cSrcweir     {
438cdf0e10cSrcweir         return uno_type_assignData(
439cdf0e10cSrcweir             pDest, pTD->pWeakRef,
440cdf0e10cSrcweir             (void *)rSource.getValue(), rSource.getValueTypeRef(),
441cdf0e10cSrcweir             reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
442cdf0e10cSrcweir             reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
443cdf0e10cSrcweir             reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
444cdf0e10cSrcweir     }
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 
450