From 02a8e8acd1f0cbb512868fd9849363f9d069db95 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 8 Apr 2013 08:45:37 +0200 Subject: [API CHANGE] WIP: Experimental new binary type.rdb format Make cppumaker work on top of unoidl/ instead of registry/, as a first step to change all the various codemakers. * API CHANGE: cppumaker no longer supports the -B switch, as that is meaningless with the new format. When reading from an old-format .rdb file, /UCR is hard-coded as the prefix now. * TODO: The new format does not yet support deprecation annotations, so the generated .hdl/.hpp files lack any SAL_DEPRECATED_INTERNALs for now. * codemaker/typemanager.hxx is extended with access to unoidl/ functionality, so the various codemakers can use registry/ and unoidl/ in parallel for now. The access to registry/ functionality will be removed. (Added small throwaway helper functions u2b/b2u to easily map between OString and OUString at the remaining seams for now.) * Includes a selective revert of ba044b1e9613ed30906a9a540b7da8392923e4e3 "remove needless forward rtl::OUString declarations" in those parts of codemaker, unodevtools, unoidl that were covered by this local work-in-progress patch; I would otherwise have hard a hard time re-applying it. * The generated .hdl/.hpp files are mostly unchanged, except for a few minor things: ** Any SAL_DEPRECATED_INTERNALs are missing (see above). ** In comprehensive getCppuType definitions, some members were erroneously classified as TypeCalss_UNKNOWN. ** In comprehensive getCppuType definitions, some unnecessary calls like ::cppu::UnoType< ::sal_Int32 >::get(); can be removed. ** For typedef sequence, the .hdl file need not include X.hdl, but only needs to forward-declare it. ** Unnecessary includes for optional bases of interfaces can be removed. ** Some numbering of local variable names (sMethodName1, ...) has changed. Change-Id: Icad98f248ac15177337f1b4ab709a755a8af6238 --- unoidl/inc/unoidl/unoidl.hxx | 183 ++++++++++++++++++++++--------------------- unoidl/source/unoidl.cxx | 66 +++++++++++++++- 2 files changed, 158 insertions(+), 91 deletions(-) (limited to 'unoidl') diff --git a/unoidl/inc/unoidl/unoidl.hxx b/unoidl/inc/unoidl/unoidl.hxx index ad4702d50ca5..02435316cb58 100644 --- a/unoidl/inc/unoidl/unoidl.hxx +++ b/unoidl/inc/unoidl/unoidl.hxx @@ -25,25 +25,25 @@ namespace unoidl { class LO_DLLPUBLIC_UNOIDL NoSuchFileException { public: - SAL_DLLPRIVATE NoSuchFileException(OUString const & uri): uri_(uri) {} + SAL_DLLPRIVATE NoSuchFileException(rtl::OUString const & uri): uri_(uri) {} SAL_DLLPRIVATE NoSuchFileException(NoSuchFileException const & other): uri_(other.uri_) {} virtual SAL_DLLPRIVATE ~NoSuchFileException() throw (); - OUString getUri() const { return uri_; } + rtl::OUString getUri() const { return uri_; } private: void operator =(NoSuchFileException) SAL_DELETED_FUNCTION; - OUString uri_; + rtl::OUString uri_; }; class LO_DLLPUBLIC_UNOIDL FileFormatException { public: SAL_DLLPRIVATE FileFormatException( - OUString const & uri, OUString const & detail): + rtl::OUString const & uri, rtl::OUString const & detail): uri_(uri), detail_(detail) {} @@ -53,15 +53,15 @@ public: virtual SAL_DLLPRIVATE ~FileFormatException() throw (); - OUString getUri() const { return uri_; } + rtl::OUString getUri() const { return uri_; } - OUString getDetail() const { return detail_; } + rtl::OUString getDetail() const { return detail_; } private: void operator =(FileFormatException) SAL_DELETED_FUNCTION; - OUString uri_; - OUString detail_; + rtl::OUString uri_; + rtl::OUString detail_; }; class LO_DLLPUBLIC_UNOIDL Entity: public salhelper::SimpleReferenceObject { @@ -88,7 +88,7 @@ private: class LO_DLLPUBLIC_UNOIDL MapCursor: public salhelper::SimpleReferenceObject { public: // throws FileFormatException: - virtual rtl::Reference< Entity > getNext(OUString * name) = 0; + virtual rtl::Reference< Entity > getNext(rtl::OUString * name) = 0; protected: SAL_DLLPRIVATE MapCursor() {} @@ -99,7 +99,7 @@ protected: class LO_DLLPUBLIC_UNOIDL ModuleEntity: public Entity { public: // throws FileFormatException: - virtual std::vector< OUString > getMemberNames() const = 0; + virtual std::vector< rtl::OUString > getMemberNames() const = 0; // throws FileFormatException: virtual rtl::Reference< MapCursor > createCursor() const = 0; @@ -128,11 +128,11 @@ private: class LO_DLLPUBLIC_UNOIDL EnumTypeEntity: public PublishableEntity { public: struct Member { - Member(OUString const & theName, sal_Int32 theValue): + Member(rtl::OUString const & theName, sal_Int32 theValue): name(theName), value(theValue) {} - OUString name; + rtl::OUString name; sal_Int32 value; }; @@ -153,23 +153,23 @@ private: class LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity: public PublishableEntity { public: struct Member { - Member(OUString const & theName, OUString const & theType): + Member(rtl::OUString const & theName, rtl::OUString const & theType): name(theName), type(theType) {} - OUString name; + rtl::OUString name; - OUString type; + rtl::OUString type; }; SAL_DLLPRIVATE PlainStructTypeEntity( - bool published, OUString const & directBase, + bool published, rtl::OUString const & directBase, std::vector< Member > const & directMembers): PublishableEntity(SORT_PLAIN_STRUCT_TYPE, published), directBase_(directBase), directMembers_(directMembers) {} - OUString getDirectBase() const { return directBase_; } + rtl::OUString getDirectBase() const { return directBase_; } std::vector< Member > const & getDirectMembers() const { return directMembers_; } @@ -177,7 +177,7 @@ public: private: virtual SAL_DLLPRIVATE ~PlainStructTypeEntity() throw (); - OUString directBase_; + rtl::OUString directBase_; std::vector< Member > directMembers_; }; @@ -187,26 +187,26 @@ class LO_DLLPUBLIC_UNOIDL PolymorphicStructTypeTemplateEntity: public: struct Member { Member( - OUString const & theName, OUString const & theType, + rtl::OUString const & theName, rtl::OUString const & theType, bool theParameterized): name(theName), type(theType), parameterized(theParameterized) {} - OUString name; + rtl::OUString name; - OUString type; + rtl::OUString type; bool parameterized; }; SAL_DLLPRIVATE PolymorphicStructTypeTemplateEntity( - bool published, std::vector< OUString > const & typeParameters, + bool published, std::vector< rtl::OUString > const & typeParameters, std::vector< Member > const & members): PublishableEntity(SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE, published), typeParameters_(typeParameters), members_(members) {} - std::vector< OUString > const & getTypeParameters() const + std::vector< rtl::OUString > const & getTypeParameters() const { return typeParameters_; } std::vector< Member > const & getMembers() const { return members_; } @@ -214,30 +214,30 @@ public: private: virtual SAL_DLLPRIVATE ~PolymorphicStructTypeTemplateEntity() throw (); - std::vector< OUString > typeParameters_; + std::vector< rtl::OUString > typeParameters_; std::vector< Member > members_; }; class LO_DLLPUBLIC_UNOIDL ExceptionTypeEntity: public PublishableEntity { public: struct Member { - Member(OUString const & theName, OUString const & theType): + Member(rtl::OUString const & theName, rtl::OUString const & theType): name(theName), type(theType) {} - OUString name; + rtl::OUString name; - OUString type; + rtl::OUString type; }; SAL_DLLPRIVATE ExceptionTypeEntity( - bool published, OUString const & directBase, + bool published, rtl::OUString const & directBase, std::vector< Member > const & directMembers): PublishableEntity(SORT_EXCEPTION_TYPE, published), directBase_(directBase), directMembers_(directMembers) {} - OUString getDirectBase() const { return directBase_; } + rtl::OUString getDirectBase() const { return directBase_; } std::vector< Member > const & getDirectMembers() const { return directMembers_; } @@ -245,7 +245,7 @@ public: private: virtual SAL_DLLPRIVATE ~ExceptionTypeEntity() throw (); - OUString directBase_; + rtl::OUString directBase_; std::vector< Member > directMembers_; }; @@ -253,26 +253,26 @@ class LO_DLLPUBLIC_UNOIDL InterfaceTypeEntity: public PublishableEntity { public: struct Attribute { Attribute( - OUString const & theName, OUString const & theType, + rtl::OUString const & theName, rtl::OUString const & theType, bool theBound, bool theReadOnly, - std::vector< OUString > const & theGetExceptions, - std::vector< OUString > const & theSetExceptions): + std::vector< rtl::OUString > const & theGetExceptions, + std::vector< rtl::OUString > const & theSetExceptions): name(theName), type(theType), bound(theBound), readOnly(theReadOnly), getExceptions(theGetExceptions), setExceptions(theSetExceptions) { assert(!theReadOnly || theSetExceptions.empty()); } - OUString name; + rtl::OUString name; - OUString type; + rtl::OUString type; bool bound; bool readOnly; - std::vector< OUString > getExceptions; + std::vector< rtl::OUString > getExceptions; - std::vector< OUString > setExceptions; + std::vector< rtl::OUString > setExceptions; }; struct Method { @@ -280,39 +280,39 @@ public: enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_IN_OUT }; Parameter( - OUString const & theName, OUString const & theType, + rtl::OUString const & theName, rtl::OUString const & theType, Direction theDirection): name(theName), type(theType), direction(theDirection) {} - OUString name; + rtl::OUString name; - OUString type; + rtl::OUString type; Direction direction; }; Method( - OUString const & theName, OUString const & theReturnType, + rtl::OUString const & theName, rtl::OUString const & theReturnType, std::vector< Parameter > const & theParameters, - std::vector< OUString > const & theExceptions): + std::vector< rtl::OUString > const & theExceptions): name(theName), returnType(theReturnType), parameters(theParameters), exceptions(theExceptions) {} - OUString name; + rtl::OUString name; - OUString returnType; + rtl::OUString returnType; std::vector< Parameter > parameters; - std::vector< OUString > exceptions; + std::vector< rtl::OUString > exceptions; }; SAL_DLLPRIVATE InterfaceTypeEntity( bool published, - std::vector< OUString > const & directMandatoryBases, - std::vector< OUString > const & directOptionalBases, + std::vector< rtl::OUString > const & directMandatoryBases, + std::vector< rtl::OUString > const & directOptionalBases, std::vector< Attribute > const & directAttributes, std::vector< Method > const & directMethods): PublishableEntity(SORT_INTERFACE_TYPE, published), @@ -321,10 +321,10 @@ public: directAttributes_(directAttributes), directMethods_(directMethods) {} - std::vector< OUString > const & getDirectMandatoryBases() const + std::vector< rtl::OUString > const & getDirectMandatoryBases() const { return directMandatoryBases_; } - std::vector< OUString > const & getDirectOptionalBases() const + std::vector< rtl::OUString > const & getDirectOptionalBases() const { return directOptionalBases_; } std::vector< Attribute > const & getDirectAttributes() const @@ -336,24 +336,24 @@ public: private: virtual SAL_DLLPRIVATE ~InterfaceTypeEntity() throw (); - std::vector< OUString > directMandatoryBases_; - std::vector< OUString > directOptionalBases_; + std::vector< rtl::OUString > directMandatoryBases_; + std::vector< rtl::OUString > directOptionalBases_; std::vector< Attribute > directAttributes_; std::vector< Method > directMethods_; }; class LO_DLLPUBLIC_UNOIDL TypedefEntity: public PublishableEntity { public: - SAL_DLLPRIVATE TypedefEntity(bool published, OUString const & type): + SAL_DLLPRIVATE TypedefEntity(bool published, rtl::OUString const & type): PublishableEntity(SORT_TYPEDEF, published), type_(type) {} - OUString getType() const { return type_; } + rtl::OUString getType() const { return type_; } private: virtual SAL_DLLPRIVATE ~TypedefEntity() throw (); - OUString type_; + rtl::OUString type_; }; struct LO_DLLPUBLIC_UNOIDL ConstantValue { @@ -412,11 +412,11 @@ struct LO_DLLPUBLIC_UNOIDL ConstantValue { class LO_DLLPUBLIC_UNOIDL ConstantGroupEntity: public PublishableEntity { public: struct Member { - Member(OUString const & theName, ConstantValue const & theValue): + Member(rtl::OUString const & theName, ConstantValue const & theValue): name(theName), value(theValue) {} - OUString name; + rtl::OUString name; ConstantValue value; }; @@ -441,14 +441,14 @@ public: struct Constructor { struct Parameter { Parameter( - OUString const & theName, OUString const & theType, + rtl::OUString const & theName, rtl::OUString const & theType, bool theRest): name(theName), type(theType), rest(theRest) {} - OUString name; + rtl::OUString name; - OUString type; + rtl::OUString type; bool rest; }; @@ -456,30 +456,30 @@ public: Constructor(): defaultConstructor(true) {} Constructor( - OUString const & theName, + rtl::OUString const & theName, std::vector< Parameter > const & theParameters, - std::vector< OUString > const & theExceptions): + std::vector< rtl::OUString > const & theExceptions): name(theName), parameters(theParameters), exceptions(theExceptions), defaultConstructor(false) {} - OUString name; + rtl::OUString name; std::vector< Parameter > parameters; - std::vector< OUString > exceptions; + std::vector< rtl::OUString > exceptions; bool defaultConstructor; }; SAL_DLLPRIVATE SingleInterfaceBasedServiceEntity( - bool published, OUString const & base, + bool published, rtl::OUString const & base, std::vector< Constructor > const & constructors): PublishableEntity(SORT_SINGLE_INTERFACE_BASED_SERVICE, published), base_(base), constructors_(constructors) {} - OUString getBase() const { return base_; } + rtl::OUString getBase() const { return base_; } std::vector< Constructor > const & getConstructors() const { return constructors_; } @@ -487,7 +487,7 @@ public: private: virtual SAL_DLLPRIVATE ~SingleInterfaceBasedServiceEntity() throw (); - OUString base_; + rtl::OUString base_; std::vector< Constructor > constructors_; }; @@ -509,24 +509,24 @@ public: }; Property( - OUString const & theName, OUString const & theType, + rtl::OUString const & theName, rtl::OUString const & theType, Attributes theAttributes): name(theName), type(theType), attributes(theAttributes) {} - OUString name; + rtl::OUString name; - OUString type; + rtl::OUString type; Attributes attributes; }; SAL_DLLPRIVATE AccumulationBasedServiceEntity( bool published, - std::vector< OUString > const & directMandatoryBaseServices, - std::vector< OUString > const & directOptionalBaseServices, - std::vector< OUString > const & directMandatoryBaseInterfaces, - std::vector< OUString > const & directOptionalBaseInterfaces, + std::vector< rtl::OUString > const & directMandatoryBaseServices, + std::vector< rtl::OUString > const & directOptionalBaseServices, + std::vector< rtl::OUString > const & directMandatoryBaseInterfaces, + std::vector< rtl::OUString > const & directOptionalBaseInterfaces, std::vector< Property > const & directProperties): PublishableEntity(SORT_ACCUMULATION_BASED_SERVICE, published), directMandatoryBaseServices_(directMandatoryBaseServices), @@ -536,17 +536,17 @@ public: directProperties_(directProperties) {} - std::vector< OUString > const & getDirectMandatoryBaseServices() const + std::vector< rtl::OUString > const & getDirectMandatoryBaseServices() const { return directMandatoryBaseServices_; } - std::vector< OUString > const & getDirectOptionalBaseServices() const + std::vector< rtl::OUString > const & getDirectOptionalBaseServices() const { return directOptionalBaseServices_; } - std::vector< OUString > const & getDirectMandatoryBaseInterfaces() + std::vector< rtl::OUString > const & getDirectMandatoryBaseInterfaces() const { return directMandatoryBaseInterfaces_; } - std::vector< OUString > const & getDirectOptionalBaseInterfaces() const + std::vector< rtl::OUString > const & getDirectOptionalBaseInterfaces() const { return directOptionalBaseInterfaces_; } std::vector< Property > const & getDirectProperties() const @@ -555,10 +555,10 @@ public: private: virtual SAL_DLLPRIVATE ~AccumulationBasedServiceEntity() throw (); - std::vector< OUString > directMandatoryBaseServices_; - std::vector< OUString > directOptionalBaseServices_; - std::vector< OUString > directMandatoryBaseInterfaces_; - std::vector< OUString > directOptionalBaseInterfaces_; + std::vector< rtl::OUString > directMandatoryBaseServices_; + std::vector< rtl::OUString > directOptionalBaseServices_; + std::vector< rtl::OUString > directMandatoryBaseInterfaces_; + std::vector< rtl::OUString > directOptionalBaseInterfaces_; std::vector< Property > directProperties_; }; @@ -567,33 +567,33 @@ class LO_DLLPUBLIC_UNOIDL InterfaceBasedSingletonEntity: { public: SAL_DLLPRIVATE InterfaceBasedSingletonEntity( - bool published, OUString const & base): + bool published, rtl::OUString const & base): PublishableEntity(SORT_INTERFACE_BASED_SINGLETON, published), base_(base) {} - OUString getBase() const { return base_; } + rtl::OUString getBase() const { return base_; } private: virtual SAL_DLLPRIVATE ~InterfaceBasedSingletonEntity() throw (); - OUString base_; + rtl::OUString base_; }; class LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity: public PublishableEntity { public: SAL_DLLPRIVATE ServiceBasedSingletonEntity( - bool published, OUString const & base): + bool published, rtl::OUString const & base): PublishableEntity(SORT_SERVICE_BASED_SINGLETON, published), base_(base) {} - OUString getBase() const { return base_; } + rtl::OUString getBase() const { return base_; } private: virtual SAL_DLLPRIVATE ~ServiceBasedSingletonEntity() throw (); - OUString base_; + rtl::OUString base_; }; class LO_DLLPUBLIC_UNOIDL Provider: public salhelper::SimpleReferenceObject { @@ -602,7 +602,7 @@ public: virtual rtl::Reference< MapCursor > createRootCursor() const = 0; // throws FileFormatException: - virtual rtl::Reference< Entity > findEntity(OUString const & name) + virtual rtl::Reference< Entity > findEntity(rtl::OUString const & name) const = 0; protected: @@ -618,7 +618,10 @@ public: void addProvider(rtl::Reference< Provider > const & provider); // throws FileFormatException: - rtl::Reference< Entity > findEntity(OUString const & name) const; + rtl::Reference< Entity > findEntity(rtl::OUString const & name) const; + + // throws FileFormatException: + rtl::Reference< MapCursor > createCursor(rtl::OUString const & name) const; private: virtual SAL_DLLPRIVATE ~Manager() throw (); @@ -628,7 +631,7 @@ private: // throws FileFormatException, NoSuchFileException: LO_DLLPUBLIC_UNOIDL rtl::Reference< Provider > loadProvider( - rtl::Reference< Manager > const & manager, OUString const & uri); + rtl::Reference< Manager > const & manager, rtl::OUString const & uri); } diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx index 19f2f41070e0..2b92afd50b31 100644 --- a/unoidl/source/unoidl.cxx +++ b/unoidl/source/unoidl.cxx @@ -9,6 +9,7 @@ #include "sal/config.h" +#include #include #include "rtl/ref.hxx" @@ -19,6 +20,47 @@ namespace unoidl { +namespace { + +class AggregatingCursor: public MapCursor { +public: + AggregatingCursor( + std::vector< rtl::Reference< MapCursor > > const & cursors): + cursors_(cursors), iterator_(cursors_.begin()) + {} + +private: + virtual ~AggregatingCursor() throw () {} + + virtual rtl::Reference< Entity > getNext(rtl::OUString * name); + + std::vector< rtl::Reference< MapCursor > > cursors_; + std::vector< rtl::Reference< MapCursor > >::iterator iterator_; + std::set< rtl::OUString > seenMembers; +}; + +rtl::Reference< Entity > AggregatingCursor::getNext(rtl::OUString * name) { + for (;;) { + if (iterator_ == cursors_.end()) { + return rtl::Reference< Entity >(); + } + rtl::OUString n; + rtl::Reference< Entity > ent((*iterator_)->getNext(&n)); + if (ent.is()) { + if (seenMembers.insert(n).second) { + if (name != 0) { + *name = n; + } + return ent; + } + } else { + ++iterator_; + } + } +} + +} + NoSuchFileException::~NoSuchFileException() throw () {} FileFormatException::~FileFormatException() throw () {} @@ -77,7 +119,7 @@ void Manager::addProvider(rtl::Reference< Provider > const & provider) { providers_.push_back(provider); } -rtl::Reference< Entity > Manager::findEntity(OUString const & name) const { +rtl::Reference< Entity > Manager::findEntity(rtl::OUString const & name) const { //TODO: add caching for (std::vector< rtl::Reference< Provider > >::const_iterator i( providers_.begin()); @@ -91,6 +133,28 @@ rtl::Reference< Entity > Manager::findEntity(OUString const & name) const { return rtl::Reference< Entity >(); } +rtl::Reference< MapCursor > Manager::createCursor(rtl::OUString const & name) + const +{ + std::vector< rtl::Reference< MapCursor > > curs; + for (std::vector< rtl::Reference< Provider > >::const_iterator i( + providers_.begin()); + i != providers_.end(); ++i) + { + if (name.isEmpty()) { + curs.push_back((*i)->createRootCursor()); + } else { + rtl::Reference< Entity > ent((*i)->findEntity(name)); + if (ent.is() && ent->getSort() == Entity::SORT_MODULE) { + curs.push_back( + static_cast< ModuleEntity * >(ent.get())->createCursor()); + } + } + } + return curs.empty() + ? rtl::Reference< MapCursor >() : new AggregatingCursor(curs); +} + Manager::~Manager() throw () {} } -- cgit