diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-11-25 17:25:08 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-11-25 17:26:17 +0100 |
commit | 454f3f72c5d7a6f92debb4e4756e330397d507e6 (patch) | |
tree | 0458a867390cee31e00ebba7d1246b058341de81 /unoidl/source/sourceprovider-scanner.hxx | |
parent | e00562d9835bd82d74ef0301ea7425ff769915df (diff) |
Fix unoidl sourceprovider interface base and member checks
...and enable tests shared with idlc
Change-Id: I422b16c9b2636835d276cc2085cb640073894c97
Diffstat (limited to 'unoidl/source/sourceprovider-scanner.hxx')
-rw-r--r-- | unoidl/source/sourceprovider-scanner.hxx | 78 |
1 files changed, 58 insertions, 20 deletions
diff --git a/unoidl/source/sourceprovider-scanner.hxx b/unoidl/source/sourceprovider-scanner.hxx index 5edd984efe51..14ac15421f08 100644 --- a/unoidl/source/sourceprovider-scanner.hxx +++ b/unoidl/source/sourceprovider-scanner.hxx @@ -14,6 +14,7 @@ #include <cassert> #include <map> +#include <set> #include <vector> #include "rtl/ref.hxx" @@ -27,6 +28,8 @@ namespace unoidl { namespace detail { +struct SourceProviderScannerData; + class SourceProviderEntityPad: public salhelper::SimpleReferenceObject { public: bool isPublished() const { return published_; } @@ -103,41 +106,76 @@ private: class SourceProviderInterfaceTypeEntityPad: public SourceProviderEntityPad { public: - struct Base { - Base( + struct DirectBase { + DirectBase( OUString const & theName, rtl::Reference<unoidl::InterfaceTypeEntity> const & theEntity, std::vector<OUString> const & theAnnotations): name(theName), entity(theEntity), annotations(theAnnotations) - {} + { assert(theEntity.is()); } OUString name; rtl::Reference<unoidl::InterfaceTypeEntity> entity; std::vector<OUString> annotations; }; - SourceProviderInterfaceTypeEntityPad( - bool published, OUString singleBaseName, - rtl::Reference<unoidl::InterfaceTypeEntity> const & singleBaseEntity): - SourceProviderEntityPad(published), - singleBase(!singleBaseName.isEmpty()) - { - assert(singleBaseName.isEmpty() != (bool) singleBaseEntity.is()); - if (singleBase) { - mandatoryBases.push_back( - Base( - singleBaseName, singleBaseEntity, std::vector<OUString>())); - } - } + enum BaseKind { + BASE_INDIRECT_OPTIONAL, BASE_DIRECT_OPTIONAL, BASE_INDIRECT_MANDATORY, + BASE_DIRECT_MANDATORY + }; + + struct Member { + OUString mandatory; + std::set<OUString> optional; + + explicit Member(OUString theMandatory): mandatory(theMandatory) {} + }; + + SourceProviderInterfaceTypeEntityPad(bool published, bool theSingleBase): + SourceProviderEntityPad(published), singleBase(theSingleBase) + {} + + bool addDirectBase( + YYLTYPE location, yyscan_t yyscanner, SourceProviderScannerData * data, + DirectBase const & base, bool optional); + + bool addDirectMember( + YYLTYPE location, yyscan_t yyscanner, SourceProviderScannerData * data, + OUString const & name); bool singleBase; - std::vector<Base> mandatoryBases; - std::vector<Base> optionalBases; - std::vector<unoidl::InterfaceTypeEntity::Attribute> attributes; - std::vector<unoidl::InterfaceTypeEntity::Method> methods; + std::vector<DirectBase> directMandatoryBases; + std::vector<DirectBase> directOptionalBases; + std::vector<unoidl::InterfaceTypeEntity::Attribute> directAttributes; + std::vector<unoidl::InterfaceTypeEntity::Method> directMethods; + std::map<OUString, BaseKind> allBases; + std::map<OUString, Member> allMembers; private: virtual ~SourceProviderInterfaceTypeEntityPad() throw () {} + + bool checkBaseClashes( + YYLTYPE location, yyscan_t yyscanner, SourceProviderScannerData * data, + OUString const & name, + rtl::Reference<unoidl::InterfaceTypeEntity> const & entity, + bool direct, bool optional, bool outerOptional, + std::set<OUString> * seen) const; + + bool checkMemberClashes( + YYLTYPE location, yyscan_t yyscanner, SourceProviderScannerData * data, + OUString const & interfaceName, OUString const & memberName, + bool checkOptional) const; + + bool addBase( + YYLTYPE location, yyscan_t yyscanner, SourceProviderScannerData * data, + OUString const & directBaseName, OUString const & name, + rtl::Reference<unoidl::InterfaceTypeEntity> const & entity, bool direct, + bool optional); + + bool addOptionalBaseMembers( + YYLTYPE location, yyscan_t yyscanner, SourceProviderScannerData * data, + OUString const & name, + rtl::Reference<unoidl::InterfaceTypeEntity> const & entity); }; class SourceProviderConstantGroupEntityPad: public SourceProviderEntityPad { |