Files
libreoffice/unoidl/source/unoidl.cxx

166 lines
4.5 KiB
C++
Raw Normal View History

/* -*- 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"
[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<X>, 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
2013-04-08 08:45:37 +02:00
#include <set>
#include <vector>
#include "osl/mutex.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "unoidl/legacyprovider.hxx"
#include "unoidl/unoidl.hxx"
#include "unoidl/unoidlprovider.hxx"
namespace unoidl {
[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<X>, 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
2013-04-08 08:45:37 +02:00
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 () {}
Entity::~Entity() throw () {}
MapCursor::~MapCursor() throw () {}
ModuleEntity::~ModuleEntity() throw () {}
PublishableEntity::~PublishableEntity() throw () {}
EnumTypeEntity::~EnumTypeEntity() throw () {}
PlainStructTypeEntity::~PlainStructTypeEntity() throw () {}
PolymorphicStructTypeTemplateEntity::~PolymorphicStructTypeTemplateEntity()
throw ()
{}
ExceptionTypeEntity::~ExceptionTypeEntity() throw () {}
InterfaceTypeEntity::~InterfaceTypeEntity() throw () {}
TypedefEntity::~TypedefEntity() throw () {}
ConstantGroupEntity::~ConstantGroupEntity() throw () {}
SingleInterfaceBasedServiceEntity::~SingleInterfaceBasedServiceEntity() throw ()
{}
AccumulationBasedServiceEntity::~AccumulationBasedServiceEntity() throw () {}
InterfaceBasedSingletonEntity::~InterfaceBasedSingletonEntity() throw () {}
ServiceBasedSingletonEntity::~ServiceBasedSingletonEntity() throw () {}
Provider::~Provider() throw () {}
rtl::Reference< Provider > loadProvider(
rtl::Reference< Manager > const & manager, OUString const & uri)
{
try {
return new UnoidlProvider(uri);
} catch (FileFormatException & e) {
SAL_INFO(
"unoidl",
"FileFormatException \"" << e.getDetail() << "\", retrying <" << uri
<< "> as legacy format");
return new LegacyProvider(manager, uri);
}
}
void Manager::addProvider(rtl::Reference< Provider > const & provider) {
assert(provider.is());
osl::MutexGuard g(mutex_);
providers_.push_back(provider);
}
[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<X>, 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
2013-04-08 08:45:37 +02:00
rtl::Reference< Entity > Manager::findEntity(rtl::OUString const & name) const {
//TODO: caching? (here or in cppuhelper::TypeManager?)
osl::MutexGuard g(mutex_);
for (std::vector< rtl::Reference< Provider > >::const_iterator i(
providers_.begin());
i != providers_.end(); ++i)
{
rtl::Reference< Entity > ent((*i)->findEntity(name));
if (ent.is()) {
return ent;
}
}
return rtl::Reference< Entity >();
}
[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<X>, 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
2013-04-08 08:45:37 +02:00
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 () {}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */