summaryrefslogtreecommitdiff
path: root/codemaker
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-04-12 15:21:37 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-04-12 15:22:11 +0200
commit0557453a35863310f34e6c10facbac63bc89837d (patch)
tree95731252de1946090f746ea30a530264ed5f10e8 /codemaker
parent9fb856ce844f2a4e794687c00ad6f0f75ef223c1 (diff)
Combine getSortResolve...() into one decompose()
Change-Id: Ie1c1311d1df14d5639b7642d2b9a1588605c31fc
Diffstat (limited to 'codemaker')
-rw-r--r--codemaker/inc/codemaker/typemanager.hxx9
-rw-r--r--codemaker/source/codemaker/typemanager.cxx123
-rw-r--r--codemaker/source/javamaker/javatype.cxx22
3 files changed, 64 insertions, 90 deletions
diff --git a/codemaker/inc/codemaker/typemanager.hxx b/codemaker/inc/codemaker/typemanager.hxx
index 0d3769319982..48e59897a2e7 100644
--- a/codemaker/inc/codemaker/typemanager.hxx
+++ b/codemaker/inc/codemaker/typemanager.hxx
@@ -87,12 +87,9 @@ public:
OUString const & name, rtl::Reference< unoidl::Entity > * entity = 0,
rtl::Reference< unoidl::MapCursor > * cursor = 0) const;
- codemaker::UnoType::Sort getSortResolveOuterSequences(
- OUString const & name, OUString * nucleus, sal_Int32 * rank) const;
-
- codemaker::UnoType::Sort getSortResolveAllSequencesTemplatesTypedefs(
- OUString const & name, OUString * nucleus, sal_Int32 * rank,
- std::vector< OUString > * arguments,
+ codemaker::UnoType::Sort decompose(
+ OUString const & name, bool resolveTypedefs, OUString * nucleus,
+ sal_Int32 * rank, std::vector< OUString > * arguments,
rtl::Reference< unoidl::Entity > * entity) const;
private:
diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx
index 027eae27446f..e07b55370108 100644
--- a/codemaker/source/codemaker/typemanager.cxx
+++ b/codemaker/source/codemaker/typemanager.cxx
@@ -445,71 +445,36 @@ codemaker::UnoType::Sort TypeManager::getSort(
}
}
-codemaker::UnoType::Sort TypeManager::getSortResolveOuterSequences(
- OUString const & name, OUString * nucleus, sal_Int32 * rank) const
-{
- assert(nucleus != 0);
- assert(rank != 0);
- *nucleus = name;
- *rank = 0;
- while (nucleus->startsWith("[]")) {
- ++rank;
- *nucleus = nucleus->copy(std::strlen("[]"));
- }
- codemaker::UnoType::Sort s = getSort(*nucleus);
- switch (s) {
- case codemaker::UnoType::SORT_BOOLEAN:
- case codemaker::UnoType::SORT_BYTE:
- case codemaker::UnoType::SORT_SHORT:
- case codemaker::UnoType::SORT_UNSIGNED_SHORT:
- case codemaker::UnoType::SORT_LONG:
- case codemaker::UnoType::SORT_UNSIGNED_LONG:
- case codemaker::UnoType::SORT_HYPER:
- case codemaker::UnoType::SORT_UNSIGNED_HYPER:
- case codemaker::UnoType::SORT_FLOAT:
- case codemaker::UnoType::SORT_DOUBLE:
- case codemaker::UnoType::SORT_CHAR:
- case codemaker::UnoType::SORT_STRING:
- case codemaker::UnoType::SORT_TYPE:
- case codemaker::UnoType::SORT_ANY:
- case codemaker::UnoType::SORT_ENUM_TYPE:
- case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
- case codemaker::UnoType::SORT_INTERFACE_TYPE:
- case codemaker::UnoType::SORT_TYPEDEF:
- return s;
- case codemaker::UnoType::SORT_SEQUENCE_TYPE:
- assert(false); // this cannot happen
- // fall through
- default:
- throw CannotDumpException(
- "unexpected \"" + *nucleus + "\" resolved from \"" + name
- + "\"in call to TypeManager::getSortResolveOuterSequences");
- }
-}
-
-codemaker::UnoType::Sort
-TypeManager::getSortResolveAllSequencesTemplatesTypedefs(
- OUString const & name, OUString * nucleus, sal_Int32 * rank,
- std::vector< OUString > * arguments,
+codemaker::UnoType::Sort TypeManager::decompose(
+ OUString const & name, bool resolveTypedefs, OUString * nucleus,
+ sal_Int32 * rank, std::vector< OUString > * arguments,
rtl::Reference< unoidl::Entity > * entity) const
{
- assert(nucleus != 0);
- assert(rank != 0);
- assert(arguments != 0);
- arguments->clear();
+ sal_Int32 k;
std::vector< OString > args;
- *nucleus = b2u(codemaker::UnoType::decompose(u2b(name), rank, &args));
+ OUString n = b2u(codemaker::UnoType::decompose(u2b(name), &k, &args));
for (;;) {
rtl::Reference< unoidl::Entity > ent;
- codemaker::UnoType::Sort s = getSort(*nucleus, &ent);
+ codemaker::UnoType::Sort s = getSort(n, &ent);
if (args.empty()
!= (s != codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE))
{
throw CannotDumpException(
- "syntax error, \"" + *nucleus + "\" resolved from \""
- + name + "\"");
+ "template arguments mismatch for \"" + n
+ + "\" resolved from \"" + name + "\"");
}
switch (s) {
+ case codemaker::UnoType::SORT_TYPEDEF:
+ if (resolveTypedefs) {
+ n = dynamic_cast< unoidl::TypedefEntity * >(ent.get())->
+ getType();
+ while (n.startsWith("[]")) {
+ ++k; //TODO: overflow
+ n = n.copy(std::strlen("[]"));
+ }
+ break;
+ }
+ // fall through
case codemaker::UnoType::SORT_VOID:
case codemaker::UnoType::SORT_BOOLEAN:
case codemaker::UnoType::SORT_BYTE:
@@ -528,37 +493,55 @@ TypeManager::getSortResolveAllSequencesTemplatesTypedefs(
case codemaker::UnoType::SORT_ENUM_TYPE:
case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
case codemaker::UnoType::SORT_INTERFACE_TYPE:
+ if (nucleus != 0) {
+ *nucleus = n;
+ }
+ if (rank != 0) {
+ *rank = k;
+ }
+ if (arguments != 0) {
+ arguments->clear();
+ }
if (entity != 0) {
*entity = ent;
}
return s;
case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
+ if (args.size()
+ != (dynamic_cast<
+ unoidl::PolymorphicStructTypeTemplateEntity * >(ent.get())->
+ getTypeParameters().size()))
+ {
+ throw CannotDumpException(
+ "bad number of template arguments for \"" + n
+ + "\" resolved from \"" + name + "\"");
+ }
+ if (nucleus != 0) {
+ *nucleus = n;
+ }
+ if (rank != 0) {
+ *rank = k;
+ }
+ if (arguments != 0) {
+ arguments->clear();
+ for (std::vector< OString >::iterator i(args.begin());
+ i != args.end(); ++i)
+ {
+ arguments->push_back(b2u(*i));
+ }
+ }
if (entity != 0) {
*entity = ent;
}
- for (std::vector< OString >::iterator i(args.begin());
- i != args.end(); ++i)
- {
- arguments->push_back(b2u(*i));
- }
return
codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE;
- case codemaker::UnoType::SORT_TYPEDEF:
- *nucleus = dynamic_cast< unoidl::TypedefEntity * >(ent.get())->
- getType();
- while (nucleus->startsWith("[]")) {
- ++*rank; //TODO: overflow
- *nucleus = nucleus->copy(std::strlen("[]"));
- }
- break;
case codemaker::UnoType::SORT_SEQUENCE_TYPE:
assert(false); // this cannot happen
// fall through
default:
throw CannotDumpException(
- "unexpected \"" + *nucleus + "\" resolved from \"" + name
- + ("\"in call to TypeManager::"
- "getSortResolveAllSequencesTemplatesTypedefs"));
+ "unexpected \"" + n + "\" resolved from \"" + name
+ + ("\"in call to TypeManager::decompose"));
}
}
}
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
index 3766b71a4171..3bd6ef4cc6d9 100644
--- a/codemaker/source/javamaker/javatype.cxx
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -74,8 +74,7 @@ void appendUnoName(
OUString n;
sal_Int32 k;
std::vector< OUString > args;
- manager->getSortResolveAllSequencesTemplatesTypedefs(
- *i, &n, &k, &args, 0);
+ manager->decompose(*i, false, &n, &k, &args, 0);
appendUnoName(manager, n, k, args, buffer);
}
buffer->append('>');
@@ -284,9 +283,8 @@ SpecialType translateUnoTypeToDescriptor(
OUString nucleus;
sal_Int32 rank;
std::vector< OUString > args;
- codemaker::UnoType::Sort sort = manager->
- getSortResolveAllSequencesTemplatesTypedefs(
- type, &nucleus, &rank, &args, 0);
+ codemaker::UnoType::Sort sort = manager->decompose(
+ type, true, &nucleus, &rank, &args, 0);
return translateUnoTypeToDescriptor(
manager, sort, nucleus, rank, args, array, classType, dependencies,
descriptor, signature, needsSignature, polymorphicUnoType);
@@ -897,9 +895,8 @@ sal_uInt16 addFieldInit(
sal_Int32 rank;
std::vector< rtl::OUString > args;
rtl::Reference< unoidl::Entity > ent;
- codemaker::UnoType::Sort sort
- = manager->getSortResolveAllSequencesTemplatesTypedefs(
- fieldType, &nucleus, &rank, &args, &ent);
+ codemaker::UnoType::Sort sort = manager->decompose(
+ fieldType, true, &nucleus, &rank, &args, &ent);
if (rank == 0) {
switch (sort) {
case codemaker::UnoType::SORT_BOOLEAN:
@@ -1023,9 +1020,8 @@ sal_uInt16 addLoadLocal(
OUString nucleus;
sal_Int32 rank;
std::vector< OUString > args;
- codemaker::UnoType::Sort sort = manager->
- getSortResolveAllSequencesTemplatesTypedefs(
- type, &nucleus, &rank, &args, 0);
+ codemaker::UnoType::Sort sort = manager->decompose(
+ type, true, &nucleus, &rank, &args, 0);
if (rank == 0) {
switch (sort) {
case codemaker::UnoType::SORT_BOOLEAN:
@@ -1928,9 +1924,7 @@ void handleTypedef(
assert(manager.is());
assert(dependencies != 0);
OUString nucleus;
- sal_Int32 rank;
- switch (manager->getSortResolveOuterSequences(
- entity->getType(), &nucleus, &rank))
+ switch (manager->decompose(entity->getType(), false, &nucleus, 0, 0, 0))
{
case codemaker::UnoType::SORT_BOOLEAN:
case codemaker::UnoType::SORT_BYTE: