diff options
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/README | 39 | ||||
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 82 |
2 files changed, 85 insertions, 36 deletions
diff --git a/stoc/README b/stoc/README index db0e8574abf7..58f0c6f1a26a 100644 --- a/stoc/README +++ b/stoc/README @@ -1 +1,40 @@ Registries, reflection, introspection implementation for UNO. + + +The UNO types and services bootstrapping code is very old, and concepts +are tightly knit together. Whenever you want to change something you risk +backwards incompatibility. The code causes mental pain, and whenever +you need to touch it you want to run away screaming. One typically ends +up doing minimally invasive changes. That way, you have a chance of +surviving the process. But you also pile up guilt. + +At the heart of the matter there is the old binary "store" file structure +and the XRegistry interface on top of it. At runtime, both all the UNO +type information (scattered across a number of binary rdb files) and +all the UNO service information (scattered across a number of rdb files +that used to be binary but have been mostly changed to XML now) are +represented by a single XRegistry instance each. + +The way the respective information is represented in the XRegistry +interface simply corresponds to the way the information is stored in the +binary rdb files. Those files are designed for storage of hierarchically +nested small blobs of information. Hence, for example information about +a UNO interface type com.sun.star.foo.XBar is stored in a nested "folder" +with path com - sun - star - foo - XBar, containing little blobs of +information about the type's ancestors, its methods, etc. Similarly +for information about instantiable services like com.sun.star.baz.Boz. + +As there are typically multiple rdb files containing types resp. +services (URE specific, LO specific, from extensions, ...), but they need +to be represented by a single XRegistry instance, so "nested registries" +were invented. They effectively form a linear list of chaining XRegistry +instances together. Whenever a path needs to be looked up in the top-level +registry, it effectively searches through the linear list of nested +registries. All with the cumbersome UNO XRegistry interface between +the individual parts. Horror. + +When the XML service rdbs were introduced, we chickened out (see above +for rationale) and put them behind an XRegistry facade, so that they +would seamlessly integrate with the existing mess. We postponed +systematic clean-up to the pie-in-the-sky days of LO 4 (or, "once we'll +become incompatible with OOo," as the phrase used to be back then) diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index a1f239f84084..1b57eb7de563 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -712,9 +712,6 @@ class ImplIntrospectionAdapter : public XEnumerationAccess, public XIdlArray, public OWeakObject { - // Parent-Objekt - ImplIntrospectionAccess* mpAccess; - // Untersuchtes Objekt const Any& mrInspectedObject; @@ -734,8 +731,7 @@ class ImplIntrospectionAdapter : Reference<XIdlArray> mxObjIdlArray; public: - ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_, - const Any& obj, + ImplIntrospectionAdapter( const Any& obj, rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ ); // Methoden von XInterface @@ -813,10 +809,9 @@ public: throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException ); }; -ImplIntrospectionAdapter::ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_, - const Any& obj, +ImplIntrospectionAdapter::ImplIntrospectionAdapter(const Any& obj, rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ ) - : mpAccess( pAccess_), mrInspectedObject( obj ), mpStaticImpl( pStaticImpl_ ) + : mrInspectedObject( obj ), mpStaticImpl( pStaticImpl_ ) { // Objekt als Interfaceholen TypeClass eType = mrInspectedObject.getValueType().getTypeClass(); @@ -1035,16 +1030,54 @@ Sequence< Property > ImplIntrospectionAdapter::getProperties(void) throw( Runtim return mpStaticImpl->getProperties(); } +namespace +{ + Property getPropertyImpl(IntrospectionAccessStatic_Impl *pStaticImpl, const OUString& Name, sal_Int32 PropertyConcepts) + throw( NoSuchElementException, RuntimeException ) + { + Property aRet; + sal_Int32 i = pStaticImpl->getPropertyIndex( Name ); + sal_Bool bFound = sal_False; + if( i != -1 ) + { + sal_Int32 nConcept = pStaticImpl->getPropertyConcepts().getConstArray()[ i ]; + if( (PropertyConcepts & nConcept) != 0 ) + { + const Property* pProps = pStaticImpl->getProperties().getConstArray(); + aRet = pProps[ i ]; + bFound = sal_True; + } + } + if( !bFound ) + throw NoSuchElementException() ; + return aRet; + } + + sal_Bool hasPropertyImpl(IntrospectionAccessStatic_Impl *pStaticImpl, const OUString& Name, sal_Int32 PropertyConcepts) + throw( RuntimeException ) + { + sal_Int32 i = pStaticImpl->getPropertyIndex( Name ); + sal_Bool bRet = sal_False; + if( i != -1 ) + { + sal_Int32 nConcept = pStaticImpl->getPropertyConcepts().getConstArray()[ i ]; + if( (PropertyConcepts & nConcept) != 0 ) + bRet = sal_True; + } + return bRet; + } +} + Property ImplIntrospectionAdapter::getPropertyByName(const OUString& Name) throw( RuntimeException ) { - return mpAccess->getProperty( Name, PropertyConcept::ALL ); + return getPropertyImpl(mpStaticImpl.get(), Name, PropertyConcept::ALL); } sal_Bool ImplIntrospectionAdapter::hasPropertyByName(const OUString& Name) throw( RuntimeException ) { - return mpAccess->hasProperty( Name, PropertyConcept::ALL ); + return hasPropertyImpl(mpStaticImpl.get(), Name, PropertyConcept::ALL); } // Methoden von XElementAccess @@ -1189,36 +1222,13 @@ sal_Int32 ImplIntrospectionAccess::getSuppliedPropertyConcepts(void) Property ImplIntrospectionAccess::getProperty(const OUString& Name, sal_Int32 PropertyConcepts) throw( NoSuchElementException, RuntimeException ) { - Property aRet; - sal_Int32 i = mpStaticImpl->getPropertyIndex( Name ); - sal_Bool bFound = sal_False; - if( i != -1 ) - { - sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ]; - if( (PropertyConcepts & nConcept) != 0 ) - { - const Property* pProps = mpStaticImpl->getProperties().getConstArray(); - aRet = pProps[ i ]; - bFound = sal_True; - } - } - if( !bFound ) - throw NoSuchElementException() ; - return aRet; + return getPropertyImpl(mpStaticImpl.get(), Name, PropertyConcepts); } sal_Bool ImplIntrospectionAccess::hasProperty(const OUString& Name, sal_Int32 PropertyConcepts) throw( RuntimeException ) { - sal_Int32 i = mpStaticImpl->getPropertyIndex( Name ); - sal_Bool bRet = sal_False; - if( i != -1 ) - { - sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ]; - if( (PropertyConcepts & nConcept) != 0 ) - bRet = sal_True; - } - return bRet; + return hasPropertyImpl(mpStaticImpl.get(), Name, PropertyConcepts); } Sequence< Property > ImplIntrospectionAccess::getProperties(sal_Int32 PropertyConcepts) @@ -1405,7 +1415,7 @@ Reference<XInterface> SAL_CALL ImplIntrospectionAccess::queryAdapter( const Type if( !mpAdapter.is() ) { ((ImplIntrospectionAccess*)this)->mpAdapter = - new ImplIntrospectionAdapter( this, maInspectedObject, mpStaticImpl ); + new ImplIntrospectionAdapter( maInspectedObject, mpStaticImpl ); } Reference<XInterface> xRet; |