[Libreoffice-commits] core.git: cppuhelper/inc cppuhelper/Library_cppuhelper.mk cppuhelper/Package_inc.mk cppuhelper/source

Stephan Bergmann sbergman at redhat.com
Fri Feb 22 08:25:41 PST 2013


 cppuhelper/Library_cppuhelper.mk              |    2 
 cppuhelper/Package_inc.mk                     |    1 
 cppuhelper/inc/cppuhelper/unoidl.hxx          |  527 ++++++
 cppuhelper/source/typedescriptionprovider.cxx | 2081 ++++----------------------
 cppuhelper/source/unoidl.cxx                  |   63 
 cppuhelper/source/unoidlprovider.cxx          | 1363 +++++++++++++++++
 cppuhelper/source/unoidlprovider.hxx          |   54 
 7 files changed, 2399 insertions(+), 1692 deletions(-)

New commits:
commit fa559f1c416884015d1d83d0a7ac8803e745d9df
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Feb 22 17:20:18 2013 +0100

    WIP: Experimental new binary type.rdb format
    
    Prepare cppuhelper/unoidl.hxx for direct consumption by code that currently uses
    registry/ to read .rdb files (e.g., codemaker).  The additional exports will
    need to be properly hidden from general users in gcc3.map (and documented,
    and...).
    
    Change-Id: I5cdff6fe69ab88435972e16dbda2311450f20ede

diff --git a/cppuhelper/Library_cppuhelper.mk b/cppuhelper/Library_cppuhelper.mk
index 500bac3..2b849a1 100644
--- a/cppuhelper/Library_cppuhelper.mk
+++ b/cppuhelper/Library_cppuhelper.mk
@@ -76,6 +76,8 @@ $(eval $(call gb_Library_add_exception_objects,cppuhelper,\
 	cppuhelper/source/tdmgr \
 	cppuhelper/source/typedescriptionprovider \
 	cppuhelper/source/typeprovider \
+	cppuhelper/source/unoidl \
+	cppuhelper/source/unoidlprovider \
 	cppuhelper/source/unourl \
 	cppuhelper/source/weak \
 ))
diff --git a/cppuhelper/Package_inc.mk b/cppuhelper/Package_inc.mk
index af5a823..420eecf 100644
--- a/cppuhelper/Package_inc.mk
+++ b/cppuhelper/Package_inc.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/queryinterface.h
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/shlib.hxx,cppuhelper/shlib.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/supportsservice.hxx,cppuhelper/supportsservice.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/typeprovider.hxx,cppuhelper/typeprovider.hxx))
+$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/unoidl.hxx,cppuhelper/unoidl.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/unourl.hxx,cppuhelper/unourl.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/weakagg.hxx,cppuhelper/weakagg.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/weak.hxx,cppuhelper/weak.hxx))
diff --git a/cppuhelper/inc/cppuhelper/unoidl.hxx b/cppuhelper/inc/cppuhelper/unoidl.hxx
new file mode 100644
index 0000000..589f846
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/unoidl.hxx
@@ -0,0 +1,527 @@
+/* -*- 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_CPPUHELPER_UNOIDL_HXX
+#define INCLUDED_CPPUHELPER_UNOIDL_HXX
+
+#include "sal/config.h"
+
+#include <cassert>
+#include <vector>
+
+#include "com/sun/star/uno/Any.hxx"
+#include "cppuhelper/cppuhelperdllapi.h"
+#include "rtl/ref.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "salhelper/simplereferenceobject.hxx"
+
+namespace cppu { namespace unoidl {
+
+class CPPUHELPER_DLLPUBLIC Entity: public salhelper::SimpleReferenceObject {
+public:
+    enum Sort {
+        SORT_MODULE,
+        SORT_ENUM_TYPE,
+        SORT_PLAIN_STRUCT_TYPE,
+        SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE,
+        SORT_EXCEPTION_TYPE,
+        SORT_INTERFACE_TYPE,
+        SORT_TYPEDEF,
+        SORT_CONSTANT_GROUP,
+        SORT_SINGLE_INTERFACE_BASED_SERVICE,
+        SORT_ACCUMULATION_BASED_SERVICE,
+        SORT_INTERFACE_BASED_SINGLETON,
+        SORT_SERVICE_BASED_SINGLETON
+    };
+
+    Sort getSort() const { return sort_; }
+
+protected:
+    explicit SAL_DLLPRIVATE Entity(Sort sort): sort_(sort) {}
+
+    virtual SAL_DLLPRIVATE ~Entity() throw ();
+
+private:
+    Sort sort_;
+};
+
+class CPPUHELPER_DLLPUBLIC MapCursor: public salhelper::SimpleReferenceObject {
+public:
+    virtual rtl::Reference< Entity > getNext(rtl::OUString * name) = 0;
+
+protected:
+    SAL_DLLPRIVATE MapCursor() {}
+
+    virtual SAL_DLLPRIVATE ~MapCursor() throw();
+};
+
+class CPPUHELPER_DLLPUBLIC ModuleEntity: public Entity {
+public:
+    virtual std::vector< rtl::OUString > getMemberNames() const = 0;
+
+    virtual rtl::Reference< MapCursor > createCursor() const = 0;
+
+protected:
+    SAL_DLLPRIVATE ModuleEntity(): Entity(SORT_MODULE) {}
+
+    virtual SAL_DLLPRIVATE ~ModuleEntity() throw ();
+};
+
+class CPPUHELPER_DLLPUBLIC PublishableEntity: public Entity {
+public:
+    bool isPublished() const { return published_; }
+
+protected:
+    SAL_DLLPRIVATE PublishableEntity(Sort sort, bool published):
+        Entity(sort), published_(published)
+    {}
+
+    virtual SAL_DLLPRIVATE ~PublishableEntity() throw ();
+
+private:
+    bool published_;
+};
+
+class CPPUHELPER_DLLPUBLIC EnumTypeEntity: public PublishableEntity {
+public:
+    struct Member {
+        Member(rtl::OUString const & theName, sal_Int32 theValue):
+            name(theName), value(theValue)
+        {}
+
+        rtl::OUString name;
+
+        sal_Int32 value;
+    };
+
+    SAL_DLLPRIVATE EnumTypeEntity(
+        bool published, std::vector< Member > const & members):
+        PublishableEntity(SORT_ENUM_TYPE, published), members_(members)
+    { assert(!members.empty()); }
+
+    std::vector< Member > const & getMembers() const { return members_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~EnumTypeEntity() throw ();
+
+    std::vector< Member > members_;
+};
+
+class CPPUHELPER_DLLPUBLIC PlainStructTypeEntity: public PublishableEntity {
+public:
+    struct Member {
+        Member(rtl::OUString const & theName, rtl::OUString const & theType):
+            name(theName), type(theType)
+        {}
+
+        rtl::OUString name;
+
+        rtl::OUString type;
+    };
+
+    SAL_DLLPRIVATE PlainStructTypeEntity(
+        bool published, rtl::OUString const & directBase,
+        std::vector< Member > const & directMembers):
+        PublishableEntity(SORT_PLAIN_STRUCT_TYPE, published),
+        directBase_(directBase), directMembers_(directMembers)
+    {}
+
+    rtl::OUString getDirectBase() const { return directBase_; }
+
+    std::vector< Member > const & getDirectMembers() const
+    { return directMembers_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~PlainStructTypeEntity() throw ();
+
+    rtl::OUString directBase_;
+    std::vector< Member > directMembers_;
+};
+
+class CPPUHELPER_DLLPUBLIC PolymorphicStructTypeTemplateEntity:
+    public PublishableEntity
+{
+public:
+    struct Member {
+        Member(
+            rtl::OUString const & theName, rtl::OUString const & theType,
+            bool theParameterized):
+            name(theName), type(theType), parameterized(theParameterized)
+        {}
+
+        rtl::OUString name;
+
+        rtl::OUString type;
+
+        bool parameterized;
+    };
+
+    SAL_DLLPRIVATE PolymorphicStructTypeTemplateEntity(
+        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< rtl::OUString > const & getTypeParameters() const
+    { return typeParameters_; }
+
+    std::vector< Member > const & getMembers() const { return members_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~PolymorphicStructTypeTemplateEntity() throw ();
+
+    std::vector< rtl::OUString > typeParameters_;
+    std::vector< Member > members_;
+};
+
+class CPPUHELPER_DLLPUBLIC ExceptionTypeEntity: public PublishableEntity {
+public:
+    struct Member {
+        Member(rtl::OUString const & theName, rtl::OUString const & theType):
+            name(theName), type(theType)
+        {}
+
+        rtl::OUString name;
+
+        rtl::OUString type;
+    };
+
+    SAL_DLLPRIVATE ExceptionTypeEntity(
+        bool published, rtl::OUString const & directBase,
+        std::vector< Member > const & directMembers):
+        PublishableEntity(SORT_EXCEPTION_TYPE, published),
+        directBase_(directBase), directMembers_(directMembers)
+    {}
+
+    rtl::OUString getDirectBase() const { return directBase_; }
+
+    std::vector< Member > const & getDirectMembers() const
+    { return directMembers_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~ExceptionTypeEntity() throw ();
+
+    rtl::OUString directBase_;
+    std::vector< Member > directMembers_;
+};
+
+class CPPUHELPER_DLLPUBLIC InterfaceTypeEntity: public PublishableEntity {
+public:
+    struct Attribute {
+        Attribute(
+            rtl::OUString const & theName, rtl::OUString const & theType,
+            bool theBound, bool theReadOnly,
+            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()); }
+
+        rtl::OUString name;
+
+        rtl::OUString type;
+
+        bool bound;
+
+        bool readOnly;
+
+        std::vector< rtl::OUString > getExceptions;
+
+        std::vector< rtl::OUString > setExceptions;
+    };
+
+    struct Method {
+        struct Parameter {
+            enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_IN_OUT };
+
+            Parameter(
+                rtl::OUString const & theName, rtl::OUString const & theType,
+                Direction theDirection):
+                name(theName), type(theType), direction(theDirection)
+            {}
+
+            rtl::OUString name;
+
+            rtl::OUString type;
+
+            Direction direction;
+        };
+
+        Method(
+            rtl::OUString const & theName, rtl::OUString const & theReturnType,
+            std::vector< Parameter > const & theParameters,
+            std::vector< rtl::OUString > const & theExceptions):
+            name(theName), returnType(theReturnType), parameters(theParameters),
+            exceptions(theExceptions)
+        {}
+
+        rtl::OUString name;
+
+        rtl::OUString returnType;
+
+        std::vector< Parameter > parameters;
+
+        std::vector< rtl::OUString > exceptions;
+    };
+
+    SAL_DLLPRIVATE InterfaceTypeEntity(
+        bool published,
+        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),
+        directMandatoryBases_(directMandatoryBases),
+        directOptionalBases_(directOptionalBases),
+        directAttributes_(directAttributes), directMethods_(directMethods)
+    {}
+
+    std::vector< rtl::OUString > const & getDirectMandatoryBases() const
+    { return directMandatoryBases_; }
+
+    std::vector< rtl::OUString > const & getDirectOptionalBases() const
+    { return directOptionalBases_; }
+
+    std::vector< Attribute > const & getDirectAttributes() const
+    { return directAttributes_; }
+
+    std::vector< Method > const & getDirectMethods() const
+    { return directMethods_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~InterfaceTypeEntity() throw ();
+
+    std::vector< rtl::OUString > directMandatoryBases_;
+    std::vector< rtl::OUString > directOptionalBases_;
+    std::vector< Attribute > directAttributes_;
+    std::vector< Method > directMethods_;
+};
+
+class CPPUHELPER_DLLPUBLIC TypedefEntity: public PublishableEntity {
+public:
+    SAL_DLLPRIVATE TypedefEntity(bool published, rtl::OUString const & type):
+        PublishableEntity(SORT_TYPEDEF, published), type_(type)
+    {}
+
+    rtl::OUString getType() const { return type_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~TypedefEntity() throw ();
+
+    rtl::OUString type_;
+};
+
+class CPPUHELPER_DLLPUBLIC ConstantGroupEntity: public PublishableEntity {
+public:
+    struct Member {
+        Member(rtl::OUString const & theName, css::uno::Any const & theValue):
+            name(theName), value(theValue)
+        {}
+
+        rtl::OUString name;
+
+        css::uno::Any value;
+    };
+
+    SAL_DLLPRIVATE ConstantGroupEntity(
+        bool published, std::vector< Member > const & members):
+        PublishableEntity(SORT_CONSTANT_GROUP, published), members_(members)
+    {}
+
+    std::vector< Member > const & getMembers() const { return members_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~ConstantGroupEntity() throw ();
+
+    std::vector< Member > members_;
+};
+
+class CPPUHELPER_DLLPUBLIC SingleInterfaceBasedServiceEntity:
+    public PublishableEntity
+{
+public:
+    struct Constructor {
+        struct Parameter {
+            Parameter(
+                rtl::OUString const & theName, rtl::OUString const & theType,
+                bool theRest):
+                name(theName), type(theType), rest(theRest)
+            {}
+
+            rtl::OUString name;
+
+            rtl::OUString type;
+
+            bool rest;
+        };
+
+        Constructor(): defaultConstructor(true) {}
+
+        Constructor(
+            rtl::OUString const & theName,
+            std::vector< Parameter > const & theParameters,
+            std::vector< rtl::OUString > const & theExceptions):
+            name(theName), parameters(theParameters), exceptions(theExceptions),
+            defaultConstructor(false)
+        {}
+
+        rtl::OUString name;
+
+        std::vector< Parameter > parameters;
+
+        std::vector< rtl::OUString > exceptions;
+
+        bool defaultConstructor;
+    };
+
+    SAL_DLLPRIVATE SingleInterfaceBasedServiceEntity(
+        bool published, rtl::OUString const & base,
+        std::vector< Constructor > const & constructors):
+        PublishableEntity(SORT_SINGLE_INTERFACE_BASED_SERVICE, published),
+        base_(base), constructors_(constructors)
+    {}
+
+    rtl::OUString getBase() const { return base_; }
+
+    std::vector< Constructor > const & getConstructors() const
+    { return constructors_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~SingleInterfaceBasedServiceEntity() throw ();
+
+    rtl::OUString base_;
+    std::vector< Constructor > constructors_;
+};
+
+class CPPUHELPER_DLLPUBLIC AccumulationBasedServiceEntity:
+    public PublishableEntity
+{
+public:
+    struct Property {
+        enum Attributes {
+            ATTRIBUTE_MAYBE_VOID = 0x001,
+            ATTRIBUTE_BOUND = 0x002,
+            ATTRIBUTE_CONSTRAINED = 0x004,
+            ATTRIBUTE_TRANSIENT = 0x008,
+            ATTRIBUTE_READ_ONLY = 0x010,
+            ATTRIBUTE_MAYBE_AMBIGUOUS = 0x020,
+            ATTRIBUTE_MAYBE_DEFAULT = 0x040,
+            ATTRIBUTE_REMOVABLE = 0x080,
+            ATTRIBUTE_OPTIONAL = 0x100
+        };
+
+        Property(
+            rtl::OUString const & theName, rtl::OUString const & theType,
+            Attributes theAttributes):
+            name(theName), type(theType), attributes(theAttributes)
+        {}
+
+        rtl::OUString name;
+
+        rtl::OUString type;
+
+        Attributes attributes;
+    };
+
+    SAL_DLLPRIVATE AccumulationBasedServiceEntity(
+        bool published,
+        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),
+        directOptionalBaseServices_(directOptionalBaseServices),
+        directMandatoryBaseInterfaces_(directMandatoryBaseInterfaces),
+        directOptionalBaseInterfaces_(directOptionalBaseInterfaces),
+        directProperties_(directProperties)
+        {}
+
+    std::vector< rtl::OUString > const & getDirectMandatoryBaseServices() const
+    { return directMandatoryBaseServices_; }
+
+    std::vector< rtl::OUString > const & getDirectOptionalBaseServices() const
+    { return directOptionalBaseServices_; }
+
+    std::vector< rtl::OUString > const & getDirectMandatoryBaseInterfaces()
+        const
+    { return directMandatoryBaseInterfaces_; }
+
+    std::vector< rtl::OUString > const & getDirectOptionalBaseInterfaces() const
+    { return directOptionalBaseInterfaces_; }
+
+    std::vector< Property > const & getDirectProperties() const
+    { return directProperties_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~AccumulationBasedServiceEntity() throw ();
+
+    std::vector< rtl::OUString > directMandatoryBaseServices_;
+    std::vector< rtl::OUString > directOptionalBaseServices_;
+    std::vector< rtl::OUString > directMandatoryBaseInterfaces_;
+    std::vector< rtl::OUString > directOptionalBaseInterfaces_;
+    std::vector< Property > directProperties_;
+};
+
+class CPPUHELPER_DLLPUBLIC InterfaceBasedSingletonEntity:
+    public PublishableEntity
+{
+public:
+    SAL_DLLPRIVATE InterfaceBasedSingletonEntity(
+        bool published, rtl::OUString const & base):
+        PublishableEntity(SORT_INTERFACE_BASED_SINGLETON, published),
+        base_(base)
+    {}
+
+    rtl::OUString getBase() const { return base_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~InterfaceBasedSingletonEntity() throw ();
+
+    rtl::OUString base_;
+};
+
+class CPPUHELPER_DLLPUBLIC ServiceBasedSingletonEntity: public PublishableEntity
+{
+public:
+    SAL_DLLPRIVATE ServiceBasedSingletonEntity(
+        bool published, rtl::OUString const & base):
+        PublishableEntity(SORT_SERVICE_BASED_SINGLETON, published), base_(base)
+    {}
+
+    rtl::OUString getBase() const { return base_; }
+
+private:
+    virtual SAL_DLLPRIVATE ~ServiceBasedSingletonEntity() throw ();
+
+    rtl::OUString base_;
+};
+
+class CPPUHELPER_DLLPUBLIC Provider: public salhelper::SimpleReferenceObject {
+public:
+    virtual rtl::Reference< MapCursor > createRootCursor() const = 0;
+
+protected:
+    SAL_DLLPRIVATE Provider() {}
+
+    virtual SAL_DLLPRIVATE ~Provider() throw ();
+};
+
+CPPUHELPER_DLLPUBLIC rtl::Reference< Provider > loadProvider(
+    rtl::OUString const & uri);
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/typedescriptionprovider.cxx b/cppuhelper/source/typedescriptionprovider.cxx
index 97a1788..bf77491 100644
--- a/cppuhelper/source/typedescriptionprovider.cxx
+++ b/cppuhelper/source/typedescriptionprovider.cxx
@@ -10,7 +10,7 @@
 #include "sal/config.h"
 
 #include <cassert>
-#include <cstring>
+#include <cstdlib>
 #include <set>
 #include <stack>
 #include <vector>
@@ -49,537 +49,19 @@
 #include "com/sun/star/uno/XInterface.hpp"
 #include "cppuhelper/compbase2.hxx"
 #include "cppuhelper/implbase1.hxx"
-#include "osl/endian.h"
-#include "osl/file.h"
+#include "cppuhelper/unoidl.hxx"
 #include "osl/file.hxx"
 #include "osl/mutex.hxx"
 #include "rtl/ref.hxx"
 #include "rtl/ustring.hxx"
-#include "sal/log.hxx"
 #include "sal/types.h"
-#include "salhelper/simplereferenceobject.hxx"
 
 #include "paths.hxx"
 #include "typedescriptionprovider.hxx"
-
-// New binary format:
-//
-// Uses the following definitions:
-//
-// * UInt16: 2-byte value, LSB first
-// * UInt32: 4-byte value, LSB first
-// * UInt64: 8-byte value, LSB first
-// * Offset: UInt32 value, counting bytes from start of file
-// * NUL-Name: zero or more non-NUL US-ASCII bytes followed by a NUL byte
-// * Len-Name: UInt32 number of characters, with 0x80000000 bit 1, followed by
-//    that many (- 0x80000000) US-ASCII bytes
-// * Idx-Name: either an Offset (with 0x80000000 bit 0) of a Len-Name, or a
-//    Len-Name
-// * Entry: Offset of NUL-Name followed by Offset of payload
-// * Map: zero or more Entries
-//
-// Layout of per-entry payload in the root or a module Map:
-//
-// * kind byte:
-// ** 0: module
-// *** followed by:
-// **** UInt32 number N1 of entries of Map
-// **** N1 * Entry
-// ** otherwise:
-// *** 0x80 bit: 1 if published
-// *** 0x40 bit: 1 if deprecated
-// *** 0x20 bit: flag (may only be 1 for certain kinds, see below)
-// *** remaining bits:
-// **** 1: enum type
-// ***** followed by:
-// ****** UInt32 number N1 of members
-// ****** N1 * tuple of:
-// ******* Offset of Idx-Name
-// ******* UInt32
-// **** 2: plain struct type (with base if flag is 1)
-// ***** followed by:
-// ****** if "with base": Offset of Idx-Name
-// ****** UInt32 number N1 of direct members
-// ****** N1 * tuple of:
-// ******* Offset of Idx-Name name
-// ******* Offset of Idx-Name type
-// **** 3: polymorphic struct type template
-// ***** followed by:
-// ****** UInt32 number N1 of type parameters
-// ****** N1 * Offset of Idx-Name
-// ****** UInt32 number N2 of members
-// ****** N2 * tuple of:
-// ******* kind byte: 0x01 bit is 1 if parameterized type
-// ******* Offset of Idx-Name name
-// ******* Offset of Idx-Name type
-// **** 4: exception type (with base if flag is 1)
-// ***** followed by:
-// ****** if "with base": Offset of Idx-Name
-// ****** UInt32 number N1 of direct members
-// ****** N1 * tuple of:
-// ******* Offset of Idx-Name name
-// ******* Offset of Idx-Name type
-// **** 5: interface type
-// ***** followed by:
-// ****** UInt32 number N1 of direct mandatory bases
-// ****** N1 * Offset of Idx-Name
-// ****** UInt32 number N2 of direct optional bases
-// ****** N2 * Offset of Idx-Name
-// ****** UInt32 number N3 of direct attributes
-// ****** N3 * tuple of:
-// ******* kind byte:
-// ******** 0x02 bit: 1 if read-only
-// ******** 0x01 bit: 1 if bound
-// ******* Offset of Idx-Name name
-// ******* Offset of Idx-Name type
-// ******* UInt32 number N4 of get exceptions
-// ******* N4 * Offset of Idx-Name
-// ******* UInt32 number N5 of set exceptions
-// ******* N5 * Offset of Idx-Name
-// ****** UInt32 number N6 of direct methods
-// ****** N6 * tuple of:
-// ******* Offset of Idx-Name name
-// ******* Offset of Idx-Name return type
-// ******* UInt32 number N7 of parameters
-// ******* N7 * tuple of:
-// ******** direction byte: 0 for in, 1 for out, 2 for in-out
-// ******** Offset of Idx-Name name
-// ******** Offset of Idx-Name type
-// ******* UInt32 number N8 of exceptions
-// ******* N8 * Offset of Idx-Name
-// **** 6: typedef
-// ***** followed by:
-// ****** Offset of Idx-Name
-// **** 7: constant group
-// ***** followed by:
-// ****** UInt32 number N1 of entries of Map
-// ****** N1 * Entry
-// **** 8: single-interface--based service (with default constructor if flag is
-//       1)
-// ***** followed by:
-// ****** Offset of Idx-Name
-// ****** if not "with default constructor":
-// ******* UInt32 number N1 of constructors
-// ******* N1 * tuple of:
-// ******** Offset of Idx-Name
-// ******** UInt32 number N2 of parameters
-// ******** N2 * tuple of
-// ********* kind byte: 0x04 bit is 1 if rest parameter
-// ********* Offset of Idx-Name name
-// ********* Offset of Idx-Name type
-// ******** UInt32 number N3 of exceptions
-// ******** N3 * Offset of Idx-Name
-// **** 9: accumulation-based service
-// ***** followed by:
-// ****** UInt32 number N1 of direct mandatory base services
-// ****** N1 * Offset of Idx-Name
-// ****** UInt32 number N2 of direct optional base services
-// ****** N2 * Offset of Idx-Name
-// ****** UInt32 number N3 of direct mandatory base interfaces
-// ****** N3 * Offset of Idx-Name
-// ****** UInt32 number N4 of direct optional base interfaces
-// ****** N4 * Offset of Idx-Name
-// ****** UInt32 number N5 of direct properties
-// ****** N5 * tuple of:
-// ******* UInt16 kind:
-// ******** 0x0100 bit: 1 if optional
-// ******** 0x0080 bit: 1 if removable
-// ******** 0x0040 bit: 1 if maybedefault
-// ******** 0x0020 bit: 1 if maybeambiguous
-// ******** 0x0010 bit: 1 if readonly
-// ******** 0x0008 bit: 1 if transient
-// ******** 0x0004 bit: 1 if constrained
-// ******** 0x0002 bit: 1 if bound
-// ******** 0x0001 bit: 1 if maybevoid
-// ******* Offset of Idx-Name name
-// ******* Offset of Idx-Name type
-// **** 10: interface-based singleton
-// ***** followed by:
-// ****** Offset of Idx-Name
-// **** 11: service-based singleton
-// ***** followed by:
-// ****** Offset of Idx-Name
-//
-// Layout of per-entry payload in a constant group Map:
-//
-// * kind byte:
-// ** 0x80 bit: 1 if deprecated
-// ** remaining bits:
-// *** 0: BOOLEAN
-// **** followed by value byte, 0 represents false, 1 represents true
-// *** 1: BYTE
-// **** followed by value byte, representing values with two's complement
-// *** 2: SHORT
-// **** followed by UInt16 value, representing values with two's complement
-// *** 3: UNSIGNED SHORT
-// **** followed by UInt16 value
-// *** 4: LONG
-// **** followed by UInt32 value, representing values with two's complement
-// *** 5: UNSIGNED LONG
-// **** followed by UInt32 value
-// *** 6: HYPER
-// **** followed by UInt64 value, representing values with two's complement
-// *** 7: UNSIGNED HYPER
-// **** followed by UInt64 value
-// *** 8: FLOAT
-// **** followed by 4-byte value, representing values in ISO 60599 binary32
-//       format, LSB first
-// *** 9: DOUBLE
-// **** followed by 8-byte value, representing values in ISO 60599 binary64
-//       format, LSB first
-//
-// Memory layout:
-//
-// * 8 byte header "UNOIDL\0\xFF
-// * Offset of root Map
-// * UInt32 number of entries of root Map
-// ...
+#include "unoidlprovider.hxx"
 
 namespace {
 
-// sizeof (Memory16) == 2
-struct Memory16 {
-    unsigned char byte[2];
-
-    sal_uInt16 getUnsigned16() const {
-        return static_cast< sal_uInt16 >(byte[0])
-            | (static_cast< sal_uInt16 >(byte[1]) << 8);
-    }
-};
-
-// sizeof (Memory32) == 4
-struct Memory32 {
-    unsigned char byte[4];
-
-    sal_uInt32 getUnsigned32() const {
-        return static_cast< sal_uInt32 >(byte[0])
-            | (static_cast< sal_uInt32 >(byte[1]) << 8)
-            | (static_cast< sal_uInt32 >(byte[2]) << 16)
-            | (static_cast< sal_uInt32 >(byte[3]) << 24);
-    }
-
-    float getIso60599Binary32() const {
-        union {
-            unsigned char buf[4];
-            float f; // assuming float is ISO 60599 binary32
-        } sa;
-#if defined OSL_LITENDIAN
-        sa.buf[0] = byte[0];
-        sa.buf[1] = byte[1];
-        sa.buf[2] = byte[2];
-        sa.buf[3] = byte[3];
-#else
-        sa.buf[0] = byte[3];
-        sa.buf[1] = byte[2];
-        sa.buf[2] = byte[1];
-        sa.buf[3] = byte[0];
-#endif
-        return sa.f;
-    }
-};
-
-// sizeof (Memory64) == 8
-struct Memory64 {
-    unsigned char byte[8];
-
-    sal_uInt64 getUnsigned64() const {
-        return static_cast< sal_uInt64 >(byte[0])
-            | (static_cast< sal_uInt64 >(byte[1]) << 8)
-            | (static_cast< sal_uInt64 >(byte[2]) << 16)
-            | (static_cast< sal_uInt64 >(byte[3]) << 24)
-            | (static_cast< sal_uInt64 >(byte[4]) << 32)
-            | (static_cast< sal_uInt64 >(byte[5]) << 40)
-            | (static_cast< sal_uInt64 >(byte[6]) << 48)
-            | (static_cast< sal_uInt64 >(byte[7]) << 56);
-        }
-
-    double getIso60599Binary64() const {
-        union {
-            unsigned char buf[8];
-            double d; // assuming double is ISO 60599 binary64
-        } sa;
-#if defined OSL_LITENDIAN
-        sa.buf[0] = byte[0];
-        sa.buf[1] = byte[1];
-        sa.buf[2] = byte[2];
-        sa.buf[3] = byte[3];
-        sa.buf[4] = byte[4];
-        sa.buf[5] = byte[5];
-        sa.buf[6] = byte[6];
-        sa.buf[7] = byte[7];
-#else
-        sa.buf[0] = byte[7];
-        sa.buf[1] = byte[6];
-        sa.buf[2] = byte[5];
-        sa.buf[3] = byte[4];
-        sa.buf[4] = byte[3];
-        sa.buf[5] = byte[2];
-        sa.buf[6] = byte[1];
-        sa.buf[7] = byte[0];
-#endif
-        return sa.d;
-    }
-};
-
-struct MappedFile:
-    public salhelper::SimpleReferenceObject, private boost::noncopyable
-{
-    explicit MappedFile(rtl::OUString const & fileUrl);
-
-    sal_uInt8 read8(sal_uInt32 offset) const;
-
-    sal_uInt16 read16(sal_uInt32 offset) const;
-
-    sal_uInt32 read32(sal_uInt32 offset) const;
-
-    sal_uInt64 read64(sal_uInt32 offset) const;
-
-    float readIso60599Binary32(sal_uInt32 offset) const;
-
-    double readIso60599Binary64(sal_uInt32 offset) const;
-
-    rtl::OUString readNameNul(sal_uInt32 offset) const;
-
-    rtl::OUString readNameLen(sal_uInt32 offset, sal_uInt32 * newOffset = 0)
-        const;
-
-    oslFileHandle handle;
-    sal_uInt64 size;
-    void * address;
-
-private:
-    virtual ~MappedFile();
-
-    sal_uInt8 get8(sal_uInt32 offset) const;
-
-    sal_uInt16 get16(sal_uInt32 offset) const;
-
-    sal_uInt32 get32(sal_uInt32 offset) const;
-
-    sal_uInt64 get64(sal_uInt32 offset) const;
-
-    float getIso60599Binary32(sal_uInt32 offset) const;
-
-    double getIso60599Binary64(sal_uInt32 offset) const;
-};
-
-MappedFile::MappedFile(rtl::OUString const & fileUrl) {
-    oslFileError e = osl_openFile(
-        fileUrl.pData, &handle, osl_File_OpenFlag_Read);
-    switch (e) {
-    case osl_File_E_None:
-        break;
-    case osl_File_E_NOENT:
-        throw css::container::NoSuchElementException(
-            fileUrl, css::uno::Reference< css::uno::XInterface >());
-    default:
-        throw css::uno::RuntimeException(
-            "cannot open " + fileUrl + ": " + rtl::OUString::number(e),
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    e = osl_getFileSize(handle, &size);
-    if (e == osl_File_E_None) {
-        e = osl_mapFile(
-            handle, &address, size, 0, osl_File_MapFlag_RandomAccess);
-    }
-    if (e != osl_File_E_None) {
-        oslFileError e2 = osl_closeFile(handle);
-        SAL_WARN_IF(
-            e2 != osl_File_E_None, "cppuhelper",
-            "cannot close " << fileUrl << ": " << +e2);
-        throw css::uno::RuntimeException(
-            "cannot mmap " + fileUrl + ": " + rtl::OUString::number(e),
-            css::uno::Reference< css::uno::XInterface >());
-    }
-}
-
-sal_uInt8 MappedFile::read8(sal_uInt32 offset) const {
-    assert(size >= 8);
-    if (offset > size - 1) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: offset for 8-bit value too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return get8(offset);
-}
-
-sal_uInt16 MappedFile::read16(sal_uInt32 offset) const {
-    assert(size >= 8);
-    if (offset > size - 2) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: offset for 16-bit value too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return get16(offset);
-}
-
-sal_uInt32 MappedFile::read32(sal_uInt32 offset) const {
-    assert(size >= 8);
-    if (offset > size - 4) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: offset for 32-bit value too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return get32(offset);
-}
-
-sal_uInt64 MappedFile::read64(sal_uInt32 offset) const {
-    assert(size >= 8);
-    if (offset > size - 8) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: offset for 64-bit value too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return get64(offset);
-}
-
-float MappedFile::readIso60599Binary32(sal_uInt32 offset) const {
-    assert(size >= 8);
-    if (offset > size - 4) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: offset for 32-bit value too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return getIso60599Binary32(offset);
-}
-
-double MappedFile::readIso60599Binary64(sal_uInt32 offset) const {
-    assert(size >= 8);
-    if (offset > size - 8) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: offset for 64-bit value too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return getIso60599Binary64(offset);
-}
-
-rtl::OUString MappedFile::readNameNul(sal_uInt32 offset) const {
-    if (offset > size) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: offset for string too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    sal_uInt64 end = offset;
-    for (;; ++end) {
-        if (end == size) {
-            throw css::uno::DeploymentException(
-                "broken UNOIDL file: string misses trailing NUL",
-                css::uno::Reference< css::uno::XInterface >());
-        }
-        if (static_cast< char const * >(address)[end] == 0) {
-            break;
-        }
-    }
-    if (end - offset > SAL_MAX_INT32) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: string too long",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    rtl::OUString name;
-    if (!rtl_convertStringToUString(
-            &name.pData, static_cast< char const * >(address) + offset,
-            end - offset, RTL_TEXTENCODING_ASCII_US,
-            (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
-             | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
-             | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
-    {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: name is not ASCII",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return name;
-}
-
-rtl::OUString MappedFile::readNameLen(sal_uInt32 offset, sal_uInt32 * newOffset)
-    const
-{
-    sal_uInt32 len = read32(offset);
-    if ((len & 0x80000000) == 0) {
-        if (newOffset != 0) {
-            *newOffset = offset + 4;
-        }
-        offset = len;
-        len = read32(offset);
-        if ((len & 0x80000000) == 0) {
-            throw css::uno::DeploymentException(
-                "broken UNOIDL file: name length high bit unset",
-                css::uno::Reference< css::uno::XInterface >());
-        }
-        len &= ~0x80000000;
-    } else {
-        len &= ~0x80000000;
-        if (newOffset != 0) {
-            *newOffset = offset + 4 + len;
-        }
-    }
-    if (len > SAL_MAX_INT32 || len > size - offset - 4) {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: size of name is too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    rtl::OUString name;
-    if (!rtl_convertStringToUString(
-            &name.pData, static_cast< char const * >(address) + offset + 4, len,
-            RTL_TEXTENCODING_ASCII_US,
-            (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
-             | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
-             | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
-    {
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: name is not ASCII",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return name;
-}
-
-MappedFile::~MappedFile() {
-    oslFileError e = osl_unmapMappedFile(handle, address, size);
-    SAL_WARN_IF(e != osl_File_E_None, "cppuhelper", "cannot unmap: " << +e);
-    e = osl_closeFile(handle);
-    SAL_WARN_IF(e != osl_File_E_None, "cppuhelper", "cannot close: " << +e);
-}
-
-sal_uInt8 MappedFile::get8(sal_uInt32 offset) const {
-    assert(size >= 8);
-    assert(offset <= size - 1);
-    return static_cast< char const * >(address)[offset];
-}
-
-sal_uInt16 MappedFile::get16(sal_uInt32 offset) const {
-    assert(size >= 8);
-    assert(offset <= size - 2);
-    return reinterpret_cast< Memory16 const * >(
-        static_cast< char const * >(address) + offset)->getUnsigned16();
-}
-
-sal_uInt32 MappedFile::get32(sal_uInt32 offset) const {
-    assert(size >= 8);
-    assert(offset <= size - 4);
-    return reinterpret_cast< Memory32 const * >(
-        static_cast< char const * >(address) + offset)->getUnsigned32();
-}
-
-sal_uInt64 MappedFile::get64(sal_uInt32 offset) const {
-    assert(size >= 8);
-    assert(offset <= size - 8);
-    return reinterpret_cast< Memory64 const * >(
-        static_cast< char const * >(address) + offset)->getUnsigned64();
-}
-
-float MappedFile::getIso60599Binary32(sal_uInt32 offset) const {
-    assert(size >= 8);
-    assert(offset <= size - 4);
-    return reinterpret_cast< Memory32 const * >(
-        static_cast< char const * >(address) + offset)->getIso60599Binary32();
-}
-
-double MappedFile::getIso60599Binary64(sal_uInt32 offset) const {
-    assert(size >= 8);
-    assert(offset <= size - 8);
-    return reinterpret_cast< Memory64 const * >(
-        static_cast< char const * >(address) + offset)->getIso60599Binary64();
-}
-
 css::uno::Reference< css::reflection::XTypeDescription > resolve(
     css::uno::Reference< css::uno::XComponentContext > const & context,
     rtl::OUString const & name)
@@ -626,9 +108,9 @@ public:
     ModuleDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
         rtl::OUString const & name,
-        std::vector< rtl::OUString > const & items):
-        context_(context), name_(name), items_(items)
-    {}
+        rtl::Reference< cppu::unoidl::ModuleEntity > const & entity):
+        context_(context), name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~ModuleDescription() {}
@@ -647,17 +129,18 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    std::vector< rtl::OUString > items_;
+    rtl::Reference< cppu::unoidl::ModuleEntity > entity_;
 };
 
 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
 ModuleDescription::getMembers() throw (css::uno::RuntimeException) {
-    assert(items_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(items_.size());
+    std::vector< rtl::OUString > names(entity_->getMemberNames());
+    assert(names.size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(names.size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = resolve(context_, name_ + "." + items_[i]);
+        s[i] = resolve(context_, name_ + "." + names[i]);
     }
     return s;
 }
@@ -668,20 +151,12 @@ EnumTypeDescription_Base;
 
 class EnumTypeDescription: public EnumTypeDescription_Base {
 public:
-    struct Member {
-        Member(rtl::OUString const & theName, sal_Int32 theValue):
-            name(theName), value(theValue)
-        {}
-
-        rtl::OUString name;
-        sal_Int32 value;
-    };
-
     EnumTypeDescription(
-        rtl::OUString const & name, bool published,
-        std::vector< Member > const & members):
-        EnumTypeDescription_Base(published), name_(name), members_(members)
-    { assert(!members_.empty()); }
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::EnumTypeEntity > const & entity):
+        EnumTypeDescription_Base(entity->isPublished()), name_(name),
+        entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~EnumTypeDescription() {}
@@ -695,7 +170,7 @@ private:
 
     virtual sal_Int32 SAL_CALL getDefaultEnumValue()
         throw (css::uno::RuntimeException)
-    { return members_[0].value; }
+    { return entity_->getMembers()[0].value; }
 
     virtual css::uno::Sequence< rtl::OUString > SAL_CALL getEnumNames()
         throw (css::uno::RuntimeException);
@@ -704,17 +179,17 @@ private:
         throw (css::uno::RuntimeException);
 
     rtl::OUString name_;
-    std::vector< Member > members_;
+    rtl::Reference< cppu::unoidl::EnumTypeEntity > entity_;
 };
 
 css::uno::Sequence< rtl::OUString > EnumTypeDescription::getEnumNames()
     throw (css::uno::RuntimeException)
 {
-    assert(members_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(members_.size());
+    assert(entity_->getMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
     css::uno::Sequence< rtl::OUString > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = members_[i].name;
+        s[i] = entity_->getMembers()[i].name;
     }
     return s;
 }
@@ -722,11 +197,11 @@ css::uno::Sequence< rtl::OUString > EnumTypeDescription::getEnumNames()
 css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues()
     throw (css::uno::RuntimeException)
 {
-    assert(members_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(members_.size());
+    assert(entity_->getMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
     css::uno::Sequence< sal_Int32 > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = members_[i].value;
+        s[i] = entity_->getMembers()[i].value;
     }
     return s;
 }
@@ -737,22 +212,13 @@ PlainStructTypeDescription_Base;
 
 class PlainStructTypeDescription: public PlainStructTypeDescription_Base {
 public:
-    struct Member {
-        Member(rtl::OUString const & theName, rtl::OUString const & theType):
-            name(theName), type(theType)
-        {}
-
-        rtl::OUString name;
-        rtl::OUString type;
-    };
-
     PlainStructTypeDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published, rtl::OUString const & base,
-        std::vector< Member > const & directMembers):
-        PlainStructTypeDescription_Base(published), context_(context),
-        name_(name), base_(base), directMembers_(directMembers)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::PlainStructTypeEntity > const & entity):
+        PlainStructTypeDescription_Base(entity->isPublished()),
+        context_(context), name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~PlainStructTypeDescription() {}
@@ -766,9 +232,9 @@ private:
 
     virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
     getBaseType() throw (css::uno::RuntimeException) {
-        return base_.isEmpty()
+        return entity_->getDirectBase().isEmpty()
             ? css::uno::Reference< css::reflection::XTypeDescription >()
-            : resolve(context_, base_);
+            : resolve(context_, entity_->getDirectBase());
     }
 
     virtual
@@ -793,19 +259,18 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    rtl::OUString base_;
-    std::vector< Member > directMembers_;
+    rtl::Reference< cppu::unoidl::PlainStructTypeEntity > entity_;
 };
 
 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
 PlainStructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException)
 {
-    assert(directMembers_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(directMembers_.size());
+    assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = resolve(context_, directMembers_[i].type);
+        s[i] = resolve(context_, entity_->getDirectMembers()[i].type);
     }
     return s;
 }
@@ -813,11 +278,11 @@ PlainStructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException)
 css::uno::Sequence< rtl::OUString > PlainStructTypeDescription::getMemberNames()
     throw (css::uno::RuntimeException)
 {
-    assert(directMembers_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(directMembers_.size());
+    assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
     css::uno::Sequence< rtl::OUString > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = directMembers_[i].name;
+        s[i] = entity_->getDirectMembers()[i].name;
     }
     return s;
 }
@@ -853,27 +318,14 @@ class PolymorphicStructTypeTemplateDescription:
     public PolymorphicStructTypeTemplateDescription_Base
 {
 public:
-    struct Member {
-        Member(
-            rtl::OUString const & theName, rtl::OUString const & theType,
-            bool theParameterized):
-            name(theName), type(theType), parameterized(theParameterized)
-        {}
-
-        rtl::OUString name;
-        rtl::OUString type;
-        bool parameterized;
-    };
-
     PolymorphicStructTypeTemplateDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published,
-        std::vector< rtl::OUString > const & typeParameters,
-        std::vector< Member > const & members):
-        PolymorphicStructTypeTemplateDescription_Base(published),
-        context_(context), name_(name), typeParameters_(typeParameters),
-        members_(members)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::PolymorphicStructTypeTemplateEntity >
+            const & entity):
+        PolymorphicStructTypeTemplateDescription_Base(entity->isPublished()),
+        context_(context), name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~PolymorphicStructTypeTemplateDescription() {}
@@ -910,22 +362,22 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    std::vector< rtl::OUString > typeParameters_;
-    std::vector< Member > members_;
+    rtl::Reference< cppu::unoidl::PolymorphicStructTypeTemplateEntity > entity_;
 };
 
 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
 PolymorphicStructTypeTemplateDescription::getMemberTypes()
     throw (css::uno::RuntimeException)
 {
-    assert(members_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(members_.size());
+    assert(entity_->getMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = members_[i].parameterized
-            ? new ParameterizedMemberTypeDescription(members_[i].type)
-            : resolve(context_, members_[i].type);
+        s[i] = entity_->getMembers()[i].parameterized
+            ? new ParameterizedMemberTypeDescription(
+                entity_->getMembers()[i].type)
+            : resolve(context_, entity_->getMembers()[i].type);
     }
     return s;
 }
@@ -934,11 +386,11 @@ css::uno::Sequence< rtl::OUString >
 PolymorphicStructTypeTemplateDescription::getMemberNames()
     throw (css::uno::RuntimeException)
 {
-    assert(members_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(members_.size());
+    assert(entity_->getMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
     css::uno::Sequence< rtl::OUString > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = members_[i].name;
+        s[i] = entity_->getMembers()[i].name;
     }
     return s;
 }
@@ -947,11 +399,11 @@ css::uno::Sequence< rtl::OUString >
 PolymorphicStructTypeTemplateDescription::getTypeParameters()
     throw (css::uno::RuntimeException)
 {
-    assert(typeParameters_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(typeParameters_.size());
+    assert(entity_->getTypeParameters().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getTypeParameters().size());
     css::uno::Sequence< rtl::OUString > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = typeParameters_[i];
+        s[i] = entity_->getTypeParameters()[i];
     }
     return s;
 }
@@ -962,22 +414,13 @@ ExceptionTypeDescription_Base;
 
 class ExceptionTypeDescription: public ExceptionTypeDescription_Base {
 public:
-    struct Member {
-        Member(rtl::OUString const & theName, rtl::OUString const & theType):
-            name(theName), type(theType)
-        {}
-
-        rtl::OUString name;
-        rtl::OUString type;
-    };
-
     ExceptionTypeDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published, rtl::OUString const & base,
-        std::vector< Member > const & directMembers):
-        ExceptionTypeDescription_Base(published), context_(context),
-        name_(name), base_(base), directMembers_(directMembers)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::ExceptionTypeEntity > const & entity):
+        ExceptionTypeDescription_Base(entity->isPublished()), context_(context),
+        name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~ExceptionTypeDescription() {}
@@ -991,9 +434,9 @@ private:
 
     virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
     getBaseType() throw (css::uno::RuntimeException) {
-        return base_.isEmpty()
+        return entity_->getDirectBase().isEmpty()
             ? css::uno::Reference< css::reflection::XTypeDescription >()
-            : resolve(context_, base_);
+            : resolve(context_, entity_->getDirectBase());
     }
 
     virtual
@@ -1006,18 +449,17 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    rtl::OUString base_;
-    std::vector< Member > directMembers_;
+    rtl::Reference< cppu::unoidl::ExceptionTypeEntity > entity_;
 };
 
 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
 ExceptionTypeDescription::getMemberTypes() throw (css::uno::RuntimeException) {
-    assert(directMembers_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(directMembers_.size());
+    assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = resolve(context_, directMembers_[i].type);
+        s[i] = resolve(context_, entity_->getDirectMembers()[i].type);
     }
     return s;
 }
@@ -1025,11 +467,11 @@ ExceptionTypeDescription::getMemberTypes() throw (css::uno::RuntimeException) {
 css::uno::Sequence< rtl::OUString > ExceptionTypeDescription::getMemberNames()
     throw (css::uno::RuntimeException)
 {
-    assert(directMembers_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(directMembers_.size());
+    assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
     css::uno::Sequence< rtl::OUString > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = directMembers_[i].name;
+        s[i] = entity_->getDirectMembers()[i].name;
     }
     return s;
 }
@@ -1100,24 +542,6 @@ void BaseOffset::calculate(
     }
 }
 
-struct Attribute {
-    Attribute(
-        rtl::OUString const & theName, rtl::OUString const & theType,
-        bool theBound, bool theReadOnly,
-        std::vector< rtl::OUString > const & theGetExceptions,
-        std::vector< rtl::OUString > const & theSetExceptions):
-        name(theName), type(theType), bound(theBound), readOnly(theReadOnly),
-        getExceptions(theGetExceptions), setExceptions(theSetExceptions)
-    {}
-
-    rtl::OUString name;
-    rtl::OUString type;
-    bool bound;
-    bool readOnly;
-    std::vector< rtl::OUString > getExceptions;
-    std::vector< rtl::OUString > setExceptions;
-};
-
 class AttributeDescription:
     public cppu::WeakImplHelper1<
         css::reflection::XInterfaceAttributeTypeDescription2 >,
@@ -1126,7 +550,9 @@ class AttributeDescription:
 public:
     AttributeDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, Attribute attribute, sal_Int32 position):
+        rtl::OUString const & name,
+        cppu::unoidl::InterfaceTypeEntity::Attribute const & attribute,
+        sal_Int32 position):
         context_(context), name_(name), attribute_(attribute),
         position_(position)
     {}
@@ -1170,7 +596,7 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    Attribute attribute_;
+    cppu::unoidl::InterfaceTypeEntity::Attribute attribute_;
     sal_Int32 position_;
 };
 
@@ -1204,35 +630,6 @@ AttributeDescription::getSetExceptions() throw (css::uno::RuntimeException) {
     return s;
 }
 
-struct Method {
-    struct Parameter {
-        enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_IN_OUT };
-
-        Parameter(
-            rtl::OUString const & theName, rtl::OUString const & theType,
-            Direction theDirection):
-            name(theName), type(theType), direction(theDirection)
-        {}
-
-        rtl::OUString name;
-        rtl::OUString type;
-        Direction direction;
-    };
-
-    Method(
-        rtl::OUString const & theName, rtl::OUString const & theReturnType,
-        std::vector< Parameter > const & theParameters,
-        std::vector< rtl::OUString > const & theExceptions):
-        name(theName), returnType(theReturnType), parameters(theParameters),
-        exceptions(theExceptions)
-    {}
-
-    rtl::OUString name;
-    rtl::OUString returnType;
-    std::vector< Parameter > parameters;
-    std::vector< rtl::OUString > exceptions;
-};
-
 class MethodParameter:
     public cppu::WeakImplHelper1< css::reflection::XMethodParameter >,
     private boost::noncopyable
@@ -1240,7 +637,8 @@ class MethodParameter:
 public:
     MethodParameter(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        Method::Parameter parameter, sal_Int32 position):
+        cppu::unoidl::InterfaceTypeEntity::Method::Parameter const & parameter,
+        sal_Int32 position):
         context_(context), parameter_(parameter), position_(position)
     {}
 
@@ -1255,20 +653,30 @@ private:
     { return resolve(context_, parameter_.type); }
 
     virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException) {
-        return parameter_.direction == Method::Parameter::DIRECTION_IN
-            || parameter_.direction == Method::Parameter::DIRECTION_IN_OUT;
+        return
+            (parameter_.direction
+             == cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
+                 DIRECTION_IN)
+            || (parameter_.direction
+                == cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
+                    DIRECTION_IN_OUT);
     }
 
     virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException) {
-        return parameter_.direction == Method::Parameter::DIRECTION_OUT
-            || parameter_.direction == Method::Parameter::DIRECTION_IN_OUT;
+        return
+            (parameter_.direction
+             == cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
+                 DIRECTION_OUT)
+            || (parameter_.direction
+                == cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
+                    DIRECTION_IN_OUT);
     }
 
     virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException)
     { return position_; }
 
     css::uno::Reference< css::uno::XComponentContext > context_;
-    Method::Parameter parameter_;
+    cppu::unoidl::InterfaceTypeEntity::Method::Parameter parameter_;
     sal_Int32 position_;
 };
 
@@ -1280,7 +688,9 @@ class MethodDescription:
 public:
     MethodDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, Method method, sal_Int32 position):
+        rtl::OUString const & name,
+        cppu::unoidl::InterfaceTypeEntity::Method const & method,
+        sal_Int32 position):
         context_(context), name_(name), method_(method), position_(position)
     {}
 
@@ -1320,7 +730,7 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    Method method_;
+    cppu::unoidl::InterfaceTypeEntity::Method method_;
     sal_Int32 position_;
 };
 
@@ -1356,16 +766,11 @@ class InterfaceTypeDescription: public InterfaceTypeDescription_Base {
 public:
     InterfaceTypeDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published,
-        std::vector< rtl::OUString > const & mandatoryDirectBases,
-        std::vector< rtl::OUString > const & optionalDirectBases,
-        std::vector< Attribute > const & directAttributes,
-        std::vector< Method > const & directMethods):
-        InterfaceTypeDescription_Base(published), context_(context),
-        name_(name), mandatoryDirectBases_(mandatoryDirectBases),
-        optionalDirectBases_(optionalDirectBases),
-        directAttributes_(directAttributes), directMethods_(directMethods)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::InterfaceTypeEntity > const & entity):
+        InterfaceTypeDescription_Base(entity->isPublished()), context_(context),
+        name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~InterfaceTypeDescription() {}
@@ -1379,9 +784,9 @@ private:
 
     virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
     getBaseType() throw (css::uno::RuntimeException) {
-        return mandatoryDirectBases_.empty()
+        return entity_->getDirectMandatoryBases().empty()
             ? css::uno::Reference< css::reflection::XTypeDescription >()
-            : resolve(context_, mandatoryDirectBases_[0]);
+            : resolve(context_, entity_->getDirectMandatoryBases()[0]);
     }
 
     virtual css::uno::Uik SAL_CALL getUik() throw (css::uno::RuntimeException)
@@ -1405,45 +810,45 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    std::vector< rtl::OUString > mandatoryDirectBases_;
-    std::vector< rtl::OUString > optionalDirectBases_;
-    std::vector< Attribute > directAttributes_;
-    std::vector< Method > directMethods_;
+    rtl::Reference< cppu::unoidl::InterfaceTypeEntity > entity_;
 };
 
 css::uno::Sequence<
     css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > >
 InterfaceTypeDescription::getMembers() throw (css::uno::RuntimeException) {
     assert(
-        directAttributes_.size() <= SAL_MAX_INT32
-        && directMethods_.size() <= SAL_MAX_INT32 - directAttributes_.size());
-    sal_Int32 n1 = static_cast< sal_Int32 >(directAttributes_.size());
-    sal_Int32 n2 = static_cast< sal_Int32 >(directMethods_.size());
+        entity_->getDirectAttributes().size() <= SAL_MAX_INT32
+        && (entity_->getDirectMethods().size()
+            <= SAL_MAX_INT32 - entity_->getDirectAttributes().size()));
+    sal_Int32 n1 = static_cast< sal_Int32 >(
+        entity_->getDirectAttributes().size());
+    sal_Int32 n2 = static_cast< sal_Int32 >(entity_->getDirectMethods().size());
     css::uno::Sequence<
         css::uno::Reference<
             css::reflection::XInterfaceMemberTypeDescription > > s(n1 + n2);
     sal_Int32 off = BaseOffset(this).get();
     for (sal_Int32 i = 0; i != n1; ++i) {
         s[i] = new AttributeDescription(
-            context_, name_ + "::" + directAttributes_[i].name,
-            directAttributes_[i], off + i);
+            context_, name_ + "::" + entity_->getDirectAttributes()[i].name,
+            entity_->getDirectAttributes()[i], off + i);
     }
     for (sal_Int32 i = 0; i != n2; ++i) {
         s[n1 + i] = new MethodDescription(
-            context_, name_ + "::" + directMethods_[i].name,
-            directMethods_[i], off + n1 + i);
+            context_, name_ + "::" + entity_->getDirectMethods()[i].name,
+            entity_->getDirectMethods()[i], off + n1 + i);
     }
     return s;
 }
 
 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
 InterfaceTypeDescription::getBaseTypes() throw (css::uno::RuntimeException) {
-    assert(mandatoryDirectBases_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(mandatoryDirectBases_.size());
+    assert(entity_->getDirectMandatoryBases().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(
+        entity_->getDirectMandatoryBases().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = resolve(context_, mandatoryDirectBases_[i]);
+        s[i] = resolve(context_, entity_->getDirectMandatoryBases()[i]);
     }
     return s;
 }
@@ -1452,12 +857,13 @@ css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
 InterfaceTypeDescription::getOptionalBaseTypes()
     throw (css::uno::RuntimeException)
 {
-    assert(optionalDirectBases_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(optionalDirectBases_.size());
+    assert(entity_->getDirectOptionalBases().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(
+        entity_->getDirectOptionalBases().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = resolve(context_, optionalDirectBases_[i]);
+        s[i] = resolve(context_, entity_->getDirectOptionalBases()[i]);
     }
     return s;
 }
@@ -1498,11 +904,11 @@ class ConstantGroupDescription: public ConstantGroupDescription_Base {
 public:
     ConstantGroupDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published,
-        std::vector< rtl::OUString > const & constants):
-        ConstantGroupDescription_Base(published), context_(context),
-        name_(name), constants_(constants)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::ConstantGroupEntity > const & entity):
+        ConstantGroupDescription_Base(entity->isPublished()), context_(context),
+        name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~ConstantGroupDescription() {}
@@ -1521,19 +927,20 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    std::vector< rtl::OUString > constants_;
+    rtl::Reference< cppu::unoidl::ConstantGroupEntity > entity_;
 };
 
 css::uno::Sequence<
     css::uno::Reference< css::reflection::XConstantTypeDescription > >
 ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException) {
-    assert(constants_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(constants_.size());
+    assert(entity_->getMembers().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
+        //TODO: use entity_->getMembers()[i].value directly?
         s[i].set(
-            resolve(context_, name_ + "." + constants_[i]),
+            resolve(context_, name_ + "." + entity_->getMembers()[i].name),
             css::uno::UNO_QUERY_THROW);
     }
     return s;
@@ -1547,10 +954,11 @@ class TypedefDescription: public TypedefDescription_Base {
 public:
     TypedefDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published, rtl::OUString const & type):
-        TypedefDescription_Base(published), context_(context), name_(name),
-        type_(type)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::TypedefEntity > const & entity):
+        TypedefDescription_Base(entity->isPublished()), context_(context),
+        name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~TypedefDescription() {}
@@ -1564,40 +972,11 @@ private:
 
     virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
     getReferencedType() throw (css::uno::RuntimeException)
-    { return resolve(context_, type_); }
+    { return resolve(context_, entity_->getType()); }
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    rtl::OUString type_;
-};
-
-struct Constructor {
-    struct Parameter {
-        Parameter(
-            rtl::OUString const & theName, rtl::OUString const & theType,
-            bool theRest):
-            name(theName), type(theType), rest(theRest)
-        {}
-
-        rtl::OUString name;
-        rtl::OUString type;
-        bool rest;
-    };
-
-    Constructor(): defaultConstructor(true) {}
-
-    Constructor(
-        rtl::OUString const & theName,
-        std::vector< Parameter > const & theParameters,
-        std::vector< rtl::OUString > const & theExceptions):
-        defaultConstructor(false), name(theName), parameters(theParameters),
-        exceptions(theExceptions)
-    {}
-
-    bool defaultConstructor;
-    rtl::OUString name;
-    std::vector< Parameter > parameters;
-    std::vector< rtl::OUString > exceptions;
+    rtl::Reference< cppu::unoidl::TypedefEntity > entity_;
 };
 
 class ConstructorParameter:
@@ -1607,7 +986,9 @@ class ConstructorParameter:
 public:
     ConstructorParameter(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        Constructor::Parameter parameter, sal_Int32 position):
+        cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
+            const & parameter,
+        sal_Int32 position):
         context_(context), parameter_(parameter), position_(position)
     {}
 
@@ -1635,7 +1016,8 @@ private:
     { return parameter_.rest; }
 
     css::uno::Reference< css::uno::XComponentContext > context_;
-    Constructor::Parameter parameter_;
+    cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
+        parameter_;
     sal_Int32 position_;
 };
 
@@ -1647,7 +1029,8 @@ class ConstructorDescription:
 public:
     ConstructorDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        Constructor const & constructor):
+        cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor const &
+            constructor):
         context_(context), constructor_(constructor)
     {}
 
@@ -1672,7 +1055,7 @@ private:
     SAL_CALL getExceptions() throw (css::uno::RuntimeException);
 
     css::uno::Reference< css::uno::XComponentContext > context_;
-    Constructor constructor_;
+    cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_;
 };
 
 css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
@@ -1713,11 +1096,12 @@ class SingleInterfaceBasedServiceDescription:
 public:
     SingleInterfaceBasedServiceDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published, rtl::OUString const & type,
-        std::vector< Constructor > const & constructors):
-        SingleInterfaceBasedServiceDescription_Base(published),
-        context_(context), name_(name), type_(type), constructors_(constructors)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::SingleInterfaceBasedServiceEntity >
+            const & entity):
+        SingleInterfaceBasedServiceDescription_Base(entity->isPublished()),
+        context_(context), name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~SingleInterfaceBasedServiceDescription() {}
@@ -1783,7 +1167,7 @@ private:
 
     virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
     getInterface() throw (css::uno::RuntimeException)
-    { return resolve(context_, type_); }
+    { return resolve(context_, entity_->getBase()); }
 
     virtual
     css::uno::Sequence<
@@ -1792,8 +1176,7 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    rtl::OUString type_;
-    std::vector< Constructor > constructors_;
+    rtl::Reference< cppu::unoidl::SingleInterfaceBasedServiceEntity > entity_;
 };
 
 css::uno::Sequence<
@@ -1801,29 +1184,18 @@ css::uno::Sequence<
 SingleInterfaceBasedServiceDescription::getConstructors()
     throw (css::uno::RuntimeException)
 {
-    assert(constructors_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(constructors_.size());
+    assert(entity_->getConstructors().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(entity_->getConstructors().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XServiceConstructorDescription > >
             s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = new ConstructorDescription(context_, constructors_[i]);
+        s[i] = new ConstructorDescription(
+            context_, entity_->getConstructors()[i]);
     }
     return s;
 }
 
-struct Property {
-    Property(
-        rtl::OUString const & theName, rtl::OUString const & theType,
-        sal_uInt16 theAttributes):
-        name(theName), type(theType), attributes(theAttributes)
-    {}
-
-    rtl::OUString name;
-    rtl::OUString type;
-    sal_Int16 attributes;
-};
-
 class PropertyDescription:
     public cppu::WeakImplHelper1< css::reflection::XPropertyTypeDescription >,
     private boost::noncopyable
@@ -1831,7 +1203,8 @@ class PropertyDescription:
 public:
     PropertyDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        Property const & property):
+        cppu::unoidl::AccumulationBasedServiceEntity::Property const &
+            property):
         context_(context), property_(property)
     {}
 
@@ -1854,7 +1227,7 @@ private:
     { return resolve(context_, property_.type); }
 
     css::uno::Reference< css::uno::XComponentContext > context_;
-    Property property_;
+    cppu::unoidl::AccumulationBasedServiceEntity::Property property_;
 };
 
 typedef cppu::ImplInheritanceHelper1<
@@ -1867,19 +1240,12 @@ class AccumulationBasedServiceDescription:
 public:
     AccumulationBasedServiceDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published,
-        std::vector< rtl::OUString > const & mandatoryDirectBaseServices,
-        std::vector< rtl::OUString > const & optionalDirectBaseServices,
-        std::vector< rtl::OUString > const & mandatoryDirectBaseInterfaces,
-        std::vector< rtl::OUString > const & optionalDirectBaseInterfaces,
-        std::vector< Property > const & directProperties):
-        AccumulationBasedServiceDescription_Base(published), context_(context),
-        name_(name), mandatoryDirectBaseServices_(mandatoryDirectBaseServices),
-        optionalDirectBaseServices_(optionalDirectBaseServices),
-        mandatoryDirectBaseInterfaces_(mandatoryDirectBaseInterfaces),
-        optionalDirectBaseInterfaces_(optionalDirectBaseInterfaces),
-        directProperties_(directProperties)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::AccumulationBasedServiceEntity > const &
+            entity):
+        AccumulationBasedServiceDescription_Base(entity->isPublished()),
+        context_(context), name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~AccumulationBasedServiceDescription() {}
@@ -1936,11 +1302,7 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    std::vector< rtl::OUString > mandatoryDirectBaseServices_;
-    std::vector< rtl::OUString > optionalDirectBaseServices_;
-    std::vector< rtl::OUString > mandatoryDirectBaseInterfaces_;
-    std::vector< rtl::OUString > optionalDirectBaseInterfaces_;
-    std::vector< Property > directProperties_;
+    rtl::Reference< cppu::unoidl::AccumulationBasedServiceEntity > entity_;
 };
 
 css::uno::Sequence<
@@ -1948,13 +1310,14 @@ css::uno::Sequence<
 AccumulationBasedServiceDescription::getMandatoryServices()
     throw (css::uno::RuntimeException)
 {
-    assert(mandatoryDirectBaseServices_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(mandatoryDirectBaseServices_.size());
+    assert(entity_->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(
+        entity_->getDirectMandatoryBaseServices().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
         s[i].set(
-            resolve(context_, mandatoryDirectBaseServices_[i]),
+            resolve(context_, entity_->getDirectMandatoryBaseServices()[i]),
             css::uno::UNO_QUERY_THROW);
     }
     return s;
@@ -1965,13 +1328,14 @@ css::uno::Sequence<
 AccumulationBasedServiceDescription::getOptionalServices()
     throw (css::uno::RuntimeException)
 {
-    assert(optionalDirectBaseServices_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(optionalDirectBaseServices_.size());
+    assert(entity_->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(
+        entity_->getDirectOptionalBaseServices().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
         s[i].set(
-            resolve(context_, optionalDirectBaseServices_[i]),
+            resolve(context_, entity_->getDirectOptionalBaseServices()[i]),
             css::uno::UNO_QUERY_THROW);
     }
     return s;
@@ -1982,16 +1346,17 @@ css::uno::Sequence<
 AccumulationBasedServiceDescription::getMandatoryInterfaces()
     throw (css::uno::RuntimeException)
 {
-    assert(mandatoryDirectBaseInterfaces_.size() <= SAL_MAX_INT32);
+    assert(entity_->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32);
     sal_Int32 n = static_cast< sal_Int32 >(
-        mandatoryDirectBaseInterfaces_.size());
+        entity_->getDirectMandatoryBaseInterfaces().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
             n);
     for (sal_Int32 i = 0; i != n; ++i) {
         s[i].set(
             resolveTypedefs(
-                resolve(context_, mandatoryDirectBaseInterfaces_[i])),
+                resolve(
+                    context_, entity_->getDirectMandatoryBaseInterfaces()[i])),
             css::uno::UNO_QUERY_THROW);
     }
     return s;
@@ -2002,16 +1367,17 @@ css::uno::Sequence<
 AccumulationBasedServiceDescription::getOptionalInterfaces()
     throw (css::uno::RuntimeException)
 {
-    assert(optionalDirectBaseInterfaces_.size() <= SAL_MAX_INT32);
+    assert(entity_->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32);
     sal_Int32 n = static_cast< sal_Int32 >(
-        optionalDirectBaseInterfaces_.size());
+        entity_->getDirectOptionalBaseInterfaces().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
             n);
     for (sal_Int32 i = 0; i != n; ++i) {
         s[i].set(
             resolveTypedefs(
-                resolve(context_, optionalDirectBaseInterfaces_[i])),
+                resolve(
+                    context_, entity_->getDirectOptionalBaseInterfaces()[i])),
             css::uno::UNO_QUERY_THROW);
     }
     return s;
@@ -2022,12 +1388,14 @@ css::uno::Sequence<
 AccumulationBasedServiceDescription::getProperties()
     throw (css::uno::RuntimeException)
 {
-    assert(directProperties_.size() <= SAL_MAX_INT32);
-    sal_Int32 n = static_cast< sal_Int32 >(directProperties_.size());
+    assert(entity_->getDirectProperties().size() <= SAL_MAX_INT32);
+    sal_Int32 n = static_cast< sal_Int32 >(
+        entity_->getDirectProperties().size());
     css::uno::Sequence<
         css::uno::Reference< css::reflection::XPropertyTypeDescription > > s(n);
     for (sal_Int32 i = 0; i != n; ++i) {
-        s[i] = new PropertyDescription(context_, directProperties_[i]);
+        s[i] = new PropertyDescription(
+            context_, entity_->getDirectProperties()[i]);
     }
     return s;
 }
@@ -2042,10 +1410,12 @@ class InterfaceBasedSingletonDescription:
 public:
     InterfaceBasedSingletonDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published, rtl::OUString const & type):
-        InterfaceBasedSingletonDescription_Base(published), context_(context),
-        name_(name), type_(type)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::InterfaceBasedSingletonEntity > const &
+            entity):
+        InterfaceBasedSingletonDescription_Base(entity->isPublished()),
+        context_(context), name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~InterfaceBasedSingletonDescription() {}
@@ -2070,11 +1440,11 @@ private:
 
     virtual css::uno::Reference< css::reflection::XTypeDescription >
     SAL_CALL getInterface() throw (css::uno::RuntimeException)
-    { return resolve(context_, type_); }
+    { return resolve(context_, entity_->getBase()); }
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    rtl::OUString type_;
+    rtl::Reference< cppu::unoidl::InterfaceBasedSingletonEntity > entity_;
 };
 
 typedef cppu::ImplInheritanceHelper1<
@@ -2087,10 +1457,12 @@ class ServiceBasedSingletonDescription:
 public:
     ServiceBasedSingletonDescription(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & name, bool published, rtl::OUString const & type):
-        ServiceBasedSingletonDescription_Base(published), context_(context),
-        name_(name), type_(type)
-    {}
+        rtl::OUString const & name,
+        rtl::Reference< cppu::unoidl::ServiceBasedSingletonEntity > const &
+            entity):
+        ServiceBasedSingletonDescription_Base(entity_->isPublished()),
+        context_(context), name_(name), entity_(entity)
+    { assert(entity.is()); }
 
 private:
     virtual ~ServiceBasedSingletonDescription() {}
@@ -2106,7 +1478,7 @@ private:
     SAL_CALL getService() throw (css::uno::RuntimeException)
     {
         return css::uno::Reference< css::reflection::XServiceTypeDescription >(
-            resolve(context_, type_), css::uno::UNO_QUERY_THROW);
+            resolve(context_, entity_->getBase()), css::uno::UNO_QUERY_THROW);
     }
 
     virtual sal_Bool SAL_CALL isInterfaceBased()
@@ -2119,13 +1491,7 @@ private:
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     rtl::OUString name_;
-    rtl::OUString type_;
-};
-
-// sizeof (MapEntry) == 8
-struct MapEntry {
-    Memory32 name;
-    Memory32 data;
+    rtl::Reference< cppu::unoidl::ServiceBasedSingletonEntity > entity_;
 };
 
 class Enumeration:
@@ -2136,13 +1502,13 @@ class Enumeration:
 public:
     Enumeration(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::Reference< MappedFile > const & file, rtl::OUString const & prefix,
-        MapEntry const * mapBegin, sal_uInt32 mapSize,
+        rtl::OUString const & prefix,
+        rtl::Reference< cppu::unoidl::MapCursor > const & cursor,
         css::uno::Sequence< css::uno::TypeClass > const & types, bool deep):
-        context_(context), file_(file), types_(types), deep_(deep)
+        context_(context), types_(types), deep_(deep)
     {
-        positions_.push(Position(prefix, mapBegin, mapSize, false));
-        findMatch();
+        positions_.push(Position(prefix, cursor));
+        findNextMatch();
     }
 
 private:
@@ -2165,26 +1531,31 @@ private:
 
     bool matches(css::uno::TypeClass tc) const;
 
-    void proceed();
-
-    void findMatch();
+    void findNextMatch();
 
     struct Position {
         Position(
-            rtl::OUString const & thePrefix, MapEntry const * mapBegin,
-            sal_uInt32 mapSize, bool theConstantGroup):
-            prefix(thePrefix), position(mapBegin), end(mapBegin + mapSize),
-            constantGroup(theConstantGroup)
-        {}
+            rtl::OUString const & thePrefix,
+            rtl::Reference< cppu::unoidl::MapCursor > const & theCursor):
+            prefix(thePrefix), cursor(theCursor)
+        { assert(theCursor.is()); }
+
+        Position(
+            rtl::OUString const & thePrefix,
+            rtl::Reference< cppu::unoidl::ConstantGroupEntity > const &
+                theConstantGroup):
+            prefix(thePrefix), constantGroup(theConstantGroup),
+            constantGroupIndex(constantGroup->getMembers().begin())
+        { assert(theConstantGroup.is()); }
 
         rtl::OUString prefix;
-        MapEntry const * position;
-        MapEntry const * end;
-        bool constantGroup;
+        rtl::Reference< cppu::unoidl::MapCursor > cursor;
+        rtl::Reference< cppu::unoidl::ConstantGroupEntity > constantGroup;
+        std::vector< cppu::unoidl::ConstantGroupEntity::Member >::const_iterator
+            constantGroupIndex;
     };
 
     css::uno::Reference< css::uno::XComponentContext > context_;
-    rtl::Reference< MappedFile > file_;
     css::uno::Sequence< css::uno::TypeClass > types_;
     bool deep_;
 
@@ -2206,8 +1577,7 @@ Enumeration::nextTypeDescription()
                 static_cast< cppu::OWeakObject * >(this));
         }
         name = current_;
-        proceed();
-        findMatch();
+        findNextMatch();
     }
     return resolve(context_, name);
 }
@@ -2224,107 +1594,87 @@ bool Enumeration::matches(css::uno::TypeClass tc) const {
     return false;
 }
 
-void Enumeration::proceed() {
-    assert(!positions_.empty());
-    assert(positions_.top().position < positions_.top().end);
-    if (deep_) {
-        sal_uInt32 off = positions_.top().position->data.getUnsigned32();
-        int v = file_->read8(off);
-        bool recurse;
-        bool cgroup = bool();
-        if (v == 0) {
-            recurse = true;
-            cgroup = false;
-        } else if ((v & 0x3F) == 7 && matches(css::uno::TypeClass_CONSTANT)) {
-            recurse = true;
-            cgroup = true;
-        } else {
-            recurse = false;
-        }
-        if (recurse) {
-            rtl::OUString prefix(
-                positions_.top().prefix
-                + file_->readNameNul(
-                    positions_.top().position->name.getUnsigned32())
-                + ".");
-            sal_uInt32 mapSize = file_->read32(off + 1);
-            if (8 * mapSize > file_->size - off - 5) { //TODO: overflow
-                throw css::uno::DeploymentException(
-                    "broken UNOIDL file: map offset + size too large",
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-            MapEntry const * mapBegin = reinterpret_cast< MapEntry const * >(
-                static_cast< char const * >(file_->address) + off + 5);
-            ++positions_.top().position;
-            positions_.push(Position(prefix, mapBegin, mapSize, cgroup));
-            return;
-        }
-    }
-    ++positions_.top().position;
-}
-
-void Enumeration::findMatch() {
-    assert(!positions_.empty());
-    for (;; proceed()) {
-        while (positions_.top().position == positions_.top().end) {
-            positions_.pop();
-            if (positions_.empty()) {
-                return;
+void Enumeration::findNextMatch() {
+    for (;;) {
+        assert(!positions_.empty());
+        rtl::OUString name;
+        if (positions_.top().cursor.is()) { // root or module
+            rtl::Reference< cppu::unoidl::Entity > ent(
+                positions_.top().cursor->getNext(&name));
+            if (!ent.is()) {
+                positions_.pop();
+                if (positions_.empty()) {
+                    break;
+                }
+                continue;
             }
-        }
-        bool match;
-        if (positions_.top().constantGroup) {
-            assert(matches(css::uno::TypeClass_CONSTANT));
-            match = true;
-        } else {
-            sal_uInt32 off = positions_.top().position->data.getUnsigned32();
-            int v = file_->read8(off);
+            name = positions_.top().prefix + name;
             css::uno::TypeClass tc;
-            switch (v & 0x1F) {
-            case 0: // module
+            switch (ent->getSort()) {
+            case cppu::unoidl::Entity::SORT_MODULE:
                 tc = css::uno::TypeClass_MODULE;
+                if (deep_) {
+                    positions_.push(
+                        Position(
+                            name + ".",
+                            static_cast< cppu::unoidl::ModuleEntity * >(
+                                ent.get())->createCursor()));
+                }
                 break;
-            case 1: // enum type
+            case cppu::unoidl::Entity::SORT_ENUM_TYPE:
                 tc = css::uno::TypeClass_ENUM;
                 break;
-            case 2: // plain struct type (with or without base)
-            case 3: // polymorphic struct type template
+            case cppu::unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
+            case cppu::unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
                 tc = css::uno::TypeClass_STRUCT;
                 break;
-            case 4: // exception type (with or without base)
+            case cppu::unoidl::Entity::SORT_EXCEPTION_TYPE:
                 tc = css::uno::TypeClass_EXCEPTION;
                 break;
-            case 5: // interface type
+            case cppu::unoidl::Entity::SORT_INTERFACE_TYPE:
                 tc = css::uno::TypeClass_INTERFACE;
                 break;
-            case 6: // typedef
+            case cppu::unoidl::Entity::SORT_TYPEDEF:
                 tc = css::uno::TypeClass_TYPEDEF;
                 break;
-            case 7: // constant group
+            case cppu::unoidl::Entity::SORT_CONSTANT_GROUP:
                 tc = css::uno::TypeClass_CONSTANTS;
+                if (deep_ && matches(css::uno::TypeClass_CONSTANT)) {
+                    positions_.push(
+                        Position(
+                            name + ".",
+                            static_cast< cppu::unoidl::ConstantGroupEntity * >(
+                                ent.get())));
+                }
                 break;
-            case 8: // single-interface--based service (with or without default
-                    // constructor)
-            case 9: // accumulation-based service
+            case cppu::unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
+            case cppu::unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
                 tc = css::uno::TypeClass_SERVICE;
                 break;
-            case 10: // interface-based singleton
-            case 11: // service-based singleton
+            case cppu::unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
+            case cppu::unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
                 tc = css::uno::TypeClass_SINGLETON;
                 break;
             default:
-                throw css::uno::DeploymentException(
-                    ("broken UNOIDL file: bad type byte "
-                     + rtl::OUString::number(v)),
-                    css::uno::Reference< css::uno::XInterface >());
+                for (;;) { std::abort(); } // this cannot happen
+            }
+            if (matches(tc)) {
+                current_ = name;
+                break;
+            }
+        } else { // constant group
+            if (positions_.top().constantGroupIndex
+                == positions_.top().constantGroup->getMembers().end())
+            {
+                positions_.pop();
+                if (positions_.empty()) {
+                    break;
+                }
+                continue;
             }
-            match = matches(tc);
-        }
-        if (match) {
             current_ = positions_.top().prefix
-                + file_->readNameNul(
-                    positions_.top().position->name.getUnsigned32());
-            return;
+                + positions_.top().constantGroupIndex++->name;
+            break;
         }
     }
 }
@@ -2340,14 +1690,15 @@ class Provider:
 public:
     Provider(
         css::uno::Reference< css::uno::XComponentContext > const & context,
-        rtl::OUString const & uri);
+        rtl::OUString const & uri):
+        Provider_Base(*static_cast< osl::Mutex * >(this)), context_(context),
+        provider_(new cppu::UnoidlProvider(uri))
+    {}
 
     using Provider_Base::acquire;
     using Provider_Base::release;
 
 private:
-    enum Compare { COMPARE_LESS, COMPARE_GREATER, COMPARE_EQUAL };
-
     virtual ~Provider() {}
 
     virtual void SAL_CALL disposing() {} //TODO
@@ -2359,7 +1710,7 @@ private:
 
     virtual sal_Bool SAL_CALL hasByHierarchicalName(
         rtl::OUString const & aName) throw (css::uno::RuntimeException)
-    { return find(aName) != 0; }
+    { return provider_->find(aName) != 0; }
 
     virtual css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
     SAL_CALL createTypeDescriptionEnumeration(
@@ -2371,654 +1722,117 @@ private:
             css::reflection::InvalidTypeNameException,
             css::uno::RuntimeException);
 
-    sal_uInt32 find(rtl::OUString const & name, bool * constant = 0) const;
-
-    sal_uInt32 findInMap(
-        rtl::OUString const & name, sal_Int32 nameOffset, sal_Int32 nameLength,
-        MapEntry const * mapBegin, sal_uInt32 mapSize) const;
-
-    Compare compare(
-        rtl::OUString const & name, sal_Int32 nameOffset, sal_Int32 nameLength,
-        MapEntry const * entry) const;
-
     css::uno::Reference< css::uno::XComponentContext > context_;
-    rtl::Reference< MappedFile > file_;
-    MapEntry const * mapBegin_;
-    sal_uInt32 mapSize_;
+    rtl::Reference< cppu::UnoidlProvider > provider_;
 };
 
-Provider::Provider(
-    css::uno::Reference< css::uno::XComponentContext > const & context,
-    rtl::OUString const & uri):
-    Provider_Base(*static_cast< osl::Mutex * >(this)), context_(context),
-    file_(new MappedFile(uri))
-{
-    if (file_->size < 8 || std::memcmp(file_->address, "UNOIDL\0\xFF", 8) != 0)
-    {
-        throw css::registry::InvalidRegistryException(
-            uri, css::uno::Reference< css::uno::XInterface >());
-    }
-    sal_uInt32 off = file_->read32(8);
-    mapSize_ = file_->read32(12);
-    if (off + 8 * mapSize_ > file_->size) { //TODO: overflow
-        throw css::uno::DeploymentException(
-            "broken UNOIDL file: root map offset + size too large",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    mapBegin_ = reinterpret_cast< MapEntry const * >(
-        static_cast< char const * >(file_->address) + off);
-}
-
 css::uno::Any Provider::getByHierarchicalName(rtl::OUString const & aName)
     throw (css::container::NoSuchElementException, css::uno::RuntimeException)
 {
     bool cnst;
-    sal_uInt32 off = find(aName, &cnst);
+    sal_uInt32 off = provider_->find(aName, &cnst);
     if (off == 0) {
         throw css::container::NoSuchElementException(
             aName, static_cast< cppu::OWeakObject * >(this));
     }
     if (cnst) {
-        int v = file_->read8(off);
-        int type = v & 0x7F;
-        bool deprecated = (v & 0x80) != 0; (void)deprecated;//TODO
-        css::uno::Any any;
-        switch (type) {
-        case 0: // BOOLEAN
-            v = file_->read8(off + 1);
-            switch (v) {
-            case 0:
-                any <<= false;
-                break;
-            case 1:
-                any <<= true;
-                break;
-            default:
-                throw css::uno::DeploymentException(
-                    ("broken UNOIDL file: bad boolean constant value "
-                     + rtl::OUString::number(v)),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-            break;
-        case 1: // BYTE
-            any <<= static_cast< sal_Int8 >(file_->read8(off + 1));
-                //TODO: implementation-defined behavior of conversion from
-                // sal_uInt8 to sal_Int8 relies on two's complement
-                // representation
-            break;
-        case 2: // SHORT
-            any <<= static_cast< sal_Int16 >(file_->read16(off + 1));
-                //TODO: implementation-defined behavior of conversion from
-                // sal_uInt16 to sal_Int16 relies on two's complement
-                // representation
-            break;
-        case 3: // UNSIGNED SHORT
-            any <<= file_->read16(off + 1);
-            break;
-        case 4: // LONG
-            any <<= static_cast< sal_Int32 >(file_->read32(off + 1));
-                //TODO: implementation-defined behavior of conversion from
-                // sal_uInt32 to sal_Int32 relies on two's complement
-                // representation
-            break;
-        case 5: // UNSIGNED LONG
-            any <<= file_->read32(off + 1);
-            break;
-        case 6: // HYPER
-            any <<= static_cast< sal_Int64 >(file_->read64(off + 1));
-                //TODO: implementation-defined behavior of conversion from
-                // sal_uInt64 to sal_Int64 relies on two's complement
-                // representation
-            break;
-        case 7: // UNSIGNED HYPER
-            any <<= file_->read64(off + 1);
-            break;
-        case 8: // FLOAT
-            any <<= file_->readIso60599Binary32(off + 1);
-            break;
-        case 9: // DOUBLE
-            any <<= file_->readIso60599Binary64(off + 1);
-            break;
-        default:
-            throw css::uno::DeploymentException(
-                ("broken UNOIDL file: bad constant type byte "
-                 + rtl::OUString::number(v)),
-                css::uno::Reference< css::uno::XInterface >());
-        }
         return css::uno::makeAny<
             css::uno::Reference< css::reflection::XTypeDescription > >(
-                new ConstantDescription(aName, any));
+                new ConstantDescription(aName, provider_->getConstant(off)));
     } else {
-        int v = file_->read8(off);
-        int type = v & 0x3F;
-        bool published = (v & 0x80) != 0;
-        bool deprecated = (v & 0x40) != 0; (void)deprecated;//TODO
-        bool flag = (v & 0x20) != 0;
-        switch (type) {
-        case 0: // module
-            {
-                if (v != 0) {
-                    throw css::uno::DeploymentException(
-                        ("broken UNOIDL file: bad module type byte "
-                         + rtl::OUString::number(v)),
-                        css::uno::Reference< css::uno::XInterface >());
-                }
-                sal_uInt32 n = file_->read32(off + 1);
-                if (n > SAL_MAX_INT32) {
-                    throw css::uno::DeploymentException(
-                        ("broken UNOIDL file: too many items in module "
-                         + aName),
-                        css::uno::Reference< css::uno::XInterface >());
-                }
-                off += 5;
-                std::vector< rtl::OUString > items;
-                for (sal_uInt32 i = 0; i != n; ++i) {
-                    items.push_back(file_->readNameNul(file_->read32(off)));
-                    off += 8;
-                }
-                return css::uno::makeAny<
-                    css::uno::Reference< css::reflection::XTypeDescription > >(
-                        new ModuleDescription(context_, aName, items));
-            }
-        case 1: // enum type
-            {
-                sal_uInt32 n = file_->read32(off + 1);
-                if (n > SAL_MAX_INT32) {
-                    throw css::uno::DeploymentException(
-                        ("broken UNOIDL file: too many members of enum type "
-                         + aName),
-                        css::uno::Reference< css::uno::XInterface >());
-                }
-                off += 5;
-                std::vector< EnumTypeDescription::Member > mems;
-                for (sal_uInt32 i = 0; i != n; ++i) {
-                    rtl::OUString memName(file_->readNameLen(off, &off));
-                    sal_Int32 memValue = static_cast< sal_Int32 >(
-                        file_->read32(off));
-                        //TODO: implementation-defined behavior of conversion
-                        // from sal_uInt32 to sal_Int32 relies on two's
-                        // complement representation
-                    off += 4;
-                    mems.push_back(
-                        EnumTypeDescription::Member(memName, memValue));
-                }
-                return css::uno::makeAny<
-                    css::uno::Reference< css::reflection::XTypeDescription > >(
-                        new EnumTypeDescription(aName, published, mems));
-            }
-        case 2: // plain struct type without base
-        case 2 | 0x20: // plain struct type with base
-            {
-                ++off;
-                rtl::OUString base;
-                if (flag) {
-                    base = file_->readNameLen(off, &off);
-                    if (base.isEmpty()) {
-                        throw css::uno::DeploymentException(
-                            ("broken UNOIDL file: empty base type name of plain"
-                             " struct type " + aName),
-                            css::uno::Reference< css::uno::XInterface >());
-                    }
-                }
-                sal_uInt32 n = file_->read32(off);
-                if (n > SAL_MAX_INT32) {
-                    throw css::uno::DeploymentException(
-                        ("broken UNOIDL file: too many direct members of plain"
-                         " struct type " + aName),
-                        css::uno::Reference< css::uno::XInterface >());
-                }
-                off += 4;
-                std::vector< PlainStructTypeDescription::Member > mems;
-                for (sal_uInt32 i = 0; i != n; ++i) {
-                    rtl::OUString memName(file_->readNameLen(off, &off));
-                    rtl::OUString memType(file_->readNameLen(off, &off));
-                    mems.push_back(
-                        PlainStructTypeDescription::Member(memName, memType));
-                }
-                return css::uno::makeAny<
-                    css::uno::Reference< css::reflection::XTypeDescription > >(
-                        new PlainStructTypeDescription(
-                            context_, aName, published, base, mems));
-            }
-        case 3: // polymorphic struct type template
-            {
-                sal_uInt32 n = file_->read32(off + 1);
-                if (n > SAL_MAX_INT32) {
-                    throw css::uno::DeploymentException(
-                        ("broken UNOIDL file: too many type parameters of"
-                         " polymorphic struct type template " + aName),
-                        css::uno::Reference< css::uno::XInterface >());
-                }
-                off += 5;
-                std::vector< rtl::OUString > params;
-                for (sal_uInt32 i = 0; i != n; ++i) {
-                    params.push_back(file_->readNameLen(off, &off));
-                }
-                n = file_->read32(off);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list