Kaydet (Commit) 0557453a authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Combine getSortResolve...() into one decompose()

Change-Id: Ie1c1311d1df14d5639b7642d2b9a1588605c31fc
üst 9fb856ce
...@@ -87,12 +87,9 @@ public: ...@@ -87,12 +87,9 @@ public:
OUString const & name, rtl::Reference< unoidl::Entity > * entity = 0, OUString const & name, rtl::Reference< unoidl::Entity > * entity = 0,
rtl::Reference< unoidl::MapCursor > * cursor = 0) const; rtl::Reference< unoidl::MapCursor > * cursor = 0) const;
codemaker::UnoType::Sort getSortResolveOuterSequences( codemaker::UnoType::Sort decompose(
OUString const & name, OUString * nucleus, sal_Int32 * rank) const; OUString const & name, bool resolveTypedefs, OUString * nucleus,
sal_Int32 * rank, std::vector< OUString > * arguments,
codemaker::UnoType::Sort getSortResolveAllSequencesTemplatesTypedefs(
OUString const & name, OUString * nucleus, sal_Int32 * rank,
std::vector< OUString > * arguments,
rtl::Reference< unoidl::Entity > * entity) const; rtl::Reference< unoidl::Entity > * entity) const;
private: private:
......
...@@ -445,71 +445,36 @@ codemaker::UnoType::Sort TypeManager::getSort( ...@@ -445,71 +445,36 @@ codemaker::UnoType::Sort TypeManager::getSort(
} }
} }
codemaker::UnoType::Sort TypeManager::getSortResolveOuterSequences( codemaker::UnoType::Sort TypeManager::decompose(
OUString const & name, OUString * nucleus, sal_Int32 * rank) const OUString const & name, bool resolveTypedefs, OUString * nucleus,
{ sal_Int32 * rank, std::vector< OUString > * arguments,
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,
rtl::Reference< unoidl::Entity > * entity) const rtl::Reference< unoidl::Entity > * entity) const
{ {
assert(nucleus != 0); sal_Int32 k;
assert(rank != 0);
assert(arguments != 0);
arguments->clear();
std::vector< OString > args; std::vector< OString > args;
*nucleus = b2u(codemaker::UnoType::decompose(u2b(name), rank, &args)); OUString n = b2u(codemaker::UnoType::decompose(u2b(name), &k, &args));
for (;;) { for (;;) {
rtl::Reference< unoidl::Entity > ent; rtl::Reference< unoidl::Entity > ent;
codemaker::UnoType::Sort s = getSort(*nucleus, &ent); codemaker::UnoType::Sort s = getSort(n, &ent);
if (args.empty() if (args.empty()
!= (s != codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE)) != (s != codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE))
{ {
throw CannotDumpException( throw CannotDumpException(
"syntax error, \"" + *nucleus + "\" resolved from \"" "template arguments mismatch for \"" + n
+ name + "\""); + "\" resolved from \"" + name + "\"");
} }
switch (s) { 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_VOID:
case codemaker::UnoType::SORT_BOOLEAN: case codemaker::UnoType::SORT_BOOLEAN:
case codemaker::UnoType::SORT_BYTE: case codemaker::UnoType::SORT_BYTE:
...@@ -528,37 +493,55 @@ TypeManager::getSortResolveAllSequencesTemplatesTypedefs( ...@@ -528,37 +493,55 @@ TypeManager::getSortResolveAllSequencesTemplatesTypedefs(
case codemaker::UnoType::SORT_ENUM_TYPE: case codemaker::UnoType::SORT_ENUM_TYPE:
case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE: case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
case codemaker::UnoType::SORT_INTERFACE_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) { if (entity != 0) {
*entity = ent; *entity = ent;
} }
return s; return s;
case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE: case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
if (entity != 0) { if (args.size()
*entity = ent; != (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()); for (std::vector< OString >::iterator i(args.begin());
i != args.end(); ++i) i != args.end(); ++i)
{ {
arguments->push_back(b2u(*i)); arguments->push_back(b2u(*i));
} }
}
if (entity != 0) {
*entity = ent;
}
return return
codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE; 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: case codemaker::UnoType::SORT_SEQUENCE_TYPE:
assert(false); // this cannot happen assert(false); // this cannot happen
// fall through // fall through
default: default:
throw CannotDumpException( throw CannotDumpException(
"unexpected \"" + *nucleus + "\" resolved from \"" + name "unexpected \"" + n + "\" resolved from \"" + name
+ ("\"in call to TypeManager::" + ("\"in call to TypeManager::decompose"));
"getSortResolveAllSequencesTemplatesTypedefs"));
} }
} }
} }
......
...@@ -74,8 +74,7 @@ void appendUnoName( ...@@ -74,8 +74,7 @@ void appendUnoName(
OUString n; OUString n;
sal_Int32 k; sal_Int32 k;
std::vector< OUString > args; std::vector< OUString > args;
manager->getSortResolveAllSequencesTemplatesTypedefs( manager->decompose(*i, false, &n, &k, &args, 0);
*i, &n, &k, &args, 0);
appendUnoName(manager, n, k, args, buffer); appendUnoName(manager, n, k, args, buffer);
} }
buffer->append('>'); buffer->append('>');
...@@ -284,9 +283,8 @@ SpecialType translateUnoTypeToDescriptor( ...@@ -284,9 +283,8 @@ SpecialType translateUnoTypeToDescriptor(
OUString nucleus; OUString nucleus;
sal_Int32 rank; sal_Int32 rank;
std::vector< OUString > args; std::vector< OUString > args;
codemaker::UnoType::Sort sort = manager-> codemaker::UnoType::Sort sort = manager->decompose(
getSortResolveAllSequencesTemplatesTypedefs( type, true, &nucleus, &rank, &args, 0);
type, &nucleus, &rank, &args, 0);
return translateUnoTypeToDescriptor( return translateUnoTypeToDescriptor(
manager, sort, nucleus, rank, args, array, classType, dependencies, manager, sort, nucleus, rank, args, array, classType, dependencies,
descriptor, signature, needsSignature, polymorphicUnoType); descriptor, signature, needsSignature, polymorphicUnoType);
...@@ -897,9 +895,8 @@ sal_uInt16 addFieldInit( ...@@ -897,9 +895,8 @@ sal_uInt16 addFieldInit(
sal_Int32 rank; sal_Int32 rank;
std::vector< rtl::OUString > args; std::vector< rtl::OUString > args;
rtl::Reference< unoidl::Entity > ent; rtl::Reference< unoidl::Entity > ent;
codemaker::UnoType::Sort sort codemaker::UnoType::Sort sort = manager->decompose(
= manager->getSortResolveAllSequencesTemplatesTypedefs( fieldType, true, &nucleus, &rank, &args, &ent);
fieldType, &nucleus, &rank, &args, &ent);
if (rank == 0) { if (rank == 0) {
switch (sort) { switch (sort) {
case codemaker::UnoType::SORT_BOOLEAN: case codemaker::UnoType::SORT_BOOLEAN:
...@@ -1023,9 +1020,8 @@ sal_uInt16 addLoadLocal( ...@@ -1023,9 +1020,8 @@ sal_uInt16 addLoadLocal(
OUString nucleus; OUString nucleus;
sal_Int32 rank; sal_Int32 rank;
std::vector< OUString > args; std::vector< OUString > args;
codemaker::UnoType::Sort sort = manager-> codemaker::UnoType::Sort sort = manager->decompose(
getSortResolveAllSequencesTemplatesTypedefs( type, true, &nucleus, &rank, &args, 0);
type, &nucleus, &rank, &args, 0);
if (rank == 0) { if (rank == 0) {
switch (sort) { switch (sort) {
case codemaker::UnoType::SORT_BOOLEAN: case codemaker::UnoType::SORT_BOOLEAN:
...@@ -1928,9 +1924,7 @@ void handleTypedef( ...@@ -1928,9 +1924,7 @@ void handleTypedef(
assert(manager.is()); assert(manager.is());
assert(dependencies != 0); assert(dependencies != 0);
OUString nucleus; OUString nucleus;
sal_Int32 rank; switch (manager->decompose(entity->getType(), false, &nucleus, 0, 0, 0))
switch (manager->getSortResolveOuterSequences(
entity->getType(), &nucleus, &rank))
{ {
case codemaker::UnoType::SORT_BOOLEAN: case codemaker::UnoType::SORT_BOOLEAN:
case codemaker::UnoType::SORT_BYTE: case codemaker::UnoType::SORT_BYTE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment