From 6292bba6debaeb5c1bbbabfb77606296c894ec28 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 16 Sep 2013 22:30:31 +0200 Subject: Rename SourceProvider -> SourceTreeProvider Change-Id: Ic864f9c6f3dbbe9f75bdae76818c00f62825182d --- unoidl/source/sourceprovider.cxx | 150 ---------------------------------- unoidl/source/sourceprovider.hxx | 46 ----------- unoidl/source/sourcetreeprovider.cxx | 152 +++++++++++++++++++++++++++++++++++ unoidl/source/sourcetreeprovider.hxx | 46 +++++++++++ unoidl/source/unoidl.cxx | 4 +- 5 files changed, 200 insertions(+), 198 deletions(-) delete mode 100755 unoidl/source/sourceprovider.cxx delete mode 100644 unoidl/source/sourceprovider.hxx create mode 100755 unoidl/source/sourcetreeprovider.cxx create mode 100644 unoidl/source/sourcetreeprovider.hxx (limited to 'unoidl/source') diff --git a/unoidl/source/sourceprovider.cxx b/unoidl/source/sourceprovider.cxx deleted file mode 100755 index 64428eb72839..000000000000 --- a/unoidl/source/sourceprovider.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "sal/config.h" - -#include -#include - -#include "osl/file.h" -#include "osl/file.hxx" -#include "rtl/character.hxx" -#include "rtl/ref.hxx" -#include "rtl/ustrbuf.hxx" -#include "rtl/ustring.hxx" -#include "unoidl/unoidl.hxx" - -#include "sourceprovider-parser-requires.hxx" -#include "sourceprovider-parser.hxx" -#include "sourceprovider-scanner.hxx" -#include "sourceprovider.hxx" - -namespace unoidl { namespace detail { - -namespace { - -class Cursor: public MapCursor { -public: - Cursor() {} - -private: - virtual ~Cursor() throw () {} - - virtual rtl::Reference getNext(OUString *) - { return rtl::Reference(); } //TODO -}; - -class SourceModuleEntity: public ModuleEntity { -public: - SourceModuleEntity() {} - -private: - virtual ~SourceModuleEntity() throw () {} - - virtual std::vector getMemberNames() const - { return std::vector(); } //TODO - - virtual rtl::Reference< MapCursor > createCursor() const - { return new Cursor; } -}; - -} - -SourceProvider::SourceProvider( - rtl::Reference const & manager, OUString const & uri): - manager_(manager), uri_(uri.endsWith("/") ? uri : uri + "/") -{} - -rtl::Reference SourceProvider::createRootCursor() const { - return new Cursor; -} - -rtl::Reference SourceProvider::findEntity(OUString const & name) const { - std::map< OUString, rtl::Reference >::iterator ci( - cache_.find(name)); - if (ci != cache_.end()) { - return ci->second; - } - // Match name against - // name ::= identifier ("." identifier)* - // identifier ::= upper-blocks | lower-block - // upper-blocks ::= upper ("_"? alnum)* - // lower-block :== lower alnum* - // alnum ::= digit | upper | lower - // digit ::= "0"--"9" - // upper ::= "A"--"Z" - // lower ::= "a"--"z" - OUStringBuffer buf(name); - sal_Int32 start = 0; - sal_Int32 i = 0; - for (; i != name.getLength(); ++i) { - sal_Unicode c = name[i]; - if (c == '.') { - assert(i == start || i != 0); - if (i == start || name[i - 1] == '_') { - throw FileFormatException( //TODO - "", "Illegal UNOIDL identifier \"" + name + "\""); - } - buf[i] = '/'; - start = i + 1; - } else if (c == '_') { - assert(i == start || i != 0); - if (i == start || name[i - 1] == '_' - || !rtl::isAsciiUpperCase(name[start])) - { - throw FileFormatException( //TODO - "", "Illegal UNOIDL identifier \"" + name + "\""); - } - } else if (rtl::isAsciiDigit(c)) { - if (i == start) { - throw FileFormatException( //TODO - "", "Illegal UNOIDL identifier \"" + name + "\""); - } - } else if (!rtl::isAsciiAlpha(c)) { - throw FileFormatException( //TODO - "", "Illegal UNOIDL identifier \"" + name + "\""); - } - } - if (i == start) { - throw FileFormatException( //TODO - "", "Illegal UNOIDL identifier \"" + name + "\""); - } - OUString uri(uri_ + buf.makeStringAndClear()); - rtl::Reference ent; - osl::DirectoryItem item; - osl::FileStatus status(osl_FileStatus_Mask_Type); - if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None - && item.getFileStatus(status) == osl::FileBase::E_None - && status.getFileType() == osl::FileStatus::Directory) - { - ent = new SourceModuleEntity; - } else { - uri += ".idl"; - SourceProviderScannerData data(manager_); - if (parse(uri, &data)) { - std::map::const_iterator i( - data.entities.find(name)); - if (i != data.entities.end()) { - ent = i->second.entity; - } - SAL_WARN_IF( - !ent.is(), "unoidl", - "<" << uri << "> does not define entity " << name); - } - } - cache_.insert( - std::map< OUString, rtl::Reference >::value_type(name, ent)); - return ent; -} - -SourceProvider::~SourceProvider() throw () {} - -} } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unoidl/source/sourceprovider.hxx b/unoidl/source/sourceprovider.hxx deleted file mode 100644 index e7ee92f64a0f..000000000000 --- a/unoidl/source/sourceprovider.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_UNOIDL_SOURCEPROVIDER_HXX -#define INCLUDED_UNOIDL_SOURCEPROVIDER_HXX - -#include "sal/config.h" - -#include - -#include "rtl/ref.hxx" -#include "unoidl/unoidl.hxx" - -namespace unoidl { namespace detail { - -class SourceProvider: public Provider { -public: - // throws FileFormatException, NoSuchFileException: - SourceProvider( - rtl::Reference const & manager, OUString const & uri); - - // throws FileFormatException: - virtual rtl::Reference createRootCursor() const; - - // throws FileFormatException: - virtual rtl::Reference findEntity(OUString const & name) const; - -private: - virtual ~SourceProvider() throw (); - - rtl::Reference manager_; - OUString uri_; - mutable std::map< OUString, rtl::Reference > cache_; //TODO: at manager -}; - -} } - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unoidl/source/sourcetreeprovider.cxx b/unoidl/source/sourcetreeprovider.cxx new file mode 100755 index 000000000000..d389f0cdff0f --- /dev/null +++ b/unoidl/source/sourcetreeprovider.cxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "sal/config.h" + +#include +#include + +#include "osl/file.h" +#include "osl/file.hxx" +#include "rtl/character.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustrbuf.hxx" +#include "rtl/ustring.hxx" +#include "unoidl/unoidl.hxx" + +#include "sourceprovider-parser-requires.hxx" +#include "sourceprovider-parser.hxx" +#include "sourceprovider-scanner.hxx" +#include "sourcetreeprovider.hxx" + +namespace unoidl { namespace detail { + +namespace { + +class Cursor: public MapCursor { +public: + Cursor() {} + +private: + virtual ~Cursor() throw () {} + + virtual rtl::Reference getNext(OUString *) + { return rtl::Reference(); } //TODO +}; + +class SourceModuleEntity: public ModuleEntity { +public: + SourceModuleEntity() {} + +private: + virtual ~SourceModuleEntity() throw () {} + + virtual std::vector getMemberNames() const + { return std::vector(); } //TODO + + virtual rtl::Reference< MapCursor > createCursor() const + { return new Cursor; } +}; + +} + +SourceTreeProvider::SourceTreeProvider( + rtl::Reference const & manager, OUString const & uri): + manager_(manager), uri_(uri.endsWith("/") ? uri : uri + "/") +{} + +rtl::Reference SourceTreeProvider::createRootCursor() const { + return new Cursor; +} + +rtl::Reference SourceTreeProvider::findEntity(OUString const & name) + const +{ + std::map< OUString, rtl::Reference >::iterator ci( + cache_.find(name)); + if (ci != cache_.end()) { + return ci->second; + } + // Match name against + // name ::= identifier ("." identifier)* + // identifier ::= upper-blocks | lower-block + // upper-blocks ::= upper ("_"? alnum)* + // lower-block :== lower alnum* + // alnum ::= digit | upper | lower + // digit ::= "0"--"9" + // upper ::= "A"--"Z" + // lower ::= "a"--"z" + OUStringBuffer buf(name); + sal_Int32 start = 0; + sal_Int32 i = 0; + for (; i != name.getLength(); ++i) { + sal_Unicode c = name[i]; + if (c == '.') { + assert(i == start || i != 0); + if (i == start || name[i - 1] == '_') { + throw FileFormatException( //TODO + "", "Illegal UNOIDL identifier \"" + name + "\""); + } + buf[i] = '/'; + start = i + 1; + } else if (c == '_') { + assert(i == start || i != 0); + if (i == start || name[i - 1] == '_' + || !rtl::isAsciiUpperCase(name[start])) + { + throw FileFormatException( //TODO + "", "Illegal UNOIDL identifier \"" + name + "\""); + } + } else if (rtl::isAsciiDigit(c)) { + if (i == start) { + throw FileFormatException( //TODO + "", "Illegal UNOIDL identifier \"" + name + "\""); + } + } else if (!rtl::isAsciiAlpha(c)) { + throw FileFormatException( //TODO + "", "Illegal UNOIDL identifier \"" + name + "\""); + } + } + if (i == start) { + throw FileFormatException( //TODO + "", "Illegal UNOIDL identifier \"" + name + "\""); + } + OUString uri(uri_ + buf.makeStringAndClear()); + rtl::Reference ent; + osl::DirectoryItem item; + osl::FileStatus status(osl_FileStatus_Mask_Type); + if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None + && item.getFileStatus(status) == osl::FileBase::E_None + && status.getFileType() == osl::FileStatus::Directory) + { + ent = new SourceModuleEntity; + } else { + uri += ".idl"; + SourceProviderScannerData data(manager_); + if (parse(uri, &data)) { + std::map::const_iterator i( + data.entities.find(name)); + if (i != data.entities.end()) { + ent = i->second.entity; + } + SAL_WARN_IF( + !ent.is(), "unoidl", + "<" << uri << "> does not define entity " << name); + } + } + cache_.insert( + std::map< OUString, rtl::Reference >::value_type(name, ent)); + return ent; +} + +SourceTreeProvider::~SourceTreeProvider() throw () {} + +} } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unoidl/source/sourcetreeprovider.hxx b/unoidl/source/sourcetreeprovider.hxx new file mode 100644 index 000000000000..1bacad8a739d --- /dev/null +++ b/unoidl/source/sourcetreeprovider.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_UNOIDL_SOURCETREEPROVIDER_HXX +#define INCLUDED_UNOIDL_SOURCETREEPROVIDER_HXX + +#include "sal/config.h" + +#include + +#include "rtl/ref.hxx" +#include "unoidl/unoidl.hxx" + +namespace unoidl { namespace detail { + +class SourceTreeProvider: public Provider { +public: + // throws FileFormatException, NoSuchFileException: + SourceTreeProvider( + rtl::Reference const & manager, OUString const & uri); + + // throws FileFormatException: + virtual rtl::Reference createRootCursor() const; + + // throws FileFormatException: + virtual rtl::Reference findEntity(OUString const & name) const; + +private: + virtual ~SourceTreeProvider() throw (); + + rtl::Reference manager_; + OUString uri_; + mutable std::map< OUString, rtl::Reference > cache_; //TODO: at manager +}; + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx index e5c3c434a357..19b8a9cab646 100644 --- a/unoidl/source/unoidl.cxx +++ b/unoidl/source/unoidl.cxx @@ -20,7 +20,7 @@ #include "unoidl/unoidl.hxx" #include "legacyprovider.hxx" -#include "sourceprovider.hxx" +#include "sourcetreeprovider.hxx" #include "unoidlprovider.hxx" namespace unoidl { @@ -114,7 +114,7 @@ rtl::Reference< Provider > loadProvider( if (item.getFileStatus(status) == osl::FileBase::E_None && status.getFileType() == osl::FileStatus::Directory) { - return new detail::SourceProvider(manager, uri); + return new detail::SourceTreeProvider(manager, uri); } } try { -- cgit